Mercurial > sdl-ios-xcode
annotate src/video/bwindow/SDL_BView.h @ 1358:c71e05b4dc2e
More header massaging... works great on Windows. ;-)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 10 Feb 2006 06:48:43 +0000 |
parents | c9b51268668f |
children | 19418e4422cb |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
114
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
23 #ifndef _SDL_BView_h |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
24 #define _SDL_BView_h |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
25 |
0 | 26 /* This is the event handling and graphics update portion of SDL_BWin */ |
27 | |
28 extern "C" { | |
29 #include "SDL_events_c.h" | |
30 }; | |
31 | |
32 class SDL_BView : public BView | |
33 { | |
34 public: | |
35 SDL_BView(BRect frame) : | |
36 BView(frame, "SDL View", B_FOLLOW_ALL_SIDES, | |
37 (B_WILL_DRAW|B_FRAME_EVENTS)) { | |
38 image = NULL; | |
39 xoff = yoff = 0; | |
40 SetViewColor(0,0,0,0); | |
41 SetHighColor(0,0,0,0); | |
42 } | |
43 virtual ~SDL_BView() { | |
44 SetBitmap(NULL); | |
45 } | |
46 /* Set drawing offsets for fullscreen mode */ | |
47 virtual void SetXYOffset(int x, int y) { | |
48 xoff = x; | |
49 yoff = y; | |
50 } | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
51 virtual void GetXYOffset(int &x, int &y) { |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
52 x = xoff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
53 y = yoff; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
54 } |
0 | 55 /* The view changed size. If it means we're in fullscreen, we |
56 * draw a nice black box in the entire view to get black borders. | |
57 */ | |
58 virtual void FrameResized(float width, float height) { | |
59 BRect bounds; | |
60 bounds.top = bounds.left = 0; | |
61 bounds.right = width; | |
62 bounds.bottom = height; | |
63 /* Fill the entire view with black */ | |
64 FillRect(bounds, B_SOLID_HIGH); | |
65 /* And if there's an image, redraw it. */ | |
66 if( image ) { | |
67 bounds = image->Bounds(); | |
68 Draw(bounds); | |
69 } | |
70 } | |
71 | |
72 /* Drawing portion of this complete breakfast. :) */ | |
73 virtual void SetBitmap(BBitmap *bitmap) { | |
74 if ( image ) { | |
75 delete image; | |
76 } | |
77 image = bitmap; | |
78 } | |
79 virtual void Draw(BRect updateRect) { | |
80 if ( image ) { | |
81 if(xoff || yoff) { | |
82 BRect dest; | |
83 dest.top = updateRect.top + yoff; | |
84 dest.left = updateRect.left + xoff; | |
85 dest.bottom = updateRect.bottom + yoff; | |
114
dabc453ce7f7
Now returns an error if unable to open audio on BeOS
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
86 dest.right = updateRect.right + xoff; |
0 | 87 DrawBitmap(image, updateRect, dest); |
88 } else { | |
89 DrawBitmap(image, updateRect, updateRect); | |
90 } | |
91 } | |
92 } | |
93 virtual void DrawAsync(BRect updateRect) { | |
94 if(xoff || yoff) { | |
95 BRect dest; | |
96 dest.top = updateRect.top + yoff; | |
97 dest.left = updateRect.left + xoff; | |
98 dest.bottom = updateRect.bottom + yoff; | |
99 dest.right = updateRect.right + xoff;; | |
100 DrawBitmapAsync(image, updateRect, dest); | |
101 } else { | |
102 DrawBitmapAsync(image, updateRect, updateRect); | |
103 } | |
104 } | |
105 | |
106 private: | |
107 BBitmap *image; | |
108 int xoff, yoff; | |
109 }; | |
756
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
110 |
10332c6fad2e
te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
111 #endif /* _SDL_BView_h */ |