Diffstat (limited to 'libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp new file mode 100644 index 0000000..197669c --- a/dev/null +++ b/libopie2/examples/opieui/oversatileviewdemo/opieuidemo.cpp | |||
@@ -0,0 +1,205 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ***********************************************************************/ | ||
15 | |||
16 | // Qt | ||
17 | |||
18 | #include <qcolor.h> | ||
19 | #include <qpopupmenu.h> | ||
20 | #include <qmenubar.h> | ||
21 | #include <qmessagebox.h> | ||
22 | #include <qvbox.h> | ||
23 | #include <qstring.h> | ||
24 | #include <qstringlist.h> | ||
25 | |||
26 | // Qtopia | ||
27 | |||
28 | #ifdef QWS | ||
29 | #include <qpe/qpeapplication.h> | ||
30 | #include <qpe/global.h> | ||
31 | #endif | ||
32 | |||
33 | // Opie | ||
34 | |||
35 | #ifdef QWS | ||
36 | #include <opie/odevice.h> | ||
37 | using namespace Opie; | ||
38 | #endif | ||
39 | |||
40 | #include <opie2/ocompletionbox.h> | ||
41 | #include <opie2/olineedit.h> | ||
42 | #include <opie2/ocombobox.h> | ||
43 | #include <opie2/oeditlistbox.h> | ||
44 | #include <opie2/oselector.h> | ||
45 | #include <opie2/opopupmenu.h> | ||
46 | |||
47 | #include <qtabwidget.h> | ||
48 | #include "oversatileviewdemo.h" | ||
49 | |||
50 | // Local | ||
51 | |||
52 | #include "opieuidemo.h" | ||
53 | |||
54 | enum Demos { ocompletionbox, olineedit, ocombobox, oeditlistbox, oselector }; | ||
55 | |||
56 | OpieUIDemo::OpieUIDemo( QWidget* parent, const char* name, WFlags fl ) | ||
57 | : QMainWindow( parent, name, fl ) | ||
58 | { | ||
59 | |||
60 | QMenuBar* mbar = this->menuBar(); | ||
61 | OPopupMenu* demo = new OPopupMenu( this ); | ||
62 | demo->setTitle( "Title" ); | ||
63 | demo->setItemParameter( demo->insertItem( "OCompletionBox", this, SLOT( demo(int) ) ), ocompletionbox ); | ||
64 | demo->setItemParameter( demo->insertItem( "OLineEdit", this, SLOT( demo(int) ) ), olineedit ); | ||
65 | demo->setItemParameter( demo->insertItem( "OComboBox", this, SLOT( demo(int) ) ), ocombobox ); | ||
66 | demo->setItemParameter( demo->insertItem( "OEditListBox", this, SLOT( demo(int) ) ), oeditlistbox ); | ||
67 | demo->setItemParameter( demo->insertItem( "OSelector", this, SLOT( demo(int) ) ), oselector ); | ||
68 | mbar->insertItem( "Demonstrate", demo ); | ||
69 | |||
70 | build(); | ||
71 | |||
72 | } | ||
73 | |||
74 | OpieUIDemo::~OpieUIDemo() | ||
75 | { | ||
76 | } | ||
77 | |||
78 | void OpieUIDemo::build() | ||
79 | { | ||
80 | main = new QTabWidget( this, "tabwidget" ); | ||
81 | setCentralWidget( main ); | ||
82 | main->show(); | ||
83 | |||
84 | main->addTab( new OVersatileViewDemo( main ), "VersatileView" ); | ||
85 | } | ||
86 | |||
87 | |||
88 | void OpieUIDemo::demo( int d ) | ||
89 | { | ||
90 | switch (d) | ||
91 | { | ||
92 | case ocompletionbox: demoOCompletionBox(); break; | ||
93 | case olineedit: demoOLineEdit(); break; | ||
94 | case ocombobox: demoOComboBox(); break; | ||
95 | case oeditlistbox: demoOEditListBox(); break; | ||
96 | case oselector: demoOSelector(); break; | ||
97 | |||
98 | } | ||
99 | |||
100 | } | ||
101 | |||
102 | void OpieUIDemo::demoOCompletionBox() | ||
103 | { | ||
104 | qDebug( "ocompletionbox" ); | ||
105 | |||
106 | OCompletionBox* box = new OCompletionBox( 0 ); | ||
107 | box->insertItem( "This CompletionBox" ); | ||
108 | box->insertItem( "Says 'Hello World'" ); | ||
109 | box->insertItem( "Here are some" ); | ||
110 | box->insertItem( "Additional Items" ); | ||
111 | box->insertItem( "Complete Completion Box" ); | ||
112 | |||
113 | connect( box, SIGNAL( activated( const QString& ) ), this, SLOT( messageBox( const QString& ) ) ); | ||
114 | box->popup(); | ||
115 | |||
116 | } | ||
117 | |||
118 | void OpieUIDemo::demoOLineEdit() | ||
119 | { | ||
120 | qDebug( "olineedit" ); | ||
121 | |||
122 | OLineEdit *edit = new OLineEdit( 0, "lineedit" ); | ||
123 | |||
124 | edit->setCompletionMode( OGlobalSettings::CompletionPopup ); | ||
125 | OCompletion* comp = edit->completionObject(); | ||
126 | |||
127 | QStringList list; | ||
128 | list << "mickeyl@handhelds.org"; | ||
129 | list << "mickey@tm.informatik.uni-frankfurt.de"; | ||
130 | list << "mickey@vanille.de"; | ||
131 | |||
132 | comp->setItems( list ); | ||
133 | |||
134 | edit->show(); | ||
135 | |||
136 | } | ||
137 | |||
138 | void OpieUIDemo::demoOComboBox() | ||
139 | { | ||
140 | qDebug( "ocombobox" ); | ||
141 | |||
142 | OComboBox *combo = new OComboBox( true, 0, "combobox" ); | ||
143 | |||
144 | combo->setCompletionMode( OGlobalSettings::CompletionPopup ); | ||
145 | OCompletion* comp = combo->completionObject(); | ||
146 | |||
147 | QStringList ilist; | ||
148 | ilist << "kergoth@handhelds.org"; | ||
149 | ilist << "harlekin@handhelds.org"; | ||
150 | ilist << "groucho@handhelds.org"; | ||
151 | combo->insertStringList( ilist ); | ||
152 | |||
153 | QStringList clist; | ||
154 | clist << "mickeyl@handhelds.org"; | ||
155 | clist << "mickey@tm.informatik.uni-frankfurt.de"; | ||
156 | clist << "mickey@vanille.de"; | ||
157 | comp->setItems( clist ); | ||
158 | |||
159 | combo->show(); | ||
160 | |||
161 | } | ||
162 | |||
163 | void OpieUIDemo::demoOEditListBox() | ||
164 | { | ||
165 | qDebug( "oeditlistbox" ); | ||
166 | |||
167 | OEditListBox* edit = new OEditListBox( "OEditListBox", 0, "editlistbox" ); | ||
168 | |||
169 | edit->lineEdit()->setCompletionMode( OGlobalSettings::CompletionPopup ); | ||
170 | OCompletion* comp = edit->lineEdit()->completionObject(); | ||
171 | QStringList clist; | ||
172 | clist << "Completion everywhere"; | ||
173 | clist << "Cool Completion everywhere"; | ||
174 | clist << "History History History"; | ||
175 | comp->setItems( clist ); | ||
176 | |||
177 | QStringList list; | ||
178 | list << "kergoth@handhelds.org"; | ||
179 | list << "harlekin@handhelds.org"; | ||
180 | list << "groucho@handhelds.org"; | ||
181 | list << "mickeyl@handhelds.org"; | ||
182 | edit->insertStringList( list ); | ||
183 | |||
184 | edit->show(); | ||
185 | |||
186 | } | ||
187 | |||
188 | void OpieUIDemo::demoOSelector() | ||
189 | { | ||
190 | qDebug( "oselector" ); | ||
191 | |||
192 | OHSSelector* sel = new OHSSelector( 0, "gradientselector" ); | ||
193 | //#sel->resize( QSize( 200, 30 ) ); | ||
194 | //#sel->setColors( QColor( 90, 190, 60 ), QColor( 200, 55, 255 ) ); | ||
195 | //#sel->setText( "Dark", "Light" ); | ||
196 | |||
197 | sel->show(); | ||
198 | } | ||
199 | |||
200 | void OpieUIDemo::messageBox( const QString& text ) | ||
201 | { | ||
202 | QString info; | ||
203 | info = "You have selected '" + text + "'"; | ||
204 | QMessageBox::information( this, "OpieUIDemo", info ); | ||
205 | } | ||