small cleanup

password window is now font sensitiv, fixes Ticket #705



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23548 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2008-01-16 00:09:49 +00:00
parent c0a4294edd
commit 13ab80745a
2 changed files with 36 additions and 25 deletions
+32 -22
View File
@@ -1,56 +1,66 @@
/* /*
* Copyright 2003-2006, Haiku. * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Michael Phipps * Michael Phipps
* Jérôme Duval, [email protected] * Jérôme Duval, [email protected]
* Julun <[email protected]>
*/ */
#include "PasswordWindow.h" #include "PasswordWindow.h"
#include <Application.h> #include <Application.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Screen.h> #include <Screen.h>
#include <StringView.h>
PasswordWindow::PasswordWindow() PasswordWindow::PasswordWindow()
: BWindow(BRect(100, 100, 400, 230), "Enter Password", B_NO_BORDER_WINDOW_LOOK, : BWindow(BRect(100, 100, 400, 230), "Enter Password", B_NO_BORDER_WINDOW_LOOK,
B_FLOATING_ALL_WINDOW_FEEL, B_FLOATING_ALL_WINDOW_FEEL,
B_NOT_MOVABLE | B_NOT_CLOSABLE |B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE B_NOT_MOVABLE | B_NOT_CLOSABLE |B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
| B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS , | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS , B_ALL_WORKSPACES)
B_ALL_WORKSPACES)
{ {
BScreen screen(this); BView* topView = new BView(Bounds(), "topView", B_FOLLOW_ALL, B_WILL_DRAW);
MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2, topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2);
BView* topView = new BView(Bounds(), "top", B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
AddChild(topView); AddChild(topView);
BRect bounds(Bounds()); BRect bounds(Bounds());
bounds.InsetBy(5, 5); bounds.InsetBy(10.0, 10.0);
BBox* box = new BBox(bounds, NULL, B_FOLLOW_NONE); BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
box->SetLabel("Unlock screen saver"); topView->AddChild(customBox);
topView->AddChild(box); customBox->SetLabel("Unlock screen saver");
fPassword = new BTextControl(BRect(10,28,260,47), NULL, "Enter password:", bounds.top += 10.0;
NULL, B_FOLLOW_NONE); fPassword = new BTextControl(bounds, "password", "Enter password:",
fPassword->TextView()->HideTyping(true); "VeryLongPasswordPossible", B_FOLLOW_NONE);
fPassword->SetDivider(100); customBox->AddChild(fPassword);
box->AddChild(fPassword);
fPassword->MakeFocus(true); fPassword->MakeFocus(true);
fPassword->ResizeToPreferred();
fPassword->TextView()->HideTyping(true);
fPassword->SetDivider(be_plain_font->StringWidth("Enter password:") + 5.0);
BButton* button = new BButton(BRect(160,70,255,85), "fUnlock", "Unlock", BButton* button = new BButton(BRect(), "unlock", "Unlock",
new BMessage(kMsgUnlock), B_FOLLOW_NONE); new BMessage(kMsgUnlock), B_FOLLOW_NONE);
button->SetTarget(NULL, be_app); customBox->AddChild(button);
box->AddChild(button);
button->MakeDefault(true); button->MakeDefault(true);
button->ResizeToPreferred();
button->SetTarget(NULL, be_app);
BRect frame = fPassword->Frame();
button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);
customBox->ResizeTo(frame.right + 10.0, button->Frame().bottom + 10.0);
frame = customBox->Frame();
ResizeTo(frame.right + 10.0, frame.bottom + 10.0);
BScreen screen(this);
MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2,
screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2);
} }
+3 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2006, Haiku. * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -16,7 +16,8 @@
const static int32 kMsgUnlock = 'ULMS'; const static int32 kMsgUnlock = 'ULMS';
class PasswordWindow : public BWindow{
class PasswordWindow : public BWindow {
public: public:
PasswordWindow(); PasswordWindow();