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