Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXHeader.h
1 /********************************************************************************
2 * *
3 * H e a d e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXHEADER_H
22 #define FXHEADER_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 class FXIcon;
31 class FXFont;
32 class FXHeader;
33 
34 
36 enum {
37  HEADER_BUTTON = 0x00008000,
38  HEADER_HORIZONTAL = 0,
39  HEADER_VERTICAL = 0x00010000,
40  HEADER_TRACKING = 0x00020000,
41  HEADER_RESIZE = 0x00040000,
42  HEADER_NORMAL = HEADER_HORIZONTAL|FRAME_NORMAL
43  };
44 
45 
47 class FXAPI FXHeaderItem : public FXObject {
48  FXDECLARE(FXHeaderItem)
49  friend class FXHeader;
50 protected:
51  FXString label; // Text of item
52  FXString tip; // Tooltip of item
53  FXIcon *icon; // Icon of item
54  void *data; // User data pointer
55  FXint size; // Item size
56  FXint pos; // Item position
57  FXuint state; // State flags
58 private:
59  FXHeaderItem(const FXHeaderItem&);
60  FXHeaderItem& operator=(const FXHeaderItem&);
61 protected:
62  FXHeaderItem(){}
63  virtual void draw(const FXHeader* header,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
64 public:
65  enum{
66  ARROW_NONE = 0,
67  ARROW_UP = 0x00000001,
68  ARROW_DOWN = 0x00000002,
69  PRESSED = 0x00000004,
70  ICONOWNED = 0x00000008,
71  RIGHT = 0x00000010,
72  LEFT = 0x00000020,
73  CENTER_X = 0,
74  TOP = 0x00000040,
75  BOTTOM = 0x00000080,
76  CENTER_Y = 0,
77  BEFORE = 0x00000100,
78  AFTER = 0x00000200,
79  ABOVE = 0x00000400,
80  BELOW = 0x00000800
81  };
82 public:
83 
85  FXHeaderItem(const FXString& text,FXIcon* ic=NULL,FXint s=0,void* ptr=NULL);
86 
88  virtual void setText(const FXString& txt);
89 
91  const FXString& getText() const { return label; }
92 
94  void setTipText(const FXString& text){ tip=text; }
95 
97  const FXString& getTipText() const { return tip; }
98 
100  virtual void setIcon(FXIcon* icn,FXbool owned=false);
101 
103  FXIcon* getIcon() const { return icon; }
104 
106  void setData(void* ptr){ data=ptr; }
107 
109  void* getData() const { return data; }
110 
112  void setSize(FXint s){ size=s; }
113 
115  FXint getSize() const { return size; }
116 
118  void setPos(FXint p){ pos=p; }
119 
121  FXint getPos() const { return pos; }
122 
124  void setArrowDir(FXuint dir=ARROW_NONE);
125 
127  FXuint getArrowDir() const;
128 
130  void setJustify(FXuint justify=LEFT|CENTER_Y);
131 
133  FXuint getJustify() const;
134 
136  void setIconPosition(FXuint mode=BEFORE);
137 
139  FXuint getIconPosition() const;
140 
142  void setPressed(FXbool pressed);
143 
145  FXbool isPressed() const;
146 
148  virtual FXint getWidth(const FXHeader* header) const;
149 
151  virtual FXint getHeight(const FXHeader* header) const;
152 
154  virtual void create();
155 
157  virtual void detach();
158 
160  virtual void destroy();
161 
163  virtual void save(FXStream& store) const;
164  virtual void load(FXStream& store);
165 
167  virtual ~FXHeaderItem();
168  };
169 
170 
172 typedef FXString (*FXNumberingFunc)(FXint);
173 
174 
176 typedef FXObjectListOf<FXHeaderItem> FXHeaderItemList;
177 
178 
198 class FXAPI FXHeader : public FXFrame {
199  FXDECLARE(FXHeader)
200 protected:
201  FXHeaderItemList items; // Item list
202  FXFont *font; // Text font
203  FXNumberingFunc numbering; // Automatic caption renumbering method
204  FXString help; // Help text
205  FXColor textColor; // Text color
206  FXint pos; // Scroll position
207  FXint active; // Active button
208  FXint activepos; // Position of active item
209  FXint activesize; // Size of active item
210  FXint offset; // Offset where split grabbed
211 protected:
212  FXHeader();
213  void drawSplit(FXint pos);
214  virtual FXHeaderItem *createItem(const FXString& text,FXIcon* icon,FXint size,void* ptr);
215 private:
216  FXHeader(const FXHeader&);
217  FXHeader &operator=(const FXHeader&);
218 public:
219  long onPaint(FXObject*,FXSelector,void*);
220  long onLeftBtnPress(FXObject*,FXSelector,void*);
221  long onLeftBtnRelease(FXObject*,FXSelector,void*);
222  long onUngrabbed(FXObject*,FXSelector,void*);
223  long onMotion(FXObject*,FXSelector,void*);
224  long onTipTimer(FXObject*,FXSelector,void*);
225  long onQueryTip(FXObject*,FXSelector,void*);
226  long onQueryHelp(FXObject*,FXSelector,void*);
227 public:
228 
230  static FXString decimalNumbering(FXint index);
231 
233  static FXString alphaNumbering(FXint index);
234 public:
235 
237  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);
238 
240  virtual void create();
241 
243  virtual void detach();
244 
246  virtual void layout();
247 
249  FXint getNumItems() const { return (FXint)items.no(); }
250 
252  FXint getTotalSize() const;
253 
255  virtual FXint getDefaultWidth();
256 
258  virtual FXint getDefaultHeight();
259 
261  void setPosition(FXint pos);
262 
264  FXint getPosition() const { return pos; }
265 
271  FXint getItemAt(FXint coord) const;
272 
274  FXHeaderItem *getItem(FXint index) const;
275 
277  FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=false);
278 
280  FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
281 
283  FXint fillItems(const FXchar *const *strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
284 
286  FXint fillItems(const FXString* strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
287 
289  FXint fillItems(const FXString& strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
290 
292  FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=false);
293 
295  FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
296 
298  FXint appendItem(FXHeaderItem* item,FXbool notify=false);
299 
301  FXint appendItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
302 
304  FXint prependItem(FXHeaderItem* item,FXbool notify=false);
305 
307  FXint prependItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
308 
310  FXHeaderItem* extractItem(FXint index,FXbool notify=false);
311 
313  void removeItem(FXint index,FXbool notify=false);
314 
316  void clearItems(FXbool notify=false);
317 
319  void setItemText(FXint index,const FXString& text);
320 
322  FXString getItemText(FXint index) const;
323 
325  void setItemTipText(FXint index,const FXString& text);
326 
328  FXString getItemTipText(FXint index) const;
329 
331  void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false);
332 
334  FXIcon* getItemIcon(FXint index) const;
335 
337  void setItemSize(FXint index,FXint size);
338 
340  FXint getItemSize(FXint index) const;
341 
343  FXint getItemOffset(FXint index) const;
344 
346  void setItemData(FXint index,void* ptr);
347 
349  void* getItemData(FXint index) const;
350 
352  void setArrowDir(FXint index,FXuint dir=FXHeaderItem::ARROW_NONE);
353 
355  FXuint getArrowDir(FXint index) const;
356 
364  void setItemJustify(FXint index,FXuint justify);
365 
367  FXuint getItemJustify(FXint index) const;
368 
376  void setItemIconPosition(FXint index,FXuint mode);
377 
379  FXuint getItemIconPosition(FXint index) const;
380 
382  void setItemPressed(FXint index,FXbool pressed=true);
383 
385  FXbool isItemPressed(FXint index) const;
386 
388  void makeItemVisible(FXint index);
389 
391  void updateItem(FXint index) const;
392 
394  void setFont(FXFont* fnt);
395 
397  FXFont* getFont() const { return font; }
398 
400  void renumberCaptions(FXNumberingFunc func,FXint fm=0,FXint to=2147483647);
401 
403  void setAutoNumbering(FXNumberingFunc func);
404 
406  FXNumberingFunc getAutoNumbering() const { return numbering; }
407 
409  void setTextColor(FXColor clr);
410 
412  FXColor getTextColor() const { return textColor; }
413 
415  void setHeaderStyle(FXuint style);
416 
418  FXuint getHeaderStyle() const;
419 
421  void setHelpText(const FXString& text){ help=text; }
422 
424  const FXString& getHelpText() const { return help; }
425 
427  virtual void save(FXStream& store) const;
428 
430  virtual void load(FXStream& store);
431 
433  virtual ~FXHeader();
434  };
435 
436 }
437 
438 #endif

Copyright © 1997-2016 Jeroen van der Zijp