xref: /haiku/headers/os/interface/Screen.h (revision d9cebac2b77547b7064f22497514eecd2d047160)
1 /*
2  * Copyright 2007, 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 
15 class BBitmap;
16 class BWindow;
17 
18 namespace BPrivate {
19 	class BPrivateScreen;
20 }
21 
22 class BScreen {
23 	public:
24 		BScreen(screen_id id = B_MAIN_SCREEN_ID);
25 		BScreen(BWindow* window);
26 		~BScreen();
27 
28 		bool		IsValid();
29 		status_t	SetToNext();
30 
31 		color_space	ColorSpace();
32 		BRect		Frame();
33 		screen_id	ID();
34 
35 		status_t	WaitForRetrace();
36 		status_t	WaitForRetrace(bigtime_t timeout);
37 
38 		uint8		IndexForColor(rgb_color color);
39 		uint8		IndexForColor(uint8 red, uint8 green, uint8 blue,
40 						uint8 alpha = 255);
41 		rgb_color	ColorForIndex(uint8 index);
42 		uint8		InvertIndex(uint8 index);
43 
44 		const color_map* ColorMap();
45 
46 		status_t	GetBitmap(BBitmap** _bitmap, bool drawCursor = true,
47 						BRect* frame = NULL);
48 		status_t	ReadBitmap(BBitmap* bitmap, bool drawCursor = true,
49 						BRect* frame = NULL);
50 
51 		rgb_color	DesktopColor();
52 		rgb_color	DesktopColor(uint32 index);
53 		void		SetDesktopColor(rgb_color color, bool makeDefault = true);
54 		void		SetDesktopColor(rgb_color color, uint32 index,
55 						bool makeDefault = true);
56 
57 		status_t	ProposeMode(display_mode* target, const display_mode* low,
58 						const display_mode* high);
59 		status_t	GetModeList(display_mode** _modeList, uint32* _count);
60 		status_t	GetMode(display_mode* mode);
61 		status_t	GetMode(uint32 workspace, display_mode* mode);
62 		status_t	SetMode(display_mode* mode, bool makeDefault = false);
63 		status_t	SetMode(uint32 workspace, display_mode* mode,
64 						bool makeDefault = false);
65 		status_t	GetDeviceInfo(accelerant_device_info* info);
66 		status_t	GetMonitorInfo(monitor_info* info);
67 		status_t	GetPixelClockLimits(display_mode* mode, uint32* low,
68 						uint32* high);
69 		status_t	GetTimingConstraints(
70 						display_timing_constraints* timingConstraints);
71 		status_t	SetDPMS(uint32 state);
72 		uint32		DPMSState();
73 		uint32		DPMSCapabilites();
74 
75 	private:
76 		BScreen&	operator=(const BScreen& other);
77 		BScreen(const BScreen& other);
78 
79 		// old and deprecated methods - should be faded out
80 		BPrivate::BPrivateScreen* private_screen();
81 		status_t	ProposeDisplayMode(display_mode* target,
82 						const display_mode* low, const display_mode* high);
83 		void*		BaseAddress();
84 		uint32		BytesPerRow();
85 
86 		BPrivate::BPrivateScreen* fScreen;
87 };
88 
89 
90 inline uint8
91 BScreen::IndexForColor(rgb_color color)
92 {
93 	return IndexForColor(color.red, color.green, color.blue, color.alpha);
94 }
95 
96 #endif	// _SCREEN_H
97