ngitem.h

Go to the documentation of this file.
00001 // $Id: ngitem.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 /*
00099     $Header: /Camelot/kernel/ngitem.h 10    15/10/04 9:37 Gerry $
00100     Attribute gallery display items ans groups.
00101 */
00102 
00103 #ifndef NGITEM_H
00104 #define NGITEM_H
00105 
00106 //#include "sgtree.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "justin3.h"
00108 
00109 class Node;
00110 class NodeRenderableInk;
00111 class DocRect;
00112 class IndexedColour;
00113 class SGNameItem;
00114 class SGNameProp;
00115 class NodeSetProperty;
00116 
00117 
00118 /***********************************************************************************************
00119 >   class CCAPI SGNameGroup : public SGDisplayGroup
00120 
00121     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00122     Created:    27/6/99
00123     SeeAlso:    SGNameItem; NameGallery; SGDisplayItem
00124 ***********************************************************************************************/
00125 
00126 class CCAPI SGNameGroup : public SGDisplayGroup
00127 {
00128     CC_DECLARE_DYNAMIC(SGNameGroup);
00129 public:
00130     // Creation & destruction.
00131     SGNameGroup(UINT32 idType, UINT32 idTitle, Document* pDoc = 0);
00132 
00133     // Returns a string ID that describes the type of items in this group.
00134     UINT32 GetTypeID() const;
00135 
00136     // Returns TRUE if the given node is a member of the named set within this group.
00137     virtual BOOL IsMember(Node* pNode, const StringBase& strName) const = 0;
00138 
00139     // Register the node and all the values (names) of the sets it is a member of
00140     // (ie. create display items for them, if necessary).  Returns FALSE for error.
00141     virtual BOOL CreateItems(Node* pNode) = 0;
00142 
00143     // Returns the address of the item with the given name, or null if there isn't one.
00144     SGNameItem* FindItem(const StringBase& strName) const;
00145 
00146     // If necessary, creates a new display item with the given name for the set that
00147     // the node is a member of.  Includes the bounds of the node in the bounds of the
00148     // set etc.
00149     SGNameItem* RegisterMember(Node* pNode, const StringBase& strName);
00150 
00151 protected:
00152 
00153     // Return a newly-created display item.
00154     virtual SGNameItem* MakeItem(const StringBase& strName) const;
00155 
00156     //  Seize back control of the group's title.
00157     virtual void ReadGroupTitle();
00158 
00159 private:
00160     // Data.
00161     const UINT32 m_idType;      // eg. 'name', 'font', 'bitmap' ...
00162     const UINT32 m_idTitle;     // eg. 'Used names', 'Used fonts', 'Used bitmaps' ...
00163 };
00164 
00165 
00166 
00167 /***********************************************************************************************
00168 >   class CCAPI SGNameItem : public SGDisplayItem
00169 
00170     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00171     Created:    27/6/99
00172     Purpose:    Represents an item in the Name gallery's display.
00173     SeeAlso:    NameGallery; SuperGallery; SGDisplayItem
00174 ***********************************************************************************************/
00175 
00176 class CCAPI SGNameItem : public SGDisplayItem
00177 {
00178 public:
00179     // Creation & destruction.
00180     SGNameItem(const StringBase& strName);
00181 
00182     // return a cached ptr to this sets property node
00183     NodeSetProperty* GetPropertyNode();
00184     void ResetCachedPropertyNode()                      { m_pCachedPropertyNode = 0; }
00185 
00186     // Set contents and selection status etc
00187     BOOL IsABackBar();
00188     BOOL IsEqual(const StringBase& strOther) const;
00189     BOOL IsEmpty() const;
00190     BOOL IsAllSelected() const;
00191     BOOL IsNoneSelected() const;
00192     BOOL IsExclusivelySelected() const;
00193     BOOL IsMember(Node* pNode) const
00194             { return ((SGNameGroup*) GetParent())->IsMember(pNode, m_strName); }
00195 
00196     // Low level contents status.
00197     INT32 GetNodeCount() const;
00198     INT32 GetObjectCount() const;
00199     INT32 GetSelectedCount() const;
00200 
00201     // Bounding boxes.
00202     const DocRect& GetSetBounds() const;
00203     const DocRect& GetOldSetBounds() const;
00204     const DocRect& GetSetSelectedBounds() const;
00205     BOOL HasChangedBounds() const
00206             { return m_rSetBounds != m_rOldSetBounds; }
00207 
00208     // sjk added this nasty backdoor for the meantime
00209     void SetSetBounds(const DocRect& r)                     { m_rSetBounds = r; }
00210 
00211     // Property management.
00212     SGNameProp* GetProperty(INT32 nIndex = -1) const;
00213 
00214     // Characteristics of this display item.
00215     virtual void GetNameText(String_256* pResult);
00216     virtual const String_256* GetNameTextPtr() const    { return &m_strName; };
00217 
00218     // Refresh and calculation of bounds and selection state.
00219     void Reset(BOOL fPropagateChanges = TRUE);
00220     void Include(Node* pNode);
00221 
00222     // Modify sorting comparisons so they take account of appended numbers.
00223     virtual INT32 CompareTo(SGDisplayNode* pOther, INT32 nKey);
00224 
00225     // Called when a drag operation turns out to be a mundane button click.
00226     virtual void DragWasReallyAClick(SGMouseInfo* pMouseInfo, SGMiscInfo* pMiscInfo);
00227     
00228 protected:
00229     // Specialised UI.
00230     virtual void CalcUiBounds(SGFormatInfo* pFormatInfo, SGMiscInfo* pMiscInfo);
00231     virtual void DrawLabel(SGRedrawInfo* pRedrawInfo, SGMiscInfo* pMiscInfo);
00232 
00233     // UI state handlers.
00234     virtual BOOL GetBubbleHelp(DocCoord* pMousePos, String_256* pResult);
00235     virtual BOOL GetStatusLineHelp(DocCoord* pMousePos, String_256* pResult);
00236     
00237     // Gallery system event & redraw handlers.
00238     virtual void CalculateMyRect(SGFormatInfo* pFormatInfo, SGMiscInfo* pMiscInfo);
00239     virtual void HandleRedraw(SGRedrawInfo* pRedrawInfo, SGMiscInfo* pMiscInfo);
00240     virtual BOOL HandleEvent(SGEventType EventType, void* pEventInfo,
00241                              SGMiscInfo* pMiscInfo);
00242 
00243     // Data for UI specialisation.
00244     String_256  m_strName;                  // displayed name of this
00245     DocRect     m_rToggle;                  // UI bounds of the selection toggle gadget
00246     DocRect     m_rText;                    // UI bounds of the item's name label
00247     DocRect     m_rProp;                    // UI bounds of currently displayed property
00248 
00249     NodeSetProperty* m_pCachedPropertyNode; // a cached ptr to this sets property node
00250                                             // this is NULLed in Reset() and filled on demand
00251 private:
00252     // Data for set creation & properties.
00253     DocRect     m_rSetBounds;               // accumulated bounds of objects in the set
00254     DocRect     m_rOldSetBounds;            // value of m_rSetBounds before last operation
00255     DocRect     m_rSelectBounds;            // accumulated bounds of selected objects in set
00256     INT32           m_nNodes;                   // count of nodes in the set of this
00257     INT32           m_nObjects;                 // count of objects in the set of this
00258     INT32           m_nSelected;                // count of selected objects in the set
00259 
00260     CC_DECLARE_DYNAMIC(SGNameItem);
00261 
00262 public:
00263     // cached items of data stored in the name item
00264     // and used in the extending code
00265     BOOL     m_SetIsAffectedTrigger;    // used in FastApplyStretchScan to store sets that have changed size
00266     BOOL     m_IsATrigger;              // used in FastApplyStretchScan to store sets that appear in a trigger list
00267     BOOL     m_IsPartOfThisStretch;     // used in FastApplyStretchScan to store sets that have been extended
00268     INT32        m_BarNumber;               // set in FastUpdateNamedSetSizes and should be up-to-date if the bar data doesn't change in your op
00269     DocCoord m_Translation;             // set in the ShuffleBar function
00270 
00271 };
00272 
00273 
00274 
00275 /***********************************************************************************************
00276 >   class CCAPI SGUsedNames : public SGNameGroup
00277     class CCAPI SGUsedFonts : public SGNameGroup
00278     class CCAPI SGUsedBitmaps : public SGNameGroup
00279     class CCAPI SGUsedColours : public SGNameGroup
00280     class CCAPI SGUsedColourItem : public SGNameItem
00281 
00282     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00283     Created:    27/6/99
00284     Purpose:    NameGallery groups and items to manage the various types of attribute sets.
00285     SeeAlso:    NameGallery; SGNameGroup; SGNameItem
00286 ***********************************************************************************************/
00287 
00288 class CCAPI SGUsedNames : public SGNameGroup
00289 {
00290 public:
00291     SGUsedNames()
00292       : SGNameGroup(_R(IDS_NAMEGAL_NAMES_TYPE), _R(IDS_NAMEGAL_NAMES_TITLE))
00293             { /* empty */ }
00294 
00295     virtual BOOL IsMember(Node*, const StringBase&) const;
00296     virtual BOOL CreateItems(Node*);
00297 };
00298 
00299 
00300 
00301 class CCAPI SGUsedFonts : public SGNameGroup
00302 {
00303 public:
00304     SGUsedFonts()
00305       : SGNameGroup(_R(IDS_NAMEGAL_TYPEFACES_TYPE), _R(IDS_NAMEGAL_TYPEFACES_TITLE))
00306             { /* empty */ }
00307 
00308     virtual BOOL IsMember(Node*, const StringBase&) const;
00309     virtual BOOL CreateItems(Node*);
00310 };
00311 
00312 
00313 
00314 class CCAPI SGUsedBitmaps : public SGNameGroup
00315 {
00316 public:
00317     SGUsedBitmaps()
00318       : SGNameGroup(_R(IDS_NAMEGAL_BITMAPS_TYPE), _R(IDS_NAMEGAL_BITMAPS_TITLE))
00319             { /* empty */ }
00320 
00321     virtual BOOL IsMember(Node*, const StringBase&) const;
00322     virtual BOOL CreateItems(Node*);
00323 };
00324 
00325 
00326 
00327 class CCAPI SGUsedColourItem : public SGNameItem
00328 {
00329 public:
00330     // Creation & destruction.
00331     SGUsedColourItem(const StringBase& strName)
00332       : SGNameItem(strName), m_picSample(0)
00333             { /* empty */ }
00334 
00335     // Set the colour associated with the given item.
00336     void SetPatchColour(IndexedColour* pCol)
00337             { m_picSample = pCol; }
00338 
00339 protected:
00340     // Override default rendering to draw a colour patch beside the label.
00341     virtual void CalcUiBounds(SGFormatInfo*, SGMiscInfo*);
00342     virtual void DrawLabel(SGRedrawInfo*, SGMiscInfo*);
00343 
00344     DocRect         m_rPatch;                   // bounds of the coloured patch by the label
00345     IndexedColour*  m_picSample;                // reference to an named indexed colour
00346 };
00347 
00348 
00349 
00350 class CCAPI SGUsedColours : public SGNameGroup
00351 {
00352 public:
00353     SGUsedColours()
00354       : SGNameGroup(_R(IDS_NAMEGAL_COLOURS_TYPE), _R(IDS_NAMEGAL_COLOURS_TITLE))
00355             { /* empty */ }
00356 
00357     virtual BOOL IsMember(Node*, const StringBase&) const;
00358     virtual BOOL CreateItems(Node*);
00359 
00360 protected:
00361     // SGUsedColours groups make special SGUsedColourItems which can render a
00362     // DocColour patch by their label.
00363     virtual SGNameItem* MakeItem(const StringBase& strName) const
00364             { return new SGUsedColourItem(strName); }
00365 
00366     static const StringBase* IsNamedColour(DocColour* pCol);
00367     SGUsedColourItem* RegisterMember(Node*, const StringBase&, DocColour* pCol);
00368 };
00369 
00370 
00371 
00372 /***********************************************************************************************
00373 >   const DocRect& SGNameItem::GetSetBounds() const
00374 
00375     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00376     Created:    27/6/99
00377     Returns:    The accumulated bounds of the objects with the set.
00378 ***********************************************************************************************/
00379 
00380 inline const DocRect& SGNameItem::GetSetBounds() const
00381 {
00382     return m_rSetBounds;
00383 }
00384 
00385 
00386 
00387 /***********************************************************************************************
00388 >   const DocRect& SGNameItem::GetOldSetBounds() const
00389 
00390     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00391     Created:    27/6/99
00392     Returns:    The accumulated bounds of the objects with the set prior to the last operation.
00393 ***********************************************************************************************/
00394 
00395 inline const DocRect& SGNameItem::GetOldSetBounds() const
00396 {
00397     return m_rOldSetBounds;
00398 }
00399 
00400 
00401 
00402 /***********************************************************************************************
00403 >   const DocRect& SGNameItem::GetSetSelectedBounds() const
00404 
00405     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00406     Created:    27/6/99
00407     Returns:    The accumulated bounds of the objects with the set.
00408 ***********************************************************************************************/
00409 
00410 inline const DocRect& SGNameItem::GetSetSelectedBounds() const
00411 {
00412     return m_rSelectBounds;
00413 }
00414 
00415 
00416 
00417 /***********************************************************************************************
00418 >   INT32 SGNameItem::GetNodeCount() const
00419 
00420     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00421     Created:    27/6/99
00422     Returns:    The number of selected objects included in this item's set.
00423 ***********************************************************************************************/
00424 
00425 inline INT32 SGNameItem::GetNodeCount() const
00426 {
00427     return m_nNodes;
00428 }
00429 
00430 
00431 
00432 /***********************************************************************************************
00433 >   INT32 SGNameItem::GetObjectCount() const
00434 
00435     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00436     Created:    27/6/99
00437     Returns:    The total number of objects included in this item's set.
00438 ***********************************************************************************************/
00439 
00440 inline INT32 SGNameItem::GetObjectCount() const
00441 {
00442     return m_nObjects;
00443 }
00444 
00445 
00446 
00447 /***********************************************************************************************
00448 >   INT32 SGNameItem::GetSelectedCount() const
00449 
00450     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00451     Created:    27/6/99
00452     Returns:    The number of selected objects included in this item's set.
00453 ***********************************************************************************************/
00454 
00455 inline INT32 SGNameItem::GetSelectedCount() const
00456 {
00457     return m_nSelected;
00458 }
00459 
00460 
00461 
00462 /***********************************************************************************************
00463 >   BOOL SGNameItem::IsEmpty() const
00464 
00465     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00466     Created:    27/6/99
00467     Returns:    TRUE if the item has no members (ie. total counter is zero).
00468 ***********************************************************************************************/
00469 
00470 inline BOOL SGNameItem::IsEmpty() const
00471 {
00472     return m_nObjects == 0;
00473 }
00474 
00475 
00476 
00477 /***********************************************************************************************
00478 >   BOOL SGNameItem::IsAllSelected() const
00479 
00480     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00481     Created:    27/6/99
00482     Returns:    TRUE if all the items in the set are selected.
00483 ***********************************************************************************************/
00484 
00485 inline BOOL SGNameItem::IsAllSelected() const
00486 {
00487     return m_nObjects > 0 && m_nSelected == m_nObjects;
00488 }
00489 
00490 
00491 
00492 /***********************************************************************************************
00493 >   BOOL SGNameItem::IsNoneSelected() const
00494 
00495     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00496     Created:    27/6/99
00497     Returns:    TRUE if no object within this item's set is selected.
00498 ***********************************************************************************************/
00499 
00500 inline BOOL SGNameItem::IsNoneSelected() const
00501 {
00502     return m_nSelected == 0;
00503 }
00504 
00505 
00506 
00507 /***********************************************************************************************
00508 >   BOOL SGNameItem::IsExclusivelySelected() const
00509 
00510     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00511     Created:    27/6/99
00512     Returns:    TRUE if this item's set and the current selection are the same.
00513 ***********************************************************************************************/
00514 
00515 inline BOOL SGNameItem::IsExclusivelySelected() const
00516 {
00517     return IsAllSelected() && m_nObjects == (INT32) GetApplication()->FindSelection()->Count();
00518 }
00519 
00520 
00521 
00522 /***********************************************************************************************
00523 >   BOOL SGNameItem::IsEqual(const StringBase& strOther) const
00524 
00525     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00526     Created:    27/6/99
00527     Inputs:     strOther    ---     'attribute value' to compare this item to
00528     Returns:    TRUE if this item has the same 'attribute value' as the input.
00529 ***********************************************************************************************/
00530 
00531 inline BOOL SGNameItem::IsEqual(const StringBase& strOther) const
00532 {
00533     return m_strName == strOther;
00534 }
00535 
00536 #endif  /* !NGITEM_H */

Generated on Sat Nov 10 03:45:51 2007 for Camelot by  doxygen 1.4.4