annotate src/video/qtopia/SDL_QWin.h @ 1383:1736c5e2173f

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