Fixed some issues in the "keep settings" alert:
* pressing the escape key now exits the window as it should be (SetEventMask() was called in the constructor, but has no effect as long as the view isn't attached to a window). * The window is now font sensitive (fixing bug #450). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17159 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -29,60 +29,81 @@ AlertView::AlertView(BRect frame, char *name)
|
|||||||
// we will wait 8 seconds until we send a message
|
// we will wait 8 seconds until we send a message
|
||||||
fSeconds(8)
|
fSeconds(8)
|
||||||
{
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
fBitmap = InitIcon();
|
fBitmap = InitIcon();
|
||||||
|
|
||||||
BStringView *stringView = new BStringView(BRect(60, 20, 400, 36), NULL,
|
BRect rect(60, 8, 400, 36);
|
||||||
|
BStringView *stringView = new BStringView(rect, NULL,
|
||||||
"Do you wish to keep these settings?");
|
"Do you wish to keep these settings?");
|
||||||
stringView->SetFont(be_bold_font);
|
stringView->SetFont(be_bold_font);
|
||||||
stringView->ResizeToPreferred();
|
stringView->ResizeToPreferred();
|
||||||
AddChild(stringView);
|
AddChild(stringView);
|
||||||
|
|
||||||
fCountdownView = new BStringView(BRect(60, 37, 400, 50), "countdown",
|
rect = stringView->Frame();
|
||||||
B_EMPTY_STRING);
|
rect.OffsetBy(0, rect.Height());
|
||||||
|
fCountdownView = new BStringView(rect, "countdown", NULL);
|
||||||
UpdateCountdownView();
|
UpdateCountdownView();
|
||||||
fCountdownView->ResizeToPreferred();
|
fCountdownView->ResizeToPreferred();
|
||||||
AddChild(fCountdownView);
|
AddChild(fCountdownView);
|
||||||
|
|
||||||
BButton *button = new BButton(BRect(215, 59, 400, 190), "keep", "Keep",
|
BButton* keepButton = new BButton(rect, "keep", "Keep",
|
||||||
new BMessage(BUTTON_KEEP_MSG));
|
new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
keepButton->ResizeToPreferred();
|
||||||
|
AddChild(keepButton);
|
||||||
|
|
||||||
|
BButton* button = new BButton(rect, "revert", "Revert",
|
||||||
|
new BMessage(BUTTON_REVERT_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
button->ResizeToPreferred();
|
button->ResizeToPreferred();
|
||||||
AddChild(button);
|
AddChild(button);
|
||||||
|
|
||||||
button = new BButton(BRect(130, 59, 400, 199), "revert", "Revert",
|
// we're resizing ourselves to the right size
|
||||||
new BMessage(BUTTON_REVERT_MSG));
|
// (but we're not implementing GetPreferredSize(), bad style!)
|
||||||
button->ResizeToPreferred();
|
float width = stringView->Frame().right;
|
||||||
AddChild(button);
|
if (fCountdownView->Frame().right > width)
|
||||||
|
width = fCountdownView->Frame().right;
|
||||||
|
if (width < Bounds().Width())
|
||||||
|
width = Bounds().Width();
|
||||||
|
|
||||||
SetEventMask(B_KEYBOARD_EVENTS);
|
float height = fCountdownView->Frame().bottom + 24 + button->Bounds().Height();
|
||||||
|
ResizeTo(width, height);
|
||||||
|
|
||||||
|
keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(),
|
||||||
|
Bounds().Height() - 8 - keepButton->Bounds().Height());
|
||||||
|
button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8,
|
||||||
|
keepButton->Frame().top);
|
||||||
|
|
||||||
|
keepButton->MakeDefault(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlertView::AttachedToWindow()
|
AlertView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
// the view displays a decrementing counter (until the user must take action)
|
||||||
|
Window()->SetPulseRate(1000000);
|
||||||
|
// every second
|
||||||
|
|
||||||
if (BButton* button = dynamic_cast<BButton *>(FindView("keep")))
|
SetEventMask(B_KEYBOARD_EVENTS);
|
||||||
Window()->SetDefaultButton(button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlertView::Draw(BRect updateRect)
|
AlertView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
rgb_color dark = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
|
rgb_color dark = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
|
||||||
SetHighColor(dark);
|
SetHighColor(dark);
|
||||||
|
|
||||||
FillRect(BRect(0.0, 0.0, 30.0, 100.0));
|
FillRect(BRect(0.0, 0.0, 30.0, Bounds().bottom));
|
||||||
|
|
||||||
if (fBitmap != NULL) {
|
if (fBitmap != NULL) {
|
||||||
SetDrawingMode(B_OP_ALPHA);
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
DrawBitmap(fBitmap, BPoint(18.0, 6.0));
|
DrawBitmap(fBitmap, BPoint(18.0, 6.0));
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlertView::Pulse()
|
AlertView::Pulse()
|
||||||
{
|
{
|
||||||
if (--fSeconds == 0)
|
if (--fSeconds == 0)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class BStringView;
|
|||||||
|
|
||||||
class AlertView : public BView {
|
class AlertView : public BView {
|
||||||
public:
|
public:
|
||||||
AlertView(BRect frame, char *name);
|
AlertView(BRect frame, char* name);
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
@@ -29,11 +29,11 @@ class AlertView : public BView {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateCountdownView();
|
void UpdateCountdownView();
|
||||||
BBitmap *InitIcon();
|
BBitmap* InitIcon();
|
||||||
|
|
||||||
BStringView *fCountdownView;
|
BStringView* fCountdownView;
|
||||||
BBitmap *fBitmap;
|
BBitmap* fBitmap;
|
||||||
int32 fSeconds;
|
int32 fSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ALERT_VIEW_H */
|
#endif /* ALERT_VIEW_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,10 +23,9 @@ AlertWindow::AlertWindow(BMessenger target)
|
|||||||
fTarget(target)
|
fTarget(target)
|
||||||
{
|
{
|
||||||
fAlertView = new AlertView(Bounds(), "AlertView");
|
fAlertView = new AlertView(Bounds(), "AlertView");
|
||||||
AddChild(fAlertView);
|
|
||||||
|
|
||||||
// the view displays a decrementing counter (until the user must take action)
|
ResizeTo(fAlertView->Bounds().Width(), fAlertView->Bounds().Height());
|
||||||
SetPulseRate(1000000); // every second
|
AddChild(fAlertView);
|
||||||
|
|
||||||
// center window on screen
|
// center window on screen
|
||||||
BScreen screen(this);
|
BScreen screen(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user