[yast-commit] r45404 - in /trunk/libyui/examples: Makefile.am SelectionBox1.cc
Author: sh-sh-sh
Date: Wed Mar 12 18:59:13 2008
New Revision: 45404
URL: http://svn.opensuse.org/viewcvs/yast?rev=45404&view=rev
Log:
new example
Added:
trunk/libyui/examples/SelectionBox1.cc
Modified:
trunk/libyui/examples/Makefile.am
Modified: trunk/libyui/examples/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/examples/Makefile.am?rev=45404&r1=45403&r2=45404&view=diff
==============================================================================
--- trunk/libyui/examples/Makefile.am (original)
+++ trunk/libyui/examples/Makefile.am Wed Mar 12 18:59:13 2008
@@ -4,7 +4,13 @@
INCLUDES = -I$(top_srcdir)/src/
-noinst_PROGRAMS = HelloWorld
+noinst_PROGRAMS = \
+ HelloWorld \
+ SelectionBox1
+
HelloWorld_SOURCES = HelloWorld.cc
HelloWorld_LDADD = -L$(top_srcdir)/src -lyui
+
+SelectionBox1_SOURCES = SelectionBox1.cc
+SelectionBox1_LDADD = -L$(top_srcdir)/src -lyui
Added: trunk/libyui/examples/SelectionBox1.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/examples/SelectionBox1.cc?rev=45404&view=auto
==============================================================================
--- trunk/libyui/examples/SelectionBox1.cc (added)
+++ trunk/libyui/examples/SelectionBox1.cc Wed Mar 12 18:59:13 2008
@@ -0,0 +1,185 @@
+// SelectionBox example.
+//
+// Compile with:
+//
+// g++ -I/usr/include/YaST2/yui -lyui SelectionBox1.cc -o SelectionBox1
+
+#define YUILogComponent "example"
+#include "YUILog.h"
+
+#include "YUI.h"
+#include "YWidgetFactory.h"
+#include "YDialog.h"
+#include "YLayoutBox.h"
+#include "YSelectionBox.h"
+#include "YCheckBox.h"
+#include "YLabel.h"
+#include "YPushButton.h"
+#include "YAlignment.h"
+#include "YEvent.h"
+
+
+YItemCollection pizzaItems()
+{
+ YItemCollection items;
+ items.push_back( new YItem( "Pizza Margherita" ) );
+ items.push_back( new YItem( "Pizza Capricciosa" ) );
+ items.push_back( new YItem( "Pizza Funghi" ) );
+ items.push_back( new YItem( "Pizza Prosciutto" ) );
+ items.push_back( new YItem( "Pizza Quattro Stagioni" ) );
+ items.push_back( new YItem( "Calzone" ) );
+
+ return items;
+}
+
+
+YItemCollection pastaItems()
+{
+ YItemCollection items;
+ items.push_back( new YItem( "Spaghetti Napoli" ) );
+ items.push_back( new YItem( "Spaghetti Bolognese" ) );
+ items.push_back( new YItem( "Fusili Emiliana" ) );
+ items.push_back( new YItem( "Penne Calabrese" ) );
+ items.push_back( new YItem( "Penne Al Forno" ) );
+ items.push_back( new YItem( "Lasagne" ) );
+
+ return items;
+}
+
+
+
+int main( int argc, char **argv )
+{
+ //
+ // Create and open dialog
+ //
+
+ YDialog * dialog = YUI::widgetFactory()->createPopupDialog();
+ YLayoutBox * vbox = YUI::widgetFactory()->createVBox( dialog );
+
+ // Specify larger size for the SelectionBox: It can scroll, so its size
+ // depends on other widgets in the layout.
+ YAlignment * minSize = YUI::widgetFactory()->createMinSize( vbox, 40, 8 ); // minWidth, minHeight
+
+ //
+ // This is what this example all about.
+ // The other widgets are here just to allow some experimenting.
+ //
+
+ YSelectionBox * selBox = YUI::widgetFactory()->createSelectionBox( minSize, "&Menu" );
+ selBox->addItems( pizzaItems() );
+
+ YLayoutBox * buttonBox = YUI::widgetFactory()->createHBox( vbox );
+ YPushButton * pastaButton = YUI::widgetFactory()->createPushButton( buttonBox, "&Pasta" );
+ YPushButton * pizzaButton = YUI::widgetFactory()->createPushButton( buttonBox, "Pi&zza" );
+
+ YUI::widgetFactory()->createVSpacing( vbox, 0.5 );
+
+ YAlignment * leftAlignment = YUI::widgetFactory()->createLeft( vbox );
+ YCheckBox * notifyCheckBox = YUI::widgetFactory()->createCheckBox( leftAlignment, "&Notify Mode" );
+ notifyCheckBox->setNotify();
+
+ leftAlignment = YUI::widgetFactory()->createLeft( vbox );
+ YCheckBox * immediateCheckBox = YUI::widgetFactory()->createCheckBox( leftAlignment, "&Immediate Mode" );
+ immediateCheckBox->setNotify();
+
+ YUI::widgetFactory()->createVSpacing( vbox, 0.3 );
+
+ YLayoutBox * hbox = YUI::widgetFactory()->createHBox( vbox );
+ YLabel * valueField = YUI::widgetFactory()->createOutputField( hbox, "???" );
+ valueField->setStretchable( YD_HORIZ, true ); // allow stretching over entire dialog width
+
+ YPushButton * valueButton = YUI::widgetFactory()->createPushButton( hbox, "&Value" );
+
+ YUI::widgetFactory()->createVSpacing( vbox, 0.7 );
+
+ YAlignment * rightAlignment = YUI::widgetFactory()->createRight( vbox );
+ YPushButton * closeButton = YUI::widgetFactory()->createPushButton( rightAlignment, "&Close" );
+
+
+ //
+ // Event loop
+ //
+
+ while ( true )
+ {
+ YEvent * event = dialog->waitForEvent();
+
+ if ( event )
+ {
+ if ( event->eventType() == YEvent::CancelEvent ) // window manager "close window" button
+ break; // leave event loop
+
+ YWidgetEvent * widgetEvent = dynamic_cast
participants (1)
-
sh-sh-sh@svn.opensuse.org