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
protected:
00063
enum{
00064
ARROW_NONE = 0,
00065
ARROW_UP = 0x00000001,
00066
ARROW_DOWN = 0x00000002,
00067 PRESSED = 0x00000004
00068 };
00069
public:
00070
enum{
00071 RIGHT = 0x00000008,
00072 LEFT = 0x00000010,
00073 CENTER_X = 0,
00074 TOP = 0x00000020,
00075 BOTTOM = 0x00000040,
00076 CENTER_Y = 0,
00077 BEFORE = 0x00000080,
00078 AFTER = 0x00000100,
00079 ABOVE = 0x00000200,
00080 BELOW = 0x00000400
00081 };
00082 public:
00083
00084
00085 FXHeaderItem(
const FXString& text,
FXIcon* ic=NULL,FXint s=0,
void* ptr=NULL):label(text),icon(ic),data(ptr),size(s),pos(0),state(FXHeaderItem::LEFT|FXHeaderItem::BEFORE){}
00086
00087
00088 virtual void setText(
const FXString& txt){ label=txt; }
00089
00090
00091 const FXString& getText()
const {
return label; }
00092
00093
00094 virtual void setIcon(
FXIcon* icn){ icon=icn; }
00095
00096
00097 FXIcon* getIcon()
const {
return icon; }
00098
00099
00100 void setData(
void* ptr){ data=ptr; }
00101
00102
00103 void* getData()
const {
return data; }
00104
00105
00106 void setSize(FXint s){ size=s; }
00107
00108
00109 FXint getSize()
const {
return size; }
00110
00111
00112
void setPos(FXint p){ pos=p; }
00113
00114
00115 FXint getPos()
const {
return pos; }
00116
00117
00118 void setArrowDir(FXbool dir=MAYBE);
00119
00120
00121 FXbool getArrowDir() const;
00122
00123
00124 void setJustify(FXuint justify);
00125
00126
00127 FXuint getJustify()
const {
return state&(RIGHT|LEFT|TOP|BOTTOM); }
00128
00129
00130 void setIconPosition(FXuint mode);
00131
00132
00133 FXuint getIconPosition()
const {
return state&(BEFORE|AFTER|ABOVE|BELOW); }
00134
00135
00136
void setPressed(FXbool pressed);
00137
00138
00139 FXbool isPressed()
const {
return (state&PRESSED)!=0; }
00140
00141
00142
virtual FXint getWidth(
const FXHeader* header)
const;
00143
00144
00145
virtual FXint getHeight(
const FXHeader* header)
const;
00146
00147
00148
virtual void create();
00149
00150
00151
virtual void detach();
00152
00153
00154
virtual void destroy();
00155
00156
00157
virtual void save(
FXStream& store)
const;
00158
virtual void load(
FXStream& store);
00159
00160
00161
virtual ~FXHeaderItem(){}
00162 };
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 FXHeaderItem **items;
00188 FXint nitems;
00189 FXColor textColor;
00190
FXFont *font;
00191
FXString help;
00192 FXint pos;
00193 FXint active;
00194 FXint activepos;
00195 FXint activesize;
00196 FXint offset;
00197
protected:
00198 FXHeader();
00199
void drawSplit(FXint pos);
00200
virtual FXHeaderItem *createItem(
const FXString& text,
FXIcon* icon,FXint size,
void* ptr);
00201
private:
00202 FXHeader(
const FXHeader&);
00203 FXHeader &operator=(
const FXHeader&);
00204 public:
00205
long onPaint(
FXObject*,FXSelector,
void*);
00206
long onLeftBtnPress(
FXObject*,FXSelector,
void*);
00207
long onLeftBtnRelease(
FXObject*,FXSelector,
void*);
00208
long onUngrabbed(
FXObject*,FXSelector,
void*);
00209
long onMotion(
FXObject*,FXSelector,
void*);
00210
long onTipTimer(
FXObject*,FXSelector,
void*);
00211
long onQueryTip(
FXObject*,FXSelector,
void*);
00212
long onQueryHelp(
FXObject*,FXSelector,
void*);
00213
public:
00214
00215
00216 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);
00217
00218
00219 virtual void create();
00220
00221
00222
virtual void detach();
00223
00224
00225
virtual void layout();
00226
00227
00228 FXint getNumItems()
const {
return nitems; }
00229
00230
00231 FXint getTotalSize() const;
00232
00233
00234 virtual FXint getDefaultWidth();
00235
00236
00237 virtual FXint getDefaultHeight();
00238
00239
00240
void setPosition(FXint p);
00241
00242
00243 FXint getPosition()
const {
return pos; }
00244
00245
00246 FXHeaderItem *getItem(FXint index)
const;
00247
00248
00249 FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00250
00251
00252
00253
00254
00255
00256 FXint getItemAt(FXint coord)
const;
00257
00258
00259 FXint setItem(FXint index,
const FXString& text,FXIcon *icon=NULL,FXint size=0,
void* ptr=NULL,FXbool notify=FALSE);
00260
00261
00262 FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=FALSE);
00263
00264
00265 FXint insertItem(FXint index,
const FXString& text,FXIcon *icon=NULL,FXint size=0,
void* ptr=NULL,FXbool notify=FALSE);
00266
00267
00268 FXint appendItem(FXHeaderItem* item,FXbool notify=FALSE);
00269
00270
00271 FXint appendItem(
const FXString& text,FXIcon *icon=NULL,FXint size=0,
void* ptr=NULL,FXbool notify=FALSE);
00272
00273
00274 FXint prependItem(FXHeaderItem* item,FXbool notify=FALSE);
00275
00276
00277 FXint prependItem(
const FXString& text,FXIcon *icon=NULL,FXint size=0,
void* ptr=NULL,FXbool notify=FALSE);
00278
00279
00280
void removeItem(FXint index,FXbool notify=FALSE);
00281
00282
00283
void clearItems(FXbool notify=FALSE);
00284
00285
00286
void setItemText(FXint index,
const FXString& text);
00287
00288
00289 FXString getItemText(FXint index)
const;
00290
00291
00292
void setItemIcon(FXint index,FXIcon* icon);
00293
00294
00295 FXIcon* getItemIcon(FXint index)
const;
00296
00297
00298
void setItemSize(FXint index,FXint size);
00299
00300
00301 FXint getItemSize(FXint index)
const;
00302
00303
00304 FXint getItemOffset(FXint index)
const;
00305
00306
00307
void setItemData(FXint index,
void* ptr);
00308
00309
00310
void* getItemData(FXint index)
const;
00311
00312
00313
void setArrowDir(FXint index,FXbool dir=MAYBE);
00314
00315
00316 FXbool getArrowDir(FXint index)
const;
00317
00318
00319
void setItemJustify(FXint index,FXuint justify);
00320
00321
00322 FXuint getItemJustify(FXint index)
const;
00323
00324
00325 void setItemIconPosition(FXint index,FXuint mode);
00326
00327
00328 FXuint getItemIconPosition(FXint index)
const;
00329
00330
00331
void setItemPressed(FXint index,FXbool pressed=TRUE);
00332
00333
00334 FXbool isItemPressed(FXint index)
const;
00335
00336
00337
void makeItemVisible(FXint index);
00338
00339
00340 void updateItem(FXint index)
const;
00341
00342
00343
void setFont(
FXFont* fnt);
00344
00345
00346
FXFont* getFont()
const {
return font; }
00347
00348
00349 FXColor getTextColor()
const {
return textColor; }
00350
00351
00352
void setTextColor(FXColor clr);
00353
00354
00355
void setHeaderStyle(FXuint style);
00356
00357
00358 FXuint getHeaderStyle() const;
00359
00360
00361
void setHelpText(const FXString& text);
00362
00363
00364 FXString getHelpText()
const {
return help; }
00365
00366
00367
virtual void save(FXStream& store)
const;
00368
00369
00370
virtual void load(FXStream& store);
00371
00372
00373
virtual ~FXHeader();
00374 };
00375
00376 }
00377
00378
#endif