00001 // $Id: sgtree.h 1139 2006-05-19 17:47:07Z 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 // SGTree.h - super gallery DisplayTree classes 00099 00100 #ifndef INC_SGTREE 00101 #define INC_SGTREE 00102 00103 00104 #ifndef INC_DOCCOLOR 00105 #include "doccolor.h" 00106 #endif 00107 00108 // Pre-declarations 00109 class Document; // defined in document.h 00110 class Library; // defined in sgscan.h 00111 00112 class SuperGallery; 00113 00114 class SGDisplayNode; 00115 class SGDisplayGroup; // defined below, but forward referenced 00116 class SGDisplayItem; 00117 00118 struct ReDrawInfoType; // kernel-rendered-dialogue information struct 00119 class DialogColourInfo; 00120 00121 class DragMessage; // Drag message class (see dragmsg.h) 00122 class ThumbMessage; // Drag message class (see thumbmsg.h) 00123 00124 00125 // Some suggested constants for sizing items in your gallery, in MILLIPOINTS 00126 // Do not change these constants, as they may affect multiple galleries. 00127 const INT32 SG_InfiniteWidth = 0; // Infinite width item- DO NOT CHANGE! 00128 00129 const INT32 SG_DefaultLargeIcon = 16000; // Size of a large icon 00130 const INT32 SG_DefaultSmallIcon = 12000; // Size of a small icon 00131 const INT32 SG_GapBeforeText = 3000; // Horz gap between icon and start of text 00132 const INT32 SG_GapAboveText = 14400; // Gap above text (when underneath the icon) 00133 const INT32 SG_DefaultNameText = 100000; // Space for brief text (e.g. item name) 00134 00135 00136 const INT32 DefaultGroupHeight = 12000; // Default millipoint height of groups 00137 const INT32 DefaultGroupWidth = 0; // Default width - infinite 00138 00139 const INT32 DefaultItemHeight = 12000; // Default millipoint height of items 00140 const INT32 DefaultItemWidth = 30000; // Default width 00141 00142 const INT32 InterLineGap = 1200; // Gap between items in a group 00143 const INT32 UpTreeGap = 3000; // Gap after a group's items 00144 const INT32 IndentWidth = 10000; // Size of indent for successive tree levels 00145 00146 00147 00148 00149 00150 /*********************************************************************************************** 00151 00152 < SGFormatInfo 00153 00154 Comment: MonoOn 00155 typedef struct 00156 { 00157 INT32 MaxWidth; 00158 INT32 WindowHeight 00159 INT32 DisplayMode; 00160 INT32 PixelSize; 00161 } SGMiscInfo; 00162 MonoOff 00163 00164 This structure is passed into SGDisplayNode class HandleEvent method. 00165 It is ALWAYS passed in, and is always valid. 00166 00167 MaxWidth gives the width of the window display in millipoints. If items are 00168 small enough this width may allow several items to format next to each other 00169 along a single line. 00170 00171 WindowHeight gives the height of the window display in millipoints. This is 00172 mainly only needed for calculating scrollbar information. 00173 00174 DisplayMode indicates which display mode (e.g. Large/Small icons, Full info) 00175 the items should be displaying themselves in. 00176 00177 PixelSize holds the size in millipoints of a display pixel in our virtual 00178 rendering coordinates. We must grid-lock all our rendering to multiples of 00179 this size to ensure that nasty aliasing effects (items jumping further apart 00180 as we scroll the list, etc) do not occur. It also means we can specify gaps 00181 and line widths, etc, in terms of "a pixel" we so desire. 00182 00183 A structure is used for easy addition of other information at a later date 00184 00185 SeeAlso: SuperGallery; SGDisplayNode::HandleEvent 00186 00187 ***********************************************************************************************/ 00188 00189 typedef struct 00190 { 00191 INT32 MaxWidth; // The maximum available width, in millipoints (Window Width) 00192 INT32 WindowHeight; // The height in millipoints of the region displayed onscreen 00193 INT32 DisplayMode; // The display mode to be reformatted for 00194 INT32 PixelSize; // Size of an output pixel in millipoints. We MUST gridlock 00195 // all plotting to multiples of this size. 00196 } SGMiscInfo; 00197 00198 00199 00200 /*********************************************************************************************** 00201 00202 < SGSortKey 00203 00204 Comment: This structure is passed into SGDisplayNode classes when a sort operation 00205 is being applied. It describes how items should be sorted. 00206 00207 MonoOn 00208 const INT32 MaxSGSortKeys = 2; 00209 00210 typedef struct 00211 { 00212 INT32 SortKey; 00213 BOOL Reversed; 00214 } SGSortKey; 00215 00216 00217 const INT32 SGSORTKEY_NONE = 0; 00218 00219 const INT32 SGSORTKEY_BYNAME = 1; 00220 MonoOff 00221 00222 SortKeys are ALWAYS used in arrays of MaxSGSortKeys length. 00223 i.e. SGSortKey SortInfo[MaxSGSortKeys]; 00224 00225 Each entry in the SortKey array gives a sort key, specified as as an 00226 integer, where 0 means 'no sorting', and other integers are defined 00227 by the specific gallery/display item. By default, the value 1 is used 00228 to mean 'sort by name', and default gallery handlers are provided by 00229 the base classes to provide this sort mode. 00230 00231 Each entry also has a Reversed flag which indicates whether the related 00232 sort mode should be used in reverse. 00233 00234 The MaxSGSortKeys constant is used to allow us to add or remove extra 00235 sort keys at will. All references to sort keys should be made by loops 00236 which scan from 0 to MaxSGSortkeys-1. 00237 00238 SeeAlso: SuperGallery; SGDisplayNode::AddItem 00239 00240 ***********************************************************************************************/ 00241 00242 const INT32 MaxSGSortKeys = 2; // We allow a primary and secondary key 00243 00244 const INT32 SGSORTKEY_NONE = 0; // Sort-key value for no-sorting 00245 const INT32 SGSORTKEY_BYNAME = 1; // Sort key value for sort-by-name, if supplied 00246 00247 typedef struct 00248 { 00249 INT32 SortKey; 00250 BOOL Reversed; 00251 } SGSortKey; 00252 00253 00254 00255 /*********************************************************************************************** 00256 00257 < SGFormatInfo 00258 00259 Comment: MonoOn 00260 typedef struct 00261 { 00262 INT32 LinePos; 00263 INT32 LineHeight; 00264 INT32 AvailableWidth; 00265 INT32 IndentLevel; 00266 DocRect InvalidBounds; 00267 } SGFormatInfo; 00268 MonoOff 00269 00270 This structure is passed into SGDisplayNode classes when the SuperGallery 00271 asks the tree to calculate and cache item formatting information. 00272 Items calculate formatting (into 'lines' across the window) using a simple 00273 but reasonably generic system, similar to foratting paragraphs of text. 00274 As many sibling items as possible will fit themselves side by side across 00275 each 'line' - overflow continues on the next line. Moving up or down 00276 the tree acts as a 'newline', forcing the next item to move to a new line. 00277 Generally speaking, leaf-nodes of the tree are the only nodes of non- 00278 'infinite' width (groups always fill entire lines), though there is no 00279 reason (other than style, taste, panache, and common decency) why they 00280 can't be shorter, and mix with other items on a single line. 00281 00282 LinePos, LineHeight are kept up to date with the Y position and size of the 00283 currently formatting display 'line'. 00284 00285 AvailableWidth contains the remaining width in this line - if an item cannot 00286 fit within AvailableWidth, it will format onto the next line (except when 00287 NeededWidth >= MaxWidth, when it takes the entire line for itself & truncates) 00288 00289 IndentLevel indicates the current tree depth; used to indent items in sub- 00290 categories further each time. 00291 00292 InvalidBounds is 'Empty' on entry to the formatting pass. As each item 00293 determines its format rect, it checks against its cached FormatRect, and 00294 if it has moved/resized since the last format, it includes its own y extent 00295 within the InvalidBounds rectangle. Thus, on exit, it is a rectangle which is 00296 either 'Empty' or encloses all invalid regions of the display list. Used 00297 to redraw only those portions of the list which have actually changed. 00298 00299 A structure is used for easy addition of other information at a later date 00300 00301 SeeAlso: SuperGallery; SGDisplayNode::HandleEvent 00302 00303 ***********************************************************************************************/ 00304 00305 typedef struct 00306 { 00307 INT32 LinePos; // Topmost Y position of the current 'line' 00308 // (Y goes from 0 at the top to -extent at the bottom of the list) 00309 INT32 LineHeight; // Minimum height of the current 'line' of the display 00310 INT32 AvailableWidth; // Available width left on the current 'line' of the display 00311 INT32 IndentLevel; // Current tree depth, used for adding indentation 00312 00313 BOOL AccumulateBounds; // TRUE if the InvalidBounds should be accumulated, FALSE for speed 00314 SGDisplayNode *LastInvalidNode; // If the previous node was invalid, this points to it. At any 00315 // other time, this should be NULL. This is to fix a problem where 00316 // the gap at the end of a group may not be redrawn, so the next 00317 // group has to include that gap in InvalidBounds on its behalf 00318 DocRect InvalidBounds; // These bounds are accumulated during the format. Each item 00319 // which discovers its bounds have changed since the last format 00320 // updates this rectange to include itself. This gives a "changed 00321 // area" which needs to be redrawn to fix the display. 00322 00323 } SGFormatInfo; 00324 00325 00326 00327 /*********************************************************************************************** 00328 00329 < SGRedrawInfo 00330 00331 Comment: MonoOn 00332 typedef struct 00333 { 00334 DocRect Bounds 00335 RenderRegion *Renderer; 00336 BOOL BgRedraw; 00337 DocColour Foreground; 00338 DocColour Background; 00339 DocColour Transparent; 00340 } SGRedrawInfo; 00341 MonoOff 00342 00343 This structure is passed down through the SuperGallery Display Tree by the 00344 SGDisplayNode::HandleEvent method, when processing REDRAW events. It includes 00345 the redraw clipping region which needs to be redrawn, plus a formatting 00346 information structure to allow the items to calculate their layout. 00347 00348 Bounds indicates the 'clip rect' for the current redraw. Items outside 00349 Bounds should not be redrawn at all. 00350 00351 Renderer points to a render region with which you can draw stuff 00352 00353 Foreground, Background, Transparent, are predefined colours which should 00354 be used for the redraw. These are read from host OS settings, so should 00355 be used in preference to constant colours where possible, in order to 00356 be as host-OS friendly as possible. 00357 00358 A structure is used for easy addition of other information at a later date 00359 00360 SeeAlso: SuperGallery; SGDisplayNode::HandleEvent; SGReformatInfo 00361 00362 ***********************************************************************************************/ 00363 00364 typedef struct 00365 { 00366 DocRect Bounds; // The bounds in which we are redrawing 00367 RenderRegion *Renderer; // The RndRgn to call to render stuff 00368 00369 // Pre-defined colours 00370 DocColour Foreground; // Foreground (black) 00371 DocColour Background; // Background (white) 00372 DocColour SelForeground; // Foreground when selected (white) 00373 DocColour SelBackground; // Background when selected (dark blue) 00374 DocColour Transparent; // Transparent (no colour) 00375 } SGRedrawInfo; 00376 00377 00378 00379 /*********************************************************************************************** 00380 00381 < SGMouseInfo 00382 00383 Comment: MonoOn 00384 typedef struct 00385 { 00386 DocCoord Position; 00387 BOOL Adjust; 00388 BOOL Extend; 00389 BOOL DoubleClick; 00390 BOOL MenuClick; 00391 } SGMouseInfo; 00392 MonoOff 00393 00394 This structure is passed down through the SuperGallery Display Tree by the 00395 SGDisplayNode::HandleEvent method, when processing MOUSE events. 00396 00397 Position contains the current x,y position of the mouse in MILLIPOINTS 00398 00399 Adjust is TRUE for an 'adjust' (ctrl) click or FALSE for a normal 00400 (left button) click 00401 00402 Extend is TRUE if it was a 'selection extending' click (shift-click in 00403 windows-listbox way of operation) 00404 00405 DoubleClick is TRUE if this mouse event closely follows another one, so 00406 that it looks like this is actually part two of a double-click. 00407 00408 MenuClick is TRUE if the click will be showing a menu (in which case, a 00409 drag MUST NOT be started or the menu will never appear) - this occurs for 00410 right-button clicks. 00411 00412 SeeAlso: SGDisplayGroup::HandleEvent; SGEventType 00413 00414 ***********************************************************************************************/ 00415 00416 typedef struct 00417 { 00418 DocCoord Position; 00419 BOOL Adjust; 00420 BOOL Extend; 00421 BOOL DoubleClick; 00422 BOOL MenuClick; 00423 } SGMouseInfo; 00424 00425 00426 00427 /*********************************************************************************************** 00428 00429 < SGMouseInfo 00430 00431 Comment: MonoOn 00432 typedef struct 00433 { 00434 DocCoord Position; 00435 INT32 ClosestSoFar; 00436 SGDisplayNode *Claimant; 00437 } SGMouseInfo; 00438 MonoOff 00439 00440 This structure is passed down through the SuperGallery Display Tree by the 00441 SGDisplayNode::HandleEvent method, when processing CLAIMPOINT events. This 00442 event allows the parent gallery to determine which item lies under the 00443 mouse pointer, etc (i.e. hit-testing for drags) 00444 00445 Position contains the x,y position, in MILLIPOINTS, of a point to be 00446 hit-tested. 00447 00448 ClosestSoFar records the distance from the nearest edge of the FormatRect 00449 of Claimant 00450 00451 Any visible display node which contains the given point inside its 00452 FormatRect should set (Claimant = this), and return TRUE. 00453 00454 Otherwise, if the node is closer to the point than 'ClosestSoFar' then 00455 they should set ClosestSoFar to this distance, set Claimant = this, 00456 and return FALSE to allow the rest of the tree to hit test the point. 00457 00458 SeeAlso: SGDisplayGroup::HandleEvent; SGEventType 00459 00460 ***********************************************************************************************/ 00461 00462 typedef struct 00463 { 00464 DocCoord Position; 00465 INT32 ClosestSoFar; 00466 SGDisplayNode *Claimant; 00467 } SGClaimPointInfo; 00468 00469 00470 00471 /*********************************************************************************************** 00472 00473 < SGEventInfo 00474 00475 Comment: Used by SuperGallery DisplayTrees 00476 00477 This would ideally be a union of all data structures that can be passed into 00478 the DisplayTree HandleEvent methods. However, you can't easily do unions of 00479 things containing classes with copy constructors, so it isn't a union. 00480 Instead, the HandleEvent function has to cast this pointer to the appropriate 00481 type for the event being processed. These are: 00482 00483 00484 'NULL' indicates that there is no specific information passed in, and this 00485 parameter of the HandleEvent method will be NULL for these event types. 00486 00487 SeeAlso: SuperGallery; SGDisplayNode::HandleEvent; SGEventType 00488 00489 ***********************************************************************************************/ 00490 00491 typedef void *SGEventInfo; 00492 00493 00494 00495 /*********************************************************************************************** 00496 00497 < SGEventType 00498 00499 Comment: Used by SuperGallery DisplayTrees 00500 00501 This is an enumeration of event types which can be passed to SGDisplayNodes 00502 to be handled by their HandleEvent methods. Along with this, a 'SGMiscInfo' 00503 structure is always passed in containing relevant information, as well as 00504 extra data which is event-specific: 00505 00506 The data passed in SGDisplayNode::HandleEvent's 'EventInfo' pointer is 00507 determined by the event type. The data will be: 00508 00509 MonoOn 00510 SGEVENT_FORMAT NULL 00511 SGEVENT_REDRAW (SGRedrawInfo *) 00512 [SGEVENT_BGREDRAW NULL] -- This event has been replaced by a virtual method 00513 SGEVENT_BGFLUSH NULL - May have NULL MiscInfo 00514 SGEVENT_MOUSECLICK (SGMouseInfo *) 00515 SGEVENT_DRAGSTARTED (DragMessage *) 00516 SGEVENT_CLAIMPOINT (SGMouseInfo *) 00517 SGEVENT_THUMBMSG (ThumbMessage *) - May have NULL MiscInfo 00518 MonoOff 00519 00520 NULL indicates that for this event type, a NULL pointer is passed in the 00521 EventInfo parameter. 00522 00523 SeeAlso: SuperGallery; SGDisplayNode::HandleEvent; SGEventInfo 00524 00525 ***********************************************************************************************/ 00526 00527 typedef enum 00528 { 00529 SGEVENT_FORMAT, // A request to just format the item (a dummy redraw run) 00530 SGEVENT_REDRAW, // A request to redraw a portion of the displayed list 00531 // SGEVENT_BGREDRAW, // A request to handle background redraws (handled by base class) 00532 SGEVENT_BGFLUSH, // A request to flush (forget) background redraws (handled by base class) 00533 SGEVENT_MOUSECLICK, // A request to determine what action should be taken for a click 00534 SGEVENT_DRAGSTARTED, // A DRAGSTARTED DragMessage has been recieved 00535 SGEVENT_CLAIMPOINT, // Asks the item enclosing a given position to claim the event 00536 SGEVENT_THUMBMSG, // Passes a library ThumbMessage onto all items in the tree 00537 } SGEventType; 00538 00539 00540 00541 00542 00543 /*********************************************************************************************** 00544 00545 < SGDisplayFlags 00546 00547 Comment: This structure simply holds a bitfield of flags relevant to SuperGallery 00548 Display classes. Although some classes do not use some of the flags, they 00549 all share the same flag structure, so that it can be treated in a more 00550 generic manner - it's reasonably convenient, too. 00551 00552 SeeAlso: SuperGallery; SGDisplayGroup; SGDisplayList; SGDisplayItem 00553 00554 ***********************************************************************************************/ 00555 00556 typedef struct 00557 { 00558 UINT32 Invisible : 1; // Set if this node/item is entirely invisible 00559 UINT32 ReadOnly : 1; // Set if this node/item is read-only 00560 UINT32 Modified : 1; // Set if this node/item has been modified 00561 UINT32 Selected : 1; // Set if this node/item is selected 00562 UINT32 CanSelect : 1; // Set if this node will allow itself to be selected 00563 UINT32 Folded : 1; // Set if this node is folded 00564 UINT32 RedrawPending : 1; // Set if this node is waiting for background redraw 00565 UINT32 Virtualised : 1; // Set if this node is waiting for background redraw 00566 00567 UINT32 HandleEventCount : 8; // DEBUG counter- how many re-entrant calls to HandleEvent 00568 // are currently in progress. Used to detect "suicides" 00569 00570 UINT32 Reserved : 16; // Reserved for future expansion (all bits default to 0) 00571 } SGDisplayFlags; 00572 00573 00574 00575 00576 00577 00578 00579 /*********************************************************************************************** 00580 00581 > class SGDisplayNode : public CCobject 00582 00583 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00584 Created: 20/10/94 00585 Purpose: This DisplayTree node type is used by the SuperGallery 00586 This is a virtual class from which all nodes in the DisplayTree are derived. 00587 00588 Before using DisplayTrees, or deriving classes from this one, please read 00589 Docs\specs\GalLib.doc, which has a section on how these nodes function. 00590 00591 SeeAlso: SuperGallery; SGDisplayGroup; SGDisplayList 00592 00593 ***********************************************************************************************/ 00594 00595 class CCAPI SGDisplayNode : public CCObject 00596 { 00597 CC_DECLARE_DYNAMIC(SGDisplayNode) 00598 00599 public: // Construction/Destruction 00600 SGDisplayNode(); 00601 ~SGDisplayNode(); 00602 00603 public: // Tree navigation methods 00604 inline SGDisplayNode* GetParent() const; 00605 virtual SGDisplayNode* GetChild() const; 00606 inline SGDisplayNode* GetNext() const; 00607 inline SGDisplayNode* GetPrevious() const; 00608 virtual SuperGallery *GetParentGallery() const; 00609 // Finds the gallery whch 'owns' this node and the tree it is in 00610 00611 00612 protected: 00613 virtual void SetChild(SGDisplayNode *NewChild); 00614 // Internal method for setting the child pointer in derived classes 00615 00616 virtual void InsertInternal(SGDisplayNode *NodeToInsert, 00617 SGDisplayNode *PrevNode, SGDisplayNode *NextNode); 00618 // Internal generic function to insert a node/subtree 00619 00620 00621 public: // Tree generation methods 00622 virtual void AddItem(SGDisplayNode *NodeToInsert, SGSortKey *SortInfo = NULL); 00623 // Inserts the given node into this subtree. If SortInfo == NULL or 00624 // NodeToInsert is not an SGDisplayItem, it is added as the last child of 00625 // this node. Otherwise, it is inserted into the subtree of SGDisplayItems 00626 // at the point 'specified' by SortFunction 00627 00628 virtual void InsertAfter(SGDisplayNode *NodeToInsert); 00629 // Inserts the given node as this node's next (right) sibling 00630 00631 virtual void InsertBefore(SGDisplayNode *NodeToInsert); 00632 // Inserts the given node as this node's previous (left) sibling 00633 00634 virtual void MoveAfter(SGDisplayNode *NodeToInsert); 00635 // MOVEs the given node from its current position to be this node's next sibling 00636 00637 virtual void MoveBefore(SGDisplayNode *NodeToInsert); 00638 // MOVEs the given node from its current position to be this node's previous sibling 00639 00640 00641 virtual void RemoveFromTree(void); 00642 // Removes (de-links) this node from the tree; use prior to deleting 00643 00644 virtual void DestroySubtree(BOOL IncludingThisNode = TRUE); 00645 // De-links and DELETEs the entire subtree from this node (inclusive) downwards 00646 // NOTE that this will allow you to delete the root node of a tree - Use with care! 00647 00648 virtual SGDisplayGroup *FindSubtree(SuperGallery *ParentGal, 00649 Document *ParentDoc, Library *ParentLib); 00650 // Finds the first _SGDisplayGroup_ node in the subtree which has parents matching the 00651 // specified parameters. Used to find a dcument/library's subtree. 00652 00653 virtual BOOL SetFoldedState(BOOL NewState, BOOL ForceRedraw = TRUE); 00654 // Folds/Unfolds the given node, returning TRUE if this call actually changed the state 00655 00656 inline BOOL IsSelected(void); 00657 virtual void SetSelected(BOOL IsSelected = TRUE); 00658 // Handle setting/reading the selection state of a Node 00659 00660 00661 public: // Sorting support methods 00662 virtual INT32 CompareTo(SGDisplayNode *Other, INT32 SortKey); 00663 // Compares 'this' to 'Other' in a manner specified by 'SortKey', and returns 00664 // -1 (I am lesser), 0 (we are equal), or +1 (I am greater) 00665 00666 00667 public: // Searching support methods 00668 virtual void GetNameText(String_256 *Result); 00669 virtual void GetFullInfoText(String_256 *Result); 00670 // Returns the name/full-info text for this item, to support simple searching 00671 // operations, and generic redraw methods for library items. 00672 00673 virtual void GetKeyWords(String_256 *Result); 00674 // Returns the keyword string for this item, to support simple keyword searching 00675 // operations. 00676 00677 public: // Help methods 00678 virtual BOOL GetBubbleHelp(DocCoord *MousePos, String_256 *Result); 00679 // Returns a bubble help string (or returns FALSE if it couldn't supply one) 00680 00681 virtual BOOL GetStatusLineHelp(DocCoord *MousePos, String_256 *Result); 00682 // Returns a status-line help string (or returns FALSE if it couldn't) 00683 00684 00685 public: // Redraw/Layout-calculation/Click-handling 00686 virtual void StartRendering(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo); 00687 virtual void StopRendering(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo); 00688 // Methods which MUST be called by all derived node types before/after doing 00689 // any rendering 00690 00691 inline SGFormatInfo *GetFormatInfo(SGEventType EventType, void *EventInfo); 00692 inline SGRedrawInfo *GetRedrawInfo(SGEventType EventType, void *EventInfo); 00693 inline SGMouseInfo *GetMouseInfo(SGEventType EventType, void *EventInfo); 00694 inline DragMessage *GetDragInfo(SGEventType EventType, void *EventInfo); 00695 inline SGClaimPointInfo *GetClaimPointInfo(SGEventType EventType, void *EventInfo); 00696 inline ThumbMessage *GetThumbMsgInfo(SGEventType EventType, void *EventInfo); 00697 // Get various info blocks from the 'eventinfo' pointer, with ERROR3 checking 00698 00699 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 00700 SGMiscInfo *MiscInfo); 00701 // Requests that the node handles a given event (redraw, click, etc) 00702 00703 virtual void DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 00704 // Called by the drag system (SGListDragInfo - see sgdrag.h) when a drag 00705 // has turned out to be a simple click 00706 00707 virtual void GetFormatRect(DocRect *LayoutRect); 00708 // Returns the rectangle position at which this node last formatted itself 00709 00710 virtual void ForceRedrawOfMyself(BOOL bEraseBkg = TRUE); 00711 // Requests that the parent gallery forces this item's region of the screen to redraw 00712 00713 virtual void ForceRedrawOfMyselfAndChildren(void); 00714 // Same as above, but redraws this item and all its children. Only useful for 00715 // SGDisplayGroup nodes (and may not work for other node types) 00716 00717 virtual void SelectItems(BOOL SelectThem, BOOL Exclusive = FALSE, 00718 Document *ParentDocument = NULL, Library *ParentLibrary = NULL); 00719 // Selects/Deselects all items inside/outside a given doc/lib range 00720 00721 virtual void SelectGroups(BOOL SelectThem, BOOL Exclusive, 00722 Document *ParentDocument, Library *ParentLibrary); 00723 // Selects/Deselects all groups inside/outside a given doc/lib range 00724 00725 virtual void SelectRangeGroups(SGDisplayGroup *PrimeNode, SGDisplayGroup *AnchorNode); 00726 // Provides group range selection 00727 00728 virtual void SelectRangeItems(SGDisplayItem *PrimeNode, SGDisplayItem *AnchorNode); 00729 // Provides item range selection 00730 00731 protected: // Internal (derived class) helper methods 00732 virtual BOOL GiveEventToMyChildren(SGEventType EventType, void *EventInfo, 00733 SGMiscInfo *MiscInfo); 00734 // Interface for derived classes: Used to pass events to all children 00735 // of a node (saves derived classes having to bother duplicating tree-scan code) 00736 00737 virtual void NewLine(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo); 00738 // Updates the FormatInfo structure ready for the start of a new line 00739 00740 00741 virtual void CalculateFormatRect(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo, 00742 INT32 ItemWidth, INT32 ItemHeight); 00743 // Calculates the display rectangle which a node occupies 00744 00745 00746 BOOL IMustRedraw(SGRedrawInfo *RedrawInfo); 00747 // Determines if an item overlaps the redraw bounds and must therefore redraw itself 00748 00749 00750 inline INT32 DevicePixels(SGMiscInfo *MiscInfo, INT32 NumPixels); 00751 // Returns the size in millipoints that 'NumPixels' device pixels will be 00752 00753 inline static INT32 GridLock(SGMiscInfo *MiscInfo, INT32 Coordinate); 00754 // Snaps a millipoint coordinate onto a device-pixel coordinate boundary 00755 00756 static void GridLockRect(SGMiscInfo *MiscInfo, DocRect *Rect); 00757 // As GridLock, but does all 4 coordinates of the given rectangle in one go 00758 00759 void DrawPlinth(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, 00760 DialogColourInfo *RedrawColours, 00761 DocRect *ButtonRect, 00762 BOOL Indented = FALSE, 00763 UINT32 GlyphResourceID = 0); 00764 // Draw Windows-95 style button plinth, with an optional bitmap glyph 00765 00766 void DrawSelectionOutline(SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo, 00767 DocRect *BoundsRect, INT32 Width = 0); 00768 // Draws a (default: 2-pixel) wide black border just inside the given rectangle 00769 00770 void DrawBitmap(RenderRegion *Renderer, DocRect *BoundsRect, UINT32 ResID); 00771 // Draw a kernel-bitmap-resource bitmap into the gallery window 00772 00773 CWindowID GetListWindow(void); 00774 // Gets the list box window (for starting drags) 00775 00776 protected: // Derived class methods for background-redraw support 00777 virtual void RegisterForBGRedraw(void); 00778 // Registers this node, which will be called back later, to do background redraw 00779 00780 virtual BOOL DoBGRedraw(SGMiscInfo *MiscInfo); 00781 // Causes an immediate redraw of this node if it is pending background redraw 00782 // Called automatically by the base class event handlers at appropriate times, 00783 // but can also be used if you want to force immediate redraw of a pending item. 00784 00785 virtual void DeregisterForBGRedraw(void); 00786 // Ensures that this node is not registered for BG redraws. Used when flushing 00787 00788 00789 virtual BOOL ShouldIDrawForeground(BOOL ForceForeground = FALSE); 00790 // Called when redrawing to know whether you should do the first pass or second of BG redraw 00791 // Rerturns TRUE if you should redraw the second pass (i.e. act as if in FG mode) 00792 00793 static SGDisplayNode *CurrentBGRenderNode; 00794 static BOOL BGRenderClaimed; 00795 00796 00797 public: // SuperGallery interface for doing a background redraw pass 00798 SGDisplayNode *DoBGRedrawPass(SGMiscInfo *MiscInfo); 00799 // Scans for the next node in the tree which should be background redrawn, redraws it, and 00800 // returns a pointer to be used on the next pass. 00801 00802 public: 00803 virtual BOOL DefaultPreDragHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 00804 virtual BOOL DefaultClickHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo, 00805 BOOL AfterDrag = FALSE, BOOL AdjustDoubleClick = TRUE); 00806 // Provides default handling of a click for selection purposes. Call this 00807 // after doing special things like detecting hits on buttons within items, 00808 // so that your list selects just like all the others. 00809 00810 00811 public: // Flags indicating the status of this node 00812 SGDisplayFlags Flags; 00813 00814 00815 private: // Private data 00816 SGDisplayNode *Parent; // Tree links 00817 SGDisplayNode *Next; 00818 SGDisplayNode *Previous; 00819 // (Note: Child links are special cased in Root/Group to reduce memory usage in display items) 00820 00821 protected: 00822 DocRect FormatRect; // The cached rect of where we last formatted to 00823 static BOOL BkgEraseMode; // Flag indicating whether the background is erased on redrawing 00824 00825 #ifdef _DEBUG 00826 public: 00827 virtual void DumpSubtree(INT32 TreeLevel = 1); // Debugging - dumps out the (sub)tree to the debugger 00828 #endif 00829 }; 00830 00831 00832 00833 /*********************************************************************************************** 00834 00835 > inline SGDisplayNode *SGDisplayNode::GetParent() const 00836 00837 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00838 Created: 20/10/94 00839 Returns: A pointer to the resquested SGDisplayNode object, or NULL 00840 00841 Purpose: Finds the parent of this DisplayTree Node. 00842 Returns NULL if you have reached the boundary of the tree 00843 00844 SeeAlso: SuperGallery; SGDisplayNode::GetChild; 00845 SGDisplayNode::GetNext; SGDisplayNode::GetPrevious 00846 00847 ***********************************************************************************************/ 00848 00849 SGDisplayNode *SGDisplayNode::GetParent() const 00850 { 00851 return Parent; 00852 } 00853 00854 00855 00856 /*********************************************************************************************** 00857 00858 > inline SGDisplayNode *SGDisplayNode::GetNext() const 00859 00860 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00861 Created: 20/10/94 00862 Returns: A pointer to the resquested SGDisplayNode object, or NULL 00863 00864 Purpose: Finds the next (right) sibling of this DisplayTree Node. 00865 Returns NULL if you have reached the boundary of the tree 00866 00867 SeeAlso: SuperGallery; SGDisplayNode::GetParent; SGDisplayNode::GetChild; 00868 SGDisplayNode::GetPrevious 00869 00870 ***********************************************************************************************/ 00871 00872 SGDisplayNode *SGDisplayNode::GetNext() const 00873 { 00874 return Next; 00875 } 00876 00877 00878 00879 /*********************************************************************************************** 00880 00881 > inline SGDisplayNode *SGDisplayNode::GetPrevious() const 00882 00883 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00884 Created: 20/10/94 00885 Returns: A pointer to the resquested SGDisplayNode object, or NULL 00886 00887 Purpose: Finds the previous (left) sibling of this DisplayTree Node. 00888 Returns NULL if you have reached the boundary of the tree 00889 00890 SeeAlso: SuperGallery; SGDisplayNode::GetParent; SGDisplayNode::GetChild; 00891 SGDisplayNode::GetNext; 00892 00893 ***********************************************************************************************/ 00894 00895 SGDisplayNode *SGDisplayNode::GetPrevious() const 00896 { 00897 return Previous; 00898 } 00899 00900 00901 00902 /*********************************************************************************************** 00903 00904 > inline static INT32 SGDisplayNode::GridLock(SGMiscInfo *MiscInfo, INT32 Coordinate) 00905 00906 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00907 Created: 28/10/94 00908 00909 Inputs: MiscInfo - A structure containing information relevant to gridlocking. 00910 This is passed into all HandleEvent calls. 00911 00912 Coordinate - the coord to be snapped onto the pixel grid 00913 00914 Purpose: In order to avoid rounding errors in the mapping between millipoints and 00915 output device pixels from causing coordinates to alias to different pixels 00916 when in different positions, all SuperGallery display coordinates must be 00917 snapped onto a grid of pixel-positions. This function does this snapping. 00918 00919 SeeAlso: SGDisplayNode::GridLockRect; SGDisplayNode::DevicePixels 00920 00921 ***********************************************************************************************/ 00922 00923 INT32 SGDisplayNode::GridLock(SGMiscInfo *MiscInfo, INT32 Coordinate) 00924 { 00925 return(Coordinate - (Coordinate % MiscInfo->PixelSize)); 00926 } 00927 00928 00929 00930 /*********************************************************************************************** 00931 00932 > inline INT32 SGDisplayNode::DevicePixels(SGMiscInfo *MiscInfo, INT32 NumPixels) 00933 00934 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00935 Created: 28/10/94 00936 00937 Inputs: MiscInfo - A structure containing information relevant to gridlocking. 00938 This is passed into all HandleEvent calls. 00939 00940 NumPixels - the number of 'pixels' you want 00941 00942 Purpose: Because we work in millipoints, it is difficult to get the right values 00943 for 'thin' lines (1-device pixel thick) or thin gaps (e.g. 1 or 2 pixels) 00944 This function uses the FormatInfo to determine the size, in millipoints, of 00945 device pixels, and multiplies this by the input parameter, to give the 00946 size in millipoints of that many device pixels. 00947 00948 SeeAlso: SGDisplayNode::GridLock; SGDisplayNode::GridLockRect 00949 00950 ***********************************************************************************************/ 00951 00952 INT32 SGDisplayNode::DevicePixels(SGMiscInfo *MiscInfo, INT32 NumPixels) 00953 { 00954 return(NumPixels * MiscInfo->PixelSize); 00955 } 00956 00957 00958 00959 /*********************************************************************************************** 00960 00961 > inline SGFormatInfo *SGDisplayNode::GetFormatInfo(SGEventType EventType, void *EventInfo) 00962 00963 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00964 Created: 19/1/95 00965 00966 Inputs: EventType - The type of the current event 00967 EventInfo - TheEventInfo for the current event 00968 00969 Purpose: Extracts certain event information from the event information passed in 00970 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 00971 but checks the validity (ERROR3's if you've asked for the wrong type of 00972 information for the current event type, and if the information is NULL) 00973 00974 ***********************************************************************************************/ 00975 00976 SGFormatInfo *SGDisplayNode::GetFormatInfo(SGEventType EventType, void *EventInfo) 00977 { 00978 ERROR3IF(EventType != SGEVENT_FORMAT, "FormatInfo not available for this event type!"); 00979 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 00980 return((SGFormatInfo *) EventInfo); 00981 } 00982 00983 00984 /*********************************************************************************************** 00985 00986 > inline SGRedrawInfo *SGDisplayNode::GetRedrawInfo(SGEventType EventType, void *EventInfo) 00987 00988 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00989 Created: 19/1/95 00990 00991 Inputs: EventType - The type of the current event 00992 EventInfo - TheEventInfo for the current event 00993 00994 Purpose: Extracts certain event information from the event information passed in 00995 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 00996 but checks the validity (ERROR3's if you've asked for the wrong type of 00997 information for the current event type, and if the information is NULL) 00998 00999 ***********************************************************************************************/ 01000 01001 SGRedrawInfo *SGDisplayNode::GetRedrawInfo(SGEventType EventType, void *EventInfo) 01002 { 01003 ERROR3IF(EventType != SGEVENT_REDRAW, "RedrawInfo not available for this event type!"); 01004 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 01005 return((SGRedrawInfo *) EventInfo); 01006 } 01007 01008 01009 /*********************************************************************************************** 01010 01011 > inline SGMouseInfo *SGDisplayNode::GetMouseInfo(SGEventType EventType, void *EventInfo) 01012 01013 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01014 Created: 19/1/95 01015 01016 Inputs: EventType - The type of the current event 01017 EventInfo - TheEventInfo for the current event 01018 01019 Purpose: Extracts certain event information from the event information passed in 01020 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 01021 but checks the validity (ERROR3's if you've asked for the wrong type of 01022 information for the current event type, and if the information is NULL) 01023 01024 ***********************************************************************************************/ 01025 01026 SGMouseInfo *SGDisplayNode::GetMouseInfo(SGEventType EventType, void *EventInfo) 01027 { 01028 ERROR3IF(EventType != SGEVENT_MOUSECLICK, "MouseInfo not available for this event type!"); 01029 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 01030 return((SGMouseInfo *) EventInfo); 01031 } 01032 01033 01034 01035 /*********************************************************************************************** 01036 01037 > inline DragMessage *SGDisplayNode::GetDragInfo(SGEventType EventType, void *EventInfo) 01038 01039 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01040 Created: 28/2/95 01041 01042 Inputs: EventType - The type of the current event 01043 EventInfo - TheEventInfo for the current event 01044 01045 Purpose: Extracts certain event information from the event information passed in 01046 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 01047 but checks the validity (ERROR3's if you've asked for the wrong type of 01048 information for the current event type, and if the information is NULL) 01049 01050 ***********************************************************************************************/ 01051 01052 DragMessage *SGDisplayNode::GetDragInfo(SGEventType EventType, void *EventInfo) 01053 { 01054 ERROR3IF(EventType != SGEVENT_DRAGSTARTED, "DragInfo not available for this event type!"); 01055 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 01056 return((DragMessage *) EventInfo); 01057 } 01058 01059 01060 01061 /*********************************************************************************************** 01062 01063 > inline SGClaimPointInfo *SGDisplayNode::GetClaimPointInfo(SGEventType EventType, 01064 void *EventInfo) 01065 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01066 Created: 15/3/95 01067 01068 Inputs: EventType - The type of the current event 01069 EventInfo - TheEventInfo for the current event 01070 01071 Purpose: Extracts certain event information from the event information passed in 01072 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 01073 but checks the validity (ERROR3's if you've asked for the wrong type of 01074 information for the current event type, and if the information is NULL) 01075 01076 ***********************************************************************************************/ 01077 01078 SGClaimPointInfo *SGDisplayNode::GetClaimPointInfo(SGEventType EventType, void *EventInfo) 01079 { 01080 ERROR3IF(EventType != SGEVENT_CLAIMPOINT, "ClaimPointInfo not available for this event type!"); 01081 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 01082 return((SGClaimPointInfo *) EventInfo); 01083 } 01084 01085 01086 01087 /*********************************************************************************************** 01088 01089 > inline ThumbMessage *SGDisplayNode::GetThumbMsgInfo(SGEventType EventType, 01090 void *EventInfo) 01091 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01092 Created: 15/3/95 01093 01094 Inputs: EventType - The type of the current event 01095 EventInfo - TheEventInfo for the current event 01096 01097 Purpose: Extracts certain event information from the event information passed in 01098 to a SGDisplayNode::HandleEvent() method. Not only gets the info for you, 01099 but checks the validity (ERROR3's if you've asked for the wrong type of 01100 information for the current event type, and if the information is NULL) 01101 01102 ***********************************************************************************************/ 01103 01104 ThumbMessage *SGDisplayNode::GetThumbMsgInfo(SGEventType EventType, void *EventInfo) 01105 { 01106 ERROR3IF(EventType != SGEVENT_THUMBMSG, "ThumbMsg info not available for this event type!"); 01107 ERROR3IF(EventInfo == NULL, "EventInfo for this event was NULL!"); 01108 return((ThumbMessage *) EventInfo); 01109 } 01110 01111 01112 01113 /*********************************************************************************************** 01114 01115 > inline BOOL SGDisplayNode::IsSelected(void) 01116 01117 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01118 Created: 28/10/94 01119 01120 Purpose: Returns TRUE if this item is selected, FALSE if it is not 01121 01122 SeeAlso: SGDisplayItem::SetSelected 01123 01124 ***********************************************************************************************/ 01125 01126 BOOL SGDisplayNode::IsSelected(void) 01127 { 01128 return(Flags.Selected); 01129 } 01130 01131 01132 01133 /*********************************************************************************************** 01134 01135 > class SGDisplayRoot : public SGDisplayNode 01136 01137 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01138 Created: 19/10/94 01139 Purpose: This DisplayTree node type is used by the SuperGallery 01140 The top (root) level of the DisplayTree is made up of a single SGDisplayRoot 01141 node. This node is used as a single entry-point for all tree-wide actions 01142 which the SuperGallery applies to it (redraw, reformatting, etc) 01143 01144 By default, the root node is completely invisible on the display, and is just 01145 used for internal tidiness. However, galleries could override this class to 01146 make a new root type (e.g. you could override the redraw of the entire tree 01147 in certain display modes, to give a "show one item at a time" mode, etc) 01148 01149 If the root node has no children, it becomes visible, redrawing itself as 01150 a piece of grey text reading 'No items' or similar. 01151 01152 SeeAlso: SGDisplayRootScroll 01153 SeeAlso: SuperGallery; SGDisplayNode; SGDisplayGroup; SGDisplayItem; 01154 01155 ***********************************************************************************************/ 01156 01157 class CCAPI SGDisplayRoot : public SGDisplayNode 01158 { 01159 CC_DECLARE_DYNAMIC(SGDisplayRoot); 01160 01161 protected: 01162 SGDisplayRoot(); // Default constructor - DO NOT USE 01163 01164 01165 public: 01166 SGDisplayRoot(SuperGallery *ParentGal); // Proper constructor 01167 01168 01169 public: // Access methods 01170 virtual SGDisplayNode *GetChild(void) const; 01171 // Returns a pointer to this node's first child 01172 01173 protected: 01174 virtual void SetChild(SGDisplayNode *NewChild); 01175 // Internal method for setting the child pointer in derived classes 01176 01177 public: 01178 virtual SuperGallery *GetParentGallery(void) const; 01179 // Finds the gallery whch 'owns' this node and the tree it is in 01180 // Overridden, because Root nodes know this information 01181 01182 // Override insert/remove calls - the root never dies, and cannot have siblings 01183 // Insertions simply call AddItem to add the node as the last child of the root node 01184 virtual void InsertAfter(SGDisplayNode *NodeToInsert); 01185 virtual void InsertBefore(SGDisplayNode *NodeToInsert); 01186 virtual void RemoveFromTree(void); 01187 virtual void DestroySubtree(BOOL IncludingThisNode = TRUE); 01188 01189 virtual void InitFormatInfo(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo); 01190 // Initialises the FormatInfo structure ready for passing to ProcessEvent methods 01191 01192 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 01193 SGMiscInfo *MiscInfo); 01194 // Handles a display list event (redraw, mouse click, etc) 01195 01196 virtual INT32 CalculateListExtent(SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo); 01197 // Calculates the extent the list would fill if it were to be redrawn now 01198 01199 virtual INT32 GetCachedListExtent(void); 01200 // Retrieves the cached list extent. Only valid after a FORMAT has been done by the 01201 // tree (or a call to CalculateListExtent) 01202 01203 virtual void SetScrollOffset(INT32 NewOffset, SGMiscInfo *MiscInfo); 01204 virtual INT32 GetScrollOffset(void); 01205 // Set and retrieve the scroll offsets - DOES NOTHING (return 0) in this base class! 01206 01207 virtual void RedrawScrollBar(SGMiscInfo *MiscInfo); 01208 // Forces a redraw of the scroll bar area (if any) 01209 01210 virtual SGDisplayItem *FindNextSelectedItem(SGDisplayNode *CurrentItem = NULL, 01211 BOOL *SkipGroup = NULL); 01212 // Scans the selection over the entire display tree 01213 01214 virtual INT32 GetSelectedItemCount(void); 01215 // Counts the number of selected items in the entire display tree 01216 01217 virtual SGDisplayGroup *FindNextSelectedGroup(SGDisplayNode *CurrentGroup = NULL); 01218 // Scans the group selection over the entire display tree 01219 01220 virtual INT32 GetSelectedGroupCount(void); 01221 // Counts the number of selected groups in the entire display tree 01222 01223 virtual void SelectRange(SGDisplayNode *PrimeNode, SGDisplayNode *AnchorNode); 01224 // this works out if we're selecting groups or nodes... 01225 01226 static SGDisplayNode *FindNextItemInTree(SGDisplayNode *StartItem); 01227 // return the next item, skipping virtualised groups 01228 01229 protected: 01230 SGDisplayNode *Child; 01231 01232 SuperGallery *ParentGallery; 01233 01234 INT32 ScrollExtent; // The (positive) Y size of the display list in its current form 01235 }; 01236 01237 01238 01239 01240 01241 01242 // Indented button types for Scroll bar buttons 01243 typedef enum 01244 { 01245 IBUTTON_NONE, 01246 IBUTTON_UP, 01247 IBUTTON_DOWN 01248 } IndentedButtonValue; 01249 01250 01251 /*********************************************************************************************** 01252 01253 > class SGDisplayRootScroll : public SGDisplayRoot 01254 01255 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01256 Created: 21/1/95 01257 Purpose: This DisplayTree node type is used by the SuperGallery 01258 01259 It is identical to the DisplayRoot, except it provides a proportional scroll 01260 bar on the right edge of the display area, which automatically handles 01261 everything to do with scrolling. 01262 01263 i.e. to get a gallery witha scrollbar, simply use this root node type, and 01264 everything just happens automatically for you. 01265 01266 SeeAlso: SuperGallery; SGDisplayRoot; SGDisplayNode; SGDisplayGroup; SGDisplayItem; 01267 01268 ***********************************************************************************************/ 01269 01270 class CCAPI SGDisplayRootScroll : public SGDisplayRoot 01271 { 01272 CC_DECLARE_DYNAMIC(SGDisplayRootScroll); 01273 01274 public: 01275 SGDisplayRootScroll(SuperGallery *ParentGal); 01276 01277 01278 public: // Access methods 01279 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 01280 SGMiscInfo *MiscInfo); 01281 // Handles a display list event (redraw, mouse click, etc) 01282 01283 virtual void SetScrollOffset(INT32 NewOffset, SGMiscInfo *MiscInfo); 01284 virtual INT32 GetScrollOffset(void); 01285 // Set and retrieve the scroll offsets 01286 01287 virtual void RedrawScrollBar(SGMiscInfo *MiscInfo); 01288 // Forces a redraw of the scroll bar area (if any) 01289 01290 public: // Access methods for SGScrollDragTarget class 01291 virtual BOOL CalculateScrollRects(SGMiscInfo *MiscInfo, 01292 BOOL Translate, 01293 DocRect *UpButton, DocRect *DownButton, 01294 DocRect *Sausage, DocRect *PageUp = NULL, 01295 DocRect *PageDown = NULL, DocRect *ScrollRect = NULL); 01296 01297 INT32 IndentedButton; // An identifier as to which scroll button (if any) is indented 01298 01299 01300 protected: 01301 virtual BOOL CalculateSausageRect(SGMiscInfo *MiscInfo, 01302 DocRect *ScrollBarRect, DocRect *Result); 01303 // Determines the position/size of the proportional scroll bar 'sausage' 01304 01305 private: 01306 INT32 ScrollOffset; // The offset (positive) to the displayed portion of the list 01307 }; 01308 01309 01310 01311 01312 01313 01314 /*********************************************************************************************** 01315 01316 > class SGDisplayGroup : public SGDisplayNode 01317 01318 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01319 Created: 19/10/94 01320 Purpose: This DisplayTree node type is used by the SuperGallery 01321 The top level(s) of the DisplayTree are made up of a number of SGDisplayGroup 01322 nodes, which divide the tree up into categories (and, potentially hierarchical 01323 groups within categories). 01324 01325 Groups have special properties, including a Title, which they will redraw, 01326 and pointers to their parent Document, Library, and SuperGallery. 01327 01328 SeeAlso: SuperGallery; SGDisplayNode; SGDisplayRoot; SGDisplayItem 01329 01330 ***********************************************************************************************/ 01331 01332 class CCAPI SGDisplayGroup : public SGDisplayNode 01333 { 01334 CC_DECLARE_DYNAMIC(SGDisplayGroup); 01335 01336 01337 public: 01338 SGDisplayGroup(); 01339 SGDisplayGroup(SuperGallery *ParentGal, 01340 Document *ParentDoc = NULL, Library *ParentLib = NULL); 01341 01342 public: 01343 virtual SGDisplayNode* GetChild(void) const; 01344 // Returns a pointer to this node's first child 01345 01346 protected: 01347 virtual void SetChild(SGDisplayNode *NewChild); 01348 // Internal method for setting the child pointer in derived classes 01349 01350 public: 01351 inline Document *GetParentDocument(void); 01352 // Returns NULL or the Document that 'owns' this subtree 01353 01354 inline Library *GetParentLibrary(void); 01355 // Returns NULL or the Library that 'owns' this subtree 01356 01357 virtual SuperGallery *GetParentGallery(void) const; 01358 // Returns the SuperGallery that 'owns' this subtree 01359 01360 virtual void DragWasReallyAClick(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 01361 // Called by the drag system (SGListDragInfo - see sgdrag.h) when a drag 01362 // has turned out to be a simple click 01363 01364 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 01365 SGMiscInfo *MiscInfo); 01366 // Handles a display list event (redraw, mouse click, etc) 01367 01368 virtual void ForceRedrawOfMyselfAndChildren(void); 01369 // Overrides the default, to draw this node and all children thereof 01370 01371 virtual SGDisplayItem *FindNextSelectedItem(SGDisplayItem *CurrentItem = NULL); 01372 // Finds the first and subsequent selected child item(s) of a group 01373 01374 virtual INT32 GetSelectedItemCount(void); 01375 // Determines how many child items of this group are selected 01376 01377 virtual void SelectItems(BOOL SelectThem, BOOL Exclusive = FALSE, 01378 Document *ParentDocument = NULL, Library *ParentLibrary = NULL); 01379 // Selects/Deselects all items inside/outside a given doc/lib range 01380 01381 virtual void SelectGroups(BOOL SelectThem, BOOL Exclusive, 01382 Document *ParentDocument, Library *ParentLibrary); 01383 // Selects/Deselects all groups inside/outside a given doc/lib range 01384 01385 virtual BOOL SetFoldedState(BOOL NewState, BOOL ForceRedraw = TRUE); 01386 // Folds/Unfolds the given node, returning TRUE if this call actually changed the state 01387 01388 void GetChildArea(DocRect *Result); 01389 // Reads the group's child area (the bounding rectangle of the group's children) rectangle 01390 // If the group is folded (or has not been reformatted since folding) this is Empty 01391 01392 01393 public: // Functions for virtualisation of groups (building groups but not adding items until we need them) 01394 virtual BOOL CanVirtualise(void); 01395 // Can this group virtualise out to disk ? 01396 01397 virtual BOOL Virtualise(void); 01398 // Virtualise out 01399 01400 virtual BOOL DeVirtualise(void); 01401 // Virtualise back in 01402 01403 void SetVirtualisedState(BOOL NewValue) {Flags.Virtualised = NewValue;}; 01404 // Set the Virtualised variable 01405 01406 BOOL IsVirtualised(void) {return Flags.Virtualised;}; 01407 // Is this group virtualised out to disk ? 01408 01409 public: 01410 virtual BOOL DefaultPreDragHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 01411 virtual BOOL DefaultClickHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo, BOOL AfterDrag = FALSE); 01412 // Provides default handling of a click for selection purposes. Call this 01413 // after doing special things like detecting hits on buttons within items, 01414 // so that your list selects just like all the others. 01415 01416 protected: // Internal handlers 01417 virtual void ReadGroupTitle(void); 01418 // (Re)Reads a group's title text from the parent doc/lib 01419 01420 01421 protected: 01422 SGDisplayNode* Child; 01423 01424 String_64 TitleText; 01425 01426 Document *ParentDocument; // NULL or pointer to document this represents 01427 Library *ParentLibrary; // NULL or pointer to library this represents 01428 01429 SuperGallery *ParentGallery; // Pointer to the SuperGallery who owns us 01430 01431 DocRect ChildArea; // Rectangle containing my children 01432 }; 01433 01434 01435 01436 /*********************************************************************************************** 01437 01438 > inline Document *SGDisplayGroup::GetParentDocument(void) 01439 01440 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01441 Created: 28/10/94 01442 01443 Returns: The parent document, or NULL 01444 01445 Purpose: Returns the document which this node (and its subtree) references 01446 01447 SeeAlso: SGDisplayGroup::GetParentGallery; SGDisplayGroup::GetParentLibrary 01448 01449 ***********************************************************************************************/ 01450 01451 Document *SGDisplayGroup::GetParentDocument(void) 01452 { 01453 return(ParentDocument); 01454 } 01455 01456 01457 01458 /*********************************************************************************************** 01459 01460 > inline Library *SGDisplayGroup::GetParentLibrary(void) 01461 01462 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01463 Created: 28/10/94 01464 01465 Returns: The parent library, or NULL 01466 01467 Purpose: Returns the Library which this node (and its subtree) references 01468 01469 SeeAlso: SGDisplayGroup::GetParentGallery; SGDisplayGroup::GetParentDocument 01470 01471 ***********************************************************************************************/ 01472 01473 Library *SGDisplayGroup::GetParentLibrary(void) 01474 { 01475 return(ParentLibrary); 01476 } 01477 01478 01479 01480 01481 /*********************************************************************************************** 01482 01483 > class SGDisplayItem : public SGDisplayNode 01484 01485 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 01486 Created: 19/10/94 01487 Purpose: This DisplayTree node is used by the SuperGallery 01488 It is responsible for providing the ability to redraw one item displayed in 01489 the gallery, and remembering information on that item (such as its selection 01490 state, etc). 01491 01492 Generally, SGDisplayItems should only occur as leaf-nodes - this base class 01493 overrides the methods of SGDisplayNodes in order to discourage any attempt 01494 to make these nodes non-leaf-nodes. 01495 01496 This class should be used to derive new DisplayItem classes from for each of 01497 the SuperGalleries. For example, the Froodle SuperGallery might provide two 01498 types of SGDisplayItem: 01499 MonoOn 01500 FroodleSGDisplayItem (which holds a pointer to a Froodle in a document) 01501 LibFroodleSGDisplayItem (which holds the information on a Froodle in an 01502 open FroodleLibrary file) 01503 MonoOff 01504 01505 SeeAlso: SuperGallery; SGDisplayNode; SGDisplayRoot; SGDisplayGroup 01506 01507 ***********************************************************************************************/ 01508 01509 class CCAPI SGDisplayItem : public SGDisplayNode 01510 { 01511 CC_DECLARE_DYNAMIC(SGDisplayItem); 01512 01513 public: 01514 SGDisplayItem(); 01515 01516 public: 01517 virtual BOOL HandleEvent(SGEventType EventType, void *EventInfo, 01518 SGMiscInfo *MiscInfo); 01519 // Handles a display list event (redraw, mouse click, etc) 01520 01521 public: 01522 virtual BOOL DefaultPreDragHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo); 01523 virtual BOOL DefaultClickHandler(SGMouseInfo *Mouse, SGMiscInfo *MiscInfo, 01524 BOOL AfterDrag = FALSE, BOOL AdjustDoubleClick = TRUE); 01525 // Provides default handling of a click for selection purposes. Call this 01526 // after doing special things like detecting hits on buttons within items, 01527 // so that your list selects just like all the others. 01528 01529 public: // Overridden tree generation methods - disallow certain insertions 01530 virtual void RemoveFromTree(void); 01531 // Ensures the item is deselected and informs the parent gallery if necessary 01532 01533 virtual void AddItem(SGDisplayNode *NodeToInsert, SGSortKey *SortInfo = NULL); 01534 // Inserts the given node into this subtree. ERRORS, as we can't have children! 01535 }; 01536 01537 01538 #endif 01539