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

Generated on Tue Dec 14 13:18:23 2004 for TNTsdk by  doxygen 1.3.8-20040913