From bd3f48e8bf4e30d57db030b03f70f713f4422426 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Mon, 1 Sep 2003 14:12:53 +0000 Subject: [PATCH] Patch submitted by Jack Burton git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4435 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Globals.cpp | 307 +++++++++++++++++++++------------ 1 file changed, 197 insertions(+), 110 deletions(-) diff --git a/src/kits/interface/Globals.cpp b/src/kits/interface/Globals.cpp index 303d5e8733..48637ffce1 100644 --- a/src/kits/interface/Globals.cpp +++ b/src/kits/interface/Globals.cpp @@ -24,359 +24,446 @@ // Description: Global functions and variables for the Interface Kit // //------------------------------------------------------------------------------ + +#include +#include +#include #include #include -#include -#include #include -#include +#include + // Private definitions not placed in public headers extern "C" void _init_global_fonts(); extern "C" status_t _fini_interface_kit_(); +using namespace BPrivate; + // InterfaceDefs.h -_IMPEXP_BE const color_map *system_colors() +_IMPEXP_BE const color_map * +system_colors() { - // Gets the color map via the BScreen class - // TODO: Implement + return BScreen(B_MAIN_SCREEN_ID).ColorMap(); } -_IMPEXP_BE status_t set_screen_space(int32 index, uint32 res, bool stick) + +_IMPEXP_BE status_t +set_screen_space(int32 index, uint32 res, bool stick) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_SET_SCREEN_MODE); - link->Attach(index); - link->Attach((int32)res); - link->Attach(stick); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_SET_SCREEN_MODE); + link.Attach(index); + link.Attach((int32)res); + link.Attach(stick); + link.Flush(); + + //TODO: Read back the status from the app_server's reply + return B_OK; } -_IMPEXP_BE status_t get_scroll_bar_info(scroll_bar_info *info) + +_IMPEXP_BE status_t +get_scroll_bar_info(scroll_bar_info *info) { PortMessage pmsg; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_GET_SCROLLBAR_INFO); - link->FlushWithReply(&pmsg); - delete link; + BAppServerLink link; + link.SetOpCode(AS_GET_SCROLLBAR_INFO); + link.FlushWithReply(&pmsg); pmsg.Read(info, sizeof(scroll_bar_info)); + //TODO: Read back the status from the app_server's reply + return B_OK; } -_IMPEXP_BE status_t set_scroll_bar_info(scroll_bar_info *info) + +_IMPEXP_BE status_t +set_scroll_bar_info(scroll_bar_info *info) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_SET_SCROLLBAR_INFO); - link->Attach(info, sizeof(scroll_bar_info)); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_SET_SCROLLBAR_INFO); + link.Attach(info, sizeof(scroll_bar_info)); + link.Flush(); + + //TODO: Read back the status from the app_server's reply + return B_OK; } -_IMPEXP_BE status_t get_mouse_type(int32 *type) + +_IMPEXP_BE status_t +get_mouse_type(int32 *type) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_mouse_type(int32 type) + +_IMPEXP_BE status_t +set_mouse_type(int32 type) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_mouse_map(mouse_map *map) + +_IMPEXP_BE status_t +get_mouse_map(mouse_map *map) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_mouse_map(mouse_map *map) + +_IMPEXP_BE status_t +set_mouse_map(mouse_map *map) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_click_speed(bigtime_t *speed) +_IMPEXP_BE status_t +get_click_speed(bigtime_t *speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_click_speed(bigtime_t speed) + +_IMPEXP_BE status_t +set_click_speed(bigtime_t speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_mouse_speed(int32 *speed) + +_IMPEXP_BE status_t +get_mouse_speed(int32 *speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_mouse_speed(int32 speed) + +_IMPEXP_BE status_t +set_mouse_speed(int32 speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_mouse_acceleration(int32 *speed) + +_IMPEXP_BE status_t +get_mouse_acceleration(int32 *speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_mouse_acceleration(int32 speed) + +_IMPEXP_BE status_t +set_mouse_acceleration(int32 speed) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_key_repeat_rate(int32 *rate) + +_IMPEXP_BE status_t +get_key_repeat_rate(int32 *rate) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_key_repeat_rate(int32 rate) + +_IMPEXP_BE status_t +set_key_repeat_rate(int32 rate) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_key_repeat_delay(bigtime_t *delay) + +_IMPEXP_BE status_t +get_key_repeat_delay(bigtime_t *delay) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t set_key_repeat_delay(bigtime_t delay) + +_IMPEXP_BE status_t +set_key_repeat_delay(bigtime_t delay) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE uint32 modifiers() + +_IMPEXP_BE uint32 +modifiers() { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_key_info(key_info *info) + +_IMPEXP_BE status_t +get_key_info(key_info *info) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE void get_key_map(key_map **map, char **key_buffer) + +_IMPEXP_BE void +get_key_map(key_map **map, char **key_buffer) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE status_t get_keyboard_id(uint16 *id) + +_IMPEXP_BE status_t +get_keyboard_id(uint16 *id) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE void set_modifier_key(uint32 modifier, uint32 key) + +_IMPEXP_BE void +set_modifier_key(uint32 modifier, uint32 key) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE void set_keyboard_locks(uint32 modifiers) + +_IMPEXP_BE void +set_keyboard_locks(uint32 modifiers) { // Contacts the input_server via _control_input_server_(BMessage *, BMessage *) // TODO: Implement } -_IMPEXP_BE rgb_color keyboard_navigation_color() + +_IMPEXP_BE rgb_color +keyboard_navigation_color() { // Queries the app_server // TODO: Implement return ui_color(B_KEYBOARD_NAVIGATION_COLOR); } -_IMPEXP_BE int32 count_workspaces() + +_IMPEXP_BE int32 +count_workspaces() { PortLink::ReplyData replydata; int32 count; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_COUNT_WORKSPACES); - link->FlushWithReply(&replydata); + BAppServerLink link; + link.SetOpCode(AS_COUNT_WORKSPACES); + link.FlushWithReply(&replydata); count=*((int32*)replydata.buffer); - delete link; return count; } -_IMPEXP_BE void set_workspace_count(int32 count) + +_IMPEXP_BE void +set_workspace_count(int32 count) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_SET_WORKSPACE_COUNT); - link->Attach(count); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_SET_WORKSPACE_COUNT); + link.Attach(count); + link.Flush(); + } -_IMPEXP_BE int32 current_workspace() + +_IMPEXP_BE int32 +current_workspace() { PortLink::ReplyData replydata; int32 index; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_CURRENT_WORKSPACE); - link->FlushWithReply(&replydata); + BAppServerLink link; + link.SetOpCode(AS_CURRENT_WORKSPACE); + link.FlushWithReply(&replydata); index=*((int32*)replydata.buffer); - delete link; return index; } -_IMPEXP_BE void activate_workspace(int32 workspace) + +_IMPEXP_BE void +activate_workspace(int32 workspace) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_ACTIVATE_WORKSPACE); - link->Attach(workspace); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_ACTIVATE_WORKSPACE); + link.Attach(workspace); + link.Flush(); } -_IMPEXP_BE bigtime_t idle_time() + +_IMPEXP_BE bigtime_t +idle_time() { PortLink::ReplyData replydata; bigtime_t idletime; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_IDLE_TIME); - link->FlushWithReply(&replydata); + BAppServerLink link; + link.SetOpCode(AS_IDLE_TIME); + link.FlushWithReply(&replydata); idletime=*((bigtime_t*)replydata.buffer); - delete link; return idletime; } -_IMPEXP_BE void run_select_printer_panel() + +_IMPEXP_BE void +run_select_printer_panel() { // Launches the Printer prefs app via the Roster // TODO: Implement } -_IMPEXP_BE void run_add_printer_panel() + +_IMPEXP_BE void +run_add_printer_panel() { // Launches the Printer prefs app via the Roster and asks it to // add a printer // TODO: Implement } -_IMPEXP_BE void run_be_about() + +_IMPEXP_BE void +run_be_about() { // Unsure about how to implement this. // TODO: Implement } -_IMPEXP_BE void set_focus_follows_mouse(bool follow) + +_IMPEXP_BE void +set_focus_follows_mouse(bool follow) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_SET_FOCUS_FOLLOWS_MOUSE); - link->Attach(follow); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_SET_FOCUS_FOLLOWS_MOUSE); + link.Attach(follow); + link.Flush(); } -_IMPEXP_BE bool focus_follows_mouse() + +_IMPEXP_BE bool +focus_follows_mouse() { PortMessage pmsg; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_FOCUS_FOLLOWS_MOUSE); - link->FlushWithReply(&pmsg); - delete link; - + BAppServerLink link; + link.SetOpCode(AS_FOCUS_FOLLOWS_MOUSE); + link.FlushWithReply(&pmsg); + bool ffm; pmsg.Read(&ffm); + return ffm; } -_IMPEXP_BE void set_mouse_mode(mode_mouse mode) + +_IMPEXP_BE void +set_mouse_mode(mode_mouse mode) { - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_SET_MOUSE_MODE); - link->Attach(&mode,sizeof(mode_mouse)); - link->Flush(); - delete link; + BAppServerLink link; + link.SetOpCode(AS_SET_MOUSE_MODE); + link.Attach(&mode,sizeof(mode_mouse)); + link.Flush(); } -_IMPEXP_BE mode_mouse mouse_mode() + +_IMPEXP_BE mode_mouse +mouse_mode() { PortLink::ReplyData replydata; mode_mouse mode; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_GET_MOUSE_MODE); - link->FlushWithReply(&replydata); + BAppServerLink link; + link.SetOpCode(AS_GET_MOUSE_MODE); + link.FlushWithReply(&replydata); mode=*((mode_mouse*)replydata.buffer); - delete link; return mode; } -_IMPEXP_BE rgb_color ui_color(color_which which) + +_IMPEXP_BE rgb_color +ui_color(color_which which) { PortLink::ReplyData replydata; rgb_color color; - BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink(); - link->SetOpCode(AS_GET_UI_COLOR); - link->FlushWithReply(&replydata); + BAppServerLink link; + link.SetOpCode(AS_GET_UI_COLOR); + link.Attach(&which, sizeof(which)); + link.FlushWithReply(&replydata); color=*((rgb_color*)replydata.buffer); - delete link; return color; } -_IMPEXP_BE rgb_color tint_color(rgb_color color, float tint) +_IMPEXP_BE rgb_color +tint_color(rgb_color color, float tint) { // Internally calculates the color // TODO: Implement } -extern "C" status_t _init_interface_kit_() + +extern "C" status_t +_init_interface_kit_() { // TODO: Find out what this does and when it's called } -extern "C" status_t _fini_interface_kit_() + +extern "C" status_t +_fini_interface_kit_() { // TODO: Find out what this does and when it's called } -extern "C" void _init_global_fonts() + +extern "C" void +_init_global_fonts() { // This function will initialize the client-side font list // TODO: Implement } + // GraphicsDefs.h -_IMPEXP_BE status_t get_pixel_size_for(color_space space, size_t * pixel_chunk, size_t * row_alignment, size_t * pixels_per_chunk) +_IMPEXP_BE status_t +get_pixel_size_for(color_space space, size_t * pixel_chunk, size_t * row_alignment, size_t * pixels_per_chunk) { // TODO: Implement } -_IMPEXP_BE bool bitmaps_support_space(color_space space, uint32 * support_flags) + +_IMPEXP_BE bool +bitmaps_support_space(color_space space, uint32 * support_flags) { // TODO: Implement }