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