Added handler code for AppServer::PollerThread to handle messages to get/set UI colors and decorators

Added a color_which lookup to ColorSet - will be necessary to look up system colors via ui_color()


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4981 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-10-08 23:18:30 +00:00
parent e2367e8fcb
commit a93fbc5951
5 changed files with 244 additions and 17 deletions

View File

@ -27,6 +27,7 @@
#include <AppDefs.h>
#include <PortMessage.h>
#include <Entry.h>
#include <Path.h>
#include <Directory.h>
#include <PortMessage.h>
#include <PortLink.h>
@ -155,6 +156,7 @@ AppServer::AppServer(void)
_active_app=-1;
_p_active_app=NULL;
decorator_name="Default";
}
/*!
@ -382,13 +384,24 @@ void AppServer::MainLoop(void)
\param path Path to the decorator to load
\return True if successful, false if not.
If the server cannot load the specified decorator, nothing changes.
If the server cannot load the specified decorator, nothing changes. Passing a
NULL string to this function sets the decorator to the internal one.
*/
bool AppServer::LoadDecorator(const char *path)
{
// Loads a window decorator based on the supplied path and forces a decorator update.
// If it cannot load the specified decorator, it will retain the current one and
// return false.
// return false. Note that passing a NULL string to this function sets the decorator
// to the internal one.
// passing the string "Default" will set the window decorator to the app_server's
// internal one
if(!path)
{
make_decorator=NULL;
return true;
}
create_decorator *pcreatefunc=NULL;
status_t stat;
image_id addon;
@ -409,7 +422,10 @@ bool AppServer::LoadDecorator(const char *path)
unload_add_on(addon);
return false;
}
BPath temppath(path);
decorator_name=temppath.Leaf();
acquire_sem(_decor_lock);
make_decorator=pcreatefunc;
_decorator_id=addon;
@ -596,33 +612,88 @@ void AppServer::DispatchMessage(PortMessage *msg)
}
case AS_SET_UI_COLORS:
{
// TODO: Unpack the colors and set the color set to such
printf("AppServer::AS_SET_UI_COLORS unimplemented\n");
break;
}
case AS_GET_UI_COLOR:
{
// TODO: get a partiular UI color and return it to the sender
printf("AppServer::AS_GET_UI_COLOR unimplemented\n");
// Client application is asking to set all the system colors at once
// using a ColorSet object
// Attached data:
// 1) ColorSet new colors to use
gui_colorset.Lock();
msg->Read<ColorSet>(&gui_colorset);
gui_colorset.Unlock();
Broadcast(AS_UPDATE_COLORS);
break;
}
case AS_SET_DECORATOR:
{
// TODO: set up window decorator notification stuff here
printf("AppServer::AS_SET_DECORATOR unimplemented\n");
// Received from an application when the user wants to set the window
// decorator to a new one
// Attached Data:
// char * name of the decorator in the decorators path to use
char *decname;
msg->ReadString(&decname);
if(decname)
{
if(strcmp(decname,"Default")!=0)
{
BString decpath;
decpath.SetTo(DECORATORS_DIR);
decpath+=decname;
if(LoadDecorator(decpath.String()))
Broadcast(AS_UPDATE_DECORATOR);
}
else
{
LoadDecorator(NULL);
Broadcast(AS_UPDATE_DECORATOR);
}
}
delete decname;
break;
}
case AS_GET_DECORATOR:
{
// TODO: get window decorator and return it to the sender
printf("AppServer::AS_GET_DECORATOR unimplemented\n");
// TODO: get window decorator's name and return it to the sender
// Attached Data:
// 1) port_id reply port
port_id replyport;
msg->Read<port_id>(&replyport);
PortLink replylink(replyport);
replylink.SetOpCode(AS_GET_DECORATOR);
replylink.AttachString(decorator_name.String());
replylink.Flush();
break;
}
case AS_R5_SET_DECORATOR:
{
// TODO: Implement. This will translate the codes to names of the
// decorators and perform the same actions as AS_SET_DECORATOR
// Sort of supports Tracker's nifty Easter Egg. It was easy to do and
// it's kind of neat, so why not?
// Attached Data:
// char * name of the decorator in the decorators path to use
printf("AppServer::AS_R5_SET_DECORATOR unimplemented\n");
int32 decindex;
msg->Read<int32>(&decindex);
BString decpath;
decpath.SetTo(DECORATORS_DIR);
switch(decindex)
{
case 0: decpath+="BeOS"; break;
case 1: decpath+="AmigaOS"; break;
case 2: decpath+="Windows"; break;
case 3: decpath+="MacOS"; break;
default:
break;
}
if(LoadDecorator(decpath.String()))
Broadcast(AS_UPDATE_DECORATOR);
break;
}
case AS_GET_SCREEN_MODE:

