Author: dejan
Date: 2007-07-03 13:27:53 -0400 (Tue, 03 Jul 2007)
New Revision: 5920
Log:
This commit applies patch given in STR #1674 by Tobias Markmann. I've also
patched test/browser.cxx to show how these
new changes can be applied. Original patch is slightly modified according to
FLTK coding rules.
There is also a new Code::Blocks workspace file for those who use this lovely
IDE. If you have any ideas/suggestions/etc
please post any comment to FLTK newsgroups, or alternatively join the
irc://irc.oftc.net/FLTK channel, and chat
with me, Tobias, and others.
Modified:
trunk/fltk/Browser.h
trunk/ide/cb/README.txt
trunk/ide/cb/fltk.workspace
trunk/src/Browser.cxx
trunk/test/browser.cxx
Modified: trunk/fltk/Browser.h
===================================================================
--- trunk/fltk/Browser.h 2007-06-27 12:41:26 UTC (rev 5919)
+++ trunk/fltk/Browser.h 2007-07-03 17:27:53 UTC (rev 5920)
@@ -40,10 +40,10 @@
enum { //<! values for type()
IS_MULTI = 1,
- NORMAL = GROUP_TYPE, //!< means single selection can be achieved by user
+ NORMAL = GROUP_TYPE, //!< means single selection can be achieved by user
MULTI = GROUP_TYPE+1 //!< means multiple selection can be achieved by
user
};
- enum { // value for selected_column
+ enum { /// value for selected_column
NO_COLUMN_SELECTED = -1 //!< means that no column has been selected by user
};
@@ -155,8 +155,11 @@
bool displayed(int line);
bool display(int line, bool value = true);
+ bool display_lines() const;
+ void display_lines(bool display);
+
int load(const char *filename);
-
+
int multi() const {return type()&IS_MULTI;}
const Symbol* leaf_symbol() const {return leaf_symbol_;}
@@ -165,9 +168,10 @@
void group_symbol(const Symbol* s) {group_symbol_ = s;}
protected:
- void handle_callback(int doit); // defines how cb are handled in the browser
+ void handle_callback(int doit); /// defines how cb are handled in the browser
private:
+ bool displaylines_;
bool indented_;
const int *column_widths_; // original column widths
int *column_widths_i; // original column widths after user interaction
Modified: trunk/ide/cb/README.txt
===================================================================
--- trunk/ide/cb/README.txt 2007-06-27 12:41:26 UTC (rev 5919)
+++ trunk/ide/cb/README.txt 2007-07-03 17:27:53 UTC (rev 5920)
@@ -1,22 +1,23 @@
-Code::Blocks
-============
-
-
-This directory contains Code::Blocks (http://www.codeblocks.org) workspace
-and project files for each specific system-subsystem.
-In order to build FLTK inside Code::Blocks you will have to propely setup
chosen
-subsystems. For example, in order to build "windows-dmc" project you will have
-to first setup DigitalMars C/C++ compiler, than activate this specific
project,
-and at the end run "Build".
-
-All files in this directory are NOT officialy supported, and serve only the
purpose
-of helping FLTK team in easier/faster development.
-
-
-Note for FLTK developers
-------------------------
-
-Developers should naturally commit only fltk.workspace, and .cbp files.
-All other files are not needed in our subversion repository, because they
-are automatically generated.
-
+Code::Blocks
+============
+
+
+This directory contains Code::Blocks (http://www.codeblocks.org) workspace
+and project files..
+In order to build FLTK inside Code::Blocks you will have to propely setup
chosen
+subsystems.
+
+All files in this directory are NOT officialy supported, and serve only the
purpose
+of helping FLTK team in easier/faster development.
+
+As You probably notice, I made only a "fltk" project, for building static FLTK
library. I hope I'll have more time in the future to make "fltk-images",
"fltk-opengl" and "fluid" projects.
+
+Note for FLTK developers
+------------------------
+
+Developers should naturally commit only fltk.workspace, and .cbp files.
+All other files are not needed in our subversion repository, because they
+are automatically generated.
+
+-------------------------------------------------------------------------
+$Id$
Modified: trunk/ide/cb/fltk.workspace
===================================================================
--- trunk/ide/cb/fltk.workspace 2007-06-27 12:41:26 UTC (rev 5919)
+++ trunk/ide/cb/fltk.workspace 2007-07-03 17:27:53 UTC (rev 5920)
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_file>
<Workspace title="Workspace">
- <Project filename="windows-mingw32.cbp" active="1" />
- <Project filename="windows-borland.cbp" />
- <Project filename="windows-dmc.cbp" />
+ <Project filename="fltk.cbp" active="1" />
</Workspace>
</CodeBlocks_workspace_file>
Modified: trunk/src/Browser.cxx
===================================================================
--- trunk/src/Browser.cxx 2007-06-27 12:41:26 UTC (rev 5919)
+++ trunk/src/Browser.cxx 2007-07-03 17:27:53 UTC (rev 5920)
@@ -619,32 +619,31 @@
int inset = (HERE.level+indented())*arrow_size;
// draw the open/close glyphs at the left:
- if (damage && inset > xposition_) {
- drawstyle(style(), 0);
- Color fg = getcolor();
- setcolor(getbgcolor());
- fillrect(0, y, inset-xposition_+arrow_size, item_h());
- setcolor(fg);
- bool preview_open = openclose_drag == 1 && pushed() && at_mark(FOCUS);
- for (unsigned j = indented() ? 0 : 1; j <= HERE.level; j++) {
- int g = (HERE.indexes[j] < children(HERE.indexes,j) - 1) ? 1 : 0;
- if (j == HERE.level) {
+ if (damage && inset > xposition_) {
+ drawstyle(style(), 0);
+ Color fg = getcolor();
+ setcolor(getbgcolor());
+ fillrect(0, y, inset-xposition_+arrow_size, item_h());
+ setcolor(fg);
+ bool preview_open = openclose_drag == 1 && pushed() &&
at_mark(FOCUS);
+ for (unsigned j = indented() ? 0 : 1; j <= HERE.level; j++) {
+ int g = (HERE.indexes[j] < children(HERE.indexes,j) -
1) ? 1 : 0;
+ if (j == HERE.level) {
if (children(HERE.indexes,j+1)>=0)
- if (item_is_open() != preview_open)
- g += OPEN_ELL;
- else
- g += CLOSED_ELL;
+ if (item_is_open() != preview_open)
+ g += OPEN_ELL;
+ else
+ g += CLOSED_ELL;
else
- g += ELL;
- }
- // if (getcolor()==BLACK) setcolor(GRAY33);
- draw_glyph(g, Rectangle(x, y, arrow_size, item_h()));
- x += arrow_size;
- }
- } else {
- x += inset;
- }
-
+ g += ELL;
+ }
+ // if (getcolor()==BLACK) setcolor(GRAY33);
+ if (displaylines_) draw_glyph(g, Rectangle(x, y,
arrow_size, item_h()));
+ x += arrow_size;
+ }
+ } else {
+ x += inset;
+ }
// Shift first column width, so labels after 1. column are lined up
correctly.
int saved_colw = 0;
int *cols = (int *)column_widths_p;
@@ -1833,6 +1832,23 @@
Make the indexed item visible and scroll to put it at the bottom of
the browser. */
+/**
+ * Accessor (get) method which returns TRUE if lines should be displayed, or
FALSE
+ * otwherwize.
+ */
+bool Browser::display_lines() const {
+ return displaylines_;
+}
+
+/**
+ * Accessor (set) method which is used to set the value of the "displaylines_"
+ * member. If you set display to FALSE it will mean that you do not want
+ * lines of the tree to be displayed.
+ */
+void Browser::display_lines(bool display) {
+ displaylines_ = display;
+}
+
////////////////////////////////////////////////////////////////
// Constructor
@@ -1876,6 +1892,7 @@
nHeader = 0; header_ = 0;
leaf_symbol_ = 0;
group_symbol_ = 0;
+ displaylines_ = true;
OPEN.unset();
Group::current(parent());
}
Modified: trunk/test/browser.cxx
===================================================================
--- trunk/test/browser.cxx 2007-06-27 12:41:26 UTC (rev 5919)
+++ trunk/test/browser.cxx 2007-07-03 17:27:53 UTC (rev 5920)
@@ -164,6 +164,7 @@
Browser *browser=0;
bool flip = false;
bool bm = true;
+bool dlines = true;
MultiImage g1(fileSmall, HIGHLIGHT, fileSmall2);
MultiImage g2(folderSmall, HIGHLIGHT, folderSmall3);
@@ -204,6 +205,13 @@
update_look();
}
+void display_lines_cb(Widget* w, void* ptr_arg) {
+ Browser* tree = reinterpret_cast<Browser*>(ptr_arg);
+ dlines = !dlines;
+ tree->display_lines(dlines);
+ tree->relayout();
+}
+
void change_resize(Button *w, long arg) {
if (w->value())
widths[1] = -1;
@@ -214,7 +222,7 @@
int main(int argc,char** argv) {
- Window win(280, 330, "Browser Example");
+ Window win(280, 340, "Browser Example");
win.begin();
Browser tree(10, 10, 260, 180);
@@ -253,10 +261,15 @@
CheckButton when_enter_key_button(88, 280, 160, 20, "WHEN_ENTER_KEY");
when_enter_key_button.callback((Callback*)cb_when_enter_key, (void *)&tree);
- CheckButton resize(88, 310, 160, 20, "Make 2. column flexible");
+ // Let's show how to show/hide lines in the Browser (tree) widget
+ CheckButton display_lines(88, 300, 160, 20, "Display lines");
+ display_lines.value(true);
+ display_lines.callback((Callback*)display_lines_cb, (void *)&tree);
+
+ CheckButton resize(108, 320, 160, 20, "Make 2. column flexible");
resize.callback((Callback*)change_resize);
- CheckButton bm(5, 310, 82, 20, "below mouse");
+ CheckButton bm(5, 320, 82, 20, "below mouse");
bm.set();
bm.callback((Callback*)below_mouse_cb);
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit