comparison src/video/bwindow/SDL_BView.h @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
24 #ifndef _SDL_BView_h 24 #ifndef _SDL_BView_h
25 #define _SDL_BView_h 25 #define _SDL_BView_h
26 26
27 /* This is the event handling and graphics update portion of SDL_BWin */ 27 /* This is the event handling and graphics update portion of SDL_BWin */
28 28
29 extern "C" { 29 extern "C"
30 {
30 #include "../../events/SDL_events_c.h" 31 #include "../../events/SDL_events_c.h"
31 }; 32 };
32 33
33 class SDL_BView : public BView 34 class SDL_BView:public BView
34 { 35 {
35 public: 36 public:
36 SDL_BView(BRect frame) : 37 SDL_BView (BRect frame):BView (frame, "SDL View", B_FOLLOW_ALL_SIDES,
37 BView(frame, "SDL View", B_FOLLOW_ALL_SIDES, 38 (B_WILL_DRAW | B_FRAME_EVENTS))
38 (B_WILL_DRAW|B_FRAME_EVENTS)) { 39 {
39 image = NULL; 40 image = NULL;
40 xoff = yoff = 0; 41 xoff = yoff = 0;
41 SetViewColor(0,0,0,0); 42 SetViewColor (0, 0, 0, 0);
42 SetHighColor(0,0,0,0); 43 SetHighColor (0, 0, 0, 0);
43 } 44 }
44 virtual ~SDL_BView() { 45 virtual ~ SDL_BView ()
45 SetBitmap(NULL); 46 {
46 } 47 SetBitmap (NULL);
47 /* Set drawing offsets for fullscreen mode */ 48 }
48 virtual void SetXYOffset(int x, int y) { 49 /* Set drawing offsets for fullscreen mode */
49 xoff = x; 50 virtual void SetXYOffset (int x, int y)
50 yoff = y; 51 {
51 } 52 xoff = x;
52 virtual void GetXYOffset(int &x, int &y) { 53 yoff = y;
53 x = xoff; 54 }
54 y = yoff; 55 virtual void GetXYOffset (int &x, int &y)
55 } 56 {
56 /* The view changed size. If it means we're in fullscreen, we 57 x = xoff;
57 * draw a nice black box in the entire view to get black borders. 58 y = yoff;
58 */ 59 }
59 virtual void FrameResized(float width, float height) { 60 /* The view changed size. If it means we're in fullscreen, we
60 BRect bounds; 61 * draw a nice black box in the entire view to get black borders.
61 bounds.top = bounds.left = 0; 62 */
62 bounds.right = width; 63 virtual void FrameResized (float width, float height)
63 bounds.bottom = height; 64 {
64 /* Fill the entire view with black */ 65 BRect bounds;
65 FillRect(bounds, B_SOLID_HIGH); 66 bounds.top = bounds.left = 0;
66 /* And if there's an image, redraw it. */ 67 bounds.right = width;
67 if( image ) { 68 bounds.bottom = height;
68 bounds = image->Bounds(); 69 /* Fill the entire view with black */
69 Draw(bounds); 70 FillRect (bounds, B_SOLID_HIGH);
70 } 71 /* And if there's an image, redraw it. */
71 } 72 if (image) {
72 73 bounds = image->Bounds ();
73 /* Drawing portion of this complete breakfast. :) */ 74 Draw (bounds);
74 virtual void SetBitmap(BBitmap *bitmap) { 75 }
75 if ( image ) { 76 }
76 delete image;
77 }
78 image = bitmap;
79 }
80 virtual void Draw(BRect updateRect) {
81 if ( image ) {
82 if(xoff || yoff) {
83 BRect dest;
84 dest.top = updateRect.top + yoff;
85 dest.left = updateRect.left + xoff;
86 dest.bottom = updateRect.bottom + yoff;
87 dest.right = updateRect.right + xoff;
88 DrawBitmap(image, updateRect, dest);
89 } else {
90 DrawBitmap(image, updateRect, updateRect);
91 }
92 }
93 }
94 virtual void DrawAsync(BRect updateRect) {
95 if(xoff || yoff) {
96 BRect dest;
97 dest.top = updateRect.top + yoff;
98 dest.left = updateRect.left + xoff;
99 dest.bottom = updateRect.bottom + yoff;
100 dest.right = updateRect.right + xoff;;
101 DrawBitmapAsync(image, updateRect, dest);
102 } else {
103 DrawBitmapAsync(image, updateRect, updateRect);
104 }
105 }
106 77
107 private: 78 /* Drawing portion of this complete breakfast. :) */
108 BBitmap *image; 79 virtual void SetBitmap (BBitmap * bitmap)
109 int xoff, yoff; 80 {
81 if (image) {
82 delete image;
83 }
84 image = bitmap;
85 }
86 virtual void Draw (BRect updateRect)
87 {
88 if (image) {
89 if (xoff || yoff) {
90 BRect dest;
91 dest.top = updateRect.top + yoff;
92 dest.left = updateRect.left + xoff;
93 dest.bottom = updateRect.bottom + yoff;
94 dest.right = updateRect.right + xoff;
95 DrawBitmap (image, updateRect, dest);
96 } else {
97 DrawBitmap (image, updateRect, updateRect);
98 }
99 }
100 }
101 virtual void DrawAsync (BRect updateRect)
102 {
103 if (xoff || yoff) {
104 BRect dest;
105 dest.top = updateRect.top + yoff;
106 dest.left = updateRect.left + xoff;
107 dest.bottom = updateRect.bottom + yoff;
108 dest.right = updateRect.right + xoff;;
109 DrawBitmapAsync (image, updateRect, dest);
110 } else {
111 DrawBitmapAsync (image, updateRect, updateRect);
112 }
113 }
114
115 private:
116 BBitmap * image;
117 int xoff, yoff;
110 }; 118 };
111 119
112 #endif /* _SDL_BView_h */ 120 #endif /* _SDL_BView_h */
121 /* vi: set ts=4 sw=4 expandtab: */