libyui  3.3.2
YWizard.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YWizard.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #define YUILogComponent "ui"
27 #include "YUILog.h"
28 
29 #include "YWizard.h"
30 #include "YPushButton.h"
31 
32 
34 {
35  YWizardPrivate( YWizardMode wizardMode )
36  : wizardMode( wizardMode )
37  , nextButtonIsProtected( false )
38  {}
39 
40  YWizardMode wizardMode;
41  bool nextButtonIsProtected;
42 };
43 
44 
45 
46 
48  const std::string & backButtonLabel,
49  const std::string & abortButtonLabel,
50  const std::string & nextButtonLabel,
51  YWizardMode wizardMode )
52  : YWidget( parent )
53  , priv( new YWizardPrivate( wizardMode ) )
54 {
55  YUI_CHECK_NEW( priv );
56 
57  // On the YWidget level, a Wizard has a content area and a couple of
58  // buttons as children, so simply subclassing from YSimpleChildManager
59  // won't do; a children manager that can handle more children is needed.
61 
62  setDefaultStretchable( YD_HORIZ, true );
63  setDefaultStretchable( YD_VERT, true );
64 }
65 
66 
68 {
69  // NOP
70 }
71 
72 
75 {
76  return priv->wizardMode;
77 }
78 
79 bool
81 {
82  return priv->nextButtonIsProtected;
83 }
84 
85 
86 void
88 {
89  priv->nextButtonIsProtected = protect;
90 }
91 
92 
93 void
94 YWizard::setButtonLabel( YPushButton * button, const std::string & label )
95 {
96  // FIXME: Throw exception? ( YUI_CHECK_PTR() )
97 
98  if ( button )
99  button->setLabel( label );
100  else
101  yuiError() << "NULL button" << std::endl;
102 }
103 
104 
105 void
107 {
108  yuiDebug() << "YWizard is active" << std::endl;
109 }
110 
111 
112 const YPropertySet &
114 {
115  static YPropertySet propSet;
116 
117  if ( propSet.isEmpty() )
118  {
119  /*
120  * @property std::string CurrentItem the currently selected tree item (read only)
121  */
122  propSet.add( YProperty( YUIProperty_CurrentItem, YStringProperty, true ) ); // read-only
123  propSet.add( YWidget::propertySet() );
124  }
125 
126  return propSet;
127 }
128 
129 
131 YWizard::getProperty( const std::string & propertyName )
132 {
133  propertySet().check( propertyName ); // throws exceptions if not found
134 
135  if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( YOtherProperty );
136  else
137  {
138  return YWidget::getProperty( propertyName );
139  }
140 }
YWizardMode
Kind of the wizard layout.
Definition: YWizard.h:42
void ping()
NOP command to check if a YWizard is running.
Definition: YWizard.cc:106
bool isEmpty() const
Returns &#39;true&#39; if this property set does not contain anything.
Definition: YProperty.h:263
void setChildrenManager(YWidgetChildrenManager *manager)
Sets a new children manager for this widget.
Definition: YWidget.cc:164
Transport class for the value of simple properties.
Definition: YProperty.h:104
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:145
Author: Stefan Hundhammer sh@suse.de
A set of properties to check names and types against.
Definition: YProperty.h:197
YWizard(YWidget *parent, const std::string &backButtonLabel, const std::string &abortButtonLabel, const std::string &nextButtonLabel, YWizardMode wizardMode=YWizardMode_Standard)
Constructor.
Definition: YWizard.cc:47
virtual ~YWizard()
Destructor.
Definition: YWizard.cc:67
virtual void setButtonLabel(YPushButton *button, const std::string &newLabel)
Set the label of one of the wizard buttons (backButton(), abortButton(), nextButton() ) if that butto...
Definition: YWizard.cc:94
Abstract base template class for children management, such as child widgets.
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YWizard.cc:113
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YWidget.cc:393
A push button; may have an icon, and a F-key shortcut.
Definition: YPushButton.h:37
bool nextButtonIsProtected() const
Check if the wizard&#39;s "Next" button is currently protected against disabling.
Definition: YWizard.cc:80
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:453
YWizardMode wizardMode() const
Return the wizard mode (what kind of wizard this is): YWizardMode_Standard, YWizardMode_Steps, YWizardMode_Tree, YWizardMode_TitleOnLeft.
Definition: YWizard.cc:74
void setDefaultStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch".
Definition: YWidget.cc:561
Class for widget properties.
Definition: YProperty.h:51
void protectNextButton(bool protect)
Protect the wizard&#39;s "Next" button against disabling.
Definition: YWizard.cc:87
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWizard.cc:131
void check(const std::string &propertyName) const
Check if a property &#39;propertyName&#39; exists in this property set.
Definition: YProperty.cc:87
virtual void setLabel(const std::string &label)
Set the label (the text on the button).
Definition: YPushButton.cc:80
Abstract base class of all UI widgets.
Definition: YWidget.h:54