Utilizes ColorSet API improvements
Major cruft removal and internal retooling in APRView - still has bugs. :( git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4953 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
68b266bbe6
commit
4087744eef
@ -27,9 +27,10 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "APRMain.h"
|
#include "APRMain.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
APRApplication::APRApplication()
|
APRApplication::APRApplication()
|
||||||
:BApplication("application/x-vnd.obos-Appearance")
|
:BApplication(APPEARANCE_APP_SIGNATURE)
|
||||||
{
|
{
|
||||||
BRect rect;
|
BRect rect;
|
||||||
|
|
||||||
|
@ -46,7 +46,13 @@
|
|||||||
#include "ColorWhichItem.h"
|
#include "ColorWhichItem.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
|
|
||||||
//#define DEBUG_COLORSET
|
#define DEBUG_COLORSET
|
||||||
|
|
||||||
|
#ifdef DEBUG_COLORSET
|
||||||
|
#define STRACE(a) printf a
|
||||||
|
#else
|
||||||
|
#define STRACE(A) /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SAVE_COLORSET 'svcs'
|
#define SAVE_COLORSET 'svcs'
|
||||||
#define DELETE_COLORSET 'dlcs'
|
#define DELETE_COLORSET 'dlcs'
|
||||||
@ -54,10 +60,13 @@
|
|||||||
#define COLOR_DROPPED 'cldp'
|
#define COLOR_DROPPED 'cldp'
|
||||||
|
|
||||||
APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags)
|
APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags)
|
||||||
:BView(frame,name,resize,flags), settings(B_SIMPLE_DATA)
|
:BView(frame,name,resize,flags)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
currentset=new ColorSet;
|
||||||
|
prevset=NULL;
|
||||||
|
|
||||||
BMenuBar *mb=new BMenuBar(BRect(0,0,Bounds().Width(),16),"menubar");
|
BMenuBar *mb=new BMenuBar(BRect(0,0,Bounds().Width(),16),"menubar");
|
||||||
|
|
||||||
settings_menu=new BMenu("Settings");
|
settings_menu=new BMenu("Settings");
|
||||||
@ -88,8 +97,6 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
|||||||
colorset_label=new BStringView(wellrect,"colorset_label","Color Set: ");
|
colorset_label=new BStringView(wellrect,"colorset_label","Color Set: ");
|
||||||
AddChild(colorset_label);
|
AddChild(colorset_label);
|
||||||
colorset_label->ResizeToPreferred();
|
colorset_label->ResizeToPreferred();
|
||||||
colorset_name=new BString("<untitled>");
|
|
||||||
|
|
||||||
|
|
||||||
// Set up list of color attributes
|
// Set up list of color attributes
|
||||||
BRect rect(10,60,200,160);
|
BRect rect(10,60,200,160);
|
||||||
@ -142,6 +149,7 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
|||||||
new BMessage(DEFAULT_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP,
|
new BMessage(DEFAULT_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
B_WILL_DRAW | B_NAVIGABLE);
|
||||||
AddChild(defaults);
|
AddChild(defaults);
|
||||||
|
defaults->SetEnabled(false);
|
||||||
|
|
||||||
cvrect.OffsetBy(70,0);
|
cvrect.OffsetBy(70,0);
|
||||||
revert=new BButton(cvrect,"RevertButton","Revert",
|
revert=new BButton(cvrect,"RevertButton","Revert",
|
||||||
@ -160,8 +168,7 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
|||||||
BEntry entry(COLOR_SET_DIR);
|
BEntry entry(COLOR_SET_DIR);
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
savepanel=new BFilePanel(B_SAVE_PANEL, NULL,
|
savepanel=new BFilePanel(B_SAVE_PANEL, NULL, &ref, 0, false);
|
||||||
&ref, 0, false);
|
|
||||||
|
|
||||||
attribute=B_PANEL_BACKGROUND_COLOR;
|
attribute=B_PANEL_BACKGROUND_COLOR;
|
||||||
attrstring="Background";
|
attrstring="Background";
|
||||||
@ -171,7 +178,10 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags
|
|||||||
APRView::~APRView(void)
|
APRView::~APRView(void)
|
||||||
{
|
{
|
||||||
delete savepanel;
|
delete savepanel;
|
||||||
delete colorset_name;
|
if(currentset)
|
||||||
|
delete currentset;
|
||||||
|
if(prevset)
|
||||||
|
delete prevset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APRView::AllAttached(void)
|
void APRView::AllAttached(void)
|
||||||
@ -188,7 +198,7 @@ void APRView::AllAttached(void)
|
|||||||
|
|
||||||
BMessenger msgr(this);
|
BMessenger msgr(this);
|
||||||
savepanel->SetTarget(msgr);
|
savepanel->SetTarget(msgr);
|
||||||
picker->SetValue(GetColorFromMessage(&settings,attrstring.String()));
|
picker->SetValue(currentset->StringToColor(attrstring.String()).GetColor32());
|
||||||
}
|
}
|
||||||
|
|
||||||
void APRView::MessageReceived(BMessage *msg)
|
void APRView::MessageReceived(BMessage *msg)
|
||||||
@ -206,28 +216,14 @@ void APRView::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
switch(msg->what)
|
switch(msg->what)
|
||||||
{
|
{
|
||||||
case B_WORKSPACE_ACTIVATED:
|
|
||||||
{
|
|
||||||
BScreen screen;
|
|
||||||
rgb_color col=screen.DesktopColor();
|
|
||||||
settings.ReplaceData("DESKTOP",(type_code)'RGBC',
|
|
||||||
&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
if(attrstring=="DESKTOP")
|
|
||||||
{
|
|
||||||
picker->SetValue(col);
|
|
||||||
colorwell->SetColor(col);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DELETE_COLORSET:
|
case DELETE_COLORSET:
|
||||||
{
|
{
|
||||||
// Construct the path and delete
|
// Construct the path and delete
|
||||||
BString path(COLOR_SET_DIR);
|
BString path(COLOR_SET_DIR);
|
||||||
path+=*colorset_name;
|
path+=currentset->name;
|
||||||
|
|
||||||
BString printstring("Remove ");
|
BString printstring("Remove ");
|
||||||
printstring+=*colorset_name;
|
printstring+=currentset->name;
|
||||||
printstring+=" from disk permenantly?";
|
printstring+=" from disk permenantly?";
|
||||||
BAlert *a=new BAlert("OpenBeOS",printstring.String(),"Yes", "No");
|
BAlert *a=new BAlert("OpenBeOS",printstring.String(),"Yes", "No");
|
||||||
if(a->Go()==0)
|
if(a->Go()==0)
|
||||||
@ -235,13 +231,11 @@ void APRView::MessageReceived(BMessage *msg)
|
|||||||
int stat=remove(path.String());
|
int stat=remove(path.String());
|
||||||
if(stat!=0)
|
if(stat!=0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("MSG: Delete Request - couldn't delete file %s\n",path.String()));
|
||||||
printf("MSG: Delete Request - couldn't delete file %s\n",path.String());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BMenuItem *item=colorset_menu->FindItem(colorset_name->String());
|
BMenuItem *item=colorset_menu->FindItem(currentset->name.String());
|
||||||
if(item!=NULL)
|
if(item!=NULL)
|
||||||
{
|
{
|
||||||
if(colorset_menu->RemoveItem(item))
|
if(colorset_menu->RemoveItem(item))
|
||||||
@ -256,9 +250,7 @@ printf("MSG: Delete Request - couldn't delete file %s\n",path.String());
|
|||||||
BString name;
|
BString name;
|
||||||
if(msg->FindString("name",&name)!=B_OK)
|
if(msg->FindString("name",&name)!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("MSG: Load Request - couldn't find file name\n"));
|
||||||
printf("MSG: Load Request - couldn't find file name\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LoadColorSet(name);
|
LoadColorSet(name);
|
||||||
@ -274,9 +266,7 @@ printf("MSG: Load Request - couldn't find file name\n");
|
|||||||
BString name;
|
BString name;
|
||||||
if(msg->FindString("name",&name)!=B_OK)
|
if(msg->FindString("name",&name)!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("MSG: Save Request - couldn't find file name\n"));
|
||||||
printf("MSG: Save Request - couldn't find file name\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SaveColorSet(name);
|
SaveColorSet(name);
|
||||||
@ -285,18 +275,28 @@ printf("MSG: Save Request - couldn't find file name\n");
|
|||||||
case UPDATE_COLOR:
|
case UPDATE_COLOR:
|
||||||
{
|
{
|
||||||
// Received from the color picker when its color changes
|
// Received from the color picker when its color changes
|
||||||
|
if(!prevset)
|
||||||
|
{
|
||||||
|
prevset=new ColorSet;
|
||||||
|
*prevset=*currentset;
|
||||||
|
}
|
||||||
|
|
||||||
rgb_color col=picker->ValueAsColor();
|
rgb_color col=picker->ValueAsColor();
|
||||||
|
|
||||||
colorwell->SetColor(col);
|
colorwell->SetColor(col);
|
||||||
colorwell->Invalidate();
|
colorwell->Invalidate();
|
||||||
|
|
||||||
// Update current attribute in the settings
|
// Update current attribute in the settings
|
||||||
settings.ReplaceData(attrstring.String(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
if(currentset->SetColor(attrstring.String(),col)!=B_OK)
|
||||||
|
{
|
||||||
|
STRACE(("Couldn't set color for attribute %s\n",attrstring.String()));
|
||||||
|
}
|
||||||
|
|
||||||
if(apply->IsEnabled()==false)
|
if(!apply->IsEnabled())
|
||||||
apply->SetEnabled(true);
|
apply->SetEnabled(true);
|
||||||
if(revert->IsEnabled()==false)
|
if(!defaults->IsEnabled())
|
||||||
|
defaults->SetEnabled(true);
|
||||||
|
if(!revert->IsEnabled())
|
||||||
revert->SetEnabled(true);
|
revert->SetEnabled(true);
|
||||||
|
|
||||||
SetColorSetName("<untitled>");
|
SetColorSetName("<untitled>");
|
||||||
@ -310,23 +310,28 @@ printf("MSG: Save Request - couldn't find file name\n");
|
|||||||
if(!whichitem)
|
if(!whichitem)
|
||||||
break;
|
break;
|
||||||
attrstring=whichitem->Text();
|
attrstring=whichitem->Text();
|
||||||
rgb_color col=GetColorFromMessage(&settings,whichitem->Text(),0);
|
rgb_color col=currentset->StringToColor(whichitem->Text()).GetColor32();
|
||||||
picker->SetValue(col);
|
picker->SetValue(col);
|
||||||
colorwell->SetColor(col);
|
colorwell->SetColor(col);
|
||||||
colorwell->Invalidate();
|
colorwell->Invalidate();
|
||||||
|
|
||||||
// SetColorSetName("<untitled>");
|
|
||||||
// if(Window())
|
|
||||||
// Window()->PostMessage(SET_UI_COLORS);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case APPLY_SETTINGS:
|
case APPLY_SETTINGS:
|
||||||
{
|
{
|
||||||
|
if(prevset)
|
||||||
|
{
|
||||||
|
delete prevset;
|
||||||
|
prevset=NULL;
|
||||||
|
revert->SetEnabled(false);
|
||||||
|
}
|
||||||
|
if(currentset->name=="Default")
|
||||||
|
defaults->SetEnabled(false);
|
||||||
|
apply->SetEnabled(false);
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
NotifyServer();
|
NotifyServer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TRY_SETTINGS:
|
/* case TRY_SETTINGS:
|
||||||
{
|
{
|
||||||
// Tell server to apply settings here without saving them.
|
// Tell server to apply settings here without saving them.
|
||||||
// Theoretically, the user can set this temporarily and keep it
|
// Theoretically, the user can set this temporarily and keep it
|
||||||
@ -334,26 +339,43 @@ printf("MSG: Save Request - couldn't find file name\n");
|
|||||||
NotifyServer();
|
NotifyServer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REVERT_SETTINGS:
|
*/ case REVERT_SETTINGS:
|
||||||
{
|
{
|
||||||
/* LoadSettings();
|
delete currentset;
|
||||||
rgb_color col=GetColorFromMessage(&settings,attrstring.String(),0);
|
currentset=prevset;
|
||||||
picker->SetValue(col);
|
prevset=NULL;
|
||||||
|
|
||||||
|
rgb_color col=picker->ValueAsColor();
|
||||||
|
|
||||||
colorwell->SetColor(col);
|
colorwell->SetColor(col);
|
||||||
colorwell->Invalidate();
|
colorwell->Invalidate();
|
||||||
if(Window())
|
|
||||||
Window()->PostMessage(SET_UI_COLORS);
|
|
||||||
*/
|
|
||||||
if(prev_set_name=="Default")
|
|
||||||
SetDefaults();
|
|
||||||
|
|
||||||
LoadColorSet(prev_set_name);
|
// Update current attribute in the settings
|
||||||
|
currentset->SetColor(attrstring.String(),col);
|
||||||
|
|
||||||
|
if(!apply->IsEnabled())
|
||||||
|
apply->SetEnabled(false);
|
||||||
|
if((currentset->name!="Default"))
|
||||||
|
defaults->SetEnabled(true);
|
||||||
|
else
|
||||||
|
defaults->SetEnabled(false);
|
||||||
|
revert->SetEnabled(false);
|
||||||
|
|
||||||
|
SetColorSetName(currentset->name.String());
|
||||||
|
Window()->PostMessage(SET_UI_COLORS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEFAULT_SETTINGS:
|
case DEFAULT_SETTINGS:
|
||||||
{
|
{
|
||||||
|
if(!prevset)
|
||||||
|
{
|
||||||
|
prevset=new ColorSet;
|
||||||
|
*prevset=*currentset;
|
||||||
|
revert->SetEnabled(true);
|
||||||
|
apply->SetEnabled(true);
|
||||||
|
}
|
||||||
SetDefaults();
|
SetDefaults();
|
||||||
rgb_color col=GetColorFromMessage(&settings,attrstring.String(),0);
|
rgb_color col=currentset->StringToColor(attrstring.String()).GetColor32();
|
||||||
picker->SetValue(col);
|
picker->SetValue(col);
|
||||||
colorwell->SetColor(col);
|
colorwell->SetColor(col);
|
||||||
colorwell->Invalidate();
|
colorwell->Invalidate();
|
||||||
@ -369,9 +391,9 @@ printf("MSG: Save Request - couldn't find file name\n");
|
|||||||
|
|
||||||
BMenu *APRView::LoadColorSets(void)
|
BMenu *APRView::LoadColorSets(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("Loading color sets from disk\n");
|
STRACE(("Loading color sets from disk\n"));
|
||||||
#endif
|
|
||||||
// This function populates the member menu *colorset_menu with the color
|
// This function populates the member menu *colorset_menu with the color
|
||||||
// set files located in the color set directory. To ensure that there are
|
// set files located in the color set directory. To ensure that there are
|
||||||
// no entries pointing to invalid color sets, they are validated before
|
// no entries pointing to invalid color sets, they are validated before
|
||||||
@ -407,17 +429,17 @@ printf("Loading color sets from disk\n");
|
|||||||
}
|
}
|
||||||
case B_BAD_VALUE:
|
case B_BAD_VALUE:
|
||||||
{
|
{
|
||||||
printf("APRView::LoadColorSets(): Invalid colorset folder path.\n");
|
STRACE(("APRView::LoadColorSets(): Invalid colorset folder path.\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_NO_MEMORY:
|
case B_NO_MEMORY:
|
||||||
{
|
{
|
||||||
printf("APRView::LoadColorSets(): No memory left. We're probably going to crash now. \n");
|
STRACE(("APRView::LoadColorSets(): No memory left. We're probably going to crash now. \n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_BUSY:
|
case B_BUSY:
|
||||||
{
|
{
|
||||||
printf("APRView::LoadColorSets(): Busy node " COLOR_SET_DIR "\n");
|
STRACE(("APRView::LoadColorSets(): Busy node " COLOR_SET_DIR "\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_FILE_ERROR:
|
case B_FILE_ERROR:
|
||||||
@ -467,50 +489,37 @@ printf("Loading color sets from disk\n");
|
|||||||
void APRView::LoadColorSet(const BString &name)
|
void APRView::LoadColorSet(const BString &name)
|
||||||
{
|
{
|
||||||
// Load the current GUI color settings from a color set file.
|
// Load the current GUI color settings from a color set file.
|
||||||
|
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("LoadColorSet: %s\n",name.String()));
|
||||||
printf("LoadColorSet: %s\n",name.String());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BDirectory dir,newdir;
|
BDirectory dir,newdir;
|
||||||
if(dir.SetTo(COLOR_SET_DIR)==B_ENTRY_NOT_FOUND)
|
if(dir.SetTo(COLOR_SET_DIR)==B_ENTRY_NOT_FOUND)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Color set folder not found. Creating %s\n",COLOR_SET_DIR));
|
||||||
printf("Color set folder not found. Creating %s\n",COLOR_SET_DIR);
|
|
||||||
#endif
|
|
||||||
create_directory(COLOR_SET_DIR,0777);
|
create_directory(COLOR_SET_DIR,0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
BString path(COLOR_SET_DIR);
|
BString path(COLOR_SET_DIR);
|
||||||
path+=name.String();
|
path+=name.String();
|
||||||
BFile file(path.String(),B_READ_ONLY);
|
BFile file(path.String(),B_READ_ONLY);
|
||||||
|
|
||||||
if(file.InitCheck()!=B_OK)
|
if(file.InitCheck()!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Couldn't open file %s for read\n",path.String()));
|
||||||
printf("Couldn't open file %s for read\n",path.String());
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(settings.Unflatten(&file)==B_OK)
|
BMessage settings;
|
||||||
|
|
||||||
|
if(settings.Unflatten(&file)!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Error unflattening file %s\n",name.String()));
|
||||||
settings.PrintToStream();
|
|
||||||
#endif
|
|
||||||
BString internal_name;
|
|
||||||
settings.FindString("name",&internal_name);
|
|
||||||
// BString namestr("Color Set: ");
|
|
||||||
// namestr+=internal_name.String();
|
|
||||||
// colorset_label->SetText(namestr.String());
|
|
||||||
SetColorSetName(internal_name.String());
|
|
||||||
|
|
||||||
picker->SetValue(GetColorFromMessage(&settings,attrstring.String()));
|
|
||||||
colorwell->SetColor(picker->ValueAsColor());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_COLORSET
|
currentset->ConvertFromMessage(&settings);
|
||||||
printf("Error unflattening file %s\n",name.String());
|
SetColorSetName(currentset->name.String());
|
||||||
#endif
|
|
||||||
|
picker->SetValue(currentset->StringToColor(attrstring.String()).GetColor32());
|
||||||
|
colorwell->SetColor(picker->ValueAsColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void APRView::SaveColorSet(const BString &name)
|
void APRView::SaveColorSet(const BString &name)
|
||||||
@ -521,31 +530,23 @@ void APRView::SaveColorSet(const BString &name)
|
|||||||
BString path(COLOR_SET_DIR);
|
BString path(COLOR_SET_DIR);
|
||||||
path+=name.String();
|
path+=name.String();
|
||||||
|
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("SaveColorSet: %s\n",path.String());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(settings.ReplaceString("name",name.String())!=B_OK)
|
STRACE(("SaveColorSet: %s\n",path.String()));
|
||||||
{
|
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("SaveColorSet: Couldn't replace set name in settings\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
||||||
|
|
||||||
if(file.InitCheck()!=B_OK)
|
if(file.InitCheck()!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("SaveColorSet: Couldn't open settings file for write\n"));
|
||||||
printf("SaveColorSet: Couldn't open settings file for write\n");
|
return;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BMessage settings;
|
||||||
|
currentset->ConvertToMessage(&settings);
|
||||||
if(settings.Flatten(&file)!=B_OK)
|
if(settings.Flatten(&file)!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("SaveColorSet: Couldn't flatten settings to file\n"));
|
||||||
printf("SaveColorSet: Couldn't flatten settings to file\n");
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,9 +555,7 @@ printf("SaveColorSet: Couldn't flatten settings to file\n");
|
|||||||
|
|
||||||
if(colorset_menu->AddItem(new BMenuItem(name.String(),msg))==false)
|
if(colorset_menu->AddItem(new BMenuItem(name.String(),msg))==false)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("SaveColorSet: Error in adding item to menu\n"));
|
||||||
printf("SaveColorSet: Error in adding item to menu\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
SetColorSetName(name.String());
|
SetColorSetName(name.String());
|
||||||
}
|
}
|
||||||
@ -566,7 +565,7 @@ void APRView::SetColorSetName(const char *name)
|
|||||||
if(!name)
|
if(!name)
|
||||||
return;
|
return;
|
||||||
BString namestr("Color Set: ");
|
BString namestr("Color Set: ");
|
||||||
colorset_name->SetTo(name);
|
currentset->name.SetTo(name);
|
||||||
namestr+=name;
|
namestr+=name;
|
||||||
colorset_label->SetText(namestr.String());
|
colorset_label->SetText(namestr.String());
|
||||||
colorset_label->ResizeToPreferred();
|
colorset_label->ResizeToPreferred();
|
||||||
@ -580,33 +579,29 @@ void APRView::SaveSettings(void)
|
|||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
BString path(SERVER_SETTINGS_DIR);
|
||||||
path+=COLOR_SETTINGS_NAME;
|
path+=COLOR_SETTINGS_NAME;
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("SaveSettings: %s\n",path.String());
|
STRACE(("SaveSettings: %s\n",path.String()));
|
||||||
#endif
|
|
||||||
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
||||||
|
|
||||||
|
BMessage settings;
|
||||||
|
|
||||||
|
currentset->ConvertToMessage(&settings);
|
||||||
settings.Flatten(&file);
|
settings.Flatten(&file);
|
||||||
prev_set_name=*colorset_name;
|
|
||||||
revert->SetEnabled(false);
|
|
||||||
revert->SetEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APRView::LoadSettings(void)
|
void APRView::LoadSettings(void)
|
||||||
{
|
{
|
||||||
// Load the current GUI color settings from disk. This is done instead of
|
// 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
|
// getting them from the server at this point for testing purposes.
|
||||||
// out the #define LOAD_SETTINGS_FROM_DISK line to use the server query code
|
|
||||||
#ifdef DEBUG_COLORSET
|
// TODO: Add app_server UI color query code
|
||||||
printf("Loading settings from disk\n");
|
STRACE(("Loading settings from disk\n"));
|
||||||
#endif
|
|
||||||
settings.MakeEmpty();
|
|
||||||
|
|
||||||
BDirectory dir,newdir;
|
BDirectory dir,newdir;
|
||||||
if(dir.SetTo(SERVER_SETTINGS_DIR)==B_ENTRY_NOT_FOUND)
|
if(dir.SetTo(SERVER_SETTINGS_DIR)==B_ENTRY_NOT_FOUND)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Color set folder not found. Creating %s\n",SERVER_SETTINGS_DIR));
|
||||||
printf("Color set folder not found. Creating %s\n",SERVER_SETTINGS_DIR);
|
|
||||||
#endif
|
|
||||||
create_directory(SERVER_SETTINGS_DIR,0777);
|
create_directory(SERVER_SETTINGS_DIR,0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,151 +611,39 @@ printf("Color set folder not found. Creating %s\n",SERVER_SETTINGS_DIR);
|
|||||||
|
|
||||||
if(file.InitCheck()!=B_OK)
|
if(file.InitCheck()!=B_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Couldn't open file %s for read\n",path.String()));
|
||||||
printf("Couldn't open file %s for read\n",path.String());
|
|
||||||
#endif
|
|
||||||
SetDefaults();
|
SetDefaults();
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(settings.Unflatten(&file)==B_OK)
|
|
||||||
|
BMessage settings;
|
||||||
|
if(settings.Unflatten(&file)!=B_OK)
|
||||||
{
|
{
|
||||||
settings.FindString("name",colorset_name);
|
STRACE(("Error unflattening SystemColors file %s\n",path.String()));
|
||||||
SetColorSetName(colorset_name->String());
|
|
||||||
prev_set_name=*colorset_name;
|
SetDefaults();
|
||||||
picker->SetValue(GetColorFromMessage(&settings,attrstring.String()));
|
SaveSettings();
|
||||||
colorwell->SetColor(picker->ValueAsColor());
|
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
settings.PrintToStream();
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("Error unflattening SystemColors file %s\n",path.String());
|
currentset->ConvertFromMessage(&settings);
|
||||||
#endif
|
SetColorSetName(currentset->name.String());
|
||||||
|
|
||||||
// If we get this far, we have encountered an error, so reset the settings
|
picker->SetValue(currentset->StringToColor(attrstring.String()).GetColor32());
|
||||||
// to the defaults
|
colorwell->SetColor(picker->ValueAsColor());
|
||||||
SetDefaults();
|
|
||||||
SaveSettings();
|
if(currentset->name.String()!="Default")
|
||||||
|
defaults->SetEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APRView::SetDefaults(void)
|
void APRView::SetDefaults(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_COLORSET
|
STRACE(("Initializing color settings to defaults\n"));
|
||||||
printf("Initializing color settings to defaults\n");
|
defaults->SetEnabled(false);
|
||||||
#endif
|
currentset->name.SetTo("Default");
|
||||||
settings.MakeEmpty();
|
|
||||||
settings.AddString("name","Default");
|
|
||||||
colorset_name->SetTo("Default");
|
|
||||||
|
|
||||||
ColorWhichItem whichitem(B_PANEL_BACKGROUND_COLOR);
|
currentset->SetToDefaults();
|
||||||
rgb_color col={216,216,216,255};
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((color_which)B_DOCUMENT_BACKGROUND_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((color_which)B_CONTROL_BACKGROUND_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((color_which)B_CONTROL_BORDER_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,115,120,184);
|
|
||||||
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((color_which)B_NAVIGATION_BASE_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((color_which)B_SHINE_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((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((color_which)B_TOOLTIP_BACKGROUND_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
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((color_which)B_SUCCESS_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,255,0,0);
|
|
||||||
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((color_which)B_MENU_SELECTED_BACKGROUND_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
whichitem.SetAttribute(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
SetRGBColor(&col,216,216,216);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,216,216,216,0);
|
|
||||||
whichitem.SetAttribute(B_MENU_BACKGROUND_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,0,0,0);
|
|
||||||
whichitem.SetAttribute(B_MENU_ITEM_TEXT_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,255,255,255);
|
|
||||||
whichitem.SetAttribute(B_MENU_SELECTED_ITEM_TEXT_COLOR);
|
|
||||||
settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color));
|
|
||||||
|
|
||||||
SetRGBColor(&col,255,203,0);
|
|
||||||
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());
|
|
||||||
SetColorSetName("Default");
|
SetColorSetName("Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +663,7 @@ void APRView::NotifyServer(void)
|
|||||||
// Set menu color
|
// Set menu color
|
||||||
menu_info minfo;
|
menu_info minfo;
|
||||||
get_menu_info(&minfo);
|
get_menu_info(&minfo);
|
||||||
col=GetColorFromMessage(&settings,"MENU_BACKGROUND");
|
col=currentset->StringToColor("Menu Background").GetColor32();
|
||||||
if(col.alpha==0 && col.red==0 && col.green==0 && col.blue==0)
|
if(col.alpha==0 && col.red==0 && col.green==0 && col.blue==0)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -791,36 +674,6 @@ void APRView::NotifyServer(void)
|
|||||||
set_menu_info(&minfo);
|
set_menu_info(&minfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set desktop color
|
|
||||||
BScreen screen;
|
|
||||||
col=GetColorFromMessage(&settings,"DESKTOP");
|
|
||||||
|
|
||||||
#ifdef DEBUG_COLORSET
|
|
||||||
printf("NotifyServer: Setting Desktop color to "); PrintRGBColor(col);
|
|
||||||
#endif
|
|
||||||
if(col.alpha==0 && col.red==0 && col.green==0 && col.blue==0)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
else
|
|
||||||
screen.SetDesktopColor(col);
|
|
||||||
|
|
||||||
if(Window())
|
if(Window())
|
||||||
Window()->PostMessage(SET_UI_COLORS);
|
Window()->PostMessage(SET_UI_COLORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb_color APRView::GetColorFromMessage(BMessage *msg, const char *name, int32 index=0)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Simple function to do the dirty work of getting an rgb_color from
|
|
||||||
// a message
|
|
||||||
rgb_color *col,rcolor={0,0,0,0};
|
|
||||||
ssize_t size;
|
|
||||||
|
|
||||||
if(!msg || !name)
|
|
||||||
return rcolor;
|
|
||||||
|
|
||||||
if(msg->FindData(name,(type_code)'RGBC',index,(const void**)&col,&size)==B_OK)
|
|
||||||
rcolor=*col;
|
|
||||||
return rcolor;
|
|
||||||
}
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
#include <Invoker.h>
|
#include <Invoker.h>
|
||||||
|
#include <ColorSet.h>
|
||||||
class ColorWell;
|
class ColorWell;
|
||||||
class APRWindow;
|
class APRWindow;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
void LoadSettings(void);
|
void LoadSettings(void);
|
||||||
void SetDefaults(void);
|
void SetDefaults(void);
|
||||||
void NotifyServer(void);
|
void NotifyServer(void);
|
||||||
rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0);
|
// rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0);
|
||||||
protected:
|
protected:
|
||||||
friend APRWindow;
|
friend APRWindow;
|
||||||
BMenu *LoadColorSets(void);
|
BMenu *LoadColorSets(void);
|
||||||
@ -68,15 +68,14 @@ protected:
|
|||||||
BButton *apply,*revert,*defaults;
|
BButton *apply,*revert,*defaults;
|
||||||
BListView *attrlist;
|
BListView *attrlist;
|
||||||
color_which attribute;
|
color_which attribute;
|
||||||
BMessage settings;
|
|
||||||
BString attrstring;
|
BString attrstring;
|
||||||
BScrollView *scrollview;
|
BScrollView *scrollview;
|
||||||
BStringView *colorset_label;
|
BStringView *colorset_label;
|
||||||
BMenu *colorset_menu,*settings_menu;
|
BMenu *colorset_menu,*settings_menu;
|
||||||
BFilePanel *savepanel;
|
BFilePanel *savepanel;
|
||||||
ColorWell *colorwell;
|
ColorWell *colorwell;
|
||||||
BString *colorset_name;
|
|
||||||
BString prev_set_name;
|
ColorSet *currentset,*prevset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,21 +41,21 @@ APRWindow::APRWindow(BRect frame)
|
|||||||
BTab *tab=NULL;
|
BTab *tab=NULL;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Swap Cursors and Colors tabs when we're done developing it
|
colors=new APRView(Bounds(),"Colors",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
cursors=new CurView(Bounds(),"Cursors",B_FOLLOW_ALL, B_WILL_DRAW);
|
tab=new BTab(colors);
|
||||||
tab=new BTab(cursors);
|
tabview->AddTab(colors,tab);
|
||||||
tabview->AddTab(cursors,tab);
|
|
||||||
|
|
||||||
decorators=new DecView(Bounds(),"Decorator",B_FOLLOW_ALL, B_WILL_DRAW);
|
decorators=new DecView(Bounds(),"Decorator",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
tab=new BTab(decorators);
|
tab=new BTab(decorators);
|
||||||
tabview->AddTab(decorators,tab);
|
tabview->AddTab(decorators,tab);
|
||||||
|
|
||||||
colors=new APRView(Bounds(),"Colors",B_FOLLOW_ALL, B_WILL_DRAW);
|
// TODO: Finish CurView
|
||||||
tab=new BTab(colors);
|
cursors=new CurView(Bounds(),"Cursors",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
tabview->AddTab(colors,tab);
|
tab=new BTab(cursors);
|
||||||
|
tabview->AddTab(cursors,tab);
|
||||||
|
|
||||||
AddChild(tabview);
|
AddChild(tabview);
|
||||||
decorators->SetColors(colors->settings);
|
decorators->SetColors(*colors->currentset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APRWindow::QuitRequested()
|
bool APRWindow::QuitRequested()
|
||||||
@ -77,7 +77,7 @@ void APRWindow::WorkspaceActivated(int32 wkspc, bool is_active)
|
|||||||
void APRWindow::MessageReceived(BMessage *msg)
|
void APRWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
if(msg->what==SET_UI_COLORS)
|
if(msg->what==SET_UI_COLORS)
|
||||||
decorators->SetColors(colors->settings);
|
decorators->SetColors(*colors->currentset);
|
||||||
else
|
else
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,13 @@
|
|||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
//#define DEBUG_DECORATOR
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECORATOR
|
||||||
|
#define STRACE(a) printf a
|
||||||
|
#else
|
||||||
|
#define STRACE(a) /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
||||||
:BView(frame,name,resize,flags)
|
:BView(frame,name,resize,flags)
|
||||||
{
|
{
|
||||||
@ -63,7 +70,9 @@ DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
|||||||
// set up app_server emulation
|
// set up app_server emulation
|
||||||
driver=new PreviewDriver();
|
driver=new PreviewDriver();
|
||||||
if(!driver->Initialize())
|
if(!driver->Initialize())
|
||||||
printf("Uh-oh... Couldn't initialize graphics module for server emu!\n");
|
{
|
||||||
|
STRACE(("Uh-oh... Couldn't initialize graphics module for server emu!\n"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
preview=driver->View();
|
preview=driver->View();
|
||||||
@ -139,23 +148,19 @@ void DecView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
case DECORATOR_CHOSEN:
|
case DECORATOR_CHOSEN:
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("MSG: Decorator Chosen - #%ld\n",declist->CurrentSelection());
|
STRACE(("MSG: Decorator Chosen - #%ld\n",declist->CurrentSelection()));
|
||||||
#endif
|
|
||||||
bool success=false;
|
bool success=false;
|
||||||
|
|
||||||
BString path( ConvertIndexToPath(declist->CurrentSelection()) );
|
BString path( ConvertIndexToPath(declist->CurrentSelection()) );
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("MSG: Decorator path: %s\n",path.String());
|
STRACE(("MSG: Decorator path: %s\n",path.String()));
|
||||||
#endif
|
|
||||||
|
|
||||||
success=LoadDecorator(path.String());
|
success=LoadDecorator(path.String());
|
||||||
|
|
||||||
if(!success)
|
if(!success)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
STRACE(("MSG: Decorator NOT Chosen - couldn't load decorator\n"));
|
||||||
printf("MSG: Decorator NOT Chosen - couldn't load decorator\n");
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +170,7 @@ printf("MSG: Decorator NOT Chosen - couldn't load decorator\n");
|
|||||||
BStringItem *item=(BStringItem*)declist->ItemAt(declist->CurrentSelection());
|
BStringItem *item=(BStringItem*)declist->ItemAt(declist->CurrentSelection());
|
||||||
path=(item)?item->Text():path="Title";
|
path=(item)?item->Text():path="Title";
|
||||||
decorator->SetDriver(driver);
|
decorator->SetDriver(driver);
|
||||||
|
decorator->SetFocus(true);
|
||||||
decorator->SetTitle(path.String());
|
decorator->SetTitle(path.String());
|
||||||
decorator->SetColors(colorset);
|
decorator->SetColors(colorset);
|
||||||
decorator->Draw();
|
decorator->Draw();
|
||||||
@ -185,7 +191,7 @@ void DecView::SaveSettings(void)
|
|||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
BString path(SERVER_SETTINGS_DIR);
|
||||||
path+="DecoratorSettings";
|
path+="DecoratorSettings";
|
||||||
printf("%s\n",path.String());
|
STRACE(("%s\n",path.String()));
|
||||||
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
||||||
|
|
||||||
settings.MakeEmpty();
|
settings.MakeEmpty();
|
||||||
@ -228,35 +234,33 @@ void DecView::LoadSettings(void)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Error unflattening settings file %s\n",path.String());
|
STRACE(("Error unflattening settings file %s\n",path.String()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecView::NotifyServer(void)
|
void DecView::NotifyServer(void)
|
||||||
{
|
{
|
||||||
// Send a message to the app_server to tell it which decorator we have selected.
|
// Send a message to the app_server to tell it which decorator we have selected.
|
||||||
|
|
||||||
port_id serverport=find_port(SERVER_PORT_NAME);
|
|
||||||
|
|
||||||
if(serverport==B_NAME_NOT_FOUND)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BStringItem *item=(BStringItem*)declist->ItemAt(declist->CurrentSelection());
|
BStringItem *item=(BStringItem*)declist->ItemAt(declist->CurrentSelection());
|
||||||
if(!item)
|
if(!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
port_id serverport=find_port(SERVER_PORT_NAME);
|
||||||
|
if(serverport==B_NAME_NOT_FOUND)
|
||||||
|
return;
|
||||||
|
|
||||||
PortLink *pl=new PortLink(serverport);
|
|
||||||
pl->SetOpCode(SET_DECORATOR);
|
PortLink pl(serverport);
|
||||||
pl->Attach(item->Text(),strlen(item->Text())+1);
|
pl.SetOpCode(AS_SET_DECORATOR);
|
||||||
pl->Flush();
|
pl.Attach(item->Text(),strlen(item->Text())+1);
|
||||||
delete pl;
|
pl.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecView::GetDecorators(void)
|
void DecView::GetDecorators(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("DecView::GetDecorators()\n");
|
STRACE(("DecView::GetDecorators()\n"));
|
||||||
#endif
|
|
||||||
BDirectory dir;
|
BDirectory dir;
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
BPath path;
|
BPath path;
|
||||||
@ -273,37 +277,37 @@ printf("DecView::GetDecorators()\n");
|
|||||||
{
|
{
|
||||||
case B_NAME_TOO_LONG:
|
case B_NAME_TOO_LONG:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: Couldn't open the folder for decorators - path string too long.\n");
|
STRACE(("DecView::GetDecorators: Couldn't open the folder for decorators - path string too long.\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_ENTRY_NOT_FOUND:
|
case B_ENTRY_NOT_FOUND:
|
||||||
{
|
{
|
||||||
printf("Couldn't open the folder for decorators - entry not found\n");
|
STRACE(("Couldn't open the folder for decorators - entry not found\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_BAD_VALUE:
|
case B_BAD_VALUE:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: Couldn't open the folder for decorators - bad path\n");
|
STRACE(("DecView::GetDecorators: Couldn't open the folder for decorators - bad path\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_NO_MEMORY:
|
case B_NO_MEMORY:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: No memory left. We're probably going to crash now\n");
|
STRACE(("DecView::GetDecorators: No memory left. We're probably going to crash now\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_BUSY:
|
case B_BUSY:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: Couldn't open the folder for decorators - node busy\n");
|
STRACE(("DecView::GetDecorators: Couldn't open the folder for decorators - node busy\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_FILE_ERROR:
|
case B_FILE_ERROR:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: Couldn't open the folder for decorators - general file error\n");
|
STRACE(("DecView::GetDecorators: Couldn't open the folder for decorators - general file error\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_NO_MORE_FDS:
|
case B_NO_MORE_FDS:
|
||||||
{
|
{
|
||||||
printf("DecView::GetDecorators: Couldn't open the folder for decorators - no more file descriptors\n");
|
STRACE(("DecView::GetDecorators: Couldn't open the folder for decorators - no more file descriptors\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,9 +344,9 @@ bool DecView::LoadDecorator(const char *path)
|
|||||||
if(stat!=B_OK)
|
if(stat!=B_OK)
|
||||||
{
|
{
|
||||||
unload_add_on(addon);
|
unload_add_on(addon);
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("LoadDecorator(%s): Couldn't get version symbol\n",path);
|
STRACE(("LoadDecorator(%s): Couldn't get version symbol\n",path));
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -355,16 +359,16 @@ printf("LoadDecorator(%s): Couldn't get version symbol\n",path);
|
|||||||
if(stat!=B_OK)
|
if(stat!=B_OK)
|
||||||
{
|
{
|
||||||
unload_add_on(addon);
|
unload_add_on(addon);
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("LoadDecorator(%s): Couldn't get allocation symbol\n",path);
|
STRACE(("LoadDecorator(%s): Couldn't get allocation symbol\n",path));
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(decorator!=NULL)
|
if(decorator!=NULL)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("LoadDecorator(): Deleting old decorator\n");
|
STRACE(("LoadDecorator(): Deleting old decorator\n"));
|
||||||
#endif
|
|
||||||
delete decorator;
|
delete decorator;
|
||||||
decorator=NULL;
|
decorator=NULL;
|
||||||
|
|
||||||
@ -388,45 +392,34 @@ BString DecView::ConvertIndexToPath(int32 index)
|
|||||||
BStringItem *item=(BStringItem*)declist->ItemAt(index);
|
BStringItem *item=(BStringItem*)declist->ItemAt(index);
|
||||||
if(!item)
|
if(!item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("ConvertIndexToPath(): Couldn't get item for index %ld\n",index);
|
STRACE(("ConvertIndexToPath(): Couldn't get item for index %ld\n",index));
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
BString path(DECORATORS_DIR);
|
BString path(DECORATORS_DIR);
|
||||||
path+=item->Text();
|
path+=item->Text();
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("ConvertIndexToPath(): returned %s\n",path.String());
|
STRACE(("ConvertIndexToPath(): returned %s\n",path.String()));
|
||||||
#endif
|
|
||||||
return BString(path.String());
|
return BString(path.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecView::SetColors(const BMessage &message)
|
void DecView::SetColors(const ColorSet &set)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("DecView::SetColors\n");
|
STRACE(("DecView::SetColors\n"));
|
||||||
#endif
|
|
||||||
if(UnpackSettings(&colorset,message))
|
colorset=set;
|
||||||
|
if(decorator)
|
||||||
{
|
{
|
||||||
if(decorator)
|
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
|
||||||
{
|
decorator->SetColors(colorset);
|
||||||
// ldata.highcolor.SetColor(colorset.desktop);
|
decorator->Draw();
|
||||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
|
|
||||||
decorator->SetColors(colorset);
|
|
||||||
decorator->Draw();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
printf("DecView::SetColors: NULL decorator\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
STRACE(("DecView::SetColors: NULL decorator\n"));
|
||||||
printf("DecView::SetColors: UnpackSetting returned false\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,9 +427,7 @@ bool DecView::UnpackSettings(ColorSet *set, const BMessage &msg)
|
|||||||
{
|
{
|
||||||
if(!set)
|
if(!set)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DECORATOR
|
STRACE(("UnpackSettings(): NULL parameter\n"));
|
||||||
printf("UnpackSettings(): NULL parameter\n");
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rgb_color *col;
|
rgb_color *col;
|
||||||
@ -492,6 +483,5 @@ printf("UnpackSettings(): NULL parameter\n");
|
|||||||
set->inactive_window_tab=*col;
|
set->inactive_window_tab=*col;
|
||||||
if(msg.FindData("Inactive Window Tab Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
if(msg.FindData("Inactive Window Tab Text",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||||
set->inactive_window_tab_text=*col;
|
set->inactive_window_tab_text=*col;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
void LoadSettings(void);
|
void LoadSettings(void);
|
||||||
void NotifyServer(void);
|
void NotifyServer(void);
|
||||||
void GetDecorators(void);
|
void GetDecorators(void);
|
||||||
void SetColors(const BMessage &message);
|
void SetColors(const ColorSet &set);
|
||||||
bool LoadDecorator(const char *path);
|
bool LoadDecorator(const char *path);
|
||||||
BString ConvertIndexToPath(int32 index);
|
BString ConvertIndexToPath(int32 index);
|
||||||
protected:
|
protected:
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#define COLOR_SETTINGS_NAME "system_colors"
|
#define COLOR_SETTINGS_NAME "system_colors"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define APPEARANCE_APP_SIGNATURE "application/x-vnd.obos-Appearance"
|
||||||
|
|
||||||
#define APPLY_SETTINGS 'aply'
|
#define APPLY_SETTINGS 'aply'
|
||||||
#define REVERT_SETTINGS 'rvrt'
|
#define REVERT_SETTINGS 'rvrt'
|
||||||
#define DEFAULT_SETTINGS 'dflt'
|
#define DEFAULT_SETTINGS 'dflt'
|
||||||
|
Loading…
Reference in New Issue
Block a user