dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

fltkui.cc
Go to the documentation of this file.
1 /*
2  * Dillo Widget
3  *
4  * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 
21 
22 #include "fltkcore.hh"
23 #include "fltkflatview.hh"
24 #include "fltkcomplexbutton.hh"
25 #include "../lout/msg.h"
26 #include "../lout/misc.hh"
27 
28 #include <FL/Fl.H>
29 #include <FL/fl_draw.H>
30 #include <FL/Fl_Input.H>
31 #include <FL/Fl_Text_Editor.H>
32 #include <FL/Fl_Check_Button.H>
33 #include <FL/Fl_Round_Button.H>
34 #include <FL/Fl_Choice.H>
35 #include <FL/Fl_Browser.H>
36 
37 #include <stdio.h>
38 
39 //----------------------------------------------------------------------------
40 
41 static Fl_Color fltkui_dimmed(Fl_Color c, Fl_Color bg)
42 {
43  return fl_color_average(c, bg, .33f);
44 };
45 
46 //----------------------------------------------------------------------------
47 /*
48  * Local sub classes
49  */
50 
51 /*
52  * Used to show optional placeholder text and to enable CTRL+{a,e,d,k} in
53  * form inputs (for start,end,del,cut)
54  */
55 class CustInput2 : public Fl_Input {
56 public:
57  CustInput2 (int x, int y, int w, int h, const char* l=0);
58  ~CustInput2 () { if (placeholder) free(placeholder); };
59  void set_placeholder(const char *str);
60  int show_placeholder();
61  int show_normal(const char *str);
62  void textcolor(Fl_Color c);
63  void input_type(int t);
64  int value(const char* str);
65  const char* value();
66  int handle(int e);
67 private:
68  char *placeholder;
70  Fl_Color usual_color;
72 };
73 
74 CustInput2::CustInput2 (int x, int y, int w, int h, const char* l) :
75  Fl_Input(x,y,w,h,l)
76 {
77  placeholder = NULL;
78  showing_placeholder = false;
79  usual_color = FL_BLACK; /* just init until widget style is set */
80 };
81 
82 /*
83  * Show normal text.
84  */
85 int CustInput2::show_normal(const char *str)
86 {
87  showing_placeholder = false;
88  Fl_Input::textcolor(usual_color);
89  Fl_Input::input_type(usual_type);
90  return Fl_Input::value(str);
91 }
92 
93 /*
94  * Show the placeholder text.
95  */
97 {
98  int ret;
99 
100  showing_placeholder = true;
101  Fl_Input::textcolor(fltkui_dimmed(usual_color, color()));
102  Fl_Input::input_type(FL_NORMAL_INPUT);
103  ret = Fl_Input::value(placeholder);
104  position(0);
105  return ret;
106 }
107 
108 /*
109  * Set the placeholder text.
110  */
111 void CustInput2::set_placeholder(const char *str)
112 {
113  if (placeholder)
114  free(placeholder);
115  placeholder = strdup(str);
116 
117  if ((Fl::focus() != this) && !*value()) {
119  }
120 }
121 
122 /*
123  * Set the text color.
124  */
125 void CustInput2::textcolor(Fl_Color c)
126 {
127  usual_color = c;
129  c = fltkui_dimmed(c, color());
130  Fl_Input::textcolor(c);
131 }
132 
133 /*
134  * Set the input type (normal, password, etc.)
135  */
137 {
138  usual_type = t;
139  Fl_Input::input_type(t);
140 }
141 
142 /*
143  * Set the value of the input.
144  * NOTE that we're not being very careful with the return value, which is
145  * supposed to be nonzero iff the value was changed.
146  */
147 int CustInput2::value(const char *str)
148 {
149  return (placeholder && (!str || !*str) && Fl::focus() != this)
150  ? show_placeholder() : show_normal(str);
151 }
152 
153 /*
154  * Return the value (text) of the input.
155  */
156 const char* CustInput2::value()
157 {
158  return showing_placeholder ? "" : Fl_Input::value();
159 }
160 
162 {
163  int rc, k = Fl::event_key();
164 
165  _MSG("CustInput2::handle event=%d\n", e);
166 
167  // We're only interested in some flags
168  unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
169 
170  if (e == FL_KEYBOARD) {
171  if (k == FL_Page_Down || k == FL_Page_Up || k == FL_Up || k == FL_Down) {
172  // Let them through for key commands and viewport motion.
173  return 0;
174  }
175  if (modifier == FL_CTRL) {
176  if (k == 'a' || k == 'e') {
177  position(k == 'a' ? 0 : size());
178  return 1;
179  } else if (k == 'k') {
180  cut(position(), size());
181  return 1;
182  } else if (k == 'd') {
183  cut(position(), position()+1);
184  return 1;
185  } else if (k == 'h' || k == 'i' || k == 'j' || k == 'l' || k == 'm') {
186  // Fl_Input wants to use ^H as backspace, and also "insert a few
187  // selected control characters literally", but this gets in the way
188  // of key commands.
189  return 0;
190  }
191  }
192  } else if (e == FL_UNFOCUS) {
193  if (placeholder && !value()[0]) {
195  }
196  }
197 
198  rc = Fl_Input::handle(e);
199 
200  if (rc && e == FL_FOCUS) {
201  // Nonzero return from handle() should mean that focus was accepted.
203  show_normal("");
204  }
205  return rc;
206 }
207 
208 /*
209  * Used to show optional placeholder text.
210  */
211 class CustTextEditor : public Fl_Text_Editor {
212 public:
213  CustTextEditor (int x, int y, int w, int h, const char* l=0);
214  ~CustTextEditor ();
215  void set_placeholder(const char *str);
216  void show_placeholder();
217  void show_normal(const char *str);
218  void textcolor(Fl_Color c);
219  void value(const char* str);
220  char* value();
221  int handle(int e);
222 private:
223  char *placeholder;
225  Fl_Color usual_color;
226  char *text_copy;
227 };
228 
229 CustTextEditor::CustTextEditor (int x, int y, int w, int h, const char* l) :
230  Fl_Text_Editor(x,y,w,h,l)
231 {
232  placeholder = NULL;
233  showing_placeholder = false;
234  buffer(new Fl_Text_Buffer());
235  usual_color = FL_BLACK; /* just init until widget style is set */
236  text_copy = NULL;
237 };
238 
240 {
241  Fl_Text_Buffer *buf = buffer();
242 
243  buffer(NULL);
244  delete buf;
245 
246  if (placeholder)
247  free(placeholder);
248  if (text_copy)
249  free(text_copy);
250 }
251 
252 /*
253  * Show normal text.
254  */
255 void CustTextEditor::show_normal(const char *str)
256 {
257  showing_placeholder = false;
258  Fl_Text_Editor::textcolor(usual_color);
259  buffer()->text(str);
260 }
261 
262 /*
263  * Show the placeholder text.
264  */
266 {
267  showing_placeholder = true;
268  Fl_Text_Editor::textcolor(fltkui_dimmed(usual_color, color()));
269  buffer()->text(placeholder);
270 }
271 
272 /*
273  * Set the placeholder text.
274  */
275 void CustTextEditor::set_placeholder(const char *str)
276 {
277  if (placeholder)
278  free(placeholder);
279  placeholder = strdup(str);
280 
281  if ((Fl::focus() != this) && buffer()->length() == 0) {
283  }
284 }
285 
286 /*
287  * Set the text color.
288  */
290 {
291  usual_color = c;
293  c = fltkui_dimmed(c, color());
294  Fl_Text_Editor::textcolor(c);
295 }
296 
297 /*
298  * Set the value of the input.
299  */
300 void CustTextEditor::value(const char *str)
301 {
302  if (placeholder && (!str || !*str) && Fl::focus() != this)
304  else
305  show_normal(str);
306 }
307 
308 /*
309  * Return the value (text) of the input.
310  */
312 {
313  /* FLTK-1.3 insists upon returning a new copy of the buffer text, so
314  * we have to keep track of it.
315  */
316  if (text_copy)
317  free(text_copy);
318  text_copy = showing_placeholder ? strdup("") : buffer()->text();
319  return text_copy;
320 }
321 
323 {
324  int rc;
325 
326  if (e == FL_UNFOCUS) {
327  if (placeholder && buffer()->length() == 0) {
329  }
330  }
331 
332  rc = Fl_Text_Editor::handle(e);
333 
334  if (rc && e == FL_FOCUS) {
335  // Nonzero return from handle() should mean that focus was accepted.
337  show_normal("");
338  }
339  return rc;
340 }
341 
342 
343 /*
344  * Used to handle some keystrokes as shortcuts to option menuitems
345  * (i.e. jump to the next menuitem whose label starts with the pressed key)
346  */
347 class CustChoice : public Fl_Choice {
348 public:
349  CustChoice (int x, int y, int w, int h, const char* l=0) :
350  Fl_Choice(x,y,w,h,l) {};
351  int handle(int e);
352 };
353 
355 {
356  int k = Fl::event_key();
357  unsigned modifier = Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META);
358 
359  _MSG("CustChoice::handle %p e=%d active=%d focus=%d\n",
360  this, e, active(), (Fl::focus() == this));
361  if (Fl::focus() != this) {
362  ; // Not Focused, let FLTK handle it
363  } else if (e == FL_KEYDOWN && modifier == 0) {
364  if (k == FL_Enter || k == FL_Down) {
365  return Fl_Choice::handle(FL_PUSH); // activate menu
366 
367  } else if (isalnum(k)) { // try key as shortcut to menuitem
368  int t = value()+1 >= size() ? 0 : value()+1;
369  while (t != value()) {
370  const Fl_Menu_Item *mi = &(menu()[t]);
371  if (mi->submenu()) // submenu?
372  ;
373  else if (mi->label() && mi->active()) { // menu item?
374  if (k == tolower(mi->label()[0])) {
375  value(mi);
376  return 1; // Let FLTK know we used this key
377  }
378  }
379  if (++t == size())
380  t = 0;
381  }
382  }
383  }
384 
385  return Fl_Choice::handle(e);
386 }
387 
388 //----------------------------------------------------------------------------
389 
390 namespace dw {
391 namespace fltk {
392 namespace ui {
393 
395 
396 using namespace lout::object;
397 using namespace lout::container::typed;
398 
400 {
401  this->platform = platform;
402 
403  allocation.x = 0;
404  allocation.y = 0;
405  allocation.width = 1;
406  allocation.ascent = 1;
407  allocation.descent = 0;
408 
409  style = NULL;
410 
411  enabled = true;
412 }
413 
419 {
420  view = NULL;
421  widget = NULL;
422  platform->attachResource (this);
423 }
424 
426 {
427  platform->detachResource (this);
428  if (widget) {
429  if (view) {
430  view->removeFltkWidget(widget);
431  }
432  delete widget;
433  }
434  if (style)
435  style->unref ();
436 }
437 
439 {
440  if (this->view)
441  MSG_ERR("FltkResource::attachView: multiple views!\n");
442 
443  if (view->usesFltkWidgets ()) {
444  this->view = view;
445 
446  widget = createNewWidget (&allocation);
447  view->addFltkWidget (widget, &allocation);
448  if (style)
449  setWidgetStyle (widget, style);
450  if (! enabled)
451  widget->deactivate ();
452  }
453 }
454 
456 {
457  if (this->view != view)
458  MSG_ERR("FltkResource::detachView: this->view: %p view: %p\n",
459  this->view, view);
460  this->view = NULL;
461 }
462 
464 {
465  this->allocation = *allocation;
466  view->allocateFltkWidget (widget, allocation);
467 }
468 
470 {
471  FltkView *fltkView = (FltkView*)view;
472  if (fltkView->usesFltkWidgets () && this->view == fltkView) {
473  fltkView->drawFltkWidget (widget, area);
474  }
475 }
476 
478 {
479  if (this->style)
480  this->style->unref ();
481 
482  this->style = style;
483  style->ref ();
484 
485  setWidgetStyle (widget, style);
486 }
487 
488 void FltkResource::setWidgetStyle (Fl_Widget *widget,
489  core::style::Style *style)
490 {
491  FltkFont *font = (FltkFont*)style->font;
492  widget->labelsize (font->size);
493  widget->labelfont (font->font);
494 
495  FltkColor *bg = (FltkColor*)style->backgroundColor;
496  if (bg) {
497  int normal_bg = bg->colors[FltkColor::SHADING_NORMAL];
498 
499  if (style->color) {
500  int style_fg = ((FltkColor*)style->color)->colors
502  Fl_Color fg = fl_contrast(style_fg, normal_bg);
503 
504  widget->labelcolor(fg);
505  widget->selection_color(fg);
506  }
507 
508  widget->color(normal_bg);
509  }
510 }
511 
512 void FltkResource::setDisplayed(bool displayed)
513 {
514  if (displayed)
515  widget->show();
516  else
517  widget->hide();
518 }
519 
521 {
522  bool ret = false;
523 
524  if (widget) {
525  // visible() is not the same thing as being show()n exactly, but
526  // show()/hide() set it appropriately for our purposes.
527  ret = widget->visible();
528  }
529  return ret;
530 }
531 
533 {
534  return enabled;
535 }
536 
537 void FltkResource::setEnabled (bool enabled)
538 {
539  this->enabled = enabled;
540 
541  if (enabled)
542  widget->activate ();
543  else
544  widget->deactivate ();
545 }
546 
547 // ----------------------------------------------------------------------
548 
550  *allocation)
551 {
552  FltkResource::sizeAllocate (allocation);
553 }
554 
555 template <class I> void FltkSpecificResource<I>::draw (core::View *view,
556  core::Rectangle *area)
557 {
558  FltkResource::draw (view, area);
559 }
560 
562  *style)
563 {
564  FltkResource::setStyle (style);
565 }
566 
567 template <class I> bool FltkSpecificResource<I>::isEnabled ()
568 {
569  return FltkResource::isEnabled ();
570 }
571 
572 template <class I> void FltkSpecificResource<I>::setEnabled (bool enabled)
573 {
574  FltkResource::setEnabled (enabled);
575 }
576 
577 // ----------------------------------------------------------------------
578 
579 class EnterButton : public Fl_Button {
580 public:
581  EnterButton (int x,int y,int w,int h, const char* label = 0) :
582  Fl_Button (x,y,w,h,label) {};
583  int handle(int e);
584 };
585 
587 {
588  if (e == FL_KEYBOARD && Fl::focus() == this && Fl::event_key() == FL_Enter){
589  set_changed();
590  simulate_key_action();
591  do_callback();
592  return 1;
593  }
594  return Fl_Button::handle(e);
595 }
596 
598  const char *label):
599  FltkSpecificResource <dw::core::ui::LabelButtonResource> (platform)
600 {
601  this->label = strdup (label);
602  init (platform);
603 }
604 
606 {
607  free((char *)label);
608 }
609 
611  *allocation)
612 {
613  Fl_Button *button =
616  button->callback (widgetCallback, this);
617  button->when (FL_WHEN_RELEASE);
618  return button;
619 }
620 
622 {
623  if (style) {
624  FltkFont *font = (FltkFont*)style->font;
625  fl_font(font->font,font->size);
626  requisition->width =
627  (int)fl_width (label, strlen (label))
628  + 2 * RELIEF_X_THICKNESS;
629  requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
630  requisition->descent = font->descent + RELIEF_Y_THICKNESS;
631  } else {
632  requisition->width = 1;
633  requisition->ascent = 1;
634  requisition->descent = 0;
635  }
636 }
637 
638 /*
639  * Get FLTK state and translate to dw
640  *
641  * TODO: find a good home for this and the fltkviewbase.cc original.
642  */
644 {
645  int s1 = Fl::event_state ();
646  int s2 = (core::ButtonState)0;
647 
648  if (s1 & FL_SHIFT) s2 |= core::SHIFT_MASK;
649  if (s1 & FL_CTRL) s2 |= core::CONTROL_MASK;
650  if (s1 & FL_ALT) s2 |= core::META_MASK;
651  if (s1 & FL_BUTTON1) s2 |= core::BUTTON1_MASK;
652  if (s1 & FL_BUTTON2) s2 |= core::BUTTON2_MASK;
653  if (s1 & FL_BUTTON3) s2 |= core::BUTTON3_MASK;
654 
655  return (core::ButtonState)s2;
656 }
657 
659 {
660  event->xCanvas = Fl::event_x();
661  event->yCanvas = Fl::event_y();
662  event->state = getDwButtonState();
663  event->button = Fl::event_button();
664  event->numPressed = Fl::event_clicks() + 1;
665 }
666 
668  void *data)
669 {
670  if (!Fl::event_button3()) {
672  dw::core::EventButton event;
673  setButtonEvent(&event);
674  lbr->emitClicked(&event);
675  }
676 }
677 
679 {
680  return label;
681 }
682 
683 
684 void FltkLabelButtonResource::setLabel (const char *label)
685 {
686  free((char *)this->label);
687  this->label = strdup (label);
688 
689  widget->label (this->label);
690  queueResize (true);
691 }
692 
693 // ----------------------------------------------------------------------
694 
697  *widget, bool relief):
698  FltkSpecificResource <dw::core::ui::ComplexButtonResource> (platform)
699 {
700  flatView = topView = NULL;
701  this->relief = relief;
704 }
705 
707 {
708 }
709 
711  void *data)
712 {
714 
715  if (Fl::event() == FL_RELEASE && Fl::event_button() != FL_RIGHT_MOUSE) {
716  int w = widget->w(), h = widget->h();
717 
718  res->click_x = Fl::event_x() - widget->x();
719  res->click_y = Fl::event_y() - widget->y();
720  if (res->style) {
721  res->click_x -= res->style->boxOffsetX();
722  res->click_y -= res->style->boxOffsetY();
723  w -= res->style->boxDiffWidth();
724  h -= res->style->boxDiffHeight();
725  }
726  if (res->click_x >= 0 && res->click_y >= 0 &&
727  res->click_x < w && res->click_y < h) {
728  dw::core::EventButton event;
729  setButtonEvent(&event);
730  res->emitClicked(&event);
731  }
732  } else if (Fl::event() == FL_KEYBOARD) {
733  // Simulate a click.
734  dw::core::EventButton event;
735 
736  res->click_x = res->click_y = 0;
737  event.xCanvas = widget->x() + res->style->boxOffsetX();
738  event.yCanvas = widget->y() + res->style->boxOffsetY();
739  // ButtonState doesn't have mouse button values on a release.
740  event.state = (core::ButtonState) 0;
741  event.button = 1;
742  event.numPressed = 1;
743  res->emitClicked(&event);
744  }
745 }
746 
748 {
749  return new FltkPlatform ();
750 }
751 
753 {
755 
756  if (view->usesFltkWidgets ())
757  topView = view;
758 }
759 
761 {
763 }
764 
766 {
768 
769  ((FltkFlatView*)flatView)->resize (
773 
774  ((FltkFlatView*)flatView)->parent ()->init_sizes ();
775 }
776 
778 {
780 }
781 
783 {
784  return relief ? RELIEF_X_THICKNESS : 0;
785 }
786 
788 {
789  return relief ? RELIEF_Y_THICKNESS : 0;
790 }
791 
792 
794  *allocation)
795 {
796  ComplexButton *button =
799  button->callback (widgetCallback, this);
800  button->when (FL_WHEN_RELEASE);
801  if (!relief)
802  button->box(FL_NO_BOX);
803 
808  - 2 * reliefYThickness ());
809  button->add ((FltkFlatView *)flatView);
810 
811  if (layout)
813  return button;
814 }
815 
816 // ----------------------------------------------------------------------
817 
819  bool password, const char *label,
820  const char *placeholder):
821  FltkSpecificResource <dw::core::ui::EntryResource> (platform)
822 {
823  this->size = size;
824  this->password = password;
825  this->label = label ? strdup(label) : NULL;
826  this->label_w = 0;
827  this->placeholder = placeholder ? strdup(placeholder) : NULL;
828 
829  initText = NULL;
830  editable = false;
831 
832  init (platform);
833 }
834 
836 {
837  if (initText)
838  free((char *)initText);
839  if (label)
840  free(label);
841  if (placeholder)
842  free(placeholder);
843 }
844 
846  *allocation)
847 {
848  CustInput2 *input =
851  input->input_type(password ? FL_SECRET_INPUT : FL_NORMAL_INPUT);
852  input->callback (widgetCallback, this);
853  input->when (FL_WHEN_ENTER_KEY_ALWAYS);
854 
855  if (label) {
856  input->label(label);
857  input->align(FL_ALIGN_LEFT);
858  }
859  if (initText)
860  input->value (initText);
861  if (placeholder)
863 
864  return input;
865 }
866 
867 void FltkEntryResource::setWidgetStyle (Fl_Widget *widget,
868  core::style::Style *style)
869 {
870  CustInput2 *in = (CustInput2 *)widget;
871 
873 
874  in->textcolor(widget->labelcolor());
875  in->cursor_color(widget->labelcolor());
876  in->textsize(in->labelsize());
877  in->textfont(in->labelfont());
878 
879  if (label) {
880  int h;
881  label_w = 0;
882  widget->measure_label(label_w, h);
884  }
885 }
886 
888 {
890  queueResize(true);
891 }
892 
894 {
895  if (displayed() && style) {
896  FltkFont *font = (FltkFont*)style->font;
897  fl_font(font->font,font->size);
898  // WORKAROUND: A bug with fl_width(uint_t) on non-xft X was present in
899  // 1.3.0 (STR #2688).
900  requisition->width =
901  (int)fl_width ("n")
902  * (size == UNLIMITED_SIZE ? 10 : size)
903  + label_w + (2 * RELIEF_X_THICKNESS);
904  requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
905  requisition->descent = font->descent + RELIEF_Y_THICKNESS;
906  } else {
907  requisition->width = 0;
908  requisition->ascent = 0;
909  requisition->descent = 0;
910  }
911 }
912 
914 {
915  if (!label) {
917  } else {
918  this->allocation = *allocation;
919 
920  /* push the Fl_Input over to the right of the label */
921  core::Allocation a = this->allocation;
922  a.x += this->label_w;
923  a.width -= this->label_w;
925  }
926 }
927 
928 void FltkEntryResource::widgetCallback (Fl_Widget *widget, void *data)
929 {
930  ((FltkEntryResource*)data)->emitActivate ();
931 }
932 
934 {
935  return ((CustInput2*)widget)->value ();
936 }
937 
938 void FltkEntryResource::setText (const char *text)
939 {
940  if (initText)
941  free((char *)initText);
942  initText = strdup (text);
943 
944  ((CustInput2*)widget)->value (initText);
945 }
946 
948 {
949  return editable;
950 }
951 
952 void FltkEntryResource::setEditable (bool editable)
953 {
954  this->editable = editable;
955 }
956 
958 {
959  ((Fl_Input *)widget)->maximum_size(maxlen);
960 }
961 
962 // ----------------------------------------------------------------------
963 
964 static int kf_backspace_word (int c, Fl_Text_Editor *e)
965 {
966  int p1, p2 = e->insert_position();
967 
968  e->previous_word();
969  p1 = e->insert_position();
970  e->buffer()->remove(p1, p2);
971  e->show_insert_position();
972  e->set_changed();
973  if (e->when() & FL_WHEN_CHANGED)
974  e->do_callback();
975  return 0;
976 }
977 
979  int cols, int rows,
980  const char *placeholder):
981  FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform)
982 {
983  editable = false;
984 
985  numCols = cols;
986  numRows = rows;
987 
988  // Check values. Upper bound check is left to the caller.
989  if (numCols < 1) {
990  MSG_WARN("numCols = %d is set to 1.\n", numCols);
991  numCols = 1;
992  }
993  if (numRows < 1) {
994  MSG_WARN("numRows = %d is set to 1.\n", numRows);
995  numRows = 1;
996  }
997  this->placeholder = placeholder ? strdup(placeholder) : NULL;
998 
999  init (platform);
1000 }
1001 
1003 {
1004  if (placeholder)
1005  free(placeholder);
1006 }
1007 
1009  *allocation)
1010 {
1011  CustTextEditor *text =
1014  text->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0);
1015  text->remove_key_binding(FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE);
1016  text->add_key_binding(FL_BackSpace, 0, Fl_Text_Editor::kf_backspace);
1017  text->add_key_binding(FL_BackSpace, FL_CTRL, kf_backspace_word);
1018  if (placeholder)
1020  return text;
1021 }
1022 
1024  core::style::Style *style)
1025 {
1027 
1029 
1030  ed->textcolor(widget->labelcolor());
1031  ed->cursor_color(widget->labelcolor());
1032  ed->textsize(ed->labelsize());
1033  ed->textfont(ed->labelfont());
1034 }
1035 
1037 {
1038  if (style) {
1039  FltkFont *font = (FltkFont*)style->font;
1040  fl_font(font->font,font->size);
1041  // WORKAROUND: A bug with fl_width(uint_t) on non-xft X was present in
1042  // 1.3.0 (STR #2688).
1043  requisition->width =
1044  (int)fl_width ("n") * numCols + 2 * RELIEF_X_THICKNESS;
1045  requisition->ascent =
1046  RELIEF_Y_THICKNESS + font->ascent +
1047  (font->ascent + font->descent) * (numRows - 1);
1048  requisition->descent =
1049  font->descent +
1051  } else {
1052  requisition->width = 1;
1053  requisition->ascent = 1;
1054  requisition->descent = 0;
1055  }
1056 }
1057 
1059 {
1060  return ((CustTextEditor*)widget)->value ();
1061 }
1062 
1063 void FltkMultiLineTextResource::setText (const char *text)
1064 {
1065  ((CustTextEditor*)widget)->value (text);
1066 }
1067 
1069 {
1070  return editable;
1071 }
1072 
1074 {
1075  this->editable = editable;
1076 }
1077 
1078 // ----------------------------------------------------------------------
1079 
1080 template <class I>
1082  bool activated):
1083  FltkSpecificResource <I> (platform)
1084 {
1085  initActivated = activated;
1086 }
1087 
1088 
1089 template <class I>
1091 {
1092 }
1093 
1094 
1095 template <class I>
1097  *allocation)
1098 {
1099  Fl_Button *button = createNewButton (allocation);
1100  button->value (initActivated);
1101  return button;
1102 }
1103 
1104 template <class I>
1106  core::style::Style *style)
1107 {
1108  FltkResource::setWidgetStyle(widget, style);
1109 
1110  widget->selection_color(FL_BLACK);
1111 }
1112 
1113 
1114 template <class I>
1116 {
1117  FltkFont *font = (FltkFont *)
1118  (this->FltkResource::style ? this->FltkResource::style->font : NULL);
1119 
1120  if (font) {
1121  fl_font(font->font, font->size);
1122  requisition->width = font->ascent + font->descent + 2*RELIEF_X_THICKNESS;
1123  requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
1124  requisition->descent = font->descent + RELIEF_Y_THICKNESS;
1125  } else {
1126  requisition->width = 1;
1127  requisition->ascent = 1;
1128  requisition->descent = 0;
1129  }
1130 }
1131 
1132 
1133 template <class I>
1135 {
1136  return ((Fl_Button*)this->widget)->value ();
1137 }
1138 
1139 
1140 template <class I>
1142 {
1143  initActivated = activated;
1144  ((Fl_Button*)this->widget)->value (initActivated);
1145 }
1146 
1147 // ----------------------------------------------------------------------
1148 
1149 FltkCheckButtonResource::FltkCheckButtonResource (FltkPlatform *platform,
1150  bool activated):
1151  FltkToggleButtonResource<dw::core::ui::CheckButtonResource> (platform,
1152  activated)
1153 {
1154  init (platform);
1155 }
1156 
1157 
1159 {
1160 }
1161 
1162 
1164  *allocation)
1165 {
1166  Fl_Check_Button *cb =
1167  new Fl_Check_Button (allocation->x, allocation->y, allocation->width,
1169  return cb;
1170 }
1171 
1172 // ----------------------------------------------------------------------
1173 
1175 {
1176  return it.hasNext ();
1177 }
1178 
1181 {
1182  return (dw::core::ui::RadioButtonResource*)it.getNext ();
1183 }
1184 
1186 {
1187  delete this;
1188 }
1189 
1190 
1192  *radioButtonResource)
1193 {
1195  connect (radioButtonResource);
1196 }
1197 
1199 {
1200  delete list;
1201 }
1202 
1204  *radioButtonResource)
1205 {
1206  list->append (radioButtonResource);
1207 }
1208 
1210  *radioButtonResource)
1211 {
1212  list->removeRef (radioButtonResource);
1213  if (list->isEmpty ())
1214  delete this;
1215 }
1216 
1217 
1220  *groupedWith,
1221  bool activated):
1222  FltkToggleButtonResource<dw::core::ui::RadioButtonResource> (platform,
1223  activated)
1224 {
1225  init (platform);
1226 
1227  if (groupedWith) {
1228  group = groupedWith->group;
1229  group->connect (this);
1230  } else
1231  group = new Group (this);
1232 }
1233 
1234 
1236 {
1237  group->unconnect (this);
1238 }
1239 
1242 {
1243  return group->groupIterator ();
1244 }
1245 
1247  void *data)
1248 {
1249  if (widget->when () & FL_WHEN_CHANGED)
1251 }
1252 
1254 {
1256  it.hasNext (); ) {
1257  FltkRadioButtonResource *other = it.getNext ();
1258  other->setActivated (other == this);
1259  }
1260 }
1261 
1263  *allocation)
1264 {
1265  /*
1266  * Groups of Fl_Radio_Button must be added to one Fl_Group, which is
1267  * not possible in this context. For this, we do the grouping ourself,
1268  * based on FltkRadioButtonResource::Group.
1269  *
1270  * What we actually need for this, is a widget, which behaves like a
1271  * check button, but looks like a radio button. The first depends on the
1272  * type, the second on the style. Since the type is simpler to change
1273  * than the style, we create a radio button, and then change the type
1274  * (instead of creating a check button, and changing the style).
1275  */
1276 
1277  Fl_Button *button =
1278  new Fl_Round_Button (allocation->x, allocation->y, allocation->width,
1280  button->when (FL_WHEN_CHANGED);
1281  button->callback (widgetCallback, this);
1282  button->type (FL_TOGGLE_BUTTON);
1283 
1284  return button;
1285 }
1286 
1287 // ----------------------------------------------------------------------
1288 
1289 template <class I> dw::core::Iterator *
1291 {
1293  return new core::EmptyIterator (this->getEmbed (), mask, atEnd);
1294 }
1295 
1296 // ----------------------------------------------------------------------
1297 
1299  FltkSelectionResource <dw::core::ui::OptionMenuResource> (platform)
1300 {
1301  /* Fl_Menu_ does not like multiple menu items with the same label, and
1302  * insert() treats some characters specially unless escaped, so let's
1303  * do our own menu handling.
1304  */
1305  itemsAllocated = 0x10;
1306  menu = new Fl_Menu_Item[itemsAllocated];
1307  memset(menu, 0, itemsAllocated * sizeof(Fl_Menu_Item));
1308  itemsUsed = 1; // menu[0].text == NULL, which is an end-of-menu marker.
1309 
1310  init (platform);
1311 }
1312 
1314 {
1315  for (int i = 0; i < itemsUsed; i++) {
1316  if (menu[i].text)
1317  free((char *) menu[i].text);
1318  }
1319  delete[] menu;
1320 }
1321 
1323  core::style::Style *style)
1324 {
1325  Fl_Choice *ch = (Fl_Choice *)widget;
1326 
1328 
1329  ch->textcolor(widget->labelcolor());
1330  ch->textfont(ch->labelfont());
1331  ch->textsize(ch->labelsize());
1332 }
1333 
1335  *allocation)
1336 {
1337  Fl_Choice *choice =
1339  allocation->width,
1341  choice->menu(menu);
1342  return choice;
1343 }
1344 
1346  void *data)
1347 {
1348 }
1349 
1351 {
1352  int i, max = 0;
1353 
1354  for (i = 0; i < itemsUsed; i++) {
1355  int width = 0;
1356  const char *str = menu[i].text;
1357 
1358  if (str) {
1359  width = fl_width(str);
1360  if (width > max)
1361  max = width;
1362  }
1363  }
1364  return max;
1365 }
1366 
1368 {
1369  if (style) {
1370  FltkFont *font = (FltkFont*)style->font;
1371  fl_font(font->font, font->size);
1372  int maxItemWidth = getMaxItemWidth ();
1373  requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
1374  requisition->descent = font->descent + RELIEF_Y_THICKNESS;
1375  requisition->width = maxItemWidth
1376  + (requisition->ascent + requisition->descent)
1377  + 2 * RELIEF_X_THICKNESS;
1378  } else {
1379  requisition->width = 1;
1380  requisition->ascent = 1;
1381  requisition->descent = 0;
1382  }
1383 }
1384 
1386 {
1387  Fl_Choice *ch = (Fl_Choice *)widget;
1388  int selected = ch->value();
1389  Fl_Menu_Item *newMenu;
1390 
1391  itemsAllocated += 0x10;
1392  newMenu = new Fl_Menu_Item[itemsAllocated];
1393  memcpy(newMenu, menu, itemsUsed * sizeof(Fl_Menu_Item));
1394  memset(newMenu + itemsUsed, 0, 0x10 * sizeof(Fl_Menu_Item));
1395  delete[] menu;
1396  menu = newMenu;
1397  ch->menu(menu);
1398  ch->value(selected);
1399 }
1400 
1402 {
1403  Fl_Menu_Item *item;
1404 
1405  if (itemsUsed == itemsAllocated)
1406  enlargeMenu();
1407 
1408  item = menu + itemsUsed - 1;
1409  itemsUsed++;
1410 
1411  return item;
1412 }
1413 
1414 void FltkOptionMenuResource::addItem (const char *str,
1415  bool enabled, bool selected)
1416 {
1417  Fl_Menu_Item *item = newItem();
1418 
1419  item->text = strdup(str);
1420 
1421  if (enabled == false)
1422  item->flags = FL_MENU_INACTIVE;
1423 
1424  if (selected)
1425  ((Fl_Choice *)widget)->value(item);
1426 
1427  queueResize (true);
1428 }
1429 
1430 void FltkOptionMenuResource::setItem (int index, bool selected)
1431 {
1432  if (selected)
1433  ((Fl_Choice *)widget)->value(menu+index);
1434 }
1435 
1436 void FltkOptionMenuResource::pushGroup (const char *name, bool enabled)
1437 {
1438  Fl_Menu_Item *item = newItem();
1439 
1440  item->text = strdup(name);
1441 
1442  if (enabled == false)
1443  item->flags = FL_MENU_INACTIVE;
1444 
1445  item->flags |= FL_SUBMENU;
1446 
1447  queueResize (true);
1448 }
1449 
1451 {
1452  /* Item with NULL text field closes the submenu */
1453  newItem();
1454  queueResize (true);
1455 }
1456 
1458 {
1459  return index == ((Fl_Choice *)widget)->value();
1460 }
1461 
1463 {
1464  return ((Fl_Choice*)widget)->size();
1465 }
1466 
1467 // ----------------------------------------------------------------------
1468 
1469 class CustBrowser : public Fl_Browser {
1470 public:
1471  CustBrowser(int x, int y, int w, int h) : Fl_Browser(x, y, w, h) {};
1472  int full_width() const;
1473  int full_height() const {return Fl_Browser::full_height();}
1474  int avg_height() {return size() ? Fl_Browser_::incr_height() : 0;}
1475 };
1476 
1477 /*
1478  * Fl_Browser_ has a full_width(), but it has a tendency to contain 0, so...
1479  */
1481 {
1482  int max = 0;
1483  void *item = item_first();
1484 
1485  while (item) {
1486  int w = item_width(item);
1487 
1488  if (w > max)
1489  max = w;
1490 
1491  item = item_next(item);
1492  }
1493  return max;
1494 }
1495 
1498  selectionMode, int rowCount):
1499  FltkSelectionResource <dw::core::ui::ListResource> (platform),
1500  currDepth(0)
1501 {
1502  mode = selectionMode;
1503  showRows = rowCount;
1504  init (platform);
1505 }
1506 
1508 {
1509 }
1510 
1511 
1513 {
1514  CustBrowser *b =
1517 
1518  b->type((mode == SELECTION_MULTIPLE) ? FL_MULTI_BROWSER : FL_HOLD_BROWSER);
1519  b->callback(widgetCallback, this);
1520  b->when(FL_WHEN_CHANGED);
1521  b->column_widths(colWidths);
1522  b->column_char('\a'); // I just chose a nonprinting character.
1523 
1524  return b;
1525 }
1526 
1527 void FltkListResource::setWidgetStyle (Fl_Widget *widget,
1528  core::style::Style *style)
1529 {
1530  Fl_Browser *b = (Fl_Browser *)widget;
1531 
1533 
1534  b->textfont(widget->labelfont());
1535  b->textsize(widget->labelsize());
1536  b->textcolor(widget->labelcolor());
1537 
1538  colWidths[0] = b->textsize();
1539  colWidths[1] = colWidths[0];
1540  colWidths[2] = colWidths[0];
1541  colWidths[3] = 0;
1542 }
1543 
1544 void FltkListResource::widgetCallback (Fl_Widget *widget, void *data)
1545 {
1546  Fl_Browser *b = (Fl_Browser *) widget;
1547 
1548  if (b->selected(b->value())) {
1549  /* If it shouldn't be selectable, deselect it again. It would be nice to
1550  * have a less unpleasant way to do this.
1551  */
1552  const char *inactive_code;
1553  if ((inactive_code = strstr(b->text(b->value()), "@N"))) {
1554  const char *ignore_codes = strstr(b->text(b->value()), "@.");
1555 
1556  if (inactive_code < ignore_codes)
1557  b->select(b->value(), 0);
1558  }
1559  }
1560 }
1561 
1562 void *FltkListResource::newItem (const char *str, bool enabled, bool selected)
1563 {
1564  Fl_Browser *b = (Fl_Browser *) widget;
1565  int index = b->size() + 1;
1566  char *label = (char *)malloc(strlen(str) + 1 + currDepth + 4),
1567  *s = label;
1568 
1569  memset(s, '\a', currDepth);
1570  s += currDepth;
1571  if (!enabled) {
1572  // FL_INACTIVE_COLOR
1573  *s++ = '@';
1574  *s++ = 'N';
1575  }
1576  // ignore further '@' chars
1577  *s++ = '@';
1578  *s++ = '.';
1579 
1580  strcpy(s, str);
1581 
1582  b->add(label);
1583  free(label);
1584 
1585  if (selected) {
1586  b->select(index, selected);
1587  if (b->type() == FL_HOLD_BROWSER) {
1588  /* Left to its own devices, it sometimes has some suboptimal ideas
1589  * about how to scroll, and sometimes doesn't seem to show everything
1590  * where it thinks it is.
1591  */
1592  if (index > showRows) {
1593  /* bottomline() and middleline() don't work because the widget is
1594  * too tiny at this point for the bbox() call in
1595  * Fl_Browser::lineposition() to do what one would want.
1596  */
1597  b->topline(index - showRows + 1);
1598  } else {
1599  b->topline(1);
1600  }
1601  }
1602  }
1603  queueResize (true);
1604  return NULL;
1605 }
1606 
1607 void FltkListResource::addItem (const char *str, bool enabled, bool selected)
1608 {
1609  // Fl_Browser_::incr_height() for item height won't do the right thing if
1610  // the first item doesn't have anything to it.
1611  if (!str || !*str)
1612  str = " ";
1613  newItem(str, enabled, selected);
1614 }
1615 
1616 void FltkListResource::setItem (int index, bool selected)
1617 {
1618  Fl_Browser *b = (Fl_Browser *) widget;
1619 
1620  b->select(index + 1, selected);
1621 }
1622 
1623 void FltkListResource::pushGroup (const char *name, bool enabled)
1624 {
1625  bool en = false;
1626  bool selected = false;
1627 
1628  // Fl_Browser_::incr_height() for item height won't do the right thing if
1629  // the first item doesn't have anything to it.
1630  if (!name || !*name)
1631  name = " ";
1632 
1633  // TODO: Proper disabling of item groups
1634  newItem(name, en, selected);
1635 
1636  if (currDepth < 3)
1637  currDepth++;
1638 }
1639 
1641 {
1642  CustBrowser *b = (CustBrowser *) widget;
1643 
1644  newItem(" ", false, false);
1645  b->hide(b->size());
1646 
1647  if (currDepth)
1648  currDepth--;
1649 }
1650 
1652 {
1653  return ((CustBrowser *) widget)->full_width();
1654 }
1655 
1657 {
1658  if (style) {
1659  CustBrowser *b = (CustBrowser *) widget;
1660  int height = b->full_height();
1661  requisition->width = getMaxItemWidth() + 4;
1662 
1663  if (showRows * b->avg_height() < height) {
1664  height = showRows * b->avg_height();
1665  b->has_scrollbar(Fl_Browser_::VERTICAL_ALWAYS);
1666  requisition->width += Fl::scrollbar_size();
1667  } else {
1668  b->has_scrollbar(0);
1669  }
1670 
1671  requisition->descent = style->font->descent + 2;
1672  requisition->ascent = height - style->font->descent + 2;
1673  } else {
1674  requisition->width = 1;
1675  requisition->ascent = 1;
1676  requisition->descent = 0;
1677  }
1678 }
1679 
1681 {
1682  return ((Fl_Browser*)widget)->size();
1683 }
1684 
1686 {
1687  Fl_Browser *b = (Fl_Browser *) widget;
1688 
1689  return b->selected(index + 1) ? true : false;
1690 }
1691 
1692 } // namespace ui
1693 } // namespace fltk
1694 } // namespace dw
1695 
CustChoice::handle
int handle(int e)
Definition: fltkui.cc:354
dw::fltk::ui::FltkListResource::getNumberOfItems
int getNumberOfItems()
Definition: fltkui.cc:1680
dw::core::ui::RadioButtonResource::GroupIterator
Definition: ui.hh:510
dw::fltk::ui::FltkOptionMenuResource::getMaxItemWidth
int getMaxItemWidth()
Definition: fltkui.cc:1350
dw::fltk::ui::FltkEntryResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:845
dw::fltk::ui::FltkEntryResource::password
bool password
Definition: fltkui.hh:300
dw::fltk::ui::getDwButtonState
static core::ButtonState getDwButtonState()
Definition: fltkui.cc:643
dw::fltk::ui::FltkRadioButtonResource::Group::groupIterator
dw::core::ui::RadioButtonResource::GroupIterator * groupIterator()
Definition: fltkui.hh:430
dw::fltk::ui::FltkComplexButtonResource::sizeAllocate
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:765
dw::fltk::ui::FltkCheckButtonResource::~FltkCheckButtonResource
~FltkCheckButtonResource()
Definition: fltkui.cc:1158
dw::fltk::ui::FltkEntryResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:928
dw::fltk::ui::FltkComplexButtonResource::attachView
void attachView(FltkView *view)
Definition: fltkui.cc:752
dw::fltk::ui::kf_backspace_word
static int kf_backspace_word(int c, Fl_Text_Editor *e)
Definition: fltkui.cc:964
fltkcore.hh
dw::fltk::FltkView
This interface adds some more methods for all flkt-based views.
Definition: fltkplatform.hh:78
dw::fltk::ui::FltkRadioButtonResource::Group::~Group
~Group()
Definition: fltkui.cc:1198
dw::core::Allocation::y
int y
Definition: types.hh:166
dw::fltk::ui::FltkMultiLineTextResource::setText
void setText(const char *text)
Definition: fltkui.cc:1063
CustInput2::value
const char * value()
Definition: fltkui.cc:156
dw::core::Allocation::x
int x
Definition: types.hh:165
dw::fltk::ui::FltkRadioButtonResource::groupIterator
GroupIterator * groupIterator()
Return an iterator, to access all radio button resources within the group.
Definition: fltkui.cc:1241
dw::fltk::ui::FltkMultiLineTextResource::numRows
int numRows
Definition: fltkui.hh:335
dw::fltk::ui::FltkOptionMenuResource::newItem
Fl_Menu_Item * newItem()
Definition: fltkui.cc:1401
dw::fltk::ui::FltkOptionMenuResource::setItem
void setItem(int index, bool selected)
Definition: fltkui.cc:1430
dw::fltk::ui::FltkRadioButtonResource::buttonClicked
void buttonClicked()
Definition: fltkui.cc:1253
dw::fltk::ui::FltkResource::FltkResource
FltkResource(FltkPlatform *platform)
Definition: fltkui.cc:399
dw::core::BUTTON2_MASK
Definition: events.hh:21
dw::core::style::Style::ref
void ref()
Definition: style.hh:598
dw::fltk::ui::FltkOptionMenuResource::~FltkOptionMenuResource
~FltkOptionMenuResource()
Definition: fltkui.cc:1313
dw::fltk::ui::FltkComplexButtonResource::detachView
void detachView(FltkView *view)
Definition: fltkui.cc:760
dw::fltk::ui::FltkListResource::isSelected
bool isSelected(int index)
Definition: fltkui.cc:1685
dw::fltk::ui::FltkEntryResource::getText
const char * getText()
Definition: fltkui.cc:933
dw::fltk::ui::FltkEntryResource::size
int size
Definition: fltkui.hh:299
dw::core::Requisition
Definition: types.hh:172
dw::fltk::ui::FltkOptionMenuResource::menu
Fl_Menu_Item * menu
Definition: fltkui.hh:486
dw::fltk::ui::FltkLabelButtonResource::sizeRequest
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:621
dw::fltk::ui::FltkRadioButtonResource::FltkRadioButtonResource
FltkRadioButtonResource(FltkPlatform *platform, FltkRadioButtonResource *groupedWith, bool activated)
Definition: fltkui.cc:1218
dw::fltk::ui::FltkEntryResource::setEditable
void setEditable(bool editable)
Definition: fltkui.cc:952
dw::core::style::StyleAttrs::boxOffsetY
int boxOffsetY()
Definition: style.hh:550
lout::object
Here, some common classes (or interfaces) are defined, to standardize the access to other classes.
Definition: object.cc:29
dw::fltk::ui::FltkResource::widget
Fl_Widget * widget
Definition: fltkui.hh:194
dw::fltk::ui::FltkComplexButtonResource::setLayout
void setLayout(dw::core::Layout *layout)
Definition: fltkui.cc:777
dw::fltk::FltkView::drawFltkWidget
virtual void drawFltkWidget(Fl_Widget *widget, core::Rectangle *area)
Definition: fltkplatform.cc:378
dw::fltk::ui::FltkListResource::newItem
void * newItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1562
dw::core::EventButton
Represents a button press or release event.
Definition: events.hh:57
dw::fltk::ui::FltkRadioButtonResource::Group::FltkGroupIterator::unref
void unref()
Definition: fltkui.cc:1185
dw::core::Requisition::descent
int descent
Definition: types.hh:176
dw::fltk::ui::FltkSelectionResource::iterator
dw::core::Iterator * iterator(dw::core::Content::Type mask, bool atEnd)
Definition: fltkui.cc:1290
dw::fltk::ui::FltkResource::view
FltkView * view
Definition: fltkui.hh:193
dw::fltk::ui::FltkResource::displayed
bool displayed()
Definition: fltkui.cc:520
dw::fltk::ui::FltkMultiLineTextResource::setEditable
void setEditable(bool editable)
Definition: fltkui.cc:1073
dw::fltk::ui::FltkMultiLineTextResource::placeholder
char * placeholder
Definition: fltkui.hh:336
CustInput2::usual_color
Fl_Color usual_color
Definition: fltkui.cc:70
dw::fltk::ui::CustBrowser::full_width
int full_width() const
Definition: fltkui.cc:1480
dw::core::style::StyleAttrs::backgroundColor
Color * backgroundColor
Definition: style.hh:495
dw::fltk::ui::FltkOptionMenuResource::isSelected
bool isSelected(int index)
Definition: fltkui.cc:1457
dw::fltk::ui::FltkMultiLineTextResource::editable
bool editable
Definition: fltkui.hh:334
CustInput2::set_placeholder
void set_placeholder(const char *str)
Definition: fltkui.cc:111
dw::fltk::ui::FltkResource::setEnabled
void setEnabled(bool enabled)
Definition: fltkui.cc:537
dw::core::Content::Type
Type
Definition: types.hh:187
dw::fltk::ui::FltkListResource::colWidths
int colWidths[4]
Definition: fltkui.hh:513
dw::fltk::ui::FltkRadioButtonResource::Group::connect
void connect(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1203
dw::fltk::ui::FltkEntryResource::~FltkEntryResource
~FltkEntryResource()
Definition: fltkui.cc:835
dw::fltk::ui::FltkComplexButtonResource::reliefXThickness
int reliefXThickness()
Definition: fltkui.cc:782
dw::fltk::ui::FltkRadioButtonResource::Group::unconnect
void unconnect(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1209
dw::fltk::ui::FltkComplexButtonResource::FltkComplexButtonResource
FltkComplexButtonResource(FltkPlatform *platform, dw::core::Widget *widget, bool relief)
Definition: fltkui.cc:695
dw::fltk::ui::FltkSpecificResource::draw
void draw(core::View *view, core::Rectangle *area)
Definition: fltkui.cc:555
CustInput2::value
int value(const char *str)
Definition: fltkui.cc:147
dw::core::Iterator
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
dw::fltk::ui::FltkEntryResource::editable
bool editable
Definition: fltkui.hh:305
CustInput2::input_type
void input_type(int t)
Definition: fltkui.cc:136
CustTextEditor::usual_color
Fl_Color usual_color
Definition: fltkui.cc:225
dw::core::ui::ListResource::SelectionMode
SelectionMode
Definition: ui.hh:436
dw::fltk::ui::FltkResource::isEnabled
bool isEnabled()
Definition: fltkui.cc:532
dw::core::EmptyIterator
This implementation of dw::core::Iterator can be used by widgets with no contents.
Definition: iterator.hh:95
dw::fltk::FltkView::allocateFltkWidget
virtual void allocateFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkplatform.cc:373
dw::fltk::ui::FltkMultiLineTextResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1008
dw::fltk::ui::FltkListResource::mode
ListResource::SelectionMode mode
Definition: fltkui.hh:515
dw::fltk::ui::FltkRadioButtonResource::createNewButton
Fl_Button * createNewButton(core::Allocation *allocation)
Definition: fltkui.cc:1262
CustInput2::CustInput2
CustInput2(int x, int y, int w, int h, const char *l=0)
Definition: fltkui.cc:74
CustInput2::usual_type
int usual_type
Definition: fltkui.cc:71
dw::fltk::ui::FltkRadioButtonResource::Group::iterator
lout::container::typed::Iterator< FltkRadioButtonResource > iterator()
Definition: fltkui.hh:424
dw::fltk::ui::FltkResource::setStyle
void setStyle(core::style::Style *style)
Definition: fltkui.cc:477
dw::fltk::ui::FltkResource::enabled
bool enabled
Definition: fltkui.hh:190
dw::fltk::ui::FltkOptionMenuResource::popGroup
void popGroup()
Definition: fltkui.cc:1450
dw::fltk::ui::FltkEntryResource::initText
const char * initText
Definition: fltkui.hh:301
dw::fltk::ui::FltkRadioButtonResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1246
dw::core::Allocation
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
dw::fltk::ui::FltkSpecificResource
Definition: fltkui.hh:223
dw::fltk::ui::FltkEntryResource::setWidgetStyle
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:867
dw::fltk::FltkPlatform::attachResource
void attachResource(ui::FltkResource *resource)
Definition: fltkplatform.cc:718
dw::fltk::ui::FltkEntryResource::isEditable
bool isEditable()
Definition: fltkui.cc:947
dw::core::CONTROL_MASK
Definition: events.hh:18
CustInput2::~CustInput2
~CustInput2()
Definition: fltkui.cc:58
dw::fltk::ui::FltkRadioButtonResource::~FltkRadioButtonResource
~FltkRadioButtonResource()
Definition: fltkui.cc:1235
dw::fltk::ui::FltkComplexButtonResource::flatView
FltkView * flatView
Definition: fltkui.hh:269
dw::fltk::ui::FltkResource::detachView
virtual void detachView(FltkView *view)
Definition: fltkui.cc:455
dw::fltk::ui::FltkToggleButtonResource
Definition: fltkui.hh:355
dw::core::BUTTON3_MASK
Definition: events.hh:22
CustInput2::handle
int handle(int e)
Definition: fltkui.cc:161
CustTextEditor::show_placeholder
void show_placeholder()
Definition: fltkui.cc:265
dw::fltk::ui::FltkResource::sizeAllocate
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:463
dw::fltk::ui::FltkOptionMenuResource::sizeRequest
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1367
dw::core::SHIFT_MASK
Definition: events.hh:17
dw::fltk::ui::FltkListResource::setItem
void setItem(int index, bool selected)
Definition: fltkui.cc:1616
dw::fltk::ui::FltkSpecificResource::setStyle
void setStyle(core::style::Style *style)
Definition: fltkui.cc:561
lout::misc::max
T max(T a, T b)
Definition: misc.hh:20
dw::fltk::ui::FltkEntryResource::label_w
int label_w
Definition: fltkui.hh:303
dw::fltk::ui::FltkResource::attachView
virtual void attachView(FltkView *view)
Definition: fltkui.cc:438
dw::fltk::ui::FltkRadioButtonResource
Definition: fltkui.hh:391
dw::fltk::ui::FltkOptionMenuResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1334
dw::core::style::Font::ascent
int ascent
Definition: style.hh:673
dw::fltk::ui::FltkOptionMenuResource::itemsUsed
int itemsUsed
Definition: fltkui.hh:487
lout::container::typed::Iterator
Typed version of container::untyped::Iterator.
Definition: container.hh:352
dw::fltk::ui::FltkListResource::popGroup
void popGroup()
Definition: fltkui.cc:1640
dw::fltk::ui::FltkMultiLineTextResource::sizeRequest
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1036
dw::fltk::ui::FltkRadioButtonResource::Group
Definition: fltkui.hh:395
dw::fltk::ui::FltkLabelButtonResource::~FltkLabelButtonResource
~FltkLabelButtonResource()
Definition: fltkui.cc:605
dw::core::META_MASK
Definition: events.hh:19
dw::fltk::ui::FltkResource::~FltkResource
~FltkResource()
Definition: fltkui.cc:425
dw::fltk::ui::FltkToggleButtonResource::setActivated
void setActivated(bool activated)
Definition: fltkui.cc:1141
dw::fltk::ui::FltkLabelButtonResource::label
const char * label
Definition: fltkui.hh:242
dw::fltk::FltkView::usesFltkWidgets
virtual bool usesFltkWidgets()=0
dw::fltk::ui::FltkToggleButtonResource::FltkToggleButtonResource
FltkToggleButtonResource(FltkPlatform *platform, bool activated)
Definition: fltkui.cc:1081
dw::fltk::ui::FltkMultiLineTextResource::FltkMultiLineTextResource
FltkMultiLineTextResource(FltkPlatform *platform, int cols, int rows, const char *placeholder)
Definition: fltkui.cc:978
dw::fltk::ui::FltkResource::platform
FltkPlatform * platform
Definition: fltkui.hh:196
dw::core::Allocation::descent
int descent
Definition: types.hh:169
dw::core::style::Color::SHADING_NORMAL
Definition: style.hh:725
CustInput2::showing_placeholder
bool showing_placeholder
Definition: fltkui.cc:69
dw::fltk::ui::FltkResource::draw
void draw(core::View *view, core::Rectangle *area)
Definition: fltkui.cc:469
dw::core::style::StyleAttrs::boxDiffHeight
int boxDiffHeight()
Definition: style.hh:558
dw::fltk::ui::FltkComplexButtonResource
Definition: fltkui.hh:260
dw::fltk::ui::RELIEF_Y_THICKNESS
Definition: fltkui.cc:394
dw::fltk::ui::FltkListResource::currDepth
int currDepth
Definition: fltkui.hh:512
dw::fltk::ui::EnterButton::EnterButton
EnterButton(int x, int y, int w, int h, const char *label=0)
Definition: fltkui.cc:581
dw::fltk::ui::FltkListResource::sizeRequest
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:1656
dw::fltk::ui::FltkMultiLineTextResource::isEditable
bool isEditable()
Definition: fltkui.cc:1068
CustInput2::placeholder
char * placeholder
Definition: fltkui.cc:68
dw::fltk::ui::FltkEntryResource::FltkEntryResource
FltkEntryResource(FltkPlatform *platform, int size, bool password, const char *label, const char *placeholder)
Definition: fltkui.cc:818
dw::fltk::ui::FltkLabelButtonResource::FltkLabelButtonResource
FltkLabelButtonResource(FltkPlatform *platform, const char *label)
Definition: fltkui.cc:597
dw::fltk::ui::RELIEF_X_THICKNESS
Definition: fltkui.cc:394
dw::fltk::ui::FltkLabelButtonResource::setLabel
void setLabel(const char *label)
Definition: fltkui.cc:684
CustTextEditor::show_normal
void show_normal(const char *str)
Definition: fltkui.cc:255
CustTextEditor::showing_placeholder
bool showing_placeholder
Definition: fltkui.cc:224
dw::fltk::ui::FltkSpecificResource::sizeAllocate
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:549
dw::core::Requisition::ascent
int ascent
Definition: types.hh:175
dw::fltk::ui::FltkCheckButtonResource::createNewButton
Fl_Button * createNewButton(core::Allocation *allocation)
Definition: fltkui.cc:1163
dw::fltk::ui::FltkSelectionResource
Definition: fltkui.hh:457
dw::fltk::ui::FltkComplexButtonResource::reliefYThickness
int reliefYThickness()
Definition: fltkui.cc:787
dw::fltk::ui::FltkMultiLineTextResource::numCols
int numCols
Definition: fltkui.hh:335
dw::fltk::ui::FltkRadioButtonResource::Group::Group
Group(FltkRadioButtonResource *radioButtonResource)
Definition: fltkui.cc:1191
dw::fltk::ui::FltkRadioButtonResource::Group::FltkGroupIterator::hasNext
bool hasNext()
Definition: fltkui.cc:1174
dw::fltk::FltkColor::colors
int colors[SHADING_NUM]
Definition: fltkplatform.hh:56
dw::fltk::ui::FltkEntryResource::setDisplayed
void setDisplayed(bool displayed)
Definition: fltkui.cc:887
dw::core::ui::Resource::queueResize
void queueResize(bool extremesChanged)
Definition: ui.hh:319
dw::core::Layout
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
fltkflatview.hh
dw::fltk::FltkFont
Definition: fltkplatform.hh:15
CustTextEditor::CustTextEditor
CustTextEditor(int x, int y, int w, int h, const char *l=0)
Definition: fltkui.cc:229
CustInput2::textcolor
void textcolor(Fl_Color c)
Definition: fltkui.cc:125
dw::fltk::FltkFont::font
Fl_Font font
Definition: fltkplatform.hh:39
dw::fltk::ui::EnterButton::handle
int handle(int e)
Definition: fltkui.cc:586
dw::core::Requisition::width
int width
Definition: types.hh:174
MSG_ERR
#define MSG_ERR(...)
Definition: dpid_common.h:22
dw::fltk::ui::FltkLabelButtonResource
Definition: fltkui.hh:238
dw::core::style::Style::unref
void unref()
Definition: style.hh:599
dw::fltk::ui::FltkOptionMenuResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1345
CustTextEditor::handle
int handle(int e)
Definition: fltkui.cc:322
dw::fltk::ui::FltkSpecificResource::isEnabled
bool isEnabled()
Definition: fltkui.cc:567
dw::fltk::FltkView::addFltkWidget
virtual void addFltkWidget(Fl_Widget *widget, core::Allocation *allocation)
Definition: fltkplatform.cc:364
I
#define I(x, y, z)
dw::fltk::ui::FltkRadioButtonResource::Group::FltkGroupIterator::it
lout::container::typed::Iterator< FltkRadioButtonResource > it
Definition: fltkui.hh:402
dw::core::Rectangle
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
dw::fltk::ui::FltkListResource::FltkListResource
FltkListResource(FltkPlatform *platform, core::ui::ListResource::SelectionMode selectionMode, int rows)
Definition: fltkui.cc:1496
lout::container::typed::List
Typed version of container::untyped::List.
Definition: container.hh:425
dw::core::View
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
dw::core::Layout::attachView
void attachView(View *view)
Attach a view to the layout.
Definition: layout.cc:379
dw::fltk::ui::setButtonEvent
static void setButtonEvent(dw::core::EventButton *event)
Definition: fltkui.cc:658
dw::fltk::ui::ComplexButton
Definition: fltkcomplexbutton.hh:30
dw::fltk::ui::FltkEntryResource
Definition: fltkui.hh:295
dw::fltk::ui::FltkResource::allocation
core::Allocation allocation
Definition: fltkui.hh:195
dw::fltk::ui::FltkEntryResource::sizeRequest
void sizeRequest(core::Requisition *requisition)
Definition: fltkui.cc:893
CustTextEditor::set_placeholder
void set_placeholder(const char *str)
Definition: fltkui.cc:275
dw::core::style::Font::descent
int descent
Definition: style.hh:673
CustInput2
Definition: fltkui.cc:55
dw::fltk::ui::FltkResource::setDisplayed
void setDisplayed(bool displayed)
Definition: fltkui.cc:512
dw::core::ui::ComplexButtonResource::click_y
int click_y
Definition: ui.hh:390
dw::fltk::ui::FltkLabelButtonResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:610
dw::fltk::ui::CustBrowser::full_height
int full_height() const
Definition: fltkui.cc:1473
dw::fltk::ui::FltkEntryResource::label
char * label
Definition: fltkui.hh:302
dw::fltk::ui::FltkOptionMenuResource::getNumberOfItems
int getNumberOfItems()
Definition: fltkui.cc:1462
lout::misc::init
void init(int argc, char *argv[])
Definition: misc.cc:35
dw::fltk::ui::FltkListResource::pushGroup
void pushGroup(const char *name, bool enabled)
Definition: fltkui.cc:1623
dw::fltk::ui::FltkSpecificResource::setEnabled
void setEnabled(bool enabled)
Definition: fltkui.cc:572
fltkui_dimmed
static Fl_Color fltkui_dimmed(Fl_Color c, Fl_Color bg)
Definition: fltkui.cc:41
dw::core::style::StyleAttrs::font
Font * font
Definition: style.hh:492
dw::fltk::ui::FltkComplexButtonResource::relief
bool relief
Definition: fltkui.hh:264
dw::fltk::ui::FltkComplexButtonResource::createPlatform
dw::core::Platform * createPlatform()
Definition: fltkui.cc:747
dw::core::ui::Resource::emitClicked
void emitClicked(EventButton *event)
Definition: ui.hh:328
dw::fltk::ui::FltkListResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:1512
dw::fltk::ui::FltkOptionMenuResource::setWidgetStyle
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1322
dw::fltk::ui::FltkMultiLineTextResource::~FltkMultiLineTextResource
~FltkMultiLineTextResource()
Definition: fltkui.cc:1002
dw::core::style::StyleAttrs::boxDiffWidth
int boxDiffWidth()
Definition: style.hh:549
dw::core::Allocation::ascent
int ascent
Definition: types.hh:168
dw::fltk::ui::FltkResource::style
core::style::Style * style
Definition: fltkui.hh:198
CustTextEditor::textcolor
void textcolor(Fl_Color c)
Definition: fltkui.cc:289
dw::fltk::ui::FltkComplexButtonResource::topView
FltkView * topView
Definition: fltkui.hh:269
_MSG
#define _MSG(...)
Definition: bookmarks.c:44
dw::fltk::ui::FltkOptionMenuResource::pushGroup
void pushGroup(const char *name, bool enabled)
Definition: fltkui.cc:1436
CustTextEditor::~CustTextEditor
~CustTextEditor()
Definition: fltkui.cc:239
CustInput2::show_placeholder
int show_placeholder()
Definition: fltkui.cc:96
dw::fltk::ui::CustBrowser::avg_height
int avg_height()
Definition: fltkui.cc:1474
dw::core::style::StyleAttrs::color
Color * color
Definition: style.hh:495
dw::fltk::ui::FltkListResource::~FltkListResource
~FltkListResource()
Definition: fltkui.cc:1507
dw::fltk::ui::FltkRadioButtonResource::group
Group * group
Definition: fltkui.hh:439
dw::fltk::FltkColor
Definition: fltkplatform.hh:47
dw::core::ui::EntryResource::UNLIMITED_SIZE
Definition: ui.hh:485
dw::fltk::ui::FltkOptionMenuResource::itemsAllocated
int itemsAllocated
Definition: fltkui.hh:487
dw::fltk::ui::FltkListResource::setWidgetStyle
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1527
dw::core::style::FontAttrs::size
int size
Definition: style.hh:642
dw::core::ui::ListResource::SELECTION_MULTIPLE
An arbitrary number of items may be selected.
Definition: ui.hh:463
dw::fltk::ui::FltkEntryResource::sizeAllocate
void sizeAllocate(core::Allocation *allocation)
Definition: fltkui.cc:913
CustTextEditor
Definition: fltkui.cc:211
dw::fltk::ui::FltkComplexButtonResource::~FltkComplexButtonResource
~FltkComplexButtonResource()
Definition: fltkui.cc:706
dw::core::ButtonState
ButtonState
Platform independent representation.
Definition: events.hh:14
dw::fltk::ui::FltkOptionMenuResource::addItem
void addItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1414
CustTextEditor::value
char * value()
Definition: fltkui.cc:311
dw::fltk::ui::FltkComplexButtonResource::createNewWidget
Fl_Widget * createNewWidget(core::Allocation *allocation)
Definition: fltkui.cc:793
dw::fltk::ui::FltkOptionMenuResource::FltkOptionMenuResource
FltkOptionMenuResource(FltkPlatform *platform)
Definition: fltkui.cc:1298
dw::fltk::ui::FltkComplexButtonResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:710
dw::fltk::ui::FltkMultiLineTextResource::setWidgetStyle
void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:1023
dw::fltk::ui::FltkEntryResource::setMaxLength
void setMaxLength(int maxlen)
Definition: fltkui.cc:957
dw::core::Widget
The base class of all dillo widgets.
Definition: widget.hh:23
dw::core::ui::RadioButtonResource
Definition: ui.hh:507
MSG_WARN
#define MSG_WARN(...)
Definition: msg.h:27
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
CustInput2::show_normal
int show_normal(const char *str)
Definition: fltkui.cc:85
dw::fltk::ui::FltkListResource::addItem
void addItem(const char *str, bool enabled, bool selected)
Definition: fltkui.cc:1607
dw::fltk::ui::EnterButton
Definition: fltkui.cc:579
dw::fltk::ui::FltkListResource::showRows
int showRows
Definition: fltkui.hh:514
CustChoice::CustChoice
CustChoice(int x, int y, int w, int h, const char *l=0)
Definition: fltkui.cc:349
CustTextEditor::text_copy
char * text_copy
Definition: fltkui.cc:226
dw::core::Platform
An interface to encapsulate some platform dependencies.
Definition: platform.hh:16
dw::fltk::ui::CustBrowser
Definition: fltkui.cc:1469
dw::core::ui::ComplexButtonResource::click_x
int click_x
Definition: ui.hh:390
dw::fltk::ui::FltkLabelButtonResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:667
lout::container::typed
This namespace provides thin wrappers, implemented as C++ templates, to gain type-safety.
Definition: container.hh:345
fltkcomplexbutton.hh
dw::fltk::ui::FltkLabelButtonResource::getLabel
const char * getLabel()
Definition: fltkui.cc:678
dw::fltk::ui::FltkRadioButtonResource::Group::FltkGroupIterator::getNext
dw::core::ui::RadioButtonResource * getNext()
Definition: fltkui.cc:1180
dw::core::BUTTON1_MASK
Definition: events.hh:20
dw::fltk::ui::FltkMultiLineTextResource::getText
const char * getText()
Definition: fltkui.cc:1058
dw::fltk::ui::FltkResource::init
void init(FltkPlatform *platform)
Definition: fltkui.cc:418
dw::fltk::ui::FltkEntryResource::setText
void setText(const char *text)
Definition: fltkui.cc:938
CustTextEditor::placeholder
char * placeholder
Definition: fltkui.cc:223
dw::core::style::Style
Definition: style.hh:571
CustChoice
Definition: fltkui.cc:347
dw::fltk::FltkFlatView
Definition: fltkflatview.hh:11
dw::core::ui::ComplexButtonResource::layout
Layout * layout
Definition: ui.hh:389
dw::core::style::StyleAttrs::boxOffsetX
int boxOffsetX()
Definition: style.hh:541
dw::fltk::FltkPlatform
Definition: fltkplatform.hh:92
dw::core::Allocation::width
int width
Definition: types.hh:167
dw::fltk::ui::FltkListResource::widgetCallback
static void widgetCallback(Fl_Widget *widget, void *data)
Definition: fltkui.cc:1544
dw::fltk::ui::FltkListResource::getMaxItemWidth
int getMaxItemWidth()
Definition: fltkui.cc:1651
dw::fltk::ui::CustBrowser::CustBrowser
CustBrowser(int x, int y, int w, int h)
Definition: fltkui.cc:1471
dw::fltk::ui::FltkRadioButtonResource::Group::list
lout::container::typed::List< FltkRadioButtonResource > * list
Definition: fltkui.hh:415
dw::fltk::ui::FltkOptionMenuResource::enlargeMenu
void enlargeMenu()
Definition: fltkui.cc:1385
dw::fltk::ui::FltkEntryResource::placeholder
char * placeholder
Definition: fltkui.hh:304
dw::fltk::ui::FltkResource::setWidgetStyle
virtual void setWidgetStyle(Fl_Widget *widget, core::style::Style *style)
Definition: fltkui.cc:488