* Made preferences window font sensitive, this fixes bug #196.
* BottomPrefsView is no longer needed (just contained two buttons, moved their creation to the PrefsWindow class). * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16705 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
//****************************************************************************************
|
|
||||||
//
|
|
||||||
// File: BottomPrefsView.cpp
|
|
||||||
//
|
|
||||||
// Written by: Daniel Switkin
|
|
||||||
//
|
|
||||||
// Copyright 1999, Be Incorporated
|
|
||||||
//
|
|
||||||
//****************************************************************************************
|
|
||||||
|
|
||||||
#include "BottomPrefsView.h"
|
|
||||||
#include "Common.h"
|
|
||||||
#include <interface/Button.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
BottomPrefsView::BottomPrefsView(BRect rect, const char *name) :
|
|
||||||
BView(rect, name, B_FOLLOW_NONE, B_WILL_DRAW) {
|
|
||||||
|
|
||||||
// Set the background color dynamically, don't hardcode 216, 216, 216
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
BRect r = Bounds();
|
|
||||||
r.right -= 13;
|
|
||||||
float width = be_plain_font->StringWidth("OK") + 20;
|
|
||||||
r.left = (width > 75) ? (r.right - width) : (r.right - 75);
|
|
||||||
r.top += 10;
|
|
||||||
r.bottom = r.top + 24;
|
|
||||||
BButton *ok = new BButton(r, "OKButton", "OK", new BMessage(PRV_BOTTOM_OK));
|
|
||||||
AddChild(ok);
|
|
||||||
|
|
||||||
r.right = r.left - 10;
|
|
||||||
width = be_plain_font->StringWidth("Defaults") + 20;
|
|
||||||
r.left = (width > 75) ? (r.right - width) : (r.right - 75);
|
|
||||||
BButton *defaults = new BButton(r, "DefaultsButton", "Defaults", new BMessage(PRV_BOTTOM_DEFAULTS));
|
|
||||||
AddChild(defaults);
|
|
||||||
|
|
||||||
ok->MakeDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do a little drawing to fit better with BTabView
|
|
||||||
void BottomPrefsView::Draw(BRect rect) {
|
|
||||||
PushState();
|
|
||||||
|
|
||||||
BRect bounds = Bounds();
|
|
||||||
SetHighColor(255, 255, 255, 255);
|
|
||||||
StrokeLine(BPoint(0, 0), BPoint(bounds.right - 1, 0));
|
|
||||||
StrokeLine(BPoint(0, 0), BPoint(0, bounds.bottom - 1));
|
|
||||||
SetHighColor(96, 96, 96, 255);
|
|
||||||
StrokeLine(BPoint(bounds.right, 0), BPoint(bounds.right, bounds.bottom));
|
|
||||||
StrokeLine(BPoint(0, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
|
||||||
|
|
||||||
PopState();
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//****************************************************************************************
|
|
||||||
//
|
|
||||||
// File: BottomPrefsView.h
|
|
||||||
//
|
|
||||||
// Written by: Daniel Switkin
|
|
||||||
//
|
|
||||||
// Copyright 1999, Be Incorporated
|
|
||||||
//
|
|
||||||
//****************************************************************************************
|
|
||||||
|
|
||||||
#ifndef BOTTOMPREFSVIEW_H
|
|
||||||
#define BOTTOMPREFSVIEW_H
|
|
||||||
|
|
||||||
#include <interface/View.h>
|
|
||||||
|
|
||||||
class BottomPrefsView : public BView {
|
|
||||||
public:
|
|
||||||
BottomPrefsView(BRect rect, const char *name);
|
|
||||||
void Draw(BRect rect);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+248
-187
@@ -1,227 +1,293 @@
|
|||||||
//****************************************************************************************
|
/*
|
||||||
//
|
* Copyright 2002-2006 Haiku, Inc. All Rights Reserved.
|
||||||
// File: ConfigView.cpp
|
* Distributed under the terms of the MIT license.
|
||||||
//
|
*
|
||||||
// Written by: Daniel Switkin
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
//
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
// Copyright 1999, Be Incorporated
|
*
|
||||||
//
|
* Written by: Daniel Switkin
|
||||||
//****************************************************************************************
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ConfigView.h"
|
#include "ConfigView.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "PulseApp.h"
|
#include "PulseApp.h"
|
||||||
#include "PrefsWindow.h"
|
#include "PrefsWindow.h"
|
||||||
#include <interface/Box.h>
|
|
||||||
|
#include <CheckBox.h>
|
||||||
|
#include <RadioButton.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
RTColorControl::RTColorControl(BPoint point, BMessage *message)
|
|
||||||
: BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false) {
|
|
||||||
|
|
||||||
|
RTColorControl::RTColorControl(BPoint point, BMessage *message)
|
||||||
|
: BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a message every time the color changes, not just
|
|
||||||
// when the mouse button is released
|
/*!
|
||||||
void RTColorControl::SetValue(int32 color) {
|
Send a message every time the color changes, not just
|
||||||
|
when the mouse button is released
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RTColorControl::SetValue(int32 color)
|
||||||
|
{
|
||||||
BColorControl::SetValue(color);
|
BColorControl::SetValue(color);
|
||||||
Invoke();
|
Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
// A single class for all three prefs views, needs to be
|
|
||||||
// customized below to give each control the right message
|
|
||||||
ConfigView::ConfigView(BRect rect, const char *name, int mode, Prefs *prefs) :
|
|
||||||
BView(rect, name, B_FOLLOW_NONE, B_WILL_DRAW) {
|
|
||||||
|
|
||||||
this->mode = mode;
|
// #pragma mark -
|
||||||
first_time_attached = true;
|
|
||||||
fadecolors = NULL;
|
|
||||||
active = idle = frame = NULL;
|
|
||||||
iconwidth = NULL;
|
|
||||||
|
|
||||||
BRect r(6, 5, 296, 115);
|
|
||||||
BBox *bbox = new BBox(r, "BBox");
|
|
||||||
bbox->SetLabel("Bar Colors");
|
|
||||||
AddChild(bbox);
|
|
||||||
|
|
||||||
if (mode == NORMAL_WINDOW_MODE) {
|
/*!
|
||||||
colorcontrol = new RTColorControl(BPoint(10, 20),
|
A single class for all three prefs views, needs to be
|
||||||
new BMessage(PRV_NORMAL_CHANGE_COLOR));
|
customized below to give each control the right message
|
||||||
} else if (mode == MINI_WINDOW_MODE) {
|
*/
|
||||||
colorcontrol = new RTColorControl(BPoint(10, 20),
|
ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& target,
|
||||||
new BMessage(PRV_MINI_CHANGE_COLOR));
|
Prefs *prefs)
|
||||||
} else {
|
: BBox(rect, name, B_FOLLOW_NONE, B_WILL_DRAW),
|
||||||
colorcontrol = new RTColorControl(BPoint(10, 20),
|
fMode(mode),
|
||||||
new BMessage(PRV_DESKBAR_CHANGE_COLOR));
|
fTarget(target),
|
||||||
}
|
fPrefs(prefs),
|
||||||
|
fFirstTimeAttached(true)
|
||||||
|
{
|
||||||
|
fFadeCheckBox = NULL;
|
||||||
|
fActiveButton = fIdleButton = fFrameButton = NULL;
|
||||||
|
fIconWidthControl = NULL;
|
||||||
|
|
||||||
bbox->AddChild(colorcontrol);
|
SetLabel("Bar Colors");
|
||||||
r = colorcontrol->Frame();
|
|
||||||
r.top = r.bottom + 10;
|
|
||||||
r.bottom = r.top + 15;
|
|
||||||
|
|
||||||
if (mode == NORMAL_WINDOW_MODE) {
|
font_height fontHeight;
|
||||||
r.right = r.left + be_plain_font->StringWidth("Fade colors") + 20;
|
be_bold_font->GetHeight(&fontHeight);
|
||||||
fadecolors = new BCheckBox(r, "FadeColors", "Fade colors",
|
|
||||||
|
fColorControl = new RTColorControl(BPoint(10, 5.0f + fontHeight.ascent
|
||||||
|
+ fontHeight.descent), new BMessage(fMode));
|
||||||
|
fColorControl->ResizeToPreferred();
|
||||||
|
AddChild(fColorControl);
|
||||||
|
|
||||||
|
rect = fColorControl->Frame();
|
||||||
|
rect.top = rect.bottom + 10.0f;
|
||||||
|
rect.bottom = rect.top + 15.0f;
|
||||||
|
|
||||||
|
if (mode == PRV_NORMAL_CHANGE_COLOR) {
|
||||||
|
// normal mode
|
||||||
|
|
||||||
|
fFadeCheckBox = new BCheckBox(rect, "FadeColors", "Fade colors",
|
||||||
new BMessage(PRV_NORMAL_FADE_COLORS));
|
new BMessage(PRV_NORMAL_FADE_COLORS));
|
||||||
bbox->AddChild(fadecolors);
|
fFadeCheckBox->ResizeToPreferred();
|
||||||
|
AddChild(fFadeCheckBox);
|
||||||
|
|
||||||
colorcontrol->SetValue(prefs->normal_bar_color);
|
fColorControl->SetValue(fPrefs->normal_bar_color);
|
||||||
fadecolors->SetValue(prefs->normal_fade_colors);
|
fFadeCheckBox->SetValue(fPrefs->normal_fade_colors);
|
||||||
} else if (mode == MINI_WINDOW_MODE) {
|
} else if (mode == PRV_MINI_CHANGE_COLOR) {
|
||||||
r.right = r.left + be_plain_font->StringWidth("Active color") + 20;
|
// mini mode
|
||||||
active = new BRadioButton(r, "ActiveColor", "Active color",
|
|
||||||
|
fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color",
|
||||||
new BMessage(PRV_MINI_ACTIVE));
|
new BMessage(PRV_MINI_ACTIVE));
|
||||||
bbox->AddChild(active);
|
fActiveButton->ResizeToPreferred();
|
||||||
active->SetValue(B_CONTROL_ON);
|
fActiveButton->SetValue(B_CONTROL_ON);
|
||||||
|
AddChild(fActiveButton);
|
||||||
|
|
||||||
r.left = r.right + 5;
|
rect.left = fActiveButton->Frame().right + 5.0f;
|
||||||
r.right = r.left + be_plain_font->StringWidth("Idle color") + 20;
|
fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color",
|
||||||
idle = new BRadioButton(r, "IdleColor", "Idle color",
|
|
||||||
new BMessage(PRV_MINI_IDLE));
|
new BMessage(PRV_MINI_IDLE));
|
||||||
bbox->AddChild(idle);
|
fIdleButton->ResizeToPreferred();
|
||||||
|
AddChild(fIdleButton);
|
||||||
|
|
||||||
r.left = r.right + 5;
|
rect.left = fIdleButton->Frame().right + 5.0f;
|
||||||
r.right = r.left + be_plain_font->StringWidth("Frame color") + 20;
|
fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color",
|
||||||
frame = new BRadioButton(r, "FrameColor", "Frame color",
|
|
||||||
new BMessage(PRV_MINI_FRAME));
|
new BMessage(PRV_MINI_FRAME));
|
||||||
bbox->AddChild(frame);
|
fFrameButton->ResizeToPreferred();
|
||||||
|
AddChild(fFrameButton);
|
||||||
|
|
||||||
colorcontrol->SetValue(prefs->mini_active_color);
|
fColorControl->SetValue(fPrefs->mini_active_color);
|
||||||
} else {
|
} else {
|
||||||
bbox->ResizeBy(0, 20);
|
// deskbar mode
|
||||||
|
fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color",
|
||||||
r.right = r.left + be_plain_font->StringWidth("Active color") + 20;
|
|
||||||
active = new BRadioButton(r, "ActiveColor", "Active color",
|
|
||||||
new BMessage(PRV_DESKBAR_ACTIVE));
|
new BMessage(PRV_DESKBAR_ACTIVE));
|
||||||
bbox->AddChild(active);
|
fActiveButton->ResizeToPreferred();
|
||||||
active->SetValue(B_CONTROL_ON);
|
fActiveButton->SetValue(B_CONTROL_ON);
|
||||||
|
AddChild(fActiveButton);
|
||||||
|
|
||||||
r.left = r.right + 5;
|
rect.left = fActiveButton->Frame().right + 5.0f;
|
||||||
r.right = r.left + be_plain_font->StringWidth("Idle color") + 20;
|
fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color",
|
||||||
idle = new BRadioButton(r, "IdleColor", "Idle color",
|
|
||||||
new BMessage(PRV_DESKBAR_IDLE));
|
new BMessage(PRV_DESKBAR_IDLE));
|
||||||
bbox->AddChild(idle);
|
fIdleButton->ResizeToPreferred();
|
||||||
|
AddChild(fIdleButton);
|
||||||
|
|
||||||
r.left = r.right + 5;
|
rect.left = fIdleButton->Frame().right + 5.0f;
|
||||||
r.right = r.left + be_plain_font->StringWidth("Frame color") + 20;
|
fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color",
|
||||||
frame = new BRadioButton(r, "FrameColor", "Frame color",
|
|
||||||
new BMessage(PRV_DESKBAR_FRAME));
|
new BMessage(PRV_DESKBAR_FRAME));
|
||||||
bbox->AddChild(frame);
|
fFrameButton->ResizeToPreferred();
|
||||||
|
AddChild(fFrameButton);
|
||||||
|
|
||||||
|
rect.left = fColorControl->Frame().left;
|
||||||
|
rect.top = fActiveButton->Frame().bottom + 5.0f;
|
||||||
|
|
||||||
r.top = active->Frame().bottom + 1;
|
|
||||||
r.bottom = r.top + 15;
|
|
||||||
r.left = 10;
|
|
||||||
r.right = r.left + be_plain_font->StringWidth("Width of icon:") + 5 + 30;
|
|
||||||
char temp[10];
|
char temp[10];
|
||||||
sprintf(temp, "%d", prefs->deskbar_icon_width);
|
snprintf(temp, sizeof(temp), "%d", fPrefs->deskbar_icon_width);
|
||||||
iconwidth = new BTextControl(r, "Width", "Width of icon:", temp,
|
fIconWidthControl = new BTextControl(rect, "Width", "Width of icon:", temp,
|
||||||
new BMessage(PRV_DESKBAR_ICON_WIDTH));
|
new BMessage(PRV_DESKBAR_ICON_WIDTH));
|
||||||
bbox->AddChild(iconwidth);
|
AddChild(fIconWidthControl);
|
||||||
iconwidth->SetDivider(be_plain_font->StringWidth("Width of icon:") + 5);
|
fIconWidthControl->SetDivider(be_plain_font->StringWidth(
|
||||||
//iconwidth->SetModificationMessage(new BMessage(PRV_DESKBAR_ICON_WIDTH));
|
fIconWidthControl->Label()) + 5.0f);
|
||||||
|
|
||||||
for (int x = 0; x < 256; x++) {
|
for (int c = 0; c < 256; c++) {
|
||||||
if (x < '0' || x > '9') iconwidth->TextView()->DisallowChar(x);
|
if (!isdigit(c))
|
||||||
|
fIconWidthControl->TextView()->DisallowChar(c);
|
||||||
}
|
}
|
||||||
iconwidth->TextView()->SetMaxBytes(2);
|
fIconWidthControl->TextView()->SetMaxBytes(2);
|
||||||
|
|
||||||
colorcontrol->SetValue(prefs->deskbar_active_color);
|
float width, height;
|
||||||
|
fIconWidthControl->GetPreferredSize(&width, &height);
|
||||||
|
fIconWidthControl->ResizeTo(fIconWidthControl->Divider() + 32.0f
|
||||||
|
+ fIconWidthControl->StringWidth("999"), height);
|
||||||
|
|
||||||
|
fColorControl->SetValue(fPrefs->deskbar_active_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigView::AttachedToWindow() {
|
|
||||||
|
void
|
||||||
|
ConfigView::GetPreferredSize(float* _width, float* _height)
|
||||||
|
{
|
||||||
|
float right, bottom;
|
||||||
|
|
||||||
|
if (fMode == PRV_NORMAL_CHANGE_COLOR) {
|
||||||
|
// normal mode
|
||||||
|
bottom = fFadeCheckBox->Frame().bottom;
|
||||||
|
right = fFadeCheckBox->Frame().right;
|
||||||
|
} else if (fMode == PRV_MINI_CHANGE_COLOR) {
|
||||||
|
// mini mode
|
||||||
|
bottom = fIdleButton->Frame().bottom;
|
||||||
|
right = fFrameButton->Frame().right;
|
||||||
|
} else {
|
||||||
|
// deskbar mode
|
||||||
|
bottom = fIconWidthControl->Frame().bottom;
|
||||||
|
right = fFrameButton->Frame().right;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (right < fColorControl->Frame().right)
|
||||||
|
right = fColorControl->Frame().right;
|
||||||
|
if (right < 300)
|
||||||
|
right = 300;
|
||||||
|
|
||||||
|
if (_width)
|
||||||
|
*_width = right + 10.0f;
|
||||||
|
if (_height)
|
||||||
|
*_height = bottom + 8.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfigView::AttachedToWindow()
|
||||||
|
{
|
||||||
BView::AttachedToWindow();
|
BView::AttachedToWindow();
|
||||||
|
|
||||||
// AttachedToWindow() gets called every time this tab is brought
|
// AttachedToWindow() gets called every time this tab is brought
|
||||||
// to the front, but we only want this initialization to happen once
|
// to the front, but we only want this initialization to happen once
|
||||||
if (first_time_attached) {
|
if (fFirstTimeAttached) {
|
||||||
BMessenger messenger(this);
|
if (Parent() != NULL)
|
||||||
colorcontrol->SetTarget(messenger);
|
SetViewColor(Parent()->ViewColor());
|
||||||
if (fadecolors != NULL) fadecolors->SetTarget(messenger);
|
else
|
||||||
if (active != NULL) active->SetTarget(messenger);
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
if (idle != NULL) idle->SetTarget(messenger);
|
|
||||||
if (frame != NULL) frame->SetTarget(messenger);
|
|
||||||
if (iconwidth != NULL) iconwidth->SetTarget(messenger);
|
|
||||||
|
|
||||||
first_time_attached = false;
|
BMessenger messenger(this);
|
||||||
|
fColorControl->SetTarget(messenger);
|
||||||
|
if (fFadeCheckBox != NULL)
|
||||||
|
fFadeCheckBox->SetTarget(messenger);
|
||||||
|
if (fActiveButton != NULL)
|
||||||
|
fActiveButton->SetTarget(messenger);
|
||||||
|
if (fIdleButton != NULL)
|
||||||
|
fIdleButton->SetTarget(messenger);
|
||||||
|
if (fFrameButton != NULL)
|
||||||
|
fFrameButton->SetTarget(messenger);
|
||||||
|
if (fIconWidthControl != NULL)
|
||||||
|
fIconWidthControl->SetTarget(messenger);
|
||||||
|
|
||||||
|
fFirstTimeAttached = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigView::MessageReceived(BMessage *message) {
|
|
||||||
PrefsWindow *prefswindow = (PrefsWindow *)Window();
|
|
||||||
if (prefswindow == NULL) return;
|
|
||||||
Prefs *prefs = prefswindow->prefs;
|
|
||||||
BMessenger *messenger = prefswindow->messenger;
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfigView::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
// These two send the color and the status of the fade checkbox together
|
// These two send the color and the status of the fade checkbox together
|
||||||
case PRV_NORMAL_FADE_COLORS:
|
case PRV_NORMAL_FADE_COLORS:
|
||||||
case PRV_NORMAL_CHANGE_COLOR: {
|
case PRV_NORMAL_CHANGE_COLOR:
|
||||||
bool fade_colors = (bool)fadecolors->Value();
|
{
|
||||||
int32 bar_color = colorcontrol->Value();
|
bool fade_colors = (bool)fFadeCheckBox->Value();
|
||||||
|
int32 bar_color = fColorControl->Value();
|
||||||
message->AddInt32("color", bar_color);
|
message->AddInt32("color", bar_color);
|
||||||
message->AddBool("fade", fade_colors);
|
message->AddBool("fade", fade_colors);
|
||||||
prefs->normal_fade_colors = fade_colors;
|
fPrefs->normal_fade_colors = fade_colors;
|
||||||
prefs->normal_bar_color = bar_color;
|
fPrefs->normal_bar_color = bar_color;
|
||||||
messenger->SendMessage(message);
|
|
||||||
|
fTarget.SendMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Share the single color control among three values
|
// Share the single color control among three values
|
||||||
case PRV_MINI_ACTIVE:
|
case PRV_MINI_ACTIVE:
|
||||||
colorcontrol->SetValue(prefs->mini_active_color);
|
fColorControl->SetValue(fPrefs->mini_active_color);
|
||||||
break;
|
break;
|
||||||
case PRV_MINI_IDLE:
|
case PRV_MINI_IDLE:
|
||||||
colorcontrol->SetValue(prefs->mini_idle_color);
|
fColorControl->SetValue(fPrefs->mini_idle_color);
|
||||||
break;
|
break;
|
||||||
case PRV_MINI_FRAME:
|
case PRV_MINI_FRAME:
|
||||||
colorcontrol->SetValue(prefs->mini_frame_color);
|
fColorControl->SetValue(fPrefs->mini_frame_color);
|
||||||
break;
|
break;
|
||||||
case PRV_MINI_CHANGE_COLOR: {
|
case PRV_MINI_CHANGE_COLOR: {
|
||||||
int32 color = colorcontrol->Value();
|
int32 color = fColorControl->Value();
|
||||||
if (active->Value()) {
|
if (fActiveButton->Value())
|
||||||
prefs->mini_active_color = color;
|
fPrefs->mini_active_color = color;
|
||||||
} else if (idle->Value()) {
|
else if (fIdleButton->Value())
|
||||||
prefs->mini_idle_color = color;
|
fPrefs->mini_idle_color = color;
|
||||||
} else {
|
else
|
||||||
prefs->mini_frame_color = color;
|
fPrefs->mini_frame_color = color;
|
||||||
}
|
|
||||||
message->AddInt32("active_color", prefs->mini_active_color);
|
message->AddInt32("active_color", fPrefs->mini_active_color);
|
||||||
message->AddInt32("idle_color", prefs->mini_idle_color);
|
message->AddInt32("idle_color", fPrefs->mini_idle_color);
|
||||||
message->AddInt32("frame_color", prefs->mini_frame_color);
|
message->AddInt32("frame_color", fPrefs->mini_frame_color);
|
||||||
messenger->SendMessage(message);
|
fTarget.SendMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PRV_DESKBAR_ACTIVE:
|
case PRV_DESKBAR_ACTIVE:
|
||||||
colorcontrol->SetValue(prefs->deskbar_active_color);
|
fColorControl->SetValue(fPrefs->deskbar_active_color);
|
||||||
break;
|
break;
|
||||||
case PRV_DESKBAR_IDLE:
|
case PRV_DESKBAR_IDLE:
|
||||||
colorcontrol->SetValue(prefs->deskbar_idle_color);
|
fColorControl->SetValue(fPrefs->deskbar_idle_color);
|
||||||
break;
|
break;
|
||||||
case PRV_DESKBAR_FRAME:
|
case PRV_DESKBAR_FRAME:
|
||||||
colorcontrol->SetValue(prefs->deskbar_frame_color);
|
fColorControl->SetValue(fPrefs->deskbar_frame_color);
|
||||||
break;
|
break;
|
||||||
case PRV_DESKBAR_ICON_WIDTH:
|
case PRV_DESKBAR_ICON_WIDTH:
|
||||||
UpdateDeskbarIconWidth();
|
UpdateDeskbarIconWidth();
|
||||||
break;
|
break;
|
||||||
case PRV_DESKBAR_CHANGE_COLOR: {
|
case PRV_DESKBAR_CHANGE_COLOR: {
|
||||||
int32 color = colorcontrol->Value();
|
int32 color = fColorControl->Value();
|
||||||
if (active->Value()) {
|
if (fActiveButton->Value())
|
||||||
prefs->deskbar_active_color = color;
|
fPrefs->deskbar_active_color = color;
|
||||||
} else if (idle->Value()) {
|
else if (fIdleButton->Value())
|
||||||
prefs->deskbar_idle_color = color;
|
fPrefs->deskbar_idle_color = color;
|
||||||
} else {
|
else
|
||||||
prefs->deskbar_frame_color = color;
|
fPrefs->deskbar_frame_color = color;
|
||||||
}
|
|
||||||
message->AddInt32("active_color", prefs->deskbar_active_color);
|
message->AddInt32("active_color", fPrefs->deskbar_active_color);
|
||||||
message->AddInt32("idle_color", prefs->deskbar_idle_color);
|
message->AddInt32("idle_color", fPrefs->deskbar_idle_color);
|
||||||
message->AddInt32("frame_color", prefs->deskbar_frame_color);
|
message->AddInt32("frame_color", fPrefs->deskbar_frame_color);
|
||||||
messenger->SendMessage(message);
|
fTarget.SendMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PRV_BOTTOM_DEFAULTS:
|
case PRV_BOTTOM_DEFAULTS:
|
||||||
ResetDefaults();
|
_ResetDefaults();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
@@ -229,15 +295,13 @@ void ConfigView::MessageReceived(BMessage *message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigView::UpdateDeskbarIconWidth() {
|
|
||||||
PrefsWindow *prefswindow = (PrefsWindow *)Window();
|
|
||||||
if (prefswindow == NULL) return;
|
|
||||||
Prefs *prefs = prefswindow->prefs;
|
|
||||||
BMessenger *messenger = prefswindow->messenger;
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfigView::UpdateDeskbarIconWidth()
|
||||||
|
{
|
||||||
// Make sure the width shows at least one pixel per CPU and
|
// Make sure the width shows at least one pixel per CPU and
|
||||||
// that it will fit in the tray in any Deskbar orientation
|
// that it will fit in the tray in any Deskbar orientation
|
||||||
int width = atoi(iconwidth->Text());
|
int width = atoi(fIconWidthControl->Text());
|
||||||
int min_width = GetMinimumViewWidth();
|
int min_width = GetMinimumViewWidth();
|
||||||
if (width < min_width || width > 50) {
|
if (width < min_width || width > 50) {
|
||||||
char temp[10];
|
char temp[10];
|
||||||
@@ -248,63 +312,60 @@ void ConfigView::UpdateDeskbarIconWidth() {
|
|||||||
strcpy(temp, "50");
|
strcpy(temp, "50");
|
||||||
width = 50;
|
width = 50;
|
||||||
}
|
}
|
||||||
iconwidth->SetText(temp);
|
fIconWidthControl->SetText(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage *message = new BMessage(PRV_DESKBAR_ICON_WIDTH);
|
fPrefs->deskbar_icon_width = width;
|
||||||
message->AddInt32("width", width);
|
|
||||||
prefs->deskbar_icon_width = width;
|
BMessage message(PRV_DESKBAR_ICON_WIDTH);
|
||||||
messenger->SendMessage(message);
|
message.AddInt32("width", width);
|
||||||
delete message;
|
fTarget.SendMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only reset our own controls to default
|
|
||||||
void ConfigView::ResetDefaults() {
|
|
||||||
PrefsWindow *prefswindow = (PrefsWindow *)Window();
|
|
||||||
if (prefswindow == NULL) return;
|
|
||||||
Prefs *prefs = prefswindow->prefs;
|
|
||||||
BMessenger *messenger = prefswindow->messenger;
|
|
||||||
|
|
||||||
if (mode == NORMAL_WINDOW_MODE) {
|
void
|
||||||
colorcontrol->SetValue(DEFAULT_NORMAL_BAR_COLOR);
|
ConfigView::_ResetDefaults()
|
||||||
fadecolors->SetValue(DEFAULT_NORMAL_FADE_COLORS);
|
{
|
||||||
} else if (mode == MINI_WINDOW_MODE) {
|
if (fMode == PRV_NORMAL_CHANGE_COLOR) {
|
||||||
prefs->mini_active_color = DEFAULT_MINI_ACTIVE_COLOR;
|
fColorControl->SetValue(DEFAULT_NORMAL_BAR_COLOR);
|
||||||
prefs->mini_idle_color = DEFAULT_MINI_IDLE_COLOR;
|
fFadeCheckBox->SetValue(DEFAULT_NORMAL_FADE_COLORS);
|
||||||
prefs->mini_frame_color = DEFAULT_MINI_FRAME_COLOR;
|
} else if (fMode == PRV_MINI_CHANGE_COLOR) {
|
||||||
if (active->Value()) {
|
fPrefs->mini_active_color = DEFAULT_MINI_ACTIVE_COLOR;
|
||||||
colorcontrol->SetValue(DEFAULT_MINI_ACTIVE_COLOR);
|
fPrefs->mini_idle_color = DEFAULT_MINI_IDLE_COLOR;
|
||||||
} else if (idle->Value()) {
|
fPrefs->mini_frame_color = DEFAULT_MINI_FRAME_COLOR;
|
||||||
colorcontrol->SetValue(DEFAULT_MINI_IDLE_COLOR);
|
if (fActiveButton->Value())
|
||||||
} else {
|
fColorControl->SetValue(DEFAULT_MINI_ACTIVE_COLOR);
|
||||||
colorcontrol->SetValue(DEFAULT_MINI_FRAME_COLOR);
|
else if (fIdleButton->Value())
|
||||||
}
|
fColorControl->SetValue(DEFAULT_MINI_IDLE_COLOR);
|
||||||
|
else
|
||||||
|
fColorControl->SetValue(DEFAULT_MINI_FRAME_COLOR);
|
||||||
|
|
||||||
BMessage *message = new BMessage(PRV_MINI_CHANGE_COLOR);
|
BMessage *message = new BMessage(PRV_MINI_CHANGE_COLOR);
|
||||||
message->AddInt32("active_color", DEFAULT_MINI_ACTIVE_COLOR);
|
message->AddInt32("active_color", DEFAULT_MINI_ACTIVE_COLOR);
|
||||||
message->AddInt32("idle_color", DEFAULT_MINI_IDLE_COLOR);
|
message->AddInt32("idle_color", DEFAULT_MINI_IDLE_COLOR);
|
||||||
message->AddInt32("frame_color", DEFAULT_MINI_FRAME_COLOR);
|
message->AddInt32("frame_color", DEFAULT_MINI_FRAME_COLOR);
|
||||||
messenger->SendMessage(message);
|
fTarget.SendMessage(message);
|
||||||
} else {
|
} else {
|
||||||
prefs->deskbar_active_color = DEFAULT_DESKBAR_ACTIVE_COLOR;
|
fPrefs->deskbar_active_color = DEFAULT_DESKBAR_ACTIVE_COLOR;
|
||||||
prefs->deskbar_idle_color = DEFAULT_DESKBAR_IDLE_COLOR;
|
fPrefs->deskbar_idle_color = DEFAULT_DESKBAR_IDLE_COLOR;
|
||||||
prefs->deskbar_frame_color = DEFAULT_DESKBAR_FRAME_COLOR;
|
fPrefs->deskbar_frame_color = DEFAULT_DESKBAR_FRAME_COLOR;
|
||||||
if (active->Value()) {
|
if (fActiveButton->Value())
|
||||||
colorcontrol->SetValue(DEFAULT_DESKBAR_ACTIVE_COLOR);
|
fColorControl->SetValue(DEFAULT_DESKBAR_ACTIVE_COLOR);
|
||||||
} else if (idle->Value()) {
|
else if (fIdleButton->Value())
|
||||||
colorcontrol->SetValue(DEFAULT_DESKBAR_IDLE_COLOR);
|
fColorControl->SetValue(DEFAULT_DESKBAR_IDLE_COLOR);
|
||||||
} else {
|
else
|
||||||
colorcontrol->SetValue(DEFAULT_DESKBAR_FRAME_COLOR);
|
fColorControl->SetValue(DEFAULT_DESKBAR_FRAME_COLOR);
|
||||||
}
|
|
||||||
BMessage *message = new BMessage(PRV_DESKBAR_CHANGE_COLOR);
|
BMessage *message = new BMessage(PRV_DESKBAR_CHANGE_COLOR);
|
||||||
message->AddInt32("active_color", DEFAULT_DESKBAR_ACTIVE_COLOR);
|
message->AddInt32("active_color", DEFAULT_DESKBAR_ACTIVE_COLOR);
|
||||||
message->AddInt32("idle_color", DEFAULT_DESKBAR_IDLE_COLOR);
|
message->AddInt32("idle_color", DEFAULT_DESKBAR_IDLE_COLOR);
|
||||||
message->AddInt32("frame_color", DEFAULT_DESKBAR_FRAME_COLOR);
|
message->AddInt32("frame_color", DEFAULT_DESKBAR_FRAME_COLOR);
|
||||||
messenger->SendMessage(message);
|
fTarget.SendMessage(message);
|
||||||
|
|
||||||
char temp[10];
|
char temp[10];
|
||||||
sprintf(temp, "%d", DEFAULT_DESKBAR_ICON_WIDTH);
|
sprintf(temp, "%d", DEFAULT_DESKBAR_ICON_WIDTH);
|
||||||
iconwidth->SetText(temp);
|
fIconWidthControl->SetText(temp);
|
||||||
// Need to force the model message to be sent
|
// Need to force the model message to be sent
|
||||||
iconwidth->Invoke();
|
fIconWidthControl->Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-27
@@ -1,47 +1,61 @@
|
|||||||
//****************************************************************************************
|
/*
|
||||||
//
|
* Copyright 2002-2006 Haiku, Inc. All Rights Reserved.
|
||||||
// File: ConfigView.h
|
* Distributed under the terms of the MIT license.
|
||||||
//
|
*
|
||||||
// Written by: Daniel Switkin
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
//
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
// Copyright 1999, Be Incorporated
|
*
|
||||||
//
|
* Written by: Daniel Switkin
|
||||||
//****************************************************************************************
|
*/
|
||||||
|
#ifndef CONFIG_VIEW_H
|
||||||
|
#define CONFIG_VIEW_H
|
||||||
|
|
||||||
#ifndef CONFIGVIEW_H
|
|
||||||
#define CONFIGVIEW_H
|
|
||||||
|
|
||||||
#include <interface/CheckBox.h>
|
|
||||||
#include <interface/RadioButton.h>
|
|
||||||
#include <interface/TextControl.h>
|
|
||||||
#include <interface/ColorControl.h>
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
|
#include <ColorControl.h>
|
||||||
|
|
||||||
|
class BCheckBox;
|
||||||
|
class BRadioButton;
|
||||||
|
class BTextControl;
|
||||||
|
|
||||||
|
|
||||||
class RTColorControl : public BColorControl {
|
class RTColorControl : public BColorControl {
|
||||||
public:
|
public:
|
||||||
RTColorControl(BPoint point, BMessage *message);
|
RTColorControl(BPoint point, BMessage *message);
|
||||||
void SetValue(int32 color);
|
void SetValue(int32 color);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigView : public BView {
|
class ConfigView : public BBox {
|
||||||
public:
|
public:
|
||||||
ConfigView(BRect rect, const char *name, int mode, Prefs *prefs);
|
ConfigView(BRect rect, const char *name, uint32 mode,
|
||||||
void AttachedToWindow();
|
BMessenger& target, Prefs *prefs);
|
||||||
void MessageReceived(BMessage *message);
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
virtual void GetPreferredSize(float* _width, float* _height);
|
||||||
|
|
||||||
void UpdateDeskbarIconWidth();
|
void UpdateDeskbarIconWidth();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ResetDefaults();
|
void _ResetDefaults();
|
||||||
bool first_time_attached;
|
|
||||||
int mode;
|
int32 fMode;
|
||||||
|
BMessenger fTarget;
|
||||||
|
Prefs* fPrefs;
|
||||||
|
RTColorControl* fColorControl;
|
||||||
|
|
||||||
|
bool fFirstTimeAttached;
|
||||||
|
|
||||||
RTColorControl *colorcontrol;
|
|
||||||
// For Normal
|
// For Normal
|
||||||
BCheckBox *fadecolors;
|
BCheckBox* fFadeCheckBox;
|
||||||
// For Mini and Deskbar
|
// For Mini and Deskbar
|
||||||
BRadioButton *active, *idle, *frame;
|
BRadioButton* fActiveButton;
|
||||||
|
BRadioButton* fIdleButton;
|
||||||
|
BRadioButton* fFrameButton;
|
||||||
// For Deskbar
|
// For Deskbar
|
||||||
BTextControl *iconwidth;
|
BTextControl* fIconWidthControl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // CONFIG_VIEW_H
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
|||||||
|
|
||||||
UsePrivateHeaders shared ;
|
UsePrivateHeaders shared ;
|
||||||
if $(TARGET_PLATFORM) != haiku {
|
if $(TARGET_PLATFORM) != haiku {
|
||||||
UseHeaders [ FDirName $(HAIKU_TOP) headers os kernel ] : true ;
|
UseHeaders [ FDirName $(HAIKU_TOP) headers os kernel ] : true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if $(TARGET_PLATFORM) = r5 {
|
if $(TARGET_PLATFORM) = r5 {
|
||||||
@@ -12,7 +12,6 @@ if $(TARGET_PLATFORM) = r5 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Application Pulse :
|
Application Pulse :
|
||||||
BottomPrefsView.cpp
|
|
||||||
ConfigView.cpp
|
ConfigView.cpp
|
||||||
CPUButton.cpp
|
CPUButton.cpp
|
||||||
DeskbarPulseView.cpp
|
DeskbarPulseView.cpp
|
||||||
@@ -28,7 +27,3 @@ Application Pulse :
|
|||||||
: be
|
: be
|
||||||
: Pulse.rdef
|
: Pulse.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
if $(HAIKU_COMPATIBLE) {
|
|
||||||
LinkAgainst Pulse : libroot.so ;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,98 +1,133 @@
|
|||||||
//****************************************************************************************
|
/*
|
||||||
//
|
* Copyright 2002-2006 Haiku, Inc. All Rights Reserved.
|
||||||
// File: PrefsWindow.cpp
|
* Distributed under the terms of the MIT license.
|
||||||
//
|
*
|
||||||
// Written by: Daniel Switkin
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
//
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
// Copyright 1999, Be Incorporated
|
*
|
||||||
//
|
* Written by: Daniel Switkin
|
||||||
//****************************************************************************************
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PrefsWindow.h"
|
#include "PrefsWindow.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "PulseApp.h"
|
#include "PulseApp.h"
|
||||||
#include "BottomPrefsView.h"
|
|
||||||
#include "ConfigView.h"
|
#include "ConfigView.h"
|
||||||
#include <interface/TabView.h>
|
|
||||||
#include <interface/TextControl.h>
|
//#include <Box.h>
|
||||||
#include <interface/Box.h>
|
#include <Button.h>
|
||||||
|
#include <TabView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
PrefsWindow::PrefsWindow(BRect rect, const char *name, BMessenger *messenger, Prefs *prefs) :
|
|
||||||
BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE |
|
|
||||||
B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS) {
|
|
||||||
|
|
||||||
this->messenger = messenger;
|
|
||||||
this->prefs = prefs;
|
|
||||||
|
|
||||||
|
PrefsWindow::PrefsWindow(BRect rect, const char *name, BMessenger *messenger, Prefs *prefs)
|
||||||
|
: BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
|
||||||
|
| B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS),
|
||||||
|
fTarget(*messenger),
|
||||||
|
fPrefs(prefs)
|
||||||
|
{
|
||||||
// This gives a nice look, and sets the background color correctly
|
// This gives a nice look, and sets the background color correctly
|
||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
BBox *parent = new BBox(bounds, "ParentView", B_FOLLOW_NONE, B_PLAIN_BORDER);
|
BView* topView = new BView(bounds, "ParentView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
AddChild(parent);
|
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(topView);
|
||||||
|
|
||||||
bounds.top += 10;
|
bounds.top += 10;
|
||||||
bounds.bottom -= 45;
|
bounds.bottom -= 45;
|
||||||
BTabView *tabview = new BTabView(bounds, "TabView");
|
fTabView = new BTabView(bounds, "TabView", B_WIDTH_FROM_LABEL);
|
||||||
tabview->SetFont(be_plain_font);
|
fTabView->SetFont(be_plain_font);
|
||||||
tabview->SetViewColor(parent->ViewColor());
|
topView->AddChild(fTabView);
|
||||||
tabview->ContainerView()->SetViewColor(parent->ViewColor());
|
|
||||||
parent->AddChild(tabview);
|
|
||||||
|
|
||||||
BRect viewsize = tabview->ContainerView()->Bounds();
|
BRect rect = fTabView->ContainerView()->Bounds();
|
||||||
viewsize.InsetBy(5, 5);
|
rect.InsetBy(5, 5);
|
||||||
|
|
||||||
ConfigView *normal = new ConfigView(viewsize, "Normal Mode", NORMAL_WINDOW_MODE, prefs);
|
ConfigView *normalView = new ConfigView(rect, "Normal Mode",
|
||||||
normal->SetViewColor(tabview->ViewColor());
|
PRV_NORMAL_CHANGE_COLOR, fTarget, prefs);
|
||||||
tabview->AddTab(normal);
|
fTabView->AddTab(normalView);
|
||||||
|
|
||||||
ConfigView *mini = new ConfigView(viewsize, "Mini Mode", MINI_WINDOW_MODE, prefs);
|
ConfigView *miniView = new ConfigView(rect, "Mini Mode", PRV_MINI_CHANGE_COLOR,
|
||||||
mini->SetViewColor(tabview->ViewColor());
|
fTarget, prefs);
|
||||||
tabview->AddTab(mini);
|
fTabView->AddTab(miniView);
|
||||||
|
|
||||||
ConfigView *deskbar = new ConfigView(viewsize, "Deskbar Mode", DESKBAR_MODE, prefs);
|
ConfigView *deskbarView = new ConfigView(rect, "Deskbar Mode", PRV_DESKBAR_CHANGE_COLOR,
|
||||||
deskbar->SetViewColor(tabview->ViewColor());
|
fTarget, prefs);
|
||||||
tabview->AddTab(deskbar);
|
fTabView->AddTab(deskbarView);
|
||||||
|
|
||||||
tabview->Select(0);
|
float width, height;
|
||||||
|
deskbarView->GetPreferredSize(&width, &height);
|
||||||
|
normalView->ResizeTo(width, height);
|
||||||
|
miniView->ResizeTo(width, height);
|
||||||
|
deskbarView->ResizeTo(width, height);
|
||||||
|
|
||||||
bounds.top = bounds.bottom + 1;
|
fTabView->Select(0L);
|
||||||
bounds.bottom += 45;
|
fTabView->ResizeTo(deskbarView->Bounds().Width() + 16.0f, deskbarView->Bounds().Height()
|
||||||
BottomPrefsView *bottomprefsview = new BottomPrefsView(bounds, "BottomPrefsView");
|
+ fTabView->ContainerView()->Frame().top + 16.0f);
|
||||||
parent->AddChild(bottomprefsview);
|
|
||||||
|
BButton *okButton = new BButton(rect, "ok", "OK", new BMessage(PRV_BOTTOM_OK),
|
||||||
|
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
okButton->ResizeToPreferred();
|
||||||
|
okButton->MoveTo(Bounds().Width() - 8.0f - okButton->Bounds().Width(),
|
||||||
|
Bounds().Height() - 8.0f - okButton->Bounds().Height());
|
||||||
|
topView->AddChild(okButton);
|
||||||
|
|
||||||
|
BButton *defaultsButton = new BButton(okButton->Frame(), "defaults", "Defaults",
|
||||||
|
new BMessage(PRV_BOTTOM_DEFAULTS), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
defaultsButton->ResizeToPreferred();
|
||||||
|
defaultsButton->MoveBy(-defaultsButton->Bounds().Width() - 10.0f, 0.0f);
|
||||||
|
topView->AddChild(defaultsButton);
|
||||||
|
|
||||||
|
okButton->MakeDefault(true);
|
||||||
|
|
||||||
|
fTabView->SetResizingMode(B_FOLLOW_NONE);
|
||||||
|
ResizeTo(fTabView->Frame().Width(), fTabView->Frame().bottom + 16.0f
|
||||||
|
+ okButton->Bounds().Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefsWindow::MessageReceived(BMessage *message) {
|
|
||||||
|
PrefsWindow::~PrefsWindow()
|
||||||
|
{
|
||||||
|
fPrefs->prefs_window_rect = Frame();
|
||||||
|
fPrefs->Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrefsWindow::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case PRV_BOTTOM_OK: {
|
case PRV_BOTTOM_OK:
|
||||||
|
{
|
||||||
Hide();
|
Hide();
|
||||||
BTabView *tabview = (BTabView *)FindView("TabView");
|
|
||||||
tabview->Select(2);
|
fTabView->Select(2);
|
||||||
ConfigView *deskbar = (ConfigView *)FindView("Deskbar Mode");
|
ConfigView *deskbar = (ConfigView *)FindView("Deskbar Mode");
|
||||||
deskbar->UpdateDeskbarIconWidth();
|
deskbar->UpdateDeskbarIconWidth();
|
||||||
if (Lock()) Quit();
|
|
||||||
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PRV_BOTTOM_DEFAULTS: {
|
|
||||||
BTabView *tabview = (BTabView *)FindView("TabView");
|
case PRV_BOTTOM_DEFAULTS:
|
||||||
BTab *tab = tabview->TabAt(tabview->Selection());
|
{
|
||||||
|
BTab *tab = fTabView->TabAt(fTabView->Selection());
|
||||||
BView *view = tab->View();
|
BView *view = tab->View();
|
||||||
view->MessageReceived(message);
|
view->MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefsWindow::Quit() {
|
|
||||||
messenger->SendMessage(new BMessage(PRV_QUIT));
|
|
||||||
BWindow::Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefsWindow::~PrefsWindow() {
|
bool
|
||||||
prefs->prefs_window_rect = Frame();
|
PrefsWindow::QuitRequested()
|
||||||
prefs->Save();
|
{
|
||||||
delete messenger;
|
fTarget.SendMessage(new BMessage(PRV_QUIT));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,35 @@
|
|||||||
//****************************************************************************************
|
/*
|
||||||
//
|
* Copyright 2002-2006 Haiku, Inc. All Rights Reserved.
|
||||||
// File: PrefsWindow.h
|
* Distributed under the terms of the MIT license.
|
||||||
//
|
*
|
||||||
// Written by: Daniel Switkin
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
//
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
// Copyright 1999, Be Incorporated
|
*
|
||||||
//
|
* Written by: Daniel Switkin
|
||||||
//****************************************************************************************
|
*/
|
||||||
|
#ifndef PREFS_WINDOW_H
|
||||||
|
#define PREFS_WINDOW_H
|
||||||
|
|
||||||
#ifndef PREFSWINDOW_H
|
|
||||||
#define PREFSWINDOW_H
|
|
||||||
|
|
||||||
#include <interface/Window.h>
|
|
||||||
#include <app/Messenger.h>
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
class BTabView;
|
||||||
|
|
||||||
class PrefsWindow : public BWindow {
|
class PrefsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
PrefsWindow(BRect rect, const char *name, BMessenger *messenger, Prefs *prefs);
|
PrefsWindow(BRect rect, const char *name, BMessenger *messenger, Prefs *prefs);
|
||||||
void MessageReceived(BMessage *message);
|
virtual ~PrefsWindow();
|
||||||
~PrefsWindow();
|
|
||||||
void Quit();
|
|
||||||
|
|
||||||
Prefs *prefs;
|
virtual void MessageReceived(BMessage *message);
|
||||||
BMessenger *messenger;
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BTabView* fTabView;
|
||||||
|
BMessenger fTarget;
|
||||||
|
Prefs* fPrefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PREFS_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user