2c5006563f
Fl_Tree::labelsize() -> item_labelsize() -- TO AVOID COLLISION WITH Fl_Widget::labelsize()! Fl_Tree::labelfont() -> item_labelfont() -- TO AVOID COLLISION WITH Fl_Widget::labelfont()! Fl_Tree_Prefs (internal) changes: Fl_Tree_Prefs::fgcolor() -> labelfgcolor() -- for consistency with above Fl_Tree_Prefs::bgcolor() -> labelbgcolor() -- for consistency with above Fl_Tree_Prefs::selectcolor() removed -- uses Fl_Widget::selection_color() instead Fl_Tree_Prefs::inactivecolor() removed -- was unused; inactive color procedurally calculated Other Fl_Tree mods: o Fixed bug with select_all(item) and deselect_all(item) (they were not limiting themselves to children of specified item) o Fixed bug with item not drawing in its /own/ bgcolor when item selected o Fl_Tree uses the Fl_Widget::selection_color() o All methods that deal with 'font types' changed int -> Fl_Font o All methods that deal with 'font sizes' changed int -> Fl_Fontsize o Added needed methods to Fl_Tree for accessing colors: item_labelfgcolor() -- access default fg color used for new items item_labelbgcolor() -- access default bg color used for new items tree_connectorcolor() -- access the connector line color o Small doxygen comment adjustments and general clarifications o test/tree demo modified to include testing of new label color methods, cleanup git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8340 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
169 lines
4.1 KiB
C++
169 lines
4.1 KiB
C++
//
|
|
// "$Id$"
|
|
//
|
|
|
|
#include <FL/Fl.H>
|
|
#include <FL/Fl_Pixmap.H>
|
|
#include <FL/Fl_Tree_Prefs.H>
|
|
#include <string.h>
|
|
|
|
//////////////////////
|
|
// Fl_Tree_Prefs.cxx
|
|
//////////////////////
|
|
//
|
|
// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
|
|
// Copyright (C) 2009-2010 by Greg Ercolano.
|
|
//
|
|
// This library is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU Library General Public
|
|
// License as published by the Free Software Foundation; either
|
|
// version 2 of the License, or (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// Library General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Library General Public
|
|
// License along with this library; if not, write to the Free Software
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
// USA.
|
|
//
|
|
|
|
// INTERNAL: BUILT IN OPEN/STOW XPMS
|
|
// These can be replaced via prefs.openicon()/closeicon()
|
|
//
|
|
static const char *L_open_xpm[] = {
|
|
#ifdef __APPLE__
|
|
"11 11 2 1",
|
|
". c None",
|
|
"@ c #000000",
|
|
"...@.......",
|
|
"...@@......",
|
|
"...@@@.....",
|
|
"...@@@@....",
|
|
"...@@@@@...",
|
|
"...@@@@@@..",
|
|
"...@@@@@...",
|
|
"...@@@@....",
|
|
"...@@@.....",
|
|
"...@@......",
|
|
"...@......."
|
|
#else
|
|
"11 11 3 1",
|
|
". c #fefefe",
|
|
"# c #444444",
|
|
"@ c #000000",
|
|
"###########",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#....@....#",
|
|
"#....@....#",
|
|
"#..@@@@@..#",
|
|
"#....@....#",
|
|
"#....@....#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"###########"
|
|
#endif
|
|
};
|
|
static Fl_Pixmap L_openpixmap(L_open_xpm);
|
|
|
|
static const char *L_close_xpm[] = {
|
|
#ifdef __APPLE__
|
|
"11 11 2 1",
|
|
". c None",
|
|
"@ c #000000",
|
|
"...........",
|
|
"...........",
|
|
"...........",
|
|
"...........",
|
|
"...........",
|
|
"@@@@@@@@@@@",
|
|
".@@@@@@@@@.",
|
|
"..@@@@@@@..",
|
|
"...@@@@@...",
|
|
"....@@@....",
|
|
".....@....."
|
|
#else
|
|
"11 11 3 1",
|
|
". c #fefefe",
|
|
"# c #444444",
|
|
"@ c #000000",
|
|
"###########",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#..@@@@@..#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"#.........#",
|
|
"###########"
|
|
#endif
|
|
};
|
|
static Fl_Pixmap L_closepixmap(L_close_xpm);
|
|
|
|
/// Sets the default icon to be used as the 'open' icon
|
|
/// when items are add()ed to the tree.
|
|
/// This overrides the built in default '[+]' icon.
|
|
///
|
|
/// \param[in] val -- The new image, or zero to use the default [+] icon.
|
|
///
|
|
void Fl_Tree_Prefs::openicon(Fl_Image *val) {
|
|
_openimage = val ? val : &L_openpixmap;
|
|
}
|
|
|
|
/// Sets the icon to be used as the 'close' icon.
|
|
/// This overrides the built in default '[-]' icon.
|
|
///
|
|
/// \param[in] val -- The new image, or zero to use the default [-] icon.
|
|
///
|
|
void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
|
|
_closeimage = val ? val : &L_closepixmap;
|
|
}
|
|
|
|
/// Fl_Tree_Prefs constructor
|
|
Fl_Tree_Prefs::Fl_Tree_Prefs() {
|
|
_labelfont = FL_HELVETICA;
|
|
_labelsize = FL_NORMAL_SIZE;
|
|
_marginleft = 6;
|
|
_margintop = 3;
|
|
//_marginright = 3;
|
|
//_marginbottom = 3;
|
|
_openchild_marginbottom = 0;
|
|
_usericonmarginleft = 3;
|
|
_labelmarginleft = 3;
|
|
_linespacing = 0;
|
|
_labelfgcolor = FL_BLACK;
|
|
_labelbgcolor = FL_WHITE;
|
|
_connectorcolor = Fl_Color(43);
|
|
#ifdef __APPLE__
|
|
_connectorstyle = FL_TREE_CONNECTOR_NONE;
|
|
#else
|
|
_connectorstyle = FL_TREE_CONNECTOR_DOTTED;
|
|
#endif
|
|
_openimage = &L_openpixmap;
|
|
_closeimage = &L_closepixmap;
|
|
_userimage = 0;
|
|
_showcollapse = 1;
|
|
_showroot = 1;
|
|
_connectorwidth = 17;
|
|
_sortorder = FL_TREE_SORT_NONE;
|
|
_selectbox = FL_FLAT_BOX;
|
|
_selectmode = FL_TREE_SELECT_SINGLE;
|
|
// Let fltk's current 'scheme' affect defaults
|
|
if ( Fl::scheme() ) {
|
|
if ( strcmp(Fl::scheme(), "gtk+") == 0 ) {
|
|
_selectbox = _FL_GTK_THIN_UP_BOX;
|
|
} else if ( strcmp(Fl::scheme(), "plastic") == 0 ) {
|
|
_selectbox = _FL_PLASTIC_THIN_UP_BOX;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// End of "$Id$".
|
|
//
|