* Cleaned up InterfaceDefs.h, added TODO about getting rid of declaring

_init_interface_kit_() in there.
* Moved private get_mode_parameter() into the BPrivate namespace.
* Renamed interface_misc.h to InterfacePrivate.h.
* Minor other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-04-09 10:07:35 +00:00
parent 3daf03d3ab
commit cfc3fa87da
6 changed files with 250 additions and 239 deletions
+135 -134
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2006, Haiku, Inc. * Copyright (c) 2001-2008, Haiku, Inc.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -34,7 +34,7 @@ class BRect;
#endif #endif
// key definitions // Key definitions
struct key_info { struct key_info {
uint32 modifiers; uint32 modifiers;
@@ -119,12 +119,54 @@ struct key_map {
uint32 tilde_tables; uint32 tilde_tables;
}; };
enum {
B_CONTROL_TABLE = 0x00000001,
B_OPTION_CAPS_SHIFT_TABLE = 0x00000002,
B_OPTION_CAPS_TABLE = 0x00000004,
B_OPTION_SHIFT_TABLE = 0x00000008,
B_OPTION_TABLE = 0x00000010,
B_CAPS_SHIFT_TABLE = 0x00000020,
B_CAPS_TABLE = 0x00000040,
B_SHIFT_TABLE = 0x00000080,
B_NORMAL_TABLE = 0x00000100
};
// modifiers
enum {
B_SHIFT_KEY = 0x00000001,
B_COMMAND_KEY = 0x00000002,
B_CONTROL_KEY = 0x00000004,
B_CAPS_LOCK = 0x00000008,
B_SCROLL_LOCK = 0x00000010,
B_NUM_LOCK = 0x00000020,
B_OPTION_KEY = 0x00000040,
B_MENU_KEY = 0x00000080,
B_LEFT_SHIFT_KEY = 0x00000100,
B_RIGHT_SHIFT_KEY = 0x00000200,
B_LEFT_COMMAND_KEY = 0x00000400,
B_RIGHT_COMMAND_KEY = 0x00000800,
B_LEFT_CONTROL_KEY = 0x00001000,
B_RIGHT_CONTROL_KEY = 0x00002000,
B_LEFT_OPTION_KEY = 0x00004000,
B_RIGHT_OPTION_KEY = 0x00008000
};
// Mouse definitions
struct mouse_map { struct mouse_map {
uint32 button[B_MAX_MOUSE_BUTTONS]; uint32 button[B_MAX_MOUSE_BUTTONS];
}; };
enum mode_mouse {
B_NORMAL_MOUSE = 0,
B_FOCUS_FOLLOWS_MOUSE = 1,
B_WARP_MOUSE = 3,
B_INSTANT_WARP_MOUSE = 7
};
/*----------------------------------------------------------------*/
// View orientation/alignment/style
enum border_style { enum border_style {
B_PLAIN_BORDER, B_PLAIN_BORDER,
@@ -132,41 +174,17 @@ enum border_style {
B_NO_BORDER B_NO_BORDER
}; };
/*----------------------------------------------------------------*/
enum orientation { enum orientation {
B_HORIZONTAL, B_HORIZONTAL,
B_VERTICAL B_VERTICAL
}; };
/*----------------------------------------------------------------*/
enum button_width { enum button_width {
B_WIDTH_AS_USUAL, B_WIDTH_AS_USUAL,
B_WIDTH_FROM_WIDEST, B_WIDTH_FROM_WIDEST,
B_WIDTH_FROM_LABEL B_WIDTH_FROM_LABEL
}; };
/*----------------------------------------------------------------*/
enum join_mode {
B_ROUND_JOIN = 0,
B_MITER_JOIN,
B_BEVEL_JOIN,
B_BUTT_JOIN,
B_SQUARE_JOIN
};
enum cap_mode {
B_ROUND_CAP=B_ROUND_JOIN,
B_BUTT_CAP=B_BUTT_JOIN,
B_SQUARE_CAP=B_SQUARE_JOIN
};
const float B_DEFAULT_MITER_LIMIT = 10.0F;
/*----------------------------------------------------------------*/
struct scroll_bar_info { struct scroll_bar_info {
bool proportional; bool proportional;
bool double_arrows; bool double_arrows;
@@ -174,8 +192,6 @@ struct scroll_bar_info {
int32 min_knob_size; int32 min_knob_size;
}; };
/*----------------------------------------------------------------*/
enum alignment { enum alignment {
B_ALIGN_LEFT, B_ALIGN_LEFT,
B_ALIGN_RIGHT, B_ALIGN_RIGHT,
@@ -199,42 +215,27 @@ enum vertical_alignment {
B_ALIGN_USE_FULL_HEIGHT = -2L B_ALIGN_USE_FULL_HEIGHT = -2L
}; };
/*----------------------------------------------------------------*/
enum { // Line join and cap modes
B_CONTROL_TABLE = 0x00000001,
B_OPTION_CAPS_SHIFT_TABLE = 0x00000002, enum join_mode {
B_OPTION_CAPS_TABLE = 0x00000004, B_ROUND_JOIN = 0,
B_OPTION_SHIFT_TABLE = 0x00000008, B_MITER_JOIN,
B_OPTION_TABLE = 0x00000010, B_BEVEL_JOIN,
B_CAPS_SHIFT_TABLE = 0x00000020, B_BUTT_JOIN,
B_CAPS_TABLE = 0x00000040, B_SQUARE_JOIN
B_SHIFT_TABLE = 0x00000080,
B_NORMAL_TABLE = 0x00000100
}; };
/*----------------------------------------------------------------*/ enum cap_mode {
B_ROUND_CAP = B_ROUND_JOIN,
enum { B_BUTT_CAP = B_BUTT_JOIN,
B_SHIFT_KEY = 0x00000001, B_SQUARE_CAP = B_SQUARE_JOIN
B_COMMAND_KEY = 0x00000002,
B_CONTROL_KEY = 0x00000004,
B_CAPS_LOCK = 0x00000008,
B_SCROLL_LOCK = 0x00000010,
B_NUM_LOCK = 0x00000020,
B_OPTION_KEY = 0x00000040,
B_MENU_KEY = 0x00000080,
B_LEFT_SHIFT_KEY = 0x00000100,
B_RIGHT_SHIFT_KEY = 0x00000200,
B_LEFT_COMMAND_KEY = 0x00000400,
B_RIGHT_COMMAND_KEY = 0x00000800,
B_LEFT_CONTROL_KEY = 0x00001000,
B_RIGHT_CONTROL_KEY = 0x00002000,
B_LEFT_OPTION_KEY = 0x00004000,
B_RIGHT_OPTION_KEY = 0x00008000
}; };
/*----------------------------------------------------------------*/ const float B_DEFAULT_MITER_LIMIT = 10.0F;
// Bitmap and overlay constants
enum bitmap_tiling { enum bitmap_tiling {
B_TILE_BITMAP_X = 0x00000001, B_TILE_BITMAP_X = 0x00000001,
@@ -249,66 +250,8 @@ enum overlay_options {
B_OVERLAY_TRANSFER_CHANNEL = 0x00080000 B_OVERLAY_TRANSFER_CHANNEL = 0x00080000
}; };
/*----------------------------------------------------------------*/
status_t get_deskbar_frame(BRect *frame); // Default UI Colors
const color_map *system_colors();
status_t set_screen_space(int32 index, uint32 res,
bool stick = true);
status_t get_scroll_bar_info(scroll_bar_info *info);
status_t set_scroll_bar_info(scroll_bar_info *info);
status_t get_mouse_type(int32 *type);
status_t set_mouse_type(int32 type);
status_t get_mouse_map(mouse_map *map);
status_t set_mouse_map(mouse_map *map);
status_t get_click_speed(bigtime_t *speed);
status_t set_click_speed(bigtime_t speed);
status_t get_mouse_speed(int32 *speed);
status_t set_mouse_speed(int32 speed);
status_t get_mouse_acceleration(int32 *speed);
status_t set_mouse_acceleration(int32 speed);
status_t get_key_repeat_rate(int32 *rate);
status_t set_key_repeat_rate(int32 rate);
status_t get_key_repeat_delay(bigtime_t *delay);
status_t set_key_repeat_delay(bigtime_t delay);
uint32 modifiers();
status_t get_key_info(key_info *info);
void get_key_map(key_map **map, char **key_buffer);
status_t get_keyboard_id(uint16 *id);
void set_modifier_key(uint32 modifier, uint32 key);
void set_keyboard_locks(uint32 modifiers);
rgb_color keyboard_navigation_color();
int32 count_workspaces();
void set_workspace_count(int32 count);
int32 current_workspace();
void activate_workspace(int32 workspace);
bigtime_t idle_time();
void run_select_printer_panel();
void run_add_printer_panel();
void run_be_about();
void set_focus_follows_mouse(bool follow);
bool focus_follows_mouse();
enum mode_mouse {
B_NORMAL_MOUSE = 0,
B_FOCUS_FOLLOWS_MOUSE = 1,
B_WARP_MOUSE = 3,
B_INSTANT_WARP_MOUSE = 7
};
void set_mouse_mode(mode_mouse mode);
mode_mouse mouse_mode();
enum color_which { enum color_which {
B_PANEL_BACKGROUND_COLOR = 1, B_PANEL_BACKGROUND_COLOR = 1,
@@ -350,27 +293,85 @@ enum color_which {
B_WINDOW_INACTIVE_TEXT_COLOR = 24 B_WINDOW_INACTIVE_TEXT_COLOR = 24
}; };
rgb_color ui_color(color_which which);
void set_ui_color(const color_which &which,
const rgb_color &color);
rgb_color tint_color(rgb_color color, float tint);
extern "C" status_t _init_interface_kit_(); // Color tinting
/* effects on standard gray level */
const float B_LIGHTEN_MAX_TINT = 0.0F; /* 216 --> 255.0 (255) */
const float B_LIGHTEN_2_TINT = 0.385F; /* 216 --> 240.0 (240) */
const float B_LIGHTEN_1_TINT = 0.590F; /* 216 --> 232.0 (232) */
const float B_NO_TINT = 1.0F; /* 216 --> 216.0 (216) */ const float B_LIGHTEN_MAX_TINT = 0.0f; // 216 --> 255.0 (255)
const float B_LIGHTEN_2_TINT = 0.385f; // 216 --> 240.0 (240)
const float B_LIGHTEN_1_TINT = 0.590f; // 216 --> 232.0 (232)
const float B_DARKEN_1_TINT = 1.147F; /* 216 --> 184.2 (184) */ const float B_NO_TINT = 1.0f; // 216 --> 216.0 (216)
const float B_DARKEN_2_TINT = 1.295F; /* 216 --> 152.3 (152) */
const float B_DARKEN_3_TINT = 1.407F; /* 216 --> 128.1 (128) */ const float B_DARKEN_1_TINT = 1.147f; // 216 --> 184.2 (184)
const float B_DARKEN_4_TINT = 1.555F; /* 216 --> 96.1 (96) */ const float B_DARKEN_2_TINT = 1.295f; // 216 --> 152.3 (152)
const float B_DARKEN_MAX_TINT = 2.0F; /* 216 --> 0.0 (0) */ const float B_DARKEN_3_TINT = 1.407f; // 216 --> 128.1 (128)
const float B_DARKEN_4_TINT = 1.555f; // 216 --> 96.1 (96)
const float B_DARKEN_MAX_TINT = 2.0f; // 216 --> 0.0 (0)
// effects on standard gray level
const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT; const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT;
const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT; const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT;
const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT; const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT;
status_t get_deskbar_frame(BRect* frame);
const color_map* system_colors();
status_t set_screen_space(int32 index, uint32 resolution,
bool save = true);
status_t get_scroll_bar_info(scroll_bar_info* info);
status_t set_scroll_bar_info(scroll_bar_info* info);
status_t get_mouse_type(int32* type);
status_t set_mouse_type(int32 type);
status_t get_mouse_map(mouse_map* map);
status_t set_mouse_map(mouse_map* map);
status_t get_click_speed(bigtime_t* speed);
status_t set_click_speed(bigtime_t speed);
status_t get_mouse_speed(int32* speed);
status_t set_mouse_speed(int32 speed);
status_t get_mouse_acceleration(int32* speed);
status_t set_mouse_acceleration(int32 speed);
status_t get_key_repeat_rate(int32* rate);
status_t set_key_repeat_rate(int32 rate);
status_t get_key_repeat_delay(bigtime_t* delay);
status_t set_key_repeat_delay(bigtime_t delay);
uint32 modifiers();
status_t get_key_info(key_info* info);
void get_key_map(key_map** _map, char** _keyBuffer);
status_t get_keyboard_id(uint16* _id);
void set_modifier_key(uint32 modifier, uint32 key);
void set_keyboard_locks(uint32 modifiers);
rgb_color keyboard_navigation_color();
int32 count_workspaces();
void set_workspace_count(int32 count);
int32 current_workspace();
void activate_workspace(int32 workspace);
bigtime_t idle_time();
void run_select_printer_panel();
void run_add_printer_panel();
void run_be_about();
void set_focus_follows_mouse(bool follow);
bool focus_follows_mouse();
void set_mouse_mode(mode_mouse mode);
mode_mouse mouse_mode();
rgb_color ui_color(color_which which);
void set_ui_color(const color_which& which, const rgb_color& color);
rgb_color tint_color(rgb_color color, float tint);
extern "C" status_t _init_interface_kit_();
// for convenience, should be removed including the friend declarations
// in Menu.h, ...
#endif // _INTERFACE_DEFS_H #endif // _INTERFACE_DEFS_H
@@ -0,0 +1,23 @@
/*
* Copyright 2007-2008, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini <[email protected]>
*/
#ifndef _INTERFACE_PRIVATE_H
#define _INTERFACE_PRIVATE_H
#include <SupportDefs.h>
namespace BPrivate {
bool get_mode_parameter(uint32 mode, int32& width, int32& height,
uint32& colorSpace);
} // namespace BPrivate
#endif // _INTERFACE_PRIVATE_H
@@ -1,20 +0,0 @@
/*
* Copyright 2007, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini <[email protected]>
*/
/** Various private functions and variables for the Interface Kit */
#ifndef __INTERFACE_MISC_H
#define __INTERFACE_MISC_H
#include <SupportDefs.h>
bool get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace);
#endif
+28 -25
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku. * Copyright 2001-2008, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -9,6 +9,29 @@
*/ */
#include <Application.h>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <Alert.h>
#include <AppFileInfo.h>
#include <Cursor.h>
#include <Debug.h>
#include <Entry.h>
#include <File.h>
#include <Locker.h>
#include <MessageRunner.h>
#include <Path.h>
#include <PropertyInfo.h>
#include <RegistrarDefs.h>
#include <Resources.h>
#include <Roster.h>
#include <Window.h>
#include <AppMisc.h> #include <AppMisc.h>
#include <AppServerLink.h> #include <AppServerLink.h>
#include <AutoLocker.h> #include <AutoLocker.h>
@@ -20,30 +43,9 @@
#include <ServerMemoryAllocator.h> #include <ServerMemoryAllocator.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
#include <Alert.h>
#include <AppFileInfo.h>
#include <Application.h>
#include <MessageRunner.h>
#include <Cursor.h>
#include <Debug.h>
#include <Entry.h>
#include <File.h>
#include <Locker.h>
#include <Path.h>
#include <PropertyInfo.h>
#include <RegistrarDefs.h>
#include <Resources.h>
#include <Roster.h>
#include <Window.h>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
using namespace BPrivate; using namespace BPrivate;
BApplication *be_app = NULL; BApplication *be_app = NULL;
BMessenger be_app_messenger; BMessenger be_app_messenger;
@@ -1227,8 +1229,9 @@ BApplication::_InitGUIContext()
if (error != B_OK) if (error != B_OK)
return error; return error;
// Initialize the IK after we have set be_app because of a construction of a // Initialize the IK after we have set be_app because of a construction
// AppServerLink (which depends on be_app) nested inside the call to get_menu_info. // of a AppServerLink (which depends on be_app) nested inside the call
// to get_menu_info.
error = _init_interface_kit_(); error = _init_interface_kit_();
if (error != B_OK) if (error != B_OK)
return error; return error;
+11 -11
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007, Haiku. All Rights Reserved. * Copyright 2002-2008, Haiku. All Rights Reserved.
* Copyright 2002-2005, * Copyright 2002-2005,
* Marcus Overhagen, * Marcus Overhagen,
* Stefano Ceccherini (stefano.ceccherini@gmail.com), * Stefano Ceccherini (stefano.ceccherini@gmail.com),
@@ -10,24 +10,24 @@
*/ */
#include <Application.h>
#include <Screen.h>
#include <String.h>
#include <WindowScreen.h> #include <WindowScreen.h>
#include <new>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <new> #include <Application.h>
#include <Screen.h>
#include <input_globals.h> #include <String.h>
#include <InputServerTypes.h> // For IS_SET_MOUSE_POSITION
#include <interface_misc.h>
#include <WindowPrivate.h>
#include <AppServerLink.h> #include <AppServerLink.h>
#include <input_globals.h>
#include <InputServerTypes.h>
#include <InterfacePrivate.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
#include <WindowPrivate.h>
using BPrivate::AppServerLink; using BPrivate::AppServerLink;
@@ -902,7 +902,7 @@ BWindowScreen::_GetModeFromSpace(uint32 space, display_mode *dmode)
int32 width, height; int32 width, height;
uint32 colorSpace; uint32 colorSpace;
if (!get_mode_parameter(space, width, height, colorSpace)) if (!BPrivate::get_mode_parameter(space, width, height, colorSpace))
return B_BAD_VALUE; return B_BAD_VALUE;
for (uint32 i = 0; i < fModeCount; i++) { for (uint32 i = 0; i < fModeCount; i++) {
+24 -20
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2006, Haiku, Inc. * Copyright 2001-2008, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -8,23 +8,13 @@
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
*/ */
/** Global functions and variables for the Interface Kit */ /*! Global functions and variables for the Interface Kit */
#include <interface_misc.h> #include <InterfacePrivate.h>
#include <truncate_string.h>
#include <utf8_functions.h>
#include <ApplicationPrivate.h> #include <stdio.h>
#include <AppServerLink.h> #include <stdlib.h>
#include <ColorConversion.h> #include <string.h>
#include <DefaultColors.h>
#include <InputServerTypes.h>
#include <input_globals.h>
#include <pr_server.h>
#include <ServerProtocol.h>
#include <ServerReadOnlyMemory.h>
#include <WidthBuffer.h>
#include <WindowInfo.h>
#include <Font.h> #include <Font.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
@@ -35,9 +25,19 @@
#include <String.h> #include <String.h>
#include <TextView.h> #include <TextView.h>
#include <stdio.h> #include <ApplicationPrivate.h>
#include <stdlib.h> #include <AppServerLink.h>
#include <string.h> #include <ColorConversion.h>
#include <DefaultColors.h>
#include <InputServerTypes.h>
#include <input_globals.h>
#include <pr_server.h>
#include <ServerProtocol.h>
#include <ServerReadOnlyMemory.h>
#include <truncate_string.h>
#include <utf8_functions.h>
#include <WidthBuffer.h>
#include <WindowInfo.h>
// Private definitions not placed in public headers // Private definitions not placed in public headers
@@ -94,6 +94,8 @@ static const rgb_color _kDefaultColors[kNumColors] = {
const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0]; const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0];
namespace BPrivate {
/*! /*!
Fills the \a width, \a height, and \a colorSpace parameters according Fills the \a width, \a height, and \a colorSpace parameters according
to the window screen's mode. to the window screen's mode.
@@ -190,6 +192,8 @@ get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace)
return true; return true;
} }
} // namespace BPrivate
const color_map * const color_map *
system_colors() system_colors()
@@ -204,7 +208,7 @@ set_screen_space(int32 index, uint32 space, bool stick)
int32 width; int32 width;
int32 height; int32 height;
uint32 depth; uint32 depth;
if (!get_mode_parameter(space, width, height, depth)) if (!BPrivate::get_mode_parameter(space, width, height, depth))
return B_BAD_VALUE; return B_BAD_VALUE;
BScreen screen(B_MAIN_SCREEN_ID); BScreen screen(B_MAIN_SCREEN_ID);