1 /***************************************************************************
2 begin : Fri Jan 22 2010
3 copyright : (C) 2010 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * Please see toplevel file COPYING for license details *
8 ***************************************************************************/
9
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13
14 #include "fox16_gui_dialog_l.hpp"
15 #include "fox16_gui_sortinglist_l.hpp"
16 #include "fox16_htmllabel.hpp"
17 #include "fox16_htmltext.hpp"
18
19 #include "theme.h"
20
21 #include <gwenhywfar/dialog_be.h>
22 #include <gwenhywfar/directory.h>
23 #include <gwenhywfar/debug.h>
24
25 #include <list>
26 #include <string>
27 #include <assert.h>
28
29 #include <fxkeys.h>
30
31
32 #define FOX16_DIALOG_WIDGET_REAL 0
33 #define FOX16_DIALOG_WIDGET_CONTENT 1
34
35 #define FOX16_DIALOG_STRING_TITLE 0
36 #define FOX16_DIALOG_STRING_VALUE 1
37
38
39
40
41
42 FXDEFMAP(FOX16_GuiDialog) FOX16_GuiDialogMap[]= {
43 FXMAPFUNCS(SEL_COMMAND, FOX16_GuiDialog::ID_WIDGET_FIRST, FOX16_GuiDialog::ID_WIDGET_LAST, FOX16_GuiDialog::onSelCommand),
44 FXMAPFUNCS(SEL_CHANGED, FOX16_GuiDialog::ID_WIDGET_FIRST, FOX16_GuiDialog::ID_WIDGET_LAST, FOX16_GuiDialog::onSelChanged),
45 FXMAPFUNCS(SEL_KEYPRESS, FOX16_GuiDialog::ID_WIDGET_FIRST, FOX16_GuiDialog::ID_WIDGET_LAST, FOX16_GuiDialog::onSelKeyPress),
46 FXMAPFUNCS(SEL_KEYRELEASE, FOX16_GuiDialog::ID_WIDGET_FIRST, FOX16_GuiDialog::ID_WIDGET_LAST, FOX16_GuiDialog::onSelKeyRelease)
47 };
48
49
FXIMPLEMENT(FOX16_GuiDialog,FXObject,FOX16_GuiDialogMap,ARRAYNUMBER (FOX16_GuiDialogMap))50 FXIMPLEMENT(FOX16_GuiDialog, FXObject, FOX16_GuiDialogMap, ARRAYNUMBER(FOX16_GuiDialogMap))
51
52
53
54 FOX16_GuiDialog::FOX16_GuiDialog()
55 :FXObject()
56 ,CppDialog()
57 ,_gui(NULL)
58 ,_widgetCount(0)
59 ,_mainWidget(NULL)
60 ,m_iconSource(NULL)
61 ,m_sizeChanged(FALSE) {
62 }
63
64
65
FOX16_GuiDialog(FOX16_Gui * gui,GWEN_DIALOG * dlg)66 FOX16_GuiDialog::FOX16_GuiDialog(FOX16_Gui *gui, GWEN_DIALOG *dlg)
67 :FXObject()
68 ,CppDialog(dlg)
69 ,_gui(gui)
70 ,_widgetCount(0)
71 ,_mainWidget(NULL)
72 ,m_iconSource(NULL)
73 ,m_sizeChanged(FALSE) {
74 }
75
76
77
~FOX16_GuiDialog()78 FOX16_GuiDialog::~FOX16_GuiDialog() {
79 if (_mainWidget)
80 delete _mainWidget;
81 if (!m_iconList.empty()) {
82 std::list<FXIcon*>::iterator it;
83
84 for (it=m_iconList.begin(); it!=m_iconList.end(); it++)
85 delete *it;
86 m_iconList.clear();
87 }
88 if (m_iconSource)
89 delete m_iconSource;
90
91 if (!m_radioGroups.empty()) {
92 std::list<RadioButtonGroup*>::iterator it;
93
94 for (it=m_radioGroups.begin(); it!=m_radioGroups.end(); it++)
95 delete *it;
96 }
97 }
98
99
100
getDialog(GWEN_DIALOG * dlg)101 FOX16_GuiDialog *FOX16_GuiDialog::getDialog(GWEN_DIALOG *dlg) {
102 CppDialog *cppDlg;
103
104 cppDlg=CppDialog::getDialog(dlg);
105 if (cppDlg)
106 return dynamic_cast<FOX16_GuiDialog*>(cppDlg);
107 return NULL;
108 }
109
110
111
getIcon(const char * fileName)112 FXIcon *FOX16_GuiDialog::getIcon(const char *fileName) {
113 GWEN_STRINGLIST *sl;
114
115 sl=GWEN_Dialog_GetMediaPaths(_dialog);
116 if (sl) {
117 GWEN_BUFFER *tbuf;
118 int rv;
119 FXIcon *ic;
120
121 tbuf=GWEN_Buffer_new(0, 256, 0, 1);
122 rv=GWEN_Directory_FindFileInPaths(sl, fileName, tbuf);
123 if (rv<0) {
124 DBG_ERROR(GWEN_LOGDOMAIN, "here (%d)", rv);
125 GWEN_Buffer_free(tbuf);
126 return NULL;
127 }
128
129 if (m_iconSource==NULL)
130 m_iconSource=new FXIconSource(FXApp::instance());
131
132 DBG_DEBUG(GWEN_LOGDOMAIN, "Loading [%s]", GWEN_Buffer_GetStart(tbuf));
133 ic=m_iconSource->loadIconFile(GWEN_Buffer_GetStart(tbuf));
134 if (ic==NULL) {
135 DBG_ERROR(GWEN_LOGDOMAIN, "Could not load icon [%s]", GWEN_Buffer_GetStart(tbuf));
136 GWEN_Buffer_free(tbuf);
137 return NULL;
138 }
139 m_iconList.push_back(ic);
140 GWEN_Buffer_free(tbuf);
141 return ic;
142 }
143 else {
144 DBG_ERROR(GWEN_LOGDOMAIN, "No media paths in dialog");
145 return NULL;
146 }
147 }
148
149
150
execute()151 int FOX16_GuiDialog::execute() {
152 FXDialogBox *dialogBox;
153 int rv;
154
155 dialogBox=_mainWidget;
156
157 /* execute dialog */
158 dialogBox->show(PLACEMENT_OWNER);
159 rv=dialogBox->execute();
160 GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");
161
162 if (rv==0) {
163 /* aborted */
164 return 0;
165 }
166 else
167 /* accepted */
168 return 1;
169 }
170
171
setIntProperty(GWEN_WIDGET * w,GWEN_DIALOG_PROPERTY prop,int index,int value,int doSignal)172 int FOX16_GuiDialog::setIntProperty(GWEN_WIDGET *w,
173 GWEN_DIALOG_PROPERTY prop,
174 int index,
175 int value,
176 int doSignal) {
177 DBG_DEBUG(GWEN_LOGDOMAIN, "SetIntProperty([%s], %d)", GWEN_Widget_GetName(w), value);
178
179 switch(GWEN_Widget_GetType(w)) {
180 case GWEN_Widget_TypeUnknown:
181 return GWEN_ERROR_GENERIC;
182
183 case GWEN_Widget_TypeNone:
184 return GWEN_ERROR_GENERIC;
185
186 case GWEN_Widget_TypeComboBox: {
187 THEMECOMBOBOX *f;
188
189 f=(THEMECOMBOBOX*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
190 assert(f);
191
192 switch(prop) {
193 case GWEN_DialogProperty_Value:
194 if (value<f->getNumItems()) {
195 f->setCurrentItem(value, doSignal?TRUE:FALSE);
196 return 0;
197 }
198 else {
199 DBG_ERROR(GWEN_LOGDOMAIN, "Index %d out of range in widget [%s]", value, GWEN_Widget_GetName(w));
200 return GWEN_ERROR_INVALID;
201 }
202
203 case GWEN_DialogProperty_ClearValues:
204 f->clearItems();
205 return 0;
206
207 default:
208 break;
209 }
210 break;
211 }
212
213 case GWEN_Widget_TypeRadioButton: {
214 FXRadioButton *f;
215
216 f=(FXRadioButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
217 assert(f);
218
219 switch(prop) {
220 case GWEN_DialogProperty_Value:
221 f->setCheck((value==0)?FALSE:TRUE, doSignal?TRUE:FALSE);
222 return 0;
223
224 default:
225 break;
226 }
227 break;
228 }
229
230 case GWEN_Widget_TypeProgressBar: {
231 FXProgressBar *f;
232
233 f=(FXProgressBar*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
234 assert(f);
235
236 switch(prop) {
237 case GWEN_DialogProperty_Value:
238 f->setProgress(value);
239 return 0;
240
241 case GWEN_DialogProperty_MinValue:
242 if (value!=0) {
243 DBG_ERROR(GWEN_LOGDOMAIN, "MinValue should be 0!");
244 return GWEN_ERROR_INVALID;
245 }
246 return 0;
247
248 case GWEN_DialogProperty_MaxValue:
249 f->setTotal(value);
250 return 0;
251
252 default:
253 break;
254 }
255 break;
256 }
257
258 case GWEN_Widget_TypeSpinBox: {
259 FXSpinner *f;
260
261 f=(FXSpinner*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
262 assert(f);
263
264 switch(prop) {
265 case GWEN_DialogProperty_Value:
266 f->setValue(value);
267 return 0;
268
269 case GWEN_DialogProperty_MinValue: {
270 FXint lo, hi;
271
272 f->getRange(lo, hi);
273 lo=value;
274 f->setRange(lo, hi);
275 return 0;
276 }
277
278 case GWEN_DialogProperty_MaxValue: {
279 FXint lo, hi;
280
281 f->getRange(lo, hi);
282 hi=value;
283 if (hi<lo)
284 hi=lo;
285 f->setRange(lo, hi);
286 return 0;
287 }
288
289 default:
290 break;
291 }
292 break;
293 }
294
295 case GWEN_Widget_TypeListBox: {
296 FOX16_GuiSortingList *f;
297 FXFoldingItem *fi;
298 int i=0;
299
300 f=(FOX16_GuiSortingList*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
301 assert(f);
302
303 switch(prop) {
304 case GWEN_DialogProperty_Value:
305 fi=f->getFirstItem();
306 while(fi && i<value) {
307 fi=fi->getNext();
308 i++;
309 }
310 if (fi && i==value)
311 f->setCurrentItem(fi, doSignal?TRUE:FALSE);
312 else {
313 DBG_ERROR(GWEN_LOGDOMAIN, "Value %d out of range", value);
314 return GWEN_ERROR_INVALID;
315 }
316 return 0;
317
318 case GWEN_DialogProperty_ColumnWidth:
319 f->setHeaderSize(index, value);
320 return 0;
321
322 case GWEN_DialogProperty_SelectionMode:
323 switch(value) {
324 case GWEN_Dialog_SelectionMode_None:
325 /* simply fall-through */
326 case GWEN_Dialog_SelectionMode_Single:
327 f->setListStyle(FOLDINGLIST_BROWSESELECT);
328 return 0;
329 case GWEN_Dialog_SelectionMode_Multi:
330 f->setListStyle(FOLDINGLIST_EXTENDEDSELECT);
331 return 0;
332 ;
333 }
334 DBG_ERROR(GWEN_LOGDOMAIN, "Unknown SelectionMode %d", value);
335 return GWEN_ERROR_INVALID;
336
337 case GWEN_DialogProperty_SelectionState: {
338 FXFoldingItem *ti;
339
340 ti=f->getItem(index);
341 if (ti==NULL) {
342 DBG_ERROR(GWEN_LOGDOMAIN, "Index %d out of range", index);
343 return GWEN_ERROR_INVALID;
344 }
345 ti->setSelected((value==0)?FALSE:TRUE);
346 return 0;
347 }
348
349 case GWEN_DialogProperty_ClearValues:
350 f->clearItems();
351 return 0;
352
353 case GWEN_DialogProperty_SortDirection: {
354 int i;
355
356 for (i=0; i<f->getNumHeaders(); i++) {
357 if (i==index) {
358 switch(value) {
359 case GWEN_DialogSortDirection_None:
360 f->setHeaderArrowDir(i, MAYBE);
361 break;
362 case GWEN_DialogSortDirection_Up:
363 f->setHeaderArrowDir(i, TRUE);
364 break;
365 case GWEN_DialogSortDirection_Down:
366 f->setHeaderArrowDir(i, FALSE);
367 break;
368 }
369 }
370 else
371 f->setHeaderArrowDir(i, MAYBE);
372 }
373
374 switch(value) {
375 case GWEN_DialogSortDirection_None:
376 break;
377 case GWEN_DialogSortDirection_Up:
378 f->sortByColumn(i, true);
379 break;
380 case GWEN_DialogSortDirection_Down:
381 f->sortByColumn(i, false);
382 break;
383 }
384 }
385 return 0;
386
387 case GWEN_DialogProperty_Sort: {
388 int i;
389
390 for (i=0; i<f->getNumHeaders(); i++) {
391 FXbool b;
392
393 b=f->getHeaderArrowDir(i);
394 if (b!=MAYBE) {
395 if (b==TRUE)
396 f->sortByColumn(i, true);
397 else
398 f->sortByColumn(i, false);
399 break;
400 }
401 }
402 }
403 return 0;
404
405
406 default:
407 break;
408 }
409 break;
410 }
411
412 case GWEN_Widget_TypeCheckBox: {
413 FXCheckButton *f;
414
415 f=(FXCheckButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
416 assert(f);
417
418 switch(prop) {
419 case GWEN_DialogProperty_Value:
420 f->setCheck((value==0)?FALSE:TRUE, doSignal?TRUE:FALSE);
421 return 0;
422
423 default:
424 break;
425 }
426 break;
427 }
428
429 case GWEN_Widget_TypeTabBook: {
430 FXTabBook *f;
431
432 f=(FXTabBook*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
433 assert(f);
434
435 switch(prop) {
436 case GWEN_DialogProperty_Value:
437 f->setCurrent(value, doSignal?TRUE:FALSE);
438 return 0;
439
440 default:
441 break;
442 }
443 break;
444 }
445
446 case GWEN_Widget_TypeWidgetStack: {
447 FXSwitcher *f;
448
449 f=(FXSwitcher*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
450 assert(f);
451
452 switch(prop) {
453 case GWEN_DialogProperty_Value:
454 f->setCurrent(value, doSignal?TRUE:FALSE);
455 return 0;
456
457 default:
458 break;
459 }
460 break;
461 }
462
463 case GWEN_Widget_TypeLabel:
464 case GWEN_Widget_TypePushButton:
465 case GWEN_Widget_TypeLineEdit:
466 case GWEN_Widget_TypeTextEdit:
467 case GWEN_Widget_TypeGroupBox:
468 case GWEN_Widget_TypeHSpacer:
469 case GWEN_Widget_TypeVSpacer:
470 case GWEN_Widget_TypeHLayout:
471 case GWEN_Widget_TypeVLayout:
472 case GWEN_Widget_TypeGridLayout:
473 case GWEN_Widget_TypeDialog:
474 case GWEN_Widget_TypeTabPage:
475 case GWEN_Widget_TypeScrollArea:
476 case GWEN_Widget_TypeHLine:
477 case GWEN_Widget_TypeVLine:
478 case GWEN_Widget_TypeTextBrowser:
479 ;
480 }
481
482 {
483 FXWindow *f;
484
485 f=(FXWindow*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
486 assert(f);
487
488 switch(prop) {
489 case GWEN_DialogProperty_Width:
490 f->recalc();
491 f->resize(value, f->getHeight());
492 m_sizeChanged=TRUE;
493 return 0;
494 case GWEN_DialogProperty_Height:
495 f->recalc();
496 f->resize(f->getWidth(), value);
497 m_sizeChanged=TRUE;
498 return 0;
499 case GWEN_DialogProperty_Enabled:
500 if (value==0)
501 f->disable();
502 else
503 f->enable();
504 return 0;
505
506 case GWEN_DialogProperty_Focus:
507 f->setFocus();
508 return 0;
509
510 case GWEN_DialogProperty_Visibility:
511 if (value==0) {
512 f->hide();
513 f->recalc();
514 }
515 else {
516 f->show();
517 f->recalc();
518 }
519 return 0;
520
521 case GWEN_DialogProperty_Title:
522 case GWEN_DialogProperty_Value:
523 case GWEN_DialogProperty_MinValue:
524 case GWEN_DialogProperty_MaxValue:
525 case GWEN_DialogProperty_AddValue:
526 case GWEN_DialogProperty_ClearValues:
527 case GWEN_DialogProperty_ValueCount:
528 case GWEN_DialogProperty_ColumnWidth:
529 case GWEN_DialogProperty_SelectionMode:
530 case GWEN_DialogProperty_SelectionState:
531 case GWEN_DialogProperty_SortDirection:
532 case GWEN_DialogProperty_Sort:
533 case GWEN_DialogProperty_ToolTip:
534 case GWEN_DialogProperty_None:
535 case GWEN_DialogProperty_Unknown:
536 ;
537 }
538 }
539
540 DBG_WARN(0, "Function is not appropriate for this type of widget (%s)",
541 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
542 return GWEN_ERROR_INVALID;
543 }
544
545
546
getIntProperty(GWEN_WIDGET * w,GWEN_DIALOG_PROPERTY prop,int index,int defaultValue)547 int FOX16_GuiDialog::getIntProperty(GWEN_WIDGET *w,
548 GWEN_DIALOG_PROPERTY prop,
549 int index,
550 int defaultValue) {
551 switch(GWEN_Widget_GetType(w)) {
552 case GWEN_Widget_TypeUnknown:
553 case GWEN_Widget_TypeNone:
554 return defaultValue;
555
556 case GWEN_Widget_TypeComboBox: {
557 THEMECOMBOBOX *f;
558
559 f=(THEMECOMBOBOX*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
560 assert(f);
561
562 switch(prop) {
563 case GWEN_DialogProperty_Value:
564 return f->getCurrentItem();
565
566 case GWEN_DialogProperty_ValueCount:
567 return f->getNumItems();
568
569 default:
570 break;
571 }
572 break;
573 }
574
575 case GWEN_Widget_TypeRadioButton: {
576 FXRadioButton *f;
577
578 f=(FXRadioButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
579 assert(f);
580
581 switch(prop) {
582 case GWEN_DialogProperty_Value:
583 return (f->getCheck()==TRUE)?1:0;
584
585 default:
586 break;
587 }
588 break;
589 }
590
591 case GWEN_Widget_TypeProgressBar: {
592 FXProgressBar *f;
593
594 f=(FXProgressBar*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
595 assert(f);
596
597 switch(prop) {
598 case GWEN_DialogProperty_Value:
599 return f->getProgress();
600
601 case GWEN_DialogProperty_MinValue:
602 return 0;
603
604 case GWEN_DialogProperty_MaxValue:
605 return f->getTotal();
606
607 default:
608 break;
609 }
610
611 break;
612 }
613
614 case GWEN_Widget_TypeSpinBox: {
615 FXSpinner *f;
616
617 f=(FXSpinner*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
618 assert(f);
619
620 switch(prop) {
621 case GWEN_DialogProperty_Value:
622 return f->getValue();
623
624 case GWEN_DialogProperty_MinValue: {
625 FXint lo, hi;
626
627 f->getRange(lo, hi);
628 return lo;
629 }
630
631 case GWEN_DialogProperty_MaxValue: {
632 FXint lo, hi;
633
634 f->getRange(lo, hi);
635 return hi;
636 }
637
638 default:
639 break;
640 }
641
642 break;
643 }
644
645 case GWEN_Widget_TypeListBox: {
646 FOX16_GuiSortingList *f;
647 FXFoldingItem *fi;
648 int i=0;
649
650 f=(FOX16_GuiSortingList*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
651 assert(f);
652
653 switch(prop) {
654 case GWEN_DialogProperty_Value:
655 fi=f->getCurrentItem();
656 if (fi==NULL)
657 return defaultValue;
658 else {
659 FXFoldingItem *ti;
660
661 ti=fi;
662 while( (ti=ti->getPrev()) )
663 i++;
664
665 return i;
666 }
667
668 case GWEN_DialogProperty_ValueCount:
669 return f->getNumItems();
670
671 case GWEN_DialogProperty_ColumnWidth:
672 return f->getHeaderSize(index);
673
674 case GWEN_DialogProperty_SelectionMode: {
675 switch(f->getListStyle()) {
676 case FOLDINGLIST_BROWSESELECT:
677 return GWEN_Dialog_SelectionMode_Single;
678 case FOLDINGLIST_EXTENDEDSELECT:
679 return GWEN_Dialog_SelectionMode_Multi;
680 default:
681 return GWEN_Dialog_SelectionMode_None;
682 }
683 break;
684 }
685
686 case GWEN_DialogProperty_SelectionState: {
687 FXFoldingItem *ti;
688 int i=index;
689
690 ti=f->getFirstItem();
691 while(ti && i) {
692 ti=ti->getNext();
693 i--;
694 }
695
696 if (ti)
697 return (ti->isSelected()==TRUE)?1:0;
698 return defaultValue;
699 }
700
701 case GWEN_DialogProperty_SortDirection: {
702 int i;
703
704 for (i=0; i<f->getNumHeaders(); i++) {
705 if (i==index) {
706 FXbool b;
707
708 b=f->getHeaderArrowDir(i);
709 if (b==MAYBE)
710 return GWEN_DialogSortDirection_None;
711 else if (b==TRUE)
712 return GWEN_DialogSortDirection_Up;
713 else
714 return GWEN_DialogSortDirection_Down;
715 }
716 }
717 DBG_ERROR(GWEN_LOGDOMAIN, "Column %d out of range", index);
718 }
719 return defaultValue;
720
721 default:
722 break;
723 }
724
725 break;
726 }
727
728 case GWEN_Widget_TypeCheckBox: {
729 FXCheckButton *f;
730
731 f=(FXCheckButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
732 assert(f);
733
734 switch(prop) {
735 case GWEN_DialogProperty_Value:
736 return (f->getCheck()==TRUE)?1:0;
737
738 default:
739 break;
740 }
741
742 break;
743 }
744
745 case GWEN_Widget_TypeTabBook: {
746 FXTabBook *f;
747
748 f=(FXTabBook*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
749 assert(f);
750
751 switch(prop) {
752 case GWEN_DialogProperty_Value:
753 return f->getCurrent();
754
755 default:
756 break;
757 }
758
759 break;
760 }
761
762 case GWEN_Widget_TypeWidgetStack: {
763 FXSwitcher *f;
764
765 f=(FXSwitcher*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
766 assert(f);
767
768 switch(prop) {
769 case GWEN_DialogProperty_Value:
770 return f->getCurrent();
771
772 default:
773 break;
774 }
775
776 break;
777 }
778
779 case GWEN_Widget_TypeLabel:
780 case GWEN_Widget_TypePushButton:
781 case GWEN_Widget_TypeLineEdit:
782 case GWEN_Widget_TypeTextEdit:
783 case GWEN_Widget_TypeGroupBox:
784 case GWEN_Widget_TypeHSpacer:
785 case GWEN_Widget_TypeVSpacer:
786 case GWEN_Widget_TypeHLayout:
787 case GWEN_Widget_TypeVLayout:
788 case GWEN_Widget_TypeGridLayout:
789 case GWEN_Widget_TypeDialog:
790 case GWEN_Widget_TypeTabPage:
791 case GWEN_Widget_TypeScrollArea:
792 case GWEN_Widget_TypeHLine:
793 case GWEN_Widget_TypeVLine:
794 case GWEN_Widget_TypeTextBrowser:
795 break;
796 }
797
798 /* generic properties every widget has */
799 {
800 FXWindow *f;
801
802 f=(FXWindow*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
803 assert(f);
804
805 switch(prop) {
806 case GWEN_DialogProperty_Width:
807 return f->getWidth();
808
809 case GWEN_DialogProperty_Height:
810 return f->getHeight();
811
812 case GWEN_DialogProperty_Enabled:
813 return (f->isEnabled()==TRUE)?1:0;
814
815 case GWEN_DialogProperty_Focus:
816 return (f->hasFocus())?1:0;
817
818 case GWEN_DialogProperty_Title:
819 case GWEN_DialogProperty_Value:
820 case GWEN_DialogProperty_MinValue:
821 case GWEN_DialogProperty_MaxValue:
822 case GWEN_DialogProperty_AddValue:
823 case GWEN_DialogProperty_ClearValues:
824 case GWEN_DialogProperty_ValueCount:
825 case GWEN_DialogProperty_ColumnWidth:
826 case GWEN_DialogProperty_SelectionMode:
827 case GWEN_DialogProperty_SelectionState:
828 case GWEN_DialogProperty_SortDirection:
829 case GWEN_DialogProperty_Sort:
830 case GWEN_DialogProperty_Visibility:
831 case GWEN_DialogProperty_ToolTip:
832 case GWEN_DialogProperty_None:
833 case GWEN_DialogProperty_Unknown:
834 ;
835 }
836 }
837
838
839 DBG_WARN(0, "Function is not appropriate for this type of widget (%s)",
840 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
841 return defaultValue;
842 }
843
844
845
setCharProperty(GWEN_WIDGET * w,GWEN_DIALOG_PROPERTY prop,int index,const char * value,int doSignal)846 int FOX16_GuiDialog::setCharProperty(GWEN_WIDGET *w,
847 GWEN_DIALOG_PROPERTY prop,
848 int index,
849 const char *value,
850 int doSignal) {
851
852 FXString strValue;
853 FXString htmlValue;
854
855 if (value && *value) {
856 strValue=FOX16_Gui::getRawText(value);
857 htmlValue=FOX16_Gui::getHtmlText(value);
858 }
859
860 switch(GWEN_Widget_GetType(w)) {
861 case GWEN_Widget_TypeUnknown:
862 return GWEN_ERROR_GENERIC;
863 case GWEN_Widget_TypeNone:
864 return GWEN_ERROR_GENERIC;
865
866 case GWEN_Widget_TypeLabel: {
867 FOX16_HtmlLabel *f;
868
869 f=(FOX16_HtmlLabel*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
870 assert(f);
871
872 switch(prop) {
873 case GWEN_DialogProperty_Title:
874 f->setText(htmlValue);
875 return 0;
876
877 default:
878 break;
879 }
880 break;
881 }
882
883 case GWEN_Widget_TypeTextBrowser: {
884 FOX16_HtmlText *f;
885
886 f=(FOX16_HtmlText*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
887 assert(f);
888
889 switch(prop) {
890 case GWEN_DialogProperty_Value:
891 f->setText(htmlValue);
892 f->makePositionVisible(strValue.length());
893 return 0;
894
895 case GWEN_DialogProperty_AddValue:
896 f->setText(f->getText()+htmlValue);
897 return 0;
898
899 case GWEN_DialogProperty_ClearValues:
900 f->setText("");
901 return 0;
902
903 default:
904 break;
905 }
906 break;
907
908 }
909
910 case GWEN_Widget_TypePushButton: {
911 THEMEBUTTON *f;
912
913 f=(THEMEBUTTON*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
914 assert(f);
915
916 switch(prop) {
917 case GWEN_DialogProperty_Title:
918 f->setText(value);
919 return 0;
920
921 case GWEN_DialogProperty_ToolTip:
922 f->setTipText(htmlValue);
923 return 0;
924
925 default:
926 break;
927 }
928 break;
929 }
930
931 case GWEN_Widget_TypeLineEdit: {
932 FXTextField *f;
933
934 f=(FXTextField*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
935 assert(f);
936
937 switch(prop) {
938 case GWEN_DialogProperty_Value:
939 f->setText(value, doSignal?TRUE:FALSE);
940 return 0;
941
942 case GWEN_DialogProperty_ToolTip:
943 f->setTipText(htmlValue);
944 return 0;
945
946 default:
947 break;
948 }
949 break;
950 }
951
952 case GWEN_Widget_TypeTextEdit: {
953 FXText *f;
954
955 f=(FXText*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
956 assert(f);
957
958 switch(prop) {
959 case GWEN_DialogProperty_Value:
960 f->setText(strValue);
961 return 0;
962
963 case GWEN_DialogProperty_ToolTip:
964 f->setTipText(htmlValue);
965 return 0;
966
967 default:
968 break;
969 }
970 break;
971 }
972
973 case GWEN_Widget_TypeComboBox: {
974 THEMECOMBOBOX *f;
975
976 f=(THEMECOMBOBOX*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
977 assert(f);
978
979 switch(prop) {
980 case GWEN_DialogProperty_Value:
981 // undefined
982 break;
983
984 case GWEN_DialogProperty_ToolTip:
985 f->setTipText(htmlValue);
986 return 0;
987
988 case GWEN_DialogProperty_AddValue: {
989 int i;
990
991 f->appendItem(strValue);
992 i=f->getNumItems();
993 if (i>10)
994 i=10;
995 f->setNumVisible(i);
996 return 0;
997 }
998
999 case GWEN_DialogProperty_ClearValues:
1000 f->clearItems();
1001 return 0;
1002
1003 default:
1004 break;
1005 }
1006 break;
1007 }
1008
1009 case GWEN_Widget_TypeGroupBox: {
1010 FXGroupBox *f;
1011
1012 f=(FXGroupBox*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1013 assert(f);
1014
1015 switch(prop) {
1016 case GWEN_DialogProperty_Title:
1017 f->setText(strValue);
1018 return 0;
1019 default:
1020 break;
1021 }
1022 break;
1023 }
1024
1025 case GWEN_Widget_TypeRadioButton: {
1026 FXRadioButton *f;
1027
1028 f=(FXRadioButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1029 assert(f);
1030
1031 switch(prop) {
1032 case GWEN_DialogProperty_Title:
1033 f->setText(strValue);
1034 return 0;
1035
1036 case GWEN_DialogProperty_ToolTip:
1037 f->setTipText(htmlValue);
1038 return 0;
1039
1040 default:
1041 break;
1042 }
1043 break;
1044 }
1045
1046 case GWEN_Widget_TypeCheckBox: {
1047 FXCheckButton *f;
1048
1049 f=(FXCheckButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1050 assert(f);
1051
1052 switch(prop) {
1053 case GWEN_DialogProperty_Title:
1054 f->setText(strValue);
1055 return 0;
1056
1057 case GWEN_DialogProperty_ToolTip:
1058 f->setTipText(htmlValue);
1059 return 0;
1060
1061 default:
1062 break;
1063 }
1064 break;
1065 }
1066
1067 case GWEN_Widget_TypeTabPage: {
1068 FXWindow *f1;
1069 THEMETABITEM *f2;
1070
1071 f1=(FXWindow*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1072 assert(f1);
1073 f2=(THEMETABITEM*) (f1->getPrev());
1074 assert(f2);
1075
1076 switch(prop) {
1077 case GWEN_DialogProperty_Title:
1078 f2->setText(strValue);
1079 return 0;
1080
1081 case GWEN_DialogProperty_ToolTip:
1082 f2->setTipText(htmlValue);
1083 return 0;
1084
1085 default:
1086 break;
1087 }
1088 break;
1089 }
1090
1091 case GWEN_Widget_TypeDialog: {
1092 FXDialogBox *f;
1093
1094 f=(FXDialogBox*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1095 assert(f);
1096
1097 switch(prop) {
1098 case GWEN_DialogProperty_Title:
1099 f->setTitle(strValue);
1100 return 0;
1101 default:
1102 break;
1103 }
1104 break;
1105 }
1106
1107 case GWEN_Widget_TypeListBox: {
1108 FXFoldingList *f;
1109 FXString str;
1110 FXString t;
1111 FXint n=0;
1112
1113 f=(FXFoldingList*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1114 assert(f);
1115
1116 switch(prop) {
1117 case GWEN_DialogProperty_Title:
1118 f->getHeader()->clearItems();
1119 str=strValue;
1120 while(!(t=str.section('\t',n)).empty()) {
1121 f->appendHeader(t, NULL, 20);
1122 n++;
1123 }
1124 return 0;
1125
1126 case GWEN_DialogProperty_AddValue:
1127 f->appendItem(NULL, strValue);
1128 return 0;
1129
1130 case GWEN_DialogProperty_ClearValues:
1131 f->clearItems();
1132 return 0;
1133
1134 default:
1135 break;
1136 }
1137 break;
1138 }
1139
1140 case GWEN_Widget_TypeSpinBox: {
1141 FXSpinner *f;
1142
1143 f=(FXSpinner*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1144 assert(f);
1145
1146 switch(prop) {
1147 case GWEN_DialogProperty_ToolTip:
1148 f->setTipText(htmlValue);
1149 return 0;
1150
1151 default:
1152 break;
1153 }
1154 break;
1155 }
1156
1157 case GWEN_Widget_TypeProgressBar:
1158 case GWEN_Widget_TypeHSpacer:
1159 case GWEN_Widget_TypeVSpacer:
1160 case GWEN_Widget_TypeHLayout:
1161 case GWEN_Widget_TypeVLayout:
1162 case GWEN_Widget_TypeGridLayout:
1163 case GWEN_Widget_TypeTabBook:
1164 case GWEN_Widget_TypeScrollArea:
1165 case GWEN_Widget_TypeWidgetStack:
1166 case GWEN_Widget_TypeHLine:
1167 case GWEN_Widget_TypeVLine:
1168 ;
1169 }
1170
1171 /* this block is just to make sure we get warnings when new
1172 * properties are available but not handled here
1173 */
1174 switch(prop) {
1175 case GWEN_DialogProperty_Title:
1176 case GWEN_DialogProperty_Value:
1177 case GWEN_DialogProperty_MinValue:
1178 case GWEN_DialogProperty_MaxValue:
1179 case GWEN_DialogProperty_Enabled:
1180 case GWEN_DialogProperty_AddValue:
1181 case GWEN_DialogProperty_ClearValues:
1182 case GWEN_DialogProperty_ValueCount:
1183 case GWEN_DialogProperty_ColumnWidth:
1184 case GWEN_DialogProperty_Width:
1185 case GWEN_DialogProperty_Height:
1186 case GWEN_DialogProperty_SelectionMode:
1187 case GWEN_DialogProperty_SelectionState:
1188 case GWEN_DialogProperty_Focus:
1189 case GWEN_DialogProperty_SortDirection:
1190 case GWEN_DialogProperty_Sort:
1191 case GWEN_DialogProperty_Visibility:
1192 case GWEN_DialogProperty_ToolTip:
1193 case GWEN_DialogProperty_None:
1194 case GWEN_DialogProperty_Unknown:
1195 break;
1196 }
1197
1198 DBG_WARN(0, "Function is not appropriate for this type of widget (%s)",
1199 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
1200 return GWEN_ERROR_INVALID;
1201 }
1202
1203
1204
getCharProperty(GWEN_WIDGET * w,GWEN_DIALOG_PROPERTY prop,int index,const char * defaultValue)1205 const char *FOX16_GuiDialog::getCharProperty(GWEN_WIDGET *w,
1206 GWEN_DIALOG_PROPERTY prop,
1207 int index,
1208 const char *defaultValue) {
1209 FXString str;
1210
1211 switch(GWEN_Widget_GetType(w)) {
1212 case GWEN_Widget_TypeUnknown:
1213 return defaultValue;
1214 case GWEN_Widget_TypeNone:
1215 return defaultValue;
1216
1217 case GWEN_Widget_TypeLabel: {
1218 FOX16_HtmlLabel *f;
1219
1220 f=(FOX16_HtmlLabel*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1221 assert(f);
1222
1223 switch(prop) {
1224 case GWEN_DialogProperty_Title:
1225 str=f->getText();
1226 if (str.empty())
1227 return defaultValue;
1228 else {
1229 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1230 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1231 }
1232
1233 default:
1234 break;
1235 }
1236 break;
1237 }
1238
1239 case GWEN_Widget_TypePushButton: {
1240 THEMEBUTTON *f;
1241
1242 f=(THEMEBUTTON*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1243 assert(f);
1244
1245 switch(prop) {
1246 case GWEN_DialogProperty_Title:
1247 str=f->getText();
1248 if (str.empty())
1249 return defaultValue;
1250 else {
1251 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1252 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1253 }
1254
1255 default:
1256 break;
1257 }
1258 break;
1259 }
1260
1261 case GWEN_Widget_TypeLineEdit: {
1262 FXTextField *f;
1263
1264 f=(FXTextField*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1265 assert(f);
1266
1267 switch(prop) {
1268 case GWEN_DialogProperty_Value:
1269 str=f->getText();
1270 if (str.empty())
1271 return defaultValue;
1272 else {
1273 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_VALUE, str.text());
1274 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_VALUE);
1275 }
1276
1277 default:
1278 break;
1279 }
1280 break;
1281 }
1282
1283 case GWEN_Widget_TypeTextEdit: {
1284 FXText *f;
1285
1286 f=(FXText*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1287 assert(f);
1288
1289 switch(prop) {
1290 case GWEN_DialogProperty_Value:
1291 str=f->getText();
1292 if (str.empty())
1293 return defaultValue;
1294 else {
1295 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_VALUE, str.text());
1296 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_VALUE);
1297 }
1298
1299 default:
1300 break;
1301 }
1302 break;
1303 }
1304
1305 case GWEN_Widget_TypeTextBrowser: {
1306 FOX16_HtmlText *f;
1307
1308 f=(FOX16_HtmlText*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1309 assert(f);
1310
1311 switch(prop) {
1312 case GWEN_DialogProperty_Value:
1313 str=f->getText();
1314 if (str.empty())
1315 return defaultValue;
1316 else {
1317 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_VALUE, str.text());
1318 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_VALUE);
1319 }
1320
1321 default:
1322 break;
1323 }
1324 break;
1325 }
1326
1327 case GWEN_Widget_TypeComboBox: {
1328 THEMECOMBOBOX *f;
1329
1330 f=(THEMECOMBOBOX*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1331 assert(f);
1332
1333 switch(prop) {
1334 case GWEN_DialogProperty_Value:
1335 if (index<f->getNumItems()) {
1336 str=f->getItem(index);
1337 if (str.empty())
1338 return defaultValue;
1339 else {
1340 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_VALUE, str.text());
1341 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_VALUE);
1342 }
1343 }
1344 else {
1345 DBG_ERROR(GWEN_LOGDOMAIN, "Index %d out of range", index);
1346 return defaultValue;
1347 }
1348
1349 default:
1350 break;
1351 }
1352 break;
1353 }
1354
1355 case GWEN_Widget_TypeGroupBox: {
1356 FXGroupBox *f;
1357
1358 f=(FXGroupBox*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1359 assert(f);
1360
1361 switch(prop) {
1362 case GWEN_DialogProperty_Title:
1363 str=f->getText();
1364 if (str.empty())
1365 return defaultValue;
1366 else {
1367 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1368 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1369 }
1370
1371 default:
1372 break;
1373 }
1374 break;
1375 }
1376
1377 case GWEN_Widget_TypeRadioButton: {
1378 FXRadioButton *f;
1379
1380 f=(FXRadioButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1381 assert(f);
1382
1383 switch(prop) {
1384 case GWEN_DialogProperty_Title:
1385 str=f->getText();
1386 if (str.empty())
1387 return defaultValue;
1388 else {
1389 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1390 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1391 }
1392
1393 default:
1394 break;
1395 }
1396 break;
1397 }
1398
1399 case GWEN_Widget_TypeCheckBox: {
1400 FXCheckButton *f;
1401
1402 f=(FXCheckButton*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1403 assert(f);
1404
1405 switch(prop) {
1406 case GWEN_DialogProperty_Title:
1407 str=f->getText();
1408 if (str.empty())
1409 return defaultValue;
1410 else {
1411 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1412 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1413 }
1414
1415 default:
1416 break;
1417 }
1418 break;
1419 }
1420
1421 case GWEN_Widget_TypeTabPage: {
1422 FXWindow *f1;
1423 THEMETABITEM *f2;
1424
1425 f1=(FXWindow*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1426 assert(f1);
1427 f2=(THEMETABITEM*) (f1->getPrev());
1428 assert(f2);
1429
1430 switch(prop) {
1431 case GWEN_DialogProperty_Title:
1432 str=f2->getText();
1433 if (str.empty())
1434 return defaultValue;
1435 else {
1436 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1437 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1438 }
1439
1440 default:
1441 break;
1442 }
1443
1444 break;
1445 }
1446
1447 case GWEN_Widget_TypeDialog: {
1448 FXDialogBox *f;
1449
1450 f=(FXDialogBox*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1451 assert(f);
1452
1453 switch(prop) {
1454 case GWEN_DialogProperty_Title:
1455 str=f->getTitle();
1456 if (str.empty())
1457 return defaultValue;
1458 else {
1459 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1460 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1461 }
1462
1463 default:
1464 break;
1465 }
1466 break;
1467 }
1468
1469 case GWEN_Widget_TypeListBox: {
1470 FXFoldingList *f;
1471 FXHeader *fh;
1472 FXFoldingItem *fi;
1473
1474 f=(FXFoldingList*)GWEN_Widget_GetImplData(w, FOX16_DIALOG_WIDGET_REAL);
1475 assert(f);
1476
1477 switch(prop) {
1478 case GWEN_DialogProperty_Title:
1479 fh=f->getHeader();
1480 if (fh) {
1481 int i;
1482
1483 for (i=0; i<fh->getNumItems(); i++) {
1484 if (!str.empty())
1485 str+="\t";
1486 str+=fh->getItemText(i);
1487 }
1488 }
1489
1490 if (str.empty())
1491 return defaultValue;
1492 else {
1493 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_TITLE, str.text());
1494 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_TITLE);
1495 }
1496
1497 case GWEN_DialogProperty_Value:
1498 fi=f->getFirstItem();
1499 if (fi) {
1500 int i=index;
1501
1502 while(fi && i>0) {
1503 fi=fi->getNext();
1504 i--;
1505 }
1506 if (fi) {
1507 str=fi->getText();
1508 if (str.empty())
1509 return defaultValue;
1510 GWEN_Widget_SetText(w, FOX16_DIALOG_STRING_VALUE, str.text());
1511 return GWEN_Widget_GetText(w, FOX16_DIALOG_STRING_VALUE);
1512 }
1513 else {
1514 DBG_ERROR(GWEN_LOGDOMAIN, "Index %d out of range", index);
1515 return defaultValue;
1516 }
1517 }
1518 else {
1519 DBG_ERROR(GWEN_LOGDOMAIN, "Empty list");
1520 return defaultValue;
1521 }
1522
1523 default:
1524 break;
1525 }
1526 break;
1527 }
1528
1529
1530 case GWEN_Widget_TypeProgressBar:
1531 case GWEN_Widget_TypeSpinBox:
1532 case GWEN_Widget_TypeHSpacer:
1533 case GWEN_Widget_TypeVSpacer:
1534 case GWEN_Widget_TypeHLayout:
1535 case GWEN_Widget_TypeVLayout:
1536 case GWEN_Widget_TypeGridLayout:
1537 case GWEN_Widget_TypeTabBook:
1538 case GWEN_Widget_TypeScrollArea:
1539 case GWEN_Widget_TypeWidgetStack:
1540 case GWEN_Widget_TypeHLine:
1541 case GWEN_Widget_TypeVLine:
1542 break;
1543 }
1544
1545 /* this block is just to make sure we get warnings when new
1546 * properties are available but not handled here
1547 */
1548 switch(prop) {
1549 case GWEN_DialogProperty_Title:
1550 case GWEN_DialogProperty_Value:
1551 case GWEN_DialogProperty_MinValue:
1552 case GWEN_DialogProperty_MaxValue:
1553 case GWEN_DialogProperty_Enabled:
1554 case GWEN_DialogProperty_AddValue:
1555 case GWEN_DialogProperty_ClearValues:
1556 case GWEN_DialogProperty_ValueCount:
1557 case GWEN_DialogProperty_ColumnWidth:
1558 case GWEN_DialogProperty_Width:
1559 case GWEN_DialogProperty_Height:
1560 case GWEN_DialogProperty_SelectionMode:
1561 case GWEN_DialogProperty_SelectionState:
1562 case GWEN_DialogProperty_Focus:
1563 case GWEN_DialogProperty_SortDirection:
1564 case GWEN_DialogProperty_Sort:
1565 case GWEN_DialogProperty_Visibility:
1566 case GWEN_DialogProperty_ToolTip:
1567 case GWEN_DialogProperty_None:
1568 case GWEN_DialogProperty_Unknown:
1569 break;
1570 }
1571
1572
1573 DBG_WARN(0, "Function is not appropriate for this type of widget (%s)",
1574 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
1575 return defaultValue;
1576 }
1577
1578
1579
1580
1581
onSelCommand(FXObject * sender,FXSelector sel,void * ptr)1582 long FOX16_GuiDialog::onSelCommand(FXObject *sender, FXSelector sel, void *ptr) {
1583 GWEN_WIDGET *w;
1584 const char *wname;
1585 int rv=GWEN_DialogEvent_ResultNotHandled;
1586 FXDialogBox *dialogBox;
1587
1588 w=GWEN_Dialog_FindWidgetByImplData(_dialog, FOX16_DIALOG_WIDGET_REAL, sender);
1589 if (w==NULL) {
1590 if (!m_radioGroups.empty()) {
1591 std::list<RadioButtonGroup*>::iterator it;
1592 RadioButtonGroup *grp=NULL;
1593
1594 for (it=m_radioGroups.begin(); it!=m_radioGroups.end(); it++) {
1595 if ((*it)->getDataTarget()==sender) {
1596 grp=*it;
1597 break;
1598 }
1599 }
1600
1601 if (grp==NULL) {
1602 DBG_WARN(GWEN_LOGDOMAIN, "Widget or RadioButtonGroup not found");
1603 return 0;
1604 }
1605 else {
1606 DBG_INFO(0, "Found button group %d: %d", grp->getGroupId(), grp->getRadioValue());
1607 // no signal for now
1608 return 1;
1609 }
1610 }
1611 }
1612 wname=GWEN_Widget_GetName(w);
1613
1614 dialogBox=_mainWidget;
1615
1616 DBG_DEBUG(GWEN_LOGDOMAIN, "Command for [%s] (type: %s)",
1617 wname?wname:"(unnamed)",
1618 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
1619
1620 switch(GWEN_Widget_GetType(w)) {
1621 case GWEN_Widget_TypeUnknown:
1622 return GWEN_ERROR_GENERIC;
1623
1624 case GWEN_Widget_TypeNone:
1625 return GWEN_ERROR_GENERIC;
1626
1627 case GWEN_Widget_TypePushButton:
1628 case GWEN_Widget_TypeLineEdit:
1629 case GWEN_Widget_TypeComboBox:
1630 case GWEN_Widget_TypeListBox:
1631 case GWEN_Widget_TypeCheckBox:
1632 case GWEN_Widget_TypeLabel:
1633 case GWEN_Widget_TypeTextEdit:
1634 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
1635 GWEN_DialogEvent_TypeActivated,
1636 GWEN_Widget_GetName(w));
1637 break;
1638 case GWEN_Widget_TypeSpinBox:
1639 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
1640 GWEN_DialogEvent_TypeValueChanged,
1641 GWEN_Widget_GetName(w));
1642 break;
1643
1644 case GWEN_Widget_TypeRadioButton: /* use SEL_UPDATED for FXRadioButton */
1645 case GWEN_Widget_TypeProgressBar:
1646 case GWEN_Widget_TypeGroupBox:
1647 case GWEN_Widget_TypeHSpacer:
1648 case GWEN_Widget_TypeVSpacer:
1649 case GWEN_Widget_TypeHLayout:
1650 case GWEN_Widget_TypeVLayout:
1651 case GWEN_Widget_TypeGridLayout:
1652 case GWEN_Widget_TypeDialog:
1653 case GWEN_Widget_TypeTabBook:
1654 case GWEN_Widget_TypeTabPage:
1655 case GWEN_Widget_TypeScrollArea:
1656 case GWEN_Widget_TypeWidgetStack:
1657 case GWEN_Widget_TypeHLine:
1658 case GWEN_Widget_TypeVLine:
1659 case GWEN_Widget_TypeTextBrowser:
1660 /* nothing to do for these types */
1661 ;
1662 }
1663
1664 if (rv==GWEN_DialogEvent_ResultAccept) {
1665 dialogBox->getApp()->stopModal(dialogBox, 1);
1666 }
1667 else if (rv==GWEN_DialogEvent_ResultReject) {
1668 dialogBox->getApp()->stopModal(dialogBox, 0);
1669 }
1670
1671 return 1;
1672 }
1673
1674
1675
onSelChanged(FXObject * sender,FXSelector sel,void * ptr)1676 long FOX16_GuiDialog::onSelChanged(FXObject *sender, FXSelector sel, void *ptr) {
1677 GWEN_WIDGET *w;
1678 int rv=GWEN_DialogEvent_ResultNotHandled;
1679 FXDialogBox *dialogBox;
1680
1681 w=GWEN_Dialog_FindWidgetByImplData(_dialog, FOX16_DIALOG_WIDGET_REAL, sender);
1682 if (w==NULL) {
1683 DBG_INFO(0, "Widget not found");
1684 return 0;
1685 }
1686
1687 dialogBox=_mainWidget;
1688
1689 switch(GWEN_Widget_GetType(w)) {
1690 case GWEN_Widget_TypeUnknown:
1691 return GWEN_ERROR_GENERIC;
1692 case GWEN_Widget_TypeNone:
1693 return GWEN_ERROR_GENERIC;
1694 case GWEN_Widget_TypeSpinBox:
1695 case GWEN_Widget_TypeLineEdit:
1696 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
1697 GWEN_DialogEvent_TypeValueChanged,
1698 GWEN_Widget_GetName(w));
1699 break;
1700
1701 case GWEN_Widget_TypeLabel:
1702 case GWEN_Widget_TypePushButton:
1703 case GWEN_Widget_TypeTextEdit:
1704 case GWEN_Widget_TypeComboBox:
1705 case GWEN_Widget_TypeRadioButton:
1706 case GWEN_Widget_TypeProgressBar:
1707 case GWEN_Widget_TypeGroupBox:
1708 case GWEN_Widget_TypeHSpacer:
1709 case GWEN_Widget_TypeVSpacer:
1710 case GWEN_Widget_TypeHLayout:
1711 case GWEN_Widget_TypeVLayout:
1712 case GWEN_Widget_TypeGridLayout:
1713 case GWEN_Widget_TypeListBox:
1714 case GWEN_Widget_TypeDialog:
1715 case GWEN_Widget_TypeTabBook:
1716 case GWEN_Widget_TypeTabPage:
1717 case GWEN_Widget_TypeCheckBox:
1718 case GWEN_Widget_TypeScrollArea:
1719 case GWEN_Widget_TypeWidgetStack:
1720 case GWEN_Widget_TypeHLine:
1721 case GWEN_Widget_TypeVLine:
1722 case GWEN_Widget_TypeTextBrowser:
1723 ;
1724 }
1725
1726 if (rv==GWEN_DialogEvent_ResultAccept) {
1727 GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");
1728 dialogBox->getApp()->stopModal(dialogBox, 1);
1729 }
1730 else if (rv==GWEN_DialogEvent_ResultReject) {
1731 GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");
1732 dialogBox->getApp()->stopModal(dialogBox, 0);
1733 }
1734
1735 return 1;
1736 }
1737
1738
1739
onSelKeyPress(FXObject * sender,FXSelector sel,void * ptr)1740 long FOX16_GuiDialog::onSelKeyPress(FXObject *sender, FXSelector sel, void *ptr) {
1741 GWEN_WIDGET *w;
1742
1743 w=GWEN_Dialog_FindWidgetByImplData(_dialog, FOX16_DIALOG_WIDGET_REAL, sender);
1744 if (w==NULL) {
1745 DBG_INFO(0, "Widget not found");
1746 return 0;
1747 }
1748
1749 switch(GWEN_Widget_GetType(w)) {
1750 case GWEN_Widget_TypeUnknown:
1751 case GWEN_Widget_TypeNone:
1752 return 0;
1753
1754 case GWEN_Widget_TypeDialog:
1755 /* catch ENTER key */
1756 if (((FXEvent*)ptr)->code==KEY_Return || ((FXEvent*)ptr)->code==KEY_KP_Enter) {
1757 return 1;
1758 }
1759 return 0;
1760
1761 case GWEN_Widget_TypeLabel:
1762 case GWEN_Widget_TypePushButton:
1763 case GWEN_Widget_TypeLineEdit:
1764 case GWEN_Widget_TypeTextEdit:
1765 case GWEN_Widget_TypeComboBox:
1766 case GWEN_Widget_TypeRadioButton:
1767 case GWEN_Widget_TypeProgressBar:
1768 case GWEN_Widget_TypeSpinBox:
1769 case GWEN_Widget_TypeGroupBox:
1770 case GWEN_Widget_TypeHSpacer:
1771 case GWEN_Widget_TypeVSpacer:
1772 case GWEN_Widget_TypeHLayout:
1773 case GWEN_Widget_TypeVLayout:
1774 case GWEN_Widget_TypeGridLayout:
1775 case GWEN_Widget_TypeListBox:
1776 case GWEN_Widget_TypeTabBook:
1777 case GWEN_Widget_TypeTabPage:
1778 case GWEN_Widget_TypeCheckBox:
1779 case GWEN_Widget_TypeScrollArea:
1780 case GWEN_Widget_TypeWidgetStack:
1781 case GWEN_Widget_TypeHLine:
1782 case GWEN_Widget_TypeVLine:
1783 case GWEN_Widget_TypeTextBrowser:
1784 ;
1785 }
1786
1787 return 0;
1788 }
1789
1790
1791
onSelKeyRelease(FXObject * sender,FXSelector sel,void * ptr)1792 long FOX16_GuiDialog::onSelKeyRelease(FXObject *sender, FXSelector sel, void *ptr) {
1793 GWEN_WIDGET *w;
1794
1795 w=GWEN_Dialog_FindWidgetByImplData(_dialog, FOX16_DIALOG_WIDGET_REAL, sender);
1796 if (w==NULL) {
1797 DBG_INFO(0, "Widget not found");
1798 return 0;
1799 }
1800
1801 switch(GWEN_Widget_GetType(w)) {
1802 case GWEN_Widget_TypeDialog:
1803 /* catch ENTER key */
1804 if (((FXEvent*)ptr)->code==KEY_Return || ((FXEvent*)ptr)->code==KEY_KP_Enter) {
1805 return 1;
1806 }
1807 return 0;
1808
1809 case GWEN_Widget_TypeUnknown:
1810 case GWEN_Widget_TypeNone:
1811 case GWEN_Widget_TypeLabel:
1812 case GWEN_Widget_TypePushButton:
1813 case GWEN_Widget_TypeLineEdit:
1814 case GWEN_Widget_TypeTextEdit:
1815 case GWEN_Widget_TypeComboBox:
1816 case GWEN_Widget_TypeRadioButton:
1817 case GWEN_Widget_TypeProgressBar:
1818 case GWEN_Widget_TypeSpinBox:
1819 case GWEN_Widget_TypeGroupBox:
1820 case GWEN_Widget_TypeHSpacer:
1821 case GWEN_Widget_TypeVSpacer:
1822 case GWEN_Widget_TypeHLayout:
1823 case GWEN_Widget_TypeVLayout:
1824 case GWEN_Widget_TypeGridLayout:
1825 case GWEN_Widget_TypeListBox:
1826 case GWEN_Widget_TypeTabBook:
1827 case GWEN_Widget_TypeTabPage:
1828 case GWEN_Widget_TypeCheckBox:
1829 case GWEN_Widget_TypeScrollArea:
1830 case GWEN_Widget_TypeWidgetStack:
1831 case GWEN_Widget_TypeHLine:
1832 case GWEN_Widget_TypeVLine:
1833 case GWEN_Widget_TypeTextBrowser:
1834 ;
1835 }
1836
1837 return 0;
1838 }
1839
1840
1841
setup(FXWindow * parentWindow)1842 bool FOX16_GuiDialog::setup(FXWindow *parentWindow) {
1843 FXWindow *xw;
1844 GWEN_WIDGET_TREE *wtree;
1845 GWEN_WIDGET *w;
1846 int rv;
1847
1848 wtree=GWEN_Dialog_GetWidgets(_dialog);
1849 if (wtree==NULL) {
1850 DBG_ERROR(GWEN_LOGDOMAIN, "No widget tree in dialog");
1851 return false;
1852 }
1853 w=GWEN_Widget_Tree_GetFirst(wtree);
1854 if (w==NULL) {
1855 DBG_ERROR(GWEN_LOGDOMAIN, "No widgets in dialog");
1856 return false;
1857 }
1858
1859 xw=setupTree(parentWindow, w);
1860 if (xw==NULL) {
1861 DBG_INFO(0, "here");
1862 return false;
1863 }
1864
1865 _mainWidget=dynamic_cast<FXDialogBox*>(xw);
1866 assert(_mainWidget);
1867
1868 /* create X11 server side resources */
1869 xw->create();
1870
1871 m_sizeChanged=FALSE;
1872 rv=GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeInit, "");
1873 if (rv<0) {
1874 DBG_INFO(0, "Error initializing dialog: %d", rv);
1875 return false;
1876 }
1877 if (!m_sizeChanged) {
1878 DBG_ERROR(0, "Resizing dialog myself");
1879 xw->resize(xw->getDefaultWidth(), xw->getDefaultHeight());
1880 }
1881 xw->layout();
1882
1883 return true;
1884 }
1885
1886
1887
1888
setupTree(FXWindow * parentWindow,GWEN_WIDGET * w)1889 FXWindow *FOX16_GuiDialog::setupTree(FXWindow *parentWindow, GWEN_WIDGET *w) {
1890 const char *s;
1891 const char *name;
1892 FXuint opts=0;
1893 uint32_t flags;
1894 FXString text;
1895 FXString htmlText;
1896 FXComposite *parentComposite=NULL;
1897 FXWindow *wChild=NULL;
1898 FXWindow *wContent=NULL;
1899 GWEN_WIDGET *parentWidget;
1900 int cols;
1901 int rows;
1902
1903 /* sample data */
1904 flags=GWEN_Widget_GetFlags(w);
1905 s=GWEN_Widget_GetText(w, 0);
1906 if (s) {
1907 text=FXString(s);
1908 htmlText=FOX16_Gui::getHtmlText(s);
1909 }
1910 name=GWEN_Widget_GetName(w);
1911 cols=GWEN_Widget_GetColumns(w);
1912 rows=GWEN_Widget_GetRows(w);
1913
1914 parentWidget=GWEN_Widget_Tree_GetParent(w);
1915
1916 /* check for parent type */
1917 if (parentWindow)
1918 parentComposite=dynamic_cast<FXComposite*>(parentWindow);
1919 if (parentComposite==NULL) {
1920 switch(GWEN_Widget_GetType(w)) {
1921 case GWEN_Widget_TypeDialog:
1922 /* these types don't need the parent to be a FXComposite */
1923 break;
1924 default:
1925 DBG_ERROR(GWEN_LOGDOMAIN, "Parent of widget [%s] (type %d) is not a composite",
1926 name?name:"(unnamed)", GWEN_Widget_GetType(w));
1927 return NULL;
1928 }
1929 }
1930
1931 /* setup info for new widget */
1932 if (flags & GWEN_WIDGET_FLAGS_FILLX)
1933 opts|=LAYOUT_FILL_X | LAYOUT_FILL_COLUMN;
1934 if (flags & GWEN_WIDGET_FLAGS_FILLY)
1935 opts|=LAYOUT_FILL_Y;
1936 if (flags & GWEN_WIDGET_FLAGS_DECOR_SHRINKABLE)
1937 opts|=DECOR_SHRINKABLE;
1938 if (flags & GWEN_WIDGET_FLAGS_DECOR_STRETCHABLE)
1939 opts|=DECOR_STRETCHABLE;
1940 if (flags & GWEN_WIDGET_FLAGS_DECOR_MINIMIZE)
1941 opts|=DECOR_MINIMIZE;
1942 if (flags & GWEN_WIDGET_FLAGS_DECOR_MAXIMIZE)
1943 opts|=DECOR_MAXIMIZE;
1944 if (flags & GWEN_WIDGET_FLAGS_DECOR_CLOSE)
1945 opts|=DECOR_CLOSE;
1946 if (flags & GWEN_WIDGET_FLAGS_DECOR_MENU)
1947 opts|=DECOR_MENU;
1948 if (flags & GWEN_WIDGET_FLAGS_EQUAL_WIDTH)
1949 opts|=PACK_UNIFORM_WIDTH;
1950 if (flags & GWEN_WIDGET_FLAGS_EQUAL_HEIGHT)
1951 opts|=PACK_UNIFORM_HEIGHT;
1952 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_LEFT)
1953 opts|=JUSTIFY_LEFT;
1954 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_RIGHT)
1955 opts|=JUSTIFY_RIGHT;
1956 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_TOP)
1957 opts|=JUSTIFY_TOP;
1958 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_BOTTOM)
1959 opts|=JUSTIFY_BOTTOM;
1960 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_CENTERX)
1961 opts|=JUSTIFY_CENTER_X;
1962 if (flags & GWEN_WIDGET_FLAGS_JUSTIFY_CENTERY)
1963 opts|=JUSTIFY_CENTER_Y;
1964
1965 /* create THIS widget */
1966 switch(GWEN_Widget_GetType(w)) {
1967
1968 case GWEN_Widget_TypeLabel: {
1969 FOX16_HtmlLabel *label;
1970 int wi;
1971 const char *s;
1972 GWEN_STRINGLISTENTRY *se;
1973
1974 if (flags & GWEN_WIDGET_FLAGS_NO_WORDWRAP)
1975 opts|=FOX16_HtmlLabel::FLAGS_NO_WORDWRAP;
1976 label=new FOX16_HtmlLabel(parentComposite,
1977 htmlText,
1978 opts);
1979 s=GWEN_Widget_GetIconFileName(w);
1980 if (s && *s) {
1981 FXIcon *ic;
1982
1983 ic=getIcon(s);
1984 if (ic)
1985 label->setIcon(ic);
1986 }
1987
1988 wi=GWEN_Widget_GetWidth(w);
1989 if (wi>0)
1990 label->setMaxDefaultWidth(wi);
1991
1992 /* copy media paths to label */
1993 se=GWEN_StringList_FirstEntry(GWEN_Dialog_GetMediaPaths(_dialog));
1994 while(se) {
1995 const char *s;
1996
1997 s=GWEN_StringListEntry_Data(se);
1998 assert(s);
1999 label->addMediaPath(s);
2000 se=GWEN_StringListEntry_Next(se);
2001 }
2002
2003 wChild=label;
2004 break;
2005 }
2006
2007 case GWEN_Widget_TypePushButton: {
2008 const char *s;
2009 FXIcon *ic=NULL;
2010
2011 if (flags & GWEN_WIDGET_FLAGS_DEFAULT_WIDGET)
2012 opts|=BUTTON_DEFAULT | BUTTON_INITIAL | BUTTON_NORMAL;
2013 else
2014 opts|=BUTTON_NORMAL;
2015 s=GWEN_Widget_GetIconFileName(w);
2016 if (s && *s)
2017 ic=getIcon(s);
2018
2019 wChild=new THEMEBUTTON(parentComposite,
2020 text,
2021 ic, /* icon */
2022 this,
2023 ID_WIDGET_FIRST+_widgetCount,
2024 opts);
2025 break;
2026 }
2027
2028 case GWEN_Widget_TypeLineEdit:
2029 if (flags & GWEN_WIDGET_FLAGS_PASSWORD)
2030 opts|=TEXTFIELD_PASSWD;
2031 if (flags & GWEN_WIDGET_FLAGS_READONLY)
2032 opts|=TEXTFIELD_READONLY;
2033 wChild=new FXTextField(parentComposite,
2034 cols?cols:16,
2035 this,
2036 ID_WIDGET_FIRST+_widgetCount,
2037 opts | TEXTFIELD_NORMAL | TEXTFIELD_ENTER_ONLY);
2038 break;
2039
2040 case GWEN_Widget_TypeTextEdit: {
2041 FXText *f;
2042
2043 if (flags & GWEN_WIDGET_FLAGS_READONLY)
2044 opts|=TEXT_READONLY;
2045 f=new FXText(parentComposite,
2046 this,
2047 ID_WIDGET_FIRST+_widgetCount,
2048 opts | HSCROLLING_OFF);
2049 if (cols)
2050 f->setVisibleColumns(cols);
2051 if (rows)
2052 f->setVisibleRows(rows);
2053 wChild=f;
2054 break;
2055 }
2056
2057 case GWEN_Widget_TypeTextBrowser: {
2058 FOX16_HtmlText *f;
2059
2060 f=new FOX16_HtmlText(parentComposite, "",
2061 opts | HSCROLLING_OFF);
2062 wChild=f;
2063 break;
2064 }
2065
2066 case GWEN_Widget_TypeComboBox:
2067 if (flags & GWEN_WIDGET_FLAGS_READONLY)
2068 opts|=COMBOBOX_STATIC;
2069 wChild=new THEMECOMBOBOX(parentComposite,
2070 cols?cols:16,
2071 this,
2072 ID_WIDGET_FIRST+_widgetCount,
2073 opts);
2074 break;
2075
2076 case GWEN_Widget_TypeRadioButton: {
2077 FXRadioButton *rb;
2078 int groupId;
2079 RadioButtonGroup *grp=NULL;
2080 std::list<RadioButtonGroup*>::iterator it;
2081
2082 groupId=GWEN_Widget_GetGroupId(w);
2083
2084
2085 for (it=m_radioGroups.begin(); it!=m_radioGroups.end(); it++) {
2086 if ((*it)->getGroupId()==groupId) {
2087 grp=*it;
2088 }
2089 }
2090 if (grp==NULL) {
2091 grp=new RadioButtonGroup(groupId, this, ID_WIDGET_FIRST+_widgetCount);
2092 m_radioGroups.push_back(grp);
2093 }
2094
2095 rb=new FXRadioButton(parentComposite,
2096 text,
2097 grp->getDataTarget(),
2098 FXDataTarget::ID_OPTION+grp->getButtonCount(),
2099 opts | RADIOBUTTON_NORMAL);
2100 grp->addButton(rb);
2101 wChild=rb;
2102 break;
2103 }
2104
2105 case GWEN_Widget_TypeProgressBar:
2106 wChild=new FXProgressBar(parentComposite,
2107 this,
2108 ID_WIDGET_FIRST+_widgetCount,
2109 opts | PROGRESSBAR_NORMAL | PROGRESSBAR_PERCENTAGE);
2110 break;
2111
2112 case GWEN_Widget_TypeGroupBox:
2113 wChild=new FXGroupBox(parentComposite,
2114 text,
2115 opts | GROUPBOX_NORMAL | FRAME_LINE);
2116 break;
2117
2118 case GWEN_Widget_TypeHSpacer:
2119 wChild=new FXSpring(parentComposite, opts | LAYOUT_FILL_X);
2120 break;
2121
2122 case GWEN_Widget_TypeVSpacer:
2123 wChild=new FXSpring(parentComposite, opts | LAYOUT_FILL_Y);
2124 break;
2125
2126 case GWEN_Widget_TypeHLayout:
2127 wChild=new FXHorizontalFrame(parentComposite, opts,
2128 0, 0, 0, 0, 0, 0, 0, 0);
2129 break;
2130
2131 case GWEN_Widget_TypeVLayout:
2132 wChild=new FXVerticalFrame(parentComposite, opts,
2133 0, 0, 0, 0, 0, 0, 0, 0);
2134 break;
2135
2136 case GWEN_Widget_TypeGridLayout:
2137 if (cols & rows) {
2138 DBG_ERROR(GWEN_LOGDOMAIN, "State columns *or* rows, not both in widget [%s]",
2139 name?name:"(unnamed)");
2140 return NULL;
2141 }
2142 if (cols)
2143 wChild=new FXMatrix(parentComposite, cols,
2144 opts | MATRIX_BY_COLUMNS,
2145 0, 0, 0, 0, 0, 0, 0, 0);
2146 else
2147 wChild=new FXMatrix(parentComposite, rows,
2148 opts | MATRIX_BY_ROWS,
2149 0, 0, 0, 0, 0, 0, 0, 0);
2150 break;
2151
2152 case GWEN_Widget_TypeListBox:
2153 wChild=new FOX16_GuiSortingList(parentComposite,
2154 this,
2155 ID_WIDGET_FIRST+_widgetCount,
2156 opts | FRAME_SUNKEN|FRAME_THICK | LISTBOX_NORMAL);
2157 break;
2158
2159 case GWEN_Widget_TypeDialog:
2160 if (parentWindow)
2161 wChild=new FXDialogBox(parentWindow,
2162 name?FXString(name):FXString(""),
2163 opts | DECOR_TITLE | DECOR_BORDER);
2164 else
2165 wChild=new FXDialogBox(FXApp::instance(),
2166 name?FXString(name):FXString(""),
2167 opts | DECOR_TITLE | DECOR_BORDER);
2168 break;
2169
2170 case GWEN_Widget_TypeTabBook:
2171 wChild=new FXTabBook(parentComposite,
2172 this,
2173 ID_WIDGET_FIRST+_widgetCount,
2174 opts | TABBOOK_NORMAL);
2175 break;
2176
2177 case GWEN_Widget_TypeTabPage:
2178 if (parentWidget==NULL) {
2179 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] has no parent", name?name:"(unnamed)");
2180 return NULL;
2181 }
2182 else {
2183 FXTabBook *tbook=dynamic_cast<FXTabBook*>(parentWindow);
2184 if (tbook==NULL) {
2185 DBG_ERROR(GWEN_LOGDOMAIN, "Parent of widget [%s] needs to be of type TabBook", name?name:"(unnamed)");
2186 return NULL;
2187 }
2188
2189 new THEMETABITEM(tbook, text, NULL, opts | TAB_TOP_NORMAL);
2190 wChild=new FXVerticalFrame(tbook, opts);
2191 }
2192 break;
2193
2194 case GWEN_Widget_TypeCheckBox:
2195 wChild=new FXCheckButton(parentComposite,
2196 text,
2197 this,
2198 ID_WIDGET_FIRST+_widgetCount,
2199 opts | CHECKBUTTON_NORMAL);
2200 break;
2201
2202 case GWEN_Widget_TypeScrollArea: {
2203 FXScrollWindow *f;
2204
2205 f=new FXScrollWindow(parentComposite, opts);
2206 wChild=f;
2207 wContent=f->contentWindow();
2208 break;
2209 }
2210
2211 case GWEN_Widget_TypeWidgetStack:
2212 wChild=new FXSwitcher(parentComposite, opts);
2213 break;
2214
2215 case GWEN_Widget_TypeHLine:
2216 wChild=new FXHorizontalSeparator(parentComposite, opts | SEPARATOR_GROOVE);
2217 break;
2218
2219 case GWEN_Widget_TypeVLine:
2220 wChild=new FXVerticalSeparator(parentComposite, opts | SEPARATOR_GROOVE);
2221 break;
2222
2223 case GWEN_Widget_TypeSpinBox:
2224 wChild=new FXSpinner(parentComposite,
2225 cols?cols:16,
2226 this,
2227 ID_WIDGET_FIRST+_widgetCount,
2228 opts | SPIN_NORMAL);
2229 break;
2230
2231 case GWEN_Widget_TypeUnknown:
2232 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] is of type \'unknown\'", name?name:"(unnamed)");
2233 return NULL;
2234 case GWEN_Widget_TypeNone:
2235 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] is of type \'none\'", name?name:"(unnamed)");
2236 return NULL;
2237 }
2238
2239 assert(wChild);
2240 _widgetCount++;
2241
2242 if (wContent==NULL)
2243 wContent=wChild;
2244
2245 GWEN_Widget_SetImplData(w, FOX16_DIALOG_WIDGET_REAL, (void*) wChild);
2246 GWEN_Widget_SetImplData(w, FOX16_DIALOG_WIDGET_CONTENT, (void*) wContent);
2247
2248 /* handle children */
2249 w=GWEN_Widget_Tree_GetFirstChild(w);
2250 while(w) {
2251 if (NULL==setupTree(wContent, w))
2252 return NULL;
2253 w=GWEN_Widget_Tree_GetNext(w);
2254 }
2255
2256 return wChild;
2257 }
2258
2259
2260
cont()2261 int FOX16_GuiDialog::cont() {
2262 FXDialogBox *dialogBox;
2263
2264 dialogBox=_mainWidget;
2265 return dialogBox->getApp()->runModalFor(dialogBox);
2266 }
2267
2268
2269
openDialog()2270 int FOX16_GuiDialog::openDialog() {
2271 FXDialogBox *dialogBox;
2272
2273 dialogBox=_mainWidget;
2274
2275 /* show dialog */
2276 dialogBox->layout();
2277 dialogBox->show(PLACEMENT_OWNER);
2278
2279 return 0;
2280 }
2281
2282
2283
closeDialog()2284 int FOX16_GuiDialog::closeDialog() {
2285 FXDialogBox *dialogBox;
2286
2287 dialogBox=_mainWidget;
2288
2289 /* let dialog write its settings */
2290 GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeFini, "");
2291
2292 /* hide dialog */
2293 dialogBox->hide();
2294 delete _mainWidget;
2295 _mainWidget=NULL;
2296
2297 return 0;
2298 }
2299
2300
2301
2302