fltk/test/wizard.cxx
engelsman 2d18c6f650
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>
2021-12-08 15:00:33 +01:00

67 lines
1.8 KiB
C++

#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();
}