summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-01 18:03:10 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-06 20:28:20 +0200
commitf09e17c3c564e8310125a10c03397cbf473ff643 (patch)
tree8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /examples
parentb0e0c355edaa2e23148cb0260ada907aec930f05 (diff)
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files - update .fl files and generated files accordingly - replace 'http://www.fltk.org' URL's with 'https://...' - replace bug report URL 'str.php' with 'bugs.php' - remove trailing whitespace - fix other whitespace errors flagged by Git - add and/or fix missing or wrong standard headers - convert tabs to spaces in all source files The only relevant code changes are in the fluid/ folder where some .fl files and other source files were used to generate the '$Id' headers and footers.
Diffstat (limited to 'examples')
-rw-r--r--examples/OpenGL3-glut-test.cxx62
-rw-r--r--examples/OpenGL3test.cxx30
-rw-r--r--examples/README.txt8
-rw-r--r--examples/browser-simple.cxx20
-rw-r--r--examples/clipboard.cxx18
-rw-r--r--examples/draggable-group.cxx118
-rw-r--r--examples/fltk-versions.cxx12
-rw-r--r--examples/howto-add_fd-and-popen.cxx32
-rw-r--r--examples/howto-browser-with-icons.cxx18
-rw-r--r--examples/howto-drag-and-drop.cxx110
-rw-r--r--examples/howto-draw-an-x.cxx18
-rw-r--r--examples/howto-menu-with-images.cxx12
-rw-r--r--examples/howto-parse-args.cxx16
-rw-r--r--examples/howto-remap-numpad-keyboard-keys.cxx10
-rw-r--r--examples/howto-simple-svg.cxx60
-rw-r--r--examples/howto-text-over-image-button.cxx40
-rw-r--r--examples/menubar-add.cxx66
-rw-r--r--examples/nativefilechooser-simple-app.cxx58
-rw-r--r--examples/nativefilechooser-simple.cxx42
-rw-r--r--examples/progress-simple.cxx12
-rw-r--r--examples/shapedwindow.cxx12
-rw-r--r--examples/simple-terminal.cxx16
-rw-r--r--examples/table-as-container.cxx114
-rw-r--r--examples/table-simple.cxx30
-rw-r--r--examples/table-sort.cxx50
-rw-r--r--examples/table-spreadsheet-with-keyboard-nav.cxx204
-rw-r--r--examples/table-spreadsheet.cxx212
-rw-r--r--examples/table-with-keynav.cxx218
-rw-r--r--examples/table-with-right-column-stretch-fit.cxx8
-rw-r--r--examples/tabs-simple.cxx42
-rw-r--r--examples/textdisplay-with-colors.cxx34
-rw-r--r--examples/texteditor-simple.cxx30
-rw-r--r--examples/texteditor-with-dynamic-colors.cxx12
-rw-r--r--examples/tree-as-container.cxx60
-rw-r--r--examples/tree-custom-draw-items.cxx46
-rw-r--r--examples/tree-custom-sort.cxx20
-rw-r--r--examples/tree-of-tables.cxx64
-rw-r--r--examples/tree-simple.cxx22
-rw-r--r--examples/wizard-simple.cxx16
39 files changed, 878 insertions, 1094 deletions
diff --git a/examples/OpenGL3-glut-test.cxx b/examples/OpenGL3-glut-test.cxx
index 84c9322a4..4688cde79 100644
--- a/examples/OpenGL3-glut-test.cxx
+++ b/examples/OpenGL3-glut-test.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Tiny OpenGL v3 + glut demo program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2015 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
@@ -32,13 +30,13 @@
// Globals
// Real programs don't use globals :-D
// Data would normally be read from files
-GLfloat vertices[] = { -1.0f,0.0f,0.0f,
+GLfloat vertices[] = { -1.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f };
-GLfloat colours[] = { 1.0f, 0.0f, 0.0f,
+GLfloat colours[] = { 1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f };
-GLfloat vertices2[] = { 0.0f,0.0f,0.0f,
+GLfloat vertices2[] = { 0.0f,0.0f,0.0f,
0.0f,-1.0f,0.0f,
1.0f,0.0f,0.0f };
@@ -52,7 +50,7 @@ void printShaderInfoLog(GLint shader)
{
int infoLogLen = 0;
GLchar *infoLog;
-
+
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLen);
if (infoLogLen > 0)
{
@@ -68,35 +66,35 @@ void printShaderInfoLog(GLint shader)
void init(void)
{
// Would load objects from file here - but using globals in this example
-
+
// Allocate Vertex Array Objects
glGenVertexArrays(2, &vertexArrayObjID[0]);
// Setup first Vertex Array Object
glBindVertexArray(vertexArrayObjID[0]);
glGenBuffers(2, vertexBufferObjID);
-
+
// VBO for vertex data
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[0]);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
-
+
// VBO for colour data
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[1]);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), colours, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)1, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(1);
-
+
// Setup second Vertex Array Object
glBindVertexArray(vertexArrayObjID[1]);
glGenBuffers(1, &vertexBufferObjID[2]);
-
+
// VBO for vertex data
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObjID[2]);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices2, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
-
+
glBindVertexArray(0);
}
@@ -105,10 +103,10 @@ void initShaders(void)
{
GLuint p, f, v;
glClearColor (1.0, 1.0, 1.0, 0.0);
-
+
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
-
+
#ifdef __APPLE__
#define SHADING_LANG_VERS "140"
#else
@@ -124,7 +122,7 @@ void initShaders(void)
ex_Color = in_Color;\
gl_Position = vec4(in_Position, 1.0);\
}";
-
+
const char *ff = "#version "SHADING_LANG_VERS"\n\
precision highp float;\
in vec3 ex_Color;\
@@ -133,12 +131,12 @@ void initShaders(void)
{\
out_Color = vec4(ex_Color,1.0);\
}";
-
+
glShaderSource(v, 1, &vv,NULL);
glShaderSource(f, 1, &ff,NULL);
-
+
GLint compiled;
-
+
glCompileShader(v);
glGetShaderiv(v, GL_COMPILE_STATUS, &compiled);
if (!compiled)
@@ -146,7 +144,7 @@ void initShaders(void)
fprintf(stderr, "Vertex shader not compiled.\n");
printShaderInfoLog(v);
}
-
+
glCompileShader(f);
glGetShaderiv(f, GL_COMPILE_STATUS, &compiled);
if (!compiled)
@@ -154,9 +152,9 @@ void initShaders(void)
fprintf(stderr, "Fragment shader not compiled.\n");
printShaderInfoLog(f);
}
-
+
p = glCreateProgram();
-
+
glAttachShader(p,v);
glAttachShader(p,f);
glBindAttribLocation(p,0, "in_Position");
@@ -180,13 +178,13 @@ void display(void)
{
// clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glBindVertexArray(vertexArrayObjID[0]); // First VAO
- glDrawArrays(GL_TRIANGLES, 0, 3); // draw first object
-
- glBindVertexArray(vertexArrayObjID[1]); // select second VAO
+
+ glBindVertexArray(vertexArrayObjID[0]); // First VAO
+ glDrawArrays(GL_TRIANGLES, 0, 3); // draw first object
+
+ glBindVertexArray(vertexArrayObjID[1]); // select second VAO
glVertexAttrib3f((GLuint)1, 1.0, 0.0, 0.0); // set constant color attribute
- glDrawArrays(GL_TRIANGLES, 0, 3); // draw second object
+ glDrawArrays(GL_TRIANGLES, 0, 3); // draw second object
}
int fullscreen = 0;
@@ -218,7 +216,3 @@ int main (int argc, char* argv[])
glutMainLoop();
return 0;
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/OpenGL3test.cxx b/examples/OpenGL3test.cxx
index b8fe670d5..1b7983529 100644
--- a/examples/OpenGL3test.cxx
+++ b/examples/OpenGL3test.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Tiny OpenGL v3 demo program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2018 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdarg.h>
@@ -86,17 +84,17 @@ public:
glCompileShader(vs);
glGetShaderiv(vs, GL_COMPILE_STATUS, &err);
if (err != GL_TRUE) {
- glGetShaderInfoLog(vs, sizeof(CLOG), &length, CLOG);
- add_output("vs ShaderInfoLog=%s\n",CLOG);
- }
+ glGetShaderInfoLog(vs, sizeof(CLOG), &length, CLOG);
+ add_output("vs ShaderInfoLog=%s\n",CLOG);
+ }
fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, 1, &fss, NULL);
glCompileShader(fs);
glGetShaderiv(fs, GL_COMPILE_STATUS, &err);
if (err != GL_TRUE) {
- glGetShaderInfoLog(fs, sizeof(CLOG), &length, CLOG);
- add_output("fs ShaderInfoLog=%s\n",CLOG);
- }
+ glGetShaderInfoLog(fs, sizeof(CLOG), &length, CLOG);
+ add_output("fs ShaderInfoLog=%s\n",CLOG);
+ }
// Attach the shaders
shaderProgram = glCreateProgram();
glAttachShader(shaderProgram, vs);
@@ -121,11 +119,11 @@ public:
0.5,-0.5,0.0,1.0, 1.0,1.0,1.0,1.0};
glGenVertexArrays(1, &vertexArrayObject);
glBindVertexArray(vertexArrayObject);
-
+
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, 4*8*sizeof(GLfloat), vertexData, GL_STATIC_DRAW);
-
+
glEnableVertexAttribArray((GLuint)positionAttribute);
glEnableVertexAttribArray((GLuint)colourAttribute );
glVertexAttribPointer((GLuint)positionAttribute, 4, GL_FLOAT, GL_FALSE, 8*sizeof(GLfloat), 0);
@@ -157,7 +155,7 @@ public:
if (gl_version_major < 3) add_output("\nThis platform does not support OpenGL V3\n\n");
redraw();
}
-
+
if (event == FL_PUSH && gl_version_major >= 3) {
static float factor = 1.1;
GLfloat data[4];
@@ -229,7 +227,3 @@ int main(int argc, char **argv)
Fl::run();
}
-//
-// End of "$Id$".
-//
-
diff --git a/examples/README.txt b/examples/README.txt
index d1a53821d..024bafffe 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -19,7 +19,7 @@ FLTK EXAMPLE PROGRAMS
misused or hard to document
o Demonstrate code that are FAQs on the newsgroup forum.
- (such as how to use threads, callbacks, etc)
+ (such as how to use threads, callbacks, etc)
o Example code should be short, but not at the expense of clarity.
@@ -119,5 +119,7 @@ DISCLAIMER
BUGS
- If you find a bug, please report it through the fltk STR form at
- https://www.fltk.org/str.php
+ If you find a bug, please report it to the FLTK team. For more
+ information on how to do this see this page:
+
+ https://www.fltk.org/bugs.php
diff --git a/examples/browser-simple.cxx b/examples/browser-simple.cxx
index 2bd1e1a2d..4198424e4 100644
--- a/examples/browser-simple.cxx
+++ b/examples/browser-simple.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Simple Fl_Browser widget example. - erco 07/26/2019
+// Simple Fl_Browser widget example. - erco 07/26/2019
//
// Copyright 2019 Greg Ercolano.
// Copyright 1998-2016 by Bill Spitzak and others.
@@ -10,11 +8,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <FL/Fl.H>
@@ -38,7 +36,7 @@ void MultiBrowserCallback(Fl_Widget *w, void *data) {
Fl_Multi_Browser *brow = (Fl_Multi_Browser*)w;
// Multi browser can have many items selected, so print all selected
for ( int t=1; t<=brow->size(); t++ )
- if ( brow->selected(t) )
+ if ( brow->selected(t) )
printf("[multi browser] item %d selected: %s\n", t, brow->text(t));
printf("\n");
}
@@ -51,7 +49,7 @@ int main(int argc, char *argv[]) {
{
// Create Hold Browser
Fl_Hold_Browser *brow = new Fl_Hold_Browser(10, 10, win->w()-20, 80, "Hold");
- brow->callback(HoldBrowserCallback); // callback for hold browser
+ brow->callback(HoldBrowserCallback); // callback for hold browser
// Add some items
brow->add("One");
brow->add("Two");
@@ -63,7 +61,7 @@ int main(int argc, char *argv[]) {
{
// Create Multi Browser
Fl_Multi_Browser *brow = new Fl_Multi_Browser(10, 120, win->w()-20, 80, "Multi");
- brow->callback(MultiBrowserCallback); // callback for multi browser
+ brow->callback(MultiBrowserCallback); // callback for multi browser
// Add some items
brow->add("Aaa");
brow->add("Bbb");
@@ -79,7 +77,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/clipboard.cxx b/examples/clipboard.cxx
index bb0a62d0e..4b4d921c6 100644
--- a/examples/clipboard.cxx
+++ b/examples/clipboard.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Clipboard display test application for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2014 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl_Window.H>
@@ -56,9 +54,9 @@ public:
fl_color(FL_LIGHT2);
const int side = 4, side2 = 2*side;
for (int j=Y; j<Y+H; j+=side) {
- for (int i=X + (j-Y)%side2; i<X+W; i+=side2) {
- fl_rectf(i,j,side,side);
- }
+ for (int i=X + (j-Y)%side2; i<X+W; i+=side2) {
+ fl_rectf(i,j,side,side);
+ }
}
fl_pop_clip();
fl_pop_clip();
@@ -160,7 +158,3 @@ int main(int argc, char **argv)
Fl_Image::RGB_scaling(FL_RGB_SCALING_BILINEAR); // set bilinear image scaling method
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/draggable-group.cxx b/examples/draggable-group.cxx
index eee143fe6..9bfd4694f 100644
--- a/examples/draggable-group.cxx
+++ b/examples/draggable-group.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Demonstrate deriving a class with draggable children.
//
// Copyright 2017 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
// K Dmitrij <kdiman@...> wrote on Wed, 26 Jul 2017 19:54:12 +0000 in
@@ -99,70 +97,70 @@ public:
switch (e) {
case FL_PUSH: {
- if (Fl::event_button() == FL_RIGHT_MOUSE) {
- if (Fl::belowmouse()->parent() == this) {
- drag_widget = Fl::belowmouse();
-
- // save pointer offsets relative to drag_widget's x/y position
- xoff = Fl::event_x() - drag_widget->x();
- yoff = Fl::event_y() - drag_widget->y();
-
- top_level(drag_widget); // raise to top for visible feedback
- redraw();
- return 1;
- }
- }
- break;
+ if (Fl::event_button() == FL_RIGHT_MOUSE) {
+ if (Fl::belowmouse()->parent() == this) {
+ drag_widget = Fl::belowmouse();
+
+ // save pointer offsets relative to drag_widget's x/y position
+ xoff = Fl::event_x() - drag_widget->x();
+ yoff = Fl::event_y() - drag_widget->y();
+
+ top_level(drag_widget); // raise to top for visible feedback
+ redraw();
+ return 1;
+ }
+ }
+ break;
}
case FL_DRAG: {
- if (!drag_widget)
- break;
+ if (!drag_widget)
+ break;
- int nX = Fl::event_x() - xoff; // new x coordinate
- int nY = Fl::event_y() - yoff; // new y coordinate
+ int nX = Fl::event_x() - xoff; // new x coordinate
+ int nY = Fl::event_y() - yoff; // new y coordinate
- int bbx = Fl::box_dx(box()); // left and right border width
- int bby = Fl::box_dy(box()); // top and bottom border width
+ int bbx = Fl::box_dx(box()); // left and right border width
+ int bby = Fl::box_dy(box()); // top and bottom border width
- // keep the widget inside its parent's borders
+ // keep the widget inside its parent's borders
- if (nX < x() + bbx) {
- nX = x() + bbx;
- } else if (nX + drag_widget->w() > x() + w() - bbx) {
- nX = x() + w() - drag_widget->w() - bbx;
- }
+ if (nX < x() + bbx) {
+ nX = x() + bbx;
+ } else if (nX + drag_widget->w() > x() + w() - bbx) {
+ nX = x() + w() - drag_widget->w() - bbx;
+ }
- if (nY < y() + bby) {
- nY = y() + bby;
- } else if (nY + drag_widget->h() > y() + h() - bby) {
- nY = y() + h() - drag_widget->h() - bby;
- }
+ if (nY < y() + bby) {
+ nY = y() + bby;
+ } else if (nY + drag_widget->h() > y() + h() - bby) {
+ nY = y() + h() - drag_widget->h() - bby;
+ }
- drag_widget->position(nX, nY); // set the new position
- redraw();
- return 1;
+ drag_widget->position(nX, nY); // set the new position
+ redraw();
+ return 1;
}
case FL_RELEASE: {
- if (drag_widget && Fl::event_button() == FL_RIGHT_MOUSE) {
-
- // Optional: restore the original widget order in the group.
- // Remove the next statement (or comment it out) if not desired.
- insert(*drag_widget, drag_index);
-
- init_sizes(); // save widget positions for later resizing
- drag_widget = 0;
- redraw();
- if (parent())
- parent()->redraw();
- return 1;
- }
- break;
+ if (drag_widget && Fl::event_button() == FL_RIGHT_MOUSE) {
+
+ // Optional: restore the original widget order in the group.
+ // Remove the next statement (or comment it out) if not desired.
+ insert(*drag_widget, drag_index);
+
+ init_sizes(); // save widget positions for later resizing
+ drag_widget = 0;
+ redraw();
+ if (parent())
+ parent()->redraw();
+ return 1;
+ }
+ break;
}
default:
- break;
+ break;
} // switch(e)
return Fl_Group::handle(e);
@@ -189,11 +187,11 @@ void button_cb(Fl_Widget *w, void *v) {
// tooltips:
-const char *tt_drag = "Drag this DraggableGroup and/or its child groups and squares. "
- "Use the right mouse button (MB3) to drag objects.";
-const char *tt_group = "You can drag this Fl_Group, but not its children (squares).";
+const char *tt_drag = "Drag this DraggableGroup and/or its child groups and squares. "
+ "Use the right mouse button (MB3) to drag objects.";
+const char *tt_group = "You can drag this Fl_Group, but not its children (squares).";
const char *tt_button = "You can drag this button with the right mouse button "
- "and you can click it with the left mouse button.";
+ "and you can click it with the left mouse button.";
// main program:
@@ -270,7 +268,3 @@ int main() {
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/fltk-versions.cxx b/examples/fltk-versions.cxx
index c68353990..ed80c7b1f 100644
--- a/examples/fltk-versions.cxx
+++ b/examples/fltk-versions.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Library version test program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2017 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
@@ -78,7 +76,3 @@ int main(int argc, char **argv) {
window->show(argc, argv);
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-add_fd-and-popen.cxx b/examples/howto-add_fd-and-popen.cxx
index 285a377f3..c6afe5049 100644
--- a/examples/howto-add_fd-and-popen.cxx
+++ b/examples/howto-add_fd-and-popen.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// How to use popen() and Fl::add_fd() - erco 10/04/04
// Originally from erco's cheat sheet, permission by author.
//
@@ -16,11 +14,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <FL/Fl.H>
@@ -28,16 +26,16 @@
#include <FL/Fl_Multi_Browser.H>
#ifdef _WIN32
-# define PING_CMD "ping -n 10 localhost" // 'slow command' under windows
+# define PING_CMD "ping -n 10 localhost" // 'slow command' under windows
# ifdef _MSC_VER
# define popen _popen
# define pclose _pclose
# else /*_MSC_VER*/
-# include <unistd.h> // non-MS win32 compilers (untested)
+# include <unistd.h> // non-MS win32 compilers (untested)
# endif /*_MSC_VER*/
#else
# include <unistd.h>
-# define PING_CMD "ping -i 2 -c 10 localhost" // 'slow command' under unix
+# define PING_CMD "ping -i 2 -c 10 localhost" // 'slow command' under unix
#endif
// GLOBALS
@@ -49,28 +47,24 @@ FILE *G_fp = NULL;
void HandleFD(FL_SOCKET fd, void *data) {
Fl_Multi_Browser *brow = (Fl_Multi_Browser*)data;
char s[1024];
- if ( fgets(s, 1023, G_fp) == NULL ) { // read the line of data
- Fl::remove_fd(fileno(G_fp)); // command ended? disconnect callback
- pclose(G_fp); // close the descriptor
- brow->add(""); brow->add("<<DONE>>"); // append msg indicating command finished
+ if ( fgets(s, 1023, G_fp) == NULL ) { // read the line of data
+ Fl::remove_fd(fileno(G_fp)); // command ended? disconnect callback
+ pclose(G_fp); // close the descriptor
+ brow->add(""); brow->add("<<DONE>>"); // append msg indicating command finished
return;
}
- brow->add(s); // line of data read? append to widget
+ brow->add(s); // line of data read? append to widget
}
int main(int argc, char *argv[]) {
Fl_Window win(600,600);
Fl_Multi_Browser brow(10,10,580,580);
- if ( ( G_fp = popen(PING_CMD, "r") ) == NULL ) { // start the external unix command
+ if ( ( G_fp = popen(PING_CMD, "r") ) == NULL ) { // start the external unix command
perror("popen failed");
return(1);
}
- Fl::add_fd(fileno(G_fp), HandleFD, (void*)&brow); // setup a callback for the popen()ed descriptor
+ Fl::add_fd(fileno(G_fp), HandleFD, (void*)&brow); // setup a callback for the popen()ed descriptor
win.resizable(brow);
win.show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-browser-with-icons.cxx b/examples/howto-browser-with-icons.cxx
index d21d53f49..965b3fc94 100644
--- a/examples/howto-browser-with-icons.cxx
+++ b/examples/howto-browser-with-icons.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Demonstrate creating an Fl_Browser with icons - Greg Ercolano 10/07/09 (STR#1739)
//
// Shows how one can add icons to items in a browser.
@@ -12,12 +10,12 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
//
-// Please report all bugs and problems on the following page:
+// https://www.fltk.org/bugs.php
//
-// http://www.fltk.org/str.php
-//
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Browser.H>
@@ -147,7 +145,7 @@ public:
// See which icon the user picked
Fl_Image *i = 0;
- if ( strcmp(ch->text(), "None" ) == 0 ) { i = 0; }
+ if ( strcmp(ch->text(), "None" ) == 0 ) { i = 0; }
else if ( strcmp(ch->text(), "Small" ) == 0 ) { i = mb->sml_icon; }
else if ( strcmp(ch->text(), "Medium") == 0 ) { i = mb->med_icon; }
else if ( strcmp(ch->text(), "Large" ) == 0 ) { i = mb->big_icon; }
@@ -179,8 +177,4 @@ int main() {
w->end();
w->show();
return(Fl::run());
-}
-
-//
-// End of "$Id$".
-//
+}
diff --git a/examples/howto-drag-and-drop.cxx b/examples/howto-drag-and-drop.cxx
index 98829c39c..35a45ed25 100644
--- a/examples/howto-drag-and-drop.cxx
+++ b/examples/howto-drag-and-drop.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// A simple demo of 'drag and drop' with FLTK.
// Originally from erco's cheat sheet, permission by author.
// Inspired by Michael Sephton's original example posted on fltk.general.
@@ -17,11 +15,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
@@ -45,10 +43,10 @@ public:
switch ( event ) {
case FL_PUSH: { // do 'copy/dnd' when someone clicks on box
const char *msg = "It works!";
- Fl::copy(msg,strlen(msg),0);
- Fl::dnd();
- ret = 1;
- break;
+ Fl::copy(msg,strlen(msg),0);
+ Fl::dnd();
+ ret = 1;
+ break;
}
}
return(ret);
@@ -70,55 +68,55 @@ public:
int ret = Fl_Box::handle(event);
int len;
switch ( event ) {
- case FL_DND_ENTER: // return(1) for this event to 'accept' dnd
- label("ENTER"); // visible only if you stop the mouse at the widget's border
- fprintf(stderr, "FL_DND_ENTER\n");
- dnd_inside = 1; // status: inside the widget, accept drop
- ret = 1;
- break;
- case FL_DND_DRAG: // return(1) for this event to 'accept' dnd
- label("drop\nhere");
- fprintf(stderr, "FL_DND_DRAG\n");
- ret = 1;
- break;
- case FL_DND_RELEASE: // return(1) for this event to 'accept' the payload (drop)
- fprintf(stderr, "FL_DND_RELEASE\n");
- if (dnd_inside) {
- ret = 1; // return(1) and expect FL_PASTE event to follow
- label("RELEASE");
- } else {
- ret = 0; // return(0) to reject the DND payload (drop)
- label("DND\nREJECTED!");
- }
- break;
+ case FL_DND_ENTER: // return(1) for this event to 'accept' dnd
+ label("ENTER"); // visible only if you stop the mouse at the widget's border
+ fprintf(stderr, "FL_DND_ENTER\n");
+ dnd_inside = 1; // status: inside the widget, accept drop
+ ret = 1;
+ break;
+ case FL_DND_DRAG: // return(1) for this event to 'accept' dnd
+ label("drop\nhere");
+ fprintf(stderr, "FL_DND_DRAG\n");
+ ret = 1;
+ break;
+ case FL_DND_RELEASE: // return(1) for this event to 'accept' the payload (drop)
+ fprintf(stderr, "FL_DND_RELEASE\n");
+ if (dnd_inside) {
+ ret = 1; // return(1) and expect FL_PASTE event to follow
+ label("RELEASE");
+ } else {
+ ret = 0; // return(0) to reject the DND payload (drop)
+ label("DND\nREJECTED!");
+ }
+ break;
case FL_PASTE: // handle actual drop (paste) operation
- fprintf(stderr, "FL_PASTE\n");
- copy_label(Fl::event_text());
- fprintf(stderr, "Pasted '%s'\n", Fl::event_text());
+ fprintf(stderr, "FL_PASTE\n");
+ copy_label(Fl::event_text());
+ fprintf(stderr, "Pasted '%s'\n", Fl::event_text());
- // Don't pop up dialog windows in FL_DND_* or FL_PASTE event handling
- // resulting from DND operations. This may hang or even crash the
- // application on *some* platforms. Use a short timer to delay the
- // message display after the event processing is completed.
+ // Don't pop up dialog windows in FL_DND_* or FL_PASTE event handling
+ // resulting from DND operations. This may hang or even crash the
+ // application on *some* platforms. Use a short timer to delay the
+ // message display after the event processing is completed.
- delete[] dnd_text; // don't leak (just in case)
- dnd_text = 0;
+ delete[] dnd_text; // don't leak (just in case)
+ dnd_text = 0;
- len = Fl::event_length();
- if (len && Fl::event_text()) {
- dnd_text = new char[len + 1];
- memcpy(dnd_text, Fl::event_text(), len);
- dnd_text[len] = '\0';
- Fl::add_timeout(0.001, timer_cb, this); // delay message popup
- }
- ret = 1;
- break;
- case FL_DND_LEAVE: // not strictly necessary to return(1) for this event
- label("..to\nhere"); // reset label
- fprintf(stderr, "FL_DND_LEAVE\n");
- dnd_inside = 0; // status: mouse is outside, don't accept drop
- ret = 1; // return(1) anyway..
- break;
+ len = Fl::event_length();
+ if (len && Fl::event_text()) {
+ dnd_text = new char[len + 1];
+ memcpy(dnd_text, Fl::event_text(), len);
+ dnd_text[len] = '\0';
+ Fl::add_timeout(0.001, timer_cb, this); // delay message popup
+ }
+ ret = 1;
+ break;
+ case FL_DND_LEAVE: // not strictly necessary to return(1) for this event
+ label("..to\nhere"); // reset label
+ fprintf(stderr, "FL_DND_LEAVE\n");
+ dnd_inside = 0; // status: mouse is outside, don't accept drop
+ ret = 1; // return(1) anyway..
+ break;
}
return(ret);
}
@@ -152,7 +150,3 @@ int main(int argc, char **argv) {
win_b.show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-draw-an-x.cxx b/examples/howto-draw-an-x.cxx
index 4c0038f0d..c1bce5b0f 100644
--- a/examples/howto-draw-an-x.cxx
+++ b/examples/howto-draw-an-x.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Demonstrate how to draw an 'X' in fltk
//
// Create a custom widget that draws an 'X' to the corners of the window,
@@ -14,11 +12,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
@@ -31,7 +29,7 @@ public:
}
void draw() {
// Draw background - a white filled rectangle
- fl_color(FL_WHITE); fl_rectf(x(),y(),w(),h());
+ fl_color(FL_WHITE); fl_rectf(x(),y(),w(),h());
// Draw black 'X' over base widget's background
fl_color(FL_BLACK);
int x1 = x(), y1 = y();
@@ -42,13 +40,9 @@ public:
};
int main() {
Fl_Double_Window win(200,200,"Draw X");
- DrawX draw_x(10, 10, win.w()-20, win.h()-20); // put our widget 10 pixels within window edges
- draw_x.color(FL_WHITE); // make widget's background white
+ DrawX draw_x(10, 10, win.w()-20, win.h()-20); // put our widget 10 pixels within window edges
+ draw_x.color(FL_WHITE); // make widget's background white
win.resizable(draw_x);
win.show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-menu-with-images.cxx b/examples/howto-menu-with-images.cxx
index 04b01c1fb..1262ffd38 100644
--- a/examples/howto-menu-with-images.cxx
+++ b/examples/howto-menu-with-images.cxx
@@ -1,4 +1,4 @@
-// "$Id$"
+//
// vim: autoindent tabstop=2 shiftwidth=2 expandtab softtabstop=2 filetype=cpp
//
// How to use Fl_Multi_Label to make menu items with images and labels.
@@ -10,11 +10,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
@@ -200,7 +200,3 @@ int main() {
win->show();
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-parse-args.cxx b/examples/howto-parse-args.cxx
index 19230cf9f..a95e2a66f 100644
--- a/examples/howto-parse-args.cxx
+++ b/examples/howto-parse-args.cxx
@@ -1,8 +1,6 @@
//
-// "$Id$"
-//
// How to parse command line arguments - Duncan Gibson 2010-10-23
-// First posted in http://www.fltk.org/newsgroups.php?gfltk.general+v:31449
+// First posted in https://www.fltk.org/newsgroups.php?gfltk.general+v:31449
//
// Shows how to decode additional command line arguments using Fl::args()
// on top of the "standard" options used by the toolkit itself.
@@ -17,11 +15,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <string.h>
@@ -37,7 +35,7 @@ char *optionString = 0;
* If there is a match, 'i' must be incremented by 2 or 1 as appropriate.
* If there is no match, Fl::args() will then call Fl::arg() as fallback
* to try to match the "standard" FLTK parameters.
- *
+ *
* Returns 2 if argv[i] matches with required parameter in argv[i+1],
* returns 1 if argv[i] matches on its own,
* returns 0 if argv[i] does not match.
@@ -87,7 +85,3 @@ int main(int argc, char** argv)
mainWin->show(argc, argv);
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-remap-numpad-keyboard-keys.cxx b/examples/howto-remap-numpad-keyboard-keys.cxx
index 049b8e203..20639224d 100644
--- a/examples/howto-remap-numpad-keyboard-keys.cxx
+++ b/examples/howto-remap-numpad-keyboard-keys.cxx
@@ -1,7 +1,5 @@
// vim: autoindent tabstop=8 shiftwidth=2 expandtab softtabstop=2
//
-// "$Id$"
-//
// Demonstrate keyboard remapping: Force number pad to type numbers even if NumLock off
//
// DESCRIPTION
@@ -31,11 +29,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
@@ -49,7 +47,7 @@ Fl_Check_Button *G_checkbut = 0;
// Global event handler: FLTK calls this after event translation. It's up to us
// to call Fl::handle_(e,w) to actually deliver the event to the widgets. If we
// don't and just return, the event will be dropped. See docs for more.
-//
+//
int MyHandler(int e, Fl_Window *w) {
// Remapping disabled? Early exit..
if ( G_checkbut->value() == 0 ) return Fl::handle_(e, w);
diff --git a/examples/howto-simple-svg.cxx b/examples/howto-simple-svg.cxx
index b9f41fd71..d70f0407a 100644
--- a/examples/howto-simple-svg.cxx
+++ b/examples/howto-simple-svg.cxx
@@ -1,8 +1,6 @@
//
-// "$Id$"
-//
-// Simple example of how to use an SVG image in an FLTK program.
-// Assumes fltk was built with --enable-nanosvg.
+// Simple example of how to use an SVG image in an FLTK program.
+// Assumes fltk was built with --enable-nanosvg.
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
@@ -10,13 +8,13 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
-#include <config.h> /* needed only to detect FLTK_USE_NANOSVG */
+#include <config.h> /* needed only to detect FLTK_USE_NANOSVG */
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
@@ -30,28 +28,28 @@ const char *svg_logo =
"<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->\n"
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
"<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n"
- " width=\"640px\" height=\"480px\" viewBox=\"0 0 640 480\" enable-background=\"new 0 0 640 480\" xml:space=\"preserve\">\n"
+ " width=\"640px\" height=\"480px\" viewBox=\"0 0 640 480\" enable-background=\"new 0 0 640 480\" xml:space=\"preserve\">\n"
"<path d=\"M282.658,250.271c0,5.31-1.031,10.156-3.087,14.543c-2.059,4.387-4.984,8.152-8.774,11.293\n"
- " c-3.793,3.144-8.477,5.58-14.055,7.312c-5.581,1.731-11.836,2.601-18.767,2.601c-9.968,0-18.605-1.572-25.917-4.713\n"
- " s-13.299-6.986-17.955-11.536l13.812-15.111c4.116,3.684,8.584,6.499,13.405,8.449c4.819,1.95,9.993,2.925,15.518,2.925\n"
- " c5.525,0,9.856-1.219,12.999-3.656c3.141-2.438,4.712-5.769,4.712-9.993c0-2.056-0.3-3.844-0.894-5.361\n"
- " c-0.596-1.517-1.653-2.925-3.168-4.226c-1.518-1.3-3.549-2.519-6.093-3.655c-2.546-1.138-5.768-2.301-9.668-3.494\n"
- " c-6.5-2.056-11.943-4.25-16.33-6.58c-4.387-2.328-7.937-4.9-10.643-7.719c-2.709-2.815-4.659-5.931-5.849-9.343\n"
- " c-1.193-3.412-1.788-7.23-1.788-11.455c0-5.2,1.082-9.831,3.25-13.893c2.166-4.062,5.144-7.5,8.937-10.318\n"
- " c3.791-2.815,8.178-4.956,13.162-6.418c4.981-1.462,10.343-2.193,16.086-2.193c8.449,0,15.842,1.247,22.179,3.737\n"
- " c6.337,2.493,11.997,6.121,16.98,10.887l-12.674,14.624c-7.583-6.281-15.655-9.424-24.21-9.424c-4.875,0-8.721,0.95-11.537,2.844\n"
- " c-2.818,1.896-4.225,4.578-4.225,8.043c0,1.843,0.297,3.412,0.894,4.712c0.594,1.3,1.65,2.519,3.168,3.656\n"
- " c1.516,1.137,3.656,2.249,6.418,3.331c2.763,1.084,6.309,2.33,10.643,3.736c5.306,1.734,10.046,3.631,14.218,5.688\n"
- " c4.169,2.06,7.662,4.524,10.48,7.394c2.815,2.871,4.981,6.174,6.5,9.911C281.898,240.603,282.658,245.071,282.658,250.271z\n"
- " M335.953,260.833l20.637-90.181h27.46l-32.011,112.604h-33.634l-32.173-112.604h28.598l20.311,90.181H335.953z M437.832,286.019\n"
- " c-16.357,0-28.896-5.01-37.615-15.03c-8.722-10.019-13.081-24.779-13.081-44.278c0-9.531,1.407-17.98,4.225-25.348\n"
- " c2.815-7.366,6.688-13.54,11.618-18.524c4.928-4.981,10.668-8.747,17.223-11.293c6.555-2.544,13.568-3.818,21.043-3.818\n"
- " c8.23,0,15.436,1.3,21.611,3.899c6.174,2.6,11.537,5.959,16.086,10.075l-14.137,14.624c-3.467-3.032-6.906-5.281-10.318-6.744\n"
- " s-7.393-2.193-11.941-2.193c-4.01,0-7.693,0.731-11.051,2.193s-6.256,3.793-8.691,6.987c-2.438,3.196-4.334,7.287-5.688,12.268\n"
- " c-1.355,4.984-2.031,10.996-2.031,18.037c0,7.367,0.486,13.567,1.463,18.604c0.975,5.037,2.408,9.1,4.305,12.187\n"
- " c1.895,3.087,4.307,5.309,7.23,6.662c2.926,1.355,6.338,2.031,10.238,2.031c5.631,0,10.613-1.244,14.947-3.737v-25.186h-14.785\n"
- " l-2.6-18.849h43.547v55.57c-5.85,3.793-12.297,6.718-19.336,8.774C453.051,284.987,445.631,286.019,437.832,286.019z M523.5,151.5\n"
- " c0-6.627-5.373-12-12-12h-343c-6.627,0-12,5.373-12,12v150c0,6.627,5.373,12,12,12h343c6.627,0,12-5.373,12-12V151.5z\"/>\n"
+ " c-3.793,3.144-8.477,5.58-14.055,7.312c-5.581,1.731-11.836,2.601-18.767,2.601c-9.968,0-18.605-1.572-25.917-4.713\n"
+ " s-13.299-6.986-17.955-11.536l13.812-15.111c4.116,3.684,8.584,6.499,13.405,8.449c4.819,1.95,9.993,2.925,15.518,2.925\n"
+ " c5.525,0,9.856-1.219,12.999-3.656c3.141-2.438,4.712-5.769,4.712-9.993c0-2.056-0.3-3.844-0.894-5.361\n"
+ " c-0.596-1.517-1.653-2.925-3.168-4.226c-1.518-1.3-3.549-2.519-6.093-3.655c-2.546-1.138-5.768-2.301-9.668-3.494\n"
+ " c-6.5-2.056-11.943-4.25-16.33-6.58c-4.387-2.328-7.937-4.9-10.643-7.719c-2.709-2.815-4.659-5.931-5.849-9.343\n"
+ " c-1.193-3.412-1.788-7.23-1.788-11.455c0-5.2,1.082-9.831,3.25-13.893c2.166-4.062,5.144-7.5,8.937-10.318\n"
+ " c3.791-2.815,8.178-4.956,13.162-6.418c4.981-1.462,10.343-2.193,16.086-2.193c8.449,0,15.842,1.247,22.179,3.737\n"
+ " c6.337,2.493,11.997,6.121,16.98,10.887l-12.674,14.624c-7.583-6.281-15.655-9.424-24.21-9.424c-4.875,0-8.721,0.95-11.537,2.844\n"
+ " c-2.818,1.896-4.225,4.578-4.225,8.043c0,1.843,0.297,3.412,0.894,4.712c0.594,1.3,1.65,2.519,3.168,3.656\n"
+ " c1.516,1.137,3.656,2.249,6.418,3.331c2.763,1.084,6.309,2.33,10.643,3.736c5.306,1.734,10.046,3.631,14.218,5.688\n"
+ " c4.169,2.06,7.662,4.524,10.48,7.394c2.815,2.871,4.981,6.174,6.5,9.911C281.898,240.603,282.658,245.071,282.658,250.271z\n"
+ " M335.953,260.833l20.637-90.181h27.46l-32.011,112.604h-33.634l-32.173-112.604h28.598l20.311,90.181H335.953z M437.832,286.019\n"
+ " c-16.357,0-28.896-5.01-37.615-15.03c-8.722-10.019-13.081-24.779-13.081-44.278c0-9.531,1.407-17.98,4.225-25.348\n"
+ " c2.815-7.366,6.688-13.54,11.618-18.524c4.928-4.981,10.668-8.747,17.223-11.293c6.555-2.544,13.568-3.818,21.043-3.818\n"
+ " c8.23,0,15.436,1.3,21.611,3.899c6.174,2.6,11.537,5.959,16.086,10.075l-14.137,14.624c-3.467-3.032-6.906-5.281-10.318-6.744\n"
+ " s-7.393-2.193-11.941-2.193c-4.01,0-7.693,0.731-11.051,2.193s-6.256,3.793-8.691,6.987c-2.438,3.196-4.334,7.287-5.688,12.268\n"
+ " c-1.355,4.984-2.031,10.996-2.031,18.037c0,7.367,0.486,13.567,1.463,18.604c0.975,5.037,2.408,9.1,4.305,12.187\n"
+ " c1.895,3.087,4.307,5.309,7.23,6.662c2.926,1.355,6.338,2.031,10.238,2.031c5.631,0,10.613-1.244,14.947-3.737v-25.186h-14.785\n"
+ " l-2.6-18.849h43.547v55.57c-5.85,3.793-12.297,6.718-19.336,8.774C453.051,284.987,445.631,286.019,437.832,286.019z M523.5,151.5\n"
+ " c0-6.627-5.373-12-12-12h-343c-6.627,0-12,5.373-12,12v150c0,6.627,5.373,12,12,12h343c6.627,0,12-5.373,12-12V151.5z\"/>\n"
"</svg>\n";
int main(int argc, char **argv) {
@@ -68,7 +66,3 @@ int main(int argc, char **argv) {
return(Fl::run());
#endif
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/howto-text-over-image-button.cxx b/examples/howto-text-over-image-button.cxx
index f102dc70b..f0861a9c1 100644
--- a/examples/howto-text-over-image-button.cxx
+++ b/examples/howto-text-over-image-button.cxx
@@ -1,16 +1,14 @@
//
-// "$Id$"
+// Simple example of a button with text over an image
+// Originally from erco's cheat sheet 10/25/2010, permission by author.
//
-// Simple example of a button with text over an image
-// Originally from erco's cheat sheet 10/25/2010, permission by author.
+// This shows how to include an 'inline' image (.xpm)
+// and have it appear on an Fl_Button. Demonstrates the use of the
+// FL_ALIGN_IMAGE_BACKDROP align() flag (new in FLTK 1.3.0).
//
-// This shows how to include an 'inline' image (.xpm)
-// and have it appear on an Fl_Button. Demonstrates the use of the
-// FL_ALIGN_IMAGE_BACKDROP align() flag (new in FLTK 1.3.0).
-//
-// Note that the XPM can just as easily be in an #include file,
-// but to keep the example self contained, the image (a gray scale
-// gradient) is included here.
+// Note that the XPM can just as easily be in an #include file,
+// but to keep the example self contained, the image (a gray scale
+// gradient) is included here.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -19,11 +17,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
@@ -33,12 +31,12 @@
/* XPM */
static const char * gradient_xpm[] = {
"135 20 26 1",
-"a c #e0e0e0", "b c #dcdcdc", "c c #d8d8d8", "d c #d4d4d4", "e c #d2d2d2",
-"f c #d0d0d0", "g c #cccccc", "h c #c8c8c8", "i c #c4c4c4", "j c #c2c2c2",
-"k c #c0c0c0", "l c #bcbcbc", "m c #b8b8b8", "n c #b4b4b4", "o c #b2b2b2",
-"p c #b0b0b0", "q c #acacac", "r c #a8a8a8", "s c #a4a4a4", "t c #a2a2a2",
-"u c #a0a0a0", "v c #9c9c9c", "w c #989898", "x c #949494", "y c #929292",
-"z c #909090",
+"a c #e0e0e0", "b c #dcdcdc", "c c #d8d8d8", "d c #d4d4d4", "e c #d2d2d2",
+"f c #d0d0d0", "g c #cccccc", "h c #c8c8c8", "i c #c4c4c4", "j c #c2c2c2",
+"k c #c0c0c0", "l c #bcbcbc", "m c #b8b8b8", "n c #b4b4b4", "o c #b2b2b2",
+"p c #b0b0b0", "q c #acacac", "r c #a8a8a8", "s c #a4a4a4", "t c #a2a2a2",
+"u c #a0a0a0", "v c #9c9c9c", "w c #989898", "x c #949494", "y c #929292",
+"z c #909090",
"aaaaaaaaabbbbbbbbcccccccddddddeeeeeefffffffgggggggghhhhhhhiiiiiiijjjjjjjkkkkkkkklllllllmmmmmmmnnnnnnnnnoooooooppppppppqqqqqqrrrrrrrssss",
"aaaaaabbbbbbbbcccccccddddddeeeeeefffffffgggggggghhhhhhhiiiiiiijjjjjjjkkkkkkkklllllllmmmmmmmnnnnnnnnnoooooooppppppppqqqqqqrrrrrrrsssssst",
"aaabbbbbbbbcccccccddddddeeeeeefffffffgggggggghhhhhhhiiiiiiijjjjjjjkkkkkkkklllllllmmmmmmmnnnnnnnnnoooooooppppppppqqqqqqrrrrrrrsssssssstt",
@@ -76,7 +74,3 @@ int main(int argc, char **argv) {
win->show(argc,argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/menubar-add.cxx b/examples/menubar-add.cxx
index 2284b2bc4..6326d4865 100644
--- a/examples/menubar-add.cxx
+++ b/examples/menubar-add.cxx
@@ -1,16 +1,14 @@
//
-// "$Id$"
+// An example of using Fl_Menu_Bar's add() to dynamically create menubars
//
-// An example of using Fl_Menu_Bar's add() to dynamically create menubars
+// Menu bars can be created several ways. Using add() allows
+// dynamically creating a menubar using a 'pathname' syntax.
+// Use if you're creating items dynamically, or if you're making
+// menubars by hand (as opposed to using fluid), as it's easier
+// to type and read.
//
-// Menu bars can be created several ways. Using add() allows
-// dynamically creating a menubar using a 'pathname' syntax.
-// Use if you're creating items dynamically, or if you're making
-// menubars by hand (as opposed to using fluid), as it's easier
-// to type and read.
-//
-// In this case we're using one callback for all items,
-// but you can make unique callbacks for each item if needed.
+// In this case we're using one callback for all items,
+// but you can make unique callbacks for each item if needed.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -19,32 +17,32 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
-#include <stdio.h> // fprintf()
-#include <stdlib.h> // exit()
-#include <string.h> // strcmp()
+#include <stdio.h> // fprintf()
+#include <stdlib.h> // exit()
+#include <string.h> // strcmp()
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Bar.H>
-#include <FL/filename.H> // fl_open_uri()
+#include <FL/filename.H> // fl_open_uri()
// This callback is invoked whenever the user clicks an item in the menu bar
static void MyMenuCallback(Fl_Widget *w, void *) {
- Fl_Menu_Bar *bar = (Fl_Menu_Bar*)w; // Get the menubar widget
- const Fl_Menu_Item *item = bar->mvalue(); // Get the menu item that was picked
+ Fl_Menu_Bar *bar = (Fl_Menu_Bar*)w; // Get the menubar widget
+ const Fl_Menu_Item *item = bar->mvalue(); // Get the menu item that was picked
- char ipath[256]; bar->item_pathname(ipath, sizeof(ipath)); // Get full pathname of picked item
+ char ipath[256]; bar->item_pathname(ipath, sizeof(ipath)); // Get full pathname of picked item
- fprintf(stderr, "callback: You picked '%s'", item->label()); // Print item picked
- fprintf(stderr, ", item_pathname() is '%s'", ipath); // ..and full pathname
+ fprintf(stderr, "callback: You picked '%s'", item->label()); // Print item picked
+ fprintf(stderr, ", item_pathname() is '%s'", ipath); // ..and full pathname
- if ( item->flags & (FL_MENU_RADIO|FL_MENU_TOGGLE) ) { // Toggle or radio item?
- fprintf(stderr, ", value is %s", item->value()?"on":"off"); // Print item's value
+ if ( item->flags & (FL_MENU_RADIO|FL_MENU_TOGGLE) ) { // Toggle or radio item?
+ fprintf(stderr, ", value is %s", item->value()?"on":"off"); // Print item's value
}
fprintf(stderr, "\n");
if ( strcmp(item->label(), "Google") == 0 ) { fl_open_uri("http://google.com/"); }
@@ -53,8 +51,8 @@ static void MyMenuCallback(Fl_Widget *w, void *) {
int main() {
Fl::scheme("gtk+");
- Fl_Window *win = new Fl_Window(400,200, "menubar-simple"); // Create window
- Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25); // Create menubar, items..
+ Fl_Window *win = new Fl_Window(400,200, "menubar-simple"); // Create window
+ Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25); // Create menubar, items..
menu->add("&File/&Open", "^o", MyMenuCallback);
menu->add("&File/&Save", "^s", MyMenuCallback, 0, FL_MENU_DIVIDER);
menu->add("&File/&Quit", "^q", MyMenuCallback);
@@ -62,23 +60,19 @@ int main() {
menu->add("&Edit/&Paste", "^v", MyMenuCallback, 0, FL_MENU_DIVIDER);
menu->add("&Edit/Radio 1", 0, MyMenuCallback, 0, FL_MENU_RADIO);
menu->add("&Edit/Radio 2", 0, MyMenuCallback, 0, FL_MENU_RADIO|FL_MENU_DIVIDER);
- menu->add("&Edit/Toggle 1", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off
- menu->add("&Edit/Toggle 2", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off
- menu->add("&Edit/Toggle 3", 0, MyMenuCallback, 0, FL_MENU_TOGGLE|FL_MENU_VALUE); // Default: on
+ menu->add("&Edit/Toggle 1", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off
+ menu->add("&Edit/Toggle 2", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off
+ menu->add("&Edit/Toggle 3", 0, MyMenuCallback, 0, FL_MENU_TOGGLE|FL_MENU_VALUE); // Default: on
menu->add("&Help/Google", 0, MyMenuCallback);
// Example: show how we can dynamically change the state of item Toggle #2 (turn it 'on')
{
- Fl_Menu_Item *item = (Fl_Menu_Item*)menu->find_item("&Edit/Toggle 2"); // Find item
- if ( item ) item->set(); // Turn it on
- else fprintf(stderr, "'Toggle 2' item not found?!\n"); // (optional) Not found? complain!
+ Fl_Menu_Item *item = (Fl_Menu_Item*)menu->find_item("&Edit/Toggle 2"); // Find item
+ if ( item ) item->set(); // Turn it on
+ else fprintf(stderr, "'Toggle 2' item not found?!\n"); // (optional) Not found? complain!
}
win->end();
win->show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/nativefilechooser-simple-app.cxx b/examples/nativefilechooser-simple-app.cxx
index d206daeac..736adb8d3 100644
--- a/examples/nativefilechooser-simple-app.cxx
+++ b/examples/nativefilechooser-simple-app.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// An example of how to use Fl_Native_File_Chooser to open & save files.
+// An example of how to use Fl_Native_File_Chooser to open & save files.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2017 by Bill Spitzak and others.
@@ -10,16 +8,16 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
-#include <stdio.h> // printf
-#include <stdlib.h> // exit,malloc
-#include <string.h> // strerror
-#include <errno.h> // errno
+#include <stdio.h> // printf
+#include <stdlib.h> // exit,malloc
+#include <string.h> // strerror
+#include <errno.h> // errno
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Bar.H>
@@ -62,28 +60,28 @@ class Application : public Fl_Window {
static void open_cb(Fl_Widget *w, void *v) {
Application *app = (Application*)v;
app->fc->title("Open");
- app->fc->type(Fl_Native_File_Chooser::BROWSE_FILE); // only picks files that exist
+ app->fc->type(Fl_Native_File_Chooser::BROWSE_FILE); // only picks files that exist
switch ( app->fc->show() ) {
- case -1: break; // Error
- case 1: break; // Cancel
- default: // Choice
+ case -1: break; // Error
+ case 1: break; // Cancel
+ default: // Choice
app->fc->preset_file(app->fc->filename());
app->open(app->fc->filename());
- break;
+ break;
}
}
// Handle a 'Save as' request from the menu
static void saveas_cb(Fl_Widget *w, void *v) {
Application *app = (Application*)v;
app->fc->title("Save As");
- app->fc->type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); // need this if file doesn't exist yet
+ app->fc->type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); // need this if file doesn't exist yet
switch ( app->fc->show() ) {
- case -1: break; // Error
- case 1: break; // Cancel
- default: // Choice
+ case -1: break; // Error
+ case 1: break; // Cancel
+ default: // Choice
app->fc->preset_file(app->fc->filename());
app->save(app->fc->filename());
- break;
+ break;
}
}
// Handle a 'Save' request from the menu
@@ -103,9 +101,9 @@ class Application : public Fl_Window {
static char *filename = 0;
if ( !filename ) {
const char *home =
- fl_getenv("HOME") ? fl_getenv("HOME") : // unix
- fl_getenv("HOME_PATH") ? fl_getenv("HOME_PATH") : // windows
- "."; // other
+ fl_getenv("HOME") ? fl_getenv("HOME") : // unix
+ fl_getenv("HOME_PATH") ? fl_getenv("HOME_PATH") : // windows
+ "."; // other
filename = (char*)malloc(strlen(home)+20);
sprintf(filename, "%s/untitled.txt", home);
}
@@ -121,16 +119,16 @@ public:
menu->add("&File/&Quit", FL_COMMAND+'q', quit_cb);
// Describe the demo..
Fl_Box *box = new Fl_Box(20,25+20,w()-40,h()-40-25);
- box->color(45);
+ box->color(45);
box->box(FL_FLAT_BOX);
box->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
box->label("This demo shows an example of implementing "
"common 'File' menu operations like:\n"
" File/Open, File/Save, File/Save As\n"
- "..using the Fl_Native_File_Chooser widget.\n\n"
- "Note 'Save' and 'Save As' really *does* create files! "
- "This is to show how behavior differs when "
- "files exist vs. do not.");
+ "..using the Fl_Native_File_Chooser widget.\n\n"
+ "Note 'Save' and 'Save As' really *does* create files! "
+ "This is to show how behavior differs when "
+ "files exist vs. do not.");
box->labelsize(12);
// Initialize the file chooser
fc = new Fl_Native_File_Chooser();
@@ -146,7 +144,3 @@ int main(int argc, char *argv[]) {
app->show(argc,argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/nativefilechooser-simple.cxx b/examples/nativefilechooser-simple.cxx
index 8ab216950..7c8268027 100644
--- a/examples/nativefilechooser-simple.cxx
+++ b/examples/nativefilechooser-simple.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Simple example of using Fl_Native_File_Chooser.
+// Simple example of using Fl_Native_File_Chooser.
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
@@ -9,19 +7,19 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/fl_message.H>
-#include <stdlib.h> /* exit() */
-#include <string.h> /* strcmp() */
+#include <stdlib.h> /* exit() */
+#include <string.h> /* strcmp() */
Fl_Window *G_win = 0;
Fl_Menu_Button *G_menu = 0;
@@ -30,28 +28,28 @@ Fl_Native_File_Chooser *G_chooser = 0;
static void Menu_CB(Fl_Widget*,void*data) {
// Handle the popup menu item the user picked..
const char *choice = (const char*)data;
- if ( strcmp(choice, "quit") == 0 ) { // Handle "quit"
+ if ( strcmp(choice, "quit") == 0 ) { // Handle "quit"
exit(0);
- } else if ( strcmp(choice, "open") == 0 ) { // Handle "open"
+ } else if ( strcmp(choice, "open") == 0 ) { // Handle "open"
if ( G_chooser == 0 ) {
// Create an instance of file chooser we can reuse..
G_chooser = new Fl_Native_File_Chooser();
- G_chooser->directory("."); // directory to start browsing with
- G_chooser->preset_file("nativefilechooser-simple.cxx"); // file to start with
+ G_chooser->directory("."); // directory to start browsing with
+ G_chooser->preset_file("nativefilechooser-simple.cxx"); // file to start with
G_chooser->filter("C++\t*.{cxx,cpp,h,H}\n");
- G_chooser->type(Fl_Native_File_Chooser::BROWSE_FILE); // only picks files that exist
- G_chooser->title("Pick a file please.."); // custom title for chooser window
+ G_chooser->type(Fl_Native_File_Chooser::BROWSE_FILE); // only picks files that exist
+ G_chooser->title("Pick a file please.."); // custom title for chooser window
}
// Show the chooser
// This blocks while chooser is open.
//
switch ( G_chooser->show() ) {
- case -1: break; // Error
- case 1: break; // Cancel
- default: // Choice
- G_chooser->preset_file(G_chooser->filename());
- fl_message("You chose: %s", G_chooser->filename());
- break;
+ case -1: break; // Error
+ case 1: break; // Cancel
+ default: // Choice
+ G_chooser->preset_file(G_chooser->filename());
+ fl_message("You chose: %s", G_chooser->filename());
+ break;
}
}
}
@@ -71,7 +69,3 @@ int main(int argc, char *argv[]) {
G_win->show(argc,argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/progress-simple.cxx b/examples/progress-simple.cxx
index 5221ddcb8..e0536f417 100644
--- a/examples/progress-simple.cxx
+++ b/examples/progress-simple.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Demonstrate using the Fl_Progress widget in an application - erco 05/02/2005
//
// Copyright 2005,2012 Greg Ercolano.
@@ -10,11 +8,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
@@ -72,7 +70,3 @@ int main() {
win.show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/shapedwindow.cxx b/examples/shapedwindow.cxx
index 200899666..cf4b7048d 100644
--- a/examples/shapedwindow.cxx
+++ b/examples/shapedwindow.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// shapedwindow example source file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2014 by Bill Spitzak and others.
@@ -9,11 +7,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems to:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl_Window.H>
@@ -119,7 +117,3 @@ int main(int argc, char **argv) {
delete win;
return 0;
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/simple-terminal.cxx b/examples/simple-terminal.cxx
index 5e14cf7b9..f1b6e5d5e 100644
--- a/examples/simple-terminal.cxx
+++ b/examples/simple-terminal.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Simple Example app using Fl_Simple_Terminal. - erco 10/12/2017
//
// Copyright 2017 Greg Ercolano.
@@ -10,14 +8,14 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
-#include <time.h> //START
+#include <time.h> //START
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Simple_Terminal.H>
@@ -53,8 +51,4 @@ int main(int argc, char **argv) {
G_win->show();
Fl::add_timeout(0.5, tick_cb);
return Fl::run();
-} //END
-
-//
-// End of "$Id$".
-//
+} //END
diff --git a/examples/table-as-container.cxx b/examples/table-as-container.cxx
index 7f833cfc0..515ad884f 100644
--- a/examples/table-as-container.cxx
+++ b/examples/table-as-container.cxx
@@ -1,16 +1,14 @@
//
-// "$Id$"
+// Show how FLTK widgets can be parented by Fl_Table. -erco 03/30/2003
//
-// Show how FLTK widgets can be parented by Fl_Table. -erco 03/30/2003
+// Originally the 'widgettable.cxx' example program that came with
+// erco's Fl_Table widget. Added to FLTK in 2010.
//
-// Originally the 'widgettable.cxx' example program that came with
-// erco's Fl_Table widget. Added to FLTK in 2010.
-//
-// This demonstrates how to use Fl_Table as a 'container' for FLTK
-// widgets; one widget per cell. This isn't optimal for large tables,
-// where it's better to make one instance of a widget, and move it to
-// where it's needed. For an example of this, see the example program
-// "table-spreadsheet.cxx".
+// This demonstrates how to use Fl_Table as a 'container' for FLTK
+// widgets; one widget per cell. This isn't optimal for large tables,
+// where it's better to make one instance of a widget, and move it to
+// where it's needed. For an example of this, see the example program
+// "table-spreadsheet.cxx".
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -19,11 +17,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems to:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
@@ -41,8 +39,8 @@ void button_cb(Fl_Widget *w, void*);
//
class WidgetTable : public Fl_Table {
protected:
- void draw_cell(TableContext context, // table cell drawing
- int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0);
+ void draw_cell(TableContext context, // table cell drawing
+ int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0);
public:
WidgetTable(int x, int y, int w, int h, const char *l=0) : Fl_Table(x,y,w,h,l) {
@@ -57,32 +55,32 @@ public:
~WidgetTable() { }
void SetSize(int newrows, int newcols) {
- clear(); // clear any previous widgets, if any
+ clear(); // clear any previous widgets, if any
rows(newrows);
cols(newcols);
- begin(); // start adding widgets to group
+ begin(); // start adding widgets to group
{
for ( int r = 0; r<newrows; r++ ) {
- for ( int c = 0; c<newcols; c++ ) {
- int X,Y,W,H;
- find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
-
- char s[40];
- if ( c & 1 ) {
- // Create the input widgets
- sprintf(s, "%d.%d", r, c);
- Fl_Input *in = new Fl_Input(X,Y,W,H);
- in->value(s);
- } else {
- // Create the light buttons
- sprintf(s, "%d/%d ", r, c);
- Fl_Light_Button *butt = new Fl_Light_Button(X,Y,W,H,strdup(s));
- butt->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
- butt->callback(button_cb, (void*)0);
- butt->value( ((r+c*2) & 4 ) ? 1 : 0);
- }
- }
+ for ( int c = 0; c<newcols; c++ ) {
+ int X,Y,W,H;
+ find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
+
+ char s[40];
+ if ( c & 1 ) {
+ // Create the input widgets
+ sprintf(s, "%d.%d", r, c);
+ Fl_Input *in = new Fl_Input(X,Y,W,H);
+ in->value(s);
+ } else {
+ // Create the light buttons
+ sprintf(s, "%d/%d ", r, c);
+ Fl_Light_Button *butt = new Fl_Light_Button(X,Y,W,H,strdup(s));
+ butt->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+ butt->callback(button_cb, (void*)0);
+ butt->value( ((r+c*2) & 4 ) ? 1 : 0);
+ }
+ }
}
}
end();
@@ -90,35 +88,35 @@ public:
};
// Handle drawing all cells in table
-void WidgetTable::draw_cell(TableContext context,
- int R, int C, int X, int Y, int W, int H) {
+void WidgetTable::draw_cell(TableContext context,
+ int R, int C, int X, int Y, int W, int H) {
switch ( context ) {
case CONTEXT_STARTPAGE:
- fl_font(FL_HELVETICA, 12); // font used by all headers
+ fl_font(FL_HELVETICA, 12); // font used by all headers
break;
case CONTEXT_RC_RESIZE: {
int X, Y, W, H;
int index = 0;
for ( int r = 0; r<rows(); r++ ) {
- for ( int c = 0; c<cols(); c++ ) {
- if ( index >= children() ) break;
- find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
- child(index++)->resize(X,Y,W,H);
- }
+ for ( int c = 0; c<cols(); c++ ) {
+ if ( index >= children() ) break;
+ find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
+ child(index++)->resize(X,Y,W,H);
+ }
}
- init_sizes(); // tell group children resized
+ init_sizes(); // tell group children resized
return;
}
case CONTEXT_ROW_HEADER:
fl_push_clip(X, Y, W, H);
{
- static char s[40];
- sprintf(s, "Row %d", R);
- fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color());
- fl_color(FL_BLACK);
- fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
+ static char s[40];
+ sprintf(s, "Row %d", R);
+ fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color());
+ fl_color(FL_BLACK);
+ fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
}
fl_pop_clip();
return;
@@ -126,17 +124,17 @@ void WidgetTable::draw_cell(TableContext context,
case CONTEXT_COL_HEADER:
fl_push_clip(X, Y, W, H);
{
- static char s[40];
- sprintf(s, "Column %d", C);
- fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color());
- fl_color(FL_BLACK);
- fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
+ static char s[40];
+ sprintf(s, "Column %d", C);
+ fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color());
+ fl_color(FL_BLACK);
+ fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
}
fl_pop_clip();
return;
case CONTEXT_CELL:
- return; // fltk handles drawing the widgets
+ return; // fltk handles drawing the widgets
default:
return;
@@ -156,7 +154,3 @@ int main() {
win.show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-simple.cxx b/examples/table-simple.cxx
index 2f3d4be68..accf3f3bb 100644
--- a/examples/table-simple.cxx
+++ b/examples/table-simple.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Simple example of using Fl_Table - Greg Ercolano 11/29/2010
//
// Demonstrates the simplest use of Fl_Table possible.
@@ -15,24 +13,24 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
//
-// Please report all bugs and problems on the following page:
+// https://www.fltk.org/bugs.php
//
-// http://www.fltk.org/str.php
-//
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Table.H>
#include <FL/fl_draw.H>
#define MAX_ROWS 30
-#define MAX_COLS 26 // A-Z
+#define MAX_COLS 26 // A-Z
// Derive a class from Fl_Table
class MyTable : public Fl_Table {
- int data[MAX_ROWS][MAX_COLS]; // data array for cells
+ int data[MAX_ROWS][MAX_COLS]; // data array for cells
// Draw the row/col headings
// Make this a dark thin upbox with the text inside.
@@ -43,7 +41,7 @@ class MyTable : public Fl_Table {
fl_color(FL_BLACK);
fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
fl_pop_clip();
- }
+ }
// Draw the cell data
// Dark gray text on white background with subtle border
//
@@ -56,7 +54,7 @@ class MyTable : public Fl_Table {
// Draw box border
fl_color(color()); fl_rect(X,Y,W,H);
fl_pop_clip();
- }
+ }
// Handle drawing table's cells
// Fl_Table calls this function to draw each visible cell in the table.
// It's up to us to use FLTK's drawing functions to draw the cells the way we want.
@@ -66,15 +64,15 @@ class MyTable : public Fl_Table {
switch ( context ) {
case CONTEXT_STARTPAGE: // before page is drawn..
fl_font(FL_HELVETICA, 16); // set the font for our drawing operations
- return;
+ return;
case CONTEXT_COL_HEADER: // Draw column headers
sprintf(s,"%c",'A'+COL); // "A", "B", "C", etc.
DrawHeader(s,X,Y,W,H);
- return;
+ return;
case CONTEXT_ROW_HEADER: // Draw row headers
sprintf(s,"%03d:",ROW); // "001:", "002:", etc
DrawHeader(s,X,Y,W,H);
- return;
+ return;
case CONTEXT_CELL: // Draw data in cells
sprintf(s,"%d",data[ROW][COL]);
DrawData(s,X,Y,W,H);
@@ -102,7 +100,7 @@ public:
col_header(1); // enable column headers (along top)
col_width_all(80); // default width of columns
col_resize(1); // enable column resizing
- end(); // end the Fl_Table group
+ end(); // end the Fl_Table group
}
~MyTable() { }
};
@@ -115,7 +113,3 @@ int main(int argc, char **argv) {
win.show(argc,argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-sort.cxx b/examples/table-sort.cxx
index dba178e8f..d492bf54c 100644
--- a/examples/table-sort.cxx
+++ b/examples/table-sort.cxx
@@ -1,12 +1,10 @@
//
-// "$Id$"
+// table-sort -- An example application using a sortable Fl_Table
//
-// table-sort -- An example application using a sortable Fl_Table
-//
-// Originally the 'sortapp.cxx' example program that came with
-// erco's Fl_Table widget. Added to FLTK in 2010.
+// Originally the 'sortapp.cxx' example program that came with
+// erco's Fl_Table widget. Added to FLTK in 2010.
//
-// Example of a non-trivial application that uses Fl_Table
+// Example of a non-trivial application that uses Fl_Table
// with sortable columns. This example is not trying to be simple,
// but to demonstrate the complexities of an actual app.
//
@@ -17,12 +15,12 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
+//
+// https://www.fltk.org/bugs.php
//
-// http://www.fltk.org/str.php
-//
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
@@ -147,17 +145,17 @@ void MyTable::draw_sort_arrow(int X,int Y,int W,int H) {
// Handle drawing all cells in table
void MyTable::draw_cell(TableContext context, int R, int C, int X, int Y, int W, int H) {
- const char *s = "";
+ const char *s = "";
if ( R < (int)_rowdata.size() && C < (int)_rowdata[R].cols.size() )
- s = _rowdata[R].cols[C];
+ s = _rowdata[R].cols[C];
switch ( context ) {
case CONTEXT_COL_HEADER:
fl_push_clip(X,Y,W,H); {
fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_BACKGROUND_COLOR);
if ( C < 9 ) {
- fl_font(HEADER_FONTFACE, HEADER_FONTSIZE);
+ fl_font(HEADER_FONTFACE, HEADER_FONTSIZE);
fl_color(FL_BLACK);
- fl_draw(G_header[C], X+2,Y,W,H, FL_ALIGN_LEFT, 0, 0); // +2=pad left
+ fl_draw(G_header[C], X+2,Y,W,H, FL_ALIGN_LEFT, 0, 0); // +2=pad left
// Draw sort arrow
if ( C == _sort_lastcol ) {
draw_sort_arrow(X,Y,W,H);
@@ -165,14 +163,14 @@ void MyTable::draw_cell(TableContext context, int R, int C, int X, int Y, int W,
}
}
fl_pop_clip();
- return;
+ return;
case CONTEXT_CELL: {
fl_push_clip(X,Y,W,H); {
// Bg color
Fl_Color bgcolor = row_selected(R) ? selection_color() : FL_WHITE;
- fl_color(bgcolor); fl_rectf(X,Y,W,H);
- fl_font(ROW_FONTFACE, ROW_FONTSIZE);
- fl_color(FL_BLACK); fl_draw(s, X+2,Y,W,H, FL_ALIGN_LEFT); // +2=pad left
+ fl_color(bgcolor); fl_rectf(X,Y,W,H);
+ fl_font(ROW_FONTFACE, ROW_FONTSIZE);
+ fl_color(FL_BLACK); fl_draw(s, X+2,Y,W,H, FL_ALIGN_LEFT); // +2=pad left
// Border
fl_color(FL_LIGHT2); fl_rect(X,Y,W,H);
}
@@ -190,7 +188,7 @@ void MyTable::autowidth(int pad) {
// Initialize all column widths to header width
fl_font(HEADER_FONTFACE, HEADER_FONTSIZE);
for ( int c=0; G_header[c]; c++ ) {
- w=0; fl_measure(G_header[c], w, h, 0); // pixel width of header text
+ w=0; fl_measure(G_header[c], w, h, 0); // pixel width of header text
col_width(c, w+pad);
}
fl_font(ROW_FONTFACE, ROW_FONTSIZE);
@@ -233,9 +231,9 @@ void MyTable::load_command(const char *cmd) {
if ( (int)rc.size() > cols() ) {
cols((int)rc.size());
}
- }
+ }
// How many rows we loaded
- rows((int)_rowdata.size());
+ rows((int)_rowdata.size());
// Auto-calculate widths, with 20 pixel padding
autowidth(20);
}
@@ -255,7 +253,7 @@ void MyTable::event_callback2() {
if ( Fl::event() == FL_RELEASE && Fl::event_button() == 1 ) {
if ( _sort_lastcol == COL ) { // Click same column? Toggle sort
_sort_reverse ^= 1;
- } else { // Click diff column? Up sort
+ } else { // Click diff column? Up sort
_sort_reverse = 0;
}
sort_column(COL, _sort_reverse);
@@ -277,15 +275,11 @@ int main() {
table.when(FL_WHEN_RELEASE); // handle table events on release
table.load_command(DIRCMD); // load table with a directory listing
table.row_height_all(18); // height of all rows
- table.tooltip("Click on column headings to toggle column sorting");
- table.color(FL_WHITE);
+ table.tooltip("Click on column headings to toggle column sorting");
+ table.color(FL_WHITE);
win.end();
win.resizable(table);
table.resize_window();
win.show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-spreadsheet-with-keyboard-nav.cxx b/examples/table-spreadsheet-with-keyboard-nav.cxx
index 03ba747f5..66273ceb9 100644
--- a/examples/table-spreadsheet-with-keyboard-nav.cxx
+++ b/examples/table-spreadsheet-with-keyboard-nav.cxx
@@ -1,9 +1,7 @@
//
-// "$Id$"
-//
-// Simple example of an interactive spreadsheet using Fl_Table.
-// Uses Mr. Satan's technique of instancing an Fl_Input around.
-// Modified to test Jean-Marc's mods for keyboard nav and mouse selection.
+// Simple example of an interactive spreadsheet using Fl_Table.
+// Uses Mr. Satan's technique of instancing an Fl_Input around.
+// Modified to test Jean-Marc's mods for keyboard nav and mouse selection.
//
// Fl_Table[1.00/LGPL] 04/18/03 Mister Satan -- Initial implementation, submitted to erco for Fl_Table
// Fl_Table[1.10/LGPL] 05/17/03 Greg Ercolano -- Small mods to follow changes to Fl_Table
@@ -17,11 +15,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <stdlib.h>
@@ -36,18 +34,18 @@ const int MAX_COLS = 26;
const int MAX_ROWS = 500;
class Spreadsheet : public Fl_Table {
- Fl_Int_Input *input; // single instance of Fl_Int_Input widget
- int values[MAX_ROWS][MAX_COLS]; // array of data for cells
- int row_edit, col_edit; // row/col being modified
- int s_left, s_top, s_right, s_bottom; // kb nav + mouse selection
+ Fl_Int_Input *input; // single instance of Fl_Int_Input widget
+ int values[MAX_ROWS][MAX_COLS]; // array of data for cells
+ int row_edit, col_edit; // row/col being modified
+ int s_left, s_top, s_right, s_bottom; // kb nav + mouse selection
protected:
void draw_cell(TableContext context,int=0,int=0,int=0,int=0,int=0,int=0);
- void event_callback2(); // table's event callback (instance)
- static void event_callback(Fl_Widget*, void *v) { // table's event callback (static)
+ void event_callback2(); // table's event callback (instance)
+ static void event_callback(Fl_Widget*, void *v) { // table's event callback (static)
((Spreadsheet*)v)->event_callback2();
}
- static void input_cb(Fl_Widget*, void* v) { // input widget's callback
+ static void input_cb(Fl_Widget*, void* v) { // input widget's callback
((Spreadsheet*)v)->set_value_hide();
}
@@ -59,13 +57,13 @@ public:
input = new Fl_Int_Input(W/2,H/2,0,0);
input->hide();
input->callback(input_cb, (void*)this);
- input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
+ input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
input->maximum_size(5);
row_edit = col_edit = 0;
s_left = s_top = s_right = s_bottom = 0;
for (int c = 0; c < MAX_COLS; c++)
for (int r = 0; r < MAX_ROWS; r++)
- values[r][c] = (r + 2) * (c + 3); // initialize cells
+ values[r][c] = (r + 2) * (c + 3); // initialize cells
end();
}
~Spreadsheet() { }
@@ -74,7 +72,7 @@ public:
void set_value_hide() {
values[row_edit][col_edit] = atoi(input->value());
input->hide();
- window()->cursor(FL_CURSOR_DEFAULT); // XXX: if we don't do this, cursor can disappear!
+ window()->cursor(FL_CURSOR_DEFAULT); // XXX: if we don't do this, cursor can disappear!
}
// Change number of rows
void rows(int val) {
@@ -97,130 +95,130 @@ public:
// and make the widget 'appear' at the cell's location.
//
void start_editing(int R, int C) {
- row_edit = R; // Now editing this row/col
+ row_edit = R; // Now editing this row/col
col_edit = C;
int X,Y,W,H;
- find_cell(CONTEXT_CELL, R,C, X,Y,W,H); // Find X/Y/W/H of cell
- input->resize(X,Y,W,H); // Move Fl_Input widget there
- char s[30]; sprintf(s, "%d", values[R][C]); // Load input widget with cell's current value
+ find_cell(CONTEXT_CELL, R,C, X,Y,W,H); // Find X/Y/W/H of cell
+ input->resize(X,Y,W,H); // Move Fl_Input widget there
+ char s[30]; sprintf(s, "%d", values[R][C]); // Load input widget with cell's current value
input->value(s);
- input->position(0,strlen(s)); // Select entire input field
- input->show(); // Show the input widget, now that we've positioned it
+ input->position(0,strlen(s)); // Select entire input field
+ input->show(); // Show the input widget, now that we've positioned it
input->take_focus();
}
// Tell the input widget it's done editing, and to 'hide'
void done_editing() {
- if (input->visible()) { // input widget visible, ie. edit in progress?
- set_value_hide(); // Transfer its current contents to cell and hide
+ if (input->visible()) { // input widget visible, ie. edit in progress?
+ set_value_hide(); // Transfer its current contents to cell and hide
}
}
// Return the sum of all rows in this column
int sum_rows(int C) {
int sum = 0;
- for (int r=0; r<rows()-1; ++r) // -1: don't include cell data in 'totals' column
+ for (int r=0; r<rows()-1; ++r) // -1: don't include cell data in 'totals' column
sum += values[r][C];
return(sum);
}
// Return the sum of all cols in this row
int sum_cols(int R) {
int sum = 0;
- for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
+ for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
sum += values[R][c];
return(sum);
}
// Return the sum of all cells in table
int sum_all() {
int sum = 0;
- for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
- for (int r=0; r<rows()-1; ++r) // -1: ""
- sum += values[r][c];
+ for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
+ for (int r=0; r<rows()-1; ++r) // -1: ""
+ sum += values[r][c];
return(sum);
}
};
// Handle drawing all cells in table
void Spreadsheet::draw_cell(TableContext context, int R,int C, int X,int Y,int W,int H) {
- static char s[30];
+ static char s[30];
switch ( context ) {
- case CONTEXT_STARTPAGE: // table about to redraw
+ case CONTEXT_STARTPAGE: // table about to redraw
// Get kb nav + mouse 'selection region' for use below
get_selection(s_top, s_left, s_bottom, s_right);
break;
- case CONTEXT_COL_HEADER: // table wants us to draw a column heading (C is column)
- fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for heading to bold
- fl_push_clip(X,Y,W,H); // clip region for text
+ case CONTEXT_COL_HEADER: // table wants us to draw a column heading (C is column)
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for heading to bold
+ fl_push_clip(X,Y,W,H); // clip region for text
{
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col_header_color());
- fl_color(FL_BLACK);
- if (C == cols()-1) { // Last column? show 'TOTAL'
- fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
- } else { // Not last column? show column letter
- sprintf(s, "%c", 'A' + C);
- fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
- }
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col_header_color());
+ fl_color(FL_BLACK);
+ if (C == cols()-1) { // Last column? show 'TOTAL'
+ fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
+ } else { // Not last column? show column letter
+ sprintf(s, "%c", 'A' + C);
+ fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ }
}
fl_pop_clip();
return;
- case CONTEXT_ROW_HEADER: // table wants us to draw a row heading (R is row)
- fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for row heading to bold
+ case CONTEXT_ROW_HEADER: // table wants us to draw a row heading (R is row)
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for row heading to bold
fl_push_clip(X,Y,W,H);
{
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color());
- fl_color(FL_BLACK);
- if (R == rows()-1) { // Last row? Show 'Total'
- fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
- } else { // Not last row? show row#
- sprintf(s, "%d", R+1);
- fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
- }
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color());
+ fl_color(FL_BLACK);
+ if (R == rows()-1) { // Last row? Show 'Total'
+ fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
+ } else { // Not last row? show row#
+ sprintf(s, "%d", R+1);
+ fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ }
}
fl_pop_clip();
return;
- case CONTEXT_CELL: { // table wants us to draw a cell
+ case CONTEXT_CELL: { // table wants us to draw a cell
if (R == row_edit && C == col_edit && input->visible()) {
- return; // dont draw for cell with input widget over it
+ return; // dont draw for cell with input widget over it
}
// Background
// Keyboard nav and mouse selection highlighting
if (R >= s_top && R <= s_bottom && C >= s_left && C <= s_right) {
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_YELLOW);
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_YELLOW);
} else if ( C < cols()-1 && R < rows()-1 ) {
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_WHITE);
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, FL_WHITE);
} else {
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, 0xbbddbb00); // money green
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, 0xbbddbb00); // money green
}
// Text
fl_push_clip(X+3, Y+3, W-6, H-6);
{
- fl_color(FL_BLACK);
- if (C == cols()-1 || R == rows()-1) { // Last row or col? Show total
- fl_font(FL_HELVETICA | FL_BOLD, 14); // ..in bold font
- if (C == cols()-1 && R == rows()-1) { // Last row+col? Total all cells
- sprintf(s, "%d", sum_all());
- } else if (C == cols()-1) { // Row subtotal
- sprintf(s, "%d", sum_cols(R));
- } else if (R == rows()-1) { // Col subtotal
- sprintf(s, "%d", sum_rows(C));
- }
- fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
- } else { // Not last row or col? Show cell contents
- fl_font(FL_HELVETICA, 14); // ..in regular font
- sprintf(s, "%d", values[R][C]);
- fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
- }
+ fl_color(FL_BLACK);
+ if (C == cols()-1 || R == rows()-1) { // Last row or col? Show total
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // ..in bold font
+ if (C == cols()-1 && R == rows()-1) { // Last row+col? Total all cells
+ sprintf(s, "%d", sum_all());
+ } else if (C == cols()-1) { // Row subtotal
+ sprintf(s, "%d", sum_cols(R));
+ } else if (R == rows()-1) { // Col subtotal
+ sprintf(s, "%d", sum_rows(C));
+ }
+ fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
+ } else { // Not last row or col? Show cell contents
+ fl_font(FL_HELVETICA, 14); // ..in regular font
+ sprintf(s, "%d", values[R][C]);
+ fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
+ }
}
fl_pop_clip();
return;
}
- case CONTEXT_RC_RESIZE: { // table resizing rows or columns
+ case CONTEXT_RC_RESIZE: { // table resizing rows or columns
if (!input->visible()) return;
find_cell(CONTEXT_TABLE, row_edit, col_edit, X, Y, W, H);
if (X==input->x() && Y==input->y() && W==input->w() && H==input->h()) {
- return; // no change? ignore
+ return; // no change? ignore
}
input->resize(X,Y,W,H);
return;
@@ -235,37 +233,37 @@ void Spreadsheet::draw_cell(TableContext context, int R,int C, int X,int Y,int W
void Spreadsheet::event_callback2() {
int R = callback_row();
int C = callback_col();
- TableContext context = callback_context();
+ TableContext context = callback_context();
switch ( context ) {
- case CONTEXT_CELL: { // A table event occurred on a cell
- switch (Fl::event()) { // see what FLTK event caused it
- case FL_PUSH: // mouse click?
- done_editing(); // finish editing previous
- if (R != rows()-1 && C != cols()-1 ) // only edit cells not in total's columns
- start_editing(R,C); // start new edit
- return;
+ case CONTEXT_CELL: { // A table event occurred on a cell
+ switch (Fl::event()) { // see what FLTK event caused it
+ case FL_PUSH: // mouse click?
+ done_editing(); // finish editing previous
+ if (R != rows()-1 && C != cols()-1 ) // only edit cells not in total's columns
+ start_editing(R,C); // start new edit
+ return;
- case FL_KEYBOARD: // key press in table?
- if ( Fl::event_key() == FL_Escape ) exit(0); // ESC closes app
- if (C == cols()-1 || R == rows()-1) return; // no editing of totals column
- done_editing(); // finish any previous editing
- set_selection(R, C, R, C); // select the current cell
- start_editing(R,C); // start new edit
- if (Fl::event() == FL_KEYBOARD && Fl::e_text[0] != '\r') {
- input->handle(Fl::event()); // pass keypress to input widget
- }
- return;
+ case FL_KEYBOARD: // key press in table?
+ if ( Fl::event_key() == FL_Escape ) exit(0); // ESC closes app
+ if (C == cols()-1 || R == rows()-1) return; // no editing of totals column
+ done_editing(); // finish any previous editing
+ set_selection(R, C, R, C); // select the current cell
+ start_editing(R,C); // start new edit
+ if (Fl::event() == FL_KEYBOARD && Fl::e_text[0] != '\r') {
+ input->handle(Fl::event()); // pass keypress to input widget
+ }
+ return;
}
return;
}
- case CONTEXT_TABLE: // A table event occurred on dead zone in table
- case CONTEXT_ROW_HEADER: // A table event occurred on row/column header
+ case CONTEXT_TABLE: // A table event occurred on dead zone in table
+ case CONTEXT_ROW_HEADER: // A table event occurred on row/column header
case CONTEXT_COL_HEADER:
- done_editing(); // done editing, hide
+ done_editing(); // done editing, hide
return;
-
+
default:
return;
}
@@ -290,7 +288,7 @@ void setrows_cb(Fl_Widget* w, void* v) {
}
int main() {
- Fl::option(Fl::OPTION_ARROW_FOCUS, 1); // we want arrow keys to navigate table's widgets
+ Fl::option(Fl::OPTION_ARROW_FOCUS, 1); // we want arrow keys to navigate table's widgets
Fl_Double_Window *win = new Fl_Double_Window(922, 382, "Fl_Table Spreadsheet with Keyboard Navigation");
Spreadsheet* table = new Spreadsheet(20, 20, win->w()-80, win->h()-80);
// Table rows
@@ -305,7 +303,7 @@ int main() {
table->col_resize(1);
table->cols(11);
table->col_width_all(70);
- table->set_selection(0,0,0,0); // select top/left cell
+ table->set_selection(0,0,0,0); // select top/left cell
// Add children to window
win->begin();
@@ -336,7 +334,3 @@ int main() {
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-spreadsheet.cxx b/examples/table-spreadsheet.cxx
index 8167f6be3..e276a80d4 100644
--- a/examples/table-spreadsheet.cxx
+++ b/examples/table-spreadsheet.cxx
@@ -1,8 +1,6 @@
//
-// "$Id$"
-//
-// Simple example of an interactive spreadsheet using Fl_Table.
-// Uses Mr. Satan's technique of instancing an Fl_Input around.
+// Simple example of an interactive spreadsheet using Fl_Table.
+// Uses Mr. Satan's technique of instancing an Fl_Input around.
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
@@ -10,11 +8,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <stdlib.h>
@@ -28,17 +26,17 @@ const int MAX_COLS = 10;
const int MAX_ROWS = 10;
class Spreadsheet : public Fl_Table {
- Fl_Int_Input *input; // single instance of Fl_Int_Input widget
- int values[MAX_ROWS][MAX_COLS]; // array of data for cells
- int row_edit, col_edit; // row/col being modified
+ Fl_Int_Input *input; // single instance of Fl_Int_Input widget
+ int values[MAX_ROWS][MAX_COLS]; // array of data for cells
+ int row_edit, col_edit; // row/col being modified
protected:
void draw_cell(TableContext context,int=0,int=0,int=0,int=0,int=0,int=0);
- void event_callback2(); // table's event callback (instance)
- static void event_callback(Fl_Widget*,void *v) { // table's event callback (static)
+ void event_callback2(); // table's event callback (instance)
+ static void event_callback(Fl_Widget*,void *v) { // table's event callback (static)
((Spreadsheet*)v)->event_callback2();
}
- static void input_cb(Fl_Widget*,void* v) { // input widget's callback
+ static void input_cb(Fl_Widget*,void* v) { // input widget's callback
((Spreadsheet*)v)->set_value_hide();
}
@@ -50,12 +48,12 @@ public:
input = new Fl_Int_Input(W/2,H/2,0,0);
input->hide();
input->callback(input_cb, (void*)this);
- input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
+ input->when(FL_WHEN_ENTER_KEY_ALWAYS); // callback triggered when user hits Enter
input->maximum_size(5);
input->color(FL_YELLOW);
for (int c = 0; c < MAX_COLS; c++)
for (int r = 0; r < MAX_ROWS; r++)
- values[r][c] = c + (r*MAX_COLS); // initialize cells
+ values[r][c] = c + (r*MAX_COLS); // initialize cells
end();
row_edit = col_edit = 0;
set_selection(0,0,0,0);
@@ -66,129 +64,129 @@ public:
void set_value_hide() {
values[row_edit][col_edit] = atoi(input->value());
input->hide();
- window()->cursor(FL_CURSOR_DEFAULT); // XXX: if we don't do this, cursor can disappear!
+ window()->cursor(FL_CURSOR_DEFAULT); // XXX: if we don't do this, cursor can disappear!
}
// Start editing a new cell: move the Fl_Int_Input widget to specified row/column
// Preload the widget with the cell's current value,
// and make the widget 'appear' at the cell's location.
//
void start_editing(int R, int C) {
- row_edit = R; // Now editing this row/col
+ row_edit = R; // Now editing this row/col
col_edit = C;
- set_selection(R,C,R,C); // Clear any previous multicell selection
+ set_selection(R,C,R,C); // Clear any previous multicell selection
int X,Y,W,H;
- find_cell(CONTEXT_CELL, R,C, X,Y,W,H); // Find X/Y/W/H of cell
- input->resize(X,Y,W,H); // Move Fl_Input widget there
- char s[30]; sprintf(s, "%d", values[R][C]); // Load input widget with cell's current value
+ find_cell(CONTEXT_CELL, R,C, X,Y,W,H); // Find X/Y/W/H of cell
+ input->resize(X,Y,W,H); // Move Fl_Input widget there
+ char s[30]; sprintf(s, "%d", values[R][C]); // Load input widget with cell's current value
input->value(s);
- input->position(0,strlen(s)); // Select entire input field
- input->show(); // Show the input widget, now that we've positioned it
+ input->position(0,strlen(s)); // Select entire input field
+ input->show(); // Show the input widget, now that we've positioned it
input->take_focus();
}
// Tell the input widget it's done editing, and to 'hide'
void done_editing() {
- if (input->visible()) { // input widget visible, ie. edit in progress?
- set_value_hide(); // Transfer its current contents to cell and hide
+ if (input->visible()) { // input widget visible, ie. edit in progress?
+ set_value_hide(); // Transfer its current contents to cell and hide
}
}
// Return the sum of all rows in this column
int sum_rows(int C) {
int sum = 0;
- for (int r=0; r<rows()-1; ++r) // -1: don't include cell data in 'totals' column
+ for (int r=0; r<rows()-1; ++r) // -1: don't include cell data in 'totals' column
sum += values[r][C];
return(sum);
}
// Return the sum of all cols in this row
int sum_cols(int R) {
int sum = 0;
- for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
+ for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
sum += values[R][c];
return(sum);
}
// Return the sum of all cells in table
int sum_all() {
int sum = 0;
- for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
- for (int r=0; r<rows()-1; ++r) // -1: ""
- sum += values[r][c];
+ for (int c=0; c<cols()-1; ++c) // -1: don't include cell data in 'totals' column
+ for (int r=0; r<rows()-1; ++r) // -1: ""
+ sum += values[r][c];
return(sum);
}
};
// Handle drawing all cells in table
void Spreadsheet::draw_cell(TableContext context, int R,int C, int X,int Y,int W,int H) {
- static char s[30];
+ static char s[30];
switch ( context ) {
- case CONTEXT_STARTPAGE: // table about to redraw
+ case CONTEXT_STARTPAGE: // table about to redraw
break;
- case CONTEXT_COL_HEADER: // table wants us to draw a column heading (C is column)
- fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for heading to bold
- fl_push_clip(X,Y,W,H); // clip region for text
+ case CONTEXT_COL_HEADER: // table wants us to draw a column heading (C is column)
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for heading to bold
+ fl_push_clip(X,Y,W,H); // clip region for text
{
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col_header_color());
- fl_color(FL_BLACK);
- if (C == cols()-1) { // Last column? show 'TOTAL'
- fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
- } else { // Not last column? show column letter
- sprintf(s, "%c", 'A' + C);
- fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
- }
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col_header_color());
+ fl_color(FL_BLACK);
+ if (C == cols()-1) { // Last column? show 'TOTAL'
+ fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
+ } else { // Not last column? show column letter
+ sprintf(s, "%c", 'A' + C);
+ fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ }
}
fl_pop_clip();
return;
- case CONTEXT_ROW_HEADER: // table wants us to draw a row heading (R is row)
- fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for row heading to bold
+ case CONTEXT_ROW_HEADER: // table wants us to draw a row heading (R is row)
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // set font for row heading to bold
fl_push_clip(X,Y,W,H);
{
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color());
- fl_color(FL_BLACK);
- if (R == rows()-1) { // Last row? Show 'Total'
- fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
- } else { // Not last row? show row#
- sprintf(s, "%d", R+1);
- fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
- }
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color());
+ fl_color(FL_BLACK);
+ if (R == rows()-1) { // Last row? Show 'Total'
+ fl_draw("TOTAL", X,Y,W,H, FL_ALIGN_CENTER);
+ } else { // Not last row? show row#
+ sprintf(s, "%d", R+1);
+ fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ }
}
fl_pop_clip();
return;
- case CONTEXT_CELL: { // table wants us to draw a cell
+ case CONTEXT_CELL: { // table wants us to draw a cell
if (R == row_edit && C == col_edit && input->visible()) {
- return; // dont draw for cell with input widget over it
+ return; // dont draw for cell with input widget over it
}
// Background
if ( C < cols()-1 && R < rows()-1 ) {
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, is_selected(R,C) ? FL_YELLOW : FL_WHITE);
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, is_selected(R,C) ? FL_YELLOW : FL_WHITE);
} else {
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, is_selected(R,C) ? 0xddffdd00 : 0xbbddbb00); // money green
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, is_selected(R,C) ? 0xddffdd00 : 0xbbddbb00); // money green
}
// Text
fl_push_clip(X+3, Y+3, W-6, H-6);
{
- fl_color(FL_BLACK);
- if (C == cols()-1 || R == rows()-1) { // Last row or col? Show total
- fl_font(FL_HELVETICA | FL_BOLD, 14); // ..in bold font
- if (C == cols()-1 && R == rows()-1) { // Last row+col? Total all cells
- sprintf(s, "%d", sum_all());
- } else if (C == cols()-1) { // Row subtotal
- sprintf(s, "%d", sum_cols(R));
- } else if (R == rows()-1) { // Col subtotal
- sprintf(s, "%d", sum_rows(C));
- }
- fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
- } else { // Not last row or col? Show cell contents
- fl_font(FL_HELVETICA, 14); // ..in regular font
- sprintf(s, "%d", values[R][C]);
- fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
- }
+ fl_color(FL_BLACK);
+ if (C == cols()-1 || R == rows()-1) { // Last row or col? Show total
+ fl_font(FL_HELVETICA | FL_BOLD, 14); // ..in bold font
+ if (C == cols()-1 && R == rows()-1) { // Last row+col? Total all cells
+ sprintf(s, "%d", sum_all());
+ } else if (C == cols()-1) { // Row subtotal
+ sprintf(s, "%d", sum_cols(R));
+ } else if (R == rows()-1) { // Col subtotal
+ sprintf(s, "%d", sum_rows(C));
+ }
+ fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
+ } else { // Not last row or col? Show cell contents
+ fl_font(FL_HELVETICA, 14); // ..in regular font
+ sprintf(s, "%d", values[R][C]);
+ fl_draw(s, X+3,Y+3,W-6,H-6, FL_ALIGN_RIGHT);
+ }
}
fl_pop_clip();
return;
}
- case CONTEXT_RC_RESIZE: // table resizing rows or columns
+ case CONTEXT_RC_RESIZE: // table resizing rows or columns
if ( input->visible() ) {
find_cell(CONTEXT_TABLE, row_edit, col_edit, X, Y, W, H);
input->resize(X,Y,W,H);
@@ -205,43 +203,43 @@ void Spreadsheet::draw_cell(TableContext context, int R,int C, int X,int Y,int W
void Spreadsheet::event_callback2() {
int R = callback_row();
int C = callback_col();
- TableContext context = callback_context();
+ TableContext context = callback_context();
switch ( context ) {
- case CONTEXT_CELL: { // A table event occurred on a cell
- switch (Fl::event()) { // see what FLTK event caused it
- case FL_PUSH: // mouse click?
- done_editing(); // finish editing previous
- if (R != rows()-1 && C != cols()-1 ) // only edit cells not in total's columns
- start_editing(R,C); // start new edit
- return;
+ case CONTEXT_CELL: { // A table event occurred on a cell
+ switch (Fl::event()) { // see what FLTK event caused it
+ case FL_PUSH: // mouse click?
+ done_editing(); // finish editing previous
+ if (R != rows()-1 && C != cols()-1 ) // only edit cells not in total's columns
+ start_editing(R,C); // start new edit
+ return;
- case FL_KEYBOARD: // key press in table?
- if ( Fl::event_key() == FL_Escape ) exit(0); // ESC closes app
- done_editing(); // finish any previous editing
- if (C==cols()-1 || R==rows()-1) return; // no editing of totals column
- switch ( Fl::e_text[0] ) {
- case '0': case '1': case '2': case '3': // any of these should start editing new cell
- case '4': case '5': case '6': case '7':
- case '8': case '9': case '+': case '-':
- start_editing(R,C); // start new edit
- input->handle(Fl::event()); // pass typed char to input
- break;
- case '\r': case '\n': // let enter key edit the cell
- start_editing(R,C); // start new edit
- break;
- }
- return;
+ case FL_KEYBOARD: // key press in table?
+ if ( Fl::event_key() == FL_Escape ) exit(0); // ESC closes app
+ done_editing(); // finish any previous editing
+ if (C==cols()-1 || R==rows()-1) return; // no editing of totals column
+ switch ( Fl::e_text[0] ) {
+ case '0': case '1': case '2': case '3': // any of these should start editing new cell
+ case '4': case '5': case '6': case '7':
+ case '8': case '9': case '+': case '-':
+ start_editing(R,C); // start new edit
+ input->handle(Fl::event()); // pass typed char to input
+ break;
+ case '\r': case '\n': // let enter key edit the cell
+ start_editing(R,C); // start new edit
+ break;
+ }
+ return;
}
return;
}
- case CONTEXT_TABLE: // A table event occurred on dead zone in table
- case CONTEXT_ROW_HEADER: // A table event occurred on row/column header
+ case CONTEXT_TABLE: // A table event occurred on dead zone in table
+ case CONTEXT_ROW_HEADER: // A table event occurred on row/column header
case CONTEXT_COL_HEADER:
- done_editing(); // done editing, hide
+ done_editing(); // done editing, hide
return;
-
+
default:
return;
}
@@ -250,20 +248,20 @@ void Spreadsheet::event_callback2() {
int main() {
Fl_Double_Window *win = new Fl_Double_Window(862, 322, "Fl_Table Spreadsheet");
Spreadsheet *table = new Spreadsheet(10, 10, win->w()-20, win->h()-20);
- table->tab_cell_nav(1); // enable tab navigation of table cells (instead of fltk widgets)
+ table->tab_cell_nav(1); // enable tab navigation of table cells (instead of fltk widgets)
table->tooltip("Use keyboard to navigate cells:\n"
"Arrow keys or Tab/Shift-Tab");
// Table rows
table->row_header(1);
table->row_header_width(70);
table->row_resize(1);
- table->rows(MAX_ROWS+1); // +1: leaves room for 'total row'
+ table->rows(MAX_ROWS+1); // +1: leaves room for 'total row'
table->row_height_all(25);
// Table cols
table->col_header(1);
table->col_header_height(25);
table->col_resize(1);
- table->cols(MAX_COLS+1); // +1: leaves room for 'total column'
+ table->cols(MAX_COLS+1); // +1: leaves room for 'total column'
table->col_width_all(70);
// Show window
win->end();
@@ -271,7 +269,3 @@ int main() {
win->show();
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-with-keynav.cxx b/examples/table-with-keynav.cxx
index 74be7e30c..ee5f98ed5 100644
--- a/examples/table-with-keynav.cxx
+++ b/examples/table-with-keynav.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Example of Fl_Table with keyboard selection navigation - Greg Ercolano 04/14/2012
//
// Display a 10x10 multiplication table, and allow the user to
@@ -18,11 +16,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/fl_draw.H>
@@ -36,147 +34,143 @@
// GLOBALS
class MyTable;
-Fl_Toggle_Button *G_rowselect = 0; // toggle to enable row selection
-MyTable *G_table = 0; // table widget
-Fl_Output *G_sum = 0; // displays sum of user's selection
+Fl_Toggle_Button *G_rowselect = 0; // toggle to enable row selection
+MyTable *G_table = 0; // table widget
+Fl_Output *G_sum = 0; // displays sum of user's selection
class MyTable : public Fl_Table_Row {
protected:
// Handle drawing all cells in table
void draw_cell(TableContext context, int R=0,int C=0, int X=0,int Y=0,int W=0,int H=0) {
- static char s[30];
- switch ( context ) {
- case CONTEXT_COL_HEADER:
- case CONTEXT_ROW_HEADER:
- fl_font(FL_HELVETICA | FL_BOLD, 14);
- fl_push_clip(X, Y, W, H);
- {
- Fl_Color c = (context==CONTEXT_COL_HEADER) ? col_header_color() : row_header_color();
- fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, c);
- fl_color(FL_BLACK);
- // Draw text for headers
- sprintf(s, "%d", (context == CONTEXT_COL_HEADER) ? C : R);
- fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
- }
- fl_pop_clip();
- return;
- case CONTEXT_CELL: {
- // Keyboard nav and mouse selection highlighting
- int selected = G_rowselect->value() ? row_selected(R) : is_selected(R,C);
- fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, selected ? FL_YELLOW : FL_WHITE);
- // Draw text for the cell
- fl_push_clip(X+3, Y+3, W-6, H-6);
- {
- fl_font(FL_HELVETICA, 14);
- fl_color(FL_BLACK);
- sprintf(s, "%d", R*C); // factor row + col for data cells
- fl_draw(s, X+3, Y+3, W-6, H-6, FL_ALIGN_RIGHT);
- }
- fl_pop_clip();
- return;
- }
- default:
- return;
- }
+ static char s[30];
+ switch ( context ) {
+ case CONTEXT_COL_HEADER:
+ case CONTEXT_ROW_HEADER:
+ fl_font(FL_HELVETICA | FL_BOLD, 14);
+ fl_push_clip(X, Y, W, H);
+ {
+ Fl_Color c = (context==CONTEXT_COL_HEADER) ? col_header_color() : row_header_color();
+ fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, c);
+ fl_color(FL_BLACK);
+ // Draw text for headers
+ sprintf(s, "%d", (context == CONTEXT_COL_HEADER) ? C : R);
+ fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
+ }
+ fl_pop_clip();
+ return;
+ case CONTEXT_CELL: {
+ // Keyboard nav and mouse selection highlighting
+ int selected = G_rowselect->value() ? row_selected(R) : is_selected(R,C);
+ fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, selected ? FL_YELLOW : FL_WHITE);
+ // Draw text for the cell
+ fl_push_clip(X+3, Y+3, W-6, H-6);
+ {
+ fl_font(FL_HELVETICA, 14);
+ fl_color(FL_BLACK);
+ sprintf(s, "%d", R*C); // factor row + col for data cells
+ fl_draw(s, X+3, Y+3, W-6, H-6, FL_ALIGN_RIGHT);
+ }
+ fl_pop_clip();
+ return;
+ }
+ default:
+ return;
+ }
}
public:
// CTOR
MyTable(int x, int y, int w, int h, const char *l=0) : Fl_Table_Row(x,y,w,h,l) {
- // Row init
- row_header(1);
- row_header_width(70);
- row_resize(1);
- rows(11);
- row_height_all(20);
- // Col init
- col_header(1);
- col_header_height(20);
- col_resize(1);
- cols(11);
- col_width_all(70);
- end(); // Fl_Table derives from Fl_Group, so end() it
+ // Row init
+ row_header(1);
+ row_header_width(70);
+ row_resize(1);
+ rows(11);
+ row_height_all(20);
+ // Col init
+ col_header(1);
+ col_header_height(20);
+ col_resize(1);
+ cols(11);
+ col_width_all(70);
+ end(); // Fl_Table derives from Fl_Group, so end() it
}
~MyTable() { }
// Update the displayed sum value
int GetSelectionSum() {
int sum = -1;
for ( int R=0; R<rows(); R++ ) {
- for ( int C=0; C<cols(); C++ ) {
- if ( G_rowselect->value() ? row_selected(R) : is_selected(R,C) ) {
- if ( sum == -1 ) sum = 0;
- sum += R*C;
- }
- }
- }
- return(sum);
+ for ( int C=0; C<cols(); C++ ) {
+ if ( G_rowselect->value() ? row_selected(R) : is_selected(R,C) ) {
+ if ( sum == -1 ) sum = 0;
+ sum += R*C;
+ }
+ }
+ }
+ return(sum);
}
// Update the "Selection sum:" display
void UpdateSum() {
- static char s[80];
- int sum = GetSelectionSum();
- if ( sum == -1 ) { sprintf(s, "(nothing selected)"); G_sum->color(48); }
- else { sprintf(s, "%d", sum); G_sum->color(FL_WHITE); }
- // Update only if different (lets one copy/paste from sum)
- if ( strcmp(s,G_sum->value()))
- { G_sum->value(s); G_sum->redraw(); }
+ static char s[80];
+ int sum = GetSelectionSum();
+ if ( sum == -1 ) { sprintf(s, "(nothing selected)"); G_sum->color(48); }
+ else { sprintf(s, "%d", sum); G_sum->color(FL_WHITE); }
+ // Update only if different (lets one copy/paste from sum)
+ if ( strcmp(s,G_sum->value()))
+ { G_sum->value(s); G_sum->redraw(); }
}
// Keyboard and mouse events
int handle(int e) {
int ret = Fl_Table_Row::handle(e);
- if ( e == FL_KEYBOARD && Fl::event_key() == FL_Escape ) exit(0);
+ if ( e == FL_KEYBOARD && Fl::event_key() == FL_Escape ) exit(0);
switch (e) {
- case FL_PUSH:
- case FL_RELEASE:
- case FL_KEYUP:
- case FL_KEYDOWN:
- case FL_DRAG: {
- //ret = 1; // *don't* indicate we 'handled' these, just update ('handling' prevents e.g. tab nav)
- UpdateSum();
- redraw();
- break;
- }
- case FL_FOCUS: // tells FLTK we're interested in keyboard events
- case FL_UNFOCUS:
- ret = 1;
- break;
- }
- return(ret);
+ case FL_PUSH:
+ case FL_RELEASE:
+ case FL_KEYUP:
+ case FL_KEYDOWN:
+ case FL_DRAG: {
+ //ret = 1; // *don't* indicate we 'handled' these, just update ('handling' prevents e.g. tab nav)
+ UpdateSum();
+ redraw();
+ break;
+ }
+ case FL_FOCUS: // tells FLTK we're interested in keyboard events
+ case FL_UNFOCUS:
+ ret = 1;
+ break;
+ }
+ return(ret);
}
};
// User changed the 'row select' toggle button
void RowSelect_CB(Fl_Widget *w, void*) {
- w->window()->redraw(); // redraw with changes applied
+ w->window()->redraw(); // redraw with changes applied
G_table->UpdateSum();
}
int main() {
- Fl::option(Fl::OPTION_ARROW_FOCUS, 0); // disable arrow focus nav (we want arrows to control cells)
+ Fl::option(Fl::OPTION_ARROW_FOCUS, 0); // disable arrow focus nav (we want arrows to control cells)
Fl_Double_Window win(862, 312, "table-with-keynav");
win.begin();
- // Create table
- G_table = new MyTable(10, 30, win.w()-20, win.h()-70, "Times Table");
- G_table->tooltip("Use mouse or Shift + Arrow Keys to make selections.\n"
- "Sum of selected values is shown.");
- // Row select toggle button
- G_rowselect = new Fl_Toggle_Button(140,10,12,12,"Row selection");
- G_rowselect->align(FL_ALIGN_LEFT);
- G_rowselect->value(0);
- G_rowselect->selection_color(FL_YELLOW);
- G_rowselect->callback(RowSelect_CB);
- G_rowselect->tooltip("Click to toggle row vs. row/col selection");
- // Selection sum display
- win.end();
- win.begin();
- G_sum = new Fl_Output(140,G_table->y()+G_table->h()+10,160,25,"Selection Sum:");
- G_sum->value("(nothing selected)");
- G_sum->color(48);
- G_sum->tooltip("This field shows the sum of the selected cells in the table");
+ // Create table
+ G_table = new MyTable(10, 30, win.w()-20, win.h()-70, "Times Table");
+ G_table->tooltip("Use mouse or Shift + Arrow Keys to make selections.\n"
+ "Sum of selected values is shown.");
+ // Row select toggle button
+ G_rowselect = new Fl_Toggle_Button(140,10,12,12,"Row selection");
+ G_rowselect->align(FL_ALIGN_LEFT);
+ G_rowselect->value(0);
+ G_rowselect->selection_color(FL_YELLOW);
+ G_rowselect->callback(RowSelect_CB);
+ G_rowselect->tooltip("Click to toggle row vs. row/col selection");
+ // Selection sum display
+ win.end();
+ win.begin();
+ G_sum = new Fl_Output(140,G_table->y()+G_table->h()+10,160,25,"Selection Sum:");
+ G_sum->value("(nothing selected)");
+ G_sum->color(48);
+ G_sum->tooltip("This field shows the sum of the selected cells in the table");
win.end();
win.resizable(G_table);
- win.show();
+ win.show();
return Fl::run();
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/table-with-right-column-stretch-fit.cxx b/examples/table-with-right-column-stretch-fit.cxx
index 302ef0676..374bcec5b 100644
--- a/examples/table-with-right-column-stretch-fit.cxx
+++ b/examples/table-with-right-column-stretch-fit.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
//
// Demonstrate resizing Fl_Table_Row right column to fit window to avoid appearance of horiz scrollbar
//
@@ -18,11 +16,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
diff --git a/examples/tabs-simple.cxx b/examples/tabs-simple.cxx
index 7f06e5e89..a6248842d 100644
--- a/examples/tabs-simple.cxx
+++ b/examples/tabs-simple.cxx
@@ -1,8 +1,6 @@
//
-// "$Id$"
-//
-// Simple Fl_Tabs widget example.
-// Originally from erco's cheat sheet 06/05/2010, permission by author.
+// Simple Fl_Tabs widget example.
+// Originally from erco's cheat sheet 06/05/2010, permission by author.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -11,11 +9,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
@@ -47,11 +45,11 @@ int main(int argc, char *argv[]) {
//
Fl_Group *aaa = new Fl_Group(10,35,500-20,200-45,"Aaa");
{
- // Put some different buttons into the group, which will be shown
- // when the tab is selected.
- Fl_Button *b1 = new Fl_Button(50, 60,90,25,"Button A1"); b1->color(88+1);
- Fl_Button *b2 = new Fl_Button(50, 90,90,25,"Button A2"); b2->color(88+2);
- Fl_Button *b3 = new Fl_Button(50,120,90,25,"Button A3"); b3->color(88+3);
+ // Put some different buttons into the group, which will be shown
+ // when the tab is selected.
+ Fl_Button *b1 = new Fl_Button(50, 60,90,25,"Button A1"); b1->color(88+1);
+ Fl_Button *b2 = new Fl_Button(50, 90,90,25,"Button A2"); b2->color(88+2);
+ Fl_Button *b3 = new Fl_Button(50,120,90,25,"Button A3"); b3->color(88+3);
}
aaa->end();
@@ -60,14 +58,14 @@ int main(int argc, char *argv[]) {
//
Fl_Group *bbb = new Fl_Group(10,35,500-10,200-35,"Bbb");
{
- // Put some different buttons into the group, which will be shown
- // when the tab is selected.
- Fl_Button *b1 = new Fl_Button( 50,60,90,25,"Button B1"); b1->color(88+1);
- Fl_Button *b2 = new Fl_Button(150,60,90,25,"Button B2"); b2->color(88+3);
- Fl_Button *b3 = new Fl_Button(250,60,90,25,"Button B3"); b3->color(88+5);
- Fl_Button *b4 = new Fl_Button( 50,90,90,25,"Button B4"); b4->color(88+2);
- Fl_Button *b5 = new Fl_Button(150,90,90,25,"Button B5"); b5->color(88+4);
- Fl_Button *b6 = new Fl_Button(250,90,90,25,"Button B6"); b6->color(88+6);
+ // Put some different buttons into the group, which will be shown
+ // when the tab is selected.
+ Fl_Button *b1 = new Fl_Button( 50,60,90,25,"Button B1"); b1->color(88+1);
+ Fl_Button *b2 = new Fl_Button(150,60,90,25,"Button B2"); b2->color(88+3);
+ Fl_Button *b3 = new Fl_Button(250,60,90,25,"Button B3"); b3->color(88+5);
+ Fl_Button *b4 = new Fl_Button( 50,90,90,25,"Button B4"); b4->color(88+2);
+ Fl_Button *b5 = new Fl_Button(150,90,90,25,"Button B5"); b5->color(88+4);
+ Fl_Button *b6 = new Fl_Button(250,90,90,25,"Button B6"); b6->color(88+6);
}
bbb->end();
}
@@ -77,7 +75,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/textdisplay-with-colors.cxx b/examples/textdisplay-with-colors.cxx
index 6c4482402..6d66d2367 100644
--- a/examples/textdisplay-with-colors.cxx
+++ b/examples/textdisplay-with-colors.cxx
@@ -1,14 +1,12 @@
//
-// "$Id$"
+// How to use Fl_Text_Display with colors. -erco 11/09/2010
+// Originally from erco's cheat sheet, permission by author.
//
-// How to use Fl_Text_Display with colors. -erco 11/09/2010
-// Originally from erco's cheat sheet, permission by author.
+// Shows how to use the two Fl_Text_Buffer's needed to manage
+// the text and style info separately.
//
-// Shows how to use the two Fl_Text_Buffer's needed to manage
-// the text and style info separately.
-//
-// For an example of a color text *editor*, see the 'editor'
-// example in the test directory.
+// For an example of a color text *editor*, see the 'editor'
+// example in the test directory.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -17,11 +15,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
@@ -38,22 +36,18 @@ int main() {
};
Fl_Window *win = new Fl_Window(640, 480, "Simple Text Display With Colors");
Fl_Text_Display *disp = new Fl_Text_Display(20, 20, 640-40, 480-40);
- Fl_Text_Buffer *tbuff = new Fl_Text_Buffer(); // text buffer
- Fl_Text_Buffer *sbuff = new Fl_Text_Buffer(); // style buffer
+ Fl_Text_Buffer *tbuff = new Fl_Text_Buffer(); // text buffer
+ Fl_Text_Buffer *sbuff = new Fl_Text_Buffer(); // style buffer
disp->buffer(tbuff);
- int stable_size = sizeof(stable)/sizeof(stable[0]); // # entries in style table (4)
+ int stable_size = sizeof(stable)/sizeof(stable[0]); // # entries in style table (4)
disp->highlight_data(sbuff, stable, stable_size, 'A', 0, 0);
// Text
tbuff->text("Red Line 1\nYel Line 2\nGrn Line 3\nBlu Line 4\n"
- "Red Line 5\nYel Line 6\nGrn Line 7\nBlu Line 8\n");
+ "Red Line 5\nYel Line 6\nGrn Line 7\nBlu Line 8\n");
// Style for text
sbuff->text("AAAAAAAAAA\nBBBBBBBBBB\nCCCCCCCCCC\nDDDDDDDDDD\n"
- "AAAAAAAAAA\nBBBBBBBBBB\nCCCCCCCCCC\nDDDDDDDDDD\n");
+ "AAAAAAAAAA\nBBBBBBBBBB\nCCCCCCCCCC\nDDDDDDDDDD\n");
win->resizable(*disp);
win->show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/texteditor-simple.cxx b/examples/texteditor-simple.cxx
index 147f49720..4271b0b5a 100644
--- a/examples/texteditor-simple.cxx
+++ b/examples/texteditor-simple.cxx
@@ -1,16 +1,14 @@
//
-// "$Id$"
+// A simple example of Fl_Text_Editor
//
-// A simple example of Fl_Text_Editor
+// Fl_Text_Editor is unlike other FLTK widgets in that
+// to work correctly, it must be assigned to an instance of an
+// Fl_Text_Buffer. The below shows using buffer() to connect
+// the two classes together.
//
-// Fl_Text_Editor is unlike other FLTK widgets in that
-// to work correctly, it must be assigned to an instance of an
-// Fl_Text_Buffer. The below shows using buffer() to connect
-// the two classes together.
-//
-// Note that the example can also be used to demonstrate
-// Fl_Text_Display; just replace all instances of
-// Fl_Text_Editor with Fl_Text_Display and rebuild.
+// Note that the example can also be used to demonstrate
+// Fl_Text_Display; just replace all instances of
+// Fl_Text_Editor with Fl_Text_Display and rebuild.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -19,11 +17,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
@@ -34,7 +32,7 @@ int main() {
Fl_Double_Window *win = new Fl_Double_Window(640, 480, "Simple Fl_Text_Editor");
Fl_Text_Buffer *buff = new Fl_Text_Buffer();
Fl_Text_Editor *edit = new Fl_Text_Editor(20, 20, 640-40, 480-40);
- edit->buffer(buff); // attach the text buffer to our editor widget
+ edit->buffer(buff); // attach the text buffer to our editor widget
win->resizable(*edit);
win->show();
buff->text("line 0\nline 1\nline 2\n"
@@ -47,7 +45,3 @@ int main() {
"line 21\nline 22\nline 23\n");
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/texteditor-with-dynamic-colors.cxx b/examples/texteditor-with-dynamic-colors.cxx
index 458774a56..0d5bba47e 100644
--- a/examples/texteditor-with-dynamic-colors.cxx
+++ b/examples/texteditor-with-dynamic-colors.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// How to use Fl_Text_Editor with dynamic colors. -erco 08/29/2018
// Originally posted on fltk.general.
//
@@ -25,11 +23,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
@@ -132,7 +130,3 @@ int main() {
win->show();
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/tree-as-container.cxx b/examples/tree-as-container.cxx
index e704d7a0b..d8cac5205 100644
--- a/examples/tree-as-container.cxx
+++ b/examples/tree-as-container.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Fl_Tree as a container of FLTK widgets. - erco 04/15/2012
+// Fl_Tree as a container of FLTK widgets. - erco 04/15/2012
//
// Copyright 2010,2012 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -10,11 +8,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <FL/Fl.H>
@@ -32,18 +30,18 @@ class MyData : public Fl_Group {
Fl_Input *fields[MAX_FIELDS];
public:
MyData(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) {
- static unsigned int colors[MAX_FIELDS] = {
- 0xffffdd00, 0xffdddd00, 0xddffff00, 0xddffdd00, 0xddddff00
- };
+ static unsigned int colors[MAX_FIELDS] = {
+ 0xffffdd00, 0xffdddd00, 0xddffff00, 0xddffdd00, 0xddddff00
+ };
for ( int t=0; t<MAX_FIELDS; t++ ) {
- fields[t] = new Fl_Input(X+t*FIELD_WIDTH,Y,FIELD_WIDTH,H);
- fields[t]->color(Fl_Color(colors[t]));
- }
- end();
+ fields[t] = new Fl_Input(X+t*FIELD_WIDTH,Y,FIELD_WIDTH,H);
+ fields[t]->color(Fl_Color(colors[t]));
+ }
+ end();
}
void SetData(int col, const char *val) {
if ( col >= 0 && col < MAX_FIELDS )
- fields[col]->value(val);
+ fields[col]->value(val);
}
};
@@ -53,7 +51,7 @@ int main(int argc, char *argv[]) {
{
// Create the tree
Fl_Tree *tree = new Fl_Tree(10, 10, win->w()-20, win->h()-20);
- tree->showroot(0); // don't show root of tree
+ tree->showroot(0); // don't show root of tree
// Add some regular text nodes
tree->add("Foo/Bar/001");
tree->add("Foo/Bar/002");
@@ -63,20 +61,20 @@ int main(int argc, char *argv[]) {
for ( int t=0; t<MAX_ROWS; t++ ) {
// Add item to tree
static char s[80];
- sprintf(s, "FLTK Widgets/%d", t);
- Fl_Tree_Item *item = tree->add(s);
- // Reconfigure item to be an FLTK widget (MyData)
- tree->begin();
- {
- MyData *data = new MyData(0,0,FIELD_WIDTH*MAX_FIELDS, FIELD_HEIGHT);
- item->widget(data);
- // Initialize widget data
- for ( int c=0; c<MAX_FIELDS; c++ ) {
- sprintf(s, "%d-%d", t,c);
- data->SetData(c,s);
- }
- }
- tree->end();
+ sprintf(s, "FLTK Widgets/%d", t);
+ Fl_Tree_Item *item = tree->add(s);
+ // Reconfigure item to be an FLTK widget (MyData)
+ tree->begin();
+ {
+ MyData *data = new MyData(0,0,FIELD_WIDTH*MAX_FIELDS, FIELD_HEIGHT);
+ item->widget(data);
+ // Initialize widget data
+ for ( int c=0; c<MAX_FIELDS; c++ ) {
+ sprintf(s, "%d-%d", t,c);
+ data->SetData(c,s);
+ }
+ }
+ tree->end();
}
}
win->end();
@@ -84,7 +82,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/tree-custom-draw-items.cxx b/examples/tree-custom-draw-items.cxx
index 45bde388e..e7fb3ecde 100644
--- a/examples/tree-custom-draw-items.cxx
+++ b/examples/tree-custom-draw-items.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Demonstrate Fl_Tree custom item draw callback. - erco 11/09/2013
+// Demonstrate Fl_Tree custom item draw callback. - erco 11/09/2013
//
// Copyright 2013 Greg Ercolano.
// Copyright 1998-2016 by Bill Spitzak and others.
@@ -10,14 +8,14 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
-#include <time.h> /* ctime.. */
+#include <time.h> /* ctime.. */
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Tree.H>
@@ -69,12 +67,12 @@ public:
//
// Our item's label dimensions
int X = label_x(), Y = label_y(),
- W = label_w(), H = label_h();
+ W = label_w(), H = label_h();
// Render background
if ( render ) {
- if ( is_selected() ) { // Selected? Use selectbox() style
+ if ( is_selected() ) { // Selected? Use selectbox() style
fl_draw_box(prefs().selectbox(),X,Y,W,H,bg);
- } else { // Not Selected? use plain filled rectangle
+ } else { // Not Selected? use plain filled rectangle
fl_color(bg); fl_rectf(X,Y,W,H);
}
}
@@ -96,25 +94,25 @@ public:
}
X += 35;
// Render the date and time, one over the other
- fl_font(labelfont(), 8); // small font
+ fl_font(labelfont(), 8); // small font
fl_color(fg);
const struct tm *tm = GetTimeStruct();
char s[80];
sprintf(s, "Date: %02d/%02d/%02d", tm->tm_mon+1, tm->tm_mday, tm->tm_year % 100);
- lw=0, lh=0; fl_measure(s, lw, lh); // get box around text (including white space)
+ lw=0, lh=0; fl_measure(s, lw, lh); // get box around text (including white space)
if ( render ) fl_draw(s, X,Y+4,W,H, FL_ALIGN_LEFT|FL_ALIGN_TOP);
sprintf(s, "Time: %02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
if ( render ) fl_draw(s, X,Y+H/2,W,H/2, FL_ALIGN_LEFT|FL_ALIGN_TOP);
int lw2=0, lh2=0; fl_measure(s, lw2, lh2);
X += MAX(lw, lw2);
- return X; // return right most edge of what we've rendered
+ return X; // return right most edge of what we've rendered
}
};
// TIMER TO HANDLE DYNAMIC CONTENT IN THE TREE
void Timer_CB(void *data) {
Fl_Tree *tree = (Fl_Tree*)data;
- tree->redraw(); // keeps time updated
+ tree->redraw(); // keeps time updated
Fl::repeat_timeout(0.2, Timer_CB, data);
}
@@ -125,8 +123,8 @@ int main(int argc, char *argv[]) {
{
// Create the tree
Fl_Tree *tree = new Fl_Tree(0, 0, win->w(), win->h());
- tree->showroot(0); // don't show root of tree
- tree->selectmode(FL_TREE_SELECT_MULTI); // multiselect
+ tree->showroot(0); // don't show root of tree
+ tree->selectmode(FL_TREE_SELECT_MULTI); // multiselect
// Add some items
tree->add("Flintstones/Fred");
@@ -134,11 +132,11 @@ int main(int argc, char *argv[]) {
tree->add("Flintstones/Pebbles");
{
MyTimeItem *myitem;
- myitem = new MyTimeItem(tree, "Local"); // create custom item
+ myitem = new MyTimeItem(tree, "Local"); // create custom item
myitem->labelsize(20);
tree->add("Time Add Item/Local", myitem);
- myitem = new MyTimeItem(tree, "GMT"); // create custom item
+ myitem = new MyTimeItem(tree, "GMT"); // create custom item
myitem->labelsize(20);
tree->add("Time Add Item/GMT", myitem);
}
@@ -148,15 +146,15 @@ int main(int argc, char *argv[]) {
MyTimeItem *myitem;
item = tree->add("Time Replace Item/Local Time");
// Replace the 'Local' item with our own
- myitem = new MyTimeItem(tree, "Local"); // create custom item
+ myitem = new MyTimeItem(tree, "Local"); // create custom item
myitem->labelsize(20);
- item->replace(myitem); // replace normal item with custom
+ item->replace(myitem); // replace normal item with custom
item = tree->add("Time Replace Item/GMT Time");
// Replace the 'GMT' item with our own
- myitem = new MyTimeItem(tree, "GMT"); // create custom item
+ myitem = new MyTimeItem(tree, "GMT"); // create custom item
myitem->labelsize(20);
- item->replace(myitem); // replace normal item with custom
+ item->replace(myitem); // replace normal item with custom
}
tree->add("Superjail/Warden");
tree->add("Superjail/Jared");
@@ -176,7 +174,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/tree-custom-sort.cxx b/examples/tree-custom-sort.cxx
index 5f14946ee..36a662560 100644
--- a/examples/tree-custom-sort.cxx
+++ b/examples/tree-custom-sort.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Simple Fl_Tree custom (numeric) sort example. - erco 12/16/2013
+// Simple Fl_Tree custom (numeric) sort example. - erco 12/16/2013
// Demonstrates custom sorting of Fl_Tree items.
//
// Copyright 2013 Greg Ercolano.
@@ -11,15 +9,15 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
-#include <stdlib.h> /* qsort(3), srand(3).. */
-#include <time.h> /* time(2) */
+#include <stdlib.h> /* qsort(3), srand(3).. */
+#include <time.h> /* time(2) */
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Tree.H>
@@ -29,7 +27,7 @@ Fl_Tree *G_tree = 0;
// Resort the tree
void MySortCallback(Fl_Widget*, void *data) {
- int dir = int(fl_intptr_t(data)); // forward or reverse
+ int dir = int(fl_intptr_t(data)); // forward or reverse
Fl_Tree_Item *i = G_tree->root();
// Bubble sort
for ( int ax=0; ax<i->children(); ax++ ) {
@@ -75,7 +73,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/tree-of-tables.cxx b/examples/tree-of-tables.cxx
index b90a015d0..f26d685b0 100644
--- a/examples/tree-of-tables.cxx
+++ b/examples/tree-of-tables.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Fl_Tree as a container of Fl_Table's. - erco 04/25/2012
+// Fl_Tree as a container of Fl_Table's. - erco 04/25/2012
//
// Demonstrates how one can make a tree where each item
// contains a complex widget.
@@ -13,14 +11,14 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
-#include <math.h> // powf()
+#include <math.h> // powf()
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Tree.H>
@@ -35,13 +33,13 @@ public:
MyTable(int X,int Y,int W,int H,const char *mode) : Fl_Table(X,Y,W,H) {
rows(11); row_height_all(20); row_header(1);
cols(11); col_width_all(60); col_header(1);
- col_resize(1); // enable column resizing
+ col_resize(1); // enable column resizing
this->mode = mode;
end();
}
void resize(int X,int Y,int W,int H) {
- if ( W > 718 ) W = 718; // don't exceed 700 in width
- Fl_Table::resize(X,Y,W,h()); // disallow changes in height
+ if ( W > 718 ) W = 718; // don't exceed 700 in width
+ Fl_Table::resize(X,Y,W,h()); // disallow changes in height
}
// Handle drawing table's cells
// Fl_Table calls this function to draw each visible cell in the table.
@@ -52,33 +50,33 @@ public:
switch ( context ) {
case CONTEXT_STARTPAGE: // before page is drawn..
fl_font(FL_HELVETICA, 10); // set the font for our drawing operations
- return;
- case CONTEXT_COL_HEADER: // Drawing column/row headers
+ return;
+ case CONTEXT_COL_HEADER: // Drawing column/row headers
case CONTEXT_ROW_HEADER: {
int val = context==CONTEXT_COL_HEADER ? COL : ROW;
int col = context==CONTEXT_COL_HEADER ? col_header_color() : row_header_color();
fl_push_clip(X,Y,W,H);
- if ( strcmp(mode, "SinCos" ) == 0 ) { sprintf(s, "%.2f", ((val/10.0)*PI)); }
- else sprintf(s,"%d",val);
- fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col);
- fl_color(FL_BLACK);
- fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ if ( strcmp(mode, "SinCos" ) == 0 ) { sprintf(s, "%.2f", ((val/10.0)*PI)); }
+ else sprintf(s,"%d",val);
+ fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, col);
+ fl_color(FL_BLACK);
+ fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
fl_pop_clip();
- return;
+ return;
}
case CONTEXT_CELL: { // Draw data in cells
int col = is_selected(ROW,COL) ? FL_YELLOW : FL_WHITE;
fl_push_clip(X,Y,W,H);
if ( strcmp(mode, "Addition") == 0 ) { sprintf(s, "%d", ROW+COL); } else
if ( strcmp(mode, "Subtract") == 0 ) { sprintf(s, "%d", ROW-COL); } else
- if ( strcmp(mode, "Multiply") == 0 ) { sprintf(s, "%d", ROW*COL); } else
- if ( strcmp(mode, "Divide" ) == 0 ) { if ( COL==0 ) sprintf(s, "N/A"); else sprintf(s, "%.2f", (float)ROW/(float)COL); } else
- if ( strcmp(mode, "Exponent") == 0 ) { sprintf(s, "%g", powf((float)ROW,(float)COL)); } else
- if ( strcmp(mode, "SinCos" ) == 0 ) { sprintf(s, "%.2f", sin((ROW/10.0)*PI) * cos((COL/10.0)*PI)); } else
- { sprintf(s, "???"); }
- fl_color(col); fl_rectf(X,Y,W,H); // bg
- fl_color(FL_GRAY0); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); // text
- fl_color(color()); fl_rect(X,Y,W,H); // box
+ if ( strcmp(mode, "Multiply") == 0 ) { sprintf(s, "%d", ROW*COL); } else
+ if ( strcmp(mode, "Divide" ) == 0 ) { if ( COL==0 ) sprintf(s, "N/A"); else sprintf(s, "%.2f", (float)ROW/(float)COL); } else
+ if ( strcmp(mode, "Exponent") == 0 ) { sprintf(s, "%g", powf((float)ROW,(float)COL)); } else
+ if ( strcmp(mode, "SinCos" ) == 0 ) { sprintf(s, "%.2f", sin((ROW/10.0)*PI) * cos((COL/10.0)*PI)); } else
+ { sprintf(s, "???"); }
+ fl_color(col); fl_rectf(X,Y,W,H); // bg
+ fl_color(FL_GRAY0); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); // text
+ fl_color(color()); fl_rect(X,Y,W,H); // box
fl_pop_clip();
return;
}
@@ -95,13 +93,13 @@ int main(int argc, char *argv[]) {
// Create tree
Fl_Tree *tree = new Fl_Tree(10, 10, win->w()-20, win->h()-20);
tree->root()->label("Math Tables");
- tree->item_labelfont(FL_COURIER); // font to use for items
- tree->linespacing(4); // extra space between items
+ tree->item_labelfont(FL_COURIER); // font to use for items
+ tree->linespacing(4); // extra space between items
tree->item_draw_mode(tree->item_draw_mode() |
FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET | // draw item with widget() next to it
- FL_TREE_ITEM_HEIGHT_FROM_WIDGET); // make item height follow table's height
- tree->selectmode(FL_TREE_SELECT_NONE); // font to use for items
- tree->widgetmarginleft(12); // space between item and table
+ FL_TREE_ITEM_HEIGHT_FROM_WIDGET); // make item height follow table's height
+ tree->selectmode(FL_TREE_SELECT_NONE); // font to use for items
+ tree->widgetmarginleft(12); // space between item and table
tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED);
// Create tables, assign each a tree item
@@ -141,7 +139,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/tree-simple.cxx b/examples/tree-simple.cxx
index 7e3cf964d..37c6fd28c 100644
--- a/examples/tree-simple.cxx
+++ b/examples/tree-simple.cxx
@@ -1,7 +1,5 @@
//
-// "$Id$"
-//
-// Simple Fl_Tree widget example. - erco 06/05/2010
+// Simple Fl_Tree widget example. - erco 06/05/2010
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2016 by Bill Spitzak and others.
@@ -10,11 +8,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <FL/Fl.H>
@@ -60,8 +58,8 @@ int main(int argc, char *argv[]) {
{
// Create the tree
Fl_Tree *tree = new Fl_Tree(10, 10, win->w()-20, win->h()-20);
- tree->showroot(0); // don't show root of tree
- tree->callback(TreeCallback); // setup a callback for the tree
+ tree->showroot(0); // don't show root of tree
+ tree->callback(TreeCallback); // setup a callback for the tree
// Add some items
tree->add("Flintstones/Fred");
@@ -71,9 +69,9 @@ int main(int argc, char *argv[]) {
tree->add("Simpsons/Marge");
tree->add("Simpsons/Bart");
tree->add("Simpsons/Lisa");
- tree->add("Pathnames/\\/bin"); // front slashes
+ tree->add("Pathnames/\\/bin"); // front slashes
tree->add("Pathnames/\\/usr\\/sbin");
- tree->add("Pathnames/C:\\\\Program Files"); // backslashes
+ tree->add("Pathnames/C:\\\\Program Files"); // backslashes
tree->add("Pathnames/C:\\\\Documents and Settings");
// Start with some items closed
@@ -85,7 +83,3 @@ int main(int argc, char *argv[]) {
win->show(argc, argv);
return(Fl::run());
}
-
-//
-// End of "$Id$".
-//
diff --git a/examples/wizard-simple.cxx b/examples/wizard-simple.cxx
index bfa6865af..f434bc9de 100644
--- a/examples/wizard-simple.cxx
+++ b/examples/wizard-simple.cxx
@@ -1,8 +1,6 @@
//
-// "$Id$"
-//
-// Simple Fl_Wizard widget example.
-// Originally from erco's cheat sheet 06/05/2010, permission by author.
+// Simple Fl_Wizard widget example.
+// Originally from erco's cheat sheet 06/05/2010, permission by author.
//
// Copyright 2010 Greg Ercolano.
// Copyright 1998-2010 by Bill Spitzak and others.
@@ -11,11 +9,11 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <stdlib.h>
#include <FL/Fl.H>
@@ -75,7 +73,3 @@ int main(int argc, char **argv) {
G_win->show(argc, argv);
return Fl::run();
}
-
-//
-// End of "$Id$".
-//