diff --git headers/os/interface/Screen.h headers/os/interface/Screen.h
index 58cb2e4..a2d6076 100644
|
|
public:
|
52 | 52 | BRect* frame = NULL); |
53 | 53 | |
54 | 54 | rgb_color DesktopColor(); |
55 | | rgb_color DesktopColor(uint32 index); |
| 55 | rgb_color DesktopColor(uint32 workspace); |
56 | 56 | void SetDesktopColor(rgb_color color, |
57 | 57 | bool makeDefault = true); |
58 | 58 | void SetDesktopColor(rgb_color color, |
59 | | uint32 index, bool makeDefault = true); |
| 59 | uint32 workspace, bool makeDefault = true); |
60 | 60 | |
61 | 61 | status_t ProposeMode(display_mode* target, |
62 | 62 | const display_mode* low, |
63 | 63 | const display_mode* high); |
64 | 64 | status_t GetModeList(display_mode** _modeList, |
65 | 65 | uint32* _count); |
66 | | status_t GetMode(display_mode* _mode); |
| 66 | status_t GetMode(display_mode* mode); |
67 | 67 | status_t GetMode(uint32 workspace, |
68 | | display_mode* _mode); |
| 68 | display_mode* mode); |
69 | 69 | status_t SetMode(display_mode* mode, |
70 | 70 | bool makeDefault = false); |
71 | 71 | status_t SetMode(uint32 workspace, |
… |
… |
public:
|
74 | 74 | status_t GetDeviceInfo(accelerant_device_info* info); |
75 | 75 | status_t GetMonitorInfo(monitor_info* info); |
76 | 76 | status_t GetPixelClockLimits(display_mode* mode, |
77 | | uint32* low, uint32* high); |
| 77 | uint32* _low, uint32* _high); |
78 | 78 | status_t GetTimingConstraints( |
79 | 79 | display_timing_constraints* |
80 | 80 | timingConstraints); |
diff --git src/kits/interface/Screen.cpp src/kits/interface/Screen.cpp
index 7c75a55..0bb4fef 100644
|
|
|
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | | /*! BScreen lets you retrieve and change the display settings. */ |
12 | | |
13 | | |
14 | 11 | #include <Screen.h> |
15 | 12 | |
16 | 13 | #include <Window.h> |
… |
… |
|
21 | 18 | using namespace BPrivate; |
22 | 19 | |
23 | 20 | |
24 | | /*! \brief Creates a BScreen object which represents the display with the given |
25 | | screen_id |
26 | | \param id The screen_id of the screen to get. |
27 | | |
28 | | In the current implementation, there is only one display (B_MAIN_SCREEN_ID). |
29 | | To be sure that the object was correctly constructed, call IsValid(). |
30 | | */ |
31 | 21 | BScreen::BScreen(screen_id id) |
32 | 22 | { |
33 | 23 | fScreen = BPrivateScreen::Get(id.id); |
34 | 24 | } |
35 | 25 | |
36 | 26 | |
37 | | /*! \brief Creates a BScreen object which represents the display which contains |
38 | | the given BWindow. |
39 | | \param window A BWindow. |
40 | | */ |
41 | 27 | BScreen::BScreen(BWindow* window) |
42 | 28 | { |
43 | 29 | fScreen = BPrivateScreen::Get(window); |
44 | 30 | } |
45 | 31 | |
46 | 32 | |
47 | | /*! \brief Releases the resources allocated by the constructor. |
48 | | */ |
49 | 33 | BScreen::~BScreen() |
50 | 34 | { |
51 | 35 | BPrivateScreen::Put(fScreen); |
52 | 36 | } |
53 | 37 | |
54 | 38 | |
55 | | /*! \brief Checks if the BScreen object represents a real screen connected to |
56 | | the computer. |
57 | | \return \c true if the BScreen object is valid, \c false if not. |
58 | | */ |
59 | 39 | bool |
60 | 40 | BScreen::IsValid() |
61 | 41 | { |
… |
… |
BScreen::IsValid()
|
63 | 43 | } |
64 | 44 | |
65 | 45 | |
66 | | /*! \brief In the current implementation, this function always returns B_ERROR. |
67 | | \return Always \c B_ERROR. |
68 | | */ |
69 | 46 | status_t |
70 | 47 | BScreen::SetToNext() |
71 | 48 | { |
… |
… |
BScreen::SetToNext()
|
80 | 57 | } |
81 | 58 | |
82 | 59 | |
83 | | /*! \brief Returns the color space of the screen display. |
84 | | \return \c B_CMAP8, \c B_RGB15, or \c B_RGB32, or \c B_NO_COLOR_SPACE |
85 | | if the screen object is invalid. |
86 | | */ |
87 | 60 | color_space |
88 | 61 | BScreen::ColorSpace() |
89 | 62 | { |
90 | 63 | if (fScreen != NULL) |
91 | 64 | return fScreen->ColorSpace(); |
| 65 | |
92 | 66 | return B_NO_COLOR_SPACE; |
93 | 67 | } |
94 | 68 | |
95 | 69 | |
96 | | /*! \brief Returns the rectangle that locates the screen in the screen |
97 | | coordinate system. |
98 | | \return a BRect that locates the screen in the screen coordinate system. |
99 | | */ |
100 | 70 | BRect |
101 | 71 | BScreen::Frame() |
102 | 72 | { |
103 | 73 | if (fScreen != NULL) |
104 | 74 | return fScreen->Frame(); |
| 75 | |
105 | 76 | return BRect(0, 0, 0, 0); |
106 | 77 | } |
107 | 78 | |
108 | 79 | |
109 | | /*! \brief Returns the identifier for the screen. |
110 | | \return A screen_id struct that identifies the screen. |
111 | | |
112 | | In the current implementation, this function always returns |
113 | | \c B_MAIN_SCREEN_ID, even if the object is invalid. |
114 | | */ |
115 | 80 | screen_id |
116 | 81 | BScreen::ID() |
117 | 82 | { |
… |
… |
BScreen::ID()
|
124 | 89 | } |
125 | 90 | |
126 | 91 | |
127 | | /*! \brief Blocks until the monitor has finished the current vertical retrace. |
128 | | \return \c B_OK, or \c B_ERROR if the screen object is invalid. |
129 | | */ |
130 | 92 | status_t |
131 | 93 | BScreen::WaitForRetrace() |
132 | 94 | { |
… |
… |
BScreen::WaitForRetrace()
|
134 | 96 | } |
135 | 97 | |
136 | 98 | |
137 | | /*! \brief Blocks until the monitor has finished the current vertical retrace, |
138 | | or until the given timeout has passed. |
139 | | \param timeout A bigtime_t which indicates the time to wait before |
140 | | returning. |
141 | | \return \c B_OK if the monitor has retraced in the given amount of time, |
142 | | \c B_ERROR otherwise. |
143 | | */ |
144 | 99 | status_t |
145 | 100 | BScreen::WaitForRetrace(bigtime_t timeout) |
146 | 101 | { |
147 | 102 | if (fScreen != NULL) |
148 | 103 | return fScreen->WaitForRetrace(timeout); |
| 104 | |
149 | 105 | return B_ERROR; |
150 | 106 | } |
151 | 107 | |
152 | 108 | |
153 | | /*! \brief Returns the index of the 8-bit color that, |
154 | | most closely matches the given 32-bit color. |
155 | | \param r The red value for a 32-bit color. |
156 | | \param g The green value for a 32-bit color. |
157 | | \param b The blue value for a 32-bit color. |
158 | | \param a The alpha value for a 32-bit color. |
159 | | \return An index for a 8-bit color in the screen's color map. |
160 | | */ |
161 | 109 | uint8 |
162 | | BScreen::IndexForColor(uint8 r, uint8 g, uint8 b, uint8 a) |
| 110 | BScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha) |
163 | 111 | { |
164 | 112 | if (fScreen != NULL) |
165 | | return fScreen->IndexForColor(r, g, b, a); |
| 113 | return fScreen->IndexForColor(red, green, blue, alpha); |
| 114 | |
166 | 115 | return 0; |
167 | 116 | } |
168 | 117 | |
169 | 118 | |
170 | | /*! \brief Returns the 32-bit color representation of a given 8-bit color index. |
171 | | \param index The 8-bit color index to convert. |
172 | | \return A rgb_color struct which represents the given 8-bit color index. |
173 | | */ |
174 | 119 | rgb_color |
175 | 120 | BScreen::ColorForIndex(const uint8 index) |
176 | 121 | { |
177 | 122 | if (fScreen != NULL) |
178 | 123 | return fScreen->ColorForIndex(index); |
| 124 | |
179 | 125 | return rgb_color(); |
180 | 126 | } |
181 | 127 | |
182 | 128 | |
183 | | /*! \brief Returns the "inversion" of the given 8-bit color. |
184 | | \param index An 8-bit color index. |
185 | | \return An 8-bit color index that represents the "inversion" of the given |
186 | | color. |
187 | | */ |
188 | 129 | uint8 |
189 | 130 | BScreen::InvertIndex(uint8 index) |
190 | 131 | { |
191 | 132 | if (fScreen != NULL) |
192 | 133 | return fScreen->InvertIndex(index); |
| 134 | |
193 | 135 | return 0; |
194 | 136 | } |
195 | 137 | |
196 | 138 | |
197 | | /*! \brief Returns the color map of the current display. |
198 | | \return A pointer to the object's color_map. |
199 | | */ |
200 | 139 | const color_map* |
201 | 140 | BScreen::ColorMap() |
202 | 141 | { |
203 | 142 | if (fScreen != NULL) |
204 | 143 | return fScreen->ColorMap(); |
| 144 | |
205 | 145 | return NULL; |
206 | 146 | } |
207 | 147 | |
208 | 148 | |
209 | | /*! \brief Copies the screen's contents into the first argument BBitmap. |
210 | | \param screen_shot A pointer to a BBitmap pointer, where the function will |
211 | | allocate a BBitmap for you. |
212 | | \param draw_cursor Specifies if you want the cursor to be drawn. |
213 | | \param bound Let you specify the area you want copied. If it's NULL, the |
214 | | entire screen is copied. |
215 | | \return \c B_OK if the operation was succesful, \c B_ERROR on failure. |
216 | | */ |
217 | 149 | status_t |
218 | 150 | BScreen::GetBitmap(BBitmap** _bitmap, bool drawCursor, BRect* bounds) |
219 | 151 | { |
220 | 152 | if (fScreen != NULL) |
221 | 153 | return fScreen->GetBitmap(_bitmap, drawCursor, bounds); |
| 154 | |
222 | 155 | return B_ERROR; |
223 | 156 | } |
224 | 157 | |
225 | 158 | |
226 | | /*! \brief Copies the screen's contents into the first argument BBitmap. |
227 | | \param screen_shot A pointer to an allocated BBitmap, where the function |
228 | | will store the screen's content. |
229 | | \param draw_cursor Specifies if you want the cursor to be drawn. |
230 | | \param bound Let you specify the area you want copied. If it's NULL, the |
231 | | entire screen is copied. |
232 | | \return \c B_OK if the operation was succesful, \c B_ERROR on failure. |
233 | | |
234 | | The only difference between this method and GetBitmap() is that ReadBitmap |
235 | | requires you to allocate a BBitmap, while the latter will allocate a BBitmap |
236 | | for you. |
237 | | */ |
238 | 159 | status_t |
239 | | BScreen::ReadBitmap(BBitmap* buffer, bool drawCursor, BRect* bounds) |
| 160 | BScreen::ReadBitmap(BBitmap* bitmap, bool drawCursor, BRect* bounds) |
240 | 161 | { |
241 | 162 | if (fScreen != NULL) |
242 | | return fScreen->ReadBitmap(buffer, drawCursor, bounds); |
| 163 | return fScreen->ReadBitmap(bitmap, drawCursor, bounds); |
| 164 | |
243 | 165 | return B_ERROR; |
244 | 166 | } |
245 | 167 | |
246 | 168 | |
247 | | /*! \brief Returns the color of the desktop. |
248 | | \return An rgb_color structure which is the color of the desktop. |
249 | | */ |
250 | 169 | rgb_color |
251 | 170 | BScreen::DesktopColor() |
252 | 171 | { |
… |
… |
BScreen::DesktopColor()
|
257 | 176 | } |
258 | 177 | |
259 | 178 | |
260 | | /*! \brief Returns the color of the desktop in the given workspace. |
261 | | \param workspace The workspace of which you want to have the color. |
262 | | \return An rgb_color structure which is the color of the desktop in the |
263 | | given workspace. |
264 | | */ |
265 | 179 | rgb_color |
266 | 180 | BScreen::DesktopColor(uint32 workspace) |
267 | 181 | { |
… |
… |
BScreen::DesktopColor(uint32 workspace)
|
272 | 186 | } |
273 | 187 | |
274 | 188 | |
275 | | /*! \brief Set the color of the desktop. |
276 | | \param rgb The color you want to paint the desktop background. |
277 | | \param stick If you pass \c true here, the color will be maintained across |
278 | | boots. |
279 | | */ |
280 | 189 | void |
281 | | BScreen::SetDesktopColor(rgb_color rgb, bool stick) |
| 190 | BScreen::SetDesktopColor(rgb_color color, bool stick) |
282 | 191 | { |
283 | 192 | if (fScreen != NULL) |
284 | | fScreen->SetDesktopColor(rgb, B_CURRENT_WORKSPACE_INDEX, stick); |
| 193 | fScreen->SetDesktopColor(color, B_CURRENT_WORKSPACE_INDEX, stick); |
285 | 194 | } |
286 | 195 | |
287 | 196 | |
288 | | /*! \brief Set the color of the desktop in the given workspace. |
289 | | \param rgb The color you want to paint the desktop background. |
290 | | \param index The workspace you want to change the color. |
291 | | \param stick If you pass \c true here, the color will be maintained across |
292 | | boots. |
293 | | */ |
294 | 197 | void |
295 | | BScreen::SetDesktopColor(rgb_color rgb, uint32 index, bool stick) |
| 198 | BScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool stick) |
296 | 199 | { |
297 | 200 | if (fScreen != NULL) |
298 | | fScreen->SetDesktopColor(rgb, index, stick); |
| 201 | fScreen->SetDesktopColor(color, workspace, stick); |
299 | 202 | } |
300 | 203 | |
301 | 204 | |
302 | | /*! \brief Attempts to adjust the supplied mode so that it's a supported mode. |
303 | | \param target The mode you want to be adjusted. |
304 | | \param low The lower limit you want target to be adjusted. |
305 | | \param high The higher limit you want target to be adjusted. |
306 | | \return |
307 | | - \c B_OK if target (as returned) is supported and falls into the |
308 | | limits. |
309 | | - \c B_BAD_VALUE if target (as returned) is supported but doesn't fall |
310 | | into the limits. |
311 | | - \c B_ERROR if target isn't supported. |
312 | | */ |
313 | 205 | status_t |
314 | 206 | BScreen::ProposeMode(display_mode* target, const display_mode* low, |
315 | 207 | const display_mode* high) |
316 | 208 | { |
317 | 209 | if (fScreen != NULL) |
318 | 210 | return fScreen->ProposeMode(target, low, high); |
| 211 | |
319 | 212 | return B_ERROR; |
320 | 213 | } |
321 | 214 | |
322 | 215 | |
323 | | /*! \brief allocates and returns a list of the display_modes |
324 | | that the graphics card supports. |
325 | | \param mode_list A pointer to a mode_list pointer, where the function will |
326 | | allocate an array of display_mode structures. |
327 | | \param count A pointer to an integer, where the function will store the |
328 | | amount of available display modes. |
329 | | \return \c B_OK. |
330 | | */ |
331 | 216 | status_t |
332 | 217 | BScreen::GetModeList(display_mode** _modeList, uint32* _count) |
333 | 218 | { |
334 | 219 | if (fScreen != NULL) |
335 | 220 | return fScreen->GetModeList(_modeList, _count); |
| 221 | |
336 | 222 | return B_ERROR; |
337 | 223 | } |
338 | 224 | |
339 | 225 | |
340 | | /*! \brief Copies the current display_mode into mode. |
341 | | \param mode A pointer to a display_mode structure, |
342 | | where the current display_mode will be copied. |
343 | | \return \c B_OK if the operation was succesful. |
344 | | */ |
345 | 226 | status_t |
346 | 227 | BScreen::GetMode(display_mode* mode) |
347 | 228 | { |
348 | 229 | if (fScreen != NULL) |
349 | 230 | return fScreen->GetMode(B_CURRENT_WORKSPACE_INDEX, mode); |
| 231 | |
350 | 232 | return B_ERROR; |
351 | 233 | } |
352 | 234 | |
353 | 235 | |
354 | | /*! \brief Copies the current display_mode of the given workspace into mode. |
355 | | \param workspace The index of the workspace to query. |
356 | | \param mode A pointer to a display_mode structure, |
357 | | where the current display_mode will be copied. |
358 | | \return \c B_OK if the operation was succesful. |
359 | | */ |
360 | 236 | status_t |
361 | 237 | BScreen::GetMode(uint32 workspace, display_mode* mode) |
362 | 238 | { |
363 | 239 | if (fScreen != NULL) |
364 | 240 | return fScreen->GetMode(workspace, mode); |
| 241 | |
365 | 242 | return B_ERROR; |
366 | 243 | } |
367 | 244 | |
368 | 245 | |
369 | | /*! \brief Set the screen to the given mode. |
370 | | \param mode A pointer to a display_mode. |
371 | | \param makeDefault If true, the mode becomes the default for the screen. |
372 | | \return \c B_OK. |
373 | | */ |
374 | 246 | status_t |
375 | 247 | BScreen::SetMode(display_mode* mode, bool makeDefault) |
376 | 248 | { |
377 | 249 | if (fScreen != NULL) |
378 | 250 | return fScreen->SetMode(B_CURRENT_WORKSPACE_INDEX, mode, makeDefault); |
| 251 | |
379 | 252 | return B_ERROR; |
380 | 253 | } |
381 | 254 | |
382 | 255 | |
383 | | /*! \brief Set the given workspace to the given mode. |
384 | | \param workspace The index of the workspace that you want to change. |
385 | | \param mode A pointer to a display_mode. |
386 | | \param makeDefault If true, the mode becomes the default for the workspace. |
387 | | \return \c B_OK. |
388 | | */ |
389 | 256 | status_t |
390 | 257 | BScreen::SetMode(uint32 workspace, display_mode* mode, bool makeDefault) |
391 | 258 | { |
392 | 259 | if (fScreen != NULL) |
393 | 260 | return fScreen->SetMode(workspace, mode, makeDefault); |
| 261 | |
394 | 262 | return B_ERROR; |
395 | 263 | } |
396 | 264 | |
397 | 265 | |
398 | | /*! \brief Returns information about the graphics card. |
399 | | \param info An accelerant_device_info struct where to store the retrieved |
400 | | info. |
401 | | \return \c B_OK if the operation went fine, otherwise an error code. |
402 | | */ |
403 | 266 | status_t |
404 | 267 | BScreen::GetDeviceInfo(accelerant_device_info* info) |
405 | 268 | { |
406 | 269 | if (fScreen != NULL) |
407 | 270 | return fScreen->GetDeviceInfo(info); |
| 271 | |
408 | 272 | return B_ERROR; |
409 | 273 | } |
410 | 274 | |
… |
… |
BScreen::GetMonitorInfo(monitor_info* info)
|
414 | 278 | { |
415 | 279 | if (fScreen != NULL) |
416 | 280 | return fScreen->GetMonitorInfo(info); |
| 281 | |
417 | 282 | return B_ERROR; |
418 | 283 | } |
419 | 284 | |
420 | 285 | |
421 | | /*! \brief Returns, in low and high, the minimum and maximum pixel clock rates |
422 | | that are possible for the given mode. |
423 | | \param mode A pointer to a display_mode. |
424 | | \param low A pointer to an int where the function will store the lowest |
425 | | available pixel clock. |
426 | | \param high A pointer to an int where the function wills tore the highest |
427 | | available pixel clock. |
428 | | \return \c B_OK if the operation went fine, otherwise an error code. |
429 | | */ |
430 | 286 | status_t |
431 | 287 | BScreen::GetPixelClockLimits(display_mode* mode, uint32* _low, uint32* _high) |
432 | 288 | { |
433 | 289 | if (fScreen != NULL) |
434 | 290 | return fScreen->GetPixelClockLimits(mode, _low, _high); |
| 291 | |
435 | 292 | return B_ERROR; |
436 | 293 | } |
437 | 294 | |
438 | 295 | |
439 | | /*! \brief Fills out the dtc structure with the timing constraints of the |
440 | | current display mode. |
441 | | \param dtc A pointer to a display_timing_constraints structure where the |
442 | | function will store the timing constraints of the current mode. |
443 | | \return \c B_OK if the operation went fine, otherwise an error code. |
444 | | */ |
445 | 296 | status_t |
446 | 297 | BScreen::GetTimingConstraints(display_timing_constraints* constraints) |
447 | 298 | { |
448 | 299 | if (fScreen != NULL) |
449 | 300 | return fScreen->GetTimingConstraints(constraints); |
| 301 | |
450 | 302 | return B_ERROR; |
451 | 303 | } |
452 | 304 | |
453 | 305 | |
454 | | /*! \brief Lets you set the VESA Display Power Management Signaling state for |
455 | | the screen. |
456 | | \param dpms_state The DPMS state you want to be set. |
457 | | valid values are: |
458 | | - \c B_DPMS_ON |
459 | | - \c B_DPMS_STAND_BY |
460 | | - \c B_DPMS_SUSPEND |
461 | | - \c B_DPMS_OFF |
462 | | \return \c B_OK if the operation went fine, otherwise an error code. |
463 | | */ |
464 | 306 | status_t |
465 | 307 | BScreen::SetDPMS(uint32 dpmsState) |
466 | 308 | { |
467 | 309 | if (fScreen != NULL) |
468 | 310 | return fScreen->SetDPMS(dpmsState); |
| 311 | |
469 | 312 | return B_ERROR; |
470 | 313 | } |
471 | 314 | |
472 | 315 | |
473 | | /*! \brief Returns the current DPMS state of the screen. |
474 | | */ |
475 | 316 | uint32 |
476 | 317 | BScreen::DPMSState() |
477 | 318 | { |
478 | 319 | if (fScreen != NULL) |
479 | 320 | return fScreen->DPMSState(); |
| 321 | |
480 | 322 | return 0; |
481 | 323 | } |
482 | 324 | |
483 | 325 | |
484 | | /*! \brief Indicates which DPMS modes the monitor supports. |
485 | | */ |
486 | 326 | uint32 |
487 | 327 | BScreen::DPMSCapabilites() |
488 | 328 | { |
489 | 329 | if (fScreen != NULL) |
490 | 330 | return fScreen->DPMSCapabilites(); |
| 331 | |
491 | 332 | return 0; |
492 | 333 | } |
493 | 334 | |
… |
… |
BScreen::DPMSCapabilites()
|
495 | 336 | // #pragma mark - Deprecated methods |
496 | 337 | |
497 | 338 | |
498 | | /*! \brief Returns the BPrivateScreen used by the BScreen object. |
499 | | \return A pointer to the BPrivateScreen class internally used by the BScreen |
500 | | object. |
501 | | */ |
502 | 339 | BPrivate::BPrivateScreen* |
503 | 340 | BScreen::private_screen() |
504 | 341 | { |
… |
… |
BScreen::private_screen()
|
506 | 343 | } |
507 | 344 | |
508 | 345 | |
509 | | /*! \brief Deprecated, use ProposeMode() instead. |
510 | | */ |
511 | 346 | status_t |
512 | 347 | BScreen::ProposeDisplayMode(display_mode* target, const display_mode* low, |
513 | 348 | const display_mode* high) |
… |
… |
BScreen::ProposeDisplayMode(display_mode* target, const display_mode* low,
|
516 | 351 | } |
517 | 352 | |
518 | 353 | |
519 | | /*! \brief Returns the base address of the framebuffer. |
520 | | */ |
521 | 354 | void* |
522 | 355 | BScreen::BaseAddress() |
523 | 356 | { |
524 | 357 | if (fScreen != NULL) |
525 | 358 | return fScreen->BaseAddress(); |
| 359 | |
526 | 360 | return NULL; |
527 | 361 | } |
528 | 362 | |
529 | 363 | |
530 | | /*! \brief Returns the amount of bytes per row of the framebuffer. |
531 | | */ |
532 | 364 | uint32 |
533 | 365 | BScreen::BytesPerRow() |
534 | 366 | { |
535 | 367 | if (fScreen != NULL) |
536 | 368 | return fScreen->BytesPerRow(); |
| 369 | |
537 | 370 | return 0; |
538 | 371 | } |