1 | /****************************************************************************
|
---|
2 | ** $Id: qdesktopwidget_pm.cpp 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Implementation of QDesktopWidget class for OS/2
|
---|
5 | **
|
---|
6 | ** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
|
---|
7 | ** Copyright (C) 2004 Norman ASA. Initial OS/2 Port.
|
---|
8 | ** Copyright (C) 2005 netlabs.org. Further OS/2 Development.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #include "qdesktopwidget.h"
|
---|
39 |
|
---|
40 | /*
|
---|
41 | \omit
|
---|
42 | Function is commented out in header
|
---|
43 | \fn void *QDesktopWidget::handle( int screen ) const
|
---|
44 |
|
---|
45 | Returns the window system handle of the display device with the
|
---|
46 | index \a screen, for low-level access. Using this function is not
|
---|
47 | portable.
|
---|
48 |
|
---|
49 | The return type varies with platform; see qwindowdefs.h for details.
|
---|
50 |
|
---|
51 | \sa x11Display(), QPaintDevice::handle()
|
---|
52 | \endomit
|
---|
53 | */
|
---|
54 |
|
---|
55 | /*!
|
---|
56 | \class QDesktopWidget qdesktopwidget.h
|
---|
57 | \brief The QDesktopWidget class provides access to screen information on multi-head systems.
|
---|
58 |
|
---|
59 | \ingroup advanced
|
---|
60 | \ingroup environment
|
---|
61 |
|
---|
62 | Systems with more than one graphics card and monitor can manage the
|
---|
63 | physical screen space available either as multiple desktops, or as a
|
---|
64 | large virtual desktop, which usually has the size of the bounding
|
---|
65 | rectangle of all the screens (see isVirtualDesktop()). For an
|
---|
66 | application, one of the available screens is the primary screen, i.e.
|
---|
67 | the screen where the main widget resides (see primaryScreen()). All
|
---|
68 | windows opened in the context of the application must be
|
---|
69 | constrained to the boundaries of the primary screen; for example,
|
---|
70 | it would be inconvenient if a dialog box popped up on a different
|
---|
71 | screen, or split over two screens.
|
---|
72 |
|
---|
73 | The QDesktopWidget provides information about the geometry of the
|
---|
74 | available screens with screenGeometry(). The number of screens
|
---|
75 | available is returned by numScreens(). The screen number that a
|
---|
76 | particular point or widget is located in is returned by
|
---|
77 | screenNumber().
|
---|
78 |
|
---|
79 | Widgets provided by Qt use this class, for example, to place
|
---|
80 | tooltips, menus and dialog boxes according to the parent or
|
---|
81 | application widget.
|
---|
82 |
|
---|
83 | Applications can use this class to save window positions, or to place
|
---|
84 | child widgets on one screen.
|
---|
85 |
|
---|
86 | \img qdesktopwidget.png Managing Multiple Screens
|
---|
87 |
|
---|
88 | In the illustration above, Application One's primary screen is
|
---|
89 | screen 0, and App Two's primary screen is screen 1.
|
---|
90 |
|
---|
91 |
|
---|
92 | */
|
---|
93 |
|
---|
94 | /*!
|
---|
95 | Creates the desktop widget.
|
---|
96 |
|
---|
97 | If the system supports a virtual desktop, this widget will have
|
---|
98 | the size of the virtual desktop; otherwise this widget will have
|
---|
99 | the size of the primary screen.
|
---|
100 |
|
---|
101 | Instead of using QDesktopWidget directly, use
|
---|
102 | QAppliation::desktop().
|
---|
103 | */
|
---|
104 | QDesktopWidget::QDesktopWidget()
|
---|
105 | : QWidget( 0, "desktop", WType_Desktop )
|
---|
106 | {
|
---|
107 | }
|
---|
108 |
|
---|
109 | /*!
|
---|
110 | Destroy the object and free allocated resources.
|
---|
111 | */
|
---|
112 | QDesktopWidget::~QDesktopWidget()
|
---|
113 | {
|
---|
114 | }
|
---|
115 |
|
---|
116 | /*!
|
---|
117 | Returns TRUE if the system manages the available screens in a
|
---|
118 | virtual desktop; otherwise returns FALSE.
|
---|
119 |
|
---|
120 | For virtual desktops, screen() will always return the same widget.
|
---|
121 | The size of the virtual desktop is the size of this desktop
|
---|
122 | widget.
|
---|
123 | */
|
---|
124 | bool QDesktopWidget::isVirtualDesktop() const
|
---|
125 | {
|
---|
126 | return FALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | /*!
|
---|
130 | Returns the index of the primary screen.
|
---|
131 |
|
---|
132 | \sa numScreens()
|
---|
133 | */
|
---|
134 | int QDesktopWidget::primaryScreen() const
|
---|
135 | {
|
---|
136 | return 0;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /*!
|
---|
140 | Returns the number of available screens.
|
---|
141 |
|
---|
142 | \sa primaryScreen()
|
---|
143 | */
|
---|
144 | int QDesktopWidget::numScreens() const
|
---|
145 | {
|
---|
146 | return 1;
|
---|
147 | }
|
---|
148 |
|
---|
149 | /*!
|
---|
150 | Returns a widget that represents the screen with index \a screen.
|
---|
151 | This widget can be used to draw directly on the desktop, using an
|
---|
152 | unclipped painter like this:
|
---|
153 |
|
---|
154 | \code
|
---|
155 | QPainter paint( QApplication::desktop()->screen( 0 ), TRUE );
|
---|
156 | paint.draw...
|
---|
157 | ...
|
---|
158 | paint.end();
|
---|
159 | \endcode
|
---|
160 |
|
---|
161 | If the system uses a virtual desktop, the returned widget will
|
---|
162 | have the geometry of the entire virtual desktop i.e. bounding
|
---|
163 | every \a screen.
|
---|
164 |
|
---|
165 | \sa primaryScreen(), numScreens(), isVirtualDesktop()
|
---|
166 | */
|
---|
167 | QWidget *QDesktopWidget::screen( int /*screen*/ )
|
---|
168 | {
|
---|
169 | // It seems that a WType_Desktop cannot be moved?
|
---|
170 | return this;
|
---|
171 | }
|
---|
172 |
|
---|
173 | /*!
|
---|
174 | Returns the available geometry of the screen with index \a screen. What
|
---|
175 | is available will be subrect of screenGeometry() based on what the
|
---|
176 | platform decides is available (for example excludes the Dock and Menubar
|
---|
177 | on Mac OS X, or the taskbar on Windows).
|
---|
178 |
|
---|
179 | \sa screenNumber(), screenGeometry()
|
---|
180 | */
|
---|
181 | const QRect& QDesktopWidget::availableGeometry( int /*screen*/ ) const
|
---|
182 | {
|
---|
183 | //@@TODO (dmik): use WinGetMaxPosition () to take into account such
|
---|
184 | // things as XCenter?
|
---|
185 | return geometry();
|
---|
186 | }
|
---|
187 |
|
---|
188 | /*!
|
---|
189 | \overload const QRect &QDesktopWidget::availableGeometry( QWidget *widget ) const
|
---|
190 |
|
---|
191 | Returns the available geometry of the screen which contains \a widget.
|
---|
192 |
|
---|
193 | \sa screenGeometry()
|
---|
194 | */
|
---|
195 |
|
---|
196 | /*!
|
---|
197 | \overload const QRect &QDesktopWidget::availableGeometry( const QPoint &p ) const
|
---|
198 |
|
---|
199 | Returns the available geometry of the screen which contains \a p.
|
---|
200 |
|
---|
201 | \sa screenGeometry()
|
---|
202 | */
|
---|
203 |
|
---|
204 |
|
---|
205 | /*!
|
---|
206 | Returns the geometry of the screen with index \a screen.
|
---|
207 |
|
---|
208 | \sa screenNumber()
|
---|
209 | */
|
---|
210 | const QRect& QDesktopWidget::screenGeometry( int /*screen*/ ) const
|
---|
211 | {
|
---|
212 | return geometry();
|
---|
213 | }
|
---|
214 |
|
---|
215 | /*!
|
---|
216 | \overload const QRect &QDesktopWidget::screenGeometry( QWidget *widget ) const
|
---|
217 |
|
---|
218 | Returns the geometry of the screen which contains \a widget.
|
---|
219 | */
|
---|
220 |
|
---|
221 | /*!
|
---|
222 | \overload const QRect &QDesktopWidget::screenGeometry( const QPoint &p ) const
|
---|
223 |
|
---|
224 | Returns the geometry of the screen which contains \a p.
|
---|
225 | */
|
---|
226 |
|
---|
227 |
|
---|
228 | /*!
|
---|
229 | Returns the index of the screen that contains the largest
|
---|
230 | part of \a widget, or -1 if the widget not on a screen.
|
---|
231 |
|
---|
232 | \sa primaryScreen()
|
---|
233 | */
|
---|
234 | int QDesktopWidget::screenNumber( QWidget */*widget*/ ) const
|
---|
235 | {
|
---|
236 | return 0;
|
---|
237 | }
|
---|
238 |
|
---|
239 | /*!
|
---|
240 | \overload
|
---|
241 | Returns the index of the screen that contains \a point, or -1 if
|
---|
242 | no screen contains the point.
|
---|
243 |
|
---|
244 | \sa primaryScreen()
|
---|
245 | */
|
---|
246 | int QDesktopWidget::screenNumber( const QPoint &/*point*/ ) const
|
---|
247 | {
|
---|
248 | return 0;
|
---|
249 | }
|
---|
250 |
|
---|
251 | /*!
|
---|
252 | \reimp
|
---|
253 | */
|
---|
254 | void QDesktopWidget::resizeEvent( QResizeEvent * )
|
---|
255 | {
|
---|
256 | // do nothing, since the desktop cannot be dynamically resized in OS/2
|
---|
257 | //@@TODO (dmik): emit workAreaResized() when XCenter changes its size
|
---|
258 | // while reducing the desktop area?
|
---|
259 | }
|
---|
260 |
|
---|
261 | /*! \fn void QDesktopWidget::insertChild( QObject *child )
|
---|
262 | \reimp
|
---|
263 | */
|
---|
264 |
|
---|
265 | /*! \fn void QDesktopWidget::resized( int screen )
|
---|
266 | This signal is emitted when the size of \a screen changes.
|
---|
267 | */
|
---|
268 |
|
---|
269 | /*! \fn void QDesktopWidget::workAreaResized( int screen )
|
---|
270 | \internal
|
---|
271 | This signal is emitted when the work area available on \a screen changes.
|
---|
272 | */
|
---|