summaryrefslogtreecommitdiff
path: root/examples/tree-of-tables.cxx
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/tree-of-tables.cxx
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/tree-of-tables.cxx')
-rw-r--r--examples/tree-of-tables.cxx64
1 files changed, 29 insertions, 35 deletions
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$".
-//