Changes to allow for the original non-Dano system colors without changing the API. Heh.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3887 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-07-07 12:13:06 +00:00
parent 19225ae191
commit d9590c6db2
3 changed files with 147 additions and 195 deletions

View File

@ -47,9 +47,6 @@
//#define DEBUG_COLORSET
// uncomment this line to query the server for the current GUI settings
#define LOAD_SETTINGS_FROM_DISK
#define SAVE_COLORSET 'svcs'
#define DELETE_COLORSET 'dlcs'
#define LOAD_COLORSET 'ldcs'
@ -104,35 +101,30 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
attrlist->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
attrlist->AddItem(new ColorWhichItem(B_PANEL_BACKGROUND_COLOR));
#ifndef BUILD_UNDER_R5
attrlist->AddItem(new ColorWhichItem(B_PANEL_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_DOCUMENT_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_DOCUMENT_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_CONTROL_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_CONTROL_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_CONTROL_BORDER_COLOR));
attrlist->AddItem(new ColorWhichItem(B_CONTROL_HIGHLIGHT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_NAVIGATION_BASE_COLOR));
attrlist->AddItem(new ColorWhichItem(B_NAVIGATION_PULSE_COLOR));
attrlist->AddItem(new ColorWhichItem(B_SHINE_COLOR));
attrlist->AddItem(new ColorWhichItem(B_SHADOW_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_PANEL_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_DOCUMENT_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_DOCUMENT_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_CONTROL_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_CONTROL_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_CONTROL_BORDER_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_CONTROL_HIGHLIGHT_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_NAVIGATION_BASE_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_NAVIGATION_PULSE_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_SHINE_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_SHADOW_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_SELECTED_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_MENU_SELECTED_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_ITEM_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_SELECTED_ITEM_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_SELECTED_BORDER_COLOR));
attrlist->AddItem(new ColorWhichItem(B_TOOLTIP_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_MENU_SELECTED_BORDER_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_TOOLTIP_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_SUCCESS_COLOR));
attrlist->AddItem(new ColorWhichItem(B_FAILURE_COLOR));
#else
attrlist->AddItem(new ColorWhichItem(B_MENU_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_SELECTION_BACKGROUND_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_ITEM_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_MENU_SELECTED_ITEM_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem(B_KEYBOARD_NAVIGATION_COLOR));
#endif
attrlist->AddItem(new ColorWhichItem((color_which)B_SUCCESS_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_FAILURE_COLOR));
attrlist->AddItem(new ColorWhichItem(B_WINDOW_TAB_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_WINDOW_TAB_TEXT_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_INACTIVE_WINDOW_TAB_COLOR));
attrlist->AddItem(new ColorWhichItem((color_which)B_INACTIVE_WINDOW_TAB_TEXT_COLOR));
picker=new BColorControl(BPoint(scrollview->Frame().right+20,scrollview->Frame().top),B_CELLS_32x8,5.0,"Picker",
new BMessage(UPDATE_COLOR));
@ -602,9 +594,6 @@ void APRView::LoadSettings(void)
// Load the current GUI color settings from disk. This is done instead of
// getting them from the server at this point for testing purposes. Comment
// out the #define LOAD_SETTINGS_FROM_DISK line to use the server query code
#ifdef LOAD_SETTINGS_FROM_DISK
#ifdef DEBUG_COLORSET
printf("Loading settings from disk\n");
#endif
@ -652,84 +641,6 @@ printf("Error unflattening SystemColors file %s\n",path.String());
// to the defaults
SetDefaults();
SaveSettings();
#else
// We will query the app_server via a bunch of ui_color() calls and then
// add the appropriate colors to the message
rgb_color col;
ColorWhichItem whichitem(B_PANEL_BACKGROUND_COLOR);
col=ui_color(whichitem.GetAttribute());
settings.AddData("B_PANEL_BACKGROUND_COLOR",(type_code)'RGBC',&col,sizeof(rgb_color));
#ifndef BUILD_UNDER_R5
whichitem.SetAttribute();
col=ui_color(B_PANEL_TEXT_COLOR);
whichitem.SetAttribute(B_PANEL_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_DOCUMENT_BACKGROUND_COLOR);
whichitem.SetAttribute(B_DOCUMENT_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_DOCUMENT_TEXT_COLOR);
whichitem.SetAttribute(B_DOCUMENT_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_CONTROL_BACKGROUND_COLOR);
whichitem.SetAttribute(B_CONTROL_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_CONTROL_TEXT_COLOR);
whichitem.SetAttribute(B_CONTROL_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_CONTROL_BORDER_COLOR);
whichitem.SetAttribute(B_CONTROL_BORDER_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_CONTROL_HIGHLIGHT_COLOR);
whichitem.SetAttribute(B_CONTROL_HIGHLIGHT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_NAVIGATION_BASE_COLOR);
whichitem.SetAttribute(B_NAVIGATION_BASE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_NAVIGATION_PULSE_COLOR);
whichitem.SetAttribute(B_NAVIGATION_PULSE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_SHINE_COLOR);
whichitem.SetAttribute(B_SHINE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_SHADOW_COLOR);
whichitem.SetAttribute(B_SHADOW_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_MENU_SELECTED_BORDER_COLOR);
whichitem.SetAttribute(B_MENU_SELECTED_BORDER_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_TOOLTIP_BACKGROUND_COLOR);
whichitem.SetAttribute(B_TOOLTIP_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_TOOLTIP_TEXT_COLOR);
whichitem.SetAttribute(B_TOOLTIP_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_SUCCESS_COLOR);
whichitem.SetAttribute(B_SUCCESS_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_FAILURE_COLOR);
whichitem.SetAttribute(B_FAILURE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
#endif
col=ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR);
whichitem.SetAttribute(B_MENU_SELECTED_ITEM_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_MENU_BACKGROUND_COLOR);
whichitem.SetAttribute(B_MENU_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_MENU_SELECTION_BACKGROUND_COLOR);
whichitem.SetAttribute(B_MENU_SELECTION_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_MENU_ITEM_TEXT_COLOR);
whichitem.SetAttribute(B_MENU_ITEM_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
col=ui_color(B_WINDOW_TAB_COLOR);
whichitem.SetAttribute(B_WINDOW_TAB_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
#endif
}
void APRView::SetDefaults(void)
@ -744,84 +655,73 @@ printf("Initializing color settings to defaults\n");
ColorWhichItem whichitem(B_PANEL_BACKGROUND_COLOR);
rgb_color col={216,216,216,255};
#ifndef BUILD_UNDER_R5
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_PANEL_TEXT_COLOR);
whichitem.SetAttribute((color_which)B_PANEL_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,255,255,255);
whichitem.SetAttribute(B_DOCUMENT_BACKGROUND_COLOR);
whichitem.SetAttribute((color_which)B_DOCUMENT_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_DOCUMENT_TEXT_COLOR);
whichitem.SetAttribute((color_which)B_DOCUMENT_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,245,245,245);
whichitem.SetAttribute(B_CONTROL_BACKGROUND_COLOR);
whichitem.SetAttribute((color_which)B_CONTROL_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_CONTROL_TEXT_COLOR);
whichitem.SetAttribute((color_which)B_CONTROL_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_CONTROL_BORDER_COLOR);
whichitem.SetAttribute((color_which)B_CONTROL_BORDER_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,115,120,184);
whichitem.SetAttribute(B_CONTROL_HIGHLIGHT_COLOR);
whichitem.SetAttribute((color_which)B_CONTROL_HIGHLIGHT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,170,50,184);
whichitem.SetAttribute(B_NAVIGATION_BASE_COLOR);
whichitem.SetAttribute((color_which)B_NAVIGATION_BASE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_NAVIGATION_PULSE_COLOR);
whichitem.SetAttribute((color_which)B_NAVIGATION_PULSE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,255,255,255);
whichitem.SetAttribute(B_SHINE_COLOR);
whichitem.SetAttribute((color_which)B_SHINE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_SHADOW_COLOR);
whichitem.SetAttribute((color_which)B_SHADOW_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_MENU_SELECTED_BORDER_COLOR);
whichitem.SetAttribute((color_which)B_MENU_SELECTED_BORDER_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,255,255,0);
whichitem.SetAttribute(B_TOOLTIP_BACKGROUND_COLOR);
whichitem.SetAttribute((color_which)B_TOOLTIP_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute(B_TOOLTIP_TEXT_COLOR);
whichitem.SetAttribute((color_which)B_TOOLTIP_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,255,0);
whichitem.SetAttribute(B_SUCCESS_COLOR);
whichitem.SetAttribute((color_which)B_SUCCESS_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,255,0,0);
whichitem.SetAttribute(B_FAILURE_COLOR);
whichitem.SetAttribute((color_which)B_FAILURE_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,51,102,160);
whichitem.SetAttribute(B_MENU_SELECTED_BACKGROUND_COLOR);
whichitem.SetAttribute((color_which)B_MENU_SELECTED_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
#else
SetRGBColor(&col,51,102,160);
whichitem.SetAttribute(B_MENU_SELECTION_BACKGROUND_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,51,102,160);
whichitem.SetAttribute(B_KEYBOARD_NAVIGATION_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
#endif
whichitem.SetAttribute(B_PANEL_BACKGROUND_COLOR);
SetRGBColor(&col,216,216,216);
@ -843,6 +743,18 @@ printf("Initializing color settings to defaults\n");
whichitem.SetAttribute(B_WINDOW_TAB_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,0,0,0);
whichitem.SetAttribute((color_which)B_WINDOW_TAB_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,232,232,232);
whichitem.SetAttribute((color_which)B_INACTIVE_WINDOW_TAB_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
SetRGBColor(&col,80,80,80);
whichitem.SetAttribute((color_which)B_INACTIVE_WINDOW_TAB_TEXT_COLOR);
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
// BString labelstr("Color Set: ");
// labelstr+=colorset_name->String();
// colorset_label->SetText(labelstr.String());

View File

@ -1,4 +1,5 @@
#include "ColorWhichItem.h"
#include <stdio.h>
ColorWhichItem::ColorWhichItem(color_which which)
: BStringItem(NULL,0,false)
@ -15,8 +16,13 @@ void ColorWhichItem::SetAttribute(color_which which)
{
switch(which)
{
#ifndef BUILD_UNDER_R5
// cases not existing in R5 which exist in OpenBeOS
case B_PANEL_BACKGROUND_COLOR:
{
attribute=which;
SetText("Background");
break;
}
case B_PANEL_TEXT_COLOR:
{
attribute=which;
@ -59,36 +65,6 @@ void ColorWhichItem::SetAttribute(color_which which)
SetText("Control Highlight");
break;
}
case B_NAVIGATION_BASE_COLOR:
{
attribute=which;
SetText("Navigation Base");
break;
}
case B_NAVIGATION_PULSE_COLOR:
{
attribute=which;
SetText("Navigation Pulse");
break;
}
case B_SHINE_COLOR:
{
attribute=which;
SetText("Shine");
break;
}
case B_SHADOW_COLOR:
{
attribute=which;
SetText("Shadow");
break;
}
case B_MENU_SELECTED_BORDER_COLOR:
{
attribute=which;
SetText("Selected Menu Item Border");
break;
}
case B_TOOLTIP_BACKGROUND_COLOR:
{
attribute=which;
@ -101,32 +77,6 @@ void ColorWhichItem::SetAttribute(color_which which)
SetText("Tooltip Text");
break;
}
case B_SUCCESS_COLOR:
{
attribute=which;
SetText("Success");
break;
}
case B_FAILURE_COLOR:
{
attribute=which;
SetText("Failure");
break;
}
#else
case B_KEYBOARD_NAVIGATION_COLOR:
{
attribute=which;
SetText("Keyboard Navigation");
break;
}
#endif
case B_PANEL_BACKGROUND_COLOR:
{
attribute=which;
SetText("Background");
break;
}
case B_MENU_BACKGROUND_COLOR:
{
attribute=which;
@ -151,14 +101,80 @@ void ColorWhichItem::SetAttribute(color_which which)
SetText("Selected Menu Item Text");
break;
}
case B_MENU_SELECTED_BORDER_COLOR:
{
attribute=which;
SetText("Selected Menu Item Border");
break;
}
case B_NAVIGATION_BASE_COLOR:
{
attribute=which;
SetText("Navigation Base");
break;
}
case B_NAVIGATION_PULSE_COLOR:
{
attribute=which;
SetText("Navigation Pulse");
break;
}
case B_SUCCESS_COLOR:
{
attribute=which;
SetText("Success");
break;
}
case B_FAILURE_COLOR:
{
attribute=which;
SetText("Failure");
break;
}
case B_SHINE_COLOR:
{
attribute=which;
SetText("Shine");
break;
}
case B_SHADOW_COLOR:
{
attribute=which;
SetText("Shadow");
break;
}
case B_WINDOW_TAB_COLOR:
{
attribute=which;
SetText("Window Tab");
break;
}
default:
case B_WINDOW_TAB_TEXT_COLOR:
{
attribute=which;
SetText("Window Tab Text");
break;
}
case B_INACTIVE_WINDOW_TAB_COLOR:
{
attribute=which;
SetText("Inactive Window Tab");
break;
}
case B_INACTIVE_WINDOW_TAB_TEXT_COLOR:
{
attribute=which;
SetText("Inactive Window Tab Text");
break;
}
default:
{
printf("unknown code '%c%c%c%c'\n",(char)((which & 0xFF000000) >> 24),
(char)((which & 0x00FF0000) >> 16),
(char)((which & 0x0000FF00) >> 8),
(char)((which & 0x000000FF)) );
break;
}
}
}

View File

@ -4,6 +4,30 @@
#include <InterfaceDefs.h>
#include <ListItem.h>
#define B_INACTIVE_WINDOW_TAB_TEXT_COLOR 'iwtt'
#define B_WINDOW_TAB_TEXT_COLOR 'wttx'
#define B_INACTIVE_WINDOW_TAB_COLOR 'iwtb'
#ifdef BUILD_UNDER_R5
#define B_MENU_SELECTED_BACKGROUND_COLOR B_MENU_SELECTION_BACKGROUND_COLOR
#define B_PANEL_TEXT_COLOR 'ptxt'
#define B_DOCUMENT_BACKGROUND_COLOR 'dbgc'
#define B_DOCUMENT_TEXT_COLOR 'dtxc'
#define B_CONTROL_BACKGROUND_COLOR 'cbgc'
#define B_CONTROL_TEXT_COLOR 'ctxc'
#define B_CONTROL_BORDER_COLOR 'cboc'
#define B_CONTROL_HIGHLIGHT_COLOR 'chic'
#define B_NAVIGATION_BASE_COLOR 'navb'
#define B_NAVIGATION_PULSE_COLOR 'navp'
#define B_SHINE_COLOR 'shin'
#define B_SHADOW_COLOR 'shad'
#define B_MENU_SELECTED_BORDER_COLOR 'msbo'
#define B_TOOLTIP_BACKGROUND_COLOR 'ttbg'
#define B_TOOLTIP_TEXT_COLOR 'tttx'
#define B_SUCCESS_COLOR 'sucs'
#define B_FAILURE_COLOR 'fail'
#endif
class ColorWhichItem : public BStringItem
{
public:
@ -15,4 +39,4 @@ private:
color_which attribute;
};
#endif
#endif