fltk/test/unittest_scrollbarsize.cxx

225 lines
9.1 KiB
C++
Raw Normal View History

//
// Unit tests for the Fast Light Tool Kit (FLTK).
//
2022-02-19 14:55:06 +03:00
// Copyright 1998-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#include "unittests.h"
#include <FL/Fl_Group.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Browser.H>
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
#include <FL/Fl_Tree.H>
#include <FL/Fl_Table.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Value_Slider.H>
//
// Test new 1.3.x global vs. local scrollbar sizing
//
class Ut_Table : 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) FL_OVERRIDE {
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
snprintf(s, 10, "%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.
//
Ut_Table(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
}
~Ut_Table() { }
};
static const char *phonetics[] = {
"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot",
"Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike",
"November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango",
"Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu", NULL
};
class Ut_Scrollbar_Size_Test : public Fl_Group {
Fl_Browser *brow_a, *brow_b, *brow_c;
Fl_Tree *tree_a, *tree_b, *tree_c;
Ut_Table *table_a,*table_b,*table_c;
Fl_Text_Display *text_a, *text_b, *text_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);
b->type(FL_MULTI_BROWSER);
b->align(FL_ALIGN_TOP);
for (int t=0; phonetics[t]; t++ ) {
b->add(phonetics[t]);
if ( phonetics[t][0] == 'C' ) b->add("Long entry will show h-bar");
}
return(b);
}
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
Fl_Tree *maketree(int X,int Y,int W,int H,const char*L=0) {
Fl_Tree *b = new Fl_Tree(X,Y,W,H,L);
b->type(FL_TREE_SELECT_MULTI);
b->align(FL_ALIGN_TOP);
for (int t=0; phonetics[t]; t++ ) {
b->add(phonetics[t]);
if ( phonetics[t][0] == 'C' ) b->add("Long entry will show h-bar");
}
return(b);
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
}
Ut_Table *maketable(int X,int Y,int W,int H,const char*L=0) {
Ut_Table *mta = new Ut_Table(X,Y,W,H,L);
mta->align(FL_ALIGN_TOP);
mta->end();
return(mta);
}
Fl_Text_Display *maketextdisplay(int X,int Y,int W,int H,const char*L=0) {
Fl_Text_Display *dpy = new Fl_Text_Display(X,Y,W,H,L);
Fl_Text_Buffer *buf = new Fl_Text_Buffer();
dpy->buffer(buf);
for (int t=0; phonetics[t]; t++ ) {
buf->printf("%s\n", phonetics[t]);
if ( phonetics[t][0] == 'C' ) buf->printf("Long entry will show h-bar\n");
}
return(dpy);
}
void slide_cb2(Fl_Value_Slider *in) {
const char *label = in->label();
int val = int(in->value());
//fprintf(stderr, "VAL='%d'\n",val);
if ( strcmp(label,"A: Scroll Size") == 0 ) {
brow_a->scrollbar_size(val);
tree_a->scrollbar_size(val);
table_a->scrollbar_size(val);
text_a->scrollbar_size(val);
} else {
Fl::scrollbar_size(val);
}
in->window()->redraw();
}
static void slide_cb(Fl_Widget *w, void *data) {
Ut_Scrollbar_Size_Test *o = (Ut_Scrollbar_Size_Test*)data;
o->slide_cb2((Fl_Value_Slider*)w);
}
public:
static Fl_Widget *create() {
return(new Ut_Scrollbar_Size_Test(UT_TESTAREA_X, UT_TESTAREA_Y, UT_TESTAREA_W, UT_TESTAREA_H));
}
// CTOR
Ut_Scrollbar_Size_Test(int X, int Y, int W, int H)
: Fl_Group(X,Y,W,H) {
begin();
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
// _____________ _______________
// |_____________| |_______________|
// --- ----- <-- tgrpy
// brow_a brow_b brow_c | 14 |
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
// ---------- ---------- ---------- --- | <-- browy
// | | | | | | |browh |
// | | | | | | | |
// ---------- ---------- ---------- --- tgrph
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
// | |
// tree_a tree_b tree_c | 20 |
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
// ---------- ---------- ---------- --- | <-- treey
// | | | | | | |treeh |
// | | | | | | | |
// ---------- ---------- ---------- --- |
// | |
// table_a table_b table_c | 20 |
// ---------- ---------- ---------- --- | <-- tabley
// | | | | | | |tableh|
// | | | | | | | |
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
// ---------- ---------- ---------- --- ------
// etc..
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
int tgrpy = Y+30;
int tgrph = H-130;
int browy = tgrpy+14;
int browh = tgrph/3 - 20;
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
int treey = browy + browh + 20;
int treeh = browh;
int tabley = treey + treeh + 20;
int tableh = browh;
int texty = tabley + tableh + 20;
int texth = browh;
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
brow_a = makebrowser(X+ 10,browy,100,browh,"Browser A");
brow_b = makebrowser(X+120,browy,100,browh,"Browser B");
brow_c = makebrowser(X+230,browy,100,browh,"Browser C");
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
tree_a = maketree(X+ 10,treey,100,treeh,"Tree A");
tree_b = maketree(X+120,treey,100,treeh,"Tree B");
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");
text_a = maketextdisplay(X+ 10,texty,100,texth,"Text Display A");
text_b = maketextdisplay(X+120,texty,100,texth,"Text Display B");
text_c = maketextdisplay(X+230,texty,100,texth,"Text Display C");
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
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);
slide_glob->align(FL_ALIGN_LEFT);
slide_glob->range(0.0, 30.0);
slide_glob->step(1.0);
slide_glob->callback(slide_cb, (void*)this);
slide_glob->labelsize(12);
Fl_Tree related mods * open() / close() now can invoke the callback(). New method callback_reason() lets one determine the cause. (Used FLU's tree for reference on this) * new Fl_Tree methods: > item_pathname() > show_item(), show_top(), show_middle(), show_bottom(). > next_selected_item() -- loop through the selected items. > callback_item() -- the item that caused the callback > callback_reason() -- reason the callback was invoked FL_TREE_REASON_SELECTED -- item was selected FL_TREE_REASON_DESELECTED -- item was de-selected FL_TREE_REASON_OPENED -- item was opened FL_TREE_REASON_CLOSED -- item was closed > position() > display() * new Fl_Tree_Item methods: > find_child_item() -- searches children for a path > find_item() -- searches self and children for a path > next(item) -- loop forward through tree > prev(item) -- loop backward through tree > first_selected_item() > next_selected_item() > x(), y(), w(), h() * deprecated: > item_clicked(). Use callback_item() instead * the 'docallback' optional integer argument for all methods is now back to 0 or 1 only. (Other values became unnecessary when above new callback() behavior was defined) * test/tree has new "Test Callback Flags" button to test the 'docallback' flags for eg. open/close/select/deselect to make sure no bugs creep in. * INTERNAL: added free_path() to free special path array created by parse_path(). * Various docs strengthened: * How to use first()/next() and last()/prev() to walk tree > made sure more method's options use \param[in] > Added more \see references * Moved several implementations from .H -> .cxx * Added autoscroll to keyboard nav and mouse drags * test/unittests: added Fl_Tree to scrollsize test TODO: o Horiz scroll bar (see Johannes Schock's email re. additions he sent) o Need to allow keyboard nav to move focus to child FLTK widgets o Fix fast-selections so that no gaps are left behind. (Select all items from the last selected item to the current) o Investigate non-default values of when() causing odd behavior. (See the tree demo's when() pulldown..) * tree demo modified to include top/mid/bot buttons that test the above. * Keyboard navigation added: Up/Down -- move focus Left/Right -- closes/opens tree item in focus Spacebar -- toggle selection state of item in focus Enter -- selects the item in focus, deselecting all others Tab/Shift-Tab -- change widget focus * All Fl_Tree select() and deselect() methods now return a value that indicates if the item's state was changed. * Fixed focus box drawing (focus box resides more precisely within item's box) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7691 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-08-26 17:32:30 +04:00
Fl_Value_Slider *slide_browa = new Fl_Value_Slider(X+350,Y,100,18,"A: Scroll Size");
slide_browa->value(0);
slide_browa->type(FL_HORIZONTAL);
slide_browa->align(FL_ALIGN_LEFT);
slide_browa->range(0.0, 30.0);
slide_browa->step(1.0);
slide_browa->callback(slide_cb, (void*)this);
slide_browa->labelsize(12);
int msgbox_x = brow_c->x() + brow_c->w() + 20;
int msgbox_w = W-(msgbox_x-X);
Fl_Box *msgbox = new Fl_Box(msgbox_x,browy,msgbox_w,H-Y-48);
msgbox->label("\nVerify global scrollbar sizing and per-widget scrollbar sizing. "
"Scrollbar's size should change interactively as size sliders are changed. "
"Changing 'Global Scroll Size' should affect all scrollbars AS LONG AS the "
"'A: Scroll Size' slider is 0. Otherwise its value takes precedence "
"for all the 'A' group widgets.");
msgbox->labelsize(12);
msgbox->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
msgbox->box(FL_FLAT_BOX);
msgbox->color(53); // 90% gray
end();
}
};
UnitTest scrollbarsize(UT_TEST_SCROLLBARSIZE, "Scrollbar Size", Ut_Scrollbar_Size_Test::create);