1bef4185eSJérôme Duval /* 2*af55bae2SAxel Dörfler * Copyright 2003-2006, Haiku. 3bef4185eSJérôme Duval * Distributed under the terms of the MIT License. 4911290f7SJérôme Duval * 5911290f7SJérôme Duval * Authors: 6911290f7SJérôme Duval * Michael Phipps 77008829bSJérôme Duval * Jérôme Duval, jerome.duval@free.fr 8bef4185eSJérôme Duval */ 9*af55bae2SAxel Dörfler 10*af55bae2SAxel Dörfler 11*af55bae2SAxel Dörfler #include "PasswordWindow.h" 12*af55bae2SAxel Dörfler 13bef4185eSJérôme Duval #include <Application.h> 14*af55bae2SAxel Dörfler #include <Box.h> 15*af55bae2SAxel Dörfler #include <Button.h> 16bef4185eSJérôme Duval #include <Screen.h> 176ebd8e95SJérôme Duval #include <StringView.h> 18*af55bae2SAxel Dörfler 19*af55bae2SAxel Dörfler 20*af55bae2SAxel Dörfler PasswordWindow::PasswordWindow() 21*af55bae2SAxel Dörfler : BWindow(BRect(100, 100, 400, 230), "Enter Password", B_NO_BORDER_WINDOW_LOOK, 22*af55bae2SAxel Dörfler B_FLOATING_ALL_WINDOW_FEEL, 23*af55bae2SAxel Dörfler B_NOT_MOVABLE | B_NOT_CLOSABLE |B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 24*af55bae2SAxel Dörfler | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS , 25*af55bae2SAxel Dörfler B_ALL_WORKSPACES) 26*af55bae2SAxel Dörfler { 27*af55bae2SAxel Dörfler BScreen screen(this); 28*af55bae2SAxel Dörfler MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2, 29*af55bae2SAxel Dörfler screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2); 30*af55bae2SAxel Dörfler 31*af55bae2SAxel Dörfler BView* topView = new BView(Bounds(), "top", B_FOLLOW_ALL, B_WILL_DRAW); 32*af55bae2SAxel Dörfler topView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); 33*af55bae2SAxel Dörfler AddChild(topView); 34*af55bae2SAxel Dörfler 35*af55bae2SAxel Dörfler BRect bounds(Bounds()); 36*af55bae2SAxel Dörfler bounds.InsetBy(5, 5); 37*af55bae2SAxel Dörfler 38*af55bae2SAxel Dörfler BBox* box = new BBox(bounds, NULL, B_FOLLOW_NONE); 39*af55bae2SAxel Dörfler box->SetLabel("Unlock screen saver"); 40*af55bae2SAxel Dörfler topView->AddChild(box); 41*af55bae2SAxel Dörfler 42*af55bae2SAxel Dörfler fPassword = new BTextControl(BRect(10,28,260,47), NULL, "Enter password:", 43*af55bae2SAxel Dörfler NULL, B_FOLLOW_NONE); 44*af55bae2SAxel Dörfler fPassword->TextView()->HideTyping(true); 45*af55bae2SAxel Dörfler fPassword->SetDivider(100); 46*af55bae2SAxel Dörfler box->AddChild(fPassword); 47*af55bae2SAxel Dörfler fPassword->MakeFocus(true); 48*af55bae2SAxel Dörfler 49*af55bae2SAxel Dörfler BButton* button = new BButton(BRect(160,70,255,85), "fUnlock", "Unlock", 50*af55bae2SAxel Dörfler new BMessage(kMsgUnlock), B_FOLLOW_NONE); 51*af55bae2SAxel Dörfler button->SetTarget(NULL, be_app); 52*af55bae2SAxel Dörfler box->AddChild(button); 53*af55bae2SAxel Dörfler button->MakeDefault(true); 54*af55bae2SAxel Dörfler } 55bef4185eSJérôme Duval 56bef4185eSJérôme Duval 57bef4185eSJérôme Duval void 58*af55bae2SAxel Dörfler PasswordWindow::SetPassword(const char* text) 59bef4185eSJérôme Duval { 60*af55bae2SAxel Dörfler if (Lock()) { 61*af55bae2SAxel Dörfler fPassword->SetText(text); 62cc5b9137SJérôme Duval fPassword->MakeFocus(true); 63*af55bae2SAxel Dörfler Unlock(); 64bef4185eSJérôme Duval } 65*af55bae2SAxel Dörfler } 66