libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YWizard.cc
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:         YWizard.cc
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #define YUILogComponent "ui"
00027 #include "YUILog.h"
00028 
00029 #include "YWizard.h"
00030 #include "YPushButton.h"
00031 
00032 
00033 struct YWizardPrivate
00034 {
00035     YWizardPrivate( YWizardMode wizardMode )
00036         : wizardMode( wizardMode )
00037         , nextButtonIsProtected( false )
00038         {}
00039 
00040     YWizardMode wizardMode;
00041     bool        nextButtonIsProtected;
00042 };
00043 
00044 
00045 
00046 
00047 YWizard::YWizard( YWidget *             parent,
00048                   const std::string &   backButtonLabel,
00049                   const std::string &   abortButtonLabel,
00050                   const std::string &   nextButtonLabel,
00051                   YWizardMode           wizardMode )
00052     : YWidget( parent )
00053     , priv( new YWizardPrivate( wizardMode ) )
00054 {
00055     YUI_CHECK_NEW( priv );
00056 
00057     // On the YWidget level, a Wizard has a content area and a couple of
00058     // buttons as children, so simply subclassing from YSimpleChildManager
00059     // won't do; a children manager that can handle more children is needed.
00060     setChildrenManager( new YWidgetChildrenManager( this ) );
00061 
00062     setDefaultStretchable( YD_HORIZ, true );
00063     setDefaultStretchable( YD_VERT,  true );
00064 }
00065 
00066 
00067 YWizard::~YWizard()
00068 {
00069     // NOP
00070 }
00071 
00072 
00073 YWizardMode
00074 YWizard::wizardMode() const
00075 {
00076     return priv->wizardMode;
00077 }
00078 
00079 bool
00080 YWizard::nextButtonIsProtected() const
00081 {
00082     return priv->nextButtonIsProtected;
00083 }
00084 
00085 
00086 void
00087 YWizard::protectNextButton( bool protect )
00088 {
00089     priv->nextButtonIsProtected = protect;
00090 }
00091 
00092 
00093 void
00094 YWizard::setButtonLabel( YPushButton * button, const std::string & label )
00095 {
00096     // FIXME: Throw exception? ( YUI_CHECK_PTR() )
00097 
00098     if ( button )
00099         button->setLabel( label );
00100     else
00101         yuiError() << "NULL button" << std::endl;
00102 }
00103 
00104 
00105 void
00106 YWizard::ping()
00107 {
00108     yuiDebug() << "YWizard is active" << std::endl;
00109 }
00110 
00111 
00112 const YPropertySet &
00113 YWizard::propertySet()
00114 {
00115     static YPropertySet propSet;
00116 
00117     if ( propSet.isEmpty() )
00118     {
00119         /*
00120          * @property std::string        CurrentItem     the currently selected tree item (read only)
00121          */
00122         propSet.add( YProperty( YUIProperty_CurrentItem, YStringProperty, true ) );     // read-only
00123         propSet.add( YWidget::propertySet() );
00124     }
00125 
00126     return propSet;
00127 }
00128 
00129 
00130 YPropertyValue
00131 YWizard::getProperty( const std::string & propertyName )
00132 {
00133     propertySet().check( propertyName ); // throws exceptions if not found
00134 
00135     if ( propertyName == YUIProperty_CurrentItem )      return YPropertyValue( YOtherProperty );
00136     else
00137     {
00138         return YWidget::getProperty( propertyName );
00139     }
00140 }
 All Classes Functions Variables Enumerations Friends