diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index dfa6eaf2e3..0f2fb5180b 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -44,6 +44,15 @@ const BFont *be_bold_font = &sBoldFont; const BFont *be_fixed_font = &sFixedFont; +extern "C" void +_init_global_fonts() +{ + _font_control_(&sPlainFont,AS_SET_SYSFONT_PLAIN,NULL); + _font_control_(&sBoldFont,AS_SET_SYSFONT_BOLD,NULL); + _font_control_(&sFixedFont,AS_SET_SYSFONT_FIXED,NULL); +} + + /*! \brief Private function originally used by Be. Now used for initialization \param font The font to initialize @@ -86,9 +95,7 @@ _font_control_(BFont *font, int32 cmd, void *data) link.Read(&font->fStyleID); link.Read(&font->fSize); link.Read(&font->fFace); - - // we may or may not need this ultimately - link.Read(&font->fHeight); + link.Read(&font->fFlags); } @@ -799,8 +806,23 @@ BFont::GetEdges(const char charArray[], int32 numBytes, edge_info edgeArray[]) c void BFont::GetHeight(font_height *height) const { - if (height) - *height = fHeight; + if(height) + { + // R5's version actually contacts the server in this call. The more and more + // I work with this class, the more and more I can't wait for R2 to fix it. Yeesh. + int32 code; + BPrivate::BAppServerLink link; + link.StartMessage(AS_GET_FONT_HEIGHT); + link.Attach(fFamilyID); + link.Attach(fStyleID); + link.Attach(fSize); + link.FlushWithReply(&code); + + if(code==SERVER_FALSE) + return; + + link.Read(height); + } } diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 0b9c387f8d..727c119a4d 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,6 @@ // Private definitions not placed in public headers extern "C" void _init_global_fonts(); extern "C" status_t _fini_interface_kit_(); - -#include "InputServerTypes.h" extern status_t _control_input_server_(BMessage *command, BMessage *reply); using namespace BPrivate; @@ -56,7 +55,6 @@ system_colors() return BScreen(B_MAIN_SCREEN_ID).ColorMap(); } -#ifndef COMPILE_FOR_R5 _IMPEXP_BE status_t set_screen_space(int32 index, uint32 res, bool stick) @@ -74,7 +72,7 @@ set_screen_space(int32 index, uint32 res, bool stick) } -_IMPEXP_BE status_t +status_t get_scroll_bar_info(scroll_bar_info *info) { if (info == NULL) @@ -89,7 +87,6 @@ get_scroll_bar_info(scroll_bar_info *info) return B_OK; } - _IMPEXP_BE status_t set_scroll_bar_info(scroll_bar_info *info) { @@ -105,12 +102,11 @@ set_scroll_bar_info(scroll_bar_info *info) return B_OK; } -#endif // COMPILE_FOR_R5 _IMPEXP_BE status_t get_mouse_type(int32 *type) { - BMessage command(IS_GET_MOUSE_TYPE); + BMessage command('Igmt'); BMessage reply; _control_input_server_(&command, &reply); @@ -125,21 +121,21 @@ get_mouse_type(int32 *type) _IMPEXP_BE status_t set_mouse_type(int32 type) { - BMessage command(IS_SET_MOUSE_TYPE); + BMessage command('Ismt'); BMessage reply; command.AddInt32("mouse_type", type); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE status_t get_mouse_map(mouse_map *map) { - BMessage command(IS_GET_MOUSE_MAP); + BMessage command('Igmm'); BMessage reply; const void *data = 0; - ssize_t count; + int32 count; _control_input_server_(&command, &reply); @@ -155,18 +151,17 @@ get_mouse_map(mouse_map *map) _IMPEXP_BE status_t set_mouse_map(mouse_map *map) { - BMessage command(IS_SET_MOUSE_MAP); + BMessage command('Ismm'); BMessage reply; command.AddData("mousemap", B_ANY_TYPE, map, sizeof(mouse_map)); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } - _IMPEXP_BE status_t get_click_speed(bigtime_t *speed) { - BMessage command(IS_GET_CLICK_SPEED); + BMessage command('Igcs'); BMessage reply; _control_input_server_(&command, &reply); @@ -181,17 +176,17 @@ get_click_speed(bigtime_t *speed) _IMPEXP_BE status_t set_click_speed(bigtime_t speed) { - BMessage command(IS_SET_CLICK_SPEED); + BMessage command('Iscs'); BMessage reply; command.AddInt64("speed", speed); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE status_t get_mouse_speed(int32 *speed) { - BMessage command(IS_GET_MOUSE_SPEED); + BMessage command('Igms'); BMessage reply; _control_input_server_(&command, &reply); @@ -206,17 +201,17 @@ get_mouse_speed(int32 *speed) _IMPEXP_BE status_t set_mouse_speed(int32 speed) { - BMessage command(IS_SET_MOUSE_SPEED); + BMessage command('Isms'); BMessage reply; command.AddInt32("speed", speed); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE status_t get_mouse_acceleration(int32 *speed) { - BMessage command(IS_GET_MOUSE_ACCELERATION); + BMessage command('Igma'); BMessage reply; _control_input_server_(&command, &reply); @@ -231,17 +226,17 @@ get_mouse_acceleration(int32 *speed) _IMPEXP_BE status_t set_mouse_acceleration(int32 speed) { - BMessage command(IS_SET_MOUSE_ACCELERATION); + BMessage command('Isma'); BMessage reply; command.AddInt32("speed", speed); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE status_t get_key_repeat_rate(int32 *rate) { - BMessage command(IS_GET_KEY_REPEAT_RATE); + BMessage command('Igrr'); BMessage reply; _control_input_server_(&command, &reply); @@ -256,17 +251,17 @@ get_key_repeat_rate(int32 *rate) _IMPEXP_BE status_t set_key_repeat_rate(int32 rate) { - BMessage command(IS_SET_KEY_REPEAT_RATE); + BMessage command('Isrr'); BMessage reply; command.AddInt32("rate", rate); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE status_t get_key_repeat_delay(bigtime_t *delay) { - BMessage command(IS_GET_KEY_REPEAT_DELAY); + BMessage command('Igrd'); BMessage reply; _control_input_server_(&command, &reply); @@ -281,17 +276,17 @@ get_key_repeat_delay(bigtime_t *delay) _IMPEXP_BE status_t set_key_repeat_delay(bigtime_t delay) { - BMessage command(IS_SET_KEY_REPEAT_DELAY); + BMessage command('Isrd'); BMessage reply; command.AddInt64("delay", delay); - return _control_input_server_(&command, &reply); + return _control_input_server_(&command, &reply) == B_OK; } _IMPEXP_BE uint32 modifiers() { - BMessage command(IS_GET_MODIFIERS); + BMessage command('Igmd'); BMessage reply; int32 err, modifier; @@ -310,11 +305,10 @@ modifiers() _IMPEXP_BE status_t get_key_info(key_info *info) { - BMessage command(IS_GET_KEY_INFO); + BMessage command('Igki'); BMessage reply; const void *data = 0; - int32 err; - ssize_t count; + int32 count, err; _control_input_server_(&command, &reply); @@ -332,9 +326,9 @@ get_key_info(key_info *info) _IMPEXP_BE void get_key_map(key_map **map, char **key_buffer) { - BMessage command(IS_GET_KEY_MAP); + BMessage command('Igkm'); BMessage reply; - ssize_t map_count, key_count; + int32 map_count, key_count; const void *map_array = 0, *key_array = 0; _control_input_server_(&command, &reply); @@ -361,7 +355,7 @@ get_key_map(key_map **map, char **key_buffer) _IMPEXP_BE status_t get_keyboard_id(uint16 *id) { - BMessage command(IS_GET_KEYBOARD_ID); + BMessage command('Igid'); BMessage reply; uint16 kid; @@ -377,7 +371,7 @@ get_keyboard_id(uint16 *id) _IMPEXP_BE void set_modifier_key(uint32 modifier, uint32 key) { - BMessage command(IS_SET_MODIFIER_KEY); + BMessage command('Ismk'); BMessage reply; command.AddInt32("modifier", modifier); @@ -389,7 +383,7 @@ set_modifier_key(uint32 modifier, uint32 key) _IMPEXP_BE void set_keyboard_locks(uint32 modifiers) { - BMessage command(IS_SET_KEYBOARD_LOCKS); + BMessage command('Iskl'); BMessage reply; command.AddInt32("locks", modifiers); @@ -397,16 +391,6 @@ set_keyboard_locks(uint32 modifiers) } -_IMPEXP_BE status_t -_restore_key_map_() -{ - BMessage message(IS_RESTORE_KEY_MAP); - BMessage reply; - - return _control_input_server_(&message, &reply); -} - - _IMPEXP_BE rgb_color keyboard_navigation_color() { @@ -415,8 +399,6 @@ keyboard_navigation_color() } -#ifndef COMPILE_FOR_R5 - _IMPEXP_BE int32 count_workspaces() { @@ -569,7 +551,6 @@ ui_color(color_which which) return color; } - _IMPEXP_BE rgb_color tint_color(rgb_color color, float tint) { @@ -578,12 +559,15 @@ tint_color(rgb_color color, float tint) #define LIGHTEN(x) ((uint8)(255.0f - (255.0f - x) * tint)) #define DARKEN(x) ((uint8)(x * (2 - tint))) - if (tint < 1.0f) { + if (tint < 1.0f) + { result.red = LIGHTEN(color.red); result.green = LIGHTEN(color.green); result.blue = LIGHTEN(color.blue); result.alpha = color.alpha; - } else { + } + else + { result.red = DARKEN(color.red); result.green = DARKEN(color.green); result.blue = DARKEN(color.blue); @@ -606,12 +590,14 @@ _init_interface_kit_() BTextView::sWidthSem = widthSem; BTextView::sWidthAtom = 0; BTextView::sWidths = new _BWidthBuffer_; + + status_t result = get_menu_info(&BMenu::sMenuInfo); + if (result != B_OK) + return result; - // TODO: get_menu_info() copies the BMenu::sMenuInfo struct - // to the passed menu_info, so we can't use it here. - // We should probably load the ui settings from the disk - - // TODO: fill the other static members + _init_global_fonts(); + + //TODO: fill the other static members return B_OK; } @@ -626,14 +612,6 @@ _fini_interface_kit_() } -extern "C" void -_init_global_fonts() -{ - // This function will initialize the client-side font list - // TODO: Implement -} - - /*! \brief private function used by Tracker to set window decor \param theme The theme to choose @@ -643,8 +621,7 @@ _init_global_fonts() - \c 2: Win95 - \c 3: MacOS */ -void -__set_window_decor(int32 theme) +void __set_window_decor(int32 theme) { BAppServerLink link; link.StartMessage(AS_R5_SET_DECORATOR); @@ -652,4 +629,12 @@ __set_window_decor(int32 theme) link.Flush(); } -#endif // COMPILE_FOR_R5 + +_IMPEXP_BE status_t +_restore_key_map_() +{ + BMessage message('Iskm'); + BMessage reply; + + return _control_input_server_(&message, &reply); +}