btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / kits / interface / Screen.cpp
blob10457563412ee4be52f654fa7d75b71e33156390
1 /*
2 * Copyright 2003-2009, Haiku Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stefano Ceccherini (burton666@libero.it)
7 * Axel Dörfler, axeld@pinc-software.de
8 */
11 #include <Screen.h>
13 #include <Window.h>
15 #include <PrivateScreen.h>
18 using namespace BPrivate;
21 BScreen::BScreen(screen_id id)
23 fScreen = BPrivateScreen::Get(id.id);
27 BScreen::BScreen(BWindow* window)
29 fScreen = BPrivateScreen::Get(window);
33 BScreen::~BScreen()
35 BPrivateScreen::Put(fScreen);
39 bool
40 BScreen::IsValid()
42 return fScreen != NULL && fScreen->IsValid();
46 status_t
47 BScreen::SetToNext()
49 if (fScreen != NULL) {
50 BPrivateScreen* screen = BPrivateScreen::GetNext(fScreen);
51 if (screen != NULL) {
52 fScreen = screen;
53 return B_OK;
56 return B_ERROR;
60 color_space
61 BScreen::ColorSpace()
63 if (fScreen != NULL)
64 return fScreen->ColorSpace();
66 return B_NO_COLOR_SPACE;
70 BRect
71 BScreen::Frame()
73 if (fScreen != NULL)
74 return fScreen->Frame();
76 return BRect(0, 0, 0, 0);
80 screen_id
81 BScreen::ID()
83 if (fScreen != NULL) {
84 screen_id id = { fScreen->ID() };
85 return id;
88 return B_MAIN_SCREEN_ID;
92 status_t
93 BScreen::WaitForRetrace()
95 return WaitForRetrace(B_INFINITE_TIMEOUT);
99 status_t
100 BScreen::WaitForRetrace(bigtime_t timeout)
102 if (fScreen != NULL)
103 return fScreen->WaitForRetrace(timeout);
105 return B_ERROR;
109 uint8
110 BScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
112 if (fScreen != NULL)
113 return fScreen->IndexForColor(red, green, blue, alpha);
115 return 0;
119 rgb_color
120 BScreen::ColorForIndex(const uint8 index)
122 if (fScreen != NULL)
123 return fScreen->ColorForIndex(index);
125 return rgb_color();
129 uint8
130 BScreen::InvertIndex(uint8 index)
132 if (fScreen != NULL)
133 return fScreen->InvertIndex(index);
135 return 0;
139 const color_map*
140 BScreen::ColorMap()
142 if (fScreen != NULL)
143 return fScreen->ColorMap();
145 return NULL;
149 status_t
150 BScreen::GetBitmap(BBitmap** _bitmap, bool drawCursor, BRect* bounds)
152 if (fScreen != NULL)
153 return fScreen->GetBitmap(_bitmap, drawCursor, bounds);
155 return B_ERROR;
159 status_t
160 BScreen::ReadBitmap(BBitmap* bitmap, bool drawCursor, BRect* bounds)
162 if (fScreen != NULL)
163 return fScreen->ReadBitmap(bitmap, drawCursor, bounds);
165 return B_ERROR;
169 rgb_color
170 BScreen::DesktopColor()
172 if (fScreen != NULL)
173 return fScreen->DesktopColor(B_CURRENT_WORKSPACE_INDEX);
175 return rgb_color();
179 rgb_color
180 BScreen::DesktopColor(uint32 workspace)
182 if (fScreen != NULL)
183 return fScreen->DesktopColor(workspace);
185 return rgb_color();
189 void
190 BScreen::SetDesktopColor(rgb_color color, bool stick)
192 if (fScreen != NULL)
193 fScreen->SetDesktopColor(color, B_CURRENT_WORKSPACE_INDEX, stick);
197 void
198 BScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool stick)
200 if (fScreen != NULL)
201 fScreen->SetDesktopColor(color, workspace, stick);
205 status_t
206 BScreen::ProposeMode(display_mode* target, const display_mode* low,
207 const display_mode* high)
209 if (fScreen != NULL)
210 return fScreen->ProposeMode(target, low, high);
212 return B_ERROR;
216 status_t
217 BScreen::GetModeList(display_mode** _modeList, uint32* _count)
219 if (fScreen != NULL)
220 return fScreen->GetModeList(_modeList, _count);
222 return B_ERROR;
226 status_t
227 BScreen::GetMode(display_mode* mode)
229 if (fScreen != NULL)
230 return fScreen->GetMode(B_CURRENT_WORKSPACE_INDEX, mode);
232 return B_ERROR;
236 status_t
237 BScreen::GetMode(uint32 workspace, display_mode* mode)
239 if (fScreen != NULL)
240 return fScreen->GetMode(workspace, mode);
242 return B_ERROR;
246 status_t
247 BScreen::SetMode(display_mode* mode, bool makeDefault)
249 if (fScreen != NULL)
250 return fScreen->SetMode(B_CURRENT_WORKSPACE_INDEX, mode, makeDefault);
252 return B_ERROR;
256 status_t
257 BScreen::SetMode(uint32 workspace, display_mode* mode, bool makeDefault)
259 if (fScreen != NULL)
260 return fScreen->SetMode(workspace, mode, makeDefault);
262 return B_ERROR;
266 status_t
267 BScreen::GetDeviceInfo(accelerant_device_info* info)
269 if (fScreen != NULL)
270 return fScreen->GetDeviceInfo(info);
272 return B_ERROR;
276 status_t
277 BScreen::GetMonitorInfo(monitor_info* info)
279 if (fScreen != NULL)
280 return fScreen->GetMonitorInfo(info);
282 return B_ERROR;
286 status_t
287 BScreen::GetPixelClockLimits(display_mode* mode, uint32* _low, uint32* _high)
289 if (fScreen != NULL)
290 return fScreen->GetPixelClockLimits(mode, _low, _high);
292 return B_ERROR;
296 status_t
297 BScreen::GetTimingConstraints(display_timing_constraints* constraints)
299 if (fScreen != NULL)
300 return fScreen->GetTimingConstraints(constraints);
302 return B_ERROR;
306 status_t
307 BScreen::SetDPMS(uint32 dpmsState)
309 if (fScreen != NULL)
310 return fScreen->SetDPMS(dpmsState);
312 return B_ERROR;
316 uint32
317 BScreen::DPMSState()
319 if (fScreen != NULL)
320 return fScreen->DPMSState();
322 return 0;
326 uint32
327 BScreen::DPMSCapabilites()
329 if (fScreen != NULL)
330 return fScreen->DPMSCapabilites();
332 return 0;
336 status_t
337 BScreen::GetBrightness(float* brightness)
339 if (fScreen != NULL)
340 return fScreen->GetBrightness(brightness);
341 return B_ERROR;
345 status_t
346 BScreen::SetBrightness(float brightness)
348 if (fScreen != NULL)
349 return fScreen->SetBrightness(brightness);
350 return B_ERROR;
354 // #pragma mark - Deprecated methods
357 BPrivate::BPrivateScreen*
358 BScreen::private_screen()
360 return fScreen;
364 status_t
365 BScreen::ProposeDisplayMode(display_mode* target, const display_mode* low,
366 const display_mode* high)
368 return ProposeMode(target, low, high);
372 void*
373 BScreen::BaseAddress()
375 if (fScreen != NULL)
376 return fScreen->BaseAddress();
378 return NULL;
382 uint32
383 BScreen::BytesPerRow()
385 if (fScreen != NULL)
386 return fScreen->BytesPerRow();
388 return 0;