summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-10-16 22:11:33 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-10-16 22:18:24 +0200
commit38871c5b3192bccd508f3686413d4e56041ab091 (patch)
tree26db3ef4a73e93f23a1d1bcb037652aafc26dbed /examples
parente7b790ae31b3c5d5e819f35f5fa8bd3619f7103f (diff)
Add Fl_Grid widget and test and demo programs
- FL/Fl_Grid.H: header file - src/Fl_Grid.cxx: implementation - examples/grid-simple.cxx: simple example program - test/cube.cxx: use Fl_Grid for layout - test/grid_alignment.cxx: test cell alignment and other functions - test/grid_buttons.cxx: demo program as discussed in fltk.general - test/grid_login.cxx: like test/flex_login.cxx but with Fl_Grid - test/flex_login.cxx: modified to match test/grid_login.cxx
Diffstat (limited to 'examples')
-rw-r--r--examples/.gitignore1
-rw-r--r--examples/CMakeLists.txt9
-rw-r--r--examples/Makefile1
-rw-r--r--examples/grid-simple.cxx49
4 files changed, 56 insertions, 4 deletions
diff --git a/examples/.gitignore b/examples/.gitignore
index f62a5e4db..d4a21b441 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -12,6 +12,7 @@ callbacks
cairo-draw-x
chart-simple
draggable-group
+grid-simple
howto-add_fd-and-popen
howto-browser-with-icons
howto-drag-and-drop
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index b1409d12e..ea0b8487a 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-2022 by Bill Spitzak and others.
+# Copyright 2020-2023 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
@@ -31,10 +31,11 @@ file (MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
############################################################
set (SIMPLE_SOURCES
- chart-simple
- callbacks
browser-simple
+ callbacks
+ chart-simple
draggable-group
+ grid-simple
howto-add_fd-and-popen
howto-browser-with-icons
howto-drag-and-drop
@@ -45,8 +46,8 @@ set (SIMPLE_SOURCES
howto-remap-numpad-keyboard-keys
howto-text-over-image-button
menubar-add
- nativefilechooser-simple-app
nativefilechooser-simple
+ nativefilechooser-simple-app
progress-simple
shapedwindow
simple-terminal
diff --git a/examples/Makefile b/examples/Makefile
index 57d87de39..43f1d3119 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -31,6 +31,7 @@ ALL = animgifimage$(EXEEXT) \
callbacks$(EXEEXT) \
chart-simple$(EXEEXT) \
draggable-group$(EXEEXT) \
+ grid-simple$(EXEEXT) \
howto-add_fd-and-popen$(EXEEXT) \
howto-browser-with-icons$(EXEEXT) \
howto-drag-and-drop$(EXEEXT) \
diff --git a/examples/grid-simple.cxx b/examples/grid-simple.cxx
new file mode 100644
index 000000000..f08a5957b
--- /dev/null
+++ b/examples/grid-simple.cxx
@@ -0,0 +1,49 @@
+//
+// Fl_Grid Example Program for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2021-2022 by Albrecht Schlosser.
+// Copyright 2022-2023 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
+//
+
+// This example program is also included in the documentation.
+// See FL/Fl_Grid.H
+
+#include <FL/Fl.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Grid.H>
+#include <FL/Fl_Button.H>
+
+int main(int argc, char **argv) {
+ Fl_Double_Window *win = new Fl_Double_Window(320, 180, "3x3 Fl_Grid with Buttons");
+ // create the Fl_Grid container with five buttons
+ Fl_Grid *grid = new Fl_Grid(0, 0, win->w(), win->h());
+ grid->layout(3, 3, 10, 10);
+ grid->color(FL_WHITE);
+ Fl_Button *b0 = new Fl_Button(0, 0, 0, 0, "New");
+ Fl_Button *b1 = new Fl_Button(0, 0, 0, 0, "Options");
+ Fl_Button *b3 = new Fl_Button(0, 0, 0, 0, "About");
+ Fl_Button *b4 = new Fl_Button(0, 0, 0, 0, "Help");
+ Fl_Button *b6 = new Fl_Button(0, 0, 0, 0, "Quit");
+ // assign buttons to grid positions
+ grid->widget(b0, 0, 0);
+ grid->widget(b1, 0, 2);
+ grid->widget(b3, 1, 1);
+ grid->widget(b4, 2, 0);
+ grid->widget(b6, 2, 2);
+ // grid->show_grid(1); // enable to display grid helper lines
+ win->end();
+ win->resizable(grid);
+ win->size_range(300, 100);
+ win->show(argc, argv);
+ return Fl::run();
+}