fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Wizard.cxx

Go to the documentation of this file.
00001 //
00002 // "$Id: Fl_Wizard.cxx 7903 2010-11-28 21:06:39Z matt $"
00003 //
00004 // Fl_Wizard widget routines.
00005 //
00006 // Copyright 1997-2010 by Easy Software Products.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 // Contents:
00028 
00029 //
00030 //   Fl_Wizard::Fl_Wizard() - Create an Fl_Wizard widget.
00031 //   Fl_Wizard::draw()      - Draw the wizard border and visible child.
00032 //   Fl_Wizard::next()      - Show the next child.
00033 //   Fl_Wizard::prev()      - Show the previous child.
00034 //   Fl_Wizard::value()     - Return the current visible child.
00035 //   Fl_Wizard::value()     - Set the visible child.
00036 //
00037 
00038 //
00039 // Include necessary header files...
00040 //
00041 
00042 #include <FL/Fl_Wizard.H>
00043 #include <FL/Fl_Window.H>
00044 #include <FL/fl_draw.H>
00045 
00046 
00047 //
00048 // 'Fl_Wizard::Fl_Wizard()' - Create an Fl_Wizard widget.
00049 //
00050 
00056 Fl_Wizard::Fl_Wizard(int        xx,     // I - Lefthand position
00057                      int        yy,     // I - Upper position
00058                      int        ww,     // I - Width
00059                      int        hh,     // I - Height
00060                      const char *l) :   // I - Label
00061     Fl_Group(xx, yy, ww, hh, l)
00062 {
00063   box(FL_THIN_UP_BOX);
00064 
00065   value_ = (Fl_Widget *)0;
00066 }
00067 
00068 
00069 //
00071 void Fl_Wizard::draw() {
00072   Fl_Widget     *kid;   // Visible child
00073 
00074 
00075   kid = value();
00076 
00077   if (damage() & FL_DAMAGE_ALL)
00078   {
00079     // Redraw everything...
00080     if (kid)
00081     {
00082       draw_box(box(), x(), y(), w(), h(), kid->color());
00083       draw_child(*kid);
00084     }
00085     else
00086       draw_box(box(), x(), y(), w(), h(), color());
00087 
00088   }
00089   else if (kid)
00090     update_child(*kid);
00091 }
00092 
00093 
00098 void Fl_Wizard::next() {
00099   int                   num_kids;
00100   Fl_Widget     * const *kids;
00101 
00102 
00103   if ((num_kids = children()) == 0)
00104     return;
00105 
00106   for (kids = array(); num_kids > 0; kids ++, num_kids --)
00107     if ((*kids)->visible())
00108       break;
00109 
00110   if (num_kids > 1)
00111     value(kids[1]);
00112 }
00113 
00115 void Fl_Wizard::prev()
00116 {
00117   int                   num_kids;
00118   Fl_Widget     * const *kids;
00119 
00120 
00121   if ((num_kids = children()) == 0)
00122     return;
00123 
00124   for (kids = array(); num_kids > 0; kids ++, num_kids --)
00125     if ((*kids)->visible())
00126       break;
00127 
00128   if (num_kids > 0 && num_kids < children())
00129     value(kids[-1]);
00130 }
00131 
00133 Fl_Widget* Fl_Wizard::value()
00134 {
00135   int                   num_kids;
00136   Fl_Widget     * const *kids;
00137   Fl_Widget             *kid;
00138 
00139 
00140   if ((num_kids = children()) == 0)
00141     return ((Fl_Widget *)0);
00142 
00143   for (kids = array(), kid = (Fl_Widget *)0; num_kids > 0; kids ++, num_kids --)
00144   {
00145     if ((*kids)->visible())
00146     {
00147       if (kid)
00148         (*kids)->hide();
00149       else
00150         kid = *kids;
00151     }
00152   }
00153 
00154   if (!kid)
00155   {
00156     kids --;
00157     kid = *kids;
00158     kid->show();
00159   }
00160 
00161   return (kid);
00162 }
00163 
00165 void Fl_Wizard::value(Fl_Widget *kid)
00166 {
00167   int                   num_kids;
00168   Fl_Widget     * const *kids;
00169 
00170 
00171   if ((num_kids = children()) == 0)
00172     return;
00173 
00174   for (kids = array(); num_kids > 0; kids ++, num_kids --)
00175   {
00176     if (*kids == kid)
00177     {
00178       if (!kid->visible())
00179         kid->show();
00180     }
00181     else
00182       (*kids)->hide();
00183   }
00184 
00185   // This will restore the mouse pointer to the window's default cursor
00186   // whenever the wizard pane is changed.  Otherwise text widgets that
00187   // show the next pane may leave the cursor set to the I beam, etc...
00188   if (window()) window()->cursor(FL_CURSOR_DEFAULT);
00189 }
00190 
00191 
00192 
00193 //
00194 // End of "$Id: Fl_Wizard.cxx 7903 2010-11-28 21:06:39Z matt $".
00195 //