View File

@ -7,6 +7,7 @@
#include <Application.h>
#include <Window.h>
#include <PortQueue.h>
#include <String.h>
#include "Decorator.h"
#include "ServerConfig.h"
@ -53,6 +54,7 @@ private:
port_id _messageport,_mouseport;
image_id _decorator_id;
BString decorator_name;
bool _quitting_server;
BList *_applist;
int32 _active_app;

View File

@ -26,6 +26,7 @@
//
//------------------------------------------------------------------------------
#include <stdio.h>
#include <InterfaceDefs.h>
#include <Message.h>
#include <File.h>
#include <Entry.h>
@ -412,6 +413,148 @@ RGBColor *ColorSet::StringToMember(const char *string)
}
RGBColor ColorSet::AttributeToColor(int32 which)
{
switch(which)
{
case B_PANEL_BACKGROUND_COLOR:
{
return panel_background;
break;
}
case B_PANEL_TEXT_COLOR:
{
return panel_text;
break;
}
case B_DOCUMENT_BACKGROUND_COLOR:
{
return document_background;
break;
}
case B_DOCUMENT_TEXT_COLOR:
{
return document_text;
break;
}
case B_CONTROL_BACKGROUND_COLOR:
{
return control_background;
break;
}
case B_CONTROL_TEXT_COLOR:
{
return control_text;
break;
}
case B_CONTROL_BORDER_COLOR:
{
return control_highlight;
break;
}
case B_CONTROL_HIGHLIGHT_COLOR:
{
return control_border;
break;
}
case B_NAVIGATION_BASE_COLOR:
{
return keyboard_navigation_base;
break;
}
case B_NAVIGATION_PULSE_COLOR:
{
return keyboard_navigation_pulse;
break;
}
case B_SHINE_COLOR:
{
return shine;
break;
}
case B_SHADOW_COLOR:
{
return shadow;
break;
}
case B_MENU_BACKGROUND_COLOR:
{
return menu_background;
break;
}
case B_MENU_SELECTED_BACKGROUND_COLOR:
{
return menu_selected_background;
break;
}
case B_MENU_ITEM_TEXT_COLOR:
{
return menu_text;
break;
}
case B_MENU_SELECTED_ITEM_TEXT_COLOR:
{
return menu_selected_text;
break;
}
case B_MENU_SELECTED_BORDER_COLOR:
{
return menu_selected_border;
break;
}
case B_TOOLTIP_BACKGROUND_COLOR:
{
return tooltip_background;
break;
}
case B_TOOLTIP_TEXT_COLOR:
{
return tooltip_text;
break;
}
case B_SUCCESS_COLOR:
{
return success;
break;
}
case B_FAILURE_COLOR:
{
return failure;
break;
}
case B_WINDOW_TAB_COLOR:
{
return window_tab;
break;
}
// DANGER! DANGER, WILL ROBINSON!!
// These are magic numbers to work around compatibility difficulties while still keeping
// functionality. This __will__ break following R1
case 22:
{
return window_tab_text;
break;
}
case 23:
{
return inactive_window_tab;
break;
}
case 24:
{
return inactive_window_tab_text;
break;
}
default:
{
return RGBColor(0,0,0,0);
break;
}
}
}
/*!
\brief Loads the saved system colors into a ColorSet
\param set the set to receive the system colors
@ -465,3 +608,4 @@ void SaveGUIColors(const ColorSet &set)
msg.Flatten(&file);
}

View File

@ -743,6 +743,12 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
replysession.Sync();
break;
}
case AS_GET_UI_COLOR:
{
// TODO: get a partiular UI color and return it to the sender
printf("ServerApp::AS_GET_UI_COLOR unimplemented\n");
break;
}
default:
{
STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(msg->Code())));

View File

@ -48,6 +48,10 @@ class Workspace;
class BSession;
class Layer;
#define AS_UPDATE_DECORATOR 'asud'
#define AS_UPDATE_COLORS 'asuc'
#define AS_UPDATE_FONTS 'asuf'
/*!
\class ServerWindow ServerWindow.h
\brief Shadow BWindow class