annotate src/video/bwindow/SDL_BWin.h @ 4012:4e29535b821b SDL-1.2

Fixed bug #360 Fixed fullscreen video modes and improved the mouse grab code.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 07 Jul 2007 19:20:28 +0000
parents 678576473849
children 5804139bdf0b
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
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: 1013
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
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: 1013
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
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: 1013
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
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: 1013
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
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: 1013
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: 1013
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 1
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifndef _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #define _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
1367
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
26 #include "SDL_config.h"
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
27
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <AppKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <InterfaceKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include <be/game/DirectWindow.h>
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
32 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include <be/opengl/GLView.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #endif
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
35 #include <support/UTF8.h>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36
1367
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
37 #include "../../main/beos/SDL_BeApp.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #include "SDL_BView.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 extern "C" {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
42 #include "../../events/SDL_events_c.h"
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
43
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
44 extern int mouse_relative;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 class SDL_BWin : public BDirectWindow
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 public:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 SDL_BWin(BRect bounds) :
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 BDirectWindow(bounds, "Untitled", B_TITLED_WINDOW, 0) {
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
52 last_buttons = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 the_view = NULL;
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
54 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 SDL_GLView = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 SDL_View = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 shown = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 }
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
62
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 virtual ~SDL_BWin() {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
66 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 the_view = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 Unlock();
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
75 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 if ( SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 delete SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 if ( SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 delete SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 }
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
84
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 /* Override the Show() method so we can tell when we've been shown */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 virtual void Show(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 BWindow::Show();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 shown = true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 virtual bool Shown(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 return (shown);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 /* If called, the next resize event will not be forwarded to SDL. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 virtual void InhibitResize(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 inhibit_resize=true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 /* Handle resizing of the window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 virtual void FrameResized(float width, float height) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 if(inhibit_resize)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 SDL_PrivateResize((int)width, (int)height);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 }
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
105 virtual int CreateView(Uint32 flags, Uint32 gl_flags) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 int retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 if ( flags & SDL_OPENGL ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
111 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 if ( SDL_GLView == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 SDL_GLView = new BGLView(Bounds(), "SDL GLView",
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
114 B_FOLLOW_ALL_SIDES, (B_WILL_DRAW|B_FRAME_EVENTS),
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
115 gl_flags);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 if ( the_view != SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 if ( the_view ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 AddChild(SDL_GLView);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 the_view = SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 SDL_SetError("OpenGL support not enabled");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 if ( SDL_View == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 SDL_View = new SDL_BView(Bounds());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 if ( the_view != SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
135 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 AddChild(SDL_View);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 the_view = SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 virtual void SetBitmap(BBitmap *bitmap) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 SDL_View->SetBitmap(bitmap);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 }
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
152 virtual void SetXYOffset(int x, int y) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
153 #if SDL_VIDEO_OPENGL
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
154 if ( the_view == SDL_GLView ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
155 return;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
156 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
157 #endif
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
158 SDL_View->SetXYOffset(x, y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
159 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
160 virtual void GetXYOffset(int &x, int &y) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
161 #if SDL_VIDEO_OPENGL
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
162 if ( the_view == SDL_GLView ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
163 x = 0;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
164 y = 0;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
165 return;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
166 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
167 #endif
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
168 SDL_View->GetXYOffset(x, y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
169 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
170 virtual void GetXYOffset(float &x, float &y) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
171 #if SDL_VIDEO_OPENGL
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
172 if ( the_view == SDL_GLView ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
173 x = 0.0f;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
174 y = 0.0f;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
175 return;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
176 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
177 #endif
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
178 SDL_View->GetXYOffset(x, y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 3878
diff changeset
179 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 virtual bool BeginDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 return(Lock());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 virtual void DrawAsync(BRect updateRect) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 SDL_View->DrawAsync(updateRect);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 virtual void EndDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 SDL_View->Sync();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 }
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
190 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 virtual void SwapBuffers(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 SDL_GLView->SwapBuffers();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 virtual BView *View(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 return(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 /* Hook functions -- overridden */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 virtual void Minimize(bool minimize) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 /* This is only called when mimimized, not when restored */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 //SDL_PrivateAppActive(minimize, SDL_APPACTIVE);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 BWindow::Minimize(minimize);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 virtual void WindowActivated(bool active) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 virtual bool QuitRequested(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 if ( SDL_BeAppActive > 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 SDL_PrivateQuit();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 /* We don't ever actually close the window here because
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 the application should respond to the quit request,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 or ignore it as desired.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 return(false);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 return(true); /* Close the app window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 }
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
221 virtual void Quit() {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
222 if (!IsLocked())
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
223 Lock();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
224 BDirectWindow::Quit();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
225 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
227 virtual int16 Translate2Unicode(const char *buf) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
228 int32 state, srclen, dstlen;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
229 unsigned char destbuf[2];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
230 Uint16 unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
231
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
232 if ((uchar)buf[0] > 127) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
233 state = 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
234 srclen = SDL_strlen(buf);
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
235 dstlen = sizeof(destbuf);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
236 convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
237 unicode = destbuf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
238 unicode <<= 8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
239 unicode |= destbuf[1];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
240 } else
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
241 unicode = buf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
242
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
243 /* For some reason function keys map to control characters */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
244 # define CTRL(X) ((X)-'@')
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
245 switch (unicode) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
246 case CTRL('A'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
247 case CTRL('B'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
248 case CTRL('C'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
249 case CTRL('D'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
250 case CTRL('E'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
251 case CTRL('K'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
252 case CTRL('L'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
253 case CTRL('P'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
254 if ( ! (SDL_GetModState() & KMOD_CTRL) )
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
255 unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
256 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
257 /* Keyboard input maps newline to carriage return */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
258 case '\n':
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
259 unicode = '\r';
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
260 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
261 default:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
262 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
263 }
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
264
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
265 return unicode;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
266 }
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
267
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
268 virtual void DispatchMessage(BMessage *msg, BHandler *target);
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
269
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 private:
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
271 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 BGLView *SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 SDL_BView *SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 BView *the_view;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 bool shown;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 bool inhibit_resize;
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
278 int32 last_buttons;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 #endif /* _SDL_BWin_h */