summaryrefslogtreecommitdiff
path: root/test/demo.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-01-01 21:53:07 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-01-12 19:21:09 +0100
commitbafd3fd3d792b530d39d3af06e087dc63d2a25a2 (patch)
tree42f4d533490191a92a13863d07378820b04a7b9c /test/demo.cxx
parent79832b679f2d195eb3b0f30ca920a857cc133b2b (diff)
Add Fl_Scheme_Choice widget and use it in test programs
This widget offers the selection of all known FLTK schemes as a simple widget based on Fl_Choice. Some test and demo programs use Fl_Scheme_Choice to enable the developer or user to switch schemes quickly for comparison. Todo: - add features to add new schemes during runtime (partially done) - update status when the scheme is changed by Fl::scheme("...")
Diffstat (limited to 'test/demo.cxx')
-rw-r--r--test/demo.cxx34
1 files changed, 15 insertions, 19 deletions
diff --git a/test/demo.cxx b/test/demo.cxx
index c41b22d45..fa763d420 100644
--- a/test/demo.cxx
+++ b/test/demo.cxx
@@ -78,7 +78,7 @@
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Menu_Button.H> // right click popup menu
-#include <FL/Fl_Choice.H>
+#include <FL/Fl_Scheme_Choice.H>
#include <FL/Fl_Simple_Terminal.H> // tty
#include <FL/filename.H>
#include <FL/platform.H>
@@ -95,13 +95,11 @@
void doexit(Fl_Widget *, void *);
void doback(Fl_Widget *, void *);
void dobut(Fl_Widget *, long);
-void doscheme(Fl_Choice *c, void *) {
- Fl::scheme(c->text(c->value()));
-}
Fl_Double_Window *form = 0;
Fl_Group *demogrp = 0;
Fl_Simple_Terminal *tty = 0;
+Fl_Scheme_Choice *scheme_choice = 0;
Fl_Button *but[9];
Fl_Button *exit_button;
@@ -185,21 +183,8 @@ void create_the_forms() {
obj = new Fl_Box(FL_FRAME_BOX, 10, 65, 330, 330, 0);
obj->color(FL_GRAY-8);
- Fl_Choice *choice = new Fl_Choice(90, 405, 100, 25, "Scheme:");
- choice->labelfont(FL_HELVETICA_BOLD);
- choice->add("none");
- choice->add("gtk+");
- choice->add("gleam");
- choice->add("oxy");
- choice->add("plastic");
- choice->callback((Fl_Callback *)doscheme);
- Fl::scheme(NULL);
- if (!Fl::scheme()) choice->value(0);
- else if (!strcmp(Fl::scheme(), "gtk+")) choice->value(1);
- else if (!strcmp(Fl::scheme(), "gleam")) choice->value(2);
- else if (!strcmp(Fl::scheme(), "oxy")) choice->value(3);
- else if (!strcmp(Fl::scheme(), "plastic")) choice->value(4);
- else choice->value(0);
+ scheme_choice = new Fl_Scheme_Choice(90, 405, 100, 25, "Scheme:");
+ scheme_choice->labelfont(FL_HELVETICA_BOLD);
exit_button = new Fl_Button(280, 405, 60, 25, "Exit");
exit_button->callback(doexit);
@@ -639,6 +624,17 @@ int main(int argc, char **argv) {
// set size_range() after show() so the window can be resizable (Win + macOS)
form->size_range(FORM_W, FORM_H, FORM_W, FORM_H);
+#if (0) // DEBUG (remove after testing)
+ {
+ const char *const *scheme_names = Fl_Scheme_Choice::scheme_names();
+ int ni = 0;
+ while (scheme_names[ni]) {
+ printf("scheme[%2d] = '%s'\n", ni, scheme_names[ni]);
+ ni++;
+ }
+ }
+#endif // End of debug and test statements
+
Fl::run();
return 0;
}