xref: /haiku/headers/os/interface/InterfaceDefs.h (revision cfc3fa87da824bdf593eb8b817a83b6376e77935)
1 /*
2  * Copyright (c) 2001-2008, Haiku, Inc.
3  * Distributed under the terms of the MIT license.
4  *
5  * Authors:
6  *		Erik Jaesler (erik@cgsoftware.com)
7  */
8 #ifndef	_INTERFACE_DEFS_H
9 #define	_INTERFACE_DEFS_H
10 
11 
12 #include <BeBuild.h>
13 #include <GraphicsDefs.h>
14 #include <OS.h>
15 
16 class BRect;
17 
18 
19 // some handy UTF-8 characters
20 
21 #define B_UTF8_BULLET		"\xE2\x80\xA2"
22 #define B_UTF8_ELLIPSIS		"\xE2\x80\xA6"
23 #define B_UTF8_OPEN_QUOTE	"\xE2\x80\x9C"
24 #define B_UTF8_CLOSE_QUOTE	"\xE2\x80\x9D"
25 #define B_UTF8_COPYRIGHT	"\xC2\xA9"
26 #define B_UTF8_REGISTERED	"\xC2\xAE"
27 #define B_UTF8_TRADEMARK	"\xE2\x84\xA2"
28 #define B_UTF8_SMILING_FACE	"\xE2\x98\xBB"
29 #define B_UTF8_HIROSHI		"\xE5\xBC\x98"
30 #ifdef COMPILE_FOR_R5
31 	#define B_MAX_MOUSE_BUTTONS 3
32 #else
33 	#define B_MAX_MOUSE_BUTTONS 16
34 #endif
35 
36 
37 // Key definitions
38 
39 struct key_info {
40 	uint32	modifiers;
41 	uint8	key_states[16];
42 };
43 
44 enum {
45 	B_BACKSPACE			= 0x08,
46 	B_RETURN			= 0x0a,
47 	B_ENTER				= 0x0a,
48 	B_SPACE				= 0x20,
49 	B_TAB				= 0x09,
50 	B_ESCAPE			= 0x1b,
51 	B_SUBSTITUTE		= 0x1a,
52 
53 	B_LEFT_ARROW		= 0x1c,
54 	B_RIGHT_ARROW		= 0x1d,
55 	B_UP_ARROW			= 0x1e,
56 	B_DOWN_ARROW		= 0x1f,
57 
58 	B_INSERT			= 0x05,
59 	B_DELETE			= 0x7f,
60 	B_HOME				= 0x01,
61 	B_END				= 0x04,
62 	B_PAGE_UP			= 0x0b,
63 	B_PAGE_DOWN			= 0x0c,
64 
65 	B_FUNCTION_KEY		= 0x10
66 };
67 
68 enum {
69 	B_F1_KEY			= 0x02,
70 	B_F2_KEY			= 0x03,
71 	B_F3_KEY			= 0x04,
72 	B_F4_KEY			= 0x05,
73 	B_F5_KEY			= 0x06,
74 	B_F6_KEY			= 0x07,
75 	B_F7_KEY			= 0x08,
76 	B_F8_KEY			= 0x09,
77 	B_F9_KEY			= 0x0a,
78 	B_F10_KEY			= 0x0b,
79 	B_F11_KEY			= 0x0c,
80 	B_F12_KEY			= 0x0d,
81 	B_PRINT_KEY			= 0x0e,
82 	B_SCROLL_KEY		= 0x0f,
83 	B_PAUSE_KEY			= 0x10
84 };
85 
86 struct key_map {
87 	uint32	version;
88 	uint32	caps_key;
89 	uint32	scroll_key;
90 	uint32	num_key;
91 	uint32	left_shift_key;
92 	uint32	right_shift_key;
93 	uint32	left_command_key;
94 	uint32	right_command_key;
95 	uint32	left_control_key;
96 	uint32	right_control_key;
97 	uint32	left_option_key;
98 	uint32	right_option_key;
99 	uint32	menu_key;
100 	uint32	lock_settings;
101 	int32	control_map[128];
102 	int32	option_caps_shift_map[128];
103 	int32	option_caps_map[128];
104 	int32	option_shift_map[128];
105 	int32	option_map[128];
106 	int32	caps_shift_map[128];
107 	int32	caps_map[128];
108 	int32	shift_map[128];
109 	int32	normal_map[128];
110 	int32	acute_dead_key[32];
111 	int32	grave_dead_key[32];
112 	int32	circumflex_dead_key[32];
113 	int32	dieresis_dead_key[32];
114 	int32	tilde_dead_key[32];
115 	uint32	acute_tables;
116 	uint32	grave_tables;
117 	uint32	circumflex_tables;
118 	uint32	dieresis_tables;
119 	uint32	tilde_tables;
120 };
121 
122 enum {
123 	B_CONTROL_TABLE				= 0x00000001,
124 	B_OPTION_CAPS_SHIFT_TABLE	= 0x00000002,
125 	B_OPTION_CAPS_TABLE			= 0x00000004,
126 	B_OPTION_SHIFT_TABLE		= 0x00000008,
127 	B_OPTION_TABLE				= 0x00000010,
128 	B_CAPS_SHIFT_TABLE			= 0x00000020,
129 	B_CAPS_TABLE				= 0x00000040,
130 	B_SHIFT_TABLE				= 0x00000080,
131 	B_NORMAL_TABLE				= 0x00000100
132 };
133 
134 // modifiers
135 enum {
136 	B_SHIFT_KEY			= 0x00000001,
137 	B_COMMAND_KEY		= 0x00000002,
138 	B_CONTROL_KEY		= 0x00000004,
139 	B_CAPS_LOCK			= 0x00000008,
140 	B_SCROLL_LOCK		= 0x00000010,
141 	B_NUM_LOCK			= 0x00000020,
142 	B_OPTION_KEY		= 0x00000040,
143 	B_MENU_KEY			= 0x00000080,
144 	B_LEFT_SHIFT_KEY	= 0x00000100,
145 	B_RIGHT_SHIFT_KEY	= 0x00000200,
146 	B_LEFT_COMMAND_KEY	= 0x00000400,
147 	B_RIGHT_COMMAND_KEY	= 0x00000800,
148 	B_LEFT_CONTROL_KEY	= 0x00001000,
149 	B_RIGHT_CONTROL_KEY	= 0x00002000,
150 	B_LEFT_OPTION_KEY	= 0x00004000,
151 	B_RIGHT_OPTION_KEY	= 0x00008000
152 };
153 
154 
155 // Mouse definitions
156 
157 struct mouse_map {
158 	uint32	button[B_MAX_MOUSE_BUTTONS];
159 };
160 
161 enum mode_mouse {
162 	B_NORMAL_MOUSE 			= 0,
163 	B_FOCUS_FOLLOWS_MOUSE	= 1,
164 	B_WARP_MOUSE			= 3,
165 	B_INSTANT_WARP_MOUSE	= 7
166 };
167 
168 
169 // View orientation/alignment/style
170 
171 enum border_style {
172 	B_PLAIN_BORDER,
173 	B_FANCY_BORDER,
174 	B_NO_BORDER
175 };
176 
177 enum orientation {
178 	B_HORIZONTAL,
179 	B_VERTICAL
180 };
181 
182 enum button_width {
183 	B_WIDTH_AS_USUAL,
184 	B_WIDTH_FROM_WIDEST,
185 	B_WIDTH_FROM_LABEL
186 };
187 
188 struct scroll_bar_info {
189 	bool	proportional;
190 	bool	double_arrows;
191 	int32	knob;
192 	int32	min_knob_size;
193 };
194 
195 enum alignment {
196 	B_ALIGN_LEFT,
197     B_ALIGN_RIGHT,
198     B_ALIGN_CENTER,
199 
200 	B_ALIGN_HORIZONTAL_CENTER	= B_ALIGN_CENTER,
201 
202 	B_ALIGN_HORIZONTAL_UNSET	= -1L,
203 	B_ALIGN_USE_FULL_WIDTH		= -2L
204 };
205 
206 enum vertical_alignment {
207 	B_ALIGN_TOP					= 0x10L,
208 	B_ALIGN_MIDDLE				= 0x20,
209 	B_ALIGN_BOTTOM				= 0x30,
210 
211 	B_ALIGN_VERTICAL_CENTER		= B_ALIGN_MIDDLE,
212 
213 	B_ALIGN_VERTICAL_UNSET		= -1L,
214 	B_ALIGN_NO_VERTICAL			= B_ALIGN_VERTICAL_UNSET,
215 	B_ALIGN_USE_FULL_HEIGHT		= -2L
216 };
217 
218 
219 // Line join and cap modes
220 
221 enum join_mode {
222 	B_ROUND_JOIN = 0,
223 	B_MITER_JOIN,
224 	B_BEVEL_JOIN,
225 	B_BUTT_JOIN,
226 	B_SQUARE_JOIN
227 };
228 
229 enum cap_mode {
230 	B_ROUND_CAP		= B_ROUND_JOIN,
231 	B_BUTT_CAP		= B_BUTT_JOIN,
232 	B_SQUARE_CAP	= B_SQUARE_JOIN
233 };
234 
235 const float B_DEFAULT_MITER_LIMIT = 10.0F;
236 
237 
238 // Bitmap and overlay constants
239 
240 enum bitmap_tiling {
241 	B_TILE_BITMAP_X		= 0x00000001,
242 	B_TILE_BITMAP_Y		= 0x00000002,
243 	B_TILE_BITMAP		= 0x00000003
244 };
245 
246 enum overlay_options {
247 	B_OVERLAY_FILTER_HORIZONTAL	= 0x00010000,
248 	B_OVERLAY_FILTER_VERTICAL	= 0x00020000,
249 	B_OVERLAY_MIRROR			= 0x00040000,
250 	B_OVERLAY_TRANSFER_CHANNEL	= 0x00080000
251 };
252 
253 
254 // Default UI Colors
255 
256 enum color_which {
257 	B_PANEL_BACKGROUND_COLOR = 1,
258 	B_PANEL_TEXT_COLOR = 10,
259 	B_DOCUMENT_BACKGROUND_COLOR = 11,
260 	B_DOCUMENT_TEXT_COLOR = 12,
261 	B_CONTROL_BACKGROUND_COLOR = 13,
262 	B_CONTROL_TEXT_COLOR = 14,
263 	B_CONTROL_BORDER_COLOR = 15,
264 	B_CONTROL_HIGHLIGHT_COLOR = 16,
265 	B_NAVIGATION_BASE_COLOR = 4,
266 	B_NAVIGATION_PULSE_COLOR = 17,
267 	B_SHINE_COLOR = 18,
268 	B_SHADOW_COLOR = 19,
269 
270 	B_MENU_BACKGROUND_COLOR = 2,
271 	B_MENU_SELECTED_BACKGROUND_COLOR = 6,
272 	B_MENU_ITEM_TEXT_COLOR = 7,
273 	B_MENU_SELECTED_ITEM_TEXT_COLOR = 8,
274 	B_MENU_SELECTED_BORDER_COLOR = 9,
275 
276 	B_TOOLTIP_BACKGROUND_COLOR = 20,
277 	B_TOOLTIP_TEXT_COLOR = 21,
278 
279 	B_SUCCESS_COLOR = 100,
280 	B_FAILURE_COLOR = 101,
281 
282 	// Old name synonyms.
283 	B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR,
284 	B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR,
285 
286 	// These are deprecated -- do not use in new code.  See BScreen for
287 	// the replacement for B_DESKTOP_COLOR.
288 	B_DESKTOP_COLOR = 5,
289 
290 	B_WINDOW_TAB_COLOR = 3,
291 	B_WINDOW_TEXT_COLOR = 22,
292 	B_WINDOW_INACTIVE_TAB_COLOR = 23,
293 	B_WINDOW_INACTIVE_TEXT_COLOR = 24
294 };
295 
296 
297 // Color tinting
298 
299 const float B_LIGHTEN_MAX_TINT	= 0.0f;		// 216 --> 255.0 (255)
300 const float B_LIGHTEN_2_TINT	= 0.385f;	// 216 --> 240.0 (240)
301 const float B_LIGHTEN_1_TINT	= 0.590f;	// 216 --> 232.0 (232)
302 
303 const float B_NO_TINT			= 1.0f;		// 216 --> 216.0 (216)
304 
305 const float B_DARKEN_1_TINT		= 1.147f;	// 216 --> 184.2 (184)
306 const float B_DARKEN_2_TINT		= 1.295f;	// 216 --> 152.3 (152)
307 const float B_DARKEN_3_TINT		= 1.407f;	// 216 --> 128.1 (128)
308 const float B_DARKEN_4_TINT		= 1.555f;	// 216 -->  96.1  (96)
309 const float B_DARKEN_MAX_TINT	= 2.0f;		// 216 -->   0.0   (0)
310 											// effects on standard gray level
311 
312 const float B_DISABLED_LABEL_TINT		= B_DARKEN_3_TINT;
313 const float B_HIGHLIGHT_BACKGROUND_TINT	= B_DARKEN_2_TINT;
314 const float B_DISABLED_MARK_TINT		= B_LIGHTEN_2_TINT;
315 
316 
317 status_t		get_deskbar_frame(BRect* frame);
318 
319 const color_map* system_colors();
320 
321 status_t		set_screen_space(int32 index, uint32 resolution,
322 					bool save = true);
323 
324 status_t		get_scroll_bar_info(scroll_bar_info* info);
325 status_t		set_scroll_bar_info(scroll_bar_info* info);
326 
327 status_t		get_mouse_type(int32* type);
328 status_t		set_mouse_type(int32 type);
329 status_t		get_mouse_map(mouse_map* map);
330 status_t		set_mouse_map(mouse_map* map);
331 status_t		get_click_speed(bigtime_t* speed);
332 status_t		set_click_speed(bigtime_t speed);
333 status_t		get_mouse_speed(int32* speed);
334 status_t		set_mouse_speed(int32 speed);
335 status_t		get_mouse_acceleration(int32* speed);
336 status_t		set_mouse_acceleration(int32 speed);
337 
338 status_t		get_key_repeat_rate(int32* rate);
339 status_t		set_key_repeat_rate(int32 rate);
340 status_t		get_key_repeat_delay(bigtime_t* delay);
341 status_t		set_key_repeat_delay(bigtime_t delay);
342 
343 uint32			modifiers();
344 status_t		get_key_info(key_info* info);
345 void			get_key_map(key_map** _map, char** _keyBuffer);
346 status_t		get_keyboard_id(uint16* _id);
347 void			set_modifier_key(uint32 modifier, uint32 key);
348 void			set_keyboard_locks(uint32 modifiers);
349 
350 rgb_color		keyboard_navigation_color();
351 
352 int32			count_workspaces();
353 void			set_workspace_count(int32 count);
354 int32			current_workspace();
355 void			activate_workspace(int32 workspace);
356 
357 bigtime_t		idle_time();
358 
359 void			run_select_printer_panel();
360 void			run_add_printer_panel();
361 void			run_be_about();
362 
363 void			set_focus_follows_mouse(bool follow);
364 bool			focus_follows_mouse();
365 
366 void			set_mouse_mode(mode_mouse mode);
367 mode_mouse		mouse_mode();
368 
369 rgb_color		ui_color(color_which which);
370 void			set_ui_color(const color_which& which, const rgb_color& color);
371 rgb_color		tint_color(rgb_color color, float tint);
372 
373 extern "C" status_t _init_interface_kit_();
374 	// for convenience, should be removed including the friend declarations
375 	// in Menu.h, ...
376 
377 #endif	// _INTERFACE_DEFS_H
378