sgline.h

Go to the documentation of this file.
00001 // $Id: sgline.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 // sgline.h - the LineGallery (Line SuperGallery) class
00099 
00100 #ifndef INC_SGLINE
00101 #define INC_SGLINE
00102 
00103 //#include "sgallery.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "brshgdgt.h"
00106 
00107 
00108 // These define the default size and formatting of items within the line gallery.
00109 const MILLIPOINT c_nHorzSizeOfItem      = 85000L;
00110 const MILLIPOINT c_nVertSizeOfItem      = 20000;
00111 const MILLIPOINT c_nHorzSizeOfText      = 28000;
00112 const MILLIPOINT c_nVertSizeOfText      = 15000;
00113 const MILLIPOINT c_nHorzGapAfterText    = 4000;
00114 const MILLIPOINT c_nVertGapAboveText    = 10000;
00115 const MILLIPOINT c_nHorzGapBetweenItems = 22000;
00116 const MILLIPOINT c_nVertGapBetweenItems = 4000;
00117 const MILLIPOINT c_nDefaultLineWidth    = 3000;
00118 const MILLIPOINT c_nAveCharWidth        = 6000;
00119 
00120 
00121 class StrokeTypeAttrValue;
00122 class BrushAttrValue;
00123 
00124 /********************************************************************************************
00125 >   class LineAttrGroup : public SGDisplayGroup
00126 
00127     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00128     Created:    17/2/95
00129     Purpose:    Specialises the SGDisplayGroup class, overriding the function that
00130                 builds up the title string.  This derived class can have any string
00131                 as its title.
00132     SeeAlso:    -
00133 ********************************************************************************************/
00134 
00135 class CCAPI LineAttrGroup : public SGDisplayGroup
00136 {
00137 public:
00138     // Creation & destruction.
00139     LineAttrGroup(const String_64& strTitle, SuperGallery* pGal);
00140 
00141     // Returns a reference to this group's title.
00142     const String_64& GetTitle() const;
00143     
00144 };
00145 
00146 
00147 
00148 /***********************************************************************************************
00149 >   class LineAttrItem : public SGDisplayItem
00150 
00151     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00152     Created:    15/2/95
00153     Purpose:    This DisplayTree node is used by the Line SuperGallery
00154                 It is responsible for providing the ability to handle/redraw one LineAttrItem
00155                 displayed in said gallery.
00156     SeeAlso:    LineGallery; SuperGallery; SGDisplayItem
00157 ***********************************************************************************************/
00158 
00159 class CCAPI LineAttrItem : public SGDisplayItem
00160 {
00161 public:
00162     // This used to pass text positions to the Render() method, below.
00163     enum TextPosition
00164     {
00165         NO_LABEL,           // don't display a text description
00166         LEFT,               // display a description to the left of the item
00167         BELOW               // display a description below the item
00168     };
00169 
00170     // These functions read and write the description string associated with this item.
00171     const String& GetDescription() const;
00172     void SetDescription(StringBase *pNewDescription);
00173 
00174     // Call this function to calculate how large this item is, in millipoints.
00175     void GetSize(TextPosition eTextPos, MILLIPOINT* pxSize, MILLIPOINT* pySize) const;
00176 
00177     // Render() will draw the object of the derived class.  It is called by HandleRedraw()
00178     // and by the gallery dragging code.
00179     void Render(RenderRegion* pRegion, const DocRect& drBounds, TextPosition eTextPos) const;
00180 
00181     // This function is called if a drag was really an ordinary click.
00182     virtual void DragWasReallyAClick(SGMouseInfo* pMouse, SGMiscInfo* pMiscInfo);
00183 
00184     // This creates a new line attribute of the appropriate kind.  Derived classes MUST
00185     // provide an implementation of this function.
00186     virtual NodeAttribute* CreateNewAttribute(BOOL fIsAdjust) const = 0;
00187 
00188     // This function is called on selection and attribute messages.  It updates the
00189     // "current attribute" flag of each item.
00190     static BOOL UpdateCurrentAttribStatus();
00191 
00192     // This function is called by the gallery base-class (?) whenever the mouse is over
00193     // an item
00194     virtual BOOL GetStatusLineHelp(DocCoord* pMousePos, String_256* pResult);
00195 
00196     // Used to return the displayed text for this item
00197     virtual void GetNameText(String_256 *pResult) {if(pResult != NULL) *pResult = m_strDescription;};
00198 
00199     // Added Diccon 1/2000 - overridden in BrushAttrItem
00200     virtual BOOL ItemSelected (NodeAttribute* pAttr);
00201 
00202 protected:
00203     // Creation & destruction.
00204     LineAttrItem(const String& strDescription, TextPosition eTextPos);
00205 
00206     // These functions are called by CalculateMyRect below, and determine the size and
00207     // spacing between items of this type.
00208     virtual MILLIPOINT GetWidth() const;
00209     virtual MILLIPOINT GetHeight() const;
00210     virtual MILLIPOINT GetHorzGap() const;
00211     virtual MILLIPOINT GetVertGap() const;
00212 
00213     // These functions are called by Render(), above.  SetAttribute() will set the
00214     // appropriate attributes in the RenderRegion for the derived class.  DrawLine()
00215     // actually renders the item's line once the attribute(s) have been set.
00216     virtual void SetAttributes(RenderRegion* pRegion) const = 0;
00217     virtual void DrawItem(RenderRegion* pRegion, const DocRect& drBounds) const;
00218 
00219     // This function determines whether this item will be labelled on-screen with a text
00220     // description, and if so, where the description will appear.
00221     void SetTextPosition(TextPosition eNewTextPos);
00222 
00223     // These functions are called by UpdateCurrentAttribStatus above.  The first returns
00224     // the run-time class of the attributes this item represents; the second returns TRUE
00225     // if this item represents the same attribute value as the given attribute.
00226     virtual CCRuntimeClass** GetAttribRuntimeClasses() const = 0;
00227     virtual BOOL IsEqualValueToAny(NodeAttribute** pOtherAttribs) const = 0;
00228 
00229 private:
00230     // Event handlers.
00231     virtual BOOL HandleEvent(SGEventType EventType, void* EventInfo, SGMiscInfo* MiscInfo);
00232     virtual void HandleRedraw(SGRedrawInfo* RedrawInfo, SGMiscInfo* MiscInfo);
00233 
00234     // Determines item size for the current DisplayMode and calculates FormatRect.
00235     virtual void CalculateMyRect(SGFormatInfo* FormatInfo, SGMiscInfo* MiscInfo);
00236 
00237     // This overrides the default click behaviour so that it is possible to simple-click
00238     // on items in more than one group.
00239     virtual BOOL DefaultClickHandler(SGMouseInfo* pMouse, SGMiscInfo* pMiscInfo);
00240 
00241     // Data members.
00242     String          m_strDescription;           // description of what this item is
00243     TextPosition    m_eDefaultTextPosition;     // the default text position for this item
00244     BOOL            m_fIsCurrentAttrib;         // TRUE if this item is included amongst the
00245                                                 // selection's current attributes.
00246     CC_DECLARE_DYNAMIC(LineAttrItem);
00247 
00248 protected:
00249     // The base class returns TRUE, so that an item of this type will auto-close the gallery
00250     // when CTRL-double-clicked. However, any derived class (e.g. arrowheads) which uses 
00251     // ctrl-double-click for a special purpose can override this to stop the gallery
00252     // from auto-closing when a ctrl-double-click occurs.
00253     virtual BOOL ShouldCloseOnDoubleClick(void);
00254 };
00255 
00256 
00257 
00258 /***********************************************************************************************
00259 >   class LineGallery : public SuperGallery
00260 
00261     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
00262     Created:    15/2/95 (Based on the Colour SGallery code)
00263     Purpose:    The Line SuperGallery class
00264     Notes:      SuperGalleries are specced in a number of docs including
00265                     specs\sgallery.doc ("super" gallery extensions)
00266                     specs\propui.doc  (gallery basic ui)
00267                 There is also howtouse\sgallery.doc which describes creating a supergallery
00268     SeeAlso:    SuperGallery; SGDisplayLine
00269 ***********************************************************************************************/
00270 
00271 class LineGallery : public SuperGallery
00272 {
00273 public:
00274     // Called on program startup.
00275     static BOOL Init();
00276 
00277     // Returns a pointer to the line gallery, or NULL if there isn't one.
00278     static LineGallery* GetInstance();
00279 
00280     // Returns TRUE if the line gallery is currently visible on-screen, FALSE otherwise.
00281     static BOOL IsActive();
00282 
00283     // Creation & destruction.
00284     LineGallery();
00285     virtual ~LineGallery();
00286 
00287     // This handles events.
00288     virtual MsgResult Message(Msg* pMessage);
00289 
00290     // This will create the gallery groups (unless they're already there) and return TRUE if ok.
00291     BOOL MakeSureGroupsHaveBeenCreated() {return(PreCreate());};
00292 
00293 public:
00294     static void AddNewStrokeItem(StrokeTypeAttrValue *pNewStroke);
00295         // Adds a new stroke type to the strokes group
00296     static void AddNewBrushItem(BrushAttrValue* pNewBrush);
00297         // adds a new brush to the brush group
00298 
00299     BOOL DeleteBrushItem(BrushHandle Handle);  
00300         // delete the item with the handle supplied
00301 
00302 PORTNOTE("other", "Removed CBrushGadget")
00303 #ifndef EXCLUDE_FROM_XARALX
00304     CBrushGadget* GetBrushGadget() { return &BrushGadget;}
00305 #endif
00306 
00307 // Overridden Command interface (for Ops and menu support)
00308 public: 
00309     virtual BOOL InitMenuCommands(void);
00310         // Called on startup to initialise any desired menu commands. Will make repeated calls
00311         // to InitMenuCommand(), below.
00312 
00313     virtual BOOL BuildCommandMenu(GalleryContextMenu *TheMenu, SGMenuID MenuID);
00314         // Builds the command menu for the given menu pop-up (over an item, or options button)
00315 
00316     virtual OpState GetCommandState(StringBase *CommandID, String_256 *ShadeReason);
00317         // Returns an OpState indicating the state of this command, much like an Op GetState
00318 
00319     virtual void DoCommand(StringBase *CommandID);
00320         // Attempts to "do" the given command. Should call down to the base class to handle
00321         // any commands it can't deal with.
00322     
00323     
00324     void UpdateBrushItem(BrushHandle Handle);
00325         // updates the given brush item
00326 
00327     // DY 1/2000 sets the current line width member
00328     MILLIPOINT  SetPreviousLineWidth();
00329     MILLIPOINT  GetPreviousLineWidth();
00330 private:
00331     // Overridden upcall methods (what are they, then?)
00332     virtual BOOL PreCreate();
00333     virtual BOOL PostCreate();
00334     virtual BOOL ApplyAction(SGActionType Action);
00335 
00336     // This overrides the default click-selection model, so items in more than one group
00337     // can be selected simultaneously.
00338     virtual void SelectionHasChanged();
00339 
00340     // This handles the state of the selection changing by updating the "current attribute"
00341     // status of all items. This fn is now redundant. It's replaced by OnCommonAttrsChangedMsg
00342     //virtual BOOL OnSelChangingMsg(SelChangingMsg::SelectionState st);
00343     virtual BOOL OnCommonAttrsChangedMsg();
00344     
00345     // This is called when the user selects the "Apply" button.
00346     virtual BOOL OnApplyButton(BOOL fIsAdjust);
00347 
00348     // Works out what status text to show, according to what's selected within the gallery.
00349     void SetStatusText();
00350 
00351     // We override these to create/destroy GDraw RenderRegions, which (currently) is
00352     // the only kind that can render line-attributes properly.
00353     virtual RenderRegion* CreateRenderRegion(DocRect* pSize, ReDrawInfoType* pInfo);
00354     virtual void DestroyRenderRegion(RenderRegion* pRegion);
00355 
00356     static BOOL PrepareBrushFolders();
00357 
00358     // Create a specialised subtree for each type of line attribute.
00359     BOOL CreateDashGroup();
00360     BOOL CreateWidthGroup();
00361     BOOL CreateArrowGroup();
00362     BOOL CreateCapGroup();
00363     BOOL CreateJoinTypeGroup();
00364     BOOL CreateVarWidthGroup();
00365     BOOL CreateStrokeTypeGroup();
00366     LineAttrGroup* CreateBrushAttrGroup(String_256 GroupName );
00367     BOOL CreateBrushGroups();
00368 
00369     // Create the group nodes (headings) and items (helper functions).
00370     LineAttrGroup* CreateGroup(const String_256& strTitle, BOOL fOpen);
00371     BOOL CreateItem(LineAttrGroup* pGroup, LineAttrItem* pItem);
00372 
00373     // Run-time type-checking etc.
00374     CC_DECLARE_DYNCREATE(LineGallery)
00375 
00376     // Data members.
00377     static LineGallery* m_pTheGallery;
00378     static double m_anArrowScales[4];
00379 
00380     // used by the new brush to store the old line width so that it can be
00381     // restored when the brush is deselcted
00382     MILLIPOINT m_PreviousLineWidth;
00383 
00384 PORTNOTE("other", "Removed CBrushGadget")
00385 #ifndef EXCLUDE_FROM_XARALX
00386     CBrushGadget    BrushGadget;
00387 #endif
00388 
00389     static String_256* m_pFileNameArray; // stores the filenames of the default brush files loaded on startup
00390     static UINT32   m_NumDefaultFiles;
00391 };
00392 
00393 
00394 
00395 // To remain compatible with existing code, these are the old names for the above classes.
00396 typedef LineAttrItem    SGDisplayLineAttrItem;
00397 typedef LineAttrGroup   SGLineDisplayGroup;
00398 typedef LineGallery     LineSGallery;
00399 
00400 
00401 
00402 /********************************************************************************************
00403 >   class OpDisplayLineGallery: public Operation
00404 
00405     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00406     Created:    9/2/95 (Based on the Colour SGallery code)
00407     Purpose:    Displays the Line gallery.
00408                 This op can be attached to a menu, button or keypress
00409     SeeAlso:    LineGallery
00410 ********************************************************************************************/
00411 
00412 #define OPTOKEN_DISPLAY_LINE_GALLERY    TEXT("DisplayLineGallery")
00413 
00414 class CCAPI OpDisplayLineGallery: public Operation
00415 {         
00416     CC_DECLARE_DYNCREATE( OpDisplayLineGallery );
00417 
00418 public:
00419     static BOOL     Init();             
00420     static OpState  GetState(String_256*, OpDescriptor*);       
00421     void            Do(OpDescriptor*);
00422 
00423 private:
00424     // Finds the Line gallery class instance
00425     static SuperGallery* FindGallery(void);
00426 };  
00427 
00428 #endif

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