libyui  3.10.0
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 using std::string;
33 
34 
36 {
37  YWizardPrivate( YWizardMode wizardMode )
38  : wizardMode( wizardMode )
39  , nextButtonIsProtected( false )
40  {}
41 
42  YWizardMode wizardMode;
43  bool nextButtonIsProtected;
44 };
45 
46 
47 
48 
50  const string & backButtonLabel,
51  const string & abortButtonLabel,
52  const string & nextButtonLabel,
53  YWizardMode wizardMode )
54  : YWidget( parent )
55  , priv( new YWizardPrivate( wizardMode ) )
56 {
57  YUI_CHECK_NEW( priv );
58 
59  // On the YWidget level, a Wizard has a content area and a couple of
60  // buttons as children, so simply subclassing from YSimpleChildManager
61  // won't do; a children manager that can handle more children is needed.
63 
64  setDefaultStretchable( YD_HORIZ, true );
65  setDefaultStretchable( YD_VERT, true );
66 }
67 
68 
70 {
71  // NOP
72 }
73 
74 
77 {
78  return priv->wizardMode;
79 }
80 
81 bool
83 {
84  return priv->nextButtonIsProtected;
85 }
86 
87 
88 void
90 {
91  priv->nextButtonIsProtected = protect;
92 }
93 
94 
95 void
96 YWizard::setButtonLabel( YPushButton * button, const string & label )
97 {
98  // FIXME: Throw exception? ( YUI_CHECK_PTR() )
99 
100  if ( button )
101  button->setLabel( label );
102  else
103  yuiError() << "NULL button" << endl;
104 }
105 
106 
107 void
109 {
110  yuiDebug() << "YWizard is active" << endl;
111 }
112 
113 
114 const YPropertySet &
116 {
117  static YPropertySet propSet;
118 
119  if ( propSet.isEmpty() )
120  {
121  /*
122  * @property string CurrentItem the currently selected tree item (read only)
123  */
124  propSet.add( YProperty( YUIProperty_CurrentItem, YStringProperty, true ) ); // read-only
125  propSet.add( YWidget::propertySet() );
126  }
127 
128  return propSet;
129 }
130 
131 
133 YWizard::getProperty( const string & propertyName )
134 {
135  propertySet().check( propertyName ); // throws exceptions if not found
136 
137  if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( YOtherProperty );
138  else
139  {
140  return YWidget::getProperty( propertyName );
141  }
142 }
Author: Stefan Hundhammer sh@suse.de
YWizardMode
Kind of the wizard layout.
Definition: YWizard.h:43
Abstract base template class for children management, such as child widgets.
A set of properties to check names and types against.
Definition: YProperty.h:198
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Definition: YProperty.cc:88
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
Definition: YProperty.h:263
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:146
Transport class for the value of simple properties.
Definition: YProperty.h:105
Class for widget properties.
Definition: YProperty.h:52
A push button; may have an icon, and a F-key shortcut.
Definition: YPushButton.h:38
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:55
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YWidget.cc:395
void setDefaultStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch".
Definition: YWidget.cc:566
void setChildrenManager(YWidgetChildrenManager *manager)
Sets a new children manager for this widget.
Definition: YWidget.cc:166
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:457
YWizard(YWidget *parent, const std::string &backButtonLabel, const std::string &abortButtonLabel, const std::string &nextButtonLabel, YWizardMode wizardMode=YWizardMode_Standard)
Constructor.
Definition: YWizard.cc:49
void ping()
NOP command to check if a YWizard is running.
Definition: YWizard.cc:108
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWizard.cc:133
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:96
virtual ~YWizard()
Destructor.
Definition: YWizard.cc:69
YWizardMode wizardMode() const
Return the wizard mode (what kind of wizard this is): YWizardMode_Standard, YWizardMode_Steps,...
Definition: YWizard.cc:76
bool nextButtonIsProtected() const
Check if the wizard's "Next" button is currently protected against disabling.
Definition: YWizard.cc:82
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YWizard.cc:115
void protectNextButton(bool protect)
Protect the wizard's "Next" button against disabling.
Definition: YWizard.cc:89