slicehelper.h

Go to the documentation of this file.
00001 // $Id: slicehelper.h 751 2006-03-31 15:43: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 // All fully static functions to help with scanning and finding
00099 // developed to help the slicing opperations
00100 // but can be used elsewhere - sjk 30/9/99
00101 
00102 #ifndef MAX_BUTTONS_IN_A_BAR
00103 
00104 #define MAX_BUTTONS_IN_A_BAR    20
00105 
00106 #define INCLUDE_CLICKED_STATE   1 // 1 to have a clicked state, 0 to not have it
00107 
00108 #include "ngscan.h"
00109 
00110 class TemplateAttribute;
00111 //class SGNameItem;
00112 class UndoableOperation;
00113 class TextLine;
00114 class TextStory;
00115 
00116 class SliceHelper
00117 {
00118 public:
00119     // These stand for things you can do to the selection in SelectAllSetsInRect.
00120     enum SelStateAction { CLEAR, SET, TOGGLE };
00121 
00122     // find layers
00123     static Layer * FindLayerCalled(const StringBase & LayerName);
00124 
00125     // count buttons
00126     static INT32 CountButtonsInBar(const StringBase & BarName);
00127     static void CountButtonsInBarScan(Node * pNode, TemplateAttribute ** ppFoundButton, INT32 * pNumberOfButtons, const StringBase & BarName);
00128 
00129     // build lists of buttons in a bar
00130     static void BuildListOfNodesInBar(List * pList, Node * pNode, const StringBase & BarName);
00131 
00132     // find out about sets from the name gallery
00133     static SGNameItem* LookupNameGalleryItem(const StringBase & strName);
00134     static void GetNextFreeButtonName(INT32 &butno, StringBase * pStr = NULL);
00135 
00136     // nice very generic function
00137     static Node * FindNextOfClass(Node *pNode, Node * pLidNode, const class CCRuntimeClass * pClass, BOOL CheckThis = FALSE);
00138     // an inline version of the above code which looks purely for WixTemplateAttributes
00139     // made inline and without the IS_A's for speed purposes (sjk 1/8/00)
00140     static Node * FindNextNameNode(Node *pNode, Node * pLidNode, BOOL CheckThis = FALSE)
00141     {
00142         Node * pNextNode = NULL;
00143         BOOL tested = FALSE;
00144         Node * pPassedNode = CheckThis ? NULL : pNode;
00145 
00146         while (pNode != pLidNode || !tested)
00147         {
00148             tested = TRUE;
00149 
00150             // check this node as we move across
00151             if (!pNode->IsNodeHidden() && pNode != pPassedNode && pNode->IsAnObjectName())
00152                 return pNode;
00153 
00154             // while can go down do so
00155             pNextNode = pNode->FindFirstChild();
00156 
00157             if (pNextNode && pNextNode->IsNodeHidden())
00158                 pNextNode = pNextNode->FindNextNonHidden();
00159             
00160             while(pNextNode)
00161             {
00162                 pNode = pNextNode;
00163                 
00164                 // check this node as we move down
00165                 if (!pNode->IsNodeHidden() && pNode != pPassedNode && pNode->IsAnObjectName())
00166                     return pNode;
00167 
00168                 pNextNode = pNode->FindFirstChild();
00169 
00170                 if (pNextNode && pNextNode->IsNodeHidden())
00171                     pNextNode = pNextNode->FindNextNonHidden();
00172             }
00173 
00174             // cant go down and we are already at the top
00175             if (pNode == pLidNode)
00176                 return NULL;
00177 
00178             // find next none hidden brother
00179             pNextNode = pNode->FindNextNonHidden();
00180 
00181             if (pNextNode)
00182                 pNode = pNextNode;
00183             else // no brothers so find an uncle
00184             {
00185                 BOOL FoundUncle = FALSE;
00186 
00187                 while (!FoundUncle)
00188                 {
00189                     pNextNode = pNode->FindParent();
00190                     if (pNextNode == pLidNode || !pNextNode)
00191                         return NULL;
00192 
00193                     pNode = pNextNode;
00194                     pNextNode = pNode->FindNextNonHidden();
00195 
00196                     // found uncle
00197                     if (pNextNode)
00198                     {
00199                         pNode = pNextNode;
00200                         FoundUncle = TRUE;
00201                     }
00202                 }
00203             }
00204         }
00205 
00206         return NULL;
00207     }
00208 
00209     // code for selecting all objects with the same name as a specific Node, or all objects in a named set.
00210     static void SelectAllSetsOfThisNode(NodeRenderableInk* pInk, String_256 & SetName, BOOL bShift);
00211     static void RecurseSelectAllSetsOfThisNode(Node * pAttrs, String_256 & SetName, BOOL bShift);
00212     static BOOL SelectObjectsInSet(const StringBase& strName, SelectScan::Change eNewState);
00213 
00214     // a custom function for selecting all nodes sharing names with those nodes within a given selection rectangle.
00215     // maybe this function should be moved into NodeRenderable?
00216     static void SelectAllSetsInRect(const DocRect, Spread*, SelStateAction st = SET);
00217 
00218     static String_256 GetBarName(TemplateAttribute * pTemplAttrib);
00219     static void MeshImportedLayersWithExistingButtonBars(Node * pImportedLayer[5], UndoableOperation * pUndoableOp, BOOL Imported);
00220     static BOOL IsUniqueName(const String_256 & Name, List * pList);
00221 
00222     static Node * ReplaceAttrsInTree(UndoableOperation * pOp,
00223                                        List * pImportedAttrList,
00224                                        const String_256 & OldButtonName,
00225                                        const String_256 & OldBarName,
00226                                        const String_256 & NewButtonName,
00227                                        const String_256 & NewBarName,
00228                                        Node ** ppNodeFound = NULL);
00229 
00230     static BOOL BarNameExists(Node * pNode, String_256 &BarName, Node * pLid = NULL);
00231     static INT32 FindTargetAndExtender(Node * pStartNode,
00232                         String_256 & Target,
00233                         String_256 & Extender, 
00234                         INT32 RequiredLevel, 
00235                         BYTE *pExtenderFlags = NULL,
00236                         DocRect *pTargetRect = NULL,
00237                         DocRect *pExtenderRect = NULL);
00238 
00239 
00240     static BOOL CreatePropertiesForSet( const String_256& SetName,
00241                                         const String_256& BarName,
00242                                         BOOL isSlice,
00243                                         BOOL Stretches,
00244                                         BOOL IsBackBar,
00245                                         BYTE StretchFlags,
00246                                         const String_256& StretchedBy,
00247                                         BOOL DontOverWrite = FALSE,
00248                                         DocRect *pTargetRect = NULL,
00249                                         DocRect *pExtenderRect = NULL,
00250                                         UndoableOperation * pOp = NULL,
00251                                         NodeSetProperty * pExampleProp = NULL);
00252 
00253     static BOOL PurgeUseOfSetName(const StringBase & SetName, UndoableOperation* pOp, const String_256 * pReplacementName = NULL);
00254 
00255 
00256     static BOOL MakeTriggerLikeExample(const String_256 & NewButtonName, const String_256 & ButtonName, const String_256 * pExclude = NULL);
00257 
00258     static DocRect BoundingNodeSize(Node * pNode);
00259 
00260     static INT32 GetBarNumberFromBarName(const String_256 & BarName);
00261 
00262     static TemplateAttribute * FindFirstSetNodeBelongsTo(Node * pNode);
00263     static String_256 GetSetNameFromAttrib(Node * pNode);
00264     static TextStory * FindNextTextStoryToSync( TextStory * pLastStory,
00265                                                 Node * pLid,
00266                                                 TextStory * pMasterStory,
00267                                                 const String_256 & ButtonName,
00268                                                 const String_256 & MasterText,
00269                                                 BOOL AnyText = FALSE);
00270 
00271     static BOOL TextStoriesHaveSameText (TextStory * pStory1, TextStory * pStory2);
00272     static BOOL TextLinesHaveSameText (TextLine * pLine1, TextLine * pLine2);
00273     static BOOL SyncTextLines (TextLine * pLine1, TextLine * pLine2, UndoableOperation * pOp);
00274     static BOOL SyncTextStories (TextStory * pStory, TextStory * pMaster, UndoableOperation * pOp);
00275 
00276     static BOOL OnTextStoryChanged( TextStory * pMasterStory,
00277                                     UndoableOperation * pOp,
00278                                     ObjChangeParam * pObjChange,
00279                                     const String_256 & MasterText);
00280 
00281     static DocRect ScanForSetSizeExcluding (const String_256 & IncludeSet, const String_256 & ExcludeSet);
00282     static BOOL BarExistsOnLayer(const String_256 &BarName, const String_256 &Layer);
00283     static void BarNameInRect(DocRect r, String_256 *pBarName);
00284     static void ShowLayer(BOOL Visible, Layer * pLayer, Spread * pSpread, UndoableOperation * pUndoOp);
00285     static INT32 DoesSelectionOnlyContainCompleteSets();
00286 
00287     static BOOL SetUsedInTree(Node * pNode, const String_256 &SetName, Node * pLid = NULL);
00288     static void DeleteUnusedReferences(const String_256 &SetName, UndoableOperation * pOp);
00289 
00290     static BOOL AddNamesToController (UndoableOperation * pOp, Node * pCtrlr);
00291     static BOOL RemoveNamesFromController (UndoableOperation * pOp, Node * pCtrlr);
00292 
00293 
00294 
00295     // Matt 6/11/2000
00296     // Given the current selection, auto-select all button elements which are fully selected on at least one layer
00297     static BOOL ModifySelectionToContainWholeButtonElements();
00298 
00299     // Matt 6/11/2000
00300     // Saves the current selection in m_pSelNodeList
00301     static void SaveSelection();
00302 
00303     // Matt 6/11/2000
00304     // Restores the current selection from that stored in m_pSelNodeList
00305     static void RestoreSelection();
00306 
00307     // Matt 18/12/2000
00308     // Validates the NodeSetSentinel and corrects it if it is corrupted
00309     static void ValidateNodeSetSentinel();
00310 
00311     // Matt 20/12/2000
00312     // Builds a list of all the nodes in a particular button on a given layer
00313     static void BuildListOfNodesInButton(List * pList, Layer * pLayer, const StringBase & ButtonName);
00314 
00315     // Matt 22/01/2001
00316     // Ensure that the Trigger Information is correct in the name gallery - it sometimes is not initialised until an
00317     // operation has called FastApplyStretchScan() - not very handy...
00318     static void EnsureTriggerInfo();
00319 
00320 private:
00321     static List* m_pSelNodeList;
00322 
00323 };
00324 
00325 #endif

Generated on Sat Nov 10 03:47:02 2007 for Camelot by  doxygen 1.4.4