2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
9 #include "PPDConfigApplication.h"
10 #include "PrinterSelection.h"
12 AppWindow::AppWindow(BRect aRect
)
13 : BWindow(aRect
, APPLICATION
, B_TITLED_WINDOW
, 0) {
15 BRect rect
= BRect(0, 0, aRect
.Width(), aRect
.Height());
16 fMenuBar
= new BMenuBar(rect
, "menu_bar");
19 menu
= new BMenu("File");
20 menu
->AddItem(new BMenuItem("About ...", new BMessage(B_ABOUT_REQUESTED
), 'A'));
21 menu
->AddSeparatorItem();
22 menu
->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED
), 'Q'));
23 fMenuBar
->AddItem(menu
);
27 float x
= aRect
.Width() / 2 - 3;
28 float right
= rect
.right
- 3;
31 aRect
.Set(0, fMenuBar
->Bounds().Height()+1, x
, aRect
.Height());
32 PrinterSelectionView
* printerSelection
= new PrinterSelectionView(aRect
,
36 AddChild(printerSelection
);
37 printerSelection
->SetMessage(new BMessage('prnt'));
38 printerSelection
->SetTarget(this);
42 AddChild(fConfig
= new PPDConfigView(aRect
, "ppd-config",
46 // make window visible
50 void AppWindow::MessageReceived(BMessage
*message
) {
52 switch(message
->what
) {
55 case B_ABOUT_REQUESTED
:
59 if (message
->FindString("file", &file
) == B_OK
) {
61 fConfig
->Set(file
, settings
);
65 BWindow::MessageReceived(message
);
70 bool AppWindow::QuitRequested() {
71 be_app
->PostMessage(B_QUIT_REQUESTED
);
75 void AppWindow::AboutRequested() {
76 BAlert
*about
= new BAlert(APPLICATION
,
77 APPLICATION
" " VERSION
"\nPrototype for PPD printer selection and configuration.\n\n"
79 "By Michael Pfeiffer.\n\n"
80 "EMail: laplace@users.sourceforge.net.","Close");
84 PPDConfigApplication::PPDConfigApplication() : BApplication(SIGNATURE
) {
86 // set up a rectangle and instantiate a new window
87 aRect
.Set(100, 80, 950, 580);
89 window
= new AppWindow(aRect
);
92 int main(int argc
, char *argv
[]) {
93 PPDConfigApplication app
;