Author: sh-sh-sh
Date: Tue Jun 12 17:44:31 2007
New Revision: 38413
URL: http://svn.opensuse.org/viewcvs/yast?rev=38413&view=rev
Log:
use factory
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
branches/tmp/sh/mod-ui/core/libyui/src/YContainerWidget.cc
branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc
branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog Tue Jun 12 17:44:31 2007
@@ -26,6 +26,12 @@
perl -p -i -e 's/virtual char \*widgetClass/virtual const char *widgetClass/' *.h
+* Factories:
+ * Derived UIs now are required to implement:
+ * YWidgetFactory * createWidgetFactory()
+ * YOptionalWidgetFactory * createOptionalWidgetFactory()
+ * Moved widget creation methods to factories
+
* YRadioButton:
@@ -61,7 +67,7 @@
* overloaded virtual setInputMaxLength( int ) is now required to call
YTextEntry::setInputMaxLength() at its end
-
+
* YPushButton:
* Made all memeber variables private.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YContainerWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YContainerWidget.cc?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YContainerWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YContainerWidget.cc Tue Jun 12 17:44:31 2007
@@ -51,8 +51,8 @@
{
if ( ! isValid() )
{
- y2error( "YContainerWidget::childDeleted( deletedChild=%s #%d ): Invalid container widget",
- deletedChild->widgetClass(), deletedChild->internalId() );
+ y2error( "YContainerWidget::childDeleted( deletedChild=%s ): Invalid container widget",
+ deletedChild->widgetClass() );
return;
}
@@ -149,8 +149,8 @@
if ( descr.empty() )
{
- y2milestone( "Widget tree: %s%s #%d %sat %p",
- indentation.c_str(), w->widgetClass(), w->internalId(), stretch.c_str(), w );
+ y2milestone( "Widget tree: %s%s %sat %p",
+ indentation.c_str(), w->widgetClass(), stretch.c_str(), w );
}
else
{
@@ -188,9 +188,8 @@
{
if ( find( children.begin(), children.end(), child ) != children.end() )
{
- y2error( "ERROR: Child added twice (%s, #%d) (%s, #%d)",
- this->widgetClass(), this->internalId(),
- child->widgetClass(), child->internalId() );
+ y2error( "ERROR: Child added twice: %s vs. %s",
+ this->widgetClass(), child->widgetClass() );
return;
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc Tue Jun 12 17:44:31 2007
@@ -18,6 +18,8 @@
#include "YOptionalWidgetFactory.h"
#include "YUIException.h"
+#include "YLabel.h"
+#include "YUI.h"
#define THROW_UNSUPPORTED( WIDGET_TYPE ) \
@@ -25,19 +27,15 @@
return 0
-bool YOptionalWidgetFactory::hasDummySpecialWidget()
+
+YOptionalWidgetFactory::YOptionalWidgetFactory()
{
- return true;
+ // NOP
}
-YDummySpecialWidget *
-YOptionalWidgetFactory::createDummySpecialWidget( YWidget * parent )
+YOptionalWidgetFactory::~YOptionalWidgetFactory()
{
-#if 0
- YUI::widgetFactory()->createOutputField( parent, "YDummySpecialWidget" );
-#else
- return 0;
-#endif
+ // NOP
}
@@ -47,7 +45,8 @@
return false;
}
-YWizard * YOptionalWidgetFactory::createWizard( YWidget * parent )
+YWizard *
+YOptionalWidgetFactory::createWizard( YWidget * parent )
{
THROW_UNSUPPORTED( "YWizard" );
}
@@ -128,7 +127,7 @@
return false;
}
-YPatternSelector *
+YWidget *
YOptionalWidgetFactory::createPatternSelector( YWidget * parent )
{
THROW_UNSUPPORTED( "YPatternSelector" );
@@ -141,7 +140,7 @@
return false;
}
-YSimplePatchSelector *
+YWidget *
YOptionalWidgetFactory::createSimplePatchSelector( YWidget * parent )
{
THROW_UNSUPPORTED( "YSimplePatchSelector" );
@@ -173,7 +172,8 @@
return false;
}
-YPartitionSplitter * YOptionalWidgetFactory::createPartitionSplitter( YWidget * parent )
+YPartitionSplitter *
+YOptionalWidgetFactory::createPartitionSplitter( YWidget * parent )
{
THROW_UNSUPPORTED( "YPartitionSplitter" );
}
@@ -193,3 +193,17 @@
{
THROW_UNSUPPORTED( "YDownloadProgress" );
}
+
+
+
+bool YOptionalWidgetFactory::hasDummySpecialWidget()
+{
+ return true;
+}
+
+YWidget *
+YOptionalWidgetFactory::createDummySpecialWidget( YWidget * parent )
+{
+ return YUI::widgetFactory()->createOutputField( parent, "YDummySpecialWidget" );
+}
+
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h Tue Jun 12 17:44:31 2007
@@ -32,8 +32,6 @@
class YDummySpecialWidget;
class YMultiProgressMeter;
class YPartitionSplitter;
-class YPatternSelector;
-class YSimplePatchSelector;
class YSlider;
class YTimeField;
class YWidget;
@@ -41,7 +39,7 @@
/**
- * Widget factory for optional ("special") widgets.
+ * Abstract widget factory for optional ("special") widgets.
*
* Remember to always check with the corresponding "has..()" method if the
* current UI actually provides the requested widget. Otherwise the
@@ -55,10 +53,6 @@
// Optional Widgets
//
- virtual bool hasDummySpecialWidget();
- virtual YDummySpecialWidget * createDummySpecialWidget( YWidget * parent );
-
-
virtual bool hasWizard();
virtual YWizard * createWizard ( YWidget * parent );
@@ -82,10 +76,10 @@
virtual YBarGraph * createBarGraph ( YWidget * parent, list<int> values, list<string> labels );
virtual bool hasPatternSelector();
- virtual YPatternSelector * createPatternSelector ( YWidget * parent );
+ virtual YWidget * createPatternSelector ( YWidget * parent );
virtual bool hasSimplePatchSelector();
- virtual YSimplePatchSelector * createSimplePatchSelector( YWidget * parent );
+ virtual YWidget * createSimplePatchSelector( YWidget * parent );
virtual bool hasMultiProgressMeter();
virtual YMultiProgressMeter * createHMultiProgressMeter( YWidget * parent, const string & label, list<int> maxValues );
@@ -101,6 +95,10 @@
long expectedFileSize );
// FIXME: drop ColoredLabel
+
+ bool hasDummySpecialWidget();
+ YWidget * createDummySpecialWidget( YWidget * parent );
+
protected:
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc Tue Jun 12 17:44:31 2007
@@ -48,9 +48,9 @@
};
-YRadioButton::YRadioButton( const YWidgetOpt & opt,
+YRadioButton::YRadioButton( YWidget * parent,
const std::string & label )
- : YWidget( opt )
+ : YWidget( parent )
, priv( new YRadioButtonPrivate( label ) )
{
YUI_CHECK_NEW( priv );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h Tue Jun 12 17:44:31 2007
@@ -51,7 +51,7 @@
* Creates a new RadioButton with user-visible text 'label'.
* 'label' can and should contain a keyboard shortcut (designated with '&').
*/
- YRadioButton( const YWidgetOpt & opt, const std::string & label );
+ YRadioButton( YWidget * parent, const std::string & label );
/**
* Destructor: Removes the button from the radio button group.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI.h?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Tue Jun 12 17:44:31 2007
@@ -595,14 +595,6 @@
virtual YWidget *createMenuButton( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
/**
- * Creates a radio button and inserts it into a radio button group
- * @param label Label of the radio button
- * @param rbg the radio button group the new button will belong to
- */
- virtual YWidget *createRadioButton( YWidget *parent, YWidgetOpt & opt, YRadioButtonGroup *rbg,
- const std::string & label, bool checked ) = 0;
-
- /**
* Creates a check box
* @param label Label of the checkbox
* @param true if it is checked
@@ -1290,16 +1282,14 @@
* Creates a RadioButton.
*/
YWidget *createRadioButton( YWidget *parent, YWidgetOpt & opt,
- const YCPTerm & term, const YCPList & optList, int argnr,
- YRadioButtonGroup *rbg );
+ const YCPTerm & term, const YCPList & optList, int argnr );
/**
* Helper function of createWidgetTree.
* Creates a RadioButtonGroup.
*/
YWidget *createRadioButtonGroup( YWidget *parent, YWidgetOpt & opt,
- const YCPTerm & term, const YCPList & optList, int argnr,
- YRadioButtonGroup *rbg );
+ const YCPTerm & term, const YCPList & optList, int argnr );
/**
* Helper function of createWidgetTree.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.cc?rev=38413&r1=38412&r2=38413&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.cc Tue Jun 12 17:44:31 2007
@@ -208,7 +208,7 @@
else if ( s == YUIWidget_MinHeight ) w = createMinSize ( p, opt, term, ol, n, rbg, false, true );
else if ( s == YUIWidget_MinSize ) w = createMinSize ( p, opt, term, ol, n, rbg, true, true );
else if ( s == YUIWidget_MinWidth ) w = createMinSize ( p, opt, term, ol, n, rbg, true, false );
- else if ( s == YUIWidget_RadioButtonGroup ) w = createRadioButtonGroup ( p, opt, term, ol, n, rbg );
+ else if ( s == YUIWidget_RadioButtonGroup ) w = createRadioButtonGroup ( p, opt, term, ol, n );
else if ( s == YUIWidget_Right ) w = createAlignment ( p, opt, term, ol, n, rbg, YAlignEnd, YAlignUnchanged );
else if ( s == YUIWidget_Top ) w = createAlignment ( p, opt, term, ol, n, rbg, YAlignUnchanged, YAlignBegin );
else if ( s == YUIWidget_VBox ) w = createLBox ( p, opt, term, ol, n, rbg, YD_VERT );
@@ -239,7 +239,7 @@
else if ( s == YUIWidget_PushButton ) w = createPushButton ( p, opt, term, ol, n, false );
else if ( s == YUIWidget_IconButton ) w = createPushButton ( p, opt, term, ol, n, true );
else if ( s == YUIWidget_MenuButton ) w = createMenuButton ( p, opt, term, ol, n );
- else if ( s == YUIWidget_RadioButton ) w = createRadioButton ( p, opt, term, ol, n, rbg );
+ else if ( s == YUIWidget_RadioButton ) w = createRadioButton ( p, opt, term, ol, n );
else if ( s == YUIWidget_RichText ) w = createRichText ( p, opt, term, ol, n );
else if ( s == YUIWidget_SelectionBox ) w = createSelectionBox ( p, opt, term, ol, n );
else if ( s == YUIWidget_Table ) w = createTable ( p, opt, term, ol, n );
@@ -1601,17 +1601,16 @@
* user can select one radio button of a group. It is much like a selection
* box, but radio buttons can be dispersed over the dialog. Radio buttons must
* be contained in a <tt>RadioButtonGroup</tt>.
- *
- */
+ **/
YWidget * YUI::createRadioButton( YWidget * parent, YWidgetOpt & opt, const YCPTerm & term, const YCPList & optList,
- int argnr, YRadioButtonGroup * rbg )
+ int argnr )
{
int s = term->size() - argnr;
if ( s < 1 || s > 2
- || !term->value(argnr)->isString()
- || (s == 2 && !term->value(argnr+1)->isBoolean()))
+ || ! term->value( argnr )->isString()
+ || ( s == 2 && ! term->value( argnr+1 )->isBoolean() ) )
{
y2error( "Invalid arguments for the RadioButton widget: %s",
term->toString().c_str() );
@@ -1619,27 +1618,13 @@
}
rejectAllOptions( term,optList );
- YCPBoolean checked( false );
- if ( s == 2 ) checked = term->value( argnr+1 )->asBoolean();
-
- if ( ! rbg )
- {
- y2error( "%s: must be inside a RadioButtonGroup",
- term->toString().c_str() );
- return 0;
- }
-
- YRadioButton *radioButton =
- dynamic_cast