Author: sh-sh-sh
Date: Mon Jun 11 18:17:05 2007
New Revision: 38396
URL: http://svn.opensuse.org/viewcvs/yast?rev=38396&view=rev
Log:
factories
Added:
branches/tmp/sh/mod-ui/core/libyui/src/YItem.h
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/YWidgetFactory.cc
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
branches/tmp/sh/mod-ui/core/libyui/src/YUI_widgets.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/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am?rev=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Mon Jun 11 18:17:05 2007
@@ -20,6 +20,8 @@
YUIPlugin.cc \
YUIException.cc \
YProperty.cc \
+ YWidgetFactory.cc \
+ YOptionalWidgetFactory.cc \
\
YWidget.cc \
YAlignment.cc \
@@ -83,6 +85,8 @@
YUIException.h \
YProperty.h \
YChildrenManager.h \
+ YWidgetFactory.h \
+ YOptionalWidgetFactory.h \
ImplPtr.h \
\
YAlignment.h \
Added: branches/tmp/sh/mod-ui/core/libyui/src/YItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YItem.h?rev=38396&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YItem.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YItem.h Mon Jun 11 18:17:05 2007
@@ -0,0 +1,48 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YItem.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YItem_h
+#define YItem_h
+
+#include <string>
+#include <list>
+
+
+struct YItem
+{
+ string label;
+ string id;
+ bool isSelected;
+
+ YItem( string labelText )
+ : label( labelText )
+ , id( labelText )
+ , isSelected( false )
+ {}
+
+ YItem( string labelText, string idText, bool sel = false )
+ : label( labelText )
+ , id( idText )
+ , isSelected( sel )
+ {}
+}; // struct YItem
+
+typedef list<YItem> YItemList;
+
+
+#endif // YItem_h
Added: 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=38396&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc Mon Jun 11 18:17:05 2007
@@ -0,0 +1,186 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YOptionalWidgetFactory.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#include "YOptionalWigetFactory.h"
+
+
+#define THROW_UNSUPPORTED( WIDGET_TYPE ) \
+ YUI_THROW( YUIUnsupportedWidgetException( WIDGET_TYPE ) ); \
+ return 0
+
+
+bool YOptionalWidgetFactory::hasDummySpecialWidget()
+{
+ return true;
+}
+
+YDummySpecialWidget *
+YOptionalWidgetFactory::createDummySpecialWidget( YWidget * parent )
+{
+#if 0
+ YUI::widgetFactory()->createOutputField( parent, "YDummySpecialWidget" );
+#else
+ return 0;
+#endif
+}
+
+
+
+bool YOptionalWidgetFactory::hasWizard()
+{
+ return false;
+}
+
+YWizard * YOptionalWidgetFactory::createWizard( YWidget * parent )
+{
+ THROW_UNSUPPORTED( "YWizard" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasDumbTab()
+{
+ return false;
+}
+
+YDumbTab *
+YOptionalWidgetFactory::createDumbTab( YWidget * parent );
+{
+ THROW_UNSUPPORTED( "YDumbTab" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasSlider()
+{
+ return false;
+}
+
+YSlider *
+YOptionalWidgetFactory::createSlider( YWidget * parent,
+ const string & label,
+ int minVal,
+ int maxVal,
+ int initialVal
+{
+ THROW_UNSUPPORTED( "YSlider" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasDateField()
+{
+ return false;
+}
+
+YDateField * YOptionalWidgetFactory::createDateField( YWidget * parent, const string & label )
+{
+ THROW_UNSUPPORTED( "YDateField" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasTimeField()
+{
+ return false;
+}
+
+YTimeField * YOptionalWidgetFactory::createTimeField( YWidget * parent, const string & label )
+{
+ THROW_UNSUPPORTED( "YTimeField" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasBarGraph()
+{
+ return false;
+}
+
+YBarGraph * YOptionalWidgetFactory::createBarGraph( YWidget * parent, list<int> values, list<string> labels )
+{
+ THROW_UNSUPPORTED( "YBarGraph" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasPatternSelector()
+{
+ return false;
+}
+
+YPatternSelector * YOptionalWidgetFactory::createPatternSelector( YWidget * parent )
+{
+ THROW_UNSUPPORTED( "YPatternSelector" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasSimplePatchSelector()
+{
+ return false;
+}
+
+YSimplePatchSelector * YOptionalWidgetFactory::createSimplePatchSelector( YWidget * parent )
+{
+ THROW_UNSUPPORTED( "YSimplePatchSelector" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasMultiProgressMeter()
+{
+ return false;
+}
+
+YMultiProgressMeter * YOptionalWidgetFactory::createHMultiProgressMeter( YWidget * parent, const string & label, list<int> maxValues )
+{
+ THROW_UNSUPPORTED( "YMultiProgressMeter" );
+}
+
+YMultiProgressMeter * YOptionalWidgetFactory::createVMultiProgressMeter( YWidget * parent, const string & label, list<int> maxValues )
+{
+ THROW_UNSUPPORTED( "YMultiProgressMeter" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasPartitionSplitter()
+{
+ return false;
+}
+
+YPartitionSplitter * YOptionalWidgetFactory::createPartitionSplitter( YWidget * parent )
+{
+ THROW_UNSUPPORTED( "YPartitionSplitter" );
+}
+
+
+
+bool YOptionalWidgetFactory::hasDownloadProgress()
+{
+ return false;
+}
+
+YDownloadProgress * YOptionalWidgetFactory::createDownloadProgress( YWidget * parent,
+ const string & label,
+ const string & filename,
+ long expectedFileSize )
+{
+ THROW_UNSUPPORTED( "YDownloadProgress" );
+}
Added: 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=38396&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h Mon Jun 11 18:17:05 2007
@@ -0,0 +1,123 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YOptionalWidgetFactory.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YOptionalWidgetFactory_h
+#define YOptionalWidgetFactory_h
+
+#include <string>
+#include <list>
+
+using std::string;
+using std::list;
+
+class YBarGraph;
+class YDateField;
+class YDownloadProgress;
+class YDumbTab;
+class YDummySpecialWidget;
+class YMultiProgressMeter;
+class YPartitionSplitter;
+class YPatternSelector;
+class YSimplePatchSelector;
+class YSlider;
+class YTimeField;
+class YWidget;
+class YWizard;
+
+
+/**
+ * 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
+ * "create...()" method will throw an exception.
+ **/
+class YOptionalWidgetFactory
+{
+public:
+
+ //
+ // Optional Widgets
+ //
+
+ virtual bool hasDummySpecialWidget() { return false; }
+ virtual YDummySpecialWidget * createDummySpecialWidget ( YWidget * parent );
+
+
+ virtual bool hasWizard() { return false; }
+ virtual YWizard * createWizard ( YWidget * parent );
+
+ virtual bool hasDumbTab() { return false; }
+ virtual YDumbTab * createDumbTab ( YWidget * parent );
+
+ virtual bool hasSlider() { return false; }
+ virtual YSlider * createSlider ( YWidget * parent,
+ const string & label,
+ int minVal,
+ int maxVal,
+ int initialVal );
+
+ virtual bool hasDateField() { return false; }
+ virtual YDateField * createDateField ( YWidget * parent, const string & label );
+
+ virtual bool hasTimeField() { return false; }
+ virtual YTimeField * createTimeField ( YWidget * parent, const string & label );
+
+ virtual bool hasBarGraph() { return false; }
+ virtual YBarGraph * createBarGraph ( YWidget * parent, list<int> values, list<string> labels );
+
+ virtual bool hasPatternSelector() { return false; }
+ virtual YPatternSelector * createPatternSelector ( YWidget * parent );
+
+ virtual bool hasSimplePatchSelector() { return false; }
+ virtual YSimplePatchSelector * createSimplePatchSelector ( YWidget * parent );
+
+ virtual bool hasMultiProgressMeter() { return false; }
+ virtual YMultiProgressMeter * createHMultiProgressMeter ( YWidget * parent, const string & label, list<int> maxValues );
+ virtual YMultiProgressMeter * createVMultiProgressMeter ( YWidget * parent, const string & label, list<int> maxValues );
+
+ virtual bool hasPartitionSplitter() { return false; }
+ virtual YPartitionSplitter * createPartitionSplitter ( YWidget * parent );
+
+ virtual bool hasDownloadProgress() { return false; }
+ virtual YDownloadProgress * createDownloadProgress ( YWidget * parent, const string & label, const string & filename, long expectedFileSize );
+
+ // FIXME: drop ColoredLabel
+
+
+protected:
+
+ friend class YUI;
+
+ /**
+ * Constructor.
+ *
+ * Use YUI::optionalWidgetFactory() to get the singleton for this class.
+ **/
+ YOptionalWidgetFactory();
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YOptionalWidgetFactory();
+
+}; // class YOptionalWidgetFactory
+
+
+
+#endif // YOptionalWidgetFactory_h
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=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Mon Jun 11 18:17:05 2007
@@ -32,6 +32,7 @@
#include
#include
+#include "YWidgetFactory.h"
#include "YWidget.h"
#include "YAlignment.h"
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h?rev=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h Mon Jun 11 18:17:05 2007
@@ -454,8 +454,8 @@
class YUIUnknownPropertyException: public YUIPropertyException
{
public:
- YUIUnknownPropertyException( const std::string & propertyName,
- YWidget * widget = 0 )
+ YUIUnknownPropertyException( const string & propertyName,
+ YWidget * widget = 0 )
: YUIPropertyException( YProperty( propertyName, YUnknownPropertyType ), widget )
{}
@@ -547,6 +547,9 @@
, _container( container )
{}
+ virtual ~YUITooManyChildrenException() throw()
+ {}
+
/**
* Returns the container widget that can't handle that many children.
**/
@@ -560,7 +563,7 @@
**/
virtual ostream & dumpOn( ostream & str ) const
{
- std::string widgetClass =
+ string widgetClass =
container() ? container()->widgetClass() :
"widget";
@@ -591,6 +594,9 @@
, _child( child )
{}
+ virtual ~YUIInvalidChildException() throw()
+ {}
+
/**
* Returns the container widget whose child should be removed etc.
**/
@@ -609,11 +615,11 @@
**/
virtual ostream & dumpOn( ostream & str ) const
{
- std::string containerWidgetClass =
+ string containerWidgetClass =
container() ? container()->widgetClass() :
"widget";
- std::string childWidgetClass =
+ string childWidgetClass =
child() ? child()->widgetClass() :
"<Null>";
@@ -630,6 +636,20 @@
};
+
+class YUIUnsupportedWidgetException: public YUIException
+{
+public:
+
+ YUIUnsupportedWidgetException( const string & widgetType )
+ : YUIException( string( "Unsupported optional widget type: " ) + widgetType )
+ {}
+
+ virtual ~YUIUnsupportedWidgetException() throw()
+ {}
+};
+
+
//
// Helper templates
//
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc?rev=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc Mon Jun 11 18:17:05 2007
@@ -748,13 +748,13 @@
if ( widget )
{
- dialog->addChild( widget );
- dialog->setInitialSize();
- dialog->checkShortcuts();
- showDialog( dialog );
+ dialog->addChild( widget );
+ dialog->setInitialSize();
+ dialog->checkShortcuts();
+ showDialog( dialog );
- unblockEvents();
- return YCPBoolean( true );
+ unblockEvents();
+ return YCPBoolean( true );
}
else removeDialog();
}
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=38396&r1=38395&r2=38396&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 Mon Jun 11 18:17:05 2007
@@ -459,8 +459,8 @@
{
// Process parameters
- float size = 1.0;
- bool param_ok = false;
+ float size = 1.0;
+ bool param_ok = false;
if ( term->size() == argnr ) // no parameter
{
@@ -984,7 +984,8 @@
/**
- * @todo doxyden does not understand this. disable.
+ * @todo doxygen does not understand this. disable.
+ *
* @widgets HBox VBox
* @id Box
* @short Generic layout: Arrange widgets horizontally or vertically
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h?rev=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h Mon Jun 11 18:17:05 2007
@@ -41,13 +41,19 @@
class YWidget;
-typedef std::list YWidgetList;
-typedef std::list::iterator YWidgetListIterator;
-typedef std::list::const_iterator YWidgetListConstIterator;
-
-typedef YChildrenManager<YWidget> YWidgetChildrenManager;
-typedef YSingleChildManager<YWidget> YSingleWidgetChildManager;
-typedef YChildrenRejector<YWidget> YWidgetChildrenRejector;
+using std::string;
+using std::list;
+
+typedef list YWidgetList;
+typedef list::iterator YWidgetListIterator;
+typedef list::const_iterator YWidgetListConstIterator;
+
+typedef YChildrenManager<YWidget> YWidgetChildrenManager;
+typedef YSingleChildManager<YWidget> YSingleWidgetChildManager;
+typedef YChildrenRejector<YWidget> YWidgetChildrenRejector;
+
+typedef double YLayoutSize_t;
+
class YWidgetPrivate;
@@ -85,7 +91,7 @@
* Note: This is usually translated to the user's target language.
* This makes this useful for debugging only.
**/
- virtual std::string debugLabel();
+ virtual string debugLabel();
//
@@ -134,7 +140,7 @@
* - if the expected type and the type mismatch
* - if the value is out of range
**/
- virtual void setProperty( const std::string & propertyName,
+ virtual void setProperty( const string & propertyName,
const YPropertyValue & val );
// FIXME: = 0
@@ -144,7 +150,7 @@
* This method may throw exceptions, for example
* - if there is no property with that name
**/
- virtual YPropertyValue getProperty( const std::string & propertyName );
+ virtual YPropertyValue getProperty( const string & propertyName );
// FIXME: = 0
@@ -524,7 +530,7 @@
*
* Overwrite this for widgets that can have keyboard shortcuts.
**/
- virtual std::string shortcutString() { return std::string( "" ); }
+ virtual string shortcutString() { return string( "" ); }
/**
* Set the string of this widget that holds the keyboard shortcut, if any.
@@ -532,7 +538,7 @@
*
* Overwrite this for widgets that can have keyboard shortcuts.
**/
- virtual void setShortcutString( const std::string & str );
+ virtual void setShortcutString( const string & str );
/**
* The name of the widget property that will return user input, if there is
Added: branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.cc?rev=38396&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.cc Mon Jun 11 18:17:05 2007
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YWidgetFactory.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#include "YWidgetFactory.h"
+
+
+YAlignment *
+YWidgetFactory::createLeft( YWidget * parent )
+{
+ return createAlignment( parent, YAlignBegin, YAlignUnchanged );
+}
+
+
+YAlignment *
+YWidgetFactory::createRight( YWidget * parent )
+{
+ return createAlignment( parent, YAlignEnd, YAlignUnchanged );
+}
+
+
+YAlignment *
+YWidgetFactory::createTop( YWidget * parent )
+{
+ return createAlignment( parent, YAlignUnchanged, YAlignBegin );
+}
+
+
+YAlignment *
+YWidgetFactory::createBottom( YWidget * parent )
+{
+ return createAlignment( parent, YAlignUnchanged, YAlignEnd );
+}
+
+
+YAlignment *
+YWidgetFactory::createHCenter( YWidget * parent )
+{
+ return createAlignment( parent, YAlignCenter, YAlignUnchanged );
+}
+
+
+YAlignment *
+YWidgetFactory::createVCenter( YWidget * parent )
+{
+ return createAlignment( parent, YAlignUnchanged, YAlignCenter );
+}
+
+
+YAlignment *
+YWidgetFactory::createHVCenter( YWidget * parent )
+{
+ return createAlignment( parent, YAlignCenter, YAlignCenter );
+}
+
+
+YAlignment *
+YWidgetFactory::createMarginBox( YWidget * parent, YLayoutSize_t horMargin, YLayoutSize_t vertMargin )
+{
+ return createMarginBox( parent,
+ horMargin, horMargin,
+ vertMargin, vertMargin );
+}
+
+
+YAlignment *
+YWidgetFactory::createMinWidth( YWidget * parent, YLayoutSize_t minWidth )
+{
+ return createMinSize( parent, minWidth, 0 );
+}
+
+
+YAlignment *
+YWidgetFactory::createMinHeight( YWidget * parent, YLayoutSize_t minHeight )
+{
+ return createMinSize( parent, 0, minHeight );
+}
+
+
+YSquash *
+YWidgetFactory::createHSquash( YWidget * parent )
+{
+ return createSquash( parent, true, false );
+}
+
+
+YSquash *
+YWidgetFactory::createVSquash( YWidget * parent )
+{
+ return createSquash( parent, false, true );
+}
+
+
+YSquash *
+YWidgetFactory::createHVSquash( YWidget * parent )
+{
+ return createSquash( parent, true, true );
+}
+
+
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.h?rev=38396&r1=38395&r2=38396&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidgetFactory.h Mon Jun 11 18:17:05 2007
@@ -20,191 +20,169 @@
#define YWidgetFactory_h
#include <string>
-#include <list>
-namespace YUI
-{
- typedef double YLayoutSize_t;
+#include "YWidget.h"
+#include "YAlignment.h" // YAlignmentType
+
+using std::string;
+
+class YCheckBox;
+class YCheckBoxFrame;
+class YComboBox;
+class YDialog;
+class YEmpty;
+class YFrame;
+class YHBox;
+class YImage;
+class YInputField;
+class YIntField;
+class YLabel;
+class YLogView;
+class YMenuButton;
+class YMultiLineEdit;
+class YPackageSelector;
+class YPkgSpecial;
+class YProgressBar;
+class YPushButton;
+class YRadioButton;
+class YRadioButtonGroup;
+class YReplacePoint;
+class YRichText;
+class YSelectionBox;
+class YSquash;
+class YTable;
+class YTimeField;
+class YTree;
+class YVBox;
-
- class YWidgetFactory
- {
- public:
-
- //
- // Dialogs
- //
-
- YDialog * createMainDialog();
- YDialog * createPopupDialog();
-
- //
- // Layout Boxes
- //
-
- YVBox * createVBox ( YWidget * parent );
- YHBox * createHBox ( YWidget * parent );
-
- //
- // Common Leaf Widgets
- //
-
- YPushButton * createPushButton ( YWidget * parent, std::string label );
- YLabel * createHeading ( YWidget * parent, std::string label );
- YLabel * createLabel ( YWidget * parent, std::string label );
- YInputField * createInputField ( YWidget * parent, std::string label );
- YCheckBox * createCheckBox ( YWidget * parent, std::string label, bool isChecked = false );
- YRadioButton * createRadioButton ( YWidget * parent, std::string label, bool isChecked = false );
- YComboBox * createComboBox ( YWidget * parent, std::string label, bool editable = false );
- YSelectionBox * createSelectionBox ( YWidget * parent, std::string label );
- YTree * createTree ( YWidget * parent, std::string label );
- YTable * createTable ( YWidget * parent );
- YProgressBar * createProgressBar ( YWidget * parent, std::string label, int maxValue = 100 );
- YRichText * createRichText ( YWidget * parent );
-
- //
- // Less Common Leaf Widgets
- //
-
- YIntField * createIntField ( YWidget * parent, std::string label, int minVal, int maxVal, int initialVal );
- YInputField * createPasswordField ( YWidget * parent, std::string label );
- YLabel * createOutputField ( YWidget * parent, std::string label );
-
- YMenuButton * createMenuButton ( YWidget * parent, std::string label );
- YPushButton * createIconButton ( YWidget * parent, std::string iconName, std::string fallbackTextLabel );
- YMultiLineEdit * createMultiLineEdit ( YWidget * parent, std::string label );
- YImage * createImage ( YWidget * parent, std::string imagePath );
- YLogView * createLogView ( YWidget * parent, std::string label, int visibleLines, int storedLines = 0 );
- YSelectionBox * createMultiSelectionBox ( YWidget * parent, std::string label );
-
- YPackageSelector *createPackageSelector ( YWidget * parent );
- YPkgSpecial *createPkgSpecial ( YWidget * parent ); // NCurses only
-
- //
- // Layout Helpers
- //
-
- YEmpty * createHStretch ( YWidget * parent );
- YEmpty * createVStretch ( YWidget * parent );
- YEmpty * createHSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 );
- YEmpty * createVSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 );
- YEmpty * createEmpty ( YWidget * parent );
-
- YAlignment * createLeft ( YWidget * parent );
- YAlignment * createRight ( YWidget * parent );
- YAlignment * createTop ( YWidget * parent );
- YAlignment * createBottom ( YWidget * parent );
- YAlignment * createHCenter ( YWidget * parent );
- YAlignment * createVCenter ( YWidget * parent );
- YAlignment * createHVCenter ( YWidget * parent );
- YAlignment * createAlignment ( YWidget * parent, YAlignment::Alignment horAlignment, YAlignment::Alignment vertAlignment );
-
- YAlignment * createMarginBox ( YWidget * parent, YLayoutSize_t horMargin, YLayoutSize_t vertMargin );
- YAlignment * createMarginBox ( YWidget * parent,
- YLayoutSize_t leftMargin, YLayoutSize_t rightMargin,
- YLayoutSize_t topMargin, YLayoutSize_t bottomMargin );
-
- YAlignment * createMinWidth ( YWidget * parent, YLayoutSize_t minWidth );
- YAlignment * createMinHeight ( YWidget * parent, YLayoutSize_t minHeight );
- YAlignment * createMinSize ( YWidget * parent, YLayoutSize_t minWidth, YLayoutSize_t minHeight );
-
- YSquash * createHSquash ( YWidget * parent );
- YSquash * createVSquash ( YWidget * parent );
- YSquash * createHVSquash ( YWidget * parent );
-
- //
- // Visual Grouping
- //
-
- YFrame * createFrame ( YWidget * parent, std::string label );
- YCheckBoxFrame *createCheckBoxFrame ( YWidget * parent, std::string label );
-
- //
- // Logical Grouping
- //
-
- YRadioButtonGroup * createRadioButtonGroup ( YWidget * parent );
- YReplacePoint * createReplacePoint ( YWidget * parent );
-
- //
- // Optional Widgets
- //
-
- bool hasDummySpecialWidget();
- YDummySpecialWidget * createDummySpecialWidget( YWidget * parent );
-
- bool hasWizard();
- YWizard * createWizard ( YWidget * parent );
-
- bool hasDumbTab();
- YDumbTab * createDumbTab ( YWidget * parent );
-
- bool hasSlider();
- YSlider * createSlider ( YWidget * parent, std::string label, int minVal, int maxVal, int initialVal );
-
- bool hasDateField();
- YDateField * createDateField ( YWidget * parent, std::string label );
-
- bool hasTimeField();
- YTimeField * createTimeField ( YWidget * parent, std::string label );
-
- bool hasBarGraph();
- YBarGraph * createBarGraph ( YWidget * parent, std::list<int> values, std::liststd::string labels );
-
- bool hasPatternSelector();
- YPatternSelector * createPatternSelector ( YWidget * parent );
-
- bool hasSimplePatchSelector();
- YSimplePatchSelector * createSimplePatchSelector ( YWidget * parent );
-
- bool hasMultiProgressMeter();
- YMultiProgressMeter * createHMultiProgressMeter ( YWidget * parent, std::string label, std::list<int> maxValues );
- YMultiProgressMeter * createVMultiProgressMeter ( YWidget * parent, std::string label, std::list<int> maxValues );
-
- bool hasPartitionSplitter();
- YPartitionSplitter * createPartitionSplitter ( YWidget * parent );
-
-
- bool hasDownloadProgress();
- YDownloadProgress * createDownloadProgress ( YWidget * parent, std::string label, std::string filename, long expectedFileSize );
-
- // FIXME: drop ColoredLabel
-
-
- protected:
- friend YUI::Impl::UI;
-
- YWidgetFactory();
- ~YWidgetFactory();
-
- }; // class YWidgetFactory
-
-
-#if 0
- struct YItem
- {
- std::string label;
- std::string id;
- bool isSelected;
-
- YItem( std::string labelText )
- : label( labelText )
- , id( labelText )
- , isSelected( false )
- {}
-
- YItem( std::string labelText, std::string idText, bool sel = false )
- : label( labelText )
- , id( idText )
- , isSelected( sel )
- {}
- }; // struct YItem
- typedef std::list<YItem> YItemList;
-#endif
+/**
+ * Widget factory for mandatory widgets.
+ * Use YOptionalWidgetFactory for optional ("special") widgets.
+ *
+ * Refer to the respective widget's documentation (in the header file) for
+ * documentation about the function parameters.
+ **/
+class YWidgetFactory
+{
+public:
+
+ //
+ // Dialogs
+ //
+
+ virtual YDialog * createMainDialog();
+ virtual YDialog * createPopupDialog();
+
+ //
+ // Layout Boxes
+ //
+
+ virtual YVBox * createVBox ( YWidget * parent );
+ virtual YHBox * createHBox ( YWidget * parent );
+
+ //
+ // Common Leaf Widgets
+ //
+
+ virtual YPushButton * createPushButton ( YWidget * parent, const string & label );
+ virtual YLabel * createHeading ( YWidget * parent, const string & label );
+ virtual YLabel * createLabel ( YWidget * parent, const string & label );
+ virtual YInputField * createInputField ( YWidget * parent, const string & label );
+ virtual YCheckBox * createCheckBox ( YWidget * parent, const string & label, bool isChecked = false );
+ virtual YRadioButton * createRadioButton ( YWidget * parent, const string & label, bool isChecked = false );
+ virtual YComboBox * createComboBox ( YWidget * parent, const string & label, bool editable = false );
+ virtual YSelectionBox * createSelectionBox ( YWidget * parent, const string & label );
+ virtual YTree * createTree ( YWidget * parent, const string & label );
+ virtual YTable * createTable ( YWidget * parent );
+ virtual YProgressBar * createProgressBar ( YWidget * parent, const string & label, int maxValue = 100 );
+ virtual YRichText * createRichText ( YWidget * parent );
+
+ //
+ // Less Common Leaf Widgets
+ //
+
+ virtual YIntField * createIntField ( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal );
+ virtual YInputField * createPasswordField ( YWidget * parent, const string & label );
+ virtual YLabel * createOutputField ( YWidget * parent, const string & label );
+
+ virtual YMenuButton * createMenuButton ( YWidget * parent, const string & label );
+ virtual YPushButton * createIconButton ( YWidget * parent, const string & iconName, const string & fallbackTextLabel );
+ virtual YMultiLineEdit * createMultiLineEdit ( YWidget * parent, const string & label );
+ virtual YImage * createImage ( YWidget * parent, const string & imagePath );
+ virtual YLogView * createLogView ( YWidget * parent, const string & label, int visibleLines, int storedLines = 0 );
+ virtual YSelectionBox * createMultiSelectionBox ( YWidget * parent, const string & label );
+
+ virtual YPackageSelector * createPackageSelector ( YWidget * parent );
+ virtual YPkgSpecial * createPkgSpecial ( YWidget * parent ); // NCurses only
+
+ //
+ // Layout Helpers
+ //
+
+ virtual YEmpty * createHStretch ( YWidget * parent );
+ virtual YEmpty * createVStretch ( YWidget * parent );
+ virtual YEmpty * createHSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 );
+ virtual YEmpty * createVSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 );
+ virtual YEmpty * createEmpty ( YWidget * parent );
+
+ YAlignment * createLeft ( YWidget * parent );
+ YAlignment * createRight ( YWidget * parent );
+ YAlignment * createTop ( YWidget * parent );
+ YAlignment * createBottom ( YWidget * parent );
+ YAlignment * createHCenter ( YWidget * parent );
+ YAlignment * createVCenter ( YWidget * parent );
+ YAlignment * createHVCenter ( YWidget * parent );
+ virtual YAlignment * createAlignment ( YWidget * parent, YAlignmentType horAlignment, YAlignmentType vertAlignment );
+
+ YAlignment * createMarginBox ( YWidget * parent, YLayoutSize_t horMargin, YLayoutSize_t vertMargin );
+ virtual YAlignment * createMarginBox ( YWidget * parent,
+ YLayoutSize_t leftMargin, YLayoutSize_t rightMargin,
+ YLayoutSize_t topMargin, YLayoutSize_t bottomMargin );
+
+
+ YAlignment * createMinWidth ( YWidget * parent, YLayoutSize_t minWidth );
+ YAlignment * createMinHeight ( YWidget * parent, YLayoutSize_t minHeight );
+ virtual YAlignment * createMinSize ( YWidget * parent, YLayoutSize_t minWidth, YLayoutSize_t minHeight );
+
+ YSquash * createHSquash ( YWidget * parent );
+ YSquash * createVSquash ( YWidget * parent );
+ YSquash * createHVSquash ( YWidget * parent );
+ virtual YSquash * createSquash ( YWidget * parent, bool hSquash, bool vSquash );
+
+ //
+ // Visual Grouping
+ //
+
+ virtual YFrame * createFrame ( YWidget * parent, const string & label );
+ virtual YCheckBoxFrame * createCheckBoxFrame ( YWidget * parent, const string & label );
+
+ //
+ // Logical Grouping
+ //
+
+ virtual YRadioButtonGroup * createRadioButtonGroup ( YWidget * parent );
+ virtual YReplacePoint * createReplacePoint ( YWidget * parent );
+
+
+protected:
+
+ friend class YUI;
+
+ /**
+ * Constructor.
+ *
+ * Use YUI::widgetFactory() to get the singleton for this class.
+ **/
+ YWidgetFactory();
+
+ /**
+ * Destructory.
+ **/
+ virtual ~YWidgetFactory();
-} // namespace YUI
+}; // class YWidgetFactory
#endif // YWidgetFactory_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org