SDL  2.0
SDL_BWin Class Reference

#include <SDL_BWin.h>

+ Inheritance diagram for SDL_BWin:
+ Collaboration diagram for SDL_BWin:

Public Member Functions

 SDL_BWin (BRect bounds, window_look look, uint32 flags)
 
virtual ~SDL_BWin ()
 
virtual BGLView * CreateGLView (Uint32 gl_flags)
 
virtual void RemoveGLView ()
 
virtual void SwapBuffers (void)
 
virtual void DirectConnected (direct_buffer_info *info)
 
virtual void FrameMoved (BPoint origin)
 
virtual void FrameResized (float width, float height)
 
virtual bool QuitRequested ()
 
virtual void WindowActivated (bool active)
 
virtual void Zoom (BPoint origin, float width, float height)
 
virtual void Show ()
 
virtual void Hide ()
 
virtual void Minimize (bool minimize)
 
virtual void DispatchMessage (BMessage *msg, BHandler *target)
 
virtual void MessageReceived (BMessage *message)
 
bool IsShown ()
 
int32 GetID ()
 
uint32 GetRowBytes ()
 
int32 GetFbX ()
 
int32 GetFbY ()
 
bool ConnectionEnabled ()
 
bool Connected ()
 
clipping_rect * GetClips ()
 
int32 GetNumClips ()
 
uint8 * GetBufferPx ()
 
int32 GetBytesPerPx ()
 
bool CanTrashWindowBuffer ()
 
bool BufferExists ()
 
bool BufferIsDirty ()
 
BBitmap * GetBitmap ()
 
BGLView * GetGLView ()
 
void SetID (int32 id)
 
void SetBufferExists (bool bufferExists)
 
void LockBuffer ()
 
void UnlockBuffer ()
 
void SetBufferDirty (bool bufferDirty)
 
void SetTrashBuffer (bool trash)
 
void SetBitmap (BBitmap *bitmap)
 

Private Member Functions

void _MouseMotionEvent (BPoint &where, int32 transit)
 
void _MouseFocusEvent (bool focusGained)
 
void _MouseButtonEvent (int32 buttons)
 
void _SendMouseButton (int32 button, int32 state)
 
void _MouseWheelEvent (int32 x, int32 y)
 
void _KeyEvent (int32 keyCode, int32 keyState)
 
void _RepaintEvent ()
 
void _PostWindowEvent (BMessage &msg)
 
void _SetTitle (BMessage *msg)
 
void _MoveTo (BMessage *msg)
 
void _ResizeTo (BMessage *msg)
 
void _SetBordered (BMessage *msg)
 
void _Restore ()
 
void _SetFullScreen (BMessage *msg)
 

Private Attributes

BGLView * _SDL_GLView
 
int32 _last_buttons
 
int32 _id
 
bool _mouse_focused
 
bool _shown
 
bool _inhibit_resize
 
BRect * _prev_frame
 
bool _connected
 
bool _connection_disabled
 
bool _buffer_created
 
bool _buffer_dirty
 
bool _trash_window_buffer
 
uint8 * _bits
 
uint32 _row_bytes
 
clipping_rect _bounds
 
BLocker * _buffer_locker
 
clipping_rect * _clips
 
int32 _num_clips
 
int32 _bytes_per_px
 
thread_id _draw_thread_id
 
BBitmap * _bitmap
 

Detailed Description

Definition at line 63 of file SDL_BWin.h.

Constructor & Destructor Documentation

SDL_BWin::SDL_BWin ( BRect  bounds,
window_look  look,
uint32  flags 
)
inline

Definition at line 67 of file SDL_BWin.h.

References _bitmap, _buffer_created, _buffer_dirty, _buffer_locker, _clips, _connected, _connection_disabled, _draw_thread_id, _inhibit_resize, _last_buttons, _mouse_focused, _prev_frame, _SDL_GLView, _shown, _trash_window_buffer, BE_DrawThread(), and NULL.

