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