themes: Workaround for bug where a background color of RGB 0,0,0 in Black color schem...
[ntk.git] / src / Fl_Wizard.cxx
blob3557cfa948855e5c7bdaf6075062077148a0380e
1 //
2 // "$Id: Fl_Wizard.cxx 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Fl_Wizard widget routines.
5 //
6 // Copyright 1997-2010 by Easy Software Products.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
27 // Contents:
30 // Fl_Wizard::Fl_Wizard() - Create an Fl_Wizard widget.
31 // Fl_Wizard::draw() - Draw the wizard border and visible child.
32 // Fl_Wizard::next() - Show the next child.
33 // Fl_Wizard::prev() - Show the previous child.
34 // Fl_Wizard::value() - Return the current visible child.
35 // Fl_Wizard::value() - Set the visible child.
39 // Include necessary header files...
42 #include <FL/Fl_Wizard.H>
43 #include <FL/Fl_Window.H>
44 #include <FL/fl_draw.H>
48 // 'Fl_Wizard::Fl_Wizard()' - Create an Fl_Wizard widget.
51 /**
52 The constructor creates the Fl_Wizard widget at the specified
53 position and size.
54 <P>The inherited destructor destroys the widget and its children.
56 Fl_Wizard::Fl_Wizard(int xx, // I - Lefthand position
57 int yy, // I - Upper position
58 int ww, // I - Width
59 int hh, // I - Height
60 const char *l) : // I - Label
61 Fl_Group(xx, yy, ww, hh, l)
63 box(FL_THIN_UP_BOX);
65 value_ = (Fl_Widget *)0;
70 /** Draws the wizard border and visible child. */
71 void Fl_Wizard::draw() {
72 Fl_Widget *kid; // Visible child
75 kid = value();
77 if (damage() & FL_DAMAGE_ALL)
79 // Redraw everything...
80 if (kid)
82 draw_box(box(), x(), y(), w(), h(), kid->color());
83 draw_child(*kid);
85 else
86 draw_box(box(), x(), y(), w(), h(), color());
89 else if (kid)
90 update_child(*kid);
94 /**
95 This method shows the next child of the wizard. If the last child
96 is already visible, this function does nothing.
98 void Fl_Wizard::next() {
99 int num_kids;
100 Fl_Widget * const *kids;
103 if ((num_kids = children()) == 0)
104 return;
106 for (kids = array(); num_kids > 0; kids ++, num_kids --)
107 if ((*kids)->visible())
108 break;
110 if (num_kids > 1)
111 value(kids[1]);
114 /** Shows the previous child.*/
115 void Fl_Wizard::prev()
117 int num_kids;
118 Fl_Widget * const *kids;
121 if ((num_kids = children()) == 0)
122 return;
124 for (kids = array(); num_kids > 0; kids ++, num_kids --)
125 if ((*kids)->visible())
126 break;
128 if (num_kids > 0 && num_kids < children())
129 value(kids[-1]);
132 /** Gets the current visible child widget. */
133 Fl_Widget* Fl_Wizard::value()
135 int num_kids;
136 Fl_Widget * const *kids;
137 Fl_Widget *kid;
140 if ((num_kids = children()) == 0)
141 return ((Fl_Widget *)0);
143 for (kids = array(), kid = (Fl_Widget *)0; num_kids > 0; kids ++, num_kids --)
145 if ((*kids)->visible())
147 if (kid)
148 (*kids)->hide();
149 else
150 kid = *kids;
154 if (!kid)
156 kids --;
157 kid = *kids;
158 kid->show();
161 return (kid);
164 /** Sets the child widget that is visible.*/
165 void Fl_Wizard::value(Fl_Widget *kid)
167 int num_kids;
168 Fl_Widget * const *kids;
171 if ((num_kids = children()) == 0)
172 return;
174 for (kids = array(); num_kids > 0; kids ++, num_kids --)
176 if (*kids == kid)
178 if (!kid->visible())
179 kid->show();
181 else
182 (*kids)->hide();
185 // This will restore the mouse pointer to the window's default cursor
186 // whenever the wizard pane is changed. Otherwise text widgets that
187 // show the next pane may leave the cursor set to the I beam, etc...
188 if (window()) window()->cursor(FL_CURSOR_DEFAULT);
194 // End of "$Id: Fl_Wizard.cxx 7903 2010-11-28 21:06:39Z matt $".