Mercurial > sdl-ios-xcode
annotate src/video/qtopia/SDL_QWin.h @ 1318:f95502c6fc72
Eliminate duplicate modes with different refresh rates
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 01 Feb 2006 09:28:42 +0000 |
parents | c9b51268668f |
children | 450721ad5436 |
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 */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #ifndef _SDL_QWin_h |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #define _SDL_QWin_h |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include <stdio.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include <qimage.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include <qpixmap.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <qwidget.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include <qpainter.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include <qdirectpainter_qws.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include "SDL_events.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 extern "C" { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #include "SDL_events_c.h" |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 }; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
481
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
39 typedef enum { |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
40 SDL_QT_NO_ROTATION = 0, |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
41 SDL_QT_ROTATION_90, |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
42 SDL_QT_ROTATION_270 |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
43 } screenRotationT; |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
44 |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
45 extern screenRotationT screenRotation; |
c96e2137f9eb
Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
379
diff
changeset
|
46 |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 class SDL_QWin : public QWidget |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 void QueueKey(QKeyEvent *e, int pressed); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 public: |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 SDL_QWin(const QSize& size); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 virtual ~SDL_QWin(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 virtual bool shown(void) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 return isVisible(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 /* 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
|
57 virtual void inhibitResize(void) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 my_inhibit_resize = true; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 void setImage(QImage *image); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 void setOffset(int x, int y) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 my_offset = QPoint(x, y); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 void GetXYOffset(int &x, int &y) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 x = my_offset.x(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 y = my_offset.y(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 } |
567 | 68 QImage *image(void) { return my_image; } |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 void setWFlags(WFlags flags) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 QWidget::setWFlags(flags); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 my_flags = flags; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 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
|
75 void setMousePos(const QPoint& newpos); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 void setFullscreen(bool); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
567 | 78 bool lockScreen(bool force=false); |
79 void unlockScreen(); | |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 void repaintRect(const QRect& rect); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 protected: |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 /* Handle resizing of the window */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 virtual void resizeEvent(QResizeEvent *e); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 void focusInEvent(QFocusEvent *); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 void focusOutEvent(QFocusEvent *); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 void closeEvent(QCloseEvent *e); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 void mouseMoveEvent(QMouseEvent *e); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 void mousePressEvent(QMouseEvent *e); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 void mouseReleaseEvent(QMouseEvent *e); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 void paintEvent(QPaintEvent *ev); |
567 | 91 void keyPressEvent(QKeyEvent *e) { QueueKey(e, 1); } |
92 void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); } | |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 private: |
567 | 94 bool repaintRotation0(const QRect& rect); |
95 bool repaintRotation1(const QRect& rect); | |
96 bool repaintRotation3(const QRect& rect); | |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 void enableFullscreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 QDirectPainter *my_painter; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 QImage *my_image; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 bool my_inhibit_resize; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 QPoint my_offset; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 QPoint my_mouse_pos; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 WFlags my_flags; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 WFlags my_has_fullscreen; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 unsigned int my_locked; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 }; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 #endif /* _SDL_QWin_h */ |