Added a menu to allow the user to choose the decorator. Untested, but theoretically working. I'll be content with the user being able pick a decorator and tweak system colors for R1.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20219 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2007-02-24 02:03:08 +00:00
parent 9439d163d4
commit 5605e701d7
3 changed files with 77 additions and 15 deletions
+64 -6
View File
@@ -8,6 +8,7 @@
#include <OS.h> #include <OS.h>
#include <Directory.h> #include <Directory.h>
#include <Alert.h> #include <Alert.h>
#include <Messenger.h>
#include <storage/Path.h> #include <storage/Path.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
@@ -30,18 +31,57 @@
#endif #endif
#define COLOR_DROPPED 'cldp' #define COLOR_DROPPED 'cldp'
#define DECORATOR_CHANGED 'dcch'
namespace BPrivate
{
int32 count_decorators(void);
status_t set_decorator(const int32 &index);
int32 get_decorator(void);
status_t get_decorator_name(const int32 &index, BString &name);
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
}
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) : BView(frame,name,resize,flags),
fDecorMenu(NULL)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// Set up list of color fAttributes BRect rect(Bounds().InsetByCopy(10,10));
BRect rect(10,10,200,85);
fAttrList = new BListView(rect,"AttributeList");
fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_LEFT | B_FOLLOW_TOP, #ifdef HAIKU_TARGET_PLATFORM_HAIKU
0, false, true); fDecorMenu = new BMenu("Window Style");
int32 decorCount = BPrivate::count_decorators();
if (decorCount > 1) {
for (int32 i = 0; i < decorCount; i++) {
BString name;
BPrivate::get_decorator_name(i, name);
fDecorMenu->AddItem(new BMenuItem(name.String(),
new BMessage(DECORATOR_CHANGED)));
}
BMenuField *field = new BMenuField(rect, "menufield", "Window Style",
fDecorMenu, B_FOLLOW_RIGHT |
B_FOLLOW_TOP);
AddChild(field);
field->SetDivider(be_plain_font->StringWidth("Window style: ") + 5);
field->ResizeToPreferred();
field->MoveTo(Bounds().right - field->Bounds().Width(), 10);
rect = Bounds().InsetByCopy(10,10);
rect.OffsetTo(10, field->Frame().bottom + 10);
}
fDecorMenu->ItemAt(BPrivate::get_decorator())->SetMarked(true);
#endif
// Set up list of color fAttributes
rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom = rect.top + 75;
fAttrList = new BListView(rect,"AttributeList", B_SINGLE_SELECTION_LIST,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fScrollView = new BScrollView("ScrollView",fAttrList, B_FOLLOW_LEFT_RIGHT |
B_FOLLOW_TOP, 0, false, true);
AddChild(fScrollView); AddChild(fScrollView);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -126,6 +166,8 @@ APRView::AttachedToWindow(void)
fPicker->SetValue(fCurrentSet.StringToColor(fAttrString.String())); fPicker->SetValue(fCurrentSet.StringToColor(fAttrString.String()));
fDecorMenu->SetTargetForItems(BMessenger(this));
Window()->ResizeTo(MAX(fPicker->Frame().right,fPicker->Frame().right) + 10, Window()->ResizeTo(MAX(fPicker->Frame().right,fPicker->Frame().right) + 10,
fDefaults->Frame().bottom + 10); fDefaults->Frame().bottom + 10);
LoadSettings(); LoadSettings();
@@ -147,6 +189,14 @@ APRView::MessageReceived(BMessage *msg)
} }
switch(msg->what) { switch(msg->what) {
case DECORATOR_CHANGED: {
int32 index = fDecorMenu->IndexOf(fDecorMenu->FindMarked());
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (index >= 0)
BPrivate::set_decorator(index);
#endif
break;
}
case UPDATE_COLOR: { case UPDATE_COLOR: {
// Received from the color fPicker when its color changes // Received from the color fPicker when its color changes
@@ -187,6 +237,14 @@ APRView::MessageReceived(BMessage *msg)
fCurrentSet.SetToDefaults(); fCurrentSet.SetToDefaults();
UpdateControlsFromAttr(fAttrString.String()); UpdateControlsFromAttr(fAttrString.String());
BMenuItem *item = fDecorMenu->FindItem("Default");
if (item)
{
item->SetMarked(true);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
BPrivate::set_decorator(fDecorMenu->IndexOf(item));
#endif
}
break; break;
} }
default: default:
+3
View File
@@ -18,6 +18,7 @@
#include <ScrollBar.h> #include <ScrollBar.h>
#include <String.h> #include <String.h>
#include <Menu.h> #include <Menu.h>
#include <MenuField.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <StringView.h> #include <StringView.h>
@@ -60,6 +61,8 @@ protected:
ColorSet fCurrentSet; ColorSet fCurrentSet;
ColorSet fPrevSet; ColorSet fPrevSet;
BMenu *fDecorMenu;
}; };
#endif #endif
+1
View File
@@ -1,5 +1,6 @@
SubDir HAIKU_TOP src preferences appearance ; SubDir HAIKU_TOP src preferences appearance ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders app [ FDirName servers app ] ; UsePrivateHeaders app [ FDirName servers app ] ;
Preference Appearance : Preference Appearance :