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
00167 typedef FXObjectListOf<FXHeaderItem> FXHeaderItemList;
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 class FXAPI FXHeader : public FXFrame {
00190 FXDECLARE(FXHeader)
00191 protected:
00192 FXHeaderItemList items;
00193 FXColor textColor;
00194 FXFont *font;
00195 FXString help;
00196 FXint pos;
00197 FXint active;
00198 FXint activepos;
00199 FXint activesize;
00200 FXint offset;
00201 protected:
00202 FXHeader();
00203 void drawSplit(FXint pos);
00204 virtual FXHeaderItem *createItem(const FXString& text,FXIcon* icon,FXint size,void* ptr);
00205 private:
00206 FXHeader(const FXHeader&);
00207 FXHeader &operator=(const FXHeader&);
00208 public:
00209 long onPaint(FXObject*,FXSelector,void*);
00210 long onLeftBtnPress(FXObject*,FXSelector,void*);
00211 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00212 long onUngrabbed(FXObject*,FXSelector,void*);
00213 long onMotion(FXObject*,FXSelector,void*);
00214 long onTipTimer(FXObject*,FXSelector,void*);
00215 long onQueryTip(FXObject*,FXSelector,void*);
00216 long onQueryHelp(FXObject*,FXSelector,void*);
00217 public:
00218
00219
00220 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);
00221
00222
00223 virtual void create();
00224
00225
00226 virtual void detach();
00227
00228
00229 virtual void layout();
00230
00231
00232 FXint getNumItems() const { return items.no(); }
00233
00234
00235 FXint getTotalSize() const;
00236
00237
00238 virtual FXint getDefaultWidth();
00239
00240
00241 virtual FXint getDefaultHeight();
00242
00243
00244 void setPosition(FXint pos);
00245
00246
00247 FXint getPosition() const { return pos; }
00248
00249
00250
00251
00252
00253
00254 FXint getItemAt(FXint coord) const;
00255
00256
00257 FXHeaderItem *getItem(FXint index) const;
00258
00259
00260 FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00261
00262
00263 FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00264
00265
00266 FXint fillItems(const FXchar** strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00267
00268
00269 FXint fillItems(const FXString& strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00270
00271
00272 FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00273
00274
00275 FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00276
00277
00278 FXint appendItem(FXHeaderItem* item,FXbool notify=FALSE);
00279
00280
00281 FXint appendItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00282
00283
00284 FXint prependItem(FXHeaderItem* item,FXbool notify=FALSE);
00285
00286
00287 FXint prependItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=FALSE);
00288
00289
00290 FXHeaderItem* extractItem(FXint index,FXbool notify=FALSE);
00291
00292
00293 void removeItem(FXint index,FXbool notify=FALSE);
00294
00295
00296 void clearItems(FXbool notify=FALSE);
00297
00298
00299 void setItemText(FXint index,const FXString& text);
00300
00301
00302 FXString getItemText(FXint index) const;
00303
00304
00305 void setItemIcon(FXint index,FXIcon* icon);
00306
00307
00308 FXIcon* getItemIcon(FXint index) const;
00309
00310
00311 void setItemSize(FXint index,FXint size);
00312
00313
00314 FXint getItemSize(FXint index) const;
00315
00316
00317 FXint getItemOffset(FXint index) const;
00318
00319
00320 void setItemData(FXint index,void* ptr);
00321
00322
00323 void* getItemData(FXint index) const;
00324
00325
00326 void setArrowDir(FXint index,FXbool dir=MAYBE);
00327
00328
00329 FXbool getArrowDir(FXint index) const;
00330
00331
00332
00333
00334
00335
00336
00337
00338 void setItemJustify(FXint index,FXuint justify);
00339
00340
00341 FXuint getItemJustify(FXint index) const;
00342
00343
00344
00345
00346
00347
00348
00349
00350 void setItemIconPosition(FXint index,FXuint mode);
00351
00352
00353 FXuint getItemIconPosition(FXint index) const;
00354
00355
00356 void setItemPressed(FXint index,FXbool pressed=TRUE);
00357
00358
00359 FXbool isItemPressed(FXint index) const;
00360
00361
00362 void makeItemVisible(FXint index);
00363
00364
00365 void updateItem(FXint index) const;
00366
00367
00368 void setFont(FXFont* fnt);
00369
00370
00371 FXFont* getFont() const { return font; }
00372
00373
00374 FXColor getTextColor() const { return textColor; }
00375
00376
00377 void setTextColor(FXColor clr);
00378
00379
00380 void setHeaderStyle(FXuint style);
00381
00382
00383 FXuint getHeaderStyle() const;
00384
00385
00386 void setHelpText(const FXString& text);
00387
00388
00389 const FXString& getHelpText() const { return help; }
00390
00391
00392 virtual void save(FXStream& store) const;
00393
00394
00395 virtual void load(FXStream& store);
00396
00397
00398 virtual ~FXHeader();
00399 };
00400
00401 }
00402
00403 #endif