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 FXHEADER_H
00025 #define FXHEADER_H
00026
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030
00031 namespace FX {
00032
00033 class FXIcon;
00034 class FXFont;
00035 class FXHeader;
00036
00037
00038
00039 enum {
00040 HEADER_BUTTON = 0x00008000,
00041 HEADER_HORIZONTAL = 0,
00042 HEADER_VERTICAL = 0x00010000,
00043 HEADER_TRACKING = 0x00020000,
00044 HEADER_RESIZE = 0x00040000,
00045 HEADER_NORMAL = HEADER_HORIZONTAL|FRAME_NORMAL
00046 };
00047
00048
00049
00050 class FXAPI FXHeaderItem : public FXObject {
00051 FXDECLARE(FXHeaderItem)
00052 friend class FXHeader;
00053 protected:
00054 FXString label;
00055 FXIcon *icon;
00056 void *data;
00057 FXint size;
00058 FXint pos;
00059 FXuint state;
00060 private:
00061 FXHeaderItem(const FXHeaderItem&);
00062 FXHeaderItem& operator=(const FXHeaderItem&);
00063 protected:
00064 FXHeaderItem(){}
00065 virtual void draw(const FXHeader* header,FXDC& dc,FXint x,FXint y,FXint w,FXint h);
00066 public:
00067 enum{
00068 ARROW_NONE = 0,
00069 ARROW_UP = 1,
00070 ARROW_DOWN = 2,
00071 PRESSED = 4,
00072 RIGHT = 8,
00073 LEFT = 16,
00074 CENTER_X = 0,
00075 TOP = 32,
00076 BOTTOM = 64,
00077 CENTER_Y = 0,
00078 BEFORE = 128,
00079 AFTER = 256,
00080 ABOVE = 512,
00081 BELOW = 1024
00082 };
00083 public:
00084
00085
00086 FXHeaderItem(const FXString& text,FXIcon* ic=NULL,FXint s=0,void* ptr=NULL):label(text),icon(ic),data(ptr),size(s),pos(0),state(LEFT|BEFORE){}
00087
00088
00089 virtual void setText(const FXString& txt);
00090
00091
00092 const FXString& getText() const { return label; }
00093
00094
00095 virtual void setIcon(FXIcon* icn);
00096
00097
00098 FXIcon* getIcon() const { return icon; }
00099
00100
00101 void setData(void* ptr){ data=ptr; }
00102
00103
00104 void* getData() const { return data; }
00105
00106
00107 void setSize(FXint s){ size=s; }
00108
00109
00110 FXint getSize() const { return size; }
00111
00112
00113 void setPos(FXint p){ pos=p; }
00114
00115
00116 FXint getPos() const { return pos; }
00117
00118
00119 void setArrowDir(FXbool dir=MAYBE);
00120
00121
00122 FXbool getArrowDir() const;
00123
00124
00125 void setJustify(FXuint justify=LEFT|CENTER_Y);
00126
00127
00128 FXuint getJustify() const { return state&(RIGHT|LEFT|TOP|BOTTOM); }
00129
00130
00131 void setIconPosition(FXuint mode=BEFORE);
00132
00133
00134 FXuint getIconPosition() const { return state&(BEFORE|AFTER|ABOVE|BELOW); }
00135
00136
00137 void setPressed(FXbool pressed);
00138
00139
00140 FXbool isPressed() const { return (state&PRESSED)!=0; }
00141
00142
00143 virtual FXint getWidth(const FXHeader* header) const;
00144
00145
00146 virtual FXint getHeight(const FXHeader* header) const;
00147
00148
00149 virtual void create();
00150
00151
00152 virtual void detach();
00153
00154
00155 virtual void destroy();
00156
00157
00158 virtual void save(FXStream& store) const;
00159 virtual void load(FXStream& store);
00160
00161
00162 virtual ~FXHeaderItem(){}
00163 };
00164
00165
00166 typedef FXObjectListOf<FXHeaderItem> FXHeaderItemList;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 class FXAPI FXHeader : public FXFrame {
00189 FXDECLARE(FXHeader)
00190 protected:
00191 FXHeaderItemList items;
00192 FXColor textColor;
00193 FXFont *font;
00194 FXString help;
00195 FXint pos;
00196 FXint active;
00197 FXint activepos;
00198 FXint activesize;
00199 FXint offset;
00200 protected:
00201 FXHeader();
00202 void drawSplit(FXint pos);
00203 virtual FXHeaderItem *createItem(const FXString& text,FXIcon* icon,FXint size,void* ptr);
00204 private:
00205 FXHeader(const FXHeader&);
00206 FXHeader &operator=(const FXHeader&);
00207 public:
00208 long onPaint(FXObject*,FXSelector,void*);
00209 long onLeftBtnPress(FXObject*,FXSelector,void*);
00210 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00211 long onUngrabbed(FXObject*,FXSelector,void*);
00212 long onMotion(FXObject*,FXSelector,void*);
00213 long onTipTimer(FXObject*,FXSelector,void*);
00214 long onQueryTip(FXObject*,FXSelector,void*);
00215 long onQueryHelp(FXObject*,FXSelector,void*);
00216 public:
00217
00218
00219 FXHeader(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=HEADER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00220
00221
00222 virtual void create();
00223
00224
00225 virtual void detach();
00226
00227
00228 virtual void layout();
00229
00230
00231 FXint getNumItems() const { return items.no(); }
00232
00233
00234 FXint getTotalSize() const;
00235
00236
00237 virtual FXint getDefaultWidth();
00238
00239
00240 virtual FXint getDefaultHeight();
00241
00242
00243 void setPosition(FXint pos);
00244
00245
00246 FXint getPosition() const { return pos; }
00247
00248
00249
00250
00251
00252
00253 FXint getItemAt(FXint coord) const;
00254
00255
00256 FXHeaderItem *getItem(FXint index) const;
00257
00258
00259 FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00260
00261
00262 FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00263
00264
00265 FXint fillItems(const FXchar** strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00266
00267
00268 FXint fillItems(const FXString& strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00269
00270
00271 FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00272
00273
00274 FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00275
00276
00277 FXint appendItem(FXHeaderItem* item,FXbool notify=FALSE);
00278
00279
00280 FXint appendItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00281
00282
00283 FXint prependItem(FXHeaderItem* item,FXbool notify=FALSE);
00284
00285
00286 FXint prependItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00287
00288
00289 FXHeaderItem* extractItem(FXint index,FXbool notify=FALSE);
00290
00291
00292 void removeItem(FXint index,FXbool notify=FALSE);
00293
00294
00295 void clearItems(FXbool notify=FALSE);
00296
00297
00298 void setItemText(FXint index,const FXString& text);
00299
00300
00301 FXString getItemText(FXint index) const;
00302
00303
00304 void setItemIcon(FXint index,FXIcon* icon);
00305
00306
00307 FXIcon* getItemIcon(FXint index) const;
00308
00309
00310 void setItemSize(FXint index,FXint size);
00311
00312
00313 FXint getItemSize(FXint index) const;
00314
00315
00316 FXint getItemOffset(FXint index) const;
00317
00318
00319 void setItemData(FXint index,void* ptr);
00320
00321
00322 void* getItemData(FXint index) const;
00323
00324
00325 void setArrowDir(FXint index,FXbool dir=MAYBE);
00326
00327
00328 FXbool getArrowDir(FXint index) const;
00329
00330
00331
00332
00333
00334
00335
00336
00337 void setItemJustify(FXint index,FXuint justify);
00338
00339
00340 FXuint getItemJustify(FXint index) const;
00341
00342
00343
00344
00345
00346
00347
00348
00349 void setItemIconPosition(FXint index,FXuint mode);
00350
00351
00352 FXuint getItemIconPosition(FXint index) const;
00353
00354
00355 void setItemPressed(FXint index,FXbool pressed=TRUE);
00356
00357
00358 FXbool isItemPressed(FXint index) const;
00359
00360
00361 void makeItemVisible(FXint index);
00362
00363
00364 void updateItem(FXint index) const;
00365
00366
00367 void setFont(FXFont* fnt);
00368
00369
00370 FXFont* getFont() const { return font; }
00371
00372
00373 FXColor getTextColor() const { return textColor; }
00374
00375
00376 void setTextColor(FXColor clr);
00377
00378
00379 void setHeaderStyle(FXuint style);
00380
00381
00382 FXuint getHeaderStyle() const;
00383
00384
00385 void setHelpText(const FXString& text);
00386
00387
00388 const FXString& getHelpText() const { return help; }
00389
00390
00391 virtual void save(FXStream& store) const;
00392
00393
00394 virtual void load(FXStream& store);
00395
00396
00397 virtual ~FXHeader();
00398 };
00399
00400 }
00401
00402 #endif