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 class BRect; 13 14 15 // some handy UTF-8 characters 16 17 #define B_UTF8_BULLET "\xE2\x80\xA2" 18 #define B_UTF8_ELLIPSIS "\xE2\x80\xA6" 19 #define B_UTF8_OPEN_QUOTE "\xE2\x80\x9C" 20 #define B_UTF8_CLOSE_QUOTE "\xE2\x80\x9D" 21 #define B_UTF8_COPYRIGHT "\xC2\xA9" 22 #define B_UTF8_REGISTERED "\xC2\xAE" 23 #define B_UTF8_TRADEMARK "\xE2\x84\xA2" 24 #define B_UTF8_SMILING_FACE "\xE2\x98\xBB" 25 #define B_UTF8_HIROSHI "\xE5\xBC\x98" 26 #ifdef COMPILE_FOR_R5 27 #define B_MAX_MOUSE_BUTTONS 3 28 #else 29 #define B_MAX_MOUSE_BUTTONS 16 30 #endif 31 32 33 // Key definitions 34 35 struct key_info { 36 uint32 modifiers; 37 uint8 key_states[16]; 38 }; 39 40 enum { 41 B_BACKSPACE = 0x08, 42 B_RETURN = 0x0a, 43 B_ENTER = 0x0a, 44 B_SPACE = 0x20, 45 B_TAB = 0x09, 46 B_ESCAPE = 0x1b, 47 B_SUBSTITUTE = 0x1a, 48 49 B_LEFT_ARROW = 0x1c, 50 B_RIGHT_ARROW = 0x1d, 51 B_UP_ARROW = 0x1e, 52 B_DOWN_ARROW = 0x1f, 53 54 B_INSERT = 0x05, 55 B_DELETE = 0x7f, 56 B_HOME = 0x01, 57 B_END = 0x04, 58 B_PAGE_UP = 0x0b, 59 B_PAGE_DOWN = 0x0c, 60 61 B_FUNCTION_KEY = 0x10, 62 63 // for Japanese keyboards 64 B_KATAKANA_HIRAGANA = 0xf2, 65 B_HANKAKU_ZENKAKU = 0xf3 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_CLICK_TO_FOCUS_MOUSE = -1, 164 B_FOCUS_FOLLOWS_MOUSE = 1 165 }; 166 167 enum mode_focus_follows_mouse { 168 B_NORMAL_FOCUS_FOLLOWS_MOUSE = 0, 169 B_WARP_FOCUS_FOLLOWS_MOUSE = 1, 170 B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE = 2 171 }; 172 173 174 // View orientation/alignment/style 175 176 enum border_style { 177 B_PLAIN_BORDER, 178 B_FANCY_BORDER, 179 B_NO_BORDER 180 }; 181 182 enum orientation { 183 B_HORIZONTAL, 184 B_VERTICAL 185 }; 186 187 enum button_width { 188 B_WIDTH_AS_USUAL, 189 B_WIDTH_FROM_WIDEST, 190 B_WIDTH_FROM_LABEL 191 }; 192 193 struct scroll_bar_info { 194 bool proportional; 195 bool double_arrows; 196 int32 knob; 197 int32 min_knob_size; 198 }; 199 200 enum alignment { 201 B_ALIGN_LEFT, 202 B_ALIGN_RIGHT, 203 B_ALIGN_CENTER, 204 205 B_ALIGN_HORIZONTAL_CENTER = B_ALIGN_CENTER, 206 207 B_ALIGN_HORIZONTAL_UNSET = -1L, 208 B_ALIGN_USE_FULL_WIDTH = -2L 209 }; 210 211 enum vertical_alignment { 212 B_ALIGN_TOP = 0x10L, 213 B_ALIGN_MIDDLE = 0x20, 214 B_ALIGN_BOTTOM = 0x30, 215 216 B_ALIGN_VERTICAL_CENTER = B_ALIGN_MIDDLE, 217 218 B_ALIGN_VERTICAL_UNSET = -1L, 219 B_ALIGN_NO_VERTICAL = B_ALIGN_VERTICAL_UNSET, 220 B_ALIGN_USE_FULL_HEIGHT = -2L 221 }; 222 223 224 // Line join and cap modes 225 226 enum join_mode { 227 B_ROUND_JOIN = 0, 228 B_MITER_JOIN, 229 B_BEVEL_JOIN, 230 B_BUTT_JOIN, 231 B_SQUARE_JOIN 232 }; 233 234 enum cap_mode { 235 B_ROUND_CAP = B_ROUND_JOIN, 236 B_BUTT_CAP = B_BUTT_JOIN, 237 B_SQUARE_CAP = B_SQUARE_JOIN 238 }; 239 240 const float B_DEFAULT_MITER_LIMIT = 10.0F; 241 242 243 // Bitmap and overlay constants 244 245 enum bitmap_tiling { 246 B_TILE_BITMAP_X = 0x00000001, 247 B_TILE_BITMAP_Y = 0x00000002, 248 B_TILE_BITMAP = 0x00000003 249 }; 250 251 enum overlay_options { 252 B_OVERLAY_FILTER_HORIZONTAL = 0x00010000, 253 B_OVERLAY_FILTER_VERTICAL = 0x00020000, 254 B_OVERLAY_MIRROR = 0x00040000, 255 B_OVERLAY_TRANSFER_CHANNEL = 0x00080000 256 }; 257 258 enum bitmap_filtering { 259 B_FILTER_BITMAP_BILINEAR = 0x00000100 260 // TODO: Make this simply "SMOOTH_SCALE" and use 261 // better quality methods the faster the computer? 262 }; 263 264 // Default UI Colors 265 266 enum color_which { 267 B_PANEL_BACKGROUND_COLOR = 1, 268 B_PANEL_TEXT_COLOR = 10, 269 B_DOCUMENT_BACKGROUND_COLOR = 11, 270 B_DOCUMENT_TEXT_COLOR = 12, 271 B_CONTROL_BACKGROUND_COLOR = 13, 272 B_CONTROL_TEXT_COLOR = 14, 273 B_CONTROL_BORDER_COLOR = 15, 274 B_CONTROL_HIGHLIGHT_COLOR = 16, 275 B_NAVIGATION_BASE_COLOR = 4, 276 B_NAVIGATION_PULSE_COLOR = 17, 277 B_SHINE_COLOR = 18, 278 B_SHADOW_COLOR = 19, 279 280 B_MENU_BACKGROUND_COLOR = 2, 281 B_MENU_SELECTED_BACKGROUND_COLOR = 6, 282 B_MENU_ITEM_TEXT_COLOR = 7, 283 B_MENU_SELECTED_ITEM_TEXT_COLOR = 8, 284 B_MENU_SELECTED_BORDER_COLOR = 9, 285 286 B_TOOL_TIP_BACKGROUND_COLOR = 20, 287 B_TOOL_TIP_TEXT_COLOR = 21, 288 289 B_SUCCESS_COLOR = 100, 290 B_FAILURE_COLOR = 101, 291 292 // Old name synonyms. 293 B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR, 294 B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR, 295 296 // These are deprecated -- do not use in new code. See BScreen for 297 // the replacement for B_DESKTOP_COLOR. 298 B_DESKTOP_COLOR = 5, 299 300 B_WINDOW_TAB_COLOR = 3, 301 B_WINDOW_TEXT_COLOR = 22, 302 B_WINDOW_INACTIVE_TAB_COLOR = 23, 303 B_WINDOW_INACTIVE_TEXT_COLOR = 24 304 }; 305 306 307 // Color tinting 308 309 const float B_LIGHTEN_MAX_TINT = 0.0f; // 216 --> 255.0 (255) 310 const float B_LIGHTEN_2_TINT = 0.385f; // 216 --> 240.0 (240) 311 const float B_LIGHTEN_1_TINT = 0.590f; // 216 --> 232.0 (232) 312 313 const float B_NO_TINT = 1.0f; // 216 --> 216.0 (216) 314 315 const float B_DARKEN_1_TINT = 1.147f; // 216 --> 184.2 (184) 316 const float B_DARKEN_2_TINT = 1.295f; // 216 --> 152.3 (152) 317 const float B_DARKEN_3_TINT = 1.407f; // 216 --> 128.1 (128) 318 const float B_DARKEN_4_TINT = 1.555f; // 216 --> 96.1 (96) 319 const float B_DARKEN_MAX_TINT = 2.0f; // 216 --> 0.0 (0) 320 // effects on standard gray level 321 322 const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT; 323 const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT; 324 const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT; 325 326 327 status_t get_deskbar_frame(BRect* frame); 328 329 const color_map* system_colors(); 330 331 status_t set_screen_space(int32 index, uint32 resolution, 332 bool save = true); 333 334 status_t get_scroll_bar_info(scroll_bar_info* info); 335 status_t set_scroll_bar_info(scroll_bar_info* info); 336 337 status_t get_mouse_type(int32* type); 338 status_t set_mouse_type(int32 type); 339 status_t get_mouse_map(mouse_map* map); 340 status_t set_mouse_map(mouse_map* map); 341 status_t get_click_speed(bigtime_t* speed); 342 status_t set_click_speed(bigtime_t speed); 343 status_t get_mouse_speed(int32* speed); 344 status_t set_mouse_speed(int32 speed); 345 status_t get_mouse_acceleration(int32* speed); 346 status_t set_mouse_acceleration(int32 speed); 347 348 status_t get_key_repeat_rate(int32* rate); 349 status_t set_key_repeat_rate(int32 rate); 350 status_t get_key_repeat_delay(bigtime_t* delay); 351 status_t set_key_repeat_delay(bigtime_t delay); 352 353 uint32 modifiers(); 354 status_t get_key_info(key_info* info); 355 void get_key_map(key_map** _map, char** _keyBuffer); 356 status_t get_keyboard_id(uint16* _id); 357 status_t get_modifier_key(uint32 modifier, uint32 *key); 358 void set_modifier_key(uint32 modifier, uint32 key); 359 void set_keyboard_locks(uint32 modifiers); 360 361 rgb_color keyboard_navigation_color(); 362 363 int32 count_workspaces(); 364 void set_workspace_count(int32 count); 365 int32 current_workspace(); 366 void activate_workspace(int32 workspace); 367 368 bigtime_t idle_time(); 369 370 void run_select_printer_panel(); 371 void run_add_printer_panel(); 372 void run_be_about(); 373 374 void set_focus_follows_mouse(bool follow); 375 bool focus_follows_mouse(); 376 377 void set_mouse_mode(mode_mouse mode); 378 mode_mouse mouse_mode(); 379 380 void set_focus_follows_mouse_mode(mode_focus_follows_mouse mode); 381 mode_focus_follows_mouse focus_follows_mouse_mode(); 382 383 void set_accept_first_click(bool acceptFirstClick); 384 bool accept_first_click(); 385 386 rgb_color ui_color(color_which which); 387 void set_ui_color(const color_which& which, const rgb_color& color); 388 rgb_color tint_color(rgb_color color, float tint); 389 390 extern "C" status_t _init_interface_kit_(); 391 // for convenience, should be removed including the friend declarations 392 // in Menu.h, ... 393 394 #endif // _INTERFACE_DEFS_H 395