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