Dillo
fltkui.hh
Go to the documentation of this file.
1 #ifndef __DW_FLTK_UI_HH__
2 #define __DW_FLTK_UI_HH__
3 
4 #ifndef __INCLUDED_FROM_DW_FLTK_CORE_HH__
5 # error Do not include this file directly, use "fltkcore.hh" instead.
6 #endif
7 
8 #include <FL/Fl_Button.H>
9 #include <FL/Fl_Menu.H>
10 #include <FL/Fl_Text_Buffer.H>
11 
12 namespace dw {
13 namespace fltk {
14 
182 namespace ui {
183 
188 {
189 private:
190  bool enabled;
191 
192 protected:
194  Fl_Widget *widget;
197 
199 
200  FltkResource (FltkPlatform *platform);
201  void init (FltkPlatform *platform);
202  virtual Fl_Widget *createNewWidget (core::Allocation *allocation) = 0;
203 
204  virtual void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
205  void setDisplayed (bool displayed);
206  bool displayed();
207 public:
208  ~FltkResource ();
209 
210  virtual void attachView (FltkView *view);
211  virtual void detachView (FltkView *view);
212 
213  void sizeAllocate (core::Allocation *allocation);
214  void draw (core::View *view, core::Rectangle *area,
215  core::DrawingContext *context);
216 
217  void setStyle (core::style::Style *style);
218 
219  bool isEnabled ();
220  void setEnabled (bool enabled);
221 };
222 
223 
224 template <class I> class FltkSpecificResource: public I, public FltkResource
225 {
226 public:
229 
231  void draw (core::View *view, core::Rectangle *area,
232  core::DrawingContext *context);
234 
235  bool isEnabled ();
236  void setEnabled (bool enabled);
237 };
238 
239 
241  public FltkSpecificResource <dw::core::ui::LabelButtonResource>
242 {
243 private:
244  const char *label;
245 
246  static void widgetCallback (Fl_Widget *widget, void *data);
247 
248 protected:
250 
251 public:
252  FltkLabelButtonResource (FltkPlatform *platform, const char *label);
254 
255  void sizeRequest (core::Requisition *requisition);
256 
257  const char *getLabel ();
258  void setLabel (const char *label);
259 };
260 
261 
263  public FltkSpecificResource <dw::core::ui::ComplexButtonResource>
264 {
265 private:
266  bool relief;
267 
268  static void widgetCallback (Fl_Widget *widget, void *data);
269 
270 protected:
272 
273  void attachView (FltkView *view);
274  void detachView (FltkView *view);
275 
277 
280 
281  int reliefXThickness ();
282  int reliefYThickness ();
283 
285 
286 public:
288  bool relief);
290 };
291 
292 
298  public FltkSpecificResource <dw::core::ui::EntryResource>
299 {
300 private:
301  int size;
302  bool password;
303  const char *initText;
304  char *label;
305  int label_w;
306  char *placeholder;
307  bool editable;
308 
309  static void widgetCallback (Fl_Widget *widget, void *data);
310  void setDisplayed (bool displayed);
311 
312 protected:
314  void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
315 
316 public:
317  FltkEntryResource (FltkPlatform *platform, int size, bool password,
318  const char *label, const char *placeholder);
320 
321  void sizeRequest (core::Requisition *requisition);
323 
324  const char *getText ();
325  void setText (const char *text);
326  bool isEditable ();
327  void setEditable (bool editable);
328  void setMaxLength (int maxlen);
329 };
330 
331 
333  public FltkSpecificResource <dw::core::ui::MultiLineTextResource>
334 {
335 private:
336  bool editable;
338  char *placeholder;
339 protected:
341  void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
342 
343 public:
344  FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows,
345  const char *placeholder);
347 
348  void sizeRequest (core::Requisition *requisition);
349 
350  const char *getText ();
351  void setText (const char *text);
352  bool isEditable ();
353  void setEditable (bool editable);
354 };
355 
356 
357 template <class I> class FltkToggleButtonResource:
358  public FltkSpecificResource <I>
359 {
360 private:
362 
363 protected:
364  virtual Fl_Button *createNewButton (core::Allocation *allocation) = 0;
366  void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
367 
368 public:
370  bool activated);
372 
373  void sizeRequest (core::Requisition *requisition);
374 
375  bool isActivated ();
376  void setActivated (bool activated);
377 };
378 
379 
381  public FltkToggleButtonResource <dw::core::ui::CheckButtonResource>
382 {
383 protected:
385 
386 public:
388  bool activated);
390 };
391 
392 
394  public FltkToggleButtonResource <dw::core::ui::RadioButtonResource>
395 {
396 private:
397  class Group
398  {
399  private:
402  {
403  private:
405 
406  public:
409  *list)
410  { it = list->iterator (); }
411 
412  bool hasNext ();
414  void unref ();
415  };
416 
418 
419  protected:
420  ~Group ();
421 
422  public:
423  Group (FltkRadioButtonResource *radioButtonResource);
424 
427  {
428  return list->iterator ();
429  }
430 
433  {
434  return new FltkGroupIterator (list);
435  }
436 
437  void connect (FltkRadioButtonResource *radioButtonResource);
438  void unconnect (FltkRadioButtonResource *radioButtonResource);
439  };
440 
442 
443  static void widgetCallback (Fl_Widget *widget, void *data);
444  void buttonClicked ();
445 
446 protected:
448 
449 public:
451  FltkRadioButtonResource *groupedWith,
452  bool activated);
454 
456 };
457 
458 
459 template <class I> class FltkSelectionResource:
460  public FltkSpecificResource <I>
461 {
462 protected:
463  virtual bool setSelectedItems() { return false; }
464  virtual void addItem (const char *str, bool enabled, bool selected) = 0;
465  virtual void setItem (int index, bool selected) = 0;
466  virtual void pushGroup (const char *name, bool enabled) = 0;
467  virtual void popGroup () = 0;
468 public:
470  FltkSpecificResource<I> (platform) {};
472 };
473 
474 
476  public FltkSelectionResource <dw::core::ui::OptionMenuResource>
477 {
478 protected:
480  virtual bool setSelectedItems() { return true; }
481  void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
482  int getNumberOfItems();
483  int getMaxItemWidth ();
484 private:
485  static void widgetCallback (Fl_Widget *widget, void *data);
486  void enlargeMenu();
487  Fl_Menu_Item *newItem();
488  Fl_Menu_Item *menu;
490 public:
493 
494  void addItem (const char *str, bool enabled, bool selected);
495  void setItem (int index, bool selected);
496  void pushGroup (const char *name, bool enabled);
497  void popGroup ();
498 
499  void sizeRequest (core::Requisition *requisition);
500  bool isSelected (int index);
501 };
502 
504  public FltkSelectionResource <dw::core::ui::ListResource>
505 {
506 protected:
508  void setWidgetStyle (Fl_Widget *widget, core::style::Style *style);
509  int getNumberOfItems();
510  int getMaxItemWidth ();
511 private:
512  static void widgetCallback (Fl_Widget *widget, void *data);
513  void *newItem (const char *str, bool enabled, bool selected);
515  int colWidths[4];
516  int showRows;
517  ListResource::SelectionMode mode;
518 public:
521  int rows);
523 
524  void addItem (const char *str, bool enabled, bool selected);
525  void setItem (int index, bool selected);
526  void pushGroup (const char *name, bool enabled);
527  void popGroup ();
528 
529  void sizeRequest (core::Requisition *requisition);
530  bool isSelected (int index);
531 };
532 
533 
534 } // namespace ui
535 } // namespace fltk
536 } // namespace dw
537 
538 
539 #endif // __DW_FLTK_UI_HH__
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:911
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:743
void setStyle(core::style::Style *style)
Definition: fltkui.cc:588
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1081
const char * getText()
Definition: fltkui.cc:988
FltkView * topView
Definition: fltkui.hh:271
FltkResource(FltkPlatform *platform)
Definition: fltkui.cc:399
void setLayout(dw::core::Layout *layout)
Definition: fltkui.cc:821
bool enabled
Definition: fltkui.hh:190
bool relief
Definition: fltkui.hh:266
virtual void pushGroup(const char *name, bool enabled)=0
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1392
void setDisplayed(bool displayed)
Definition: fltkui.cc:931
void connect(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1273
bool isEnabled()
Definition: fltkui.cc:543
void pushGroup(const char *name, bool enabled)
Definition: fltkui.cc:1512
dw::core::Iterator * iterator(dw::core::Content::Type mask, bool atEnd)
Definition: fltkui.cc:1360
ListResource::SelectionMode mode
Definition: fltkui.hh:517
Definition: fltkui.hh:240
Layout * layout
Definition: ui.hh:425
int currDepth
Definition: fltkui.hh:514
dw::core::Platform * createPlatform()
Definition: fltkui.cc:780
Definition: fltkui.hh:380
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1094
void popGroup()
Definition: fltkui.cc:1716
Definition: fltkui.hh:475
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:889
FltkToggleButtonResource(FltkPlatform *platform, bool activated)
Definition: fltkui.cc:1145
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
int reliefYThickness()
Definition: fltkui.cc:831
int size
Definition: fltkui.hh:301
Type
Definition: types.hh:199
int itemsAllocated
Definition: fltkui.hh:489
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:574
int showRows
Definition: fltkui.hh:516
GroupIterator * groupIterator()
Return an iterator, to access all radio button resources within the group.
Definition: fltkui.cc:1311
SelectionMode
Definition: ui.hh:481
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:798
bool isEditable()
Definition: fltkui.cc:1002
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
void setStyle(core::style::Style *style)
Definition: fltkui.cc:488
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
bool editable
Definition: fltkui.hh:336
FltkOptionMenuResource(FltkPlatform *platform)
Definition: fltkui.cc:1368
int reliefXThickness()
Definition: fltkui.cc:826
Fl_Button * createNewButton(core::Allocation *allocation)
Definition: fltkui.cc:1332
void setEditable(bool editable)
Definition: fltkui.cc:1007
char * label
Definition: fltkui.hh:304
bool isEditable()
Definition: fltkui.cc:1132
bool isActivated()
Definition: fltkui.cc:1204
~FltkResource()
Definition: fltkui.cc:427
bool isEnabled()
Definition: fltkui.cc:594
void unconnect(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1279
int getNumberOfItems()
Definition: fltkui.cc:1538
void detachView(FltkView *view)
Definition: fltkui.cc:793
Iterator< T > iterator()
Definition: container.hh:416
core::style::Style * style
Definition: fltkui.hh:198
void enlargeMenu()
Definition: fltkui.cc:1461
FltkListResource(FltkPlatform *platform, core::ui::ListResource::SelectionMode selectionMode, int rows)
Definition: fltkui.cc:1572
void pushGroup(const char *name, bool enabled)
Definition: fltkui.cc:1699
lout::container::typed::Iterator< FltkRadioButtonResource > iterator()
Definition: fltkui.hh:426
virtual void addItem(const char *str, bool enabled, bool selected)=0
void setText(const char *text)
Definition: fltkui.cc:1127
virtual Fl_Button * createNewButton(core::Allocation *allocation)=0
virtual void setItem(int index, bool selected)=0
~FltkRadioButtonResource()
Definition: fltkui.cc:1305
void init(FltkPlatform *platform)
Definition: fltkui.cc:420
lout::container::typed::List< FltkRadioButtonResource > * list
Definition: fltkui.hh:417
const char * getText()
Definition: fltkui.cc:1122
~FltkListResource()
Definition: fltkui.cc:1583
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:837
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
Definition: fltkui.hh:393
const char * label
Definition: fltkui.hh:244
Definition: fltkui.hh:297
bool displayed()
Definition: fltkui.cc:531
FltkPlatform * platform
Definition: fltkui.hh:196
void setLabel(const char *label)
Definition: fltkui.cc:717
void addItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1683
FltkSpecificResource(FltkPlatform *platform)
Definition: fltkui.cc:560
Fl_Widget * widget
Definition: fltkui.hh:194
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1160
FltkCheckButtonResource(FltkPlatform *platform, bool activated)
Definition: fltkui.cc:1219
~FltkComplexButtonResource()
Definition: fltkui.cc:739
void setEnabled(bool enabled)
Definition: fltkui.cc:599
void setText(const char *text)
Definition: fltkui.cc:993
Fl_Menu_Item * menu
Definition: fltkui.hh:488
void setItem(int index, bool selected)
Definition: fltkui.cc:1506
virtual void detachView(FltkView *view)
Definition: fltkui.cc:459
Definition: style.hh:613
~FltkMultiLineTextResource()
Definition: fltkui.cc:1060
FltkComplexButtonResource(FltkPlatform *platform, dw::core::Widget *widget, bool relief)
Definition: fltkui.cc:728
Definition: types.hh:172
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
int label_w
Definition: fltkui.hh:305
virtual void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:499
void setItem(int index, bool selected)
Definition: fltkui.cc:1692
virtual bool setSelectedItems()
Definition: fltkui.hh:463
~FltkSpecificResource()
Definition: fltkui.cc:569
bool password
Definition: fltkui.hh:302
This interface adds some more methods for all flkt-based views.
Definition: fltkplatform.hh:78
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1415
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1179
The base class of all dillo widgets.
Definition: widget.hh:23
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:937
char * placeholder
Definition: fltkui.hh:338
Set at the top when drawing.
Definition: types.hh:294
int getMaxItemWidth()
Definition: fltkui.cc:1727
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:467
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1732
virtual bool setSelectedItems()
Definition: fltkui.hh:480
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:648
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:700
~FltkCheckButtonResource()
Definition: fltkui.cc:1228
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:637
void attachView(FltkView *view)
Definition: fltkui.cc:785
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1066
const char * getLabel()
Definition: fltkui.cc:711
FltkLabelButtonResource(FltkPlatform *platform, const char *label)
Definition: fltkui.cc:624
Fl_Button * createNewButton(core::Allocation *allocation)
Definition: fltkui.cc:1233
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1588
dw::core::ui::RadioButtonResource::GroupIterator * groupIterator()
Definition: fltkui.hh:432
FltkMultiLineTextResource(FltkPlatform *platform, int cols, int rows, const char *placeholder)
Definition: fltkui.cc:1033
char * placeholder
Definition: fltkui.hh:306
~FltkEntryResource()
Definition: fltkui.cc:879
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: fltkui.cc:580
bool editable
Definition: fltkui.hh:307
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:983
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1316
~FltkToggleButtonResource()
Definition: fltkui.cc:1154
void setActivated(bool activated)
Definition: fltkui.cc:1211
Fl_Menu_Item * newItem()
Definition: fltkui.cc:1477
int itemsUsed
Definition: fltkui.hh:489
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
FltkView * view
Definition: fltkui.hh:193
~FltkLabelButtonResource()
Definition: fltkui.cc:632
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1404
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
Definition: fltkplatform.hh:92
dw::core::ui::RadioButtonResource * getNext()
Definition: fltkui.cc:1250
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:963
core::Allocation allocation
Definition: fltkui.hh:195
Group(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1261
const char * initText
Definition: fltkui.hh:303
~FltkOptionMenuResource()
Definition: fltkui.cc:1383
An interface to encapsulate some platform dependencies.
Definition: platform.hh:16
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1169
FltkRadioButtonResource(FltkPlatform *platform, FltkRadioButtonResource *groupedWith, bool activated)
Definition: fltkui.cc:1288
Definition: fltkui.hh:224
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1603
Typed version of container::untyped::Iterator.
Definition: container.hh:373
int numRows
Definition: fltkui.hh:337
Definition: fltkui.hh:503
Definition: fltkui.hh:459
virtual Fl_Widget * createNewWidget(core::Allocation *allocation)=0
void setDisplayed(bool displayed)
Definition: fltkui.cc:523
int getMaxItemWidth()
Definition: fltkui.cc:1420
lout::container::typed::Iterator< FltkRadioButtonResource > it
Definition: fltkui.hh:404
FltkView * flatView
Definition: fltkui.hh:271
FltkSelectionResource(FltkPlatform *platform)
Definition: fltkui.hh:469
bool isSelected(int index)
Definition: fltkui.cc:1533
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: fltkui.cc:479
bool isSelected(int index)
Definition: fltkui.cc:1767
int numCols
Definition: fltkui.hh:337
FltkGroupIterator(lout::container::typed::List< FltkRadioButtonResource > *list)
Definition: fltkui.hh:407
void * newItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1638
bool initActivated
Definition: fltkui.hh:361
virtual void attachView(FltkView *view)
Definition: fltkui.cc:442
int getNumberOfItems()
Definition: fltkui.cc:1762
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1437
Typed version of container::untyped::List.
Definition: container.hh:463
void popGroup()
Definition: fltkui.cc:1526
void setMaxLength(int maxlen)
Definition: fltkui.cc:1012
void buttonClicked()
Definition: fltkui.cc:1323
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1620
int colWidths[4]
Definition: fltkui.hh:515
void setEditable(bool editable)
Definition: fltkui.cc:1137
Group * group
Definition: fltkui.hh:441
Definition: fltkui.hh:187
void setEnabled(bool enabled)
Definition: fltkui.cc:548
FltkEntryResource(FltkPlatform *platform, int size, bool password, const char *label, const char *placeholder)
Definition: fltkui.cc:862
void addItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1490