blob: 796c219894340f91ea68b37f6f1cb1f41b1c4c8e [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Tree_Prefs.cxx 8340 2011-01-30 20:22:06Z greg.ercolano $"
3//
4
5#include <FL/Fl.H>
6#include <FL/Fl_Pixmap.H>
7#include <FL/Fl_Tree_Prefs.H>
8#include <string.h>
9
10//////////////////////
11// Fl_Tree_Prefs.cxx
12//////////////////////
13//
14// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
15// Copyright (C) 2009-2010 by Greg Ercolano.
16//
17// This library is free software; you can redistribute it and/or
18// modify it under the terms of the GNU Library General Public
19// License as published by the Free Software Foundation; either
20// version 2 of the License, or (at your option) any later version.
21//
22// This library is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25// Library General Public License for more details.
26//
27// You should have received a copy of the GNU Library General Public
28// License along with this library; if not, write to the Free Software
29// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30// USA.
31//
32
33// INTERNAL: BUILT IN OPEN/STOW XPMS
34// These can be replaced via prefs.openicon()/closeicon()
35//
36static const char *L_open_xpm[] = {
37#ifdef __APPLE__
38 "11 11 2 1",
39 ". c None",
40 "@ c #000000",
41 "...@.......",
42 "...@@......",
43 "...@@@.....",
44 "...@@@@....",
45 "...@@@@@...",
46 "...@@@@@@..",
47 "...@@@@@...",
48 "...@@@@....",
49 "...@@@.....",
50 "...@@......",
51 "...@......."
52#else
53 "11 11 3 1",
54 ". c #fefefe",
55 "# c #444444",
56 "@ c #000000",
57 "###########",
58 "#.........#",
59 "#.........#",
60 "#....@....#",
61 "#....@....#",
62 "#..@@@@@..#",
63 "#....@....#",
64 "#....@....#",
65 "#.........#",
66 "#.........#",
67 "###########"
68#endif
69};
70static Fl_Pixmap L_openpixmap(L_open_xpm);
71
72static const char *L_close_xpm[] = {
73#ifdef __APPLE__
74 "11 11 2 1",
75 ". c None",
76 "@ c #000000",
77 "...........",
78 "...........",
79 "...........",
80 "...........",
81 "...........",
82 "@@@@@@@@@@@",
83 ".@@@@@@@@@.",
84 "..@@@@@@@..",
85 "...@@@@@...",
86 "....@@@....",
87 ".....@....."
88#else
89 "11 11 3 1",
90 ". c #fefefe",
91 "# c #444444",
92 "@ c #000000",
93 "###########",
94 "#.........#",
95 "#.........#",
96 "#.........#",
97 "#.........#",
98 "#..@@@@@..#",
99 "#.........#",
100 "#.........#",
101 "#.........#",
102 "#.........#",
103 "###########"
104#endif
105};
106static Fl_Pixmap L_closepixmap(L_close_xpm);
107
108/// Sets the default icon to be used as the 'open' icon
109/// when items are add()ed to the tree.
110/// This overrides the built in default '[+]' icon.
111///
112/// \param[in] val -- The new image, or zero to use the default [+] icon.
113///
114void Fl_Tree_Prefs::openicon(Fl_Image *val) {
115 _openimage = val ? val : &L_openpixmap;
116}
117
118/// Sets the icon to be used as the 'close' icon.
119/// This overrides the built in default '[-]' icon.
120///
121/// \param[in] val -- The new image, or zero to use the default [-] icon.
122///
123void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
124 _closeimage = val ? val : &L_closepixmap;
125}
126
127/// Fl_Tree_Prefs constructor
128Fl_Tree_Prefs::Fl_Tree_Prefs() {
129 _labelfont = FL_HELVETICA;
130 _labelsize = FL_NORMAL_SIZE;
131 _marginleft = 6;
132 _margintop = 3;
133 //_marginright = 3;
134 //_marginbottom = 3;
135 _openchild_marginbottom = 0;
136 _usericonmarginleft = 3;
137 _labelmarginleft = 3;
138 _linespacing = 0;
139 _labelfgcolor = FL_BLACK;
140 _labelbgcolor = FL_WHITE;
141 _connectorcolor = Fl_Color(43);
142#ifdef __APPLE__
143 _connectorstyle = FL_TREE_CONNECTOR_NONE;
144#else
145 _connectorstyle = FL_TREE_CONNECTOR_DOTTED;
146#endif
147 _openimage = &L_openpixmap;
148 _closeimage = &L_closepixmap;
149 _userimage = 0;
150 _showcollapse = 1;
151 _showroot = 1;
152 _connectorwidth = 17;
153 _sortorder = FL_TREE_SORT_NONE;
154 _selectbox = FL_FLAT_BOX;
155 _selectmode = FL_TREE_SELECT_SINGLE;
156 // Let fltk's current 'scheme' affect defaults
157 if ( Fl::scheme() ) {
158 if ( strcmp(Fl::scheme(), "gtk+") == 0 ) {
159 _selectbox = _FL_GTK_THIN_UP_BOX;
160 } else if ( strcmp(Fl::scheme(), "plastic") == 0 ) {
161 _selectbox = _FL_PLASTIC_THIN_UP_BOX;
162 }
163 }
164}
165
166//
167// End of "$Id: Fl_Tree_Prefs.cxx 8340 2011-01-30 20:22:06Z greg.ercolano $".
168//