InterfaceDefs.h revision 80bc632a
1/*
2 * Copyright 2001-2015, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef	_INTERFACE_DEFS_H
6#define	_INTERFACE_DEFS_H
7
8
9#include <GraphicsDefs.h>
10#include <OS.h>
11
12
13class BBitmap;
14class BMessage;
15class BPoint;
16class 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
39struct key_info {
40	uint32	modifiers;
41	uint8	key_states[16];
42};
43
44enum {
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	// for Japanese and Korean keyboards
68	B_KATAKANA_HIRAGANA	= 0xf2,
69	B_HANKAKU_ZENKAKU	= 0xf3,
70	B_HANGUL			= 0xf0,
71	B_HANGUL_HANJA		= 0xf1
72};
73
74enum {
75	B_F1_KEY			= 0x02,
76	B_F2_KEY			= 0x03,
77	B_F3_KEY			= 0x04,
78	B_F4_KEY			= 0x05,
79	B_F5_KEY			= 0x06,
80	B_F6_KEY			= 0x07,
81	B_F7_KEY			= 0x08,
82	B_F8_KEY			= 0x09,
83	B_F9_KEY			= 0x0a,
84	B_F10_KEY			= 0x0b,
85	B_F11_KEY			= 0x0c,
86	B_F12_KEY			= 0x0d,
87	B_PRINT_KEY			= 0x0e,
88	B_SCROLL_KEY		= 0x0f,
89	B_PAUSE_KEY			= 0x10
90};
91
92struct key_map {
93	uint32	version;
94	uint32	caps_key;
95	uint32	scroll_key;
96	uint32	num_key;
97	uint32	left_shift_key;
98	uint32	right_shift_key;
99	uint32	left_command_key;
100	uint32	right_command_key;
101	uint32	left_control_key;
102	uint32	right_control_key;
103	uint32	left_option_key;
104	uint32	right_option_key;
105	uint32	menu_key;
106	uint32	lock_settings;
107	int32	control_map[128];
108	int32	option_caps_shift_map[128];
109	int32	option_caps_map[128];
110	int32	option_shift_map[128];
111	int32	option_map[128];
112	int32	caps_shift_map[128];
113	int32	caps_map[128];
114	int32	shift_map[128];
115	int32	normal_map[128];
116	int32	acute_dead_key[32];
117	int32	grave_dead_key[32];
118	int32	circumflex_dead_key[32];
119	int32	dieresis_dead_key[32];
120	int32	tilde_dead_key[32];
121	uint32	acute_tables;
122	uint32	grave_tables;
123	uint32	circumflex_tables;
124	uint32	dieresis_tables;
125	uint32	tilde_tables;
126};
127
128enum {
129	B_CONTROL_TABLE				= 0x00000001,
130	B_OPTION_CAPS_SHIFT_TABLE	= 0x00000002,
131	B_OPTION_CAPS_TABLE			= 0x00000004,
132	B_OPTION_SHIFT_TABLE		= 0x00000008,
133	B_OPTION_TABLE				= 0x00000010,
134	B_CAPS_SHIFT_TABLE			= 0x00000020,
135	B_CAPS_TABLE				= 0x00000040,
136	B_SHIFT_TABLE				= 0x00000080,
137	B_NORMAL_TABLE				= 0x00000100
138};
139
140// modifiers
141enum {
142	B_SHIFT_KEY			= 0x00000001,
143	B_COMMAND_KEY		= 0x00000002,
144	B_CONTROL_KEY		= 0x00000004,
145	B_CAPS_LOCK			= 0x00000008,
146	B_SCROLL_LOCK		= 0x00000010,
147	B_NUM_LOCK			= 0x00000020,
148	B_OPTION_KEY		= 0x00000040,
149	B_MENU_KEY			= 0x00000080,
150	B_LEFT_SHIFT_KEY	= 0x00000100,
151	B_RIGHT_SHIFT_KEY	= 0x00000200,
152	B_LEFT_COMMAND_KEY	= 0x00000400,
153	B_RIGHT_COMMAND_KEY	= 0x00000800,
154	B_LEFT_CONTROL_KEY	= 0x00001000,
155	B_RIGHT_CONTROL_KEY	= 0x00002000,
156	B_LEFT_OPTION_KEY	= 0x00004000,
157	B_RIGHT_OPTION_KEY	= 0x00008000
158};
159
160
161// Mouse definitions
162
163struct mouse_map {
164	uint32	button[B_MAX_MOUSE_BUTTONS];
165};
166
167enum mode_mouse {
168	B_NORMAL_MOUSE 			= 0,
169	B_CLICK_TO_FOCUS_MOUSE	= -1,
170	B_FOCUS_FOLLOWS_MOUSE	= 1
171};
172
173enum mode_focus_follows_mouse {
174	B_NORMAL_FOCUS_FOLLOWS_MOUSE		= 0,
175	B_WARP_FOCUS_FOLLOWS_MOUSE			= 1,
176	B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE	= 2
177};
178
179
180// View orientation/alignment/style
181
182enum border_style {
183	B_PLAIN_BORDER,
184	B_FANCY_BORDER,
185	B_NO_BORDER
186};
187
188enum orientation {
189	B_HORIZONTAL,
190	B_VERTICAL
191};
192
193enum button_width {
194	B_WIDTH_AS_USUAL,
195	B_WIDTH_FROM_WIDEST,
196	B_WIDTH_FROM_LABEL
197};
198
199struct scroll_bar_info {
200	bool	proportional;
201	bool	double_arrows;
202	int32	knob;
203	int32	min_knob_size;
204};
205
206enum alignment {
207	B_ALIGN_LEFT,
208	B_ALIGN_RIGHT,
209	B_ALIGN_CENTER,
210
211	B_ALIGN_HORIZONTAL_CENTER	= B_ALIGN_CENTER,
212
213	B_ALIGN_HORIZONTAL_UNSET	= -1L,
214	B_ALIGN_USE_FULL_WIDTH		= -2L
215};
216
217enum vertical_alignment {
218	B_ALIGN_TOP					= 0x10L,
219	B_ALIGN_MIDDLE				= 0x20,
220	B_ALIGN_BOTTOM				= 0x30,
221
222	B_ALIGN_VERTICAL_CENTER		= B_ALIGN_MIDDLE,
223
224	B_ALIGN_VERTICAL_UNSET		= -1L,
225	B_ALIGN_NO_VERTICAL			= B_ALIGN_VERTICAL_UNSET,
226	B_ALIGN_USE_FULL_HEIGHT		= -2L
227};
228
229
230// Layout spacing and insets, see BControlLook::ComposeSpacing()
231
232
233enum {
234	B_USE_DEFAULT_SPACING = -1002,
235	B_USE_ITEM_SPACING = -1003,
236	B_USE_ITEM_INSETS = -1003,
237	B_USE_HALF_ITEM_SPACING = -1004,
238	B_USE_HALF_ITEM_INSETS = -1004,
239	B_USE_WINDOW_INSETS = -1005,
240	B_USE_WINDOW_SPACING = -1005,
241	B_USE_SMALL_INSETS = -1006,
242	B_USE_SMALL_SPACING = -1006,
243	B_USE_BIG_INSETS = -1007,
244	B_USE_BIG_SPACING = -1007
245};
246
247
248// Line join and cap modes
249
250enum join_mode {
251	B_ROUND_JOIN = 0,
252	B_MITER_JOIN,
253	B_BEVEL_JOIN,
254	B_BUTT_JOIN,
255	B_SQUARE_JOIN
256};
257
258enum cap_mode {
259	B_ROUND_CAP		= B_ROUND_JOIN,
260	B_BUTT_CAP		= B_BUTT_JOIN,
261	B_SQUARE_CAP	= B_SQUARE_JOIN
262};
263
264const float B_DEFAULT_MITER_LIMIT = 10.0F;
265
266
267// Polygon filling rules
268
269enum {
270	B_EVEN_ODD = 0,
271	B_NONZERO
272};
273
274
275// Bitmap and overlay constants
276
277enum bitmap_tiling {
278	B_TILE_BITMAP_X				= 0x00000001,
279	B_TILE_BITMAP_Y				= 0x00000002,
280	B_TILE_BITMAP				= 0x00000003
281};
282
283enum overlay_options {
284	B_OVERLAY_FILTER_HORIZONTAL	= 0x00010000,
285	B_OVERLAY_FILTER_VERTICAL	= 0x00020000,
286	B_OVERLAY_MIRROR			= 0x00040000,
287	B_OVERLAY_TRANSFER_CHANNEL	= 0x00080000
288};
289
290enum bitmap_drawing_options {
291	B_FILTER_BITMAP_BILINEAR	= 0x00000100,
292
293	B_WAIT_FOR_RETRACE			= 0x00000800
294};
295
296
297// Default UI Colors
298
299enum color_which {
300	B_NO_COLOR = 0,
301	B_PANEL_BACKGROUND_COLOR = 1,
302	B_PANEL_TEXT_COLOR = 10,
303	B_DOCUMENT_BACKGROUND_COLOR = 11,
304	B_DOCUMENT_TEXT_COLOR = 12,
305	B_CONTROL_BACKGROUND_COLOR = 13,
306	B_CONTROL_TEXT_COLOR = 14,
307	B_CONTROL_BORDER_COLOR = 15,
308	B_CONTROL_HIGHLIGHT_COLOR = 16,
309	B_CONTROL_MARK_COLOR = 27,
310	B_NAVIGATION_BASE_COLOR = 4,
311	B_NAVIGATION_PULSE_COLOR = 17,
312	B_SHINE_COLOR = 18,
313	B_SHADOW_COLOR = 19,
314
315	B_LINK_TEXT_COLOR = 33,
316	B_LINK_HOVER_COLOR = 34,
317	B_LINK_VISITED_COLOR = 35,
318	B_LINK_ACTIVE_COLOR = 36,
319
320	B_MENU_BACKGROUND_COLOR = 2,
321	B_MENU_SELECTED_BACKGROUND_COLOR = 6,
322	B_MENU_ITEM_TEXT_COLOR = 7,
323	B_MENU_SELECTED_ITEM_TEXT_COLOR = 8,
324	B_MENU_SELECTED_BORDER_COLOR = 9,
325
326	B_LIST_BACKGROUND_COLOR = 28,
327	B_LIST_SELECTED_BACKGROUND_COLOR = 29,
328	B_LIST_ITEM_TEXT_COLOR = 30,
329	B_LIST_SELECTED_ITEM_TEXT_COLOR = 31,
330
331	B_SCROLL_BAR_THUMB_COLOR = 32,
332
333	B_TOOL_TIP_BACKGROUND_COLOR = 20,
334	B_TOOL_TIP_TEXT_COLOR = 21,
335
336	B_STATUS_BAR_COLOR = 37,
337
338	B_SUCCESS_COLOR = 100,
339	B_FAILURE_COLOR = 101,
340
341	B_WINDOW_TAB_COLOR = 3,
342	B_WINDOW_TEXT_COLOR = 22,
343	B_WINDOW_INACTIVE_TAB_COLOR = 23,
344	B_WINDOW_INACTIVE_TEXT_COLOR = 24,
345
346	B_WINDOW_BORDER_COLOR = 25,
347	B_WINDOW_INACTIVE_BORDER_COLOR = 26,
348
349	// Old name synonyms.
350	B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR,
351	B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR,
352
353	// The following constants are deprecated, do not use in new code.
354	B_DESKTOP_COLOR = 5
355		// see BScreen class for B_DESKTOP_COLOR replacement
356};
357
358
359// Color tinting
360
361const float B_LIGHTEN_MAX_TINT	= 0.0f;		// 216 --> 255.0 (255)
362const float B_LIGHTEN_2_TINT	= 0.385f;	// 216 --> 240.0 (240)
363const float B_LIGHTEN_1_TINT	= 0.590f;	// 216 --> 232.0 (232)
364
365const float B_NO_TINT			= 1.0f;		// 216 --> 216.0 (216)
366
367const float B_DARKEN_1_TINT		= 1.147f;	// 216 --> 184.2 (184)
368const float B_DARKEN_2_TINT		= 1.295f;	// 216 --> 152.3 (152)
369const float B_DARKEN_3_TINT		= 1.407f;	// 216 --> 128.1 (128)
370const float B_DARKEN_4_TINT		= 1.555f;	// 216 -->  96.1  (96)
371const float B_DARKEN_MAX_TINT	= 2.0f;		// 216 -->   0.0   (0)
372											// effects on standard gray level
373
374const float B_DISABLED_LABEL_TINT		= B_DARKEN_3_TINT;
375const float B_HIGHLIGHT_BACKGROUND_TINT	= B_DARKEN_2_TINT;
376const float B_DISABLED_MARK_TINT		= B_LIGHTEN_2_TINT;
377
378
379// Icon related constants
380
381// Values for [Set]IconBitmap() of various view classes. Not all types are
382// applicable for all views.
383enum {
384	B_INACTIVE_ICON_BITMAP					= 0x00,
385	B_ACTIVE_ICON_BITMAP					= 0x01,
386	B_PARTIALLY_ACTIVATE_ICON_BITMAP		= 0x02,
387
388	// flag, can be combined with any of the above
389	B_DISABLED_ICON_BITMAP					= 0x80,
390		// disabled version of the specified bitmap
391};
392
393// flags for SetIconBitmap() of various view classes
394enum {
395	B_KEEP_ICON_BITMAP						= 0x0001,
396		// transfer bitmap ownership to the view
397};
398
399// flags for SetIcon() of various view classes
400enum {
401	B_TRIM_ICON_BITMAP						= 0x0100,
402		// crop the bitmap to the not fully transparent area; may change the
403		// icon size
404	B_TRIM_ICON_BITMAP_KEEP_ASPECT			= 0x0200,
405		// like B_TRIM_BITMAP, but keeps the aspect ratio
406	B_CREATE_ACTIVE_ICON_BITMAP				= 0x0400,
407	B_CREATE_PARTIALLY_ACTIVE_ICON_BITMAP	= 0x0800,
408	B_CREATE_DISABLED_ICON_BITMAPS			= 0x1000,
409};
410
411
412status_t		get_deskbar_frame(BRect* frame);
413
414const color_map* system_colors();
415
416status_t		set_screen_space(int32 index, uint32 resolution,
417					bool save = true);
418
419status_t		get_scroll_bar_info(scroll_bar_info* info);
420status_t		set_scroll_bar_info(scroll_bar_info* info);
421
422status_t		get_mouse_type(int32* type);
423status_t		set_mouse_type(int32 type);
424status_t		get_mouse_map(mouse_map* map);
425status_t		set_mouse_map(mouse_map* map);
426status_t		get_click_speed(bigtime_t* speed);
427status_t		set_click_speed(bigtime_t speed);
428status_t		get_mouse_speed(int32* speed);
429status_t		set_mouse_speed(int32 speed);
430status_t		get_mouse_acceleration(int32* speed);
431status_t		set_mouse_acceleration(int32 speed);
432
433status_t		get_key_repeat_rate(int32* rate);
434status_t		set_key_repeat_rate(int32 rate);
435status_t		get_key_repeat_delay(bigtime_t* delay);
436status_t		set_key_repeat_delay(bigtime_t delay);
437
438uint32			modifiers();
439status_t		get_key_info(key_info* info);
440void			get_key_map(key_map** _map, char** _keyBuffer);
441status_t		get_keyboard_id(uint16* _id);
442status_t		get_modifier_key(uint32 modifier, uint32 *key);
443void			set_modifier_key(uint32 modifier, uint32 key);
444void			set_keyboard_locks(uint32 modifiers);
445
446rgb_color		keyboard_navigation_color();
447
448int32			count_workspaces();
449void			set_workspace_count(int32 count);
450int32			current_workspace();
451void			activate_workspace(int32 workspace);
452
453bigtime_t		idle_time();
454
455void			run_select_printer_panel();
456void			run_add_printer_panel();
457void			run_be_about();
458
459void			set_focus_follows_mouse(bool follow);
460bool			focus_follows_mouse();
461
462void			set_mouse_mode(mode_mouse mode);
463mode_mouse		mouse_mode();
464
465void			set_focus_follows_mouse_mode(mode_focus_follows_mouse mode);
466mode_focus_follows_mouse	focus_follows_mouse_mode();
467
468status_t		get_mouse(BPoint* screenWhere, uint32* buttons);
469status_t		get_mouse_bitmap(BBitmap** bitmap, BPoint* hotspot);
470
471void			set_accept_first_click(bool acceptFirstClick);
472bool			accept_first_click();
473
474rgb_color		ui_color(color_which which);
475const char*		ui_color_name(color_which which);
476color_which		which_ui_color(const char* name);
477void			set_ui_color(const color_which& which, const rgb_color& color);
478void			set_ui_colors(const BMessage* colors);
479rgb_color		tint_color(rgb_color color, float tint);
480
481extern "C" status_t _init_interface_kit_();
482	// for convenience, should be removed including the friend declarations
483	// in Menu.h, ...
484
485#endif	// _INTERFACE_DEFS_H
486