sglayer.h

Go to the documentation of this file.
00001 // $Id: sglayer.h 1282 2006-06-09 09:46:49Z alex $
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 // SGLayer.h - the LayerSGallery (Layer SuperGallery) class
00099 
00100 
00101 #ifndef INC_SGLAYER
00102 #define INC_SGLAYER
00103 
00104 
00105 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 #include "layergal.h"
00109 
00110 class DocView;
00111 class Layer;
00112 
00113 // WEBSTER - markn 15/1/97
00114 // Don't need this gallery in Webster
00115 // Only need the bits left by ralph
00116 //#ifdef WEBSTER
00117 //  #ifndef EXCLUDE_GALS
00118 //      #define UNDEF_EXCLUDE_GALS  // Remember to undefine EXCLUDE_GALS at the end
00119 //      #define EXCLUDE_GALS
00120 //  #endif
00121 //#endif
00122 
00123 #ifndef EXCLUDE_GALS
00124 /***********************************************************************************************
00125 
00126 >   class SGDisplayLayer : public SGDisplayItem
00127 
00128     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00129     Created:    27/01/95
00130     Purpose:    This DisplayTree node is used by the Layer SuperGallery
00131                 It is responsible for providing the ability to handle/redraw one Layer
00132                 displayed in said gallery.
00133 
00134     SeeAlso:    LayerSGallery; SuperGallery; SGDisplayItem
00135 
00136 ***********************************************************************************************/
00137 
00138 class CCAPI SGDisplayLayer : public SGDisplayItem
00139 {
00140 friend class SGLayerGroup;      // Allows access to CalculateButtonRects
00141 
00142     CC_DECLARE_DYNAMIC(SGDisplayLayer);
00143 
00144 public:
00145     SGDisplayLayer();
00146     SGDisplayLayer(Layer *LayerToDisplay);
00147     ~SGDisplayLayer();
00148 
00149     virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo,
00150                              SGMiscInfo *MiscInfo);
00151 
00152     // Functions that handle dragging of layers
00153     virtual void MoveBefore(SGDisplayNode *NodeToMove);
00154     virtual void MoveAfter(SGDisplayNode *NodeToMove);
00155     virtual void MoveLayer(SGDisplayNode *NodeToMove,BOOL Before,BOOL ToggleBackground);
00156 
00157 protected:  // Internal handlers
00158     virtual void CalculateMyRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo);
00159             // Determines item size for the current DisplayMode and calculates FormatRect
00160 
00161     static void CalculateButtonRects(SGMiscInfo *MiscInfo, DocRect *MyRect,
00162                                      DocRect *VisibleBtn, DocRect *LockedBtn, DocRect *SnapButton = NULL);
00163             // Chops off two (three) button rects from the given 'myrect'
00164 
00165     virtual void HandleRedraw(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo);
00166             // Redraws the item into the current FormatRect
00167 
00168     virtual void DoChangeState(OpLayerGalReason Reason,BOOL NewState);
00169             // Changes the state of the layer this object displays, in some way
00170 
00171     virtual void ChangeRangeState(SGDisplayLayer *Start, SGDisplayLayer *End,
00172                                   BOOL Range, INT32 WhichButton, SGMiscInfo *MiscInfo);
00173             // Changes the state (visible or locked) of a range of layers
00174 
00175 
00176 public:     // Specialisations of this class
00177     inline Layer *GetDisplayedLayer(void);
00178 
00179 
00180 protected:      // Special member variables (Used to be private but needed by SGDisplayFrame)
00181     Layer *TheLayer;
00182 
00183 private:        // Special member variables
00184     static SGDisplayLayer *LastClickedLayer;        // Remembers the last layer clicked on (for shift-clicks)
00185 };
00186 
00187 
00188 
00189 /***********************************************************************************************
00190 
00191 >   class SGLayerGroup : public SGDisplayGroup
00192 
00193     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00194     Created:    1/2/95
00195     Purpose:    This is a display tree group specifically for the layer gallery - it disables
00196                 group things like folding, and provides column headings for the layers display.
00197     SeeAlso:    SuperGallery; SGDisplayGroup;
00198 
00199 ***********************************************************************************************/
00200 
00201 
00202 class CCAPI SGLayerGroup : public SGDisplayGroup
00203 {
00204     CC_DECLARE_DYNAMIC(SGLayerGroup);
00205 
00206 public:
00207     SGLayerGroup(SuperGallery *ParentGal,
00208                     Document *ParentDoc = NULL, Library *ParentLib = NULL, BOOL IsForeground = TRUE);
00209 
00210     virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo,
00211                              SGMiscInfo *MiscInfo);
00212         // Handles a display list event (redraw, mouse click, etc)
00213 
00214     // Is this group the foreground layer group (TRUE) or the background layer group (FALSE)
00215     BOOL IsForeground() { return Foreground; }
00216 
00217 private:
00218     BOOL Foreground;
00219 };
00220 
00221 
00222 
00223 
00224 /********************************************************************************************
00225 
00226 >   inline Layer *SGDisplayLayer::GetDisplayedLayer(void)
00227 
00228     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00229     Created:    27/1/95
00230 
00231     Returns:    A pointer to the Layer which this Display Item is used to display.
00232             
00233     Purpose:    To find out the Layer this object is responsible for displaying
00234 
00235 ********************************************************************************************/
00236 
00237 Layer *SGDisplayLayer::GetDisplayedLayer(void)
00238 {
00239     return(TheLayer);
00240 }
00241 
00242 
00243 
00244 #endif
00245 
00246 
00247 /***********************************************************************************************
00248 
00249 >   class LayerSGallery : public SuperGallery
00250 
00251     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00252     Created:    27/1/95 (Based on the Colour SGallery code)
00253     Purpose:    The Layer SuperGallery class
00254 
00255     Notes:      SuperGalleries are specced in a number of docs including
00256                     specs\sgallery.doc ("super" gallery extensions)
00257                     specs\propui.doc  (gallery basic ui)
00258                 There is also howtouse\sgallery.doc which describes creating a supergallery
00259 
00260     SeeAlso:    SuperGallery; SGDisplayLayer
00261 
00262 ***********************************************************************************************/
00263 
00264 #ifdef EXCLUDE_GALS
00265 class LayerSGallery : public Operation
00266 #else
00267 class LayerSGallery : public SuperGallery
00268 #endif
00269 {
00270     CC_DECLARE_DYNCREATE(LayerSGallery)
00271 
00272 public:
00273     LayerSGallery();
00274     ~LayerSGallery();
00275 
00276 #ifndef EXCLUDE_GALS
00277     virtual MsgResult Message(Msg* Message);
00278 
00279 
00280 protected:              // Overridden upcall methods
00281     virtual BOOL PreCreate(void);
00282     virtual BOOL PostCreate(void);
00283 
00284     virtual BOOL ApplyAction(SGActionType Action);
00285 
00286     virtual void DoShadeGallery(BOOL ShadeIt);
00287 
00288     // handles the copying of items between groups via item drags
00289     virtual SGDisplayItem *CopyDisplayItem(SGDisplayItem *SourceItem, 
00290                                 SGDisplayGroup *DestGroup,
00291                                 SGDisplayItem *TargetPosition = NULL);
00292 
00293 
00294 public:         // Overridden Command interface (for Ops and menu support)
00295     virtual BOOL InitMenuCommands(void);
00296         // Called on startup to initialise any desired menu commands. Will make repeated calls
00297         // to InitMenuCommand(), below.
00298 
00299     virtual BOOL BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID);
00300         // Builds the command menu for the given menu pop-up (over an item, or options button)
00301 
00302     virtual OpState GetCommandState(StringBase *CommandID, String_256 *ShadeReason);
00303         // Returns an OpState indicating the state of this command, much like an Op GetState
00304 
00305     virtual void DoCommand(StringBase *CommandID);
00306         // Attempts to "do" the given command. Should call down to the base class to handle
00307         // any commands it can't deal with.
00308 
00309 
00310 public:             // Personal/Internal methods
00311     virtual void CreateNewSubtree(Document *ParentDoc, SGDisplayGroup *ExistingGroup = NULL);
00312             // Creates a new subtree group to display the Layers for the given document
00313             // If ExistingGroup != NULL, that group will be re-cached for the given doc
00314 
00315 
00316 public:
00317     inline Spread *GetSelectedSpread(void);
00318             // Returns the spread which the layer gallery is currently using
00319 
00320 
00321 protected:
00322     Spread          *pSpread;           // The Current spread
00323     Document        *pDoc;              // The Current document
00324     SGDisplayGroup  *DisplayForeground; // Group of foreground layers
00325     SGDisplayGroup  *DisplayBackground; // Group of background layers
00326     BOOL            m_NewDocBorn;       // Flag to determine when a new doc. is born.       
00327 
00328 protected:      // Internal methods (directly ported from old LayerGallery class)
00329     virtual void NewSelectedSpread(Spread* pNewSelSpread = NULL);
00330     virtual void EnsureSelSpreadSelectionIntegrity();
00331 #endif
00332 public:         // Public so SGDisplayLayer items can call them
00333     static void ForceRedrawLayer(Document* pDoc,Layer* pLayer);
00334     static void MakeActiveLayer(Layer* pNewActiveLayer, BOOL TellAll = TRUE);
00335     static void EnsureActiveLayerIntegrity(Spread* pSpread,Layer** ppActiveLayer = NULL);
00336 
00337 public:         // Public access functions for everybody who wants 'em
00338     static void SetActive(Document* pDoc,Layer* pLayer,BOOL state);
00339     static void MakeTopLayerActive(Spread* pSpread);
00340     static String_256 CreateUniqueLayerID(Spread* pSpread);
00341 
00342 #ifndef EXCLUDE_GALS
00343 protected:
00344     virtual void EnsureActiveLayerIntegrity();
00345     virtual BOOL CheckVarsAreValid();
00346 
00347     virtual SGDisplayLayer *GetSelectedLayerGalItem();
00348 
00349     virtual BOOL HasLayerGotChildren(Layer* pLayer);
00350  
00351     virtual BOOL PrepareToDelete(void);
00352     virtual BOOL DoDeleteSelection(void);
00353 
00354     virtual void DoCreateNewItem(void);
00355     virtual void DoChangeName();
00356     virtual void DoCopyLayer();
00357     virtual void DoLayerProperties();
00358     virtual void DoCreateGuideLayer();
00359     virtual void DoChangeLayerStatus(Layer* pLayer, const LayerStatus& NewStatus);
00360 
00361     virtual void DoMoveLayer(MoveLayerType Reason);
00362 
00363 protected: // Used to be private but needed by FrameSGallery
00364     virtual INT32 GetGuideLayerState(DocView* pDocView);
00365     INT32 OldGuideLayerState;
00366     INT32 NewGuideLayerState;
00367     virtual BOOL IsSelectedItemGuideLayer();
00368 
00369 public:
00370     static void DoChangeVisible(Layer* pLayer,BOOL Visible);
00371     static void DoChangeLocked(Layer* pLayer,BOOL Locked);
00372     virtual void DoChangeAllVisible(BOOL AllVisible);
00373     virtual void DoChangeMultilayer(BOOL Multilayer);
00374 
00375     virtual void DoChangeLayerState(Layer* pLayer,OpLayerGalReason Reason,BOOL NewState);
00376 
00377     static BOOL DoMoveSelectionToActiveLayer();
00378 
00379 protected:
00380 
00381     // Function to determine the document mode.
00382     BOOL IsLayerMode(Document* pDoc);       
00383 
00384     // Function to close the frame gallery
00385     BOOL CloseLayerGallery();
00386 
00387     // Function to open the Layer gallery
00388     BOOL OpenFrameGallery();
00389 
00390     // Access functions to determine when a new document is born.
00391     void SetNewDocBorn(BOOL Val)    { m_NewDocBorn = Val;  }
00392     BOOL GetNewDocBorn()            { return m_NewDocBorn; }
00393     
00394 #endif
00395 };
00396 
00397 
00398 #ifndef EXCLUDE_GALS
00399 
00400 
00401 /********************************************************************************************
00402 
00403 >   inline Spread *LayerSGallery::GetSelectedSpread(void)
00404 
00405     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00406     Created:    30/1/95
00407 
00408     Returns:    A pointer to the spread that the layer gallery regards as 'current'
00409 
00410     Purpose:    To find the current layer gallery spread
00411 
00412 ********************************************************************************************/
00413 
00414 Spread *LayerSGallery::GetSelectedSpread(void)
00415 {
00416     return(pSpread);
00417 }
00418 
00419 #endif
00420 
00421 // WEBSTER - markn 15/1/97
00422 // Do we need to undefine EXCLUDE_GALS?
00423 //#ifdef UNDEF_EXCLUDE_GALS
00424 //#undef EXCLUDE_GALS
00425 //#undef UNDEF_EXCLUDE_GALS
00426 //#endif
00427 
00428 #endif //INC_SGLAYER
00429 

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