68  : BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
69  {
70  _last_buttons = 0;
71 
72 #if SDL_VIDEO_OPENGL
73  _SDL_GLView = NULL;
74 #endif
75  _shown = false;
76  _inhibit_resize = false;
77  _mouse_focused = false;
78  _prev_frame = NULL;
79 
80  /* Handle framebuffer stuff */
83  _trash_window_buffer = false;
84  _buffer_locker = new BLocker();
85  _bitmap = NULL;
86  _clips = NULL;
87 
88 #ifdef DRAWTHREAD
89  _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
90  B_NORMAL_PRIORITY, (void*) this);
91  resume_thread(_draw_thread_id);
92 #endif
93  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
int32 _last_buttons
Definition: SDL_BWin.h:597
bool _connected
Definition: SDL_BWin.h:606
bool _buffer_dirty
Definition: SDL_BWin.h:606
bool _connection_disabled
Definition: SDL_BWin.h:606
bool _shown
Definition: SDL_BWin.h:600
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
bool _inhibit_resize
Definition: SDL_BWin.h:601
bool _mouse_focused
Definition: SDL_BWin.h:599
clipping_rect * _clips
Definition: SDL_BWin.h:615
BRect * _prev_frame
Definition: SDL_BWin.h:603
#define NULL
Definition: begin_code.h:143
bool _trash_window_buffer
Definition: SDL_BWin.h:606
bool _buffer_created
Definition: SDL_BWin.h:606
BBitmap * _bitmap
Definition: SDL_BWin.h:620
GLbitfield flags
thread_id _draw_thread_id
Definition: SDL_BWin.h:618
int32 BE_DrawThread(void *data)
virtual SDL_BWin::~SDL_BWin ( )
inlinevirtual

Definition at line 95 of file SDL_BWin.h.

References _buffer_locker, _clips, _connection_disabled, _draw_thread_id, _SDL_GLView, and free.

96  {
97  Lock();
98  _connection_disabled = true;
99  int32 result;
100 
101 #if SDL_VIDEO_OPENGL
102  if (_SDL_GLView) {
103  _SDL_GLView->UnlockGL();
104  RemoveChild(_SDL_GLView); /* Why was this outside the if
105  statement before? */
106  }
107 
108 #endif
109  Unlock();
110 #if SDL_VIDEO_OPENGL
111  if (_SDL_GLView) {
112  delete _SDL_GLView;
113  }
114 #endif
115 
116  /* Clean up framebuffer stuff */
117  _buffer_locker->Lock();
118 #ifdef DRAWTHREAD
119  wait_for_thread(_draw_thread_id, &result);
120 #endif
121  free(_clips);
122  delete _buffer_locker;
123  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
GLuint64EXT * result
bool _connection_disabled
Definition: SDL_BWin.h:606
SDL_EventEntry * free
Definition: SDL_events.c:81
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
clipping_rect * _clips
Definition: SDL_BWin.h:615
thread_id _draw_thread_id
Definition: SDL_BWin.h:618

Member Function Documentation

void SDL_BWin::_KeyEvent ( int32  keyCode,
int32  keyState 
)
inlineprivate

Definition at line 511 of file SDL_BWin.h.

References BAPP_KEY.

Referenced by DispatchMessage().

511  {
512  /* Create a message to pass along to the BeApp thread */
513  BMessage msg(BAPP_KEY);
514  msg.AddInt32("key-state", keyState);
515  msg.AddInt32("key-scancode", keyCode);
516  be_app->PostMessage(&msg);
517  /* Apparently SDL only uses the scancode */
518  }
void SDL_BWin::_MouseButtonEvent ( int32  buttons)
inlineprivate

Definition at line 471 of file SDL_BWin.h.

References _last_buttons, _SendMouseButton(), SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, and SDL_BUTTON_RIGHT.

Referenced by DispatchMessage().

471  {
472  int32 buttonStateChange = buttons ^ _last_buttons;
473 
474  /* Make sure at least one button has changed state */
475  if( !(buttonStateChange) ) {
476  return;
477  }
478 
479  /* Add any mouse button events */
480  if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
482  B_PRIMARY_MOUSE_BUTTON);
483  }
484  if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
486  B_PRIMARY_MOUSE_BUTTON);
487  }
488  if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
490  B_PRIMARY_MOUSE_BUTTON);
491  }
492 
493  _last_buttons = buttons;
494  }
int32 _last_buttons
Definition: SDL_BWin.h:597
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:282
void _SendMouseButton(int32 button, int32 state)
Definition: SDL_BWin.h:496
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:280
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:281
void SDL_BWin::_MouseFocusEvent ( bool  focusGained)
inlineprivate

Definition at line 460 of file SDL_BWin.h.

References _mouse_focused, _PostWindowEvent(), and BAPP_MOUSE_FOCUS.

Referenced by _MouseMotionEvent().

460  {
461  _mouse_focused = focusGained;
462  BMessage msg(BAPP_MOUSE_FOCUS);
463  msg.AddBool("focusGained", focusGained);
464  _PostWindowEvent(msg);
465 
466 /* FIXME: Why were these here?
467  if false: be_app->SetCursor(B_HAND_CURSOR);
468  if true: SDL_SetCursor(NULL); */
469  }
bool _mouse_focused
Definition: SDL_BWin.h:599
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
void SDL_BWin::_MouseMotionEvent ( BPoint &  where,
int32  transit 
)
inlineprivate

Definition at line 441 of file SDL_BWin.h.

References _mouse_focused, _MouseFocusEvent(), _PostWindowEvent(), and BAPP_MOUSE_MOVED.

Referenced by DispatchMessage().

441  {
442  if(transit == B_EXITED_VIEW) {
443  /* Change mouse focus */
444  if(_mouse_focused) {
445  _MouseFocusEvent(false);
446  }
447  } else {
448  /* Change mouse focus */
449  if (!_mouse_focused) {
450  _MouseFocusEvent(true);
451  }
452  BMessage msg(BAPP_MOUSE_MOVED);
453  msg.AddInt32("x", (int)where.x);
454  msg.AddInt32("y", (int)where.y);
455 
456  _PostWindowEvent(msg);
457  }
458  }
bool _mouse_focused
Definition: SDL_BWin.h:599
void _MouseFocusEvent(bool focusGained)
Definition: SDL_BWin.h:460
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
void SDL_BWin::_MouseWheelEvent ( int32  x,
int32  y 
)
inlineprivate

Definition at line 503 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_WHEEL.

Referenced by DispatchMessage().

503  {
504  /* Create a message to pass along to the BeApp thread */
505  BMessage msg(BAPP_MOUSE_WHEEL);
506  msg.AddInt32("xticks", x);
507  msg.AddInt32("yticks", y);
508  _PostWindowEvent(msg);
509  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void SDL_BWin::_MoveTo ( BMessage *  msg)
inlineprivate

Definition at line 541 of file SDL_BWin.h.

Referenced by MessageReceived().

541  {
542  int32 x, y;
543  if(
544  msg->FindInt32("window-x", &x) != B_OK ||
545  msg->FindInt32("window-y", &y) != B_OK
546  ) {
547  return;
548  }
549  MoveTo(x, y);
550  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void SDL_BWin::_PostWindowEvent ( BMessage &  msg)
inlineprivate

Definition at line 525 of file SDL_BWin.h.

References _id.

Referenced by _MouseFocusEvent(), _MouseMotionEvent(), _MouseWheelEvent(), _RepaintEvent(), _SendMouseButton(), FrameMoved(), FrameResized(), Hide(), Minimize(), QuitRequested(), Show(), WindowActivated(), and Zoom().

525  {
526  msg.AddInt32("window-id", _id);
527  be_app->PostMessage(&msg);
528  }
int32 _id
Definition: SDL_BWin.h:598
void SDL_BWin::_RepaintEvent ( )
inlineprivate

Definition at line 520 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_REPAINT.

520  {
521  /* Force a repaint: Call the SDL exposed event */
522  BMessage msg(BAPP_REPAINT);
523  _PostWindowEvent(msg);
524  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
void SDL_BWin::_ResizeTo ( BMessage *  msg)
inlineprivate

Definition at line 552 of file SDL_BWin.h.

Referenced by MessageReceived().

552  {
553  int32 w, h;
554  if(
555  msg->FindInt32("window-w", &w) != B_OK ||
556  msg->FindInt32("window-h", &h) != B_OK
557  ) {
558  return;
559  }
560  ResizeTo(w, h);
561  }
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
void SDL_BWin::_Restore ( )
inlineprivate

Definition at line 571 of file SDL_BWin.h.

References _prev_frame, Minimize(), NULL, and Show().

Referenced by MessageReceived().

571  {
572  if(IsMinimized()) {
573  Minimize(false);
574  } else if(IsHidden()) {
575  Show();
576  } else if(_prev_frame != NULL) { /* Zoomed */
577  MoveTo(_prev_frame->left, _prev_frame->top);
578  ResizeTo(_prev_frame->Width(), _prev_frame->Height());
579  }
580  }
virtual void Show()
Definition: SDL_BWin.h:270
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:288
BRect * _prev_frame
Definition: SDL_BWin.h:603
#define NULL
Definition: begin_code.h:143
void SDL_BWin::_SendMouseButton ( int32  button,
int32  state 
)
inlineprivate

Definition at line 496 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_BUTTON.

Referenced by _MouseButtonEvent().

496  {
497  BMessage msg(BAPP_MOUSE_BUTTON);
498  msg.AddInt32("button-id", button);
499  msg.AddInt32("button-state", state);
500  _PostWindowEvent(msg);
501  }
SDL_Texture * button
struct xkb_state * state
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
void SDL_BWin::_SetBordered ( BMessage *  msg)
inlineprivate

Definition at line 563 of file SDL_BWin.h.

Referenced by MessageReceived().

563  {
564  bool bEnabled;
565  if(msg->FindBool("window-border", &bEnabled) != B_OK) {
566  return;
567  }
568  SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
569  }
void SDL_BWin::_SetFullScreen ( BMessage *  msg)
inlineprivate

Definition at line 582 of file SDL_BWin.h.

Referenced by MessageReceived().

582  {
583  bool fullscreen;
584  if(
585  msg->FindBool("fullscreen", &fullscreen) != B_OK
586  ) {
587  return;
588  }
589  SetFullScreen(fullscreen);
590  }
void SDL_BWin::_SetTitle ( BMessage *  msg)
inlineprivate

Definition at line 531 of file SDL_BWin.h.

Referenced by MessageReceived().

531  {
532  const char *title;
533  if(
534  msg->FindString("window-title", &title) != B_OK
535  ) {
536  return;
537  }
538  SetTitle(title);
539  }
bool SDL_BWin::BufferExists ( )
inline

Definition at line 422 of file SDL_BWin.h.

References _buffer_created.

422 { return _buffer_created; }
bool _buffer_created
Definition: SDL_BWin.h:606
bool SDL_BWin::BufferIsDirty ( )
inline

Definition at line 423 of file SDL_BWin.h.

References _buffer_dirty.

423 { return _buffer_dirty; }
bool _buffer_dirty
Definition: SDL_BWin.h:606
bool SDL_BWin::CanTrashWindowBuffer ( )
inline

Definition at line 421 of file SDL_BWin.h.

References _trash_window_buffer.

421 { return _trash_window_buffer; }
bool _trash_window_buffer
Definition: SDL_BWin.h:606
bool SDL_BWin::Connected ( )
inline

Definition at line 416 of file SDL_BWin.h.

References _connected.

416 { return _connected; }
bool _connected
Definition: SDL_BWin.h:606
bool SDL_BWin::ConnectionEnabled ( )
inline

Definition at line 415 of file SDL_BWin.h.

References _connection_disabled.

415 { return !_connection_disabled; }
bool _connection_disabled
Definition: SDL_BWin.h:606
virtual BGLView* SDL_BWin::CreateGLView ( Uint32  gl_flags)
inlinevirtual

Definition at line 128 of file SDL_BWin.h.

References _SDL_GLView, and NULL.

128  {
129  Lock();
130  if (_SDL_GLView == NULL) {
131  _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
132  B_FOLLOW_ALL_SIDES,
133  (B_WILL_DRAW | B_FRAME_EVENTS),
134  gl_flags);
135  }
136  AddChild(_SDL_GLView);
137  _SDL_GLView->EnableDirectMode(true);
138  _SDL_GLView->LockGL(); /* "New" GLViews are created */
139  Unlock();
140  return (_SDL_GLView);
141  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
#define NULL
Definition: begin_code.h:143
virtual void SDL_BWin::DirectConnected ( direct_buffer_info *  info)
inlinevirtual

Definition at line 160 of file SDL_BWin.h.

References _bits, _bounds, _buffer_dirty, _bytes_per_px, _clips, _connected, _connection_disabled, _num_clips, _row_bytes, _SDL_GLView, _trash_window_buffer, free, LockBuffer(), malloc, memcpy, NULL, and UnlockBuffer().

160  {
162  return;
163  }
164 
165  /* Determine if the pixel buffer is usable after this update */
167  || ((info->buffer_state & B_BUFFER_RESIZED)
168  || (info->buffer_state & B_BUFFER_RESET)
169  || (info->driver_state == B_MODE_CHANGED));
170  LockBuffer();
171 
172  switch(info->buffer_state & B_DIRECT_MODE_MASK) {
173  case B_DIRECT_START:
174  _connected = true;
175 
176  case B_DIRECT_MODIFY:
177  if(_clips) {
178  free(_clips);
179  _clips = NULL;
180  }
181 
182  _num_clips = info->clip_list_count;
183  _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
184  if(_clips) {
185  memcpy(_clips, info->clip_list,
186  _num_clips*sizeof(clipping_rect));
187 
188  _bits = (uint8*) info->bits;
189  _row_bytes = info->bytes_per_row;
190  _bounds = info->window_bounds;
191  _bytes_per_px = info->bits_per_pixel / 8;
192  _buffer_dirty = true;
193  }
194  break;
195 
196  case B_DIRECT_STOP:
197  _connected = false;
198  break;
199  }
200 #if SDL_VIDEO_OPENGL
201  if(_SDL_GLView) {
202  _SDL_GLView->DirectConnected(info);
203  }
204 #endif
205 
206 
207  /* Call the base object directconnected */
208  BDirectWindow::DirectConnected(info);
209 
210  UnlockBuffer();
211 
212  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
void UnlockBuffer()
Definition: SDL_BWin.h:433
bool _connected
Definition: SDL_BWin.h:606
bool _buffer_dirty
Definition: SDL_BWin.h:606
bool _connection_disabled
Definition: SDL_BWin.h:606
uint8 * _bits
Definition: SDL_BWin.h:611
SDL_EventEntry * free
Definition: SDL_events.c:81
int32 _bytes_per_px
Definition: SDL_BWin.h:617
void LockBuffer()
Definition: SDL_BWin.h:432
int32 _num_clips
Definition: SDL_BWin.h:616
clipping_rect * _clips
Definition: SDL_BWin.h:615
clipping_rect _bounds
Definition: SDL_BWin.h:613
#define NULL
Definition: begin_code.h:143
#define malloc
Definition: SDL_malloc.c:641
bool _trash_window_buffer
Definition: SDL_BWin.h:606
#define memcpy
Definition: SDL_malloc.c:640
uint32 _row_bytes
Definition: SDL_BWin.h:612
virtual void SDL_BWin::DispatchMessage ( BMessage *  msg,
BHandler *  target 
)
inlinevirtual

Definition at line 298 of file SDL_BWin.h.

References _KeyEvent(), _MouseButtonEvent(), _MouseMotionEvent(), _MouseWheelEvent(), SDL_PRESSED, and SDL_RELEASED.

299  {
300  BPoint where; /* Used by mouse moved */
301  int32 buttons; /* Used for mouse button events */
302  int32 key; /* Used for key events */
303 
304  switch (msg->what) {
305  case B_MOUSE_MOVED:
306  int32 transit;
307  if (msg->FindPoint("where", &where) == B_OK
308  && msg->FindInt32("be:transit", &transit) == B_OK) {
309  _MouseMotionEvent(where, transit);
310  }
311 
312  /* FIXME: Apparently a button press/release event might be dropped
313  if made before before a different button is released. Does
314  B_MOUSE_MOVED have the data needed to check if a mouse button
315  state has changed? */
316  if (msg->FindInt32("buttons", &buttons) == B_OK) {
317  _MouseButtonEvent(buttons);
318  }
319  break;
320 
321  case B_MOUSE_DOWN:
322  case B_MOUSE_UP:
323  /* _MouseButtonEvent() detects any and all buttons that may have
324  changed state, as well as that button's new state */
325  if (msg->FindInt32("buttons", &buttons) == B_OK) {
326  _MouseButtonEvent(buttons);
327  }
328  break;
329 
330  case B_MOUSE_WHEEL_CHANGED:
331  float x, y;
332  if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
333  && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
334  _MouseWheelEvent((int)x, (int)y);
335  }
336  break;
337 
338  case B_KEY_DOWN:
339  case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
340  if (msg->FindInt32("key", &key) == B_OK) {
342  }
343  break;
344 
345  case B_KEY_UP:
346  case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
347  if (msg->FindInt32("key", &key) == B_OK) {
348  _KeyEvent(key, SDL_RELEASED);
349  }
350  break;
351 
352  default:
353  /* move it after switch{} so it's always handled
354  that way we keep Haiku features like:
355  - CTRL+Q to close window (and other shortcuts)
356  - PrintScreen to make screenshot into /boot/home
357  - etc.. */
358  /* BDirectWindow::DispatchMessage(msg, target); */
359  break;
360  }
361 
362  BDirectWindow::DispatchMessage(msg, target);
363  }
void _KeyEvent(int32 keyCode, int32 keyState)
Definition: SDL_BWin.h:511
void _MouseButtonEvent(int32 buttons)
Definition: SDL_BWin.h:471
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
void _MouseMotionEvent(BPoint &where, int32 transit)
Definition: SDL_BWin.h:441
#define SDL_PRESSED
Definition: SDL_events.h:50
#define SDL_RELEASED
Definition: SDL_events.h:49
GLenum target
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
void _MouseWheelEvent(int32 x, int32 y)
Definition: SDL_BWin.h:503
virtual void SDL_BWin::FrameMoved ( BPoint  origin)
inlinevirtual

Definition at line 219 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_MOVED.

219  {
220  /* Post a message to the BApp so that it can handle the window event */
221  BMessage msg(BAPP_WINDOW_MOVED);
222  msg.AddInt32("window-x", (int)origin.x);
223  msg.AddInt32("window-y", (int)origin.y);
224  _PostWindowEvent(msg);
225 
226  /* Perform normal hook operations */
227  BDirectWindow::FrameMoved(origin);
228  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
virtual void SDL_BWin::FrameResized ( float  width,
float  height 
)
inlinevirtual

Definition at line 230 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_RESIZED.

230  {
231  /* Post a message to the BApp so that it can handle the window event */
232  BMessage msg(BAPP_WINDOW_RESIZED);
233 
234  msg.AddInt32("window-w", (int)width + 1);
235  msg.AddInt32("window-h", (int)height + 1);
236  _PostWindowEvent(msg);
237 
238  /* Perform normal hook operations */
239  BDirectWindow::FrameResized(width, height);
240  }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
BBitmap* SDL_BWin::GetBitmap ( )
inline

Definition at line 424 of file SDL_BWin.h.

References _bitmap.

424 { return _bitmap; }
BBitmap * _bitmap
Definition: SDL_BWin.h:620
uint8* SDL_BWin::GetBufferPx ( )
inline

Definition at line 419 of file SDL_BWin.h.

References _bits.

419 { return _bits; }
uint8 * _bits
Definition: SDL_BWin.h:611
int32 SDL_BWin::GetBytesPerPx ( )
inline

Definition at line 420 of file SDL_BWin.h.

References _bytes_per_px.

420 { return _bytes_per_px; }
int32 _bytes_per_px
Definition: SDL_BWin.h:617
clipping_rect* SDL_BWin::GetClips ( )
inline

Definition at line 417 of file SDL_BWin.h.

References _clips.

417 { return _clips; }
clipping_rect * _clips
Definition: SDL_BWin.h:615
int32 SDL_BWin::GetFbX ( )
inline

Definition at line 413 of file SDL_BWin.h.

References _bounds.

413 { return _bounds.left; }
clipping_rect _bounds
Definition: SDL_BWin.h:613
int32 SDL_BWin::GetFbY ( )
inline

Definition at line 414 of file SDL_BWin.h.

References _bounds.

414 { return _bounds.top; }
clipping_rect _bounds
Definition: SDL_BWin.h:613
BGLView* SDL_BWin::GetGLView ( )
inline

Definition at line 426 of file SDL_BWin.h.

References _SDL_GLView.

426 { return _SDL_GLView; }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
int32 SDL_BWin::GetID ( )
inline

Definition at line 411 of file SDL_BWin.h.

References _id.

411 { return _id; }
int32 _id
Definition: SDL_BWin.h:598
int32 SDL_BWin::GetNumClips ( )
inline

Definition at line 418 of file SDL_BWin.h.

References _num_clips.

418 { return _num_clips; }
int32 _num_clips
Definition: SDL_BWin.h:616
uint32 SDL_BWin::GetRowBytes ( )
inline

Definition at line 412 of file SDL_BWin.h.

References _row_bytes.

412 { return _row_bytes; }
uint32 _row_bytes
Definition: SDL_BWin.h:612
virtual void SDL_BWin::Hide ( )
inlinevirtual

Definition at line 280 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_HIDE.

Referenced by MessageReceived().

280  {
281  BDirectWindow::Hide();
282  _shown = false;
283 
284  BMessage msg(BAPP_HIDE);
285  _PostWindowEvent(msg);
286  }
bool _shown
Definition: SDL_BWin.h:600
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
bool SDL_BWin::IsShown ( )
inline

Definition at line 410 of file SDL_BWin.h.

References _shown.

410 { return _shown; }
bool _shown
Definition: SDL_BWin.h:600
void SDL_BWin::LockBuffer ( )
inline

Definition at line 432 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

432 { _buffer_locker->Lock(); }
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
virtual void SDL_BWin::MessageReceived ( BMessage *  message)
inlinevirtual

Definition at line 366 of file SDL_BWin.h.

References _MoveTo(), _ResizeTo(), _Restore(), _SetBordered(), _SetFullScreen(), _SetTitle(), BWIN_FULLSCREEN, BWIN_HIDE_WINDOW, BWIN_MAXIMIZE_WINDOW, BWIN_MINIMIZE_WINDOW, BWIN_MOVE_WINDOW, BWIN_RESIZE_WINDOW, BWIN_RESTORE_WINDOW, BWIN_SET_BORDERED, BWIN_SET_TITLE, BWIN_SHOW_WINDOW, Hide(), Minimize(), and Show().

366  {
367  switch (message->what) {
368  /* Handle commands from SDL */
369  case BWIN_SET_TITLE:
371  break;
372  case BWIN_MOVE_WINDOW:
373  _MoveTo(message);
374  break;
375  case BWIN_RESIZE_WINDOW:
377  break;
378  case BWIN_SET_BORDERED:
380  break;
381  case BWIN_SHOW_WINDOW:
382  Show();
383  break;
384  case BWIN_HIDE_WINDOW:
385  Hide();
386  break;
388  BWindow::Zoom();
389  break;
391  Minimize(true);
392  break;
393  case BWIN_RESTORE_WINDOW:
394  _Restore();
395  break;
396  case BWIN_FULLSCREEN:
398  break;
399  default:
400  /* Perform normal message handling */
401  BDirectWindow::MessageReceived(message);
402  break;
403  }
404 
405  }
virtual void Show()
Definition: SDL_BWin.h:270
void _ResizeTo(BMessage *msg)
Definition: SDL_BWin.h:552
GLuint GLsizei const GLchar * message
virtual void Hide()
Definition: SDL_BWin.h:280
void _SetFullScreen(BMessage *msg)
Definition: SDL_BWin.h:582
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:288
void _MoveTo(BMessage *msg)
Definition: SDL_BWin.h:541
void _SetTitle(BMessage *msg)
Definition: SDL_BWin.h:531
void _SetBordered(BMessage *msg)
Definition: SDL_BWin.h:563
void _Restore()
Definition: SDL_BWin.h:571
virtual void SDL_BWin::Minimize ( bool  minimize)
inlinevirtual

Definition at line 288 of file SDL_BWin.h.

References _PostWindowEvent(), BAPP_MINIMIZE, and BAPP_RESTORE.

Referenced by _Restore(), and MessageReceived().

288  {
289  BDirectWindow::Minimize(minimize);
290  int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
291 
292  BMessage msg(minState);
293  _PostWindowEvent(msg);
294  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
virtual bool SDL_BWin::QuitRequested ( )
inlinevirtual

Definition at line 242 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_CLOSE_REQUESTED.

242  {
243  BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
244  _PostWindowEvent(msg);
245 
246  /* We won't allow a quit unless asked by DestroyWindow() */
247  return false;
248  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
virtual void SDL_BWin::RemoveGLView ( )
inlinevirtual

Definition at line 143 of file SDL_BWin.h.

References _SDL_GLView.

143  {
144  Lock();
145  if(_SDL_GLView) {
146  _SDL_GLView->UnlockGL();
147  RemoveChild(_SDL_GLView);
148  }
149  Unlock();
150  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
void SDL_BWin::SetBitmap ( BBitmap *  bitmap)
inline

Definition at line 436 of file SDL_BWin.h.

References _bitmap.

436 { _bitmap = bitmap; }
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:620
void SDL_BWin::SetBufferDirty ( bool  bufferDirty)
inline

Definition at line 434 of file SDL_BWin.h.

References _buffer_dirty.

434 { _buffer_dirty = bufferDirty; }
bool _buffer_dirty
Definition: SDL_BWin.h:606
void SDL_BWin::SetBufferExists ( bool  bufferExists)
inline

Definition at line 431 of file SDL_BWin.h.

References _buffer_created.

431 { _buffer_created = bufferExists; }
bool _buffer_created
Definition: SDL_BWin.h:606
void SDL_BWin::SetID ( int32  id)
inline

Definition at line 430 of file SDL_BWin.h.

References _id.

430 { _id = id; }
GLuint id
int32 _id
Definition: SDL_BWin.h:598
void SDL_BWin::SetTrashBuffer ( bool  trash)
inline

Definition at line 435 of file SDL_BWin.h.

References _trash_window_buffer.

435 { _trash_window_buffer = trash; }
bool _trash_window_buffer
Definition: SDL_BWin.h:606
virtual void SDL_BWin::Show ( )
inlinevirtual

Definition at line 270 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_SHOW.

Referenced by _Restore(), and MessageReceived().

270  {
271  while(IsHidden()) {
272  BDirectWindow::Show();
273  }
274  _shown = true;
275 
276  BMessage msg(BAPP_SHOW);
277  _PostWindowEvent(msg);
278  }
bool _shown
Definition: SDL_BWin.h:600
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
virtual void SDL_BWin::SwapBuffers ( void  )
inlinevirtual

Definition at line 152 of file SDL_BWin.h.

References _SDL_GLView.

152  {
153  _SDL_GLView->UnlockGL();
154  _SDL_GLView->LockGL();
155  _SDL_GLView->SwapBuffers();
156  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
void SDL_BWin::UnlockBuffer ( )
inline

Definition at line 433 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

433 { _buffer_locker->Unlock(); }
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
virtual void SDL_BWin::WindowActivated ( bool  active)
inlinevirtual

Definition at line 250 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_KEYBOARD_FOCUS.

250  {
251  BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
252  _PostWindowEvent(msg);
253  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
virtual void SDL_BWin::Zoom ( BPoint  origin,
float  width,
float  height 
)
inlinevirtual

Definition at line 255 of file SDL_BWin.h.

References _PostWindowEvent(), _prev_frame, and BAPP_MAXIMIZE.

257  {
258  BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
259  _PostWindowEvent(msg);
260 
261  /* Before the window zooms, record its size */
262  if( !_prev_frame )
263  _prev_frame = new BRect(Frame());
264 
265  /* Perform normal hook operations */
266  BDirectWindow::Zoom(origin, width, height);
267  }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
BRect * _prev_frame
Definition: SDL_BWin.h:603
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

Field Documentation

BBitmap* SDL_BWin::_bitmap
private

Definition at line 620 of file SDL_BWin.h.

Referenced by GetBitmap(), SDL_BWin(), and SetBitmap().

uint8* SDL_BWin::_bits
private

Definition at line 611 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBufferPx().

clipping_rect SDL_BWin::_bounds
private

Definition at line 613 of file SDL_BWin.h.

Referenced by DirectConnected(), GetFbX(), and GetFbY().

bool SDL_BWin::_buffer_created
private

Definition at line 606 of file SDL_BWin.h.

Referenced by BufferExists(), SDL_BWin(), and SetBufferExists().

bool SDL_BWin::_buffer_dirty
private

Definition at line 606 of file SDL_BWin.h.

Referenced by BufferIsDirty(), DirectConnected(), SDL_BWin(), and SetBufferDirty().

BLocker* SDL_BWin::_buffer_locker
private

Definition at line 614 of file SDL_BWin.h.

Referenced by LockBuffer(), SDL_BWin(), UnlockBuffer(), and ~SDL_BWin().

int32 SDL_BWin::_bytes_per_px
private

Definition at line 617 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBytesPerPx().

clipping_rect* SDL_BWin::_clips
private

Definition at line 615 of file SDL_BWin.h.

Referenced by DirectConnected(), GetClips(), SDL_BWin(), and ~SDL_BWin().

bool SDL_BWin::_connected
private

Definition at line 606 of file SDL_BWin.h.

Referenced by Connected(), DirectConnected(), and SDL_BWin().

bool SDL_BWin::_connection_disabled
private

Definition at line 606 of file SDL_BWin.h.

Referenced by ConnectionEnabled(), DirectConnected(), SDL_BWin(), and ~SDL_BWin().

thread_id SDL_BWin::_draw_thread_id
private

Definition at line 618 of file SDL_BWin.h.

Referenced by SDL_BWin(), and ~SDL_BWin().

int32 SDL_BWin::_id
private

Definition at line 598 of file SDL_BWin.h.

Referenced by _PostWindowEvent(), GetID(), and SetID().

bool SDL_BWin::_inhibit_resize
private

Definition at line 601 of file SDL_BWin.h.

Referenced by SDL_BWin().

int32 SDL_BWin::_last_buttons
private

Definition at line 597 of file SDL_BWin.h.

Referenced by _MouseButtonEvent(), and SDL_BWin().

bool SDL_BWin::_mouse_focused
private

Definition at line 599 of file SDL_BWin.h.

Referenced by _MouseFocusEvent(), _MouseMotionEvent(), and SDL_BWin().

int32 SDL_BWin::_num_clips
private

Definition at line 616 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetNumClips().

BRect* SDL_BWin::_prev_frame
private

Definition at line 603 of file SDL_BWin.h.

Referenced by _Restore(), SDL_BWin(), and Zoom().

uint32 SDL_BWin::_row_bytes
private

Definition at line 612 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetRowBytes().

BGLView* SDL_BWin::_SDL_GLView
private
bool SDL_BWin::_shown
private

Definition at line 600 of file SDL_BWin.h.

Referenced by Hide(), IsShown(), SDL_BWin(), and Show().

bool SDL_BWin::_trash_window_buffer
private

Definition at line 606 of file SDL_BWin.h.

Referenced by CanTrashWindowBuffer(), DirectConnected(), SDL_BWin(), and SetTrashBuffer().


The documentation for this class was generated from the following file: