3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
24 class AboutBoxView
: public BView
{
26 AboutBoxView(BRect frame
, const char *driver_name
, const char *version
, const char *copyright
);
27 virtual void Draw(BRect
);
28 virtual void AttachedToWindow();
36 AboutBoxView::AboutBoxView(BRect rect
, const char *driver_name
, const char *version
, const char *copyright
)
37 : BView(rect
, "", B_FOLLOW_ALL
, B_WILL_DRAW
)
39 fDriverName
= driver_name
;
41 fCopyright
= copyright
;
42 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
43 SetDrawingMode(B_OP_SELECT
);
46 void AboutBoxView::Draw(BRect
)
48 SetHighColor(0, 0, 0);
49 DrawString(fDriverName
.c_str(), BPoint(10.0f
, 16.0f
));
50 DrawString(" Driver for ");
51 SetHighColor(0, 0, 0xff);
53 SetHighColor(0xff, 0, 0);
55 SetHighColor(0, 0, 0);
56 DrawString("OS Version ");
57 DrawString(fVersion
.c_str());
58 DrawString(fCopyright
.c_str(), BPoint(10.0f
, 30.0f
));
61 void AboutBoxView::AttachedToWindow()
64 rect
.Set(110, 50, 175, 55);
65 BButton
*button
= new BButton(rect
, "", "OK", new BMessage(kMsgOK
));
67 button
->MakeDefault(true);
70 class AboutBoxWindow
: public BWindow
{
72 AboutBoxWindow(BRect frame
, const char *driver_name
, const char *version
, const char *copyright
);
73 virtual void MessageReceived(BMessage
*msg
);
74 virtual bool QuitRequested();
77 AboutBoxWindow::AboutBoxWindow(BRect frame
, const char *driver_name
, const char *version
, const char *copyright
)
78 : BWindow(frame
, "", B_TITLED_WINDOW
,
79 B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
| B_CLOSE_ON_ESCAPE
)
82 sprintf(title
, "About %s Driver", driver_name
);
84 AddChild(new AboutBoxView(Bounds(), driver_name
, version
, copyright
));
87 void AboutBoxWindow::MessageReceived(BMessage
*msg
)
91 be_app
->PostMessage(B_QUIT_REQUESTED
);
96 bool AboutBoxWindow::QuitRequested()
98 be_app
->PostMessage(B_QUIT_REQUESTED
);
102 AboutBox::AboutBox(const char *signature
, const char *driver_name
, const char *version
, const char *copyright
)
103 : BApplication(signature
)
106 rect
.Set(100, 80, 400, 170);
107 AboutBoxWindow
*window
= new AboutBoxWindow(rect
, driver_name
, version
, copyright
);