annotate src/video/qtopia/SDL_QWin.h @ 4085:51486c979189 SDL-1.2

> Hi Ryan, > I checked the list you linked to, but did not see any reference to whether > the Win32 window centering bug was fixed... Has that been addressed at all? > I refer to the bug where, unless one has globally set the > SDL_WINDOW_CENTERED variable in the OS, only the 1st window that is created > will be centered. Subsequent calls to SetVideoMode will create a window tha t > shares the same upper-left corner location. I'm working on that now, thanks for reporting it. What I'm doing is if the width and height are the same, I'm leaving the window position alone, but if they're different they will respect the positioning environment variables.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 20 Jul 2007 03:25:40 +0000
parents d910939febfa
children 782fd950bd46 c121d94672cb a1b03ba2fcd0
rev   line source
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #ifndef _SDL_QWin_h
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #define _SDL_QWin_h
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
26
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include <stdio.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include <qimage.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <qpixmap.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <qwidget.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <qpainter.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <qdirectpainter_qws.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL_events.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 extern "C" {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1330
diff changeset
38 #include "../../events/SDL_events_c.h"
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 };
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
41 typedef enum {
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
42 SDL_QT_NO_ROTATION = 0,
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
43 SDL_QT_ROTATION_90,
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
44 SDL_QT_ROTATION_270
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
45 } screenRotationT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
46
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
47 extern screenRotationT screenRotation;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
48
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 class SDL_QWin : public QWidget
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 void QueueKey(QKeyEvent *e, int pressed);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 public:
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 SDL_QWin(const QSize& size);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 virtual ~SDL_QWin();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 virtual bool shown(void) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 return isVisible();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 /* If called, the next resize event will not be forwarded to SDL. */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 virtual void inhibitResize(void) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 my_inhibit_resize = true;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 void setImage(QImage *image);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 void setOffset(int x, int y) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 my_offset = QPoint(x, y);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 void GetXYOffset(int &x, int &y) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 x = my_offset.x();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 y = my_offset.y();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 }
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
70 QImage *image(void) { return my_image; }
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 void setWFlags(WFlags flags) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 QWidget::setWFlags(flags);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 my_flags = flags;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 const QPoint& mousePos() const { return my_mouse_pos; }
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
77 void setMousePos(const QPoint& newpos);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 void setFullscreen(bool);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
80 bool lockScreen(bool force=false);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
81 void unlockScreen();
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 void repaintRect(const QRect& rect);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 protected:
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 /* Handle resizing of the window */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 virtual void resizeEvent(QResizeEvent *e);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 void focusInEvent(QFocusEvent *);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 void focusOutEvent(QFocusEvent *);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 void closeEvent(QCloseEvent *e);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 void mouseMoveEvent(QMouseEvent *e);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 void mousePressEvent(QMouseEvent *e);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 void mouseReleaseEvent(QMouseEvent *e);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 void paintEvent(QPaintEvent *ev);
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
93 void keyPressEvent(QKeyEvent *e) { QueueKey(e, 1); }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
94 void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); }
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 private:
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
96 bool repaintRotation0(const QRect& rect);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
97 bool repaintRotation1(const QRect& rect);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
98 bool repaintRotation3(const QRect& rect);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 void enableFullscreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 QDirectPainter *my_painter;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 QImage *my_image;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 bool my_inhibit_resize;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 QPoint my_offset;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 QPoint my_mouse_pos;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 WFlags my_flags;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 WFlags my_has_fullscreen;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 unsigned int my_locked;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 };
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 #endif /* _SDL_QWin_h */