zenilib: zenilib/jni/external/sdl/src/video/bwindow/SDL_bwindow.cc Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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