Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

cstree.h

00001 /*
00002     Crystal Space Windowing System: tree box class
00003     Copyright (C) 2000 by Norman Krämer, based on the listbox code:
00004     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __CSTREE_H__
00022 #define __CSTREE_H__
00023 
00024 #include "cscomp.h"
00025 #include "csscrbar.h"
00026 
00030 enum
00031 {
00039   cscmdTreeItemCheck = 0x00000e00,
00047   cscmdTreeItemToggle,
00054   cscmdTreeItemToggleAll,
00066   cscmdTreeItemToggleNotify,
00074   cscmdTreeItemSizeChangeNotify,
00085   cscmdTreeItemFocused,
00097   cscmdTreeItemGetPrev,
00109   cscmdTreeItemGetNext,
00116   cscmdTreeItemGetFirst,
00123   cscmdTreeItemGetLast,
00130   cscmdTreeItemDeleteNotify,
00138   cscmdTreeItemRightClick,
00146   cscmdTreeQuerySelected,
00154   cscmdTreeSelectItem,
00161   cscmdTreeSetHorizOffset,
00169   cscmdTreeStartTracking,
00179   cscmdTreeTrack,
00187   cscmdTreeMakeVisible,
00197   cscmdTreeMakeBranchVisible,
00201   cscmdTreeClear
00202 };
00203 
00205 #define CSS_TREEITEM_OPEN       0x00010000
00206 
00207 #define CSS_TREEITEM_PLACEITEMS 0x00020000
00208 
00210 #define CS_TREEITEM_MAGIC       (void *)0xdeadface
00211 
00216 enum csTreeItemStyle
00217 {
00219   cstisNormal,
00221   cstisEmphasized
00222 };
00223 
00235 class csTreeItem : public csComponent
00236 {
00237   friend class csTreeBox;
00238 
00240   csTreeItemStyle ItemStyle;
00242   csPixmap *ItemBitmap [2];
00244   bool DeleteBitmap;
00246   int hChildrenOffset;
00248   csButton *button;
00250   csTreeBox *treebox;
00251 
00253   void PlaceItems ();
00255   csTreeItem *NextItem ();
00257   csTreeItem *PrevItem ();
00258 
00259 public:
00261   csTreeItem (csComponent *iParent, const char *iText, int iID = 0,
00262     csTreeItemStyle iStyle = cstisNormal);
00263 
00265   virtual ~csTreeItem ();
00266 
00268   virtual bool HandleEvent (iEvent &Event);
00269 
00271   virtual void Draw ();
00272 
00274   virtual void SetState (int mask, bool enable);
00275 
00277   virtual bool SetFocused (csComponent *comp);
00278 
00280   virtual void Insert (csComponent *comp);
00281 
00283   virtual void Delete (csComponent *comp);
00284 
00286   virtual void SuggestSize (int &w, int &h);
00287 
00289   void SuggestTotalSize (int &w, int &h, int &totw, int &toth);
00290 
00292   void SetBitmap (csPixmap *iBitmap, csPixmap *iBitmapOpen = NULL,
00293     bool iDelete = true);
00294 
00296   void SetChildOffset (int ihOffset)
00297   { hChildrenOffset = ihOffset; }
00298 
00300   int Toggle (int iAction = 2);
00301 
00308   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00309     void *param = NULL, bool iOnlyOpen = false);
00310 
00312   void ResetButton ()
00313   { button->SetRect (0, 0, -1, -1); parent->SendCommand (cscmdTreeItemSizeChangeNotify, this); }
00314 };
00315 
00320 
00321 #define CSTS_HSCROLL            0x00000001
00322 
00323 #define CSTS_VSCROLL            0x00000002
00324 
00325 #define CSTS_AUTOSCROLLBAR      0x00000004
00326 
00327 #define CSTS_SMALLBUTTONS       0x00000008
00328 
00330 #define CSTS_DEFAULTVALUE       CSTS_VSCROLL | CSTS_AUTOSCROLLBAR
00331 
00333 #define CSS_TREEBOX_PLACEITEMS  0x00010000
00334 
00335 #define CSS_TREEBOX_LOCKVISIBLE 0x00020000
00336 
00338 enum csTreeFrameStyle
00339 {
00341   cstfsNone,
00343   cstfsThinRect,
00345   cstfsThickRect
00346 };
00347 
00406 class csTreeBox : public csComponent
00407 {
00427   class csTreeView : public csComponent
00428   {
00429   public:
00431     csTreeView (csComponent *iParent);
00432 
00434     virtual bool HandleEvent (iEvent &Event);
00435 
00437     virtual void Delete (csComponent *comp);
00438   } *clipview;
00439 
00441   int TreeStyle;
00443   csTreeFrameStyle FrameStyle;
00445   int BorderWidth, BorderHeight;
00447   csComponent *timer;
00449   csScrollBar *hscroll, *vscroll;
00451   csScrollBarStatus hsbstatus, vsbstatus;
00453   int deltax, maxdeltax;
00455   int deltay, maxdeltay;
00457   csTreeItem *active;
00458 
00460   csTreeItem *NextItem ();
00462   csTreeItem *PrevItem ();
00463 
00464 public:
00466   csTreeBox (csComponent *iParent, int iStyle = CSTS_DEFAULTVALUE,
00467     csTreeFrameStyle iFrameStyle = cstfsThickRect);
00468 
00470   virtual ~csTreeBox ();
00471 
00473   virtual bool HandleEvent (iEvent &Event);
00474 
00476   virtual void Draw ();
00477 
00479   void PlaceItems (int sbFlags = CSTS_HSCROLL | CSTS_VSCROLL);
00480 
00482   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00483 
00488   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00489     void *param = NULL, bool iOnlyOpen = false);
00490 
00492   virtual void SetState (int mask, bool enable);
00493 
00495   virtual void Insert (csComponent *comp);
00496 
00498   virtual void ExpandAll ();
00499 
00501   virtual void CollapseAll ();
00502 
00504   int GetStyle () { return TreeStyle; }
00506   csTreeFrameStyle GetFrameStyle () { return FrameStyle; }
00508   void SetStyle (int iStyle, csTreeFrameStyle iFrameStyle);
00509 
00510 protected:
00511   friend class csTreeItem;
00512 
00514   void PrepareButton (csButton *iButton, bool iOpen);
00515 
00517   void MakeItemVisible (csComponent *iItem, bool iChildren = false);
00518 
00520   void FocusItem (csTreeItem *iItem);
00521 
00523   void VScroll (int iDelta, bool iMoveCaret);
00524 
00526   void PlaceScrollbars ();
00527 };
00528 
00529 #endif // __CSTREE_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000