summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2011-07-16 03:50:58 +0000
committerGreg Ercolano <erco@seriss.com>2011-07-16 03:50:58 +0000
commit46d9c4553655b53568356114719ecd510fd66cc3 (patch)
treee8b14beddea93227bf53675098c2a9c3920c1668 /test
parentada26bff297a24bcca8f48f0a0699a14c824d04a (diff)
Added Fl_Table to scrollbar resize unittests
as prep for resolving STR #2679. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8862 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
-rw-r--r--test/unittest_scrollbarsize.cxx73
1 files changed, 66 insertions, 7 deletions
diff --git a/test/unittest_scrollbarsize.cxx b/test/unittest_scrollbarsize.cxx
index 9a26a5960..b3079d6f9 100644
--- a/test/unittest_scrollbarsize.cxx
+++ b/test/unittest_scrollbarsize.cxx
@@ -28,14 +28,58 @@
#include <FL/Fl_Group.H>
#include <FL/Fl_Browser.H>
#include <FL/Fl_Tree.H>
+#include <FL/Fl_Table.H>
#include <FL/Fl_Value_Slider.H>
//
// Test new 1.3.x global vs. local scrollbar sizing
//
+class MyTable : public Fl_Table {
+ // 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.
+ //
+ void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0) {
+ static char s[10];
+ switch ( context ) {
+ case CONTEXT_STARTPAGE: // before page is drawn..
+ fl_font(FL_HELVETICA, 8); // set font for drawing operations
+ return;
+ case CONTEXT_CELL: // Draw data in cells
+ sprintf(s, "%c", 'A'+ROW+COL);
+ fl_push_clip(X,Y,W,H);
+ // Draw cell bg
+ fl_color(FL_WHITE); fl_rectf(X,Y,W,H);
+ // Draw cell data
+ fl_color(FL_GRAY0); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER);
+ // Draw box border
+ fl_color(color()); fl_rect(X,Y,W,H);
+ fl_pop_clip();
+ return;
+ default:
+ return;
+ }
+ }
+ public:
+ // Constructor
+ // Make our data array, and initialize the table options.
+ //
+ MyTable(int X, int Y, int W, int H, const char *L=0) : Fl_Table(X,Y,W,H,L) {
+ // Rows
+ rows(13); // how many rows
+ row_height_all(10); // default height of rows
+ // Cols
+ cols(13); // how many columns
+ col_width_all(10); // default width of columns
+ end(); // end the Fl_Table group
+ }
+ ~MyTable() { }
+};
+
class ScrollBarSizeTest : public Fl_Group {
Fl_Browser *brow_a, *brow_b, *brow_c;
Fl_Tree *tree_a, *tree_b, *tree_c;
+ MyTable *table_a,*table_b,*table_c;
Fl_Browser *makebrowser(int X,int Y,int W,int H,const char*L=0) {
Fl_Browser *b = new Fl_Browser(X,Y,W,H,L);
@@ -78,6 +122,12 @@ class ScrollBarSizeTest : public Fl_Group {
b->add("Whisky"); b->add("Zulu");
return(b);
}
+ MyTable *maketable(int X,int Y,int W,int H,const char*L=0) {
+ MyTable *mta = new MyTable(X,Y,W,H,L);
+ mta->align(FL_ALIGN_TOP);
+ mta->end();
+ return(mta);
+ }
void slide_cb2(Fl_Value_Slider *in) {
const char *label = in->label();
int val = int(in->value());
@@ -107,30 +157,39 @@ public:
// --- ----- <-- tgrpy
// brow_a brow_b brow_c | 14 |
// ---------- ---------- ---------- --- | <-- browy
- // | | | | | | | |
// | | | | | | |browh |
// | | | | | | | |
// ---------- ---------- ---------- --- tgrph
// | |
// tree_a tree_b tree_c | 20 |
// ---------- ---------- ---------- --- | <-- treey
- // | | | | | | | |
// | | | | | | |treeh |
// | | | | | | | |
+ // ---------- ---------- ---------- --- |
+ // | |
+ // table_a table_b table_c | 20 |
+ // ---------- ---------- ---------- --- | <-- tabley
+ // | | | | | | |tableh|
+ // | | | | | | | |
// ---------- ---------- ---------- --- ------
- //
+ // etc..
int tgrpy = Y+30;
int tgrph = H-130;
int browy = tgrpy+14;
- int browh = tgrph/2 - 20;
+ int browh = tgrph/3 - 20;
int treey = browy + browh + 20;
int treeh = browh;
+ int tabley = treey + treeh + 20;
+ int tableh = browh;
brow_a = makebrowser(X+ 10,browy,100,browh,"Browser A");
brow_b = makebrowser(X+120,browy,100,browh,"Browser B");
- brow_c = makebrowser(X+240,browy,100,browh,"Browser C");
+ brow_c = makebrowser(X+230,browy,100,browh,"Browser C");
tree_a = maketree(X+ 10,treey,100,treeh,"Tree A");
tree_b = maketree(X+120,treey,100,treeh,"Tree B");
- tree_c = maketree(X+240,treey,100,treeh,"Tree C");
+ tree_c = maketree(X+230,treey,100,treeh,"Tree C");
+ table_a = maketable(X+ 10,tabley,100,tableh,"Table A");
+ table_b = maketable(X+120,tabley,100,tableh,"Table B");
+ table_c = maketable(X+230,tabley,100,tableh,"Table C");
Fl_Value_Slider *slide_glob = new Fl_Value_Slider(X+100,Y,100,18,"Global Scroll Size");
slide_glob->value(16);
slide_glob->type(FL_HORIZONTAL);
@@ -153,7 +212,7 @@ public:
"Changing 'Global Scroll Size' should affect all three browser's scrollbars UNLESS\n"
"the 'A: Scroll Size' slider is changed, in which case its value will take precedence\n"
"for 'Browser A', and the global size will only affect Browser B and C.");
- labelsize(12);
+ labelsize(10);
align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
}
};