1 //**************************************************************************************** 2 // 3 // File: PrefsWindow.cpp 4 // 5 // Written by: Daniel Switkin 6 // 7 // Copyright 1999, Be Incorporated 8 // 9 //**************************************************************************************** 10 11 #include "PrefsWindow.h" 12 #include "Common.h" 13 #include "PulseApp.h" 14 #include "BottomPrefsView.h" 15 #include "ConfigView.h" 16 #include <interface/TabView.h> 17 #include <interface/TextControl.h> 18 #include <interface/Box.h> 19 #include <stdlib.h> 20 #include <stdio.h> 21 22 PrefsWindow::PrefsWindow(BRect rect, const char *name, BMessenger *messenger, Prefs *prefs) : 23 BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | 24 B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS) { 25 26 this->messenger = messenger; 27 this->prefs = prefs; 28 29 // This gives a nice look, and sets the background color correctly 30 BRect bounds = Bounds(); 31 BBox *parent = new BBox(bounds, "ParentView", B_FOLLOW_NONE, B_PLAIN_BORDER); 32 AddChild(parent); 33 34 bounds.top += 10; 35 bounds.bottom -= 45; 36 BTabView *tabview = new BTabView(bounds, "TabView"); 37 tabview->SetFont(be_plain_font); 38 tabview->SetViewColor(parent->ViewColor()); 39 tabview->ContainerView()->SetViewColor(parent->ViewColor()); 40 parent->AddChild(tabview); 41 42 BRect viewsize = tabview->ContainerView()->Bounds(); 43 viewsize.InsetBy(5, 5); 44 45 ConfigView *normal = new ConfigView(viewsize, "Normal Mode", NORMAL_WINDOW_MODE, prefs); 46 normal->SetViewColor(tabview->ViewColor()); 47 tabview->AddTab(normal); 48 49 ConfigView *mini = new ConfigView(viewsize, "Mini Mode", MINI_WINDOW_MODE, prefs); 50 mini->SetViewColor(tabview->ViewColor()); 51 tabview->AddTab(mini); 52 53 ConfigView *deskbar = new ConfigView(viewsize, "Deskbar Mode", DESKBAR_MODE, prefs); 54 deskbar->SetViewColor(tabview->ViewColor()); 55 tabview->AddTab(deskbar); 56 57 tabview->Select(0); 58 59 bounds.top = bounds.bottom + 1; 60 bounds.bottom += 45; 61 BottomPrefsView *bottomprefsview = new BottomPrefsView(bounds, "BottomPrefsView"); 62 parent->AddChild(bottomprefsview); 63 } 64 65 void PrefsWindow::MessageReceived(BMessage *message) { 66 switch (message->what) { 67 case PRV_BOTTOM_OK: { 68 Hide(); 69 BTabView *tabview = (BTabView *)FindView("TabView"); 70 tabview->Select(2); 71 ConfigView *deskbar = (ConfigView *)FindView("Deskbar Mode"); 72 deskbar->UpdateDeskbarIconWidth(); 73 if (Lock()) Quit(); 74 break; 75 } 76 case PRV_BOTTOM_DEFAULTS: { 77 BTabView *tabview = (BTabView *)FindView("TabView"); 78 BTab *tab = tabview->TabAt(tabview->Selection()); 79 BView *view = tab->View(); 80 view->MessageReceived(message); 81 break; 82 } 83 default: 84 BWindow::MessageReceived(message); 85 break; 86 } 87 } 88 89 void PrefsWindow::Quit() { 90 messenger->SendMessage(new BMessage(PRV_QUIT)); 91 BWindow::Quit(); 92 } 93 94 PrefsWindow::~PrefsWindow() { 95 prefs->prefs_window_rect = Frame(); 96 prefs->Save(); 97 delete messenger; 98 } 99