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