00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FXCHECKTREELIST_H
00023 #define FXCHECKTREELIST_H
00024
00025 #ifndef FXSCROLLAREA_H
00026 #include <fox/FXScrollArea.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030
00031
00032 enum {
00033 CHECKTREELIST_EXTENDEDSELECT= 0,
00034 CHECKTREELIST_SINGLESELECT = 0x00100000,
00035 CHECKTREELIST_BROWSESELECT = 0x00200000,
00036 CHECKTREELIST_MULTIPLESELECT= 0x00300000,
00037 CHECKTREELIST_AUTOSELECT = 0x00400000,
00038 CHECKTREELIST_SHOWS_LINES = 0x00800000,
00039 CHECKTREELIST_SHOWS_BOXES = 0x01000000,
00040 CHECKTREELIST_ROOT_BOXES = 0x02000000,
00041 CHECKTREELIST_NORMAL = CHECKTREELIST_EXTENDEDSELECT
00042 };
00043
00044
00045
00046 class FXAPI FXCheckTreeItem : public FXObject {
00047 FXDECLARE(FXCheckTreeItem)
00048 friend class FXCheckTreeList;
00049 friend class FXDirList;
00050
00051 protected:
00052 FXCheckTreeItem *prev;
00053 FXCheckTreeItem *next;
00054 FXCheckTreeItem *parent;
00055 FXCheckTreeItem *first;
00056 FXCheckTreeItem *last;
00057 FXString label;
00058 FXIcon *openIcon;
00059 FXIcon *closedIcon;
00060 void *data;
00061 FXuint state;
00062 FXint x,y;
00063
00064 protected:
00065 FXCheckTreeItem():prev(NULL),next(NULL),parent(NULL),first(NULL),last(NULL),openIcon(NULL),closedIcon(NULL),data(NULL),state(0),x(0),y(0){}
00066 virtual void draw(const FXCheckTreeList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00067 void drawFocus(const FXCheckTreeList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00068 virtual FXint hitItem(const FXCheckTreeList* list,FXint x,FXint y) const;
00069
00070 protected:
00071 enum{
00072 SELECTED = 1,
00073 FOCUS = 2,
00074 DISABLED = 4,
00075 OPENED = 8,
00076 EXPANDED = 16,
00077 HASITEMS = 32,
00078 DRAGGABLE = 64,
00079 OPENICONOWNED = 128,
00080 CLOSEDICONOWNED = 256,
00081 CHECKED = 512
00082 };
00083
00084 public:
00085
00086 FXCheckTreeItem(const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL):prev(NULL),next(NULL),parent(NULL),first(NULL),last(NULL),label(text),openIcon(oi),closedIcon(ci),data(ptr),state(0),x(0),y(0){}
00087
00088
00089 FXCheckTreeItem* getParent() const { return parent; }
00090
00091
00092 FXCheckTreeItem* getNext() const { return next; }
00093
00094
00095 FXCheckTreeItem* getPrev() const { return prev; }
00096
00097
00098 FXCheckTreeItem* getFirst() const { return first; }
00099
00100
00101 FXCheckTreeItem* getLast() const { return last; }
00102
00103
00104 FXCheckTreeItem* getBelow() const;
00105
00106
00107 FXCheckTreeItem* getAbove() const;
00108
00109
00110 FXint getNumChildren() const;
00111
00112
00113 virtual void setText(const FXString& txt){ label=txt; }
00114
00115
00116 FXString getText() const { return label; }
00117
00118
00119 virtual void setOpenIcon(FXIcon* icn){ openIcon=icn; }
00120
00121
00122 FXIcon* getOpenIcon() const { return openIcon; }
00123
00124
00125 virtual void setClosedIcon(FXIcon* icn){ closedIcon=icn; }
00126
00127
00128 FXIcon* getClosedIcon() const { return closedIcon; }
00129
00130
00131 void setData(void* ptr){ data=ptr; }
00132
00133
00134 void* getData() const { return data; }
00135
00136
00137 virtual void setFocus(FXbool focus);
00138
00139
00140 FXbool hasFocus() const { return (state&FOCUS)!=0; }
00141
00142
00143 virtual void setSelected(FXbool selected);
00144
00145
00146 FXbool isSelected() const { return (state&SELECTED)!=0; }
00147
00148
00149 virtual void setChecked(FXbool checked);
00150
00151
00152 FXbool isChecked() const { return (state&CHECKED)!=0; }
00153
00154
00155 virtual void setOpened(FXbool opened);
00156
00157
00158 FXbool isOpened() const { return (state&OPENED)!=0; }
00159
00160
00161 virtual void setExpanded(FXbool expanded);
00162
00163
00164 FXbool isExpanded() const { return (state&EXPANDED)!=0; }
00165
00166
00167 virtual void setEnabled(FXbool enabled);
00168
00169
00170 FXbool isEnabled() const { return (state&DISABLED)==0; }
00171
00172
00173 virtual void setDraggable(FXbool draggable);
00174
00175
00176 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; }
00177
00178
00179 virtual void setIconOwned(FXuint owned=(OPENICONOWNED|CLOSEDICONOWNED));
00180
00181
00182 FXuint isIconOwned() const { return (state&(OPENICONOWNED|CLOSEDICONOWNED)); }
00183
00184
00185 virtual FXint getWidth(const FXCheckTreeList* list) const;
00186
00187
00188 virtual FXint getHeight(const FXCheckTreeList* list) const;
00189
00190
00191 virtual void create();
00192
00193
00194 virtual void detach();
00195
00196
00197 virtual void destroy();
00198
00199
00200 virtual void save(FXStream& store) const;
00201
00202
00203 virtual void load(FXStream& store);
00204
00205
00206 virtual ~FXCheckTreeItem();
00207 };
00208
00209
00210
00211
00212 typedef FXint (*FXCheckTreeListSortFunc)(const FXCheckTreeItem*,const FXCheckTreeItem*);
00213
00214
00215
00216
00217 class FXAPI FXCheckTreeList : public FXScrollArea {
00218 FXDECLARE(FXCheckTreeList)
00219
00220 protected:
00221 FXCheckTreeItem *firstitem;
00222 FXCheckTreeItem *lastitem;
00223 FXCheckTreeItem *anchoritem;
00224 FXCheckTreeItem *currentitem;
00225 FXCheckTreeItem *extentitem;
00226 FXCheckTreeItem *cursoritem;
00227 FXFont *font;
00228 FXCheckTreeListSortFunc sortfunc;
00229 FXColor textColor;
00230 FXColor selbackColor;
00231 FXColor seltextColor;
00232 FXColor lineColor;
00233 FXint treeWidth;
00234 FXint treeHeight;
00235 FXint visible;
00236 FXint indent;
00237 FXint grabx;
00238 FXint graby;
00239 FXString lookup;
00240 FXString help;
00241 FXbool state;
00242
00243 protected:
00244
00245 FXCheckTreeList();
00246
00247
00248 virtual void layout();
00249
00250
00251 virtual FXCheckTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
00252
00253
00254 void sort(FXCheckTreeItem*& f1,FXCheckTreeItem*& t1,FXCheckTreeItem*& f2,FXCheckTreeItem*& t2,int n);
00255 void recompute();
00256
00257 private:
00258 FXCheckTreeList(const FXCheckTreeList&);
00259 FXCheckTreeList& operator=(const FXCheckTreeList&);
00260
00261 public:
00262 long onPaint(FXObject*,FXSelector,void*);
00263 long onEnter(FXObject*,FXSelector,void*);
00264 long onLeave(FXObject*,FXSelector,void*);
00265 long onUngrabbed(FXObject*,FXSelector,void*);
00266 long onMotion(FXObject*,FXSelector,void*);
00267 long onKeyPress(FXObject*,FXSelector,void*);
00268 long onKeyRelease(FXObject*,FXSelector,void*);
00269 long onLeftBtnPress(FXObject*,FXSelector,void*);
00270 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00271 long onRightBtnPress(FXObject*,FXSelector,void*);
00272 long onRightBtnRelease(FXObject*,FXSelector,void*);
00273 long onQueryTip(FXObject*,FXSelector,void*);
00274 long onQueryHelp(FXObject*,FXSelector,void*);
00275 long onTipTimer(FXObject*,FXSelector,void*);
00276 long onFocusIn(FXObject*,FXSelector,void*);
00277 long onFocusOut(FXObject*,FXSelector,void*);
00278 long onAutoScroll(FXObject*,FXSelector,void*);
00279 long onClicked(FXObject*,FXSelector,void*);
00280 long onDoubleClicked(FXObject*,FXSelector,void*);
00281 long onTripleClicked(FXObject*,FXSelector,void*);
00282 long onCommand(FXObject*,FXSelector,void*);
00283 long onSelected(FXObject*,FXSelector,void*);
00284 long onDeselected(FXObject*,FXSelector,void*);
00285 long onOpened(FXObject*,FXSelector,void*);
00286 long onClosed(FXObject*,FXSelector,void*);
00287 long onExpanded(FXObject*,FXSelector,void*);
00288 long onCollapsed(FXObject*,FXSelector,void*);
00289 long onLookupTimer(FXObject*,FXSelector,void*);
00290
00291 public:
00292
00293 static FXint ascending(const FXCheckTreeItem* a,const FXCheckTreeItem* b);
00294
00295
00296 static FXint descending(const FXCheckTreeItem* a,const FXCheckTreeItem* b);
00297
00298 public:
00299 enum {
00300 ID_TIPTIMER=FXScrollArea::ID_LAST,
00301 ID_LOOKUPTIMER,
00302 ID_LAST
00303 };
00304
00305 public:
00306
00307 FXCheckTreeList(FXComposite *p,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CHECKTREELIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00308
00309
00310 virtual void create();
00311
00312
00313 virtual void detach();
00314
00315
00316 virtual FXint getDefaultWidth();
00317
00318
00319 virtual FXint getDefaultHeight();
00320
00321
00322 virtual FXint getContentWidth();
00323
00324
00325 virtual FXint getContentHeight();
00326
00327
00328 virtual void recalc();
00329
00330
00331 virtual FXbool canFocus() const;
00332
00333
00334 FXint getNumItems() const;
00335
00336
00337 FXint getNumVisible() const { return visible; }
00338
00339
00340 void setNumVisible(FXint nvis);
00341
00342
00343 FXCheckTreeItem* getFirstItem() const { return firstitem; }
00344
00345
00346 FXCheckTreeItem* getLastItem() const { return lastitem; }
00347
00348
00349 FXCheckTreeItem* addItemFirst(FXCheckTreeItem* p,FXCheckTreeItem* item,FXbool notify=FALSE);
00350
00351
00352 FXCheckTreeItem* addItemFirst(FXCheckTreeItem* p,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=FALSE);
00353
00354
00355 FXCheckTreeItem* addItemLast(FXCheckTreeItem* p,FXCheckTreeItem* item,FXbool notify=FALSE);
00356
00357
00358 FXCheckTreeItem* addItemLast(FXCheckTreeItem* p,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=FALSE);
00359
00360
00361 FXCheckTreeItem* addItemAfter(FXCheckTreeItem* other,FXCheckTreeItem* item,FXbool notify=FALSE);
00362
00363
00364 FXCheckTreeItem* addItemAfter(FXCheckTreeItem* other,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=FALSE);
00365
00366
00367 FXCheckTreeItem* addItemBefore(FXCheckTreeItem* other,FXCheckTreeItem* item,FXbool notify=FALSE);
00368
00369
00370 FXCheckTreeItem* addItemBefore(FXCheckTreeItem* other,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=FALSE);
00371
00372
00373 void removeItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00374
00375
00376 void removeItems(FXCheckTreeItem* fm,FXCheckTreeItem* to,FXbool notify=FALSE);
00377
00378
00379 void clearItems(FXbool notify=FALSE);
00380
00381
00382 FXint getItemWidth(const FXCheckTreeItem* item) const { return item->getWidth(this); }
00383
00384
00385 FXint getItemHeight(const FXCheckTreeItem* item) const { return item->getHeight(this); }
00386
00387
00388 virtual FXCheckTreeItem* getItemAt(FXint x,FXint y) const;
00389
00390
00391
00392
00393
00394 FXCheckTreeItem* findItem(const FXString& text,FXCheckTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00395
00396
00397 void makeItemVisible(FXCheckTreeItem* item);
00398
00399
00400 void setItemText(FXCheckTreeItem* item,const FXString& text);
00401
00402
00403 FXString getItemText(const FXCheckTreeItem* item) const;
00404
00405
00406 void setItemOpenIcon(FXCheckTreeItem* item,FXIcon* icon);
00407
00408
00409 FXIcon* getItemOpenIcon(const FXCheckTreeItem* item) const;
00410
00411
00412 void setItemClosedIcon(FXCheckTreeItem* item,FXIcon* icon);
00413
00414
00415 FXIcon* getItemClosedIcon(const FXCheckTreeItem* item) const;
00416
00417
00418 void setItemData(FXCheckTreeItem* item,void* ptr) const;
00419
00420
00421 void* getItemData(const FXCheckTreeItem* item) const;
00422
00423
00424 FXbool isItemSelected(const FXCheckTreeItem* item) const;
00425
00426
00427 FXbool isItemChecked(const FXCheckTreeItem* item) const;
00428
00429
00430 FXbool isItemCurrent(const FXCheckTreeItem* item) const;
00431
00432
00433 FXbool isItemVisible(const FXCheckTreeItem* item) const;
00434
00435
00436 FXbool isItemOpened(const FXCheckTreeItem* item) const;
00437
00438
00439 FXbool isItemExpanded(const FXCheckTreeItem* item) const;
00440
00441
00442 FXbool isItemLeaf(const FXCheckTreeItem* item) const;
00443
00444
00445 FXbool isItemEnabled(const FXCheckTreeItem* item) const;
00446
00447
00448
00449 FXint hitItem(const FXCheckTreeItem* item,FXint x,FXint y) const;
00450
00451
00452 void updateItem(FXCheckTreeItem* item);
00453
00454
00455 FXbool enableItem(FXCheckTreeItem* item);
00456
00457
00458 FXbool disableItem(FXCheckTreeItem* item);
00459
00460
00461 FXbool selectItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00462
00463
00464 FXbool deselectItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00465
00466
00467 FXbool toggleItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00468
00469
00470 FXbool checkItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00471
00472
00473 FXbool uncheckItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00474
00475
00476 FXbool toggleCheckItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00477
00478
00479 FXbool openItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00480
00481
00482 FXbool closeItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00483
00484
00485 FXbool collapseTree(FXCheckTreeItem* tree,FXbool notify=FALSE);
00486
00487
00488 FXbool expandTree(FXCheckTreeItem* tree,FXbool notify=FALSE);
00489
00490
00491 void reparentItem(FXCheckTreeItem* item,FXCheckTreeItem* p);
00492
00493
00494 void setCurrentItem(FXCheckTreeItem* item,FXbool notify=FALSE);
00495
00496
00497 FXCheckTreeItem* getCurrentItem() const { return currentitem; }
00498
00499
00500 void setAnchorItem(FXCheckTreeItem* item);
00501
00502
00503 FXCheckTreeItem* getAnchorItem() const { return anchoritem; }
00504
00505
00506 FXCheckTreeItem* getCursorItem() const { return cursoritem; }
00507
00508
00509 FXbool extendSelection(FXCheckTreeItem* item,FXbool notify=FALSE);
00510
00511
00512 FXbool killSelection(FXbool notify=FALSE);
00513
00514
00515 void sortItems();
00516
00517
00518 void sortChildItems(FXCheckTreeItem* item);
00519
00520
00521 void setFont(FXFont* fnt);
00522
00523
00524 FXFont* getFont() const { return font; }
00525
00526
00527 void setIndent(FXint in);
00528
00529
00530 FXint getIndent() const { return indent; }
00531
00532
00533 FXColor getTextColor() const { return textColor; }
00534
00535
00536 void setTextColor(FXColor clr);
00537
00538
00539 FXColor getSelBackColor() const { return selbackColor; }
00540
00541
00542 void setSelBackColor(FXColor clr);
00543
00544
00545 FXColor getSelTextColor() const { return seltextColor; }
00546
00547
00548 void setSelTextColor(FXColor clr);
00549
00550
00551 FXColor getLineColor() const { return lineColor; }
00552
00553
00554 void setLineColor(FXColor clr);
00555
00556
00557 FXCheckTreeListSortFunc getSortFunc() const { return sortfunc; }
00558
00559
00560 void setSortFunc(FXCheckTreeListSortFunc func){ sortfunc=func; }
00561
00562
00563 FXuint getListStyle() const;
00564
00565
00566 void setListStyle(FXuint style);
00567
00568
00569 void setHelpText(const FXString& text);
00570
00571
00572 FXString getHelpText() const { return help; }
00573
00574
00575 virtual void save(FXStream& store) const;
00576
00577
00578 virtual void load(FXStream& store);
00579
00580
00581 virtual ~FXCheckTreeList();
00582 };
00583
00584 }
00585 #endif // FXCHECKTREE_LIST_H
00586