CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

cstree.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space Windowing System: tree box class
00003     Copyright (C) 2000 by Norman Kraemer, 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 __CS_CSTREE_H__
00022 #define __CS_CSTREE_H__
00023 
00032 #include "csextern.h"
00033  
00034 #include "cscomp.h"
00035 #include "csscrbar.h"
00036 
00040 enum
00041 {
00049   cscmdTreeItemCheck = 0x00000e00,
00057   cscmdTreeItemToggle,
00064   cscmdTreeItemToggleAll,
00076   cscmdTreeItemToggleNotify,
00084   cscmdTreeItemSizeChangeNotify,
00095   cscmdTreeItemFocused,
00107   cscmdTreeItemGetPrev,
00119   cscmdTreeItemGetNext,
00126   cscmdTreeItemGetFirst,
00133   cscmdTreeItemGetLast,
00140   cscmdTreeItemDeleteNotify,
00148   cscmdTreeItemRightClick,
00156   cscmdTreeQuerySelected,
00164   cscmdTreeSelectItem,
00171   cscmdTreeSetHorizOffset,
00179   cscmdTreeStartTracking,
00189   cscmdTreeTrack,
00197   cscmdTreeMakeVisible,
00207   cscmdTreeMakeBranchVisible,
00211   cscmdTreeClear
00212 };
00213 
00217 
00218 #define CSS_TREEITEM_OPEN       0x00010000
00219 
00220 #define CSS_TREEITEM_PLACEITEMS 0x00020000
00221 
00223 
00224 #define CS_TREEITEM_MAGIC       (void *)0xdeadface
00225 
00230 enum csTreeItemStyle
00231 {
00233   cstisNormal,
00235   cstisEmphasized
00236 };
00237 
00249 class CS_CSWS_EXPORT csTreeItem : public csComponent
00250 {
00251   friend class csTreeBox;
00252 
00254   csTreeItemStyle ItemStyle;
00256   csPixmap *ItemBitmap [2];
00258   bool DeleteBitmap;
00260   int hChildrenOffset;
00262   csButton *button;
00264   csTreeBox *treebox;
00265 
00267   void PlaceItems ();
00269   csTreeItem *NextItem ();
00271   csTreeItem *PrevItem ();
00272 
00273 public:
00275   csTreeItem (csComponent *iParent, const char *iText, int iID = 0,
00276     csTreeItemStyle iStyle = cstisNormal);
00277 
00279   virtual ~csTreeItem ();
00280 
00282   virtual bool HandleEvent (iEvent &Event);
00283 
00285   virtual void Draw ();
00286 
00288   virtual void SetState (int mask, bool enable);
00289 
00291   virtual bool SetFocused (csComponent *comp);
00292 
00294   virtual void Insert (csComponent *comp);
00295 
00297   virtual void Delete (csComponent *comp);
00298 
00300   virtual void SuggestSize (int &w, int &h);
00301 
00303   void SuggestTotalSize (int &w, int &h, int &totw, int &toth);
00304 
00306   void SetBitmap (csPixmap *iBitmap, csPixmap *iBitmapOpen = 0,
00307     bool iDelete = true);
00308 
00310   void SetChildOffset (int ihOffset)
00311   { hChildrenOffset = ihOffset; }
00312 
00314   int Toggle (int iAction = 2);
00315 
00322   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00323     void *param = 0, bool iOnlyOpen = false);
00324 
00326   void ResetButton ()
00327   { button->SetRect (0, 0, -1, -1); parent->SendCommand (cscmdTreeItemSizeChangeNotify, this); }
00328 };
00329 
00335 
00336 #define CSTS_HSCROLL            0x00000001
00337 
00338 #define CSTS_VSCROLL            0x00000002
00339 
00340 #define CSTS_AUTOSCROLLBAR      0x00000004
00341 
00342 #define CSTS_SMALLBUTTONS       0x00000008
00343 
00345 #define CSTS_DEFAULTVALUE       CSTS_VSCROLL | CSTS_AUTOSCROLLBAR
00346 
00351 
00352 #define CSS_TREEBOX_PLACEITEMS  0x00010000
00353 
00356 #define CSS_TREEBOX_LOCKVISIBLE 0x00020000
00357 
00359 
00360 enum csTreeFrameStyle
00361 {
00363   cstfsNone,
00365   cstfsThinRect,
00367   cstfsThickRect
00368 };
00369 
00428 class CS_CSWS_EXPORT csTreeBox : public csComponent
00429 {
00449   class csTreeView : public csComponent
00450   {
00451   public:
00453     csTreeView (csComponent *iParent);
00454 
00456     virtual bool HandleEvent (iEvent &Event);
00457 
00459     virtual void Delete (csComponent *comp);
00460   } *clipview;
00461 
00463   int TreeStyle;
00465   csTreeFrameStyle FrameStyle;
00467   int BorderWidth, BorderHeight;
00469   csComponent *timer;
00471   csScrollBar *hscroll, *vscroll;
00473   csScrollBarStatus hsbstatus, vsbstatus;
00475   int deltax, maxdeltax;
00477   int deltay, maxdeltay;
00479   csTreeItem *active;
00480 
00482   csTreeItem *NextItem ();
00484   csTreeItem *PrevItem ();
00485 
00486 public:
00488   csTreeBox (csComponent *iParent, int iStyle = CSTS_DEFAULTVALUE,
00489     csTreeFrameStyle iFrameStyle = cstfsThickRect);
00490 
00492   virtual ~csTreeBox ();
00493 
00495   virtual bool HandleEvent (iEvent &Event);
00496 
00498   virtual void Draw ();
00499 
00501   void PlaceItems (int sbFlags = CSTS_HSCROLL | CSTS_VSCROLL);
00502 
00504   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00505 
00510   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00511     void *param = 0, bool iOnlyOpen = false);
00512 
00514   virtual void SetState (int mask, bool enable);
00515 
00517   virtual void Insert (csComponent *comp);
00518 
00520   virtual void ExpandAll ();
00521 
00523   virtual void CollapseAll ();
00524 
00526   int GetStyle () { return TreeStyle; }
00528   csTreeFrameStyle GetFrameStyle () { return FrameStyle; }
00530   void SetStyle (int iStyle, csTreeFrameStyle iFrameStyle);
00531 
00532 protected:
00533   friend class csTreeItem;
00534 
00536   void PrepareButton (csButton *iButton, bool iOpen);
00537 
00539   void MakeItemVisible (csComponent *iItem, bool iChildren = false);
00540 
00542   void FocusItem (csTreeItem *iItem);
00543 
00545   void VScroll (int iDelta, bool iMoveCaret);
00546 
00548   void PlaceScrollbars ();
00549 };
00550 
00553 #endif // __CS_CSTREE_H__

Generated for Crystal Space by doxygen 1.3.9.1