-rw-r--r-- | library/widget_showing.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/library/widget_showing.cpp b/library/widget_showing.cpp new file mode 100644 index 0000000..43ece64 --- a/dev/null +++ b/library/widget_showing.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | Copyright (c) 2004 Andreas Richter <ar@handhelds.org> | ||
4 | Copyright (c) 2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This library is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This library is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #include <qtopia/qpeapplication.h> | ||
33 | |||
34 | #ifdef Q_WS_QWS | ||
35 | extern Q_EXPORT QRect qt_maxWindowRect; | ||
36 | #endif | ||
37 | |||
38 | void QPEApplication::showDialog( QDialog* d, bool nomax ) | ||
39 | { | ||
40 | showWidget( d, nomax ); | ||
41 | } | ||
42 | |||
43 | int QPEApplication::execDialog( QDialog* d, bool nomax ) | ||
44 | { | ||
45 | showDialog( d, nomax ); | ||
46 | return d->exec(); | ||
47 | } | ||
48 | |||
49 | void QPEApplication::showWidget( QWidget* wg, bool nomax ) { | ||
50 | if ( wg->isVisible() ) { | ||
51 | wg->show(); | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | if ( !nomax | ||
56 | && ( qApp->desktop()->width() <= 320 ) ){ | ||
57 | wg->showMaximized(); | ||
58 | } else { | ||
59 | #ifdef Q_WS_QWS | ||
60 | QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() ); | ||
61 | #else | ||
62 | QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | ||
63 | #endif | ||
64 | |||
65 | QSize sh = wg->sizeHint(); | ||
66 | int w = QMAX( sh.width(), wg->width() ); | ||
67 | int h = QMAX( sh.height(), wg->height() ); | ||
68 | // desktop widget-frame taskbar | ||
69 | w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) ); | ||
70 | h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) ); | ||
71 | wg->resize( w, h ); | ||
72 | wg->show(); | ||
73 | } | ||
74 | } | ||