grtree.h

Go to the documentation of this file.
00001 /**
00002  * \file grtree.h <mi32/grtree.h>
00003  * \brief Definitions for GraphicTree functions
00004  *
00005  * \if NODOC
00006  * $Id: grtree.h_v 1.47 2005/06/07 18:02:06 mju Exp $
00007  *
00008  * $Log: grtree.h_v $
00009  * Revision 1.47  2005/06/07 18:02:06  mju
00010  * Change enum to not overlap.
00011  *
00012  * Revision 1.46  2005/05/31 21:23:26  mju
00013  * Add procmsg NoSelect enum.
00014  *
00015  * Revision 1.45  2005/03/31 16:57:11  fileserver!dwilliss
00016  * Rename one of our types to MIUNICODE because it conflicted with a Microsoft #define
00017  *
00018  * Revision 1.44  2005/02/15 17:56:01  scowan
00019  * Added unused default ctor for graphic tree so that native and mfc builds
00020  * will shut up about it.
00021  *
00022  * Revision 1.43  2004/02/16 15:31:24  mju
00023  * Don't include X stuff as need to build for MFC also.
00024  *
00025  * Revision 1.42  2004/02/12 22:15:24  dwilliss
00026  * Deprecate old MGD
00027  *
00028  * Revision 1.41  2003/12/01 20:55:02  dwilliss
00029  * Added new static event handler
00030  *
00031  * Revision 1.40  2003/09/15 13:49:56  fileserver!dwilliss
00032  * Doxygen
00033  *
00034  * Revision 1.39  2002/09/12 22:30:45  dwilliss
00035  * Added a member to keep track of where tool tip popped up
00036  *
00037  * Revision 1.38  2002/08/28 20:59:16  scowan
00038  * Added private nested class.
00039  *
00040  * Revision 1.37  2002/02/08 15:42:03  mju
00041  * Make ScrollToItem() public.
00042  *
00043  * Revision 1.36  2002/02/08 14:59:29  mju
00044  * Add GetActiveItem method.
00045  *
00046  * Revision 1.35  2001/11/27 14:25:40  mju
00047  * Add ITEM::SetMayHaveChildren().
00048  *
00049  * Revision 1.34  2001/07/09 20:44:14  mju
00050  * n/c
00051  *
00052  * Revision 1.33  2001/05/09 16:47:08  mju
00053  * Allow access to ITEM pointer and add ITEM methods for navigation.
00054  * Make MSG nested in ITEM.
00055  * Add MSG::GetItem() and associated item member.
00056  *
00057  * Revision 1.32  2001/05/08 21:42:24  mju
00058  * Add single-selection mode.
00059  * Add ability to include expand/collapse icons.
00060  *
00061  * Revision 1.31  2000/09/19 19:34:39  dwilliss
00062  * doubleclick test not available in win32-native
00063  *
00064  * Revision 1.30  2000/09/19 17:54:19  dwilliss
00065  * Added double click support
00066  *
00067  * Revision 1.29  2000/09/15 19:10:02  dwilliss
00068  * Added Double click message
00069  *
00070  * Revision 1.28  2000/08/14 17:53:02  dwilliss
00071  * Evil default constructor for message struct
00072  *
00073  * Revision 1.27  2000/08/14 15:01:32  dwilliss
00074  * Why does it think I still have this checked out locked?  I just checked in
00075  * revision 1.26
00076  *
00077  * Revision 1.26  2000/08/14 14:58:34  dwilliss
00078  * Added Get/SetPrivData() to the tree
00079  * Added pointer to the tree to the message structure
00080  * Gave message structure a constructor which takes tree so you can't mess it up.
00081  *
00082  * Revision 1.25  2000/06/12 12:57:19  sparsons
00083  * Genitor documentation.
00084  *
00085  * Revision 1.24  2000/06/07 14:19:21  mju
00086  * Include xdefns.h.
00087  *
00088  * Revision 1.23  2000/01/14 23:13:00  mju
00089  * Add ItemExists.
00090  *
00091  * Revision 1.21  1999/10/19 20:52:01  mju
00092  * Use callbacks for scrolling.
00093  *
00094  * Revision 1.20  1999/10/14  22:09:29  mju
00095  * Use m_ for member vars.
00096  *
00097  * Revision 1.19  1999/10/13  20:39:01  mju
00098  * Include mg2x.h if not already.
00099  *
00100  * Revision 1.18  1999/08/23  15:48:44  dwilliss
00101  * Don't leave dangling commas on enums or the Macintosh will hate you
00102  *
00103  * Revision 1.17  1999/07/15 13:48:40  mju
00104  * Declare cb/eh removal methods.
00105  *
00106  * Revision 1.16  1999/04/30  16:54:00  mju
00107  * Use DEFINE_ENUM_OPERATORS for flags.
00108  *
00109  * Revision 1.15  1999/03/12  23:06:39  mju
00110  * Add autoscroll flag to DrawInsertionIndicator.
00111  *
00112  * Revision 1.14  1999/03/12  16:07:22  mju
00113  * Eliminate defaulting for all RefIndex parameters.
00114  *
00115  * Revision 1.13  1999/03/10  15:34:03  mju
00116  * Add "RefIndex" stuff so can reuse references.
00117  *
00118  * Revision 1.12  1999/03/09  18:20:41  mju
00119  * Add items needed for drag-and-drop reordering.
00120  *
00121  * Revision 1.11  1999/03/01  17:57:57  mju
00122  * Add control of children visibility.
00123  *
00124  * Revision 1.10  1999/02/26  18:21:15  mju
00125  * Fix popup menu support.
00126  *
00127  * Revision 1.9  1999/02/26  14:26:24  mju
00128  * Don't declare MSG.popupmenu if WIN32_NATIVE.
00129  *
00130  * Revision 1.7  1999/02/24  23:06:42  mju
00131  * Add ToolTip support.
00132  * Add methods to disable drawing.
00133  *
00134  * Revision 1.6  1999/02/19  23:08:48  mju
00135  * Eliminate callback system, add messages for selected/deselected/deleting.
00136  *
00137  * Revision 1.5  1999/01/29  22:18:08  mju
00138  * Don't define constructor using widget in win32-native mode.
00139  *
00140  * Revision 1.4  1999/01/29  22:13:58  mju
00141  * Redesign to be a class.
00142  *
00143  * Revision 1.1  1999/01/05  21:10:42  mju
00144  * Initial revision
00145  *
00146  * \endif
00147 **/
00148 
00149 #ifndef  INC_MI32_GRTREE_H
00150 #define  INC_MI32_GRTREE_H
00151 
00152 #if !defined(INC_MI32_XDEFNS_H) && defined(X_NATIVE)
00153    #include <mi32/xdefns.h>
00154 #endif
00155 
00156 #ifndef  INC_MI32_MCB_H
00157 #include <mi32/mcb.h>
00158 #endif
00159 
00160 #ifndef  INC_MI32_POINT_H
00161 #include <mi32/point.h>
00162 #endif
00163 
00164 #ifndef  INC_MI32_RECT_H
00165 #include <mi32/rect.h>
00166 #endif
00167 
00168 #if !defined(INC_MI32_MGD2_H)
00169 #include <mi32/mgd2.h>
00170 #endif
00171 
00172 #ifndef GENERATING_DOXYGEN_OUTPUT
00173 const int GTREEHASHSIZE = 37;          //!< Size of hash table
00174 #endif //!< GENERATING_DOXYGEN_OUTPUT
00175 
00176 
00177 class GRAPHICTREE {
00178    public:
00179 
00180       //! Flags used in tree and item creation.
00181       enum FLAGS {
00182          FirstAtTop =            0x00000000,
00183          FirstAtBottom =         0x00000001,
00184          NoScrollHorizontal =    0x00000002, //!< Don't include horizontal scrollbar
00185          AllowChildSelection =   0x00000004,
00186          AllowChildReorder =     0x00000008,
00187          IncludeExpandIcons =    0x00000010, //!< Include expand/collapse icons
00188          ItemMayHaveChildren =   0x00000020, //!< Item may have children, determine when attempt to expand
00189          SingleSelectionOnly =   0x00000040, //!< Only single tree item may be selected at a time
00190          ChildrenHidden =        0x00000080  //!< Children initially hidden
00191          };
00192 
00193       //! Individual tree item.
00194       class ITEM {
00195          public:
00196 
00197             //! Message container to send to message handler.
00198             class MSG {
00199                public:
00200 
00201                   //! Message type.
00202                   enum MSGTYPE {
00203                      NoMessage = 0,
00204                      Draw,
00205                      PointerMotion,
00206                      ButtonPressed,
00207                      ButtonReleased,
00208                      ButtonMotion,
00209                      KeyPressed,
00210                      KeyReleased,
00211                      RequestSize,
00212                      Deselected,
00213                      Selected,                        //!< Item "selected"
00214                      PositionChanged,                 //!< Position changed
00215                      Deleting,                        //!< Item being deleted
00216                      RequestToolTip,                  //!< Requesting ToolTip
00217                      ButtonDoubleClick,               //!< User double-clicked
00218                      ShowChildren,                    //!< Children about to be shown
00219                      HideChildren                     //!< Children have been hidden
00220                      };
00221 
00222                   //! Processing done for Button/KeyPress messages.
00223                   enum MSGPROC {       
00224                      Ignored = 0x000,                 //!< Message was ignored, don't send Button/Key release message
00225                      Normal = 0x001,                  //!< Message handled, send Button/KeyRelease message
00226                      Reset = 0x002,                   //!< Message handled and Button/KeyRelease consumed also (grab)
00227                      PopupMenu = 0x004,               //!< Message handler wants graphictree to popup menu
00228                      NoSelect = 0x100                 //!< Don't select item user clicked on
00229                      };
00230 
00231                   enum BTNKEY {
00232                      ButtonLeft =   0x01,
00233                      ButtonMiddle = 0x02,
00234                      ButtonRight =  0x04,
00235                      Shift =        0x10,
00236                      Control =      0x20
00237                      };
00238 
00239                   MSGTYPE type;                       //!< Message type
00240                   void *Reference;                    //!< Item reference
00241                   void *PrivPtr;                      //!< Item's private pointer if set
00242                   UINT32 RefIndex;                    //!< Item reference index
00243                   LPOINT2D origin;                    //!< Item origin in window coordinates
00244                   LPOINT2D pointer;                   //!< Pointer location where event occurred
00245                   MSGPROC proc;                       //!< What processing message handler did
00246                   BTNKEY state;                       //!< Button/Modifier key state
00247                   BTNKEY button;                      //!< Which button was pressed/released
00248                   MIUNICODE key;                      //!< Which key was pressed/released
00249                   LRECT2D drawrect;                   //!< Rectangle to draw
00250                   MGD::CONTEXT* gc;                   //!< Graphic context for drawing
00251                   UINT32 VisibleWidth;                //!< Visible width for SizeRequest
00252                   LPOINT2D size;                      //!< Item size for SizeRequest
00253                   MIUNICODE *tooltip;                    //!< ToolTip string returned (will be freed)
00254                #ifdef X_NATIVE
00255                   Widget popupmenu;                   //!< Menu to display when message handler requests
00256                #endif
00257                   GRAPHICTREE* tree;                  //!< The GRAPHICTREE that the message came from.
00258 
00259                   //! Default constructor.
00260                   MSG (
00261                      ) {
00262                      memset(this, 0, sizeof(MSG));
00263                      }
00264 
00265                   //! Get item message applies to.
00266                   ITEM* GetItem (
00267                      ) const { return (m_item); }
00268 
00269                private:
00270                   #ifndef GENERATING_DOXYGEN_OUTPUT
00271                   ITEM *m_item;
00272                   #endif // GENERATING_DOXYGEN_OUTPUT
00273                friend class ITEM;
00274                }; //! End of MSG class
00275 
00276             //! Get first child for this item.
00277             //! @return ITEM pointer or NULL if no children.
00278             ITEM* GetFirstChild (
00279                ) const { return (FirstChild); }
00280 
00281             //! Get next sibling for this item.
00282             //! @return ITEM pointer or NULL if end of list.
00283             ITEM* GetNextSibling (
00284                ) const { return (NextSibling); }
00285 
00286             //! Get parent for this item.
00287             //! @return ITEM pointer or NULL if this is root item.
00288             ITEM* GetParent (
00289                ) const { return (Parent); }
00290 
00291             //! Get 'private pointer' for this item.
00292             void* GetPrivPtr (
00293                ) const { return (m_PrivPtr); }
00294 
00295             //! Get 'reference index' for this item.
00296             UINT32 GetRefIndex (
00297                ) const { return (RefIndex); }
00298 
00299             //! Get 'reference pointer' used when item was created.
00300             void* GetRefPointer (
00301                ) const { return (Reference); }
00302 
00303             //! Get 'selected' child for this item.
00304             //! @return ITEM pointer or NULL if none selected.
00305             ITEM* GetSelectedChild (
00306                ) const { return (ActiveChild); }
00307 
00308             //! Get GRAPHICTREE associated with item.
00309             //! @return Reference to GRAPHICTREE.
00310             GRAPHICTREE& GetTree (
00311                ) const { return (m_tree); };
00312 
00313             //! Determine if this is the 'root' item.
00314             bool IsRoot (
00315                ) const { return (Parent == 0); }
00316 
00317             //! Set visibility for item's children.
00318             void SetChildrenVisible (
00319                bool visible = true,
00320                bool redraw = true
00321                );
00322 
00323             //! Set spacing between children.
00324             void SetChildSpacing (
00325                UINT8 p_Spacing
00326                ) { Spacing = p_Spacing; SetTotalSizeInvalid(); return; }
00327 
00328             //! Set whether item 'might' have children.
00329             //! This setting has no effect if item does have children.
00330             void SetMayHaveChildren (
00331                bool p_MayHaveChildren = true
00332                ) { MayHaveChildren = p_MayHaveChildren; }
00333 
00334             //! Set 'private pointer' for this item.
00335             void SetPrivPtr (
00336                void *PrivPtr
00337                ) { m_PrivPtr = PrivPtr; }
00338 
00339          private:
00340             #ifndef GENERATING_DOXYGEN_OUTPUT
00341             GRAPHICTREE& m_tree;       //!< Tree containing item
00342             void *Reference;
00343             void *m_PrivPtr;
00344             UINT32 RefIndex;
00345             void (*HandleMsg)(MSG*);   //! Message handler
00346             LPOINT2D TopLeft;          //!< Top-Left point for item relative to parent
00347             LPOINT2D ItemSize;         //!< Size of item in pixels
00348             LPOINT2D TotalSize;        //!< Size of item and all visible children including margins
00349             UINT8 Visible;             //!< Set if item is visible
00350             UINT8 ChildrenVisible;     //!< Set if children are visible
00351             UINT8 Hidden;              //!< Set if item is hidden based on visibility settings
00352             UINT8 ItemSizeValid;       //!< Set if Size for this item is valid
00353             UINT8 TotalSizeValid;      //!< Set if TotalSize is valid
00354             UINT8 FirstChildAtBottom;  //!< First child in list is at bottom
00355             UINT8 AllowChildSelection; //!< Allow child to be selected graphically
00356             UINT8 AllowChildReorder;   //!< Allow children to be reordered via drag-and-drop
00357             UINT8 MayHaveChildren;     //!< Item might have children, determine on expansion
00358             UINT8 MarginTop;           //!< Top margin for child list
00359             UINT8 MarginBottom;        //!< Bottom margin for child list
00360             UINT8 MarginLeft;          //!< Left margin for child list
00361             UINT8 MarginRight;         //!< Right margin for child list
00362             UINT8 Spacing;             //!< Spacing between children
00363             ITEM *Parent;              //!< Parent item, NULL if item is root
00364             ITEM *NextSibling;         //!< Next sibling item if any
00365             ITEM *FirstChild;          //!< First child item if any
00366             ITEM *ActiveChild;         //!< Active child item if any
00367             ITEM *NextHash;            //!< Next item in hash list
00368 
00369             ITEM (
00370                GRAPHICTREE& tree
00371                );
00372 
00373             ITEM (
00374                ITEM *parent, 
00375                void *ItemRef, 
00376                UINT32 RefIndex, 
00377                void (*HandleMsg)(MSG*),
00378                FLAGS flags
00379                );
00380 
00381             ~ITEM (
00382                );
00383 
00384             int GetPosition (
00385                );
00386 
00387             void Initialize (
00388                );
00389 
00390             void Insert (
00391                int
00392                );
00393 
00394             void Remove (
00395                );
00396 
00397             void SendMsg (
00398                MSG& msg, 
00399                MSG::MSGTYPE msgtype=MSG::NoMessage
00400                );
00401 
00402             void SendMsg (
00403                MSG::MSGTYPE msgtype
00404                );
00405 
00406             void SetTotalSizeInvalid (
00407                );
00408 
00409             friend class GRAPHICTREE;        //!< Give GRAPHICTREE access to ITEM
00410             #endif // GENERATING_DOXYGEN_OUTPUT
00411          };
00412 
00413 #ifdef X_NATIVE
00414       //! Constructor.
00415       GRAPHICTREE (                    
00416          Widget parent,
00417          const char *sizefield,
00418          Arg *arglist,
00419          int argcount,
00420          FLAGS flags = FirstAtTop
00421          );
00422 #else
00423       //! Constructor.
00424       GRAPHICTREE ();         // To stop warnings on NATIVE and MFC builds
00425 #endif
00426       //! Destructor.
00427       ~GRAPHICTREE ();
00428 
00429       //! Delete all children of specified parent.
00430       void DeleteChildren (
00431          void *ParentReference,
00432          UINT32 ParentRefIndex,
00433          bool redraw = true
00434          );
00435 
00436       //! Find item matching specified reference pointer and index.
00437       //! @return Pointer to item or NULL if none found.
00438       ITEM* FindItemByRef (
00439          const void *RefPointer,
00440          UINT32 RefIndex
00441          ) const;
00442 
00443       //! Get "active" child for given parent if any.
00444       void *GetActiveChild (           
00445          void *ParentReference,
00446          UINT32 ParentRefIndex
00447          );
00448 
00449       //! get 'active' item in single-selection mode.
00450       //! @return Pointer to active item, NULL if none active.
00451       ITEM* GetActiveItem (
00452          ) const { return (m_ActiveItem); }
00453 
00454 #ifdef X_NATIVE
00455       //! Get DrawingArea widget for GraphicTree.
00456       Widget GetDrawingArea (          
00457          ) const {
00458          return (m_da);
00459          }
00460 #endif
00461       //! Get first child for given parent.                                         
00462       void *GetFirstItem (          
00463          void *ParentReference,
00464          UINT32 ParentRefIndex
00465          ) const;
00466 
00467       //! Get next "sibling" item.
00468       void *GetNextItem (              
00469          void *ItemReference,
00470          UINT32 ItemRefIndex
00471          ) const;
00472 
00473       void *GetParentItem (
00474          void *ItemReference,
00475          UINT32 ItemRefIndex
00476          ) const;
00477 
00478       void * GetPrivData (
00479          ) const {
00480          return (m_PrivPtr);
00481          }
00482 
00483       const ITEM* GetRootItem (
00484          ) const { return (&m_Root); }
00485 
00486 #ifdef X_NATIVE
00487       //! Get widget.
00488       Widget GetWidget (
00489          ) const {
00490          return (XtParent(m_da));
00491          }
00492 #endif
00493       //! Add item to GRAPHICTREE as child of specified item.
00494       //! @return Pointer to ITEM added.
00495       ITEM* ItemAdd (                     
00496          void *ParentReference,
00497          UINT32 ParentRefIndex,
00498          void *ItemReference,
00499          UINT32 ItemRefIndex,
00500          void (*MsgHandler)(ITEM::MSG*),
00501          int position,
00502          FLAGS flags = FirstAtTop
00503          );
00504 
00505       //! Add item to GRAPHICTREE as child of root.
00506       //! @return Pointer to ITEM added.
00507       ITEM* ItemAdd (                     
00508          void *ItemReference,
00509          UINT32 ItemRefIndex,
00510          void (*MsgHandler)(ITEM::MSG*),
00511          int position,
00512          FLAGS flags = FirstAtTop
00513          ) {
00514          return (ItemAdd(NULL,0,ItemReference,ItemRefIndex,MsgHandler,position,flags));
00515          }
00516 
00517       //! Determine if item's children are visible.
00518       bool ItemAreChildrenVisible (    
00519          void *ItemReference,
00520          UINT32 ItemRefIndex
00521          );
00522 
00523       //! Delete item and all children.
00524       bool ItemDelete (                
00525          void *ItemReference,
00526          UINT32 ItemRefIndex,
00527          bool redraw = true
00528          );
00529 
00530       //! Determine if specified item exists.
00531       bool ItemExists (                
00532          void *ItemReference,
00533          UINT32 ItemRefIndex
00534          ) {
00535          return (FindItemByRef(ItemReference,ItemRefIndex) != NULL);
00536          }
00537 
00538       //! Get position of item in parent's list of children.
00539       int ItemGetPosition (            
00540          void *ItemReference,
00541          UINT32 ItemRefIndex
00542          );
00543 
00544       //! Get private pointer for item.
00545       void* ItemGetPrivPtr (           
00546          void *ItemReference,
00547          UINT32 ItemRefIndex
00548          ) {
00549          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) return (item->GetPrivPtr());
00550          return (NULL);
00551          }
00552 
00553       //! Determine visibility for item.
00554       bool ItemIsVisible (             
00555          void *ItemReference,
00556          UINT32 ItemRefIndex
00557          );
00558 
00559       //! Notify GRAPHICTREE that item has changed so will update size.
00560       void ItemNotifyChanged (         
00561          void *ItemReference,
00562          UINT32 ItemRefIndex,
00563          bool redraw = true
00564          );
00565 
00566       //! Redraw specified item.
00567       void ItemRedraw (                
00568          void *ItemReference,
00569          UINT32 ItemRefIndex
00570          );
00571 
00572       //! Set bottom margin for child list.
00573       void ItemSetChildMarginBottom (  
00574          void *ItemReference,
00575          UINT32 ItemRefIndex,
00576          UINT8 Margin
00577          ) {
00578          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) {
00579             item->MarginBottom = Margin;
00580             item->SetTotalSizeInvalid();
00581             }
00582          return;
00583          }
00584 
00585       //! Set left margin for child list.
00586       void ItemSetChildMarginLeft (    
00587          void *ItemReference,
00588          UINT32 ItemRefIndex,
00589          UINT8 Margin
00590          ) {
00591          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) {
00592             item->MarginLeft = Margin;
00593             item->SetTotalSizeInvalid();
00594             }
00595          return;
00596          }
00597 
00598       //! Set right margin for child list.
00599       void ItemSetChildMarginRight (   
00600          void *ItemReference,
00601          UINT32 ItemRefIndex,
00602          UINT8 Margin
00603          ) {
00604          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) {
00605             item->MarginRight = Margin;
00606             item->SetTotalSizeInvalid();
00607             }
00608          return;
00609          }
00610 
00611       //! Set top margin for child list.
00612       void ItemSetChildMarginTop (     
00613          void *ItemReference,
00614          UINT32 ItemRefIndex,
00615          UINT8 Margin
00616          ) {
00617          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) {
00618             item->MarginTop = Margin;
00619             item->SetTotalSizeInvalid();
00620             }
00621          return;
00622          }
00623 
00624       //! Set spacing between children.
00625       void ItemSetChildSpacing (       
00626          void *ItemReference,
00627          UINT32 ItemRefIndex,
00628          UINT8 Spacing
00629          ) {
00630          if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) {
00631             item->SetChildSpacing(Spacing);
00632             }
00633          return;
00634          }
00635 
00636       //! Set visibility for children of item.
00637       void ItemSetChildrenVisible (    
00638          void *ItemReference,
00639          UINT32 ItemRefIndex,
00640          bool visible,
00641          bool redraw = true
00642          );
00643 
00644       //! Set item position in list.
00645       void ItemSetPosition (
00646          void *ItemReference,
00647          UINT32 ItemRefIndex,
00648          int position,
00649          bool redraw = true
00650          );
00651 
00652       //! Set private pointer for item.
00653       void ItemSetPrivPtr (            
00654          void *ItemReference,
00655          UINT32 ItemRefIndex,
00656          void *PrivPtr
00657          ) { if (ITEM *item = FindItemByRef(ItemReference,ItemRefIndex)) item->SetPrivPtr(PrivPtr); }
00658 
00659       //! Set visiblity for item.
00660       void ItemSetVisible (            
00661          void *ItemReference,
00662          UINT32 ItemRefIndex,
00663          bool visible,
00664          bool redraw = true
00665          );
00666 
00667       //! Notify GraphicTree that item has changed so can recompute size/position.
00668       void NotifyChanged (
00669          bool redraw = true
00670          ) { ItemNotifyChanged(NULL,0,redraw); }
00671 
00672       //! Redraw GRAPHICTREE.
00673       void Redraw (                    
00674          LRECT2D *rect=0
00675          );
00676 
00677       //! Disable redraw.
00678       void RedrawDisable (
00679          ) { m_DisableRedraw = 1; }
00680 
00681       //! Enable redraw.
00682       void RedrawEnable (
00683          bool redraw = true
00684          ) { m_DisableRedraw = 0; if (redraw) Redraw(); }
00685 
00686       //! Scroll to make specified item visible.
00687       void ScrollToItem (
00688          ITEM *item                    //!< Item to make visible
00689          );
00690 
00691       //! Set active child item.
00692       void SetActiveChild (
00693          void *ParentReference,
00694          UINT32 ParentRefIndex,
00695          void *ItemReference,          //!< Pass NULL to set to have no active item
00696          UINT32 ItemRefIndex
00697          );
00698 
00699       //! Set active child item.
00700       inline void SetActiveChild (
00701          void *ParentReference,
00702          void *ItemReference
00703          ) {
00704          SetActiveChild(ParentReference,0,ItemReference,0);
00705          return;
00706          };
00707 
00708       //! Set active item in single-selection mode.
00709       void SetActiveItem (
00710          ITEM* item
00711          );
00712 
00713       inline void SetPrivData (
00714          void *data
00715          ) {
00716          m_PrivPtr = data;
00717          return;
00718          }
00719 
00720    private:
00721       #ifndef GENERATING_DOXYGEN_OUTPUT
00722 
00723       mutable ITEM *m_TraversalItem;   //!< Last item returned by FindFirst/FindNext
00724       ITEM *m_HashItem[GTREEHASHSIZE]; //!< Hash table for searching by reference
00725       ITEM *m_CursorItem;           //!< Item mouse cursor was last in (grabbed for ButtonPress)
00726       ITEM *m_DragParent;           //!< Parent for drag-and-drop reordering
00727       ITEM *m_DragInsertItem;       //!< Item to insert after while dragging, NULL to put first
00728       ITEM *m_ActiveItem;           //!< Active item in single-selection mode
00729       LPOINT2D m_CursorPos;            //!< Pointer location where last event occurred (relative to CursorItem)
00730       LPOINT2D m_DrawSize;             //!< Size of DrawingArea
00731       LPOINT2D m_TopLeft;              //!< Current top-left visible coordinate (0,0 in DrawingArea)
00732       LRECT2D m_DrawClipRect;          //!< Current drawing clip rectangle
00733       UINT8 m_NeedRedraw;              //!< Set if need to do complete redraw
00734       UINT8 m_DoingRedraw;             //!< Set if doing redraw
00735       UINT8 m_DisableRedraw;           //!< Set if redraw is disabled
00736       UINT8 m_UpdateSB;                //!< Set if scrollbars need to be updated
00737       UINT8 m_ToolTipVisible;
00738       UINT8 m_DoingReorder;            //!< Set while dragging child
00739       bool m_IncludeExpandIcon;
00740       bool m_SingleSelection;
00741       MGD::DEVICE* m_sdisp;
00742       MGD::CONTEXT* m_sgc;
00743       MPIXEL m_BackgroundPixel;
00744       MPIXEL m_HighlightPixel;
00745 #ifdef X_NATIVE
00746       Widget m_da;                     //!< DrawingArea
00747       Widget m_hsb;                    //!< Horizontal ScrollBar
00748       Widget m_vsb;                    //!< Vertical ScrollBar
00749       void *m_ToolTipHandle;
00750 #endif
00751       ITEM m_Root;                     //!< Root item
00752       void *m_PrivPtr;                 //!< Private data which can be set/retrieved by the caller
00753 #ifdef X_NATIVE
00754       DOUBLECLICKTEST m_DoubleClickTest;
00755       LPOINT2D m_ToolTipPos;
00756 #endif
00757 
00758       //! Helper methods
00759       void BeginReorder ();
00760       void ComputeHiddenStatus (ITEM*);
00761       void ComputeItemSizePos (ITEM*, INT32, bool);
00762       void DeleteChildren (ITEM*);
00763       void DeleteItem (ITEM*);
00764       void DrawHighlight (ITEM*, bool);
00765       void DrawInsertionIndicator (bool show, bool autoscroll=false);
00766       void DrawItem (ITEM*, INT32, INT32);
00767       void EndReorder ();
00768       ITEM * FindItemByCoord (ITEM*, int, int) const;
00769       void NotifyChanged (ITEM*);
00770       void SetActiveChild (ITEM*);
00771       void UpdateSize ();
00772 
00773 #ifdef X_NATIVE
00774       //! Callbacks & event handlers
00775       static void CB_Destroy (Widget, GRAPHICTREE*, void*);
00776       static void CB_Expose (Widget, GRAPHICTREE*, void*);
00777       static void CB_Resize (Widget, GRAPHICTREE*, void*);
00778       static void CB_ScrollH (Widget, GRAPHICTREE*, void*);
00779       static void CB_ScrollV (Widget, GRAPHICTREE*, void*);
00780       static void CBT_ToolTipPopup (GRAPHICTREE*, XtIntervalId*);
00781       static void EH_Input (Widget, GRAPHICTREE*, XEvent*, Boolean*);
00782       static void EH_GraphicsExpose (Widget, GRAPHICTREE*, XEvent*, Boolean*);
00783 //!      static void EH_ScrollH (Widget, GRAPHICTREE*, XEvent*, Boolean*);
00784 //!      static void EH_ScrollV (Widget, GRAPHICTREE*, XEvent*, Boolean*);
00785       XtIntervalId m_IntervalID;
00786 
00787       MXXTCB_ADD(GRAPHICTREE);
00788       MXXTEH_ADD(GRAPHICTREE);
00789       MXXTTO_ADD(GRAPHICTREE);
00790       MXXTCB_REMOVE(GRAPHICTREE);
00791       MXXTEH_REMOVE(GRAPHICTREE);
00792       
00793       class EVENTSENTRY;
00794       friend class EVENTSENTRY;
00795 #endif
00796 
00797       friend class GRAPHICTREE::ITEM;
00798       #endif // GENERATING_DOXYGEN_OUTPUT
00799    };
00800 
00801 DEFINE_ENUM_OPERATORS(GRAPHICTREE::FLAGS)
00802 
00803 typedef GRAPHICTREE::ITEM::MSG GRAPHICTREEITEM_MSG;
00804 typedef void (*GraphicTreeItemMsgHandler)(GRAPHICTREE::ITEM::MSG*);
00805 
00806 #endif

Generated on Wed May 31 15:26:53 2006 for TNTsdk by  doxygen 1.3.8-20040913