sgbitmap.h

Go to the documentation of this file.
00001 // $Id: sgbitmap.h 1664 2006-08-04 10:06:16Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // SGBitmap.h - the BitmapSGallery (Bitmap SuperGallery) class
00099 
00100 #ifndef INC_SGBASE
00101 #define INC_SGBASE
00102 
00103 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "dragbmp.h"
00106 #include "sgdrag.h"
00107 //#include "bmpsdlg.h"
00108 
00109 const INT32 SG_DefaultSmallBmp      = 64000;    
00110 const INT32 SG_DefaultSmallBmpText  = 80000;
00111 const INT32 SG_DefaultLargeBmp      = 96000;
00112 const INT32 SG_DefaultLargeBmpText  = 120000;
00113 
00114 class Bitmap;
00115 class KernelBitmap;
00116 class BmpDlgParam;
00117 class SGDisplayKernelBitmap;
00118 
00119 /********************************************************************************************
00120 
00121 >   class GalleryBitmapDragInfo : public BitmapDragInformation
00122 
00123     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    19/3/95
00125     Purpose:    A bitmap drag, which was started from the bitmap gallery
00126     SeeAlso:    BitmapDragInformation
00127                 
00128 ********************************************************************************************/
00129 
00130 class GalleryBitmapDragInfo : public BitmapDragInformation
00131 { 
00132     CC_DECLARE_DYNCREATE(GalleryBitmapDragInfo)
00133  
00134 public:
00135     GalleryBitmapDragInfo();
00136     GalleryBitmapDragInfo(  SGDisplayKernelBitmap *pSourceItem,
00137                             SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo,
00138                             BOOL IsAdjust = FALSE);
00139     ~GalleryBitmapDragInfo();
00140 
00141     virtual void OnClick(INT32 Flags, POINT Point);
00142 
00143     virtual UINT32 GetCursorID(DragTarget* pDragTarget);
00144     virtual BOOL GetStatusLineText(String_256 * TheText, DragTarget* pDragTarget);
00145 
00146     virtual BOOL CanDropOnPage() { return TRUE; }
00147     virtual BOOL OnPageDrop(ViewDragTarget*);
00148 
00149     SGDisplayKernelBitmap*  GetDraggedBitmap()  { return(SourceItem); }
00150 
00151 protected:
00152     SGDisplayKernelBitmap*  SourceItem;
00153     SGMouseInfo             MouseInfo;
00154     SGMiscInfo              MiscInfo;
00155 };
00156 
00157 /*********************************************************************************************
00158 
00159 >   class   SGBitmapDragTarget : public SGListDragTarget
00160 
00161     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00162     Created:    25/3/95
00163 
00164     Purpose:    An instantiation of this class is created by each entity which wishes to 
00165                 provide a 'destination' to which the mouse can go to complete a drag.
00166 
00167                 This particular target is used for handling drags of BitmapSGalllery items
00168                 within their displayed list. It automatically handles drags with draginfo
00169                 derived from BitmapDragInformation.
00170 
00171     Notes:      Drag targets are destructed automatically when a drag finishes by the drag
00172                 manager with which they were registered.
00173 
00174                 To remove a drag target at any time, destruct it - it automatically deregisters
00175                 and cleans up.
00176                 
00177     SeeAlso:    DragManagerOp::StartDrag; DragInformation; DragTarget;
00178                 SGBitmapDragTarget::ProcessEvent
00179 
00180     Documentation:  Docs\Specs\DragMan.doc; Docs\HowToUse\SGallery.doc
00181 
00182 *********************************************************************************************/
00183 
00184 class SGBitmapDragTarget : public SGListDragTarget
00185 {
00186 friend class DragManagerOp;
00187     
00188 CC_DECLARE_DYNAMIC(SGBitmapDragTarget)
00189 
00190 public: // Public interface
00191     SGBitmapDragTarget(DialogOp *TheDialog, CGadgetID TheGadget = NULL);
00192 
00193 protected:
00194         // Process a drag-related event
00195     virtual BOOL ProcessEvent(DragEventType Event,
00196                                 DragInformation *pDragInfo,
00197                                 OilCoord *pMousePos, KeyPress* pKeyPress);
00198 };
00199 
00200 /***********************************************************************************************
00201 
00202 >   class SGDisplayKernelBitmap : public SGDisplayItem
00203 
00204     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00205     Created:    27/01/95
00206     Purpose:    This DisplayTree node is used by the Bitmap SuperGallery
00207                 It is responsible for providing the ability to handle/redraw one KernelBitmap
00208                 displayed in said gallery.
00209 
00210     SeeAlso:    BitmapSGallery; SuperGallery; SGDisplayItem
00211 
00212 ***********************************************************************************************/
00213 
00214 class CCAPI SGDisplayKernelBitmap : public SGDisplayItem
00215 {
00216     CC_DECLARE_DYNAMIC(SGDisplayKernelBitmap);
00217 
00218 public:
00219     SGDisplayKernelBitmap();
00220     SGDisplayKernelBitmap(KernelBitmap *KernelBitmapToDisplay);
00221 
00222     virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo,
00223                              SGMiscInfo *MiscInfo);
00224 
00225     virtual void DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo);
00226         // Special handler called by GalleryColourDragInfo when a drag turns out to be a click
00227 
00228     virtual void GetNameText(String_256 *Result);
00229     virtual void GetFullInfoText(String_256 *Result);
00230         // Read the name and full-information text for this item
00231 
00232     virtual void MoveAfter(SGDisplayNode *NodeToMove);
00233     virtual void MoveBefore(SGDisplayNode *NodeToMove);
00234         // Move items around in the tree, and also move the original in the bitmap list
00235 
00236     // Status line help for bitmap item
00237     virtual BOOL GetStatusLineHelp(DocCoord *MousePos, String_256 *Result);
00238 
00239 protected:  // Internal handlers
00240     virtual void CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo);
00241             // Determines item size for the current DisplayMode and calculates FormatRect
00242 
00243     virtual void HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo);
00244             // Redraws the item into the current FormatRect
00245 
00246 public:     // Specialisations of this class
00247     inline KernelBitmap *GetDisplayedKernelBitmap(void);
00248 
00249 
00250 private:        // Special member variables
00251     KernelBitmap *TheKernelBitmap;
00252 };
00253 
00254 
00255 
00256 /********************************************************************************************
00257 
00258 >   inline KernelBitmap *SGDisplayKernelBitmap::GetDisplayedKernelBitmap(void)
00259 
00260     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00261     Created:    27/1/95
00262 
00263     Returns:    A pointer to the KernelBitmap which this Display Item is used to display.
00264             
00265     Purpose:    To find out the KernelBitmap this object is responsible for displaying
00266 
00267 ********************************************************************************************/
00268 
00269 KernelBitmap *SGDisplayKernelBitmap::GetDisplayedKernelBitmap(void)
00270 {
00271     return(TheKernelBitmap);
00272 }
00273 
00274 
00275 
00276 
00277 
00278 
00279 /***********************************************************************************************
00280 
00281 >   class BitmapSGallery : public SuperGallery
00282 
00283     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00284     Created:    27/1/95 (Based on the Colour SGallery code)
00285     Purpose:    The Bitmap SuperGallery class
00286 
00287     Notes:      SuperGalleries are specced in a number of docs including
00288                     specs\sgallery.doc ("super" gallery extensions)
00289                     specs\propui.doc  (gallery basic ui)
00290                 There is also howtouse\sgallery.doc which describes creating a supergallery
00291 
00292     SeeAlso:    SuperGallery; SGDisplayBitmap
00293 
00294 ***********************************************************************************************/
00295 
00296 class BitmapSGallery : public SuperGallery
00297 {
00298     CC_DECLARE_DYNCREATE(BitmapSGallery)
00299 
00300 public:
00301     BitmapSGallery();
00302     ~BitmapSGallery();
00303 
00304     virtual MsgResult Message(Msg* Message);
00305     virtual void SelectionHasChanged(void);
00306 
00307     virtual SGDisplayItem *CopyDisplayItem(SGDisplayItem *SourceItem, 
00308                                 SGDisplayGroup *DestGroup,
00309                                 SGDisplayItem *TargetPosition = NULL);
00310         // Asks the gallery to copy (or if appropriate, move) the given item to
00311         // the given group. This hould be done by copying the given item, and
00312         // then calling InsertCopiedItem() to insert it appropriately (see above)
00313 
00314 protected:              // Overridden upcall methods
00315     virtual BOOL PreCreate(void);
00316 
00317     virtual BOOL ApplyAction(SGActionType Action);
00318 
00319     virtual void HandleDragStart(DragMessage *DragMsg);
00320 
00321     virtual RenderRegion *CreateRenderRegion(DocRect *VirtualSize,
00322                                             ReDrawInfoType *DlgRedrawInfo);
00323 
00324     virtual void DestroyRenderRegion(RenderRegion *pRender);
00325 
00326     virtual void DoShadeGallery(BOOL ShadeIt);
00327         // Called by SuperGallery::ShadeGallery to allow the derived gallery to add code
00328         // to shade/unshade any extra controls it may have in the window
00329 
00330 public:                 // Overridden Command interface (for Ops and menu support)
00331     virtual BOOL PreContextMenu(void);
00332         // Give the gallery a chance to do something before popping up the context menu
00333         // At present, used by the bitmap gallery to ensure that the plug-ins have all
00334         // been parsed.
00335 
00336     virtual BOOL InitMenuCommands(void);
00337         // Called on startup to initialise any desired menu commands. Will make repeated calls
00338         // to InitMenuCommand(), below.
00339 
00340     virtual BOOL BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID);
00341         // Builds the command menu for the given menu pop-up (over an item, or options button)
00342 
00343     virtual OpState GetCommandState(StringBase *CommandID, String_256 *ShadeReason);
00344         // Returns an OpState indicating the state of this command, much like an Op GetState
00345 
00346     virtual void DoCommand(StringBase *CommandID);
00347         // Attempts to "do" the given command. Should call down to the base class to handle
00348         // any commands it can't deal with.
00349 
00350 
00351 protected:              // Personal/Internal methods
00352     void CreateNewSubtree(Document *ParentDoc, SGDisplayGroup *ExistingGroup = NULL);
00353             // Creates a new subtree group to display the Bitmaps for the given document
00354             // If ExistingGroup != NULL, that group will be re-cached for the given doc
00355 
00356     KernelBitmap* GetSelectedBitmap();
00357     BOOL GetSelectedBitmaps(KernelBitmap*** pOutputArray, UINT32* pOutputCount);
00358 public:
00359     BOOL HasDelayValueChanged ();
00360     //BOOL AreDelayValuesSame();
00361     //UINT32 GetBitmapDelay();
00362     BOOL IsJPEG(KernelBitmap** pList,UINT32 ListSize, BmpDlgParam* Param, INT32* pBytes);
00363     
00364 protected:
00365     BOOL DeleteSelection();
00366 
00367     KernelBitmap* CheckTextureBitmap(KernelBitmap* pBitmap);
00368 
00369     BOOL FindCentreInsertionPosition(Spread** Spread, DocCoord* Position);
00370 
00371     void SetSelectionFromDocument(BOOL AlwaysScroll = FALSE);
00372 
00373     BOOL GetBmpInfo(BmpDlgParam* Param);
00374     BOOL SetBmpInfo(BmpDlgParam* Param);
00375 
00376 public:
00377     static BOOL IgnoreBmpListChange;
00378 };
00379 
00380 //-------------------------------------------------------------------------------
00381 //-------------------------------------------------------------------------------
00382 //-------------------------------------------------------------------------------
00383 //-------------------------------------------------------------------------------
00384 
00385 // Optoken for the display bitmap gallery operation
00386 #define OPTOKEN_DISPLAYBITMAPGALLERY _T("DisplayBitmapGallery") 
00387 
00388 /********************************************************************************************
00389 
00390 >   class OpDisplayBitmapGallery: public Operation
00391 
00392     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00393     Created:    31/1/95
00394     Purpose:    Displays the bitmap gallery. This op can be attached to a menu, button or keypress
00395     SeeAlso:    -
00396 
00397 ********************************************************************************************/
00398 
00399 class CCAPI OpDisplayBitmapGallery: public Operation
00400 {         
00401     CC_DECLARE_DYNCREATE( OpDisplayBitmapGallery );
00402 
00403 public:
00404     static BOOL     Init();             
00405     static OpState  GetState(String_256*, OpDescriptor*);       
00406     void            Do(OpDescriptor*);  
00407 };  
00408 
00409 #endif
00410 

Generated on Sat Nov 10 03:46:50 2007 for Camelot by  doxygen 1.4.4