summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2003-09-02 18:15:07 (UTC)
committer zecke <zecke>2003-09-02 18:15:07 (UTC)
commit3cf3fc001922a7ef34c7ff95751beb569809383b (patch) (unidiff)
tree4fb5fba6b8684b7a9a6cf88e3eb3e02068e73a52 /libopie
parente87caebc920ad256d210eeb31aeb134318f0c104 (diff)
downloadopie-3cf3fc001922a7ef34c7ff95751beb569809383b.zip
opie-3cf3fc001922a7ef34c7ff95751beb569809383b.tar.gz
opie-3cf3fc001922a7ef34c7ff95751beb569809383b.tar.bz2
Allow adding child Osplitters and sharing
the same OTabBar ( untested ) but the normal mode still works
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/big-screen/osplitter.cpp263
-rw-r--r--libopie/big-screen/osplitter.h28
2 files changed, 266 insertions, 25 deletions
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp
index 1cd0fd5..d06568f 100644
--- a/libopie/big-screen/osplitter.cpp
+++ b/libopie/big-screen/osplitter.cpp
@@ -1,345 +1,560 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qvaluelist.h> 29#include <qvaluelist.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <opie/otabwidget.h> 32#include <opie/otabwidget.h>
33 33
34#include "osplitter.h" 34#include "osplitter.h"
35 35
36 36
37/** 37/**
38 * 38 *
39 * This is the constructor of OSplitter 39 * This is the constructor of OSplitter
40 * You might want to call setSizeChange to tell 40 * You might want to call setSizeChange to tell
41 * OSplitter to change its layout when a specefic 41 * OSplitter to change its layout when a specefic
42 * mark was crossed. OSplitter sets a default value. 42 * mark was crossed. OSplitter sets a default value.
43 * 43 *
44 * You cann add widget with addWidget to the OSplitter. 44 * You cann add widget with addWidget to the OSplitter.
45 * OSplitter supports also grouping of Splitters where they
46 * can share one OTabBar in small screen mode. This can be used
47 * for email clients like vies but see the example.
45 * 48 *
46 * @param orient The orientation wether to layout horizontal or vertical 49 * @param orient The orientation wether to layout horizontal or vertical
47 * @param parent The parent of this widget 50 * @param parent The parent of this widget
48 * @param name The name passed on to QObject 51 * @param name The name passed on to QObject
49 * @param fl Additional widgets flags passed to QWidget 52 * @param fl Additional widgets flags passed to QWidget
50 * 53 *
51 * @short single c'tor of the OSplitter 54 * @short single c'tor of the OSplitter
52 */ 55 */
53OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) 56OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
54 : QFrame( parent, name, fl ) 57 : QFrame( parent, name, fl )
55{ 58{
56 m_orient = orient; 59 m_orient = orient;
57 m_hbox = 0; 60 m_hbox = 0;
58 m_size_policy = 330; 61 m_size_policy = 330;
59 setFontPropagation( AllChildren ); 62 setFontPropagation( AllChildren );
60 setPalettePropagation( AllChildren ); 63 setPalettePropagation( AllChildren );
61 64
62 /* start by default with the tab widget */ 65 /* start by default with the tab widget */
63 m_tabWidget = 0; 66 m_tabWidget = 0;
67 m_parentTab = 0;
64 changeTab(); 68 changeTab();
65 69
66} 70}
67 71
68 72
69/** 73/**
70 * Destructor destructs this object and cleans up. All child 74 * Destructor destructs this object and cleans up. All child
71 * widgets will be deleted 75 * widgets will be deleted
72 * @see addWidget 76 * @see addWidget
73 */ 77 */
74OSplitter::~OSplitter() { 78OSplitter::~OSplitter() {
79 m_splitter.setAutoDelete( true );
80 m_splitter.clear();
81
75 delete m_hbox; 82 delete m_hbox;
76 delete m_tabWidget; 83 delete m_tabWidget;
77} 84}
78 85
79 86
80/** 87/**
88 * Sets the label for the Splitter. This label will be used
89 * if a parent splitter is arranged as TabWidget but
90 * this splitter is in fullscreen mode. Then a tab with OSplitter::label()
91 * and iconName() gets added.
92 *
93 * @param name The name of the Label
94 */
95void OSplitter::setLabel( const QString& name ) {
96 m_name = name;
97}
98
99/**
100 * @see setLabel but this is for the icon retrieved by Resource
101 *
102 * @param name The name of the icon in example ( "zoom" )
103 */
104void OSplitter::setIconName( const QString& name ) {
105 m_icon = name;
106}
107
108
109/**
110 * returns the iconName
111 * @see setIconName
112 */
113QString OSplitter::iconName()const {
114 return m_icon;
115}
116
117/**
118 * returns the label set with setLabel
119 * @see setLabel
120 */
121QString OSplitter::label()const {
122 return m_name;
123}
124
125/**
81 * This function sets the size change policy of the splitter. 126 * This function sets the size change policy of the splitter.
82 * If this size marked is crossed the splitter will relayout. 127 * If this size marked is crossed the splitter will relayout.
83 * Note: that depending on the set Orientation it'll either look 128 * Note: that depending on the set Orientation it'll either look
84 * at the width or height. 129 * at the width or height.
85 * Note: If you want to from side to side view to tabbed view you need 130 * Note: If you want to from side to side view to tabbed view you need
86 * to make sure that the size you supply is not smaller than the minimum 131 * to make sure that the size you supply is not smaller than the minimum
87 * size of your added widgets. Note that if you use widgets like QComboBoxes 132 * size of your added widgets. Note that if you use widgets like QComboBoxes
88 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy 133 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
89 * 134 *
90 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. 135 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
91 * @return void 136 * @return void
92 */ 137 */
93void OSplitter::setSizeChange( int width_height ) { 138void OSplitter::setSizeChange( int width_height ) {
94 m_size_policy = width_height; 139 m_size_policy = width_height;
95 QSize sz(width(), height() ); 140 QSize sz(width(), height() );
96 QResizeEvent ev(sz, sz ); 141 QResizeEvent ev(sz, sz );
97 resizeEvent(&ev); 142 resizeEvent(&ev);
98} 143}
99 144
100/** 145/**
146 * This functions allows to add another OSplitter and to share
147 * the OTabBar in small screen mode. The ownerships gets transfered.
148 * OSplitters are always added after normal widget items
149 */
150void OSplitter::addWidget( OSplitter* split ) {
151 m_splitter.append( split );
152
153 /*
154 * set tab widget
155 */
156 if (m_tabWidget )
157 split->setTabWidget( m_tabWidget );
158 else{
159 Opie::OSplitterContainer con;
160 con.widget =split;
161 addToBox( con );
162 }
163}
164
165/*
166 * If in a tab it should be removed
167 * and if in a hbox the reparent kills it too
168 */
169/**
170 * This removes the splitter again. You currently need to call this
171 * before you delete or otherwise you can get mem corruption
172 * or other weird behaviour.
173 * Owner ship gets transfered back to you it's current parent
174 * is 0
175 */
176void OSplitter::removeWidget( OSplitter* split) {
177 split->setTabWidget( 0 );
178 split->reparent( 0, 0, QPoint(0, 0) );
179}
180
181/**
101 * Adds a widget to the Splitter. The widgets gets inserted 182 * Adds a widget to the Splitter. The widgets gets inserted
102 * at the end of either the Box or TabWidget. 183 * at the end of either the Box or TabWidget.
103 * Ownership gets transfered and the widgets gets reparented. 184 * Ownership gets transfered and the widgets gets reparented.
104 * Note: icon and label is only available on small screensizes 185 * Note: icon and label is only available on small screensizes
105 * if size is smaller than the mark 186 * if size is smaller than the mark
106 * Warning: No null checking of the widget is done. Only on debug 187 * Warning: No null checking of the widget is done. Only on debug
107 * a message will be outputtet 188 * a message will be outputtet
108 * 189 *
109 * @param wid The widget which will be added 190 * @param wid The widget which will be added
110 * @param icon The icon of the possible Tab 191 * @param icon The icon of the possible Tab
111 * @param label The label of the possible Tab 192 * @param label The label of the possible Tab
112 */ 193 */
113void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { 194void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) {
114#ifdef DEBUG 195#ifdef DEBUG
115 if (!wid ) { 196 if (!wid ) {
116 qWarning("Widget is not valid!"); 197 qWarning("Widget is not valid!");
117 return; 198 return;
118 } 199 }
119#endif 200#endif
120 Opie::OSplitterContainer cont; 201 Opie::OSplitterContainer cont;
121 cont.widget = wid; 202 cont.widget = wid;
122 cont.icon =icon; 203 cont.icon =icon;
123 cont.name = label; 204 cont.name = label;
124 205
125 m_container.append( cont ); 206 m_container.append( cont );
126 207
127 if (m_hbox ) 208 /*
128 addToBox( cont ); 209 *
129 else 210 */
130 addToTab( cont ); 211 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
212 setTabWidget( m_parentTab );
213 else {
214 if (m_hbox )
215 addToBox( cont );
216 else
217 addToTab( cont );
218 }
131} 219}
132 220
133 221
134/** 222/**
135 * Removes the widget from the tab widgets if necessary. 223 * Removes the widget from the tab widgets if necessary.
136 * OSplitter drops ownership of this widget and the widget 224 * OSplitter drops ownership of this widget and the widget
137 * will be reparented i tto 0. 225 * will be reparented i tto 0.
138 * The widget will not be deleted. 226 * The widget will not be deleted.
139 * 227 *
140 * @param w The widget to be removed 228 * @param w The widget to be removed
141 */ 229 */
142void OSplitter::removeWidget( QWidget* w) { 230void OSplitter::removeWidget( QWidget* w) {
143 ContainerList::Iterator it; 231 ContainerList::Iterator it;
144 for ( it = m_container.begin(); it != m_container.end(); ++it ) 232 for ( it = m_container.begin(); it != m_container.end(); ++it )
145 if ( (*it).widget == w ) 233 if ( (*it).widget == w )
146 break; 234 break;
147 235
148 if (it == m_container.end() ) 236 if (it == m_container.end() )
149 return; 237 return;
150 238
151 239
152 /* only tab needs to be removed.. box recognizes it */ 240 /* only tab needs to be removed.. box recognizes it */
153 if ( !m_hbox ) 241 if ( !m_hbox )
154 removeFromTab( w ); 242 removeFromTab( w );
155 243
156 244
157 /* Find reparent it and remove it from our list */ 245 /* Find reparent it and remove it from our list */
158 246
159 w->reparent( 0, 0, QPoint(0, 0)); 247 w->reparent( 0, 0, QPoint(0, 0));
160 it = m_container.remove( it ); 248 it = m_container.remove( it );
161 249
162} 250}
163 251
164 252
165/** 253/**
166 * This method will give focus to the widget. If in a tabwidget 254 * This method will give focus to the widget. If in a tabwidget
167 * the tabbar will be changed 255 * the tabbar will be changed
168 * 256 *
169 * @param w The widget which will be set the current one 257 * @param w The widget which will be set the current one
170 */ 258 */
171void OSplitter::setCurrentWidget( QWidget* w) { 259void OSplitter::setCurrentWidget( QWidget* w) {
172 if (m_tabWidget ) 260 if (m_tabWidget )
173 m_tabWidget->setCurrentTab( w ); 261 m_tabWidget->setCurrentTab( w );
174// else 262// else
175 // m_hbox->setFocus( w ); 263 // m_hbox->setFocus( w );
176 264
177} 265}
178 266
179/** 267/**
180 * This is an overloaded member function and only differs in the 268 * This is an overloaded member function and only differs in the
181 * argument it takes. 269 * argument it takes.
182 * Searches list of widgets for label. It'll pick the first label it finds 270 * Searches list of widgets for label. It'll pick the first label it finds
183 * 271 *
184 * @param label Label to look for. First match will be taken 272 * @param label Label to look for. First match will be taken
185 */ 273 */
186void OSplitter::setCurrentWidget( const QString& label ) { 274void OSplitter::setCurrentWidget( const QString& label ) {
187 ContainerList::Iterator it; 275 ContainerList::Iterator it;
188 for (it = m_container.begin(); it != m_container.end(); ++it ) { 276 for (it = m_container.begin(); it != m_container.end(); ++it ) {
189 if ( (*it).name == label ) { 277 if ( (*it).name == label ) {
190 setCurrentWidget( (*it).widget ); 278 setCurrentWidget( (*it).widget );
191 break; 279 break;
192 } 280 }
193 } 281 }
194} 282}
195 283
196/** 284/**
197 * This will only work when the TabWidget is active 285 * This will only work when the TabWidget is active
198 * If everything is visible this signal is kindly ignored 286 * If everything is visible this signal is kindly ignored
199 * @see OTabWidget::setCurrentTab(int) 287 * @see OTabWidget::setCurrentTab(int)
200 * 288 *
201 * @param tab The tab to make current 289 * @param tab The tab to make current
202 */ 290 */
203void OSplitter::setCurrentWidget( int tab ) { 291void OSplitter::setCurrentWidget( int tab ) {
204 if (m_tabWidget ) 292 if (m_tabWidget )
205 m_tabWidget->setCurrentTab( tab ); 293 m_tabWidget->setCurrentTab( tab );
206} 294}
207 295
208/** 296/**
209 * return the currently activated widget if in tab widget mode 297 * return the currently activated widget if in tab widget mode
210 * or null because all widgets are visible 298 * or null because all widgets are visible
211 */ 299 */
212QWidget* OSplitter::currentWidget() { 300QWidget* OSplitter::currentWidget() const{
213 if ( m_hbox ) 301 if (m_tabWidget)
214 return 0l;
215 else
216 return m_tabWidget->currentWidget(); 302 return m_tabWidget->currentWidget();
303 else if (m_parentTab )
304 return m_parentTab->currentWidget();
305
306 return 0l;
217} 307}
218 308
219#if 0 309#if 0
220/** 310/**
221 * @reimplented for internal reasons 311 * @reimplented for internal reasons
222 * returns the sizeHint of one of its sub widgets 312 * returns the sizeHint of one of its sub widgets
223 */ 313 */
224QSize OSplitter::sizeHint()const { 314QSize OSplitter::sizeHint()const {
225 return QSize(10, 10); 315 return QSize(10, 10);
226 316
227 if (m_hbox ) 317 if (m_hbox )
228 return m_hbox->sizeHint(); 318 return m_hbox->sizeHint();
229 else 319 else
230 return m_tabWidget->sizeHint(); 320 return m_tabWidget->sizeHint();
231} 321}
232 322
233QSize OSplitter::minimumSizeHint()const { 323QSize OSplitter::minimumSizeHint()const {
234 return QSize(10, 10 ); 324 return QSize(10, 10 );
235} 325}
236#endif 326#endif
237 327
238/** 328/**
239 * @reimplemented for internal reasons 329 * @reimplemented for internal reasons
240 */ 330 */
241void OSplitter::resizeEvent( QResizeEvent* res ) { 331void OSplitter::resizeEvent( QResizeEvent* res ) {
242 QFrame::resizeEvent( res ); 332 QFrame::resizeEvent( res );
243 /* 333 /*
244 * 334 *
245 */ 335 */
246// qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); 336// qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() );
337 bool mode = true;
247 qWarning("New size is width = %d height = %d", res->size().width(), res->size().height() ); 338 qWarning("New size is width = %d height = %d", res->size().width(), res->size().height() );
248 if ( res->size().width() > m_size_policy && 339 if ( res->size().width() > m_size_policy &&
249 m_orient == Horizontal ) { 340 m_orient == Horizontal ) {
250 changeHBox(); 341 changeHBox();
342 mode = false;
251 }else if ( (res->size().width() <= m_size_policy && 343 }else if ( (res->size().width() <= m_size_policy &&
252 m_orient == Horizontal ) || 344 m_orient == Horizontal ) ||
253 (res->size().height() <= m_size_policy && 345 (res->size().height() <= m_size_policy &&
254 m_orient == Vertical ) ) { 346 m_orient == Vertical ) ) {
255 changeTab(); 347 changeTab();
256 }else if ( res->size().height() > m_size_policy && 348 }else if ( res->size().height() > m_size_policy &&
257 m_size_policy == Vertical ) { 349 m_size_policy == Vertical ) {
258 changeVBox(); 350 changeVBox();
351 mode = false;
259 } 352 }
260}
261 353
354 emit sizeChanged(mode, m_orient );
355}
262 356
357/*
358 * Adds a container to a tab either the parent tab
359 * or our own
360 */
263void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { 361void OSplitter::addToTab( const Opie::OSplitterContainer& con ) {
264 QWidget *wid = con.widget; 362 QWidget *wid = con.widget;
265// not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 363// not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
266 m_tabWidget->addTab( wid, con.icon, con.name ); 364 if (m_parentTab )
365 m_parentTab->addTab( wid, con.icon, con.name );
366 else
367 m_tabWidget->addTab( wid, con.icon, con.name );
267} 368}
268 369
370
371/*
372 * adds a container to the box
373 */
269void OSplitter::addToBox( const Opie::OSplitterContainer& con ) { 374void OSplitter::addToBox( const Opie::OSplitterContainer& con ) {
270 QWidget* wid = con.widget; 375 QWidget* wid = con.widget;
271 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 376 wid->reparent(m_hbox, 0, QPoint(0, 0) );
272} 377}
273 378
379
380/*
381 * Removes a widget from the tab
382 */
274void OSplitter::removeFromTab( QWidget* wid ) { 383void OSplitter::removeFromTab( QWidget* wid ) {
275 m_tabWidget->removePage( wid ); 384 if (m_parentTab )
385 m_parentTab->removePage( wid );
386 else
387 m_tabWidget->removePage( wid );
276} 388}
277 389
390/*
391 * switches over to a OTabWidget layout
392 * it is recursive
393 */
278void OSplitter::changeTab() { 394void OSplitter::changeTab() {
395 /* if we're the owner of the tab widget */
279 if (m_tabWidget ) { 396 if (m_tabWidget ) {
280 m_tabWidget->setGeometry( frameRect() ); 397 m_tabWidget->setGeometry( frameRect() );
281 return; 398 return;
282 } 399 }
283 400
284 qWarning(" New Tab Widget "); 401 qWarning(" New Tab Widget ");
285 /* 402 /*
286 * and add all widgets this will reparent them 403 * and add all widgets this will reparent them
287 * delete m_hbox set it to 0 404 * delete m_hbox set it to 0
288 * 405 *
289 */ 406 */
290 m_tabWidget = new OTabWidget( this ); 407 OTabWidget *tab;
291 connect(m_tabWidget, SIGNAL(currentChanged(QWidget*) ), 408 if ( m_parentTab ) {
409 tab = m_parentTab;
410 tab->removePage( this );
411 }else
412 tab = m_tabWidget = new OTabWidget( this );
413
414 connect(tab, SIGNAL(currentChanged(QWidget*) ),
292 this, SIGNAL(currentChanged(QWidget*) ) ); 415 this, SIGNAL(currentChanged(QWidget*) ) );
293 416
294 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { 417 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) {
295 qWarning("Widget is %s", (*it).name.latin1() ); 418 qWarning("Widget is %s", (*it).name.latin1() );
296 addToTab( (*it) ); 419 addToTab( (*it) );
297 } 420 }
298 421
422 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
423 split->setTabWidget( tab );
424
425
299 delete m_hbox; 426 delete m_hbox;
300 m_hbox = 0; 427 m_hbox = 0;
428 if (!m_tabWidget )
429 return;
430
301 m_tabWidget->setGeometry( frameRect() ); 431 m_tabWidget->setGeometry( frameRect() );
302 m_tabWidget->show(); 432 m_tabWidget->show();
303 433
304} 434}
305 435
436/*
437 * changes over to a box
438 * this is recursive as well
439 */
306void OSplitter::changeHBox() { 440void OSplitter::changeHBox() {
307 if (m_hbox ) { 441 if (m_hbox ) {
308 m_hbox->setGeometry( frameRect() ); 442 m_hbox->setGeometry( frameRect() );
309 return; 443 return;
310 } 444 }
311 445
312 qWarning("new HBox"); 446 qWarning("new HBox");
313 m_hbox = new QHBox( this ); 447 m_hbox = new QHBox( this );
314 commonChangeBox(); 448 commonChangeBox();
315 delete m_tabWidget;
316 m_tabWidget = 0;
317 m_hbox->setGeometry( frameRect() );
318 m_hbox->show();
319} 449}
320 450
321void OSplitter::changeVBox() { 451void OSplitter::changeVBox() {
322 if (m_hbox ) { 452 if (m_hbox ) {
323 m_hbox->setGeometry( frameRect() ); 453 m_hbox->setGeometry( frameRect() );
324 return; 454 return;
325 } 455 }
326 456
327 qWarning("New VBOX"); 457 qWarning("New VBOX");
328 m_hbox = new QVBox( this ); 458 m_hbox = new QVBox( this );
329 459
330 commonChangeBox(); 460 commonChangeBox();
331 delete m_tabWidget;
332 m_tabWidget = 0;
333 m_hbox->setGeometry( frameRect() );
334 m_hbox->show();
335}
336 461
462}
337 463
464/*
465 * common box code
466 * first remove and add children
467 * the other splitters
468 * it is recursive as well due the call to setTabWidget
469 */
338void OSplitter::commonChangeBox() { 470void OSplitter::commonChangeBox() {
471
339 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { 472 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) {
473 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
474 if (m_parentTab )
475 removeFromTab( (*it).widget );
340 qWarning("Adding to box %s", (*it).name.latin1() ); 476 qWarning("Adding to box %s", (*it).name.latin1() );
341 addToBox( (*it) ); 477 addToBox( (*it) );
342 } 478 }
343 delete m_tabWidget; 479 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) {
344 m_tabWidget = 0; 480 /* tell them the world had changed */
481 split->setTabWidget( 0 );
482 Opie::OSplitterContainer con;
483 con.widget = split;
484 addToBox( con );
485 }
486
487
488
489 if (m_parentTab )
490 m_parentTab->addTab(this, iconName(), label() );
491 else {
492 m_hbox->setGeometry( frameRect() );
493 m_hbox->show();
494 delete m_tabWidget;
495 m_tabWidget = 0;
496 }
497}
498
499/*
500 * sets the tabwidget, removes tabs, and relayouts the widget
501 */
502void OSplitter::setTabWidget( OTabWidget* wid) {
503 /* clean up cause m_parentTab will not be available for us */
504 if ( m_parentTab ) {
505 if (m_hbox )
506 m_parentTab->removePage( this );
507 else if (!m_container.isEmpty() ){
508 ContainerList::Iterator it = m_container.begin();
509 for ( ; it != m_container.end(); ++it )
510 m_parentTab->removePage( (*it).widget );
511 }
512 }
513 /* the parent Splitter changed so either make us indepent or dep */
514
515 m_parentTab = wid;
516
517 QWidget *tab = m_tabWidget;
518 QWidget *box = m_hbox;
519 m_hbox = 0; m_tabWidget = 0;
520
521 if ( layoutMode() )
522 changeTab();
523 else if (m_orient == Horizontal )
524 changeHBox();
525 else
526 changeVBox();
527
528 /* our own crap is added and children from change* */
529 delete tab;
530 delete box;
531}
532
533
534#if 0
535void OSplitter::reparentAll() {
536 if (m_container.isEmpty() )
537 return;
538
539 ContainerList::Iterator it = m_container.begin();
540 for ( ; it != m_container.end(); ++it )
541 (*it).wid->reparent(0, 0, QPoint(0, 0) );
542
543
544}
545#endif
546
547/**
548 * @internal
549 */
550bool OSplitter::layoutMode()const {
551 if ( size().width() > m_size_policy &&
552 m_orient == Horizontal ) {
553 return false;
554 }else if ( size().height() > m_size_policy &&
555 m_size_policy == Vertical ) {
556 return false;
557 }
558
559 return true;
345} 560}
diff --git a/libopie/big-screen/osplitter.h b/libopie/big-screen/osplitter.h
index db69fc6..2bcde57 100644
--- a/libopie/big-screen/osplitter.h
+++ b/libopie/big-screen/osplitter.h
@@ -1,113 +1,139 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OPIE_SPLITTER_H 29#ifndef OPIE_SPLITTER_H
30#define OPIE_SPLITTER_H 30#define OPIE_SPLITTER_H
31 31
32#include <qstring.h> 32#include <qstring.h>
33 33
34#include <qframe.h> 34#include <qframe.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36#include <qlist.h>
36 37
37#include "obigscreen_p.h" 38#include "obigscreen_p.h"
38 39
39/* forward declarations */ 40/* forward declarations */
40class OTabWidget; 41class OTabWidget;
41class QHBox; 42class QHBox;
42//template class QValueList<Opie::OSplitterContainer>; 43//template class QValueList<Opie::OSplitterContainer>;
43 44
44 45
45/** 46/**
46 * 47 *
47 * If you've widgets that could be placed side by side but you think 48 * If you've widgets that could be placed side by side but you think
48 * on small resolutions is not enough place but it would really make sense 49 * on small resolutions is not enough place but it would really make sense
49 * on bigger resolutions this class will help you. 50 * on bigger resolutions this class will help you.
50 * You can add as many widgets you want to it. Set a poliy on which width/height it 51 * You can add as many widgets you want to it. Set a poliy on which width/height it
51 * should switch the layout. 52 * should switch the layout.
52 * You can either say to place widgets vertical or horizontal. 53 * You can either say to place widgets vertical or horizontal.
53 * This class uses QHBox, QVBox and QTAbWidget internally. 54 * This class uses QHBox, QVBox and QTAbWidget internally.
54 * OSplitter takes ownership of the widgets 55 * OSplitter takes ownership of the widgets
55 * 56 *
56 * @since 1.2 57 * @since 1.2
57 * 58 *
58 * @short a small dynamically changing its layout to store two or more widgets side by side 59 * @short a small dynamically changing its layout to store two or more widgets side by side
59 * @version 0.1 60 * @version 0.1
60 * @author zecke 61 * @author zecke
61 */ 62 */
62class OSplitter : public QFrame{ 63class OSplitter : public QFrame{
63 Q_OBJECT 64 Q_OBJECT
64public: 65public:
65 typedef QValueList<Opie::OSplitterContainer> ContainerList; 66 typedef QValueList<Opie::OSplitterContainer> ContainerList;
66 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, 67 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0,
67 const char* name = 0, WFlags fl = 0 ); 68 const char* name = 0, WFlags fl = 0 );
68 ~OSplitter(); 69 ~OSplitter();
69 70
71 void setLabel( const QString& name );
72 void setIconName( const QString& name );
73 QString label()const;
74 QString iconName()const;
75
70 void setSizeChange( int width_height ); 76 void setSizeChange( int width_height );
71 77
78 void addWidget( OSplitter* splitter );
72 void addWidget( QWidget* wid, const QString& icon, const QString& label ); 79 void addWidget( QWidget* wid, const QString& icon, const QString& label );
73 void removeWidget( QWidget* ); 80 void removeWidget( QWidget* );
81 void removeWidget( OSplitter* );
74 82
75 void setCurrentWidget( QWidget* ); 83 void setCurrentWidget( QWidget* );
76 void setCurrentWidget( const QString& label ); 84 void setCurrentWidget( const QString& label );
77 void setCurrentWidget( int ); 85 void setCurrentWidget( int );
78 QWidget* currentWidget(); 86 QWidget* currentWidget()const;
79 87
80signals: 88signals:
81 /** 89 /**
82 * Emitted if in tab and comes directly from the tab widget 90 * Emitted if in tab and comes directly from the tab widget
83 * 91 *
84 */ 92 */
85 void currentChanged( QWidget* ); 93 void currentChanged( QWidget* );
94
95 /**
96 * emitted whenever a border is crossed
97 * true if in small screen mode
98 * false if in bigscreen
99 * this signal is emitted after the layout switch
100 * @param b The layout mode
101 * @param ori The orientation
102 */
103 void sizeChanged( bool b, Orientation ori);
86public: 104public:
87// QSize sizeHint()const; 105// QSize sizeHint()const;
88// QSize minimumSizeHint()const; 106// QSize minimumSizeHint()const;
89 107
90protected: 108protected:
91 void resizeEvent( QResizeEvent* ); 109 void resizeEvent( QResizeEvent* );
92 110
93private: 111private:
112 /* true if OTabMode */
113 bool layoutMode()const;
114// void reparentAll();
115 void setTabWidget( OTabWidget*);
94 void addToTab( const Opie::OSplitterContainer& ); 116 void addToTab( const Opie::OSplitterContainer& );
95 void addToBox( const Opie::OSplitterContainer& ); 117 void addToBox( const Opie::OSplitterContainer& );
96 void removeFromTab( QWidget* ); 118 void removeFromTab( QWidget* );
97 void changeTab(); 119 void changeTab();
98 void changeHBox(); 120 void changeHBox();
99 void changeVBox(); 121 void changeVBox();
100 void commonChangeBox(); 122 void commonChangeBox();
101 QHBox *m_hbox; 123 QHBox *m_hbox;
102 OTabWidget *m_tabWidget; 124 OTabWidget *m_tabWidget;
125 OTabWidget *m_parentTab;
103 Orientation m_orient; 126 Orientation m_orient;
104 int m_size_policy; 127 int m_size_policy;
105 128
106 ContainerList m_container; 129 ContainerList m_container;
130 QList<OSplitter> m_splitter;
131
132 QString m_icon, m_name;
107 133
108 struct Private; 134 struct Private;
109 Private *d; 135 Private *d;
110}; 136};
111 137
112 138
113#endif 139#endif