[yast-commit] r38407 - in /branches/tmp/sh/mod-ui/core/libyui/src: YUI.h YUI_core.cc
![](https://seccdn.libravatar.org/avatar/d788d4d6ea7d5ed777eaa8feaaa2c1d8.jpg?s=120&d=mm&r=g)
Author: sh-sh-sh Date: Tue Jun 12 13:37:36 2007 New Revision: 38407 URL: http://svn.opensuse.org/viewcvs/yast?rev=38407&view=rev Log: use factories Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc 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=38407&r1=38406&r2=38407&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 13:37:36 2007 @@ -40,6 +40,8 @@ using std::deque; using std::string; +class YWidgetFactory; +class YOptionalWidgetFactory; class YContainerWidget; class YEvent; class YDialog; @@ -110,16 +112,55 @@ */ virtual ~YUI(); - /** * Access the global UI. **/ - static YUI * ui() { return _yui; } + static YUI * ui(); + /** + * Return the widget factory that provides all the createXY() methods for + * standard (mandatory, i.e. non-optional) widgets. + * + * This will create the factory upon the first call and return a pointer to + * the one and only (singleton) factory upon each subsequent call. + * This may throw exceptions if the factory cannot be created. + **/ + static YWidgetFactory * widgetFactory(); /** - * Looks up the topmost dialog - */ + * Return the widget factory that provides all the createXY() methods for + * optional ("special") widgets and the corresponding hasXYWidget() + * methods. + * + * This will create the factory upon the first call and return a pointer to + * the one and only (singleton) factory upon each subsequent call. + * This may throw exceptions if the factory cannot be created. + **/ + static YOptionalWidgetFactory * optionalWidgetFactory(); + + +protected: + /** + * Create the widget factory that provides all the createXY() methods for + * standard (mandatory, i.e. non-optional) widgets. + * + * Derived classes are required to implement this. + **/ + virtual YWidgetFactory * createWidgetFactory() = 0; + + /** + * Create the widget factory that provides all the createXY() methods for + * optional ("special") widgets and the corresponding hasXYWidget() + * methods. + * + * Derived classes are required to implement this. + **/ + virtual YOptionalWidgetFactory * createOptionalWidgetFactory() = 0; + +public: + /** + * Look up the topmost dialog. + **/ YDialog *currentDialog() const; Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc?rev=38407&r1=38406&r2=38407&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc Tue Jun 12 13:37:36 2007 @@ -106,6 +106,40 @@ } +YUI * +YUI::ui() +{ + YUI_CHECK_PTR( _yui ); + return _yui; +} + + +YWidgetFactory * +YUI::widgetFactory() +{ + static YWidgetFactory * factory = 0; + + if ( ! factory ) + factory = ui()->createWidgetFactory(); + + YUI_CHECK_PTR( factory ); + return factory; +} + + +YOptionalWidgetFactory * +YUI::optionalWidgetFactory() +{ + static YOptionalWidgetFactory * factory = 0; + + if ( ! factory ) + factory = ui()->createOptionalWidgetFactory(); + + YUI_CHECK_PTR( factory ); + return factory; +} + + void YUI::internalError( const char *msg ) { -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
sh-sh-sh@svn.opensuse.org