CrystalSpace

Public API Reference

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

csws/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 "cscomp.h"
00033 #include "csscrbar.h"
00034 
00038 enum
00039 {
00047   cscmdTreeItemCheck = 0x00000e00,
00055   cscmdTreeItemToggle,
00062   cscmdTreeItemToggleAll,
00074   cscmdTreeItemToggleNotify,
00082   cscmdTreeItemSizeChangeNotify,
00093   cscmdTreeItemFocused,
00105   cscmdTreeItemGetPrev,
00117   cscmdTreeItemGetNext,
00124   cscmdTreeItemGetFirst,
00131   cscmdTreeItemGetLast,
00138   cscmdTreeItemDeleteNotify,
00146   cscmdTreeItemRightClick,
00154   cscmdTreeQuerySelected,
00162   cscmdTreeSelectItem,
00169   cscmdTreeSetHorizOffset,
00177   cscmdTreeStartTracking,
00187   cscmdTreeTrack,
00195   cscmdTreeMakeVisible,
00205   cscmdTreeMakeBranchVisible,
00209   cscmdTreeClear
00210 };
00211 
00215 
00216 #define CSS_TREEITEM_OPEN       0x00010000
00217 
00218 #define CSS_TREEITEM_PLACEITEMS 0x00020000
00219 
00221 
00222 #define CS_TREEITEM_MAGIC       (void *)0xdeadface
00223 
00228 enum csTreeItemStyle
00229 {
00231   cstisNormal,
00233   cstisEmphasized
00234 };
00235 
00247 class csTreeItem : public csComponent
00248 {
00249   friend class csTreeBox;
00250 
00252   csTreeItemStyle ItemStyle;
00254   csPixmap *ItemBitmap [2];
00256   bool DeleteBitmap;
00258   int hChildrenOffset;
00260   csButton *button;
00262   csTreeBox *treebox;
00263 
00265   void PlaceItems ();
00267   csTreeItem *NextItem ();
00269   csTreeItem *PrevItem ();
00270 
00271 public:
00273   csTreeItem (csComponent *iParent, const char *iText, int iID = 0,
00274     csTreeItemStyle iStyle = cstisNormal);
00275 
00277   virtual ~csTreeItem ();
00278 
00280   virtual bool HandleEvent (iEvent &Event);
00281 
00283   virtual void Draw ();
00284 
00286   virtual void SetState (int mask, bool enable);
00287 
00289   virtual bool SetFocused (csComponent *comp);
00290 
00292   virtual void Insert (csComponent *comp);
00293 
00295   virtual void Delete (csComponent *comp);
00296 
00298   virtual void SuggestSize (int &w, int &h);
00299 
00301   void SuggestTotalSize (int &w, int &h, int &totw, int &toth);
00302 
00304   void SetBitmap (csPixmap *iBitmap, csPixmap *iBitmapOpen = 0,
00305     bool iDelete = true);
00306 
00308   void SetChildOffset (int ihOffset)
00309   { hChildrenOffset = ihOffset; }
00310 
00312   int Toggle (int iAction = 2);
00313 
00320   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00321     void *param = 0, bool iOnlyOpen = false);
00322 
00324   void ResetButton ()
00325   { button->SetRect (0, 0, -1, -1); parent->SendCommand (cscmdTreeItemSizeChangeNotify, this); }
00326 };
00327 
00333 
00334 #define CSTS_HSCROLL            0x00000001
00335 
00336 #define CSTS_VSCROLL            0x00000002
00337 
00338 #define CSTS_AUTOSCROLLBAR      0x00000004
00339 
00340 #define CSTS_SMALLBUTTONS       0x00000008
00341 
00343 #define CSTS_DEFAULTVALUE       CSTS_VSCROLL | CSTS_AUTOSCROLLBAR
00344 
00349 
00350 #define CSS_TREEBOX_PLACEITEMS  0x00010000
00351 
00352 #define CSS_TREEBOX_LOCKVISIBLE 0x00020000
00353 
00355 
00356 enum csTreeFrameStyle
00357 {
00359   cstfsNone,
00361   cstfsThinRect,
00363   cstfsThickRect
00364 };
00365 
00424 class csTreeBox : public csComponent
00425 {
00445   class csTreeView : public csComponent
00446   {
00447   public:
00449     csTreeView (csComponent *iParent);
00450 
00452     virtual bool HandleEvent (iEvent &Event);
00453 
00455     virtual void Delete (csComponent *comp);
00456   } *clipview;
00457 
00459   int TreeStyle;
00461   csTreeFrameStyle FrameStyle;
00463   int BorderWidth, BorderHeight;
00465   csComponent *timer;
00467   csScrollBar *hscroll, *vscroll;
00469   csScrollBarStatus hsbstatus, vsbstatus;
00471   int deltax, maxdeltax;
00473   int deltay, maxdeltay;
00475   csTreeItem *active;
00476 
00478   csTreeItem *NextItem ();
00480   csTreeItem *PrevItem ();
00481 
00482 public:
00484   csTreeBox (csComponent *iParent, int iStyle = CSTS_DEFAULTVALUE,
00485     csTreeFrameStyle iFrameStyle = cstfsThickRect);
00486 
00488   virtual ~csTreeBox ();
00489 
00491   virtual bool HandleEvent (iEvent &Event);
00492 
00494   virtual void Draw ();
00495 
00497   void PlaceItems (int sbFlags = CSTS_HSCROLL | CSTS_VSCROLL);
00498 
00500   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00501 
00506   csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param),
00507     void *param = 0, bool iOnlyOpen = false);
00508 
00510   virtual void SetState (int mask, bool enable);
00511 
00513   virtual void Insert (csComponent *comp);
00514 
00516   virtual void ExpandAll ();
00517 
00519   virtual void CollapseAll ();
00520 
00522   int GetStyle () { return TreeStyle; }
00524   csTreeFrameStyle GetFrameStyle () { return FrameStyle; }
00526   void SetStyle (int iStyle, csTreeFrameStyle iFrameStyle);
00527 
00528 protected:
00529   friend class csTreeItem;
00530 
00532   void PrepareButton (csButton *iButton, bool iOpen);
00533 
00535   void MakeItemVisible (csComponent *iItem, bool iChildren = false);
00536 
00538   void FocusItem (csTreeItem *iItem);
00539 
00541   void VScroll (int iDelta, bool iMoveCaret);
00542 
00544   void PlaceScrollbars ();
00545 };
00546 
00549 #endif // __CS_CSTREE_H__

Generated for Crystal Space by doxygen 1.2.18