summaryrefslogtreecommitdiff
path: root/test/resize-example4a.cxx
diff options
context:
space:
mode:
authorDuncan Gibson <engelsman@users.noreply.github.com>2020-07-15 01:11:31 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-20 14:08:47 +0200
commitc132ac564ed46464c05de0a70e2afc3822916a67 (patch)
tree16af9684fa1f05e6cd20cfe0b376e7924108ae63 /test/resize-example4a.cxx
parent4858882e1e4af51cbe7125752f83216c273eed7c (diff)
add resize examples as per STR3433
add example code for creating images for resize.dox based on Article #415: How does resizing work? https://www.fltk.org/articles.php?L415 see also https://www.fltk.org/str.php?L3433
Diffstat (limited to 'test/resize-example4a.cxx')
-rw-r--r--test/resize-example4a.cxx99
1 files changed, 99 insertions, 0 deletions
diff --git a/test/resize-example4a.cxx b/test/resize-example4a.cxx
new file mode 100644
index 000000000..3764b1e93
--- /dev/null
+++ b/test/resize-example4a.cxx
@@ -0,0 +1,99 @@
+//
+// Resize example for use in the Fast Light Tool Kit (FLTK) documentation.
+//
+// See Article #415: How does resizing work?
+// https://www.fltk.org/articles.php?L415
+//
+// Copyright 1998-2020 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 "resize-arrows.h"
+#include <FL/Fl_Double_Window.H>
+
+// window, simplex and arrow dimensions
+int TLx = 35, TRx = 320, TLw = 260, Ww = 620;
+int TLy = 35, LGy = 100, TLh = 65, LGh = 70, LAh = 35, Wh = 200;
+
+Fl_Double_Window *window = 0;
+
+class Simplex : public Fl_Group {
+public:
+ Simplex(int X, int Y, int W, int H, const char *T = 0);
+ Fl_Box *m_button1, *m_input1, *m_button2, *m_input2;
+};
+
+Simplex::Simplex(int X, int Y, int W, int H, const char *T)
+ : Fl_Group(X, Y, W, H, T) {
+ this->box(FL_UP_BOX);
+ Fl_Group *group = new Fl_Group(X + 10, Y + 10, 240, 45);
+ group->box(FL_NO_BOX);
+ m_button1 = new Fl_Box(X + 20, Y + 20, 40, 25, "btn");
+ m_button1->box(FL_UP_BOX);
+ m_input1 = new Fl_Box(X + 70, Y + 20, 50, 25, "input");
+ m_input1->box(FL_UP_BOX);
+ m_button2 = new Fl_Box(X + 140, Y + 20, 40, 25, "btn");
+ m_button2->box(FL_UP_BOX);
+ m_input2 = new Fl_Box(X + 190, Y + 20, 50, 25, "input");
+ m_input2->box(FL_UP_BOX);
+ m_input2->color(FL_YELLOW);
+ group->resizable(m_input2);
+ group->end();
+ this->resizable(group);
+ this->end();
+}
+
+class Resizables : public Fl_Group {
+public:
+ Resizables(int X, int Y, int W, int H, const char *T = 0);
+ Simplex *TL, *TR; // top left, top right
+ Harrow *LA, *RA; // left arrow, right arrow
+};
+
+Resizables::Resizables(int X, int Y, int W, int H, const char *T)
+ : Fl_Group(X, Y, W, H, T) {
+ TL = new Simplex(X + TLx, Y + TLy, TLw, TLh, "Original");
+ TL->align(FL_ALIGN_TOP_LEFT);
+
+ TR = new Simplex(X + TRx, Y + TLy, TLw, TLh, "Horizonally Resized");
+ TR->align(FL_ALIGN_TOP_LEFT);
+
+ Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
+ LG->box(FL_NO_BOX);
+ LG->color(FL_WHITE);
+ LA = new Harrow(TL->m_input2->x(), LG->y(), TL->m_input2->w(), LAh, "Initial\nwidth");
+ LG->resizable(LA);
+ LG->end();
+
+ Fl_Group *RG = new Fl_Group(X + TRx, Y + LGy, TLw, LGh);
+ RG->box(FL_NO_BOX);
+ RG->color(FL_WHITE);
+ RA = new Harrow(TR->m_input2->x(), RG->y(), TR->m_input2->w(), LAh, "Resized\nwidth");
+ RG->resizable(RA);
+ RG->end();
+
+ this->resizable(TR);
+ this->end();
+}
+
+
+int main(int argc, char **argv) {
+ window = new Fl_Double_Window(Ww, Wh, "resize-example4a");
+ window->color(FL_WHITE);
+ Resizables *resizables = new Resizables(0, 0, Ww, Wh);
+ window->end();
+ window->resizable(resizables);
+ window->size_range(Ww, Wh);
+ window->show(argc, argv);
+ window->size(Ww + 90, Wh);
+ return Fl::run();
+}