Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
223 lines (174 loc) · 6.07 KB

SDL_bwindow.cc

File metadata and controls

223 lines (174 loc) · 6.07 KB
 
1
2
/*
Simple DirectMedia Layer
Dec 31, 2011
Dec 31, 2011
3
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
Oct 31, 2011
Oct 31, 2011
22
23
#if SDL_VIDEO_DRIVER_BWINDOW
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "../SDL_sysvideo.h"
#include "SDL_BWin.h"
#include <new>
/* Define a path to window's BWIN data */
#ifdef __cplusplus
extern "C" {
#endif
static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata));
}
static inline SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app);
}
Aug 22, 2011
Aug 22, 2011
42
static int _InitWindow(_THIS, SDL_Window *window) {
Aug 3, 2011
Aug 3, 2011
43
uint32 flags = 0;
Sep 13, 2012
Sep 13, 2012
44
45
window_look look = B_BORDERED_WINDOW_LOOK;
46
47
48
49
50
51
BRect bounds(
window->x,
window->y,
window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing
window->y + window->h - 1
);
Aug 3, 2011
Aug 3, 2011
52
53
if(window->flags & SDL_WINDOW_FULLSCREEN) {
Aug 22, 2011
Aug 22, 2011
54
55
/* TODO: Add support for this flag */
printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
Aug 3, 2011
Aug 3, 2011
56
57
}
if(window->flags & SDL_WINDOW_OPENGL) {
Aug 22, 2011
Aug 22, 2011
58
/* TODO: Add support for this flag */
Aug 3, 2011
Aug 3, 2011
59
60
}
if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
Aug 17, 2011
Aug 17, 2011
61
flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
Aug 3, 2011
Aug 3, 2011
62
63
}
if(window->flags & SDL_WINDOW_BORDERLESS) {
Sep 13, 2012
Sep 13, 2012
64
look = B_NO_BORDER_WINDOW_LOOK;
Aug 3, 2011
Aug 3, 2011
65
66
}
Sep 13, 2012
Sep 13, 2012
67
SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags);
68
69
if(bwin == NULL)
return ENOMEM;
Jul 25, 2011
Jul 25, 2011
70
71
72
73
window->driverdata = bwin;
int32 winID = _GetBeApp()->GetID(window);
bwin->SetID(winID);
Aug 3, 2011
Aug 3, 2011
74
Jul 25, 2011
Jul 25, 2011
78
int BE_CreateWindow(_THIS, SDL_Window *window) {
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
if(_InitWindow(_this, window) == ENOMEM)
return ENOMEM;
/* Start window loop */
_ToBeWin(window)->Show();
return 0;
}
int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) {
SDL_BWin *otherBWin = (SDL_BWin*)data;
if(!otherBWin->LockLooper())
return -1;
/* Create the new window and initialize its members */
window->x = (int)otherBWin->Frame().left;
window->y = (int)otherBWin->Frame().top;
window->w = (int)otherBWin->Frame().Width();
window->h = (int)otherBWin->Frame().Height();
Aug 3, 2011
Aug 3, 2011
99
100
101
102
103
/* Set SDL flags */
if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) {
window->flags |= SDL_WINDOW_RESIZABLE;
}
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* If we are out of memory, return the error code */
if(_InitWindow(_this, window) == ENOMEM)
return ENOMEM;
/* TODO: Add any other SDL-supported window attributes here */
_ToBeWin(window)->SetTitle(otherBWin->Title());
/* Start window loop and unlock the other window */
_ToBeWin(window)->Show();
otherBWin->UnlockLooper();
return 0;
}
void BE_SetWindowTitle(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SET_TITLE);
msg.AddString("window-title", window->title);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) {
/* FIXME: Icons not supported by BeOs/Haiku */
}
void BE_SetWindowPosition(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MOVE_WINDOW);
msg.AddInt32("window-x", window->x);
msg.AddInt32("window-y", window->y);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_SetWindowSize(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESIZE_WINDOW);
msg.AddInt32("window-w", window->w - 1);
msg.AddInt32("window-h", window->h - 1);
_ToBeWin(window)->PostMessage(&msg);
}
Sep 13, 2012
Sep 13, 2012
142
143
144
145
146
147
void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
BMessage msg(BWIN_SET_BORDERED);
msg.AddBool("window-border", bordered != SDL_FALSE);
_ToBeWin(window)->PostMessage(&msg);
}
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
void BE_ShowWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_HideWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_HIDE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_RaiseWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */
_ToBeWin(window)->PostMessage(&msg);
}
void BE_MaximizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MAXIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_MinimizeWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_MINIMIZE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_RestoreWindow(_THIS, SDL_Window * window) {
BMessage msg(BWIN_RESTORE_WINDOW);
_ToBeWin(window)->PostMessage(&msg);
}
void BE_SetWindowFullscreen(_THIS, SDL_Window * window,
SDL_VideoDisplay * display, SDL_bool fullscreen) {
/* Haiku tracks all video display information */
BMessage msg(BWIN_FULLSCREEN);
msg.AddBool("fullscreen", fullscreen);
_ToBeWin(window)->PostMessage(&msg);
}
int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */
Aug 22, 2011
Aug 22, 2011
189
return -1;
190
191
192
193
}
int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not BeOs/Haiku supported */
Aug 22, 2011
Aug 22, 2011
194
return -1;
Nov 7, 2012
Nov 7, 2012
198
void BE_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) {
199
200
201
202
203
204
205
206
207
208
209
210
211
/* TODO: Implement this! */
}
void BE_DestroyWindow(_THIS, SDL_Window * window) {
_ToBeWin(window)->LockLooper(); /* This MUST be locked */
_GetBeApp()->ClearID(_ToBeWin(window));
_ToBeWin(window)->Quit();
window->driverdata = NULL;
}
SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info) {
/* FIXME: What is the point of this? What information should be included? */
Aug 22, 2011
Aug 22, 2011
212
return SDL_FALSE;
Jul 20, 2011
Jul 20, 2011
216
217
218
219
220
221
222
#ifdef __cplusplus
}
#endif
Oct 31, 2011
Oct 31, 2011
223
#endif /* SDL_VIDEO_DRIVER_BWINDOW */