00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXCHECKLIST_H
00025 #define FXCHECKLIST_H
00026
00027 #ifndef FXSCROLLAREA_H
00028 #include <fox/FXScrollArea.h>
00029 using namespace FX;
00030 #endif
00031 namespace FXEX {
00032
00033
00034 enum {
00035 CHECKLIST_EXTENDEDSELECT= 0,
00036 CHECKLIST_SINGLESELECT = 0x00100000,
00037 CHECKLIST_BROWSESELECT = 0x00200000,
00038 CHECKLIST_MULTIPLESELECT= 0x00300000,
00039 CHECKLIST_AUTOSELECT = 0x00400000,
00040 CHECKLIST_NORMAL = CHECKLIST_EXTENDEDSELECT
00041 };
00042
00043
00044
00045 class FXAPI FXCheckListItem : public FXObject {
00046 FXDECLARE(FXCheckListItem)
00047 friend class FXCheckList;
00048
00049 protected:
00050 FXString label;
00051 FXIcon *icon;
00052 void *data;
00053 FXuint state;
00054
00055 protected:
00056
00057
00058 FXCheckListItem():icon(NULL),data(NULL),state(0){}
00059
00060
00061 virtual void draw(const FXCheckList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h);
00062
00063
00064 void drawFocus(const FXCheckList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00065
00066
00067 virtual FXint hitItem(const FXCheckList* list,FXint x,FXint y) const;
00068
00069 protected:
00070
00071 enum {
00072 SELECTED = 1,
00073 FOCUS = 2,
00074 DISABLED = 4,
00075 DRAGGABLE = 8,
00076 ICONOWNED = 16,
00077 CHECKED = 32
00078 };
00079
00080 public:
00081
00082 FXCheckListItem(const FXString& text,FXIcon* ic=NULL,void* ptr=NULL):label(text),icon(ic),data(ptr),state(0){}
00083
00084
00085 virtual void setText(const FXString& txt){ label=txt; }
00086
00087
00088 FXString getText() const { return label; }
00089
00090
00091 virtual void setIcon(FXIcon* icn){ icon=icn; }
00092
00093
00094 FXIcon* getIcon() const { return icon; }
00095
00096
00097 void setData(void* ptr){ data=ptr; }
00098
00099
00100 void* getData() const { return data; }
00101
00102
00103 virtual void setFocus(FXbool focus);
00104
00105
00106 FXbool hasFocus() const { return (state&FOCUS)!=0; }
00107
00108
00109 virtual void setSelected(FXbool selected);
00110
00111
00112 FXbool isSelected() const { return (state&SELECTED)!=0; }
00113
00114
00115 virtual void setChecked(FXbool checked);
00116
00117
00118 FXbool isChecked() const { return (state&CHECKED)!=0; }
00119
00120
00121 virtual void setEnabled(FXbool enabled);
00122
00123
00124 FXbool isEnabled() const { return (state&DISABLED)==0; }
00125
00126
00127 virtual void setDraggable(FXbool draggable);
00128
00129
00130 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; }
00131
00132
00133 virtual void setIconOwned(FXuint owned=ICONOWNED);
00134
00135
00136 FXuint isIconOwned() const { return (state&ICONOWNED); }
00137
00138
00139 virtual FXint getWidth(const FXCheckList* list) const;
00140
00141
00142 virtual FXint getHeight(const FXCheckList* list) const;
00143
00144
00145 virtual void create();
00146
00147
00148 virtual void detach();
00149
00150
00151 virtual void destroy();
00152
00153
00154 virtual void save(FXStream& store) const;
00155
00156
00157 virtual void load(FXStream& store);
00158
00159
00160 virtual ~FXCheckListItem();
00161 };
00162
00163
00164
00165 typedef FXint (*FXCheckListSortFunc)(const FXCheckListItem*,const FXCheckListItem*);
00166
00167
00168
00169 class FXAPI FXCheckList : public FXScrollArea {
00170 FXDECLARE(FXCheckList)
00171
00172 protected:
00173 FXCheckListItem **items;
00174 FXint nitems;
00175 FXint anchor;
00176 FXint current;
00177 FXint extent;
00178 FXint cursor;
00179 FXFont *font;
00180 FXColor textColor;
00181 FXColor selbackColor;
00182 FXColor seltextColor;
00183 FXint itemWidth;
00184 FXint itemHeight;
00185 FXint visible;
00186 FXString help;
00187 FXCheckListSortFunc sortfunc;
00188 FXint grabx;
00189 FXint graby;
00190 FXString lookup;
00191 FXbool state;
00192
00193 protected:
00194 FXCheckList();
00195 virtual void layout();
00196 void recompute();
00197 virtual FXCheckListItem *createItem(const FXString& text,FXIcon* icon,void* ptr);
00198
00199 private:
00200 FXCheckList(const FXCheckList&);
00201 FXCheckList &operator=(const FXCheckList&);
00202
00203 public:
00204 long onPaint(FXObject*,FXSelector,void*);
00205 long onEnter(FXObject*,FXSelector,void*);
00206 long onLeave(FXObject*,FXSelector,void*);
00207 long onUngrabbed(FXObject*,FXSelector,void*);
00208 long onKeyPress(FXObject*,FXSelector,void*);
00209 long onKeyRelease(FXObject*,FXSelector,void*);
00210 long onLeftBtnPress(FXObject*,FXSelector,void*);
00211 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00212 long onRightBtnPress(FXObject*,FXSelector,void*);
00213 long onRightBtnRelease(FXObject*,FXSelector,void*);
00214 long onMotion(FXObject*,FXSelector,void*);
00215 long onFocusIn(FXObject*,FXSelector,void*);
00216 long onFocusOut(FXObject*,FXSelector,void*);
00217 long onAutoScroll(FXObject*,FXSelector,void*);
00218 long onClicked(FXObject*,FXSelector,void*);
00219 long onDoubleClicked(FXObject*,FXSelector,void*);
00220 long onTripleClicked(FXObject*,FXSelector,void*);
00221 long onCommand(FXObject*,FXSelector,void*);
00222 long onQueryTip(FXObject*,FXSelector,void*);
00223 long onQueryHelp(FXObject*,FXSelector,void*);
00224 long onTipTimer(FXObject*,FXSelector,void*);
00225 long onLookupTimer(FXObject*,FXSelector,void*);
00226 long onCmdSetValue(FXObject*,FXSelector,void*);public:
00227 long onCmdGetIntValue(FXObject*,FXSelector,void*);
00228 long onCmdSetIntValue(FXObject*,FXSelector,void*);
00229
00230 public:
00231 static FXint ascending(const FXCheckListItem* a,const FXCheckListItem* b);
00232 static FXint descending(const FXCheckListItem* a,const FXCheckListItem* b);
00233
00234 public:
00235 enum {
00236 ID_TIPTIMER=FXScrollArea::ID_LAST,
00237 ID_LOOKUPTIMER,
00238 ID_LAST
00239 };
00240
00241 public:
00242
00243 FXCheckList(FXComposite *p,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CHECKLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00244
00245
00246 virtual void create();
00247
00248
00249 virtual void detach();
00250
00251
00252 virtual FXint getDefaultWidth();
00253
00254
00255 virtual FXint getDefaultHeight();
00256
00257
00258 virtual FXint getContentWidth();
00259
00260
00261 virtual FXint getContentHeight();
00262
00263
00264 virtual void recalc();
00265
00266
00267 virtual FXbool canFocus() const;
00268
00269
00270 FXint getNumItems() const { return nitems; }
00271
00272
00273 FXint getNumVisible() const { return visible; }
00274
00275
00276 void setNumVisible(FXint nvis);
00277
00278
00279 FXCheckListItem *retrieveItem(FXint index) const;
00280
00281
00282 FXint replaceItem(FXint index,FXCheckListItem* item,FXbool notify=FALSE);
00283
00284
00285 FXint replaceItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00286
00287
00288 FXint insertItem(FXint index,FXCheckListItem* item,FXbool notify=FALSE);
00289
00290
00291 FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00292
00293
00294 FXint appendItem(FXCheckListItem* item,FXbool notify=FALSE);
00295
00296
00297 FXint appendItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00298
00299
00300 FXint prependItem(FXCheckListItem* item,FXbool notify=FALSE);
00301
00302
00303 FXint prependItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00304
00305
00306 void removeItem(FXint index,FXbool notify=FALSE);
00307
00308
00309 void clearItems(FXbool notify=FALSE);
00310
00311
00312 FXint getItemWidth() const { return itemWidth; }
00313
00314
00315 FXint getItemHeight() const { return itemHeight; }
00316
00317
00318 FXint getItemAt(FXint x,FXint y) const;
00319
00320
00321
00322 FXint hitItem(FXint index,FXint x,FXint y) const;
00323
00324
00325
00326
00327
00328 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00329
00330
00331 void makeItemVisible(FXint index);
00332
00333
00334 void setItemText(FXint index,const FXString& text);
00335
00336
00337 FXString getItemText(FXint index) const;
00338
00339
00340 void setItemIcon(FXint index,FXIcon* icon);
00341
00342
00343 FXIcon* getItemIcon(FXint index) const;
00344
00345
00346 void setItemData(FXint index,void* ptr);
00347
00348
00349 void* getItemData(FXint index) const;
00350
00351
00352 FXbool isItemSelected(FXint index) const;
00353
00354
00355 FXbool isItemChecked(FXint index) const;
00356
00357
00358 FXbool isItemCurrent(FXint index) const;
00359
00360
00361 FXbool isItemVisible(FXint index) const;
00362
00363
00364 FXbool isItemEnabled(FXint index) const;
00365
00366
00367 void updateItem(FXint index);
00368
00369
00370 FXbool enableItem(FXint index);
00371
00372
00373 FXbool disableItem(FXint index);
00374
00375
00376 FXbool selectItem(FXint index,FXbool notify=FALSE);
00377
00378
00379 FXbool deselectItem(FXint index,FXbool notify=FALSE);
00380
00381
00382 FXbool toggleItem(FXint index,FXbool notify=FALSE);
00383
00384
00385 FXbool checkItem(FXint index,FXbool notify=FALSE);
00386
00387
00388 FXbool uncheckItem(FXint index,FXbool notify=FALSE);
00389
00390
00391 FXbool toggleCheckItem(FXint index,FXbool notify=FALSE);
00392
00393
00394 void setCurrentItem(FXint index,FXbool notify=FALSE);
00395
00396
00397 FXint getCurrentItem() const { return current; }
00398
00399
00400 void setAnchorItem(FXint index);
00401
00402
00403 FXint getAnchorItem() const { return anchor; }
00404
00405
00406 FXint getCursorItem() const { return cursor; }
00407
00408
00409 FXbool extendSelection(FXint index,FXbool notify=FALSE);
00410
00411
00412 FXbool killSelection(FXbool notify=FALSE);
00413
00414
00415 void sortItems();
00416
00417
00418 void setFont(FXFont* fnt);
00419
00420
00421 FXFont* getFont() const { return font; }
00422
00423
00424 FXColor getTextColor() const { return textColor; }
00425
00426
00427 void setTextColor(FXColor clr);
00428
00429
00430 FXColor getSelBackColor() const { return selbackColor; }
00431
00432
00433 void setSelBackColor(FXColor clr);
00434
00435
00436 FXColor getSelTextColor() const { return seltextColor; }
00437
00438
00439 void setSelTextColor(FXColor clr);
00440
00441
00442 FXCheckListSortFunc getSortFunc() const { return sortfunc; }
00443
00444
00445 void setSortFunc(FXCheckListSortFunc func){ sortfunc=func; }
00446
00447
00448 FXuint getListStyle() const;
00449
00450
00451 void setListStyle(FXuint style);
00452
00453
00454 void setHelpText(const FXString& text);
00455
00456
00457 FXString getHelpText() const { return help; }
00458
00459
00460 virtual void save(FXStream& store) const;
00461
00462
00463 virtual void load(FXStream& store);
00464
00465
00466 virtual ~FXCheckList();
00467 };
00468
00469 }
00470 #endif // FXCHECKLIST_H