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 "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 00354 #define CSS_TREEBOX_LOCKVISIBLE 0x00020000 00355 00357 00358 enum csTreeFrameStyle 00359 { 00361 cstfsNone, 00363 cstfsThinRect, 00365 cstfsThickRect 00366 }; 00367 00426 class CS_CSWS_EXPORT csTreeBox : public csComponent 00427 { 00447 class csTreeView : public csComponent 00448 { 00449 public: 00451 csTreeView (csComponent *iParent); 00452 00454 virtual bool HandleEvent (iEvent &Event); 00455 00457 virtual void Delete (csComponent *comp); 00458 } *clipview; 00459 00461 int TreeStyle; 00463 csTreeFrameStyle FrameStyle; 00465 int BorderWidth, BorderHeight; 00467 csComponent *timer; 00469 csScrollBar *hscroll, *vscroll; 00471 csScrollBarStatus hsbstatus, vsbstatus; 00473 int deltax, maxdeltax; 00475 int deltay, maxdeltay; 00477 csTreeItem *active; 00478 00480 csTreeItem *NextItem (); 00482 csTreeItem *PrevItem (); 00483 00484 public: 00486 csTreeBox (csComponent *iParent, int iStyle = CSTS_DEFAULTVALUE, 00487 csTreeFrameStyle iFrameStyle = cstfsThickRect); 00488 00490 virtual ~csTreeBox (); 00491 00493 virtual bool HandleEvent (iEvent &Event); 00494 00496 virtual void Draw (); 00497 00499 void PlaceItems (int sbFlags = CSTS_HSCROLL | CSTS_VSCROLL); 00500 00502 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00503 00508 csTreeItem *ForEachItem (bool (*func) (csTreeItem *child, void *param), 00509 void *param = 0, bool iOnlyOpen = false); 00510 00512 virtual void SetState (int mask, bool enable); 00513 00515 virtual void Insert (csComponent *comp); 00516 00518 virtual void ExpandAll (); 00519 00521 virtual void CollapseAll (); 00522 00524 int GetStyle () { return TreeStyle; } 00526 csTreeFrameStyle GetFrameStyle () { return FrameStyle; } 00528 void SetStyle (int iStyle, csTreeFrameStyle iFrameStyle); 00529 00530 protected: 00531 friend class csTreeItem; 00532 00534 void PrepareButton (csButton *iButton, bool iOpen); 00535 00537 void MakeItemVisible (csComponent *iItem, bool iChildren = false); 00538 00540 void FocusItem (csTreeItem *iItem); 00541 00543 void VScroll (int iDelta, bool iMoveCaret); 00544 00546 void PlaceScrollbars (); 00547 }; 00548 00551 #endif // __CS_CSTREE_H__
Generated for Crystal Space by doxygen 1.2.18