summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/CMakeLists.txt3
-rw-r--r--examples/Makefile18
-rw-r--r--examples/Makefile.FLTK17
-rw-r--r--examples/howto-flex-simple.cxx63
4 files changed, 100 insertions, 1 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index fc92de28b..2cf147637 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# CMakeLists.txt used to build example apps by the CMake build system
#
-# Copyright 2020-2021 by Bill Spitzak and others.
+# Copyright 2020-2022 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this
@@ -37,6 +37,7 @@ set (SIMPLE_SOURCES
howto-browser-with-icons
howto-drag-and-drop
howto-draw-an-x
+ howto-flex-simple
howto-menu-with-images
howto-parse-args
howto-remap-numpad-keyboard-keys
diff --git a/examples/Makefile b/examples/Makefile
index 00b8acafb..dc312aa7a 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,3 +1,20 @@
+#
+# Makefile used to build example apps by 'make'
+#
+# Copyright 2020-2022 by Bill Spitzak and others.
+#
+# This library is free software. Distribution and use rights are outlined in
+# the file "COPYING" which should have been included with this file. If this
+# file is missing or damaged, see the license at:
+#
+# https://www.fltk.org/COPYING.php
+#
+# Please see the following page on how to report bugs and issues:
+#
+# https://www.fltk.org/bugs.php
+#
+################################################################################
+
include Makefile.FLTK
RM = rm -f
@@ -13,6 +30,7 @@ ALL = browser-simple$(EXEEXT) \
howto-browser-with-icons$(EXEEXT) \
howto-drag-and-drop$(EXEEXT) \
howto-draw-an-x$(EXEEXT) \
+ howto-flex-simple$(EXEEXT) \
howto-menu-with-images$(EXEEXT) \
howto-parse-args$(EXEEXT) \
howto-remap-numpad-keyboard-keys$(EXEEXT) \
diff --git a/examples/Makefile.FLTK b/examples/Makefile.FLTK
index 902797c59..59899b724 100644
--- a/examples/Makefile.FLTK
+++ b/examples/Makefile.FLTK
@@ -1,4 +1,21 @@
#
+# Included Makefile used to build example apps by 'make'
+#
+# Copyright 2020-2022 by Bill Spitzak and others.
+#
+# This library is free software. Distribution and use rights are outlined in
+# the file "COPYING" which should have been included with this file. If this
+# file is missing or damaged, see the license at:
+#
+# https://www.fltk.org/COPYING.php
+#
+# Please see the following page on how to report bugs and issues:
+#
+# https://www.fltk.org/bugs.php
+#
+################################################################################
+
+#
# Stuff every FLTK application might need
#
# If you take this for use in your own project, be sure to change
diff --git a/examples/howto-flex-simple.cxx b/examples/howto-flex-simple.cxx
new file mode 100644
index 000000000..329fe9351
--- /dev/null
+++ b/examples/howto-flex-simple.cxx
@@ -0,0 +1,63 @@
+//
+// Very simple Fl_Flex demo program for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2022 by Bill Spitzak and others.
+//
+// This library is free software. Distribution and use rights are outlined in
+// the file "COPYING" which should have been included with this file. If this
+// file is missing or damaged, see the license at:
+//
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
+//
+// https://www.fltk.org/bugs.php
+//
+
+#include <FL/Fl.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Flex.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Button.H>
+#include <FL/fl_ask.H>
+
+// the 'Exit' button callback closes the window and terminates the program
+void exit_cb(Fl_Widget *w, void *) {
+ fl_message("The '%s' button closes the window\nand terminates the program.", w->label());
+ w->window()->hide();
+}
+
+// common callback for all other buttons
+void button_cb(Fl_Widget *w, void *) {
+ fl_message("The '%s' button does nothing.", w->label());
+}
+
+int main(int argc, char **argv) {
+ Fl_Double_Window window(410, 40, "Simple Fl_Flex Demo");
+ Fl_Flex flex(5, 5, window.w() - 10, window.h() - 10, Fl_Flex::HORIZONTAL);
+ Fl_Button b1(0, 0, 0, 0, "File");
+ Fl_Button b2(0, 0, 0, 0, "New");
+ Fl_Button b3(0, 0, 0, 0, "Save");
+ Fl_Box bx(0, 0, 0, 0); // empty space
+ Fl_Button eb(0, 0, 0, 0, "Exit");
+
+ // assign callbacks to buttons
+ b1.callback(button_cb);
+ b2.callback(button_cb);
+ b3.callback(button_cb);
+ eb.callback(exit_cb);
+
+ // set gap between adjacent buttons and extra spacing (invisible box size)
+ flex.gap(10);
+ flex.set_size(bx, 30); // total 50: 2 * gap + 30
+
+ // end() groups
+ flex.end();
+ window.end();
+
+ // set resizable, minimal window size, show() window, and execute event loop
+ window.resizable(flex);
+ window.size_range(300, 30);
+ window.show(argc, argv);
+ return Fl::run();
+}