Author: gs
Date: Thu Jun 28 12:18:13 2007
New Revision: 39070
URL: http://svn.opensuse.org/viewcvs/yast?rev=39070&view=rev
Log:
try to make widget factory work (not yet finished)
Modified:
branches/tmp/sh/mod-ui/ncurses/src/Makefile.am
branches/tmp/sh/mod-ui/ncurses/src/NCPackageSelectorStart.h
branches/tmp/sh/mod-ui/ncurses/src/NCPopupTextEntry.h
branches/tmp/sh/mod-ui/ncurses/src/NCRadioButton.cc
branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.cc
branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.h
branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.cc
branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.h
branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h
Modified: branches/tmp/sh/mod-ui/ncurses/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/Makefile.am?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/Makefile.am Thu Jun 28 12:18:13 2007
@@ -84,8 +84,6 @@
NCLogView.h \
NCMultiLineEdit.h \
NCFileSelection.h \
- NCAskForDirectory.h \
- NCAskForFile.h \
NCPopup.h \
NCPopupTable.h \
NCPopupList.h \
@@ -98,6 +96,9 @@
Y2CCNCursesUI.h \
YNCursesComponent.h
+# NCAskForDirectory.h \
+# NCAskForFile.h
+
libpy2ncurses_la_SOURCES = \
Y2Log.cc \
position.cc \
@@ -155,8 +156,6 @@
NCLogView.cc \
NCMultiLineEdit.cc \
NCFileSelection.cc \
- NCAskForDirectory.cc \
- NCAskForFile.cc \
\
NCPopup.cc \
NCPopupTable.cc \
@@ -167,6 +166,9 @@
\
Y2CCNCursesUI.cc
+# NCAskForDirectory.cc \
+# NCAskForFile.cc
+
#libpy2ncurses_la_SOURCES = $(liby2ncurses_la_SOURCES) \
# Y2CCNCursesUI.cc Y2CCNCursesUI.h \
# YNCursesComponent.h
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPackageSelectorStart.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPackageSelectorStart.h?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPackageSelectorStart.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPackageSelectorStart.h Thu Jun 28 12:18:13 2007
@@ -31,7 +31,7 @@
class NCPkgTable;
-
+class NCPackageSelector;
/**
* @short the package selector widget
@@ -77,6 +77,9 @@
virtual long nicesize( YUIDimension dim ) { return NCSplit::nicesize( dim ); }
+ virtual int preferredWidth() { return NCSplit::preferredWidth(); }
+ virtual int preferredHeight() { return NCSplit::preferredHeight(); }
+
/**
* Set the new size of the widget.
*
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPopupTextEntry.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPopupTextEntry.h?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPopupTextEntry.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPopupTextEntry.h Thu Jun 28 12:18:13 2007
@@ -22,7 +22,7 @@
#include <iosfwd>
#include "NCPopup.h"
-#include "NCTextEntry.h"
+#include "NCInputField.h"
///////////////////////////////////////////////////////////////////
@@ -38,7 +38,7 @@
private:
- NCTextEntry * wtext;
+ NCInputField * wtext;
virtual bool postAgain();
@@ -49,7 +49,7 @@
const YCPString & text,
unsigned maxInput = 0,
unsigned maxFld = 0,
- NCTextEntry::FTYPE t = NCTextEntry::PLAIN );
+ NCInputField::FTYPE t = NCInputField::PLAIN );
virtual ~NCPopupTextEntry();
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCRadioButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCRadioButton.cc?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCRadioButton.cc Thu Jun 28 12:18:13 2007
@@ -32,7 +32,7 @@
// DESCRIPTION :
//
NCRadioButton::NCRadioButton( NCWidget * parent,
- const string & nlabel )
+ const string & nlabel, )
: YRadioButton( dynamic_cast(parent), nlabel )
, NCWidget( parent )
, checked( false )
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.cc?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.cc Thu Jun 28 12:18:13 2007
@@ -10,65 +10,24 @@
| (C) SuSE GmbH |
\----------------------------------------------------------------------/
- File: NCWidgetFactory.cc
+ File: NCWidgetFactory.cc
- Author: Gabriele Mohr
+ Author: Stefan Hundhammer
/-*/
+
#include "NCWidgetFactory.h"
+#include "YUIException.h"
+
#include <string>
-#include
-#include
-#include "Y2Log.h"
-#include
-#include "YDialog.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "NCDialog.h"
-#include "NCAlignment.h"
-#include "NCCheckBox.h"
-#include "NCEmpty.h"
-#include "NCSpacing.h"
-#include "NCFrame.h"
-#include "NCCheckBoxFrame.h"
-#include "NCImage.h"
-#include "NCLabel.h"
-#include "NCProgressBar.h"
-#include "NCPushButton.h"
-#include "NCMenuButton.h"
-#include "NCRadioButton.h"
-#include "NCRadioButtonGroup.h"
-#include "NCReplacePoint.h"
-#include "NCRichText.h"
-#include "NCSelectionBox.h"
-#include "NCMultiSelectionBox.h"
-#include "NCSplit.h"
-#include "NCSquash.h"
-#include "NCTable.h"
-#include "NCInputField.h"
-#include "NCIntField.h"
-#include "NCComboBox.h"
-#include "NCTree.h"
-#include "NCLogView.h"
-#include "NCMultiLineEdit.h"
-#include "NCPackageSelectorPlugin.h"
-#include "NCPackageSelectorStart.h"
-#include "NCAskForDirectory.h"
-#include "NCAskForFile.h"
-#include "NCstring.h"
-extern string language2encoding( string lang );
+using std::string;
-NCWidgetFactory::NCWidgetFactory( )
- : YWidgetFactory ()
+
+NCWidgetFactory::NCWidgetFactory()
+ : YWidgetFactory()
{
// NOP
}
@@ -79,317 +38,303 @@
}
-///////////////////////////////////////////////////////////////////
+
+
//
-// Widget creation functions - container widgets
+// Dialogs
//
-///////////////////////////////////////////////////////////////////
-
-//#define ONCREATE WIDDBG << endl
-#define ONCREATE
-YContainerWidget * YNCursesUI::createSplit( YWidget * parent, YWidgetOpt & opt,
- YUIDimension dimension )
+NCDialog *
+NCWidgetFactory::createMainDialog()
{
- ONCREATE;
- return new NCSplit( dynamic_cast( parent ), opt,
- dimension );
+ return 0; // FIXME: TO DO
}
-YSingleChildContainerWidget * YNCursesUI::createReplacePoint( YWidget * parent )
-{
- ONCREATE;
- return new NCReplacePoint( dynamic_cast( parent ) );
-}
-YSingleChildContainerWidget * YNCursesUI::createAlignment( YWidget * parent,
- YAlignmentType halign,
- YAlignmentType valign )
-{
- ONCREATE;
- return new NCAlignment( dynamic_cast( parent ),
- halign, valign );
-}
-YSingleChildContainerWidget * YNCursesUI::createSquash( YWidget * parent,
- bool hsquash,
- bool vsquash )
+NCDialog *
+NCWidgetFactory::createPopupDialog()
{
- ONCREATE;
- return new NCSquash( dynamic_cast( parent ),
- hsquash, vsquash );
+ return 0; // FIXME: TO DO
}
-YSingleChildContainerWidget * YNCursesUI::createFrame( YWidget * parent,
- const string & label )
+
+
+
+
+//
+// Common Leaf Widgets
+//
+
+NCPushButton *
+NCWidgetFactory::createPushButton( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCFrame( dynamic_cast( parent ), label );
+ NCPushButton * pushButton = new NCPushButton( dynamic_cast(parent), label );
+ YUI_CHECK_NEW( pushButton );
+
+ return pushButton;
}
-YSingleChildContainerWidget * YNCursesUI::createCheckBoxFrame( YWidget * parent,
- const string & label, bool checked )
+
+
+NCLabel *
+NCWidgetFactory::createLabel( YWidget * parent,
+ const string & text,
+ bool isHeading,
+ bool isOutputField )
{
- ONCREATE;
- return new NCCheckBoxFrame( dynamic_cast( parent ), label, checked );
+ NCLabel * label = new NCLabel( dynamic_cast( parent ), text, isHeading, isOutputField );
+ YUI_CHECK_NEW( label );
+
+ return label;
}
-///////////////////////////////////////////////////////////////////
-//
-// Widget creation functions - leaf widgets
-//
-///////////////////////////////////////////////////////////////////
-YWidget * YNCursesUI::createEmpty( YWidget * parent )
+
+NCInputField *
+NCWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
{
- ONCREATE;
- return new NCEmpty( dynamic_cast( parent ) );
+ NCInputField * inputField = new NCInputField( dynamic_cast( parent ), label, passwordMode );
+ YUI_CHECK_NEW( inputField );
+
+ return inputField;
}
-YWidget * YNCursesUI::createSpacing( YWidget * parent,
- YUIDimension dim,
- bool stretchable,
- YLayoutSize_t layoutUnits )
+
+NCCheckBox *
+NCWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
{
- ONCREATE;
- return new NCSpacing( dynamic_cast( parent ), dim,
- stretchable, layoutUnits );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createLabel( YWidget * parent, const string & text,
- bool isHeading, bool isOutputField )
+
+
+NCRadioButton *
+NCWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool checked )
{
- ONCREATE;
- return new NCLabel( dynamic_cast( parent ), text,
- isHeading, isOutputField );
+ NCRadioButton * radioButton = new NCRadioButton( dynamic_cast( parent ), label );
+ YUI_CHECK_NEW( radioButton );
+
+ // Register radio button with its button group.
+ // This has to be done after all constructors are done so virtual functions
+ // can be used.
+
+ if ( radioButton->buttonGroup() )
+ radioButton->buttonGroup()->addRadioButton( radioButton );
+
+ return radioButton;
}
-YWidget * YNCursesUI::createRichText( YWidget * parent, YWidgetOpt & opt,
- const YCPString & text )
+
+
+NCComboBox *
+NCWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable )
{
- ONCREATE;
- return new NCRichText( dynamic_cast( parent ), opt,
- text );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createLogView( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- int visibleLines,
- int maxLines )
+
+
+NCSelectionBox *
+NCWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCLogView( dynamic_cast( parent ), opt,
- label, visibleLines, maxLines );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createPushButton( YWidget * parent,
- const string & label )
+
+
+NCTree *
+NCWidgetFactory::createTree( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCPushButton( dynamic_cast( parent ), label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createMenuButton( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label )
+
+
+NCTable *
+NCWidgetFactory::createTable( YWidget * parent )
{
- ONCREATE;
- return new NCMenuButton( dynamic_cast( parent ), opt,
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createRadioButton( YWidget * parent,
- const string & label )
+
+
+NCProgressBar *
+NCWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
{
- ONCREATE;
- return new NCRadioButton( dynamic_cast( parent ),
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createCheckBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- bool checked )
+
+
+NCRichText *
+NCWidgetFactory::createRichText( YWidget * parent )
{
- ONCREATE;
- return new NCCheckBox( dynamic_cast( parent ), opt,
- label, checked );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createInputField( YWidget * parent,
- const string & label,
- bool passwordMode )
+
+
+
+//
+// Less Common Leaf Widgets
+//
+
+NCIntField *
+NCWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
{
- ONCREATE;
- return new NCInputField( dynamic_cast( parent ),
- label, passwordMode );
+ return 0; // FIXME: TO DO
}
-YWidget *YNCursesUI::createMultiLineEdit( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- const YCPString & initialText )
+
+
+NCMenuButton *
+NCWidgetFactory::createMenuButton( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCMultiLineEdit( dynamic_cast( parent ), opt,
- label, initialText );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createSelectionBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label )
+
+
+NCMultiLineEdit *
+NCWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCSelectionBox( dynamic_cast( parent ), opt,
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createMultiSelectionBox( YWidget *parent, YWidgetOpt & opt,
- const YCPString & label )
+
+
+NCImage *
+NCWidgetFactory::createImage( YWidget * parent, const string & imagePath )
{
- ONCREATE;
- return new NCMultiSelectionBox( dynamic_cast( parent ), opt,
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createComboBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label )
+
+
+NCLogView *
+NCWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
{
- ONCREATE;
- return new NCComboBox( dynamic_cast( parent ), opt,
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createTree( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label )
+
+
+NCSelectionBox *
+NCWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
{
- ONCREATE;
- return new NCTree( dynamic_cast( parent ), opt,
- label );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createTable( YWidget * parent, YWidgetOpt & opt,
- vector<string> header )
+
+
+
+YPackageSelector *
+NCWidgetFactory::createPackageSelector( YWidget * parent )
{
- ONCREATE;
- return new NCTable( dynamic_cast( parent ), opt,
- header, true );
+ return 0; // FIXME: TO DO
}
-YWidget * YNCursesUI::createProgressBar( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- const YCPInteger & maxprogress,
- const YCPInteger & progress )
+
+
+YPkgSpecial *
+NCWidgetFactory::createPkgSpecial( YWidget * parent )
{
- ONCREATE;
- return new NCProgressBar( dynamic_cast( parent ), opt,
- label, maxprogress, progress );
+ YUI_THROW( YUIUnsupportedWidgetException( "NCPkgSpecial" ) ); // NCurses only
+ return 0;
}
-YWidget * YNCursesUI::createImage( YWidget * parent, YWidgetOpt & opt,
- YCPByteblock /* not used */,
- YCPString defaulttext )
+
+//
+// Layout Helpers
+//
+
+NCSpacing *
+NCWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
{
- ONCREATE;
- return new NCImage( dynamic_cast( parent ), opt,
- defaulttext );
+ NCSpacing * spacing = new NCSpacing( dynamic_cast( parent ), dim, stretchable, size );
+ YUI_CHECK_NEW( spacing );
+
+ return spacing;
}
-YWidget * YNCursesUI::createImage( YWidget * parent, YWidgetOpt & opt,
- YCPString /* not used */,
- YCPString defaulttext )
+
+NCEmpty *
+NCWidgetFactory::createEmpty( YWidget * parent )
{
- ONCREATE;
- return new NCImage( dynamic_cast( parent ), opt,
- defaulttext );
+ NCEmpty * empty = new NCEmpty( dynamic_cast( parent ) );
+ YUI_CHECK_NEW( empty );
+
+ return empty;
}
-YWidget * YNCursesUI::createIntField( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- int minValue, int maxValue,
- int initialValue )
+
+NCAlignment *
+NCWidgetFactory::createAlignment( YWidget * parent,
+ YAlignmentType horAlignment,
+ YAlignmentType vertAlignment )
{
- ONCREATE;
- return new NCIntField( dynamic_cast( parent ), opt,
- label, minValue, maxValue, initialValue );
+ NCAlignment * alignment = new NCAlignment( dynamic_cast( parent ), horAlignment, vertAlignment );
+ YUI_CHECK_NEW( alignment );
+
+ return alignment;
}
-///////////////////////////////////////////////////////////////////
-//
-// package selection
-//
-///////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : YNCursesUI::packageSelectorPlugin()
-// METHOD TYPE : NCPackageSelectorPlugin
-//
-// DESCRIPTION : Create the package selector plugin
-//
-NCPackageSelectorPlugin * YNCursesUI::packageSelectorPlugin()
+NCSquash *
+NCWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
{
- static NCPackageSelectorPlugin * plugin = 0;
+ NCSquash * squash = new NCSquash( dynamic_cast(parent), horSquash, vertSquash );
+ YUI_CHECK_NEW( squash );
- if ( ! plugin )
- {
- plugin = new NCPackageSelectorPlugin();
+ return squash;
+}
- // This is a deliberate memory leak: If an application requires a
- // PackageSelector, it is a package selection application by
- // definition. In this case, the ncurses_pkg plugin is intentionally
- // kept open to avoid repeated start-up cost of the plugin and libzypp.
- }
- return plugin;
-}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : YNCursesUI::createPackageSelector
-// METHOD TYPE : YWidget
-//
-// DESCRIPTION : Calls NCPackageSelectorPlugin::createPackageSelector
-//
-YWidget * YNCursesUI::createPackageSelector( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & floppyDevice )
+NCFrame *
+NCWidgetFactory::createFrame( YWidget * parent, const string & label )
{
- ONCREATE;
- YWidget * w = 0;
+ NCFrame * frame = new NCFrame( dynamic_cast(parent), label );
+ YUI_CHECK_NEW( frame );
+
+ return frame;
+}
- NCPackageSelectorPlugin * plugin = packageSelectorPlugin();
- if ( plugin )
- {
- w = plugin->createPackageSelector( parent, opt );
- }
- return w;
+NCCheckBoxFrame *
+NCWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
+{
+ NCCheckBoxFrame * checkBoxFrame = new NCCheckBoxFrame( dynamic_cast( parent ), label, checked );
+ YUI_CHECK_NEW( checkBoxFrame );
+
+ return checkBoxFrame;
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : YNCursesUI::createPkgSpecial
-// METHOD TYPE : YWidget
-//
-// DESCRIPTION : creates special widgets used for the package selection
-// dialog (which do not have a corresponding widget in qt-ui)
-//
-YWidget * YNCursesUI::createPkgSpecial( YWidget *parent, YWidgetOpt &opt, const YCPString &subwidget )
+
+
+NCRadioButtonGroup *
+NCWidgetFactory::createRadioButtonGroup( YWidget * parent )
{
- ONCREATE;
- YWidget * w = 0;
+ NCRadioButtonGroup * radioButtonGroup = new NCRadioButtonGroup( dynamic_cast( parent ) );
+ YUI_CHECK_NEW( radioButtonGroup );
- NCPackageSelectorPlugin * plugin = packageSelectorPlugin();
+ return radioButtonGroup;
+}
+
- if ( plugin )
- {
- w = plugin->createPkgSpecial( parent, opt, subwidget );
- }
+
+NCReplacePoint *
+NCWidgetFactory::createReplacePoint( YWidget * parent )
+{
+ NCReplacePoint * replacePoint = new NCReplacePoint( dynamic_cast( parent ) );
+ YUI_CHECK_NEW( replacePoint );
- return w;
+ return replacePoint;
}
+
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.h?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCWidgetFactory.h Thu Jun 28 12:18:13 2007
@@ -1,264 +1,147 @@
/*---------------------------------------------------------------------\
-| |
-| __ __ ____ _____ ____ |
-| \ \ / /_ _/ ___|_ _|___ \ |
-| \ V / _` \___ \ | | __) | |
-| | | (_| |___) || | / __/ |
-| |_|\__,_|____/ |_| |_____| |
-| |
-| core system |
-| (C) SuSE GmbH |
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
\----------------------------------------------------------------------/
- File: NCWidgetFactory.h
+ File: NCWidgetFactory.h
- Author: Gabriele Mohr <@suse.de>
+ Author: Gabriele Mohr
/-*/
-
#ifndef NCWidgetFactory_h
#define NCWidgetFactory_h
+
#include "YWidgetFactory.h"
+#include "NCAlignment.h"
+#include "NCCheckBox.h"
+#include "NCCheckBoxFrame.h"
+#include "NCComboBox.h"
+#include "NCDialog.h"
+#include "NCEmpty.h"
+#include "NCFrame.h"
+#include "NCImage.h"
+#include "NCInputField.h"
+#include "NCIntField.h"
+#include "NCLabel.h"
+#include "NCLogView.h"
+#include "NCMenuButton.h"
+#include "NCMultiLineEdit.h"
+#include "NCPackageSelectorStart.h"
+#include "NCProgressBar.h"
+#include "NCPushButton.h"
+#include "NCRadioButton.h"
+#include "NCRadioButtonGroup.h"
+#include "NCReplacePoint.h"
+#include "NCRichText.h"
+#include "NCSelectionBox.h"
+#include "NCSpacing.h"
+#include "NCSquash.h"
+#include "NCTable.h"
+#include "NCTree.h"
-/**
- * @short YaST2 Component: NCursesUI Widget Factory
- * Concrete widget factory for mandatory widgets.
- */
-class NCWidgetFactory : public YWidgetFactory
-{
- protected:
+using std::string;
- friend class NCursesUI;
- /**
- * Constructor.
- *
- * Use YUI::widgetFactory() to get the singleton for this class.
- **/
- NCWidgetFactory();
- /**
- * Destructory.
- **/
- virtual ~NCWidgetFactory();
-
+/**
+ * Concrete widget factory for mandatory widgets.
+ **/
+class NCWidgetFactory: public YWidgetFactory
+{
public:
+ // Note: Using covariant return types for all createSomeWidget() methods
+ // (returning NCSomeWidget where the base class declares virtual methods that
+ // return YSomeWidget)
+
//
- // Widget creation functions - container widgets
+ // Dialogs
//
- /**
- * Creates a split
- */
- virtual YContainerWidget * createSplit( YWidget * parent, YWidgetOpt & opt,
- YUIDimension dimension );
-
- /**
- * Creates a replace point.
- */
- virtual YSingleChildContainerWidget * createReplacePoint( YWidget * parent );
-
- /**
- * Creates an alignment widget
- */
- virtual YSingleChildContainerWidget * createAlignment( YWidget * parent,
- YAlignmentType halign,
- YAlignmentType valign);
-
- /**
- * Creates a squash widget
- */
- virtual YSingleChildContainerWidget * createSquash( YWidget * parent,
- bool hsquash,
- bool vsquash );
-
- /**
- * Creates a radio button group.
- */
- // virtual YContainerWidget * createRadioButtonGroup( YWidget * parent, YWidgetOpt & opt );
+ virtual NCDialog * createMainDialog();
+ virtual NCDialog * createPopupDialog();
- /**
- * Creates a frame widget
- */
- virtual YSingleChildContainerWidget * createFrame( YWidget * parent,
- const string & label );
-
- virtual YSingleChildContainerWidget * createCheckBoxFrame( YWidget * parent,
- const string & label,
- bool checked );
//
- // Widget creation functions - leaf widgets
+ // Common Leaf Widgets
//
- /**
- * Creates an empty widget
- */
- virtual YWidget * createEmpty( YWidget * parent );
-
- /**
- * Creates a spacing widget
- */
- virtual YWidget * createSpacing( YWidget * parent,
- YUIDimension dim,
- bool stretchable,
- YLayoutSize_t layoutUnits );
-
- /**
- * Creates a label.
- * @param text Initial text of the label
- * @param heading true if the label is a Heading()
- * @param output_field true if the label should look like an output field (3D look)
- */
- virtual YWidget * createLabel( YWidget * parent, const string & text,
- bool isHeading, bool isOutputField );
-
- /**
- * Creates a rich text widget
- * @param text Initial text of the label
- */
- virtual YWidget * createRichText( YWidget * parent, YWidgetOpt & opt,
- const YCPString & text );
-
- /**
- * Creates a log view widget
- * @param label label above the log view
- * @param visibleLines default number of vislible lines
- * @param maxLines number of lines to store (use 0 for "all")
- */
- virtual YWidget * createLogView( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- int visibleLines,
- int maxLines );
+ virtual NCPushButton * createPushButton ( YWidget * parent, const string & label );
+ virtual NCLabel * createLabel ( YWidget * parent, const string & text, bool isHeading = false, bool isOutputField = false );
+ virtual NCInputField * createInputField ( YWidget * parent, const string & label, bool passwordMode = false );
+ virtual NCCheckBox * createCheckBox ( YWidget * parent, const string & label, bool isChecked = false );
+ virtual NCRadioButton * createRadioButton ( YWidget * parent, const string & label, bool isChecked = false );
+ virtual NCComboBox * createComboBox ( YWidget * parent, const string & label, bool editable = false );
+ virtual NCSelectionBox * createSelectionBox ( YWidget * parent, const string & label );
+ virtual NCTree * createTree ( YWidget * parent, const string & label );
+ virtual NCTable * createTable ( YWidget * parent );
+ virtual NCProgressBar * createProgressBar ( YWidget * parent, const string & label, int maxValue = 100 );
+ virtual NCRichText * createRichText ( YWidget * parent );
- /**
- * Creates a MultiLineEdit widget
- * @param label label above the edit field
- * @param text initial contents of the edit field
- */
- virtual YWidget * createMultiLineEdit( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- const YCPString & text);
-
- /**
- * Creates a push button.
- * @param label Label of the button
- * @param default_button true if the button should be the dialogs default button
- */
- virtual YWidget * createPushButton( YWidget * parent,
- const string & label );
-
- /**
- * Creates a menu button.
- * @param label Label of the button
- */
- virtual YWidget * createMenuButton( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label );
+ //
+ // Less Common Leaf Widgets
+ //
- /**
- * 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,
- const string & label );
+ virtual NCIntField * createIntField ( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal );
+ virtual NCMenuButton * createMenuButton ( YWidget * parent, const string & label );
+ virtual NCMultiLineEdit * createMultiLineEdit ( YWidget * parent, const string & label );
+ virtual NCImage * createImage ( YWidget * parent, const string & imagePath );
+ virtual NCLogView * createLogView ( YWidget * parent, const string & label, int visibleLines, int storedLines = 0 );
+ virtual NCSelectionBox * createMultiSelectionBox ( YWidget * parent, const string & label );
- /**
- * Creates a check box
- * @param label Label of the checkbox
- * @param true if it is checked
- */
- virtual YWidget * createCheckBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- bool checked );
+ virtual YPackageSelector * createPackageSelector ( YWidget * parent );
+ virtual YPkgSpecial * createPkgSpecial ( YWidget * parent ); // NCurses only, will throw exception in the Qt UI
- /**
- * Creates a text entry or password entry field.
- */
- virtual YWidget * createTextEntry( YWidget * parent,
- const string & label,
- bool passwordMode );
+ //
+ // Layout Helpers
+ //
- /**
- * Creates a selection box
- */
- virtual YWidget * createSelectionBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label );
+ virtual NCSpacing * createSpacing ( YWidget * parent, YUIDimension dim, bool stretchable = false, YLayoutSize_t size = 0.0 );
+ virtual NCEmpty * createEmpty ( YWidget * parent );
+ virtual NCAlignment * createAlignment ( YWidget * parent, YAlignmentType horAlignment, YAlignmentType vertAlignment );
+ virtual NCSquash * createSquash ( YWidget * parent, bool horSquash, bool vertSquash );
- /**
- * Creates a multi selection box
- */
- virtual YWidget * createMultiSelectionBox( YWidget *parent, YWidgetOpt & opt,
- const YCPString & label );
+ //
+ // Visual Grouping
+ //
- /**
- * Creates a combo box
- */
- virtual YWidget * createComboBox( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label );
+ virtual NCFrame * createFrame ( YWidget * parent, const string & label );
+ virtual NCCheckBoxFrame * createCheckBoxFrame ( YWidget * parent, const string & label, bool checked );
- /**
- * Creates a tree
- */
- virtual YWidget * createTree( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label );
+ //
+ // Logical Grouping
+ //
- /**
- * Creates a table widget
- */
- virtual YWidget * createTable( YWidget * parent, YWidgetOpt & opt,
- vector<string> header );
+ virtual NCRadioButtonGroup *createRadioButtonGroup ( YWidget * parent );
+ virtual NCReplacePoint * createReplacePoint ( YWidget * parent );
- /**
- * Creates a progress bar
- */
- virtual YWidget * createProgressBar( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- const YCPInteger & maxprogress,
- const YCPInteger & progress);
- /**
- * Creates an image widget from a YCP byteblock
- */
- virtual YWidget * createImage( YWidget * parent, YWidgetOpt & opt,
- YCPByteblock imagedata,
- YCPString defaulttext);
+protected:
- /**
- * Creates an image widget from a YCP byteblock
- */
- virtual YWidget * createImage( YWidget * parent, YWidgetOpt & opt,
- YCPString filename,
- YCPString defaulttext);
+ friend class NCUI;
/**
- * Creates an IntField widget.
- */
- virtual YWidget * createIntField( YWidget * parent, YWidgetOpt & opt,
- const YCPString & label,
- int minValue, int maxValue,
- int initialValue );
+ * Constructor.
+ *
+ * Use YUI::widgetFactory() to get the singleton for this class.
+ **/
+ NCWidgetFactory();
/**
- * Creates the PackageSelector widget (i.e. a widget tree).
- */
- virtual YWidget * createPackageSelector( YWidget *parent,
- YWidgetOpt &opt,
- const YCPString & floppyDevice );
+ * Destructory.
+ **/
+ virtual ~NCWidgetFactory();
-
- /**
- * Creates a special subwidget used for Package Selection (which doesn't exist in QT-UI).
- */
- virtual YWidget * createPkgSpecial( YWidget *parent,
- YWidgetOpt &opt,
- const YCPString &subwidget );
-
+}; // class NCWidgetFactory
-};
#endif // NCWidgetFactory_h
-
Modified: branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.cc?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.cc Thu Jun 28 12:18:13 2007
@@ -66,6 +66,7 @@
#include "NCAskForFile.h"
#include "NCstring.h"
+
extern string language2encoding( string lang );
YNCursesUI::YNCursesUI( int argc, char **argv, bool with_threads, const char * macro_file )
@@ -119,6 +120,38 @@
YNCursesUI * YNCursesUI::_ui = 0;
+YWidgetFactory *
+YNCursesUI::createWidgetFactory()
+{
+ NCWidgetFactory * factory = new NCWidgetFactory();
+ YUI_CHECK_NEW( factory );
+
+ return factory;
+}
+
+
+
+YOptionalWidgetFactory *
+YNCursesUI::createOptionalWidgetFactory()
+{
+ NCOptionalWidgetFactory * factory = new NCOptionalWidgetFactory();
+ YUI_CHECK_NEW( factory );
+
+ return factory;
+}
+
+
+YApplication *
+YNCursesUI::createApplication()
+{
+ NCApplication * app = new NCApplication();
+ YUI_CHECK_NEW( app );
+
+ return app;
+}
+
+
+
/******************************************************************
**
**
Modified: branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.h?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/YNCursesUI.h Thu Jun 28 12:18:13 2007
@@ -27,6 +27,10 @@
#include "YUI.h"
#include "YSingleChildContainerWidget.h"
+#include "NCWidgetFactory.h"
+#include "NCOptionalWidgetFactory.h"
+#include "NCApplication.h"
+
#include "NCurses.h"
class YUI;
@@ -53,6 +57,30 @@
protected:
+ /**
+ * Create the widget factory that provides all the createXY() methods for
+ * standard (mandatory, i.e. non-optional) widgets.
+ *
+ * Reimplemented from YUI.
+ **/
+ virtual YWidgetFactory * createWidgetFactory();
+
+ /**
+ * Create the widget factory that provides all the createXY() methods for
+ * optional ("special") widgets and the corresponding hasXYWidget()
+ * methods.
+ *
+ * Reimplemented from YUI.
+ **/
+ virtual YOptionalWidgetFactory * createOptionalWidgetFactory();
+
+ /*
+ * Create the YApplication object that provides global methods.
+ *
+ * Reimplemented from YUI.
+ **/
+ virtual YApplication * createApplication();
+
virtual bool want_colors();
virtual void init_title();
Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h?rev=39070&r1=39069&r2=39070&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h Thu Jun 28 12:18:13 2007
@@ -46,6 +46,7 @@
class NCPkgPopupDiskspace;
class NCPkgPopupSearch;
class NCPkgPopupFile;
+class YNCursesUI;
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org