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
This commit is contained in:
Duncan Gibson 2020-07-15 01:11:31 +02:00 committed by Albrecht Schlosser
parent 4858882e1e
commit c132ac564e
12 changed files with 1012 additions and 1 deletions

View File

@ -98,6 +98,13 @@ CREATE_EXAMPLE (offscreen offscreen.cxx fltk)
CREATE_EXAMPLE (radio radio.fl fltk)
CREATE_EXAMPLE (resize resize.fl fltk)
CREATE_EXAMPLE (resizebox resizebox.cxx fltk)
CREATE_EXAMPLE (resize-example1 "resize-example1.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example2 "resize-example2.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example3a "resize-example3a.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example3b "resize-example3b.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example3c "resize-example3c.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example4a "resize-example4a.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (resize-example4b "resize-example4b.cxx;resize-arrows.cxx" fltk)
CREATE_EXAMPLE (rotated_text rotated_text.cxx fltk)
CREATE_EXAMPLE (scroll scroll.cxx fltk)
CREATE_EXAMPLE (subwindow subwindow.cxx fltk)

View File

@ -76,8 +76,15 @@ CPPFILES =\
pixmap.cxx \
preferences.cxx \
radio.cxx \
resizebox.cxx \
resize.cxx \
resizebox.cxx \
resize-example1.cxx \
resize-example2.cxx \
resize-example3a.cxx \
resize-example3b.cxx \
resize-example3c.cxx \
resize-example4a.cxx \
resize-example4b.cxx \
rotated_text.cxx \
scroll.cxx \
shape.cxx \
@ -152,6 +159,13 @@ ALL = \
radio$(EXEEXT) \
resize$(EXEEXT) \
resizebox$(EXEEXT) \
resize-example1$(EXEEXT) \
resize-example2$(EXEEXT) \
resize-example3a$(EXEEXT) \
resize-example3b$(EXEEXT) \
resize-example3c$(EXEEXT) \
resize-example4a$(EXEEXT) \
resize-example4b$(EXEEXT) \
rotated_text$(EXEEXT) \
scroll$(EXEEXT) \
subwindow$(EXEEXT) \
@ -487,6 +501,41 @@ resize.cxx: resize.fl ../fluid/fluid$(EXEEXT)
resizebox$(EXEEXT): resizebox.o
resize-example1$(EXEEXT): resize-example1.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example1.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example2$(EXEEXT): resize-example2.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example2.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example3a$(EXEEXT): resize-example3a.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example3a.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example3b$(EXEEXT): resize-example3b.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example3b.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example3c$(EXEEXT): resize-example3c.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example3c.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example4a$(EXEEXT): resize-example4a.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example4a.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
resize-example4b$(EXEEXT): resize-example4b.o resize-arrows.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CXXFLAGS) $(LDFLAGS) resize-example4b.o resize-arrows.o -o $@ $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
rotated_text$(EXEEXT): rotated_text.o
scroll$(EXEEXT): scroll.o

View File

@ -98,3 +98,11 @@
@i:clock:clock
@i:popups:message
@i:boxtypes:boxtype
@i:Resize Examples\n...:@ir
@ir:Example\n1:resize-example1
@ir:Example\n2:resize-example2
@ir:Example\n3a:resize-example3a
@ir:Example\n3b:resize-example3b
@ir:Example\n3c:resize-example3c
@ir:Example\n4a:resize-example4a
@ir:Example\n4b:resize-example4b

59
test/resize-arrows.cxx Normal file
View File

@ -0,0 +1,59 @@
//
// 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_draw.H>
Harrow::Harrow(int X, int Y, int W, int H, const char *T)
: Fl_Box(X, Y, W, H, T) {
align(FL_ALIGN_BOTTOM);
box(FL_NO_BOX);
color(FL_WHITE);
}
void Harrow::draw() {
Fl_Color old = fl_color();
int dx = 5, dy = 4;
int my = y() + h() / 2;
fl_rectf(x(), y(), w(), h(), FL_WHITE);
fl_color(FL_BLACK);
fl_polygon(x(), my, x() + dx, my - dy, x() + dx, my + dy);
fl_line(x() + dx, my, x() + w() - dx, my);
fl_polygon(x() + w(), my, x() + w() - dx, my + dy, x() + w() - dx, my - dy);
fl_color(old);
}
Varrow::Varrow(int X, int Y, int W, int H, const char *T)
: Fl_Box(X, Y, W, H, T) {
align(FL_ALIGN_RIGHT);
box(FL_NO_BOX);
color(FL_WHITE);
}
void Varrow::draw() {
Fl_Color old = fl_color();
int dx = 4, dy = 5;
int mx = x() + w() / 2;
fl_rectf(x(), y(), w(), h(), FL_WHITE);
fl_color(FL_BLACK);
fl_polygon(mx - dx, y() + dy, mx, y(), mx + dx, y() + dy);
fl_line(mx, y() + dy, mx, y() + h() - dy);
fl_polygon(mx - dx, y() + h() - dy, mx + dx, y() + h() - dy, mx, y() + h());
fl_color(old);
}

50
test/resize-arrows.h Normal file
View File

@ -0,0 +1,50 @@
//
// 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
//
#ifndef RESIZE_ARROWS_H
#define RESIZE_ARROWS_H
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
/** Harrow is an Fl_Box with a horizontal arrow drawn across the middle.
The arrow is drawn in black on a white background.
By default, the box has no border, and the label is below the box.
*/
class Harrow : public Fl_Box {
public:
Harrow(int X, int Y, int W, int H, const char *T = 0);
void draw();
};
/** Varrow is an Fl_Box with a vertical arrow drawn down the middle.
The arrow is drawn in black on a white background.
By default, the box has no border, and the label is to the right of the box.
*/
class Varrow : public Fl_Box {
public:
Varrow(int X, int Y, int W, int H, const char *T = 0);
void draw();
};
#endif // RESIZE_ARROWS_H

128
test/resize-example1.cxx Normal file
View File

@ -0,0 +1,128 @@
//
// 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>
Fl_Double_Window *window;
// inner box dimensions
int Ax = 0, Bx = 35, Cx = 70, Dx = 105, Nx = 140, Aw = 35, Rw = 70, Mw = 140;
int Ay = 0, Ey = 35, Gy = 70, Iy = 105, My = 140, Ah = 35, Rh = 70, Nh = 175;
// resize box and arrow group dimensions
int TLx = 35, TRx = 245, TGx = 420, TLw = 175, TGw = 140, TAw = 35;
int TLy = 35, BLy = 245, LGy = 420, TLh = 175, LGh = 105, LAh = 35;
// window dimensions
int Ww = 560, Wh = 525;
class Resizebox : public Fl_Group {
public:
Resizebox(int X, int Y, int W, int H, const char *T);
};
Resizebox::Resizebox(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->align(FL_ALIGN_TOP_LEFT);
this->box(FL_UP_BOX);
Fl_Box *b;
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Ay, Aw, Ah, "A"); b->color(14);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Ay, Aw, Ah, "B"); b->color(9);
b = new Fl_Box(FL_FRAME_BOX, X + Cx, Y + Ay, Aw, Ah, "C"); b->color(10);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Ay, Aw, Ah, "D"); b->color(11);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Ey, Aw, Ah, "E"); b->color(9);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Ey, Rw, Rh, " "); b->color(8);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Ey, Aw, Ah, "F"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Gy, Aw, Ah, "G"); b->color(10);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Gy, Aw, Ah, "H"); b->color(13);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Iy, Aw, Ah, "I"); b->color(11);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Iy, Aw, Ah, "J"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Cx, Y + Iy, Aw, Ah, "K"); b->color(13);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Iy, Aw, Ah, "L"); b->color(14);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + My, Mw, Ah, "M"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Nx, Y + Ay, Aw, Nh, "N"); b->color(13);
this->end();
this->resizable(this);
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
Resizebox *TL, *TR, *BL, *BR; // topleft, topright, bottomleft, bottomright
Harrow *LA, *RA; // left arrow, right arrow
Varrow *TA, *BA; // top arrow, bottom arrow
};
Resizables::Resizables(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->box(FL_UP_BOX);
this->color(FL_WHITE);
TL = new Resizebox(X + TLx, Y + TLy, TLw, TLh, "Original Size");
TL->resizable(0);
TR = new Resizebox(X + TRx, Y + TLy, TLw, TLh, "Horizontally Resized");
BL = new Resizebox(X + TLx, Y + BLy, TLw, TLh, "Vertically Resized");
BR = new Resizebox(X + TRx, Y + BLy, TLw, TLh, "Horizontally and Vertically Resized");
Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
LG->box(FL_NO_BOX);
LG->color(FL_WHITE);
LA = new Harrow(LG->x(), LG->y(), LG->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(RG->x(), RG->y(), RG->w(), LAh, "Resized\nwidth");
RG->resizable(RA);
RG->end();
Fl_Group *TG = new Fl_Group(X + TGx, Y + TLy, TGw, TLh);
TG->box(FL_NO_BOX);
TG->color(FL_WHITE);
TA = new Varrow(X + TGx, Y + TLy, TAw, TLh, "Initial\nheight");
TG->resizable(TA);
TG->end();
Fl_Group *BG = new Fl_Group(X + TGx, Y + BLy, TGw, TLh);
BG->box(FL_NO_BOX);
BG->color(FL_WHITE);
BA = new Varrow(X + TGx, Y + BLy, TAw, TLh, "Resized\nheight");
BG->resizable(BA);
BG->end();
this->resizable(BR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example1");
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 + 140, Wh + 35);
return Fl::run();
}

132
test/resize-example2.cxx Normal file
View File

@ -0,0 +1,132 @@
//
// 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>
// inner box dimensions
int Ax = 0, Bx = 35, Cx = 70, Dx = 105, Nx = 140, Aw = 35, Rw = 70, Mw = 140;
int Ay = 0, Ey = 35, Gy = 70, Iy = 105, My = 140, Ah = 35, Rh = 70, Nh = 175;
// resize box and arrow group dimensions
int TLx = 35, TRx = 245, TGx = 420, TLw = 175, TGw = 140, TAw = 35;
int TLy = 35, BLy = 245, LGy = 420, TLh = 175, LGh = 105, LAh = 35;
// window dimensions
int Ww = 560, Wh = 525;
Fl_Double_Window *window;
class Resizebox : public Fl_Group {
public:
Resizebox(int X, int Y, int W, int H, const char *T);
Fl_Box *m_box;
};
Resizebox::Resizebox(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->align(FL_ALIGN_TOP_LEFT);
this->box(FL_UP_BOX);
Fl_Box *b;
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Ay, Aw, Ah, "A"); b->color(14);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Ay, Aw, Ah, "B"); b->color(9);
b = new Fl_Box(FL_FRAME_BOX, X + Cx, Y + Ay, Aw, Ah, "C"); b->color(10);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Ay, Aw, Ah, "D"); b->color(11);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Ey, Aw, Ah, "E"); b->color(9);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Ey, Rw, Rh, "R"); b->color(3);
b->label("resizable");
m_box = b;
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Ey, Aw, Ah, "F"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Gy, Aw, Ah, "G"); b->color(10);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Gy, Aw, Ah, "H"); b->color(13);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + Iy, Aw, Ah, "I"); b->color(11);
b = new Fl_Box(FL_FRAME_BOX, X + Bx, Y + Iy, Aw, Ah, "J"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Cx, Y + Iy, Aw, Ah, "K"); b->color(13);
b = new Fl_Box(FL_FRAME_BOX, X + Dx, Y + Iy, Aw, Ah, "L"); b->color(14);
b = new Fl_Box(FL_FRAME_BOX, X + Ax, Y + My, Mw, Ah, "M"); b->color(12);
b = new Fl_Box(FL_FRAME_BOX, X + Nx, Y + Ay, Aw, Nh, "N"); b->color(13);
this->end();
this->resizable(m_box);
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
Resizebox *TL, *TR, *BL, *BR; // topleft, topright, bottomleft, bottomright
Harrow *LA, *RA; // left arrow, right arrow
Varrow *TA, *BA; // top arrow, bottom arrow
};
Resizables::Resizables(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->box(FL_UP_BOX);
this->color(FL_WHITE);
TL = new Resizebox(X + TLx, Y + TLy, TLw, TLh, "Original Size");
TL->resizable(0);
TR = new Resizebox(X + TRx, Y + TLy, TLw, TLh, "Horizontally Resized");
BL = new Resizebox(X + TLx, Y + BLy, TLw, TLh, "Vertically Resized");
BR = new Resizebox(X + TRx, Y + BLy, TLw, TLh, "Horizontally and Vertically Resized");
Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
LG->box(FL_NO_BOX);
LG->color(FL_WHITE);
LA = new Harrow(BL->m_box->x(), LG->y(), BL->m_box->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(BR->m_box->x(), LG->y(), BL->m_box->w(), LAh, "Resized\nwidth");
RG->resizable(RA);
RG->end();
Fl_Group *TG = new Fl_Group(X + TGx, Y + TLy, TGw, TLh);
TG->box(FL_NO_BOX);
TG->color(FL_WHITE);
TA = new Varrow(TG->x(), TR->m_box->y(), TAw, TR->m_box->h(), "Initial\nheight");
TG->resizable(TA);
TG->end();
Fl_Group *BG = new Fl_Group(X + TGx, Y + BLy, TGw, TLh);
BG->box(FL_NO_BOX);
BG->color(FL_WHITE);
BA = new Varrow(BG->x(), BR->m_box->y(), TAw, BR->m_box->h(), "Resized\nheight");
BG->resizable(BA);
BG->end();
this->resizable(BR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example2");
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 + 140, Wh + 35);
return Fl::run();
}

119
test/resize-example3a.cxx Normal file
View File

@ -0,0 +1,119 @@
//
// 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>
#include <FL/Fl_Button.H>
// resize dialog and arrow dimensions
int TLx = 35, TRx = 270, TGx = 470, TLw = 200, TGw = 120, TAw = 35;
int TLy = 35, BLy = 160, LGy = 250, TLh = 90, LGh = 90, LAh = 35;
// window dimensions
int Ww = 590, Wh = 340;
Fl_Double_Window *window;
class ResizeDialog : public Fl_Group {
public:
ResizeDialog(int X, int Y, int W, int H, const char *T = 0);
Fl_Box *m_icon;
Fl_Box *m_message;
Fl_Button *m_button;
};
ResizeDialog::ResizeDialog(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->align(FL_ALIGN_TOP_LEFT);
this->box(FL_UP_BOX);
m_icon = new Fl_Box(X + 10, Y + 10, 30, 30, "!");
m_icon->box(FL_DOWN_BOX);
m_icon->color(FL_YELLOW);
m_message = new Fl_Box(X + 50, Y + 10, 140, 30, "Out of Memory");
m_message->box(FL_DOWN_BOX);
m_button = new Fl_Button(X + 140, Y + 50, 50, 30, "Darn!");
this->end();
this->resizable(m_icon);
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
ResizeDialog *TL, *TR, *BL, *BR; // topleft, topright, bottomleft, bottomright
Harrow *LA, *RA; // left arrow, right arrow
Varrow *TA, *BA; // top arrow, bottom arrow
};
Resizables::Resizables(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->box(FL_UP_BOX);
this->color(FL_WHITE);
TL = new ResizeDialog(X + TLx, Y + TLy, TLw, TLh, "Original Size");
TL->resizable(0);
TR = new ResizeDialog(X + TRx, Y + TLy, TLw, TLh, "Horizontally Resized");
BL = new ResizeDialog(X + TLx, Y + BLy, TLw, TLh, "Vertically Resized");
BR = new ResizeDialog(X + TRx, Y + BLy, TLw, TLh, "Horizontally and Vertically Resized");
Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
LG->box(FL_NO_BOX);
LG->color(FL_WHITE);
LA = new Harrow(BL->m_icon->x(), LG->y(), BL->m_icon->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(BR->m_icon->x(), LG->y(), BL->m_icon->w(), LAh, "Resized\nwidth");
RG->resizable(RA);
RG->end();
Fl_Group *TG = new Fl_Group(X + TGx, Y + TLy, TGw, TLh);
TG->box(FL_NO_BOX);
TG->color(FL_WHITE);
TA = new Varrow(TG->x(), TR->m_icon->y(), TAw, TR->m_icon->h(), "Initial\nheight");
TG->resizable(TA);
TG->end();
Fl_Group *BG = new Fl_Group(X + TGx, Y + BLy, TGw, TLh);
BG->box(FL_NO_BOX);
BG->color(FL_WHITE);
BA = new Varrow(BG->x(), BR->m_icon->y(), TAw, BR->m_icon->h(), "Resized\nheight");
BG->resizable(BA);
BG->end();
this->resizable(BR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example3a");
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 + 50, Wh + 35);
Fl::visible_focus(0); // suppress focus box
return Fl::run();
}

119
test/resize-example3b.cxx Normal file
View File

@ -0,0 +1,119 @@
//
// 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>
#include <FL/Fl_Button.H>
// resize dialog and arrow dimensions
int TLx = 35, TRx = 270, TGx = 470, TLw = 200, TGw = 120, TAw = 35;
int TLy = 35, BLy = 160, LGy = 250, TLh = 90, LGh = 90, LAh = 35;
// window dimensions
int Ww = 590, Wh = 340;
Fl_Double_Window *window;
class ResizeDialog : public Fl_Group {
public:
ResizeDialog(int X, int Y, int W, int H, const char *T = 0);
Fl_Box *m_icon;
Fl_Box *m_message;
Fl_Button *m_button;
};
ResizeDialog::ResizeDialog(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->align(FL_ALIGN_TOP_LEFT);
this->box(FL_UP_BOX);
m_icon = new Fl_Box(X + 10, Y + 10, 30, 30, "!");
m_icon->box(FL_DOWN_BOX);
m_message = new Fl_Box(X + 50, Y + 10, 140, 30, "Out of Memory");
m_message->box(FL_DOWN_BOX);
m_message->color(FL_YELLOW);
m_button = new Fl_Button(X + 140, Y + 50, 50, 30, "Darn!");
this->end();
this->resizable(m_message);
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
ResizeDialog *TL, *TR, *BL, *BR; // topleft, topright, bottomleft, bottomright
Harrow *LA, *RA; // left arrow, right arrow
Varrow *TA, *BA; // top arrow, bottom arrow
};
Resizables::Resizables(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->box(FL_UP_BOX);
this->color(FL_WHITE);
TL = new ResizeDialog(X + TLx, Y + TLy, TLw, TLh, "Original Size");
TL->resizable(0);
TR = new ResizeDialog(X + TRx, Y + TLy, TLw, TLh, "Horizontally Resized");
BL = new ResizeDialog(X + TLx, Y + BLy, TLw, TLh, "Vertically Resized");
BR = new ResizeDialog(X + TRx, Y + BLy, TLw, TLh, "Horizontally and Vertically Resized");
Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
LG->box(FL_NO_BOX);
LG->color(FL_WHITE);
LA = new Harrow(BL->m_message->x(), LG->y(), BL->m_message->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(BR->m_message->x(), LG->y(), BL->m_message->w(), LAh, "Resized\nwidth");
RG->resizable(RA);
RG->end();
Fl_Group *TG = new Fl_Group(X + TGx, Y + TLy, TGw, TLh);
TG->box(FL_NO_BOX);
TG->color(FL_WHITE);
TA = new Varrow(TG->x(), TR->m_message->y(), TAw, TR->m_message->h(), "Initial\nheight");
TG->resizable(TA);
TG->end();
Fl_Group *BG = new Fl_Group(X + TGx, Y + BLy, TGw, TLh);
BG->box(FL_NO_BOX);
BG->color(FL_WHITE);
BA = new Varrow(BG->x(), BR->m_message->y(), TAw, BR->m_message->h(), "Resized\nheight");
BG->resizable(BA);
BG->end();
this->resizable(BR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example3b");
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 + 50, Wh + 35);
Fl::visible_focus(0); // suppress focus box
return Fl::run();
}

126
test/resize-example3c.cxx Normal file
View File

@ -0,0 +1,126 @@
//
// 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>
#include <FL/Fl_Button.H>
// resize dialog and arrow dimensions
int TLx = 35, TRx = 270, TGx = 470, TLw = 200, TGw = 120, TAw = 35;
int TLy = 35, BLy = 160, LGy = 250, TLh = 90, LGh = 90, LAh = 35;
// window dimensions
int Ww = 590, Wh = 340;
Fl_Double_Window *window;
class ResizeDialog : public Fl_Group {
public:
ResizeDialog(int X, int Y, int W, int H, const char *T = 0);
Fl_Box *m_icon;
Fl_Box *m_message;
Fl_Button *m_button;
};
ResizeDialog::ResizeDialog(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->align(FL_ALIGN_TOP_LEFT);
this->box(FL_UP_BOX);
m_icon = new Fl_Box(X + 10, Y + 10, 30, 30, "!");
m_icon->box(FL_DOWN_BOX);
m_message = new Fl_Box(X + 50, Y + 10, 140, 30, "Out of Memory");
m_message->box(FL_DOWN_BOX);
m_message->color(FL_YELLOW);
Fl_Group *group = new Fl_Group(X + 50, Y + 50, 140, 30);
Fl_Box *b = new Fl_Box(X + 50, Y + 50, 90, 30, "R");
b->box(FL_UP_BOX);
// b->color(FL_YELLOW);
m_button = new Fl_Button(X + 140, Y + 50, 50, 30, "Darn!");
group->resizable(b);
group->end();
this->end();
this->resizable(m_message);
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
ResizeDialog *TL, *TR, *BL, *BR; // topleft, topright, bottomleft, bottomright
Harrow *LA, *RA; // left arrow, right arrow
Varrow *TA, *BA; // top arrow, bottom arrow
};
Resizables::Resizables(int X, int Y, int W, int H, const char *T)
: Fl_Group(X, Y, W, H, T) {
this->box(FL_UP_BOX);
this->color(FL_WHITE);
TL = new ResizeDialog(X + TLx, Y + TLy, TLw, TLh, "Original Size");
TL->resizable(0);
TR = new ResizeDialog(X + TRx, Y + TLy, TLw, TLh, "Horizontally Resized");
BL = new ResizeDialog(X + TLx, Y + BLy, TLw, TLh, "Vertically Resized");
BR = new ResizeDialog(X + TRx, Y + BLy, TLw, TLh, "Horizontally and Vertically Resized");
Fl_Group *LG = new Fl_Group(X + TLx, Y + LGy, TLw, LGh);
LG->box(FL_NO_BOX);
LG->color(FL_WHITE);
LA = new Harrow(BL->m_message->x(), LG->y(), BL->m_message->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(BR->m_message->x(), LG->y(), BL->m_message->w(), LAh, "Resized\nwidth");
RG->resizable(RA);
RG->end();
Fl_Group *TG = new Fl_Group(X + TGx, Y + TLy, TGw, TLh);
TG->box(FL_NO_BOX);
TG->color(FL_WHITE);
TA = new Varrow(TG->x(), TR->m_message->y(), TAw, TR->m_message->h(), "Initial\nheight");
TG->resizable(TA);
TG->end();
Fl_Group *BG = new Fl_Group(X + TGx, Y + BLy, TGw, TLh);
BG->box(FL_NO_BOX);
BG->color(FL_WHITE);
BA = new Varrow(BG->x(), BR->m_message->y(), TAw, BR->m_message->h(), "Resized\nheight");
BG->resizable(BA);
BG->end();
this->resizable(BR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example3c");
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 + 50, Wh + 35);
Fl::visible_focus(0); // suppress focus box
return Fl::run();
}

99
test/resize-example4a.cxx Normal file
View File

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

115
test/resize-example4b.cxx Normal file
View File

@ -0,0 +1,115 @@
//
// 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, complex and arrow dimensions
int TLx = 35, TRx = 320, TLw = 260, Ww = 620;
int TLy = 35, LGy = 100, TLh = 65, LGh = 80, LAh = 35, Wh = 200;
Fl_Double_Window *window = 0;
class Complex : public Fl_Group {
public:
Complex(int X, int Y, int W, int H, const char *T = 0);
Fl_Box *m_button1, *m_input1, *m_button2, *m_input2;
};
Complex::Complex(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 *LG = new Fl_Group(X + 10, Y + 10, 120, 45);
LG->box(FL_UP_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_input1->color(FL_YELLOW);
LG->resizable(m_input1);
LG->end();
Fl_Group *RG = new Fl_Group(X + 130, Y + 10, 120, 45);
RG->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);
RG->resizable(m_input2);
RG->end();
this->end();
}
class Resizables : public Fl_Group {
public:
Resizables(int X, int Y, int W, int H, const char *T = 0);
Complex *TL, *TR; // topleft, topright
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 Complex(X + TLx, Y + TLy, TLw, TLh, "Original");
TL->align(FL_ALIGN_TOP_LEFT);
TR = new Complex(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);
Fl_Group *RG0 = new Fl_Group(X + TRx, Y + LGy, TLw / 2, LGh);
RG0->box(FL_NO_BOX);
RG0->color(FL_WHITE);
RG0->end();
Fl_Group *RG1 = new Fl_Group(X + TRx + TLw / 2, Y + LGy, TLw / 2, LGh);
RG1->box(FL_NO_BOX);
RG1->color(FL_WHITE);
RA = new Harrow(TR->m_input2->x(), RG1->y(), TR->m_input2->w(), LAh, "Resized\nwidth");
RG1->resizable(RA);
RG1->end();
RG->end();
this->resizable(TR);
this->end();
}
int main(int argc, char **argv) {
window = new Fl_Double_Window(Ww, Wh, "resize-example4b");
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();
}