mirror of https://github.com/fltk/fltk
Add Fl_Flex demo "howto-flex-simple" to examples
This demo program uses an Fl_Flex widget with one row of buttons.
This commit is contained in:
parent
713d276b1c
commit
e6c2503453
|
@ -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
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
#
|
||||
# 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
|
||||
#
|
||||
|
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue