Mercurial > sdl-ios-xcode
comparison src/video/bwindow/SDL_BView.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 | a1b03ba2fcd0 |
comparison
equal
deleted
inserted
replaced
4011:f5794774970d | 4012:4e29535b821b |
---|---|
35 public: | 35 public: |
36 SDL_BView(BRect frame) : | 36 SDL_BView(BRect frame) : |
37 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 image = NULL; | 39 image = NULL; |
40 xoff = yoff = 0; | |
40 SetViewColor(0,0,0,0); | 41 SetViewColor(0,0,0,0); |
41 SetHighColor(0,0,0,0); | 42 SetHighColor(0,0,0,0); |
42 } | 43 } |
43 virtual ~SDL_BView() { | 44 virtual ~SDL_BView() { |
44 SetBitmap(NULL); | 45 SetBitmap(NULL); |
46 } | |
47 /* Set drawing offsets for fullscreen mode */ | |
48 virtual void SetXYOffset(int x, int y) { | |
49 xoff = x; | |
50 yoff = y; | |
51 } | |
52 virtual void GetXYOffset(int &x, int &y) { | |
53 x = xoff; | |
54 y = yoff; | |
55 } | |
56 virtual void GetXYOffset(float &x, float &y) { | |
57 x = (float)xoff; | |
58 y = (float)yoff; | |
45 } | 59 } |
46 /* The view changed size. If it means we're in fullscreen, we | 60 /* The view changed size. If it means we're in fullscreen, we |
47 * draw a nice black box in the entire view to get black borders. | 61 * draw a nice black box in the entire view to get black borders. |
48 */ | 62 */ |
49 virtual void FrameResized(float width, float height) { | 63 virtual void FrameResized(float width, float height) { |
50 BRect bounds; | 64 BRect bounds; |
51 bounds.top = bounds.left = 0; | 65 bounds.top = bounds.left = 0; |
52 bounds.right = width; | 66 bounds.right = width; |
53 bounds.bottom = height; | 67 bounds.bottom = height; |
54 /* Fill the entire view with black */ | 68 /* Fill the entire view with black */ |
55 // FillRect(bounds, B_SOLID_HIGH); | 69 FillRect(bounds, B_SOLID_HIGH); |
56 /* And if there's an image, redraw it. */ | 70 /* And if there's an image, redraw it. */ |
57 if( image ) { | 71 if( image ) { |
58 bounds = image->Bounds(); | 72 bounds = image->Bounds(); |
59 Draw(bounds); | 73 Draw(bounds); |
60 } | 74 } |
61 } | 75 } |
62 | 76 |
63 /* Drawing portion of this complete breakfast. :) */ | 77 /* Drawing portion of this complete breakfast. :) */ |
64 virtual void SetBitmap(BBitmap *bitmap) { | 78 virtual void SetBitmap(BBitmap *bitmap) { |
65 if ( image ) { | 79 if ( image ) { |
66 delete image; | 80 delete image; |
67 } | 81 } |
68 image = bitmap; | 82 image = bitmap; |
69 } | 83 } |
70 virtual void Draw(BRect updateRect) { | 84 virtual void Draw(BRect updateRect) { |
71 if ( image ) { | 85 if ( image ) { |
72 DrawBitmap(image, updateRect, updateRect); | 86 if(xoff || yoff) { |
87 BRect dest; | |
88 dest.top = updateRect.top + yoff; | |
89 dest.left = updateRect.left + xoff; | |
90 dest.bottom = updateRect.bottom + yoff; | |
91 dest.right = updateRect.right + xoff; | |
92 DrawBitmap(image, updateRect, dest); | |
93 } else { | |
94 DrawBitmap(image, updateRect, updateRect); | |
95 } | |
73 } | 96 } |
74 } | 97 } |
75 virtual void DrawAsync(BRect updateRect) { | 98 virtual void DrawAsync(BRect updateRect) { |
76 if ( image ) { | 99 if(xoff || yoff) { |
100 BRect dest; | |
101 dest.top = updateRect.top + yoff; | |
102 dest.left = updateRect.left + xoff; | |
103 dest.bottom = updateRect.bottom + yoff; | |
104 dest.right = updateRect.right + xoff;; | |
105 DrawBitmapAsync(image, updateRect, dest); | |
106 } else { | |
77 DrawBitmapAsync(image, updateRect, updateRect); | 107 DrawBitmapAsync(image, updateRect, updateRect); |
78 } | 108 } |
79 } | 109 } |
80 | 110 |
81 private: | 111 private: |
82 BBitmap *image; | 112 BBitmap *image; |
113 int xoff, yoff; | |
83 }; | 114 }; |
84 | 115 |
85 #endif /* _SDL_BView_h */ | 116 #endif /* _SDL_BView_h */ |