Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

opieuidemo.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2002 Michael 'Mickey' Lauer.  All rights reserved.
00003 **
00004 ** This file is part of Opie Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ***********************************************************************/
00015 
00016 // Qt
00017 
00018 #include <qcolor.h>
00019 #include <qpopupmenu.h>
00020 #include <qmenubar.h>
00021 #include <qmessagebox.h>
00022 #include <qvbox.h>
00023 #include <qstring.h>
00024 #include <qstringlist.h>
00025 
00026 // Qtopia
00027 
00028 #include <qpe/qpeapplication.h>
00029 #include <qpe/global.h>
00030 
00031 // Opie
00032 
00033 #include <opie2/odevice.h>
00034 
00035 #include <opie2/ocompletionbox.h>
00036 #include <opie2/olineedit.h>
00037 #include <opie2/ocombobox.h>
00038 #include <opie2/oeditlistbox.h>
00039 #include <opie2/oselector.h>
00040 #include <opie2/opopupmenu.h>
00041 
00042 #include <qtabwidget.h>
00043 #include "oversatileviewdemo.h"
00044 
00045 // Local
00046 
00047 #include "opieuidemo.h"
00048 
00049 using namespace Opie::Core;
00050 using namespace Opie::Ui;
00051 
00052 enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector };
00053 
00054 OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl )
00055     : QMainWindow( parent, name, fl )
00056 {
00057 
00058     QMenuBar* mbar = this->menuBar();
00059     OPopupMenu* demo = new OPopupMenu( this );
00060     demo->setTitle( "Title" );
00061     demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox );
00062     demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit );
00063     demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox );
00064     demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox );
00065     demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector );
00066     mbar->insertItem( "Demonstrate", demo );
00067 
00068     build();
00069 
00070 }
00071 
00072 OpieUIDemo::~OpieUIDemo()
00073 {
00074 }
00075 
00076 void OpieUIDemo::build()
00077 {
00078     main = new QTabWidget( this, "tabwidget" );
00079     setCentralWidget( main );
00080     main->show();
00081 
00082     main->addTab( new OVersatileViewDemo( main ), "VersatileView" );
00083 }
00084 
00085 
00086 void OpieUIDemo::demo( int d )
00087 {
00088     switch (d)
00089     {
00090         case ocompletionbox: demoOCompletionBox(); break;
00091         case olineedit: demoOLineEdit(); break;
00092         case ocombobox: demoOComboBox(); break;
00093         case oeditlistbox: demoOEditListBox(); break;
00094         case oselector: demoOSelector(); break;
00095 
00096     }
00097 
00098 }
00099 
00100 void OpieUIDemo::demoOCompletionBox()
00101 {
00102     odebug << "ocompletionbox" << oendl; 
00103 
00104     OCompletionBox* box = new OCompletionBox( 0 );
00105     box->insertItem( "This CompletionBox" );
00106     box->insertItem( "Says 'Hello World'" );
00107     box->insertItem( "Here are some" );
00108     box->insertItem( "Additional Items" );
00109     box->insertItem( "Complete Completion Box" );
00110 
00111     connect( box, SIGNAL( activated(const QString&) ), this, SLOT( messageBox(const QString&) ) );
00112     box->popup();
00113 
00114 }
00115 
00116 void OpieUIDemo::demoOLineEdit()
00117 {
00118     odebug << "olineedit" << oendl; 
00119 
00120     OLineEdit *edit = new OLineEdit( 0, "lineedit" );
00121 
00122     edit->setCompletionMode( OGlobalSettings::CompletionPopup );
00123     OCompletion* comp = edit->completionObject();
00124 
00125     QStringList list;
00126     list << "mickeyl@handhelds.org";
00127     list << "mickey@tm.informatik.uni-frankfurt.de";
00128     list << "mickey@vanille.de";
00129 
00130     comp->setItems( list );
00131 
00132     edit->show();
00133 
00134 }
00135 
00136 void OpieUIDemo::demoOComboBox()
00137 {
00138     odebug << "ocombobox" << oendl; 
00139 
00140     OComboBox *combo = new OComboBox( true, 0, "combobox" );
00141 
00142     combo->setCompletionMode( OGlobalSettings::CompletionPopup );
00143     OCompletion* comp = combo->completionObject();
00144 
00145     QStringList ilist;
00146     ilist << "kergoth@handhelds.org";
00147     ilist << "harlekin@handhelds.org";
00148     ilist << "groucho@handhelds.org";
00149     combo->insertStringList( ilist );
00150 
00151     QStringList clist;
00152     clist << "mickeyl@handhelds.org";
00153     clist << "mickey@tm.informatik.uni-frankfurt.de";
00154     clist << "mickey@vanille.de";
00155     comp->setItems( clist );
00156 
00157     combo->show();
00158 
00159 }
00160 
00161 void OpieUIDemo::demoOEditListBox()
00162 {
00163     odebug << "oeditlistbox" << oendl; 
00164 
00165     OEditListBox* edit = new OEditListBox( "OEditListBox", 0, "editlistbox" );
00166 
00167     edit->lineEdit()->setCompletionMode( OGlobalSettings::CompletionPopup );
00168     OCompletion* comp = edit->lineEdit()->completionObject();
00169     QStringList clist;
00170     clist << "Completion everywhere";
00171     clist << "Cool Completion everywhere";
00172     clist << "History History History";
00173     comp->setItems( clist );
00174 
00175     QStringList list;
00176     list << "kergoth@handhelds.org";
00177     list << "harlekin@handhelds.org";
00178     list << "groucho@handhelds.org";
00179     list << "mickeyl@handhelds.org";
00180     edit->insertStringList( list );
00181 
00182     edit->show();
00183 
00184 }
00185 
00186 void OpieUIDemo::demoOSelector()
00187 {
00188     odebug << "oselector" << oendl; 
00189 
00190     OHSSelector* sel = new OHSSelector( 0, "gradientselector" );
00191     //#sel->resize( QSize( 200, 30 ) );
00192     //#sel->setColors( QColor( 90, 190, 60 ), QColor( 200, 55, 255 ) );
00193     //#sel->setText( "Dark", "Light" );
00194 
00195     sel->show();
00196 }
00197 
00198 void OpieUIDemo::messageBox( const QString& text )
00199 {
00200     QString info;
00201     info = "You have selected '" + text + "'";
00202     QMessageBox::information( this, "OpieUIDemo", info );
00203 }

Generated on Sat Nov 5 16:15:59 2005 for OPIE by  doxygen 1.4.2