1/*
2 * Copyright 2007-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _SCREEN_H
6#define _SCREEN_H
7
8
9#include <Accelerant.h>
10#include <GraphicsDefs.h>
11#include <Rect.h>
12#include <OS.h>
13
14
15class BBitmap;
16class BWindow;
17
18namespace BPrivate {
19	class BPrivateScreen;
20}
21
22
23class BScreen {
24public:
25								BScreen(screen_id id = B_MAIN_SCREEN_ID);
26								BScreen(BWindow* window);
27								~BScreen();
28
29			bool				IsValid();
30			status_t			SetToNext();
31
32			color_space			ColorSpace();
33			BRect				Frame();
34			screen_id			ID();
35
36			status_t			WaitForRetrace();
37			status_t			WaitForRetrace(bigtime_t timeout);
38
39			uint8				IndexForColor(rgb_color color);
40			uint8				IndexForColor(uint8 red, uint8 green,
41									uint8 blue, uint8 alpha = 255);
42			rgb_color			ColorForIndex(uint8 index);
43			uint8				InvertIndex(uint8 index);
44
45			const color_map*	ColorMap();
46
47			status_t			GetBitmap(BBitmap** _bitmap,
48									bool drawCursor = true,
49									BRect* frame = NULL);
50			status_t			ReadBitmap(BBitmap* bitmap,
51									bool drawCursor = true,
52									BRect* frame = NULL);
53
54			rgb_color			DesktopColor();
55			rgb_color			DesktopColor(uint32 workspace);
56			void				SetDesktopColor(rgb_color color,
57									bool stick = true);
58			void				SetDesktopColor(rgb_color color,
59									uint32 workspace, bool stick = true);
60
61			status_t			ProposeMode(display_mode* target,
62									const display_mode* low,
63									const display_mode* high);
64			status_t			GetModeList(display_mode** _modeList,
65									uint32* _count);
66			status_t			GetMode(display_mode* mode);
67			status_t			GetMode(uint32 workspace,
68									display_mode* mode);
69			status_t			SetMode(display_mode* mode,
70									bool makeDefault = false);
71			status_t			SetMode(uint32 workspace,
72									display_mode* mode,
73									bool makeDefault = false);
74			status_t			GetDeviceInfo(accelerant_device_info* info);
75			status_t			GetMonitorInfo(monitor_info* info);
76			status_t			GetPixelClockLimits(display_mode* mode,
77									uint32* _low, uint32* _high);
78			status_t			GetTimingConstraints(
79									display_timing_constraints*
80										timingConstraints);
81			status_t			SetDPMS(uint32 state);
82			uint32				DPMSState();
83			uint32				DPMSCapabilites();
84
85private:
86	// Forbidden and deprecated methods
87								BScreen(const BScreen& other);
88			BScreen&			operator=(const BScreen& other);
89
90			BPrivate::BPrivateScreen* private_screen();
91			status_t			ProposeDisplayMode(display_mode* target,
92									const display_mode* low,
93									const display_mode* high);
94			void*				BaseAddress();
95			uint32				BytesPerRow();
96
97private:
98			BPrivate::BPrivateScreen* fScreen;
99};
100
101
102inline uint8
103BScreen::IndexForColor(rgb_color color)
104{
105	return IndexForColor(color.red, color.green, color.blue, color.alpha);
106}
107
108#endif // _SCREEN_H
109