diff options
| author | engelsman <engelsman@users.noreply.github.com> | 2021-12-08 15:00:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-08 15:00:33 +0100 |
| commit | 2d18c6f650c0001319c8883f8deb819d12984ac0 (patch) | |
| tree | 3fe72b80a2baadf7239cc40d9a0adedf9df9970f /test/wizard.cxx | |
| parent | eb7fb00801eb917ca1350d36ea896446cf4e5fb8 (diff) | |
Documentation on widget coordinates and layout, plus new test programs (#304)
Add coordinates and layout section to user manual
add section to user manual to clarify the use of window-relative
coordinates in both Fl_Group and Fl_Window containers, and include
brief descriptions of current layout manager widgets in one place.
add test/coordinates.cxx, test/wizard.cxx and related screenshots
under documentation/src.
update CMakeLists.txt, Makefile and .gitignore for new files.
Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
Diffstat (limited to 'test/wizard.cxx')
| -rw-r--r-- | test/wizard.cxx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/wizard.cxx b/test/wizard.cxx new file mode 100644 index 000000000..3baa051dc --- /dev/null +++ b/test/wizard.cxx @@ -0,0 +1,66 @@ +#include <FL/Fl.H> +#include <FL/Fl_Button.H> +#include <FL/Fl_Window.H> +#include <FL/Fl_Wizard.H> + +class Panel : public Fl_Group { +public: + Panel(int X, int Y, int W, int H, Fl_Color C, const char* T) + : Fl_Group(X, Y, W, H, T) { + align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER); + box(FL_ENGRAVED_BOX); + labelcolor(C); + labelsize(20); + end(); + } +}; + +class Wizard : public Fl_Wizard { +public: + Wizard(int X, int Y, int W, int H, const char* T=0) + : Fl_Wizard(X, Y, W, H, T) { + p1 = new Panel(X, Y, W, H, FL_RED, "Panel 1"); + p2 = new Panel(X, Y, W, H, FL_MAGENTA, "Panel 2"); + p3 = new Panel(X, Y, W, H, FL_BLUE, "Panel 3"); + value(p1); + } + void next_panel() { + Panel* p = (Panel*)value(); + if (p == p3) value(p1); else next(); + } + void prev_panel() { + Panel* p = (Panel*)value(); + if (p == p1) value(p3); else prev(); + } +private: + Panel *p1, *p2, *p3; +}; + +void next_callback(Fl_Widget *widget, void *data) { + Wizard *pWizard = (Wizard*)data; + pWizard->next_panel(); +} + +void prev_callback(Fl_Widget *widget, void *data) { + Wizard *pWizard = (Wizard*)data; + pWizard->prev_panel(); +} + +int main(int argc, char** argv) { + Fl_Window window(300, 165, "Fl_Wizard test"); + Wizard wizard(5, 5, 290, 100); + wizard.end(); + Fl_Group buttons(5, 110, 290, 50); + buttons.box(FL_ENGRAVED_BOX); + Fl_Button prev_button( 15, 120, 110, 30, "@< Prev Panel"); + prev_button.callback(prev_callback, (void*)&wizard); + prev_button.align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER | FL_ALIGN_LEFT); + Fl_Button next_button(175, 120, 110, 30, "Next Panel @>"); + next_button.align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER | FL_ALIGN_RIGHT); + next_button.callback(next_callback, (void*)&wizard); + buttons.end(); + window.end(); + window.show(argc, argv); + return Fl::run(); +} + |
