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