comparison src/video/qtopia/SDL_QWin.h @ 371:db0cc6034336

Added David Hedbor's Qtopia patches
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 May 2002 20:06:01 +0000
parents
children 11c8a7684f74
comparison
equal deleted inserted replaced
370:ba72f259bc88 371:db0cc6034336
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22
23 #ifdef SAVE_RCSID
24 static char rcsid =
25 "@(#) $Id$";
26 #endif
27
28 #ifndef _SDL_QWin_h
29 #define _SDL_QWin_h
30 #include <stdio.h>
31
32 #include <qimage.h>
33 #include <qpixmap.h>
34 #include <qwidget.h>
35 #include <qpainter.h>
36 #include <qdirectpainter_qws.h>
37
38 #include "SDL_events.h"
39 //#include "SDL_BView.h"
40
41 extern "C" {
42 #include "SDL_events_c.h"
43 };
44
45 class SDL_QWin : public QWidget
46 {
47 void QueueKey(QKeyEvent *e, int pressed);
48 public:
49 SDL_QWin(const QSize& size);
50 virtual ~SDL_QWin();
51 virtual bool shown(void) {
52 return isVisible();
53 }
54 /* If called, the next resize event will not be forwarded to SDL. */
55 virtual void inhibitResize(void) {
56 my_inhibit_resize = true;
57 }
58 void setImage(QImage *image);
59 void setOffset(int x, int y) {
60 my_offset = QPoint(x, y);
61 }
62 void GetXYOffset(int &x, int &y) {
63 x = my_offset.x();
64 y = my_offset.y();
65 }
66 bool beginDraw(void) {
67 return true;
68 }
69 void endDraw(void) {
70 }
71 QImage *image(void) {
72 return my_image;
73 }
74
75 void setWFlags(WFlags flags) {
76 QWidget::setWFlags(flags);
77 my_flags = flags;
78 }
79 const QPoint& mousePos() const { return my_mouse_pos; }
80 void setMousePos(const QPoint& newpos) { my_mouse_pos = newpos; }
81 void setFullscreen(bool);
82
83 void lockScreen() {
84 if(!my_painter) {
85 my_painter = new QDirectPainter(this);
86 }
87 my_locked++; // Increate lock refcount
88 }
89 void unlockScreen() {
90 if(my_locked > 0) {
91 my_locked--; // decrease lock refcount;
92 }
93 if(!my_locked && my_painter) {
94 my_painter->end();
95 delete my_painter;
96 my_painter = 0;
97 }
98 }
99 void repaintRect(const QRect& rect);
100 protected:
101 /* Handle resizing of the window */
102 virtual void resizeEvent(QResizeEvent *e);
103 void focusInEvent(QFocusEvent *);
104 void focusOutEvent(QFocusEvent *);
105 void closeEvent(QCloseEvent *e);
106 void mouseMoveEvent(QMouseEvent *e);
107 void mousePressEvent(QMouseEvent *e);
108 void mouseReleaseEvent(QMouseEvent *e);
109 void paintEvent(QPaintEvent *ev);
110 void keyPressEvent(QKeyEvent *e) {
111 QueueKey(e, 1);
112 }
113 void keyReleaseEvent(QKeyEvent *e) {
114 QueueKey(e, 0);
115 }
116 private:
117 void enableFullscreen();
118 QDirectPainter *my_painter;
119 QImage *my_image;
120 bool my_inhibit_resize;
121 QPoint my_offset;
122 QPoint my_mouse_pos;
123 WFlags my_flags;
124 WFlags my_has_fullscreen;
125 unsigned int my_locked;
126 };
127
128 #endif /* _SDL_QWin_h */