xref: /haiku/src/libs/print/libprint/AboutBox.cpp (revision 26db1794f9199838b3d4c8e6199f72dcf9cfec08)
112fd6cc2SKarsten Heimrich /*
212fd6cc2SKarsten Heimrich  * AboutBox.cpp
312fd6cc2SKarsten Heimrich  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
412fd6cc2SKarsten Heimrich  */
512fd6cc2SKarsten Heimrich 
612fd6cc2SKarsten Heimrich #include <cstdio>
712fd6cc2SKarsten Heimrich #include <string>
812fd6cc2SKarsten Heimrich 
912fd6cc2SKarsten Heimrich #include <Window.h>
1012fd6cc2SKarsten Heimrich #include <View.h>
1112fd6cc2SKarsten Heimrich #include <Button.h>
1212fd6cc2SKarsten Heimrich 
1312fd6cc2SKarsten Heimrich #include "AboutBox.h"
1412fd6cc2SKarsten Heimrich 
1508d759feSMichael Pfeiffer 
1612fd6cc2SKarsten Heimrich using namespace std;
1708d759feSMichael Pfeiffer 
1812fd6cc2SKarsten Heimrich 
1912fd6cc2SKarsten Heimrich enum {
2012fd6cc2SKarsten Heimrich 	kMsgOK = 'AbOK'
2112fd6cc2SKarsten Heimrich };
2212fd6cc2SKarsten Heimrich 
2312fd6cc2SKarsten Heimrich 
2412fd6cc2SKarsten Heimrich class AboutBoxView : public BView {
2512fd6cc2SKarsten Heimrich public:
2612fd6cc2SKarsten Heimrich 	AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright);
2712fd6cc2SKarsten Heimrich 	virtual void Draw(BRect);
2812fd6cc2SKarsten Heimrich 	virtual void AttachedToWindow();
2912fd6cc2SKarsten Heimrich 
3012fd6cc2SKarsten Heimrich private:
3112fd6cc2SKarsten Heimrich 	string fDriverName;
3212fd6cc2SKarsten Heimrich 	string fVersion;
3312fd6cc2SKarsten Heimrich 	string fCopyright;
3412fd6cc2SKarsten Heimrich };
3512fd6cc2SKarsten Heimrich 
AboutBoxView(BRect rect,const char * driver_name,const char * version,const char * copyright)3612fd6cc2SKarsten Heimrich AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright)
3712fd6cc2SKarsten Heimrich 	: BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
3812fd6cc2SKarsten Heimrich {
3912fd6cc2SKarsten Heimrich 	fDriverName = driver_name;
4012fd6cc2SKarsten Heimrich 	fVersion     = version;
4112fd6cc2SKarsten Heimrich 	fCopyright   = copyright;
42*f696e88aSlooncraz 	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
4312fd6cc2SKarsten Heimrich 	SetDrawingMode(B_OP_SELECT);
4412fd6cc2SKarsten Heimrich }
4512fd6cc2SKarsten Heimrich 
Draw(BRect)4612fd6cc2SKarsten Heimrich void AboutBoxView::Draw(BRect)
4712fd6cc2SKarsten Heimrich {
4812fd6cc2SKarsten Heimrich 	SetHighColor(0, 0, 0);
4912fd6cc2SKarsten Heimrich 	DrawString(fDriverName.c_str(), BPoint(10.0f, 16.0f));
5012fd6cc2SKarsten Heimrich 	DrawString(" Driver for ");
5112fd6cc2SKarsten Heimrich 	SetHighColor(0, 0, 0xff);
5212fd6cc2SKarsten Heimrich 	DrawString("B");
5312fd6cc2SKarsten Heimrich 	SetHighColor(0xff, 0, 0);
5412fd6cc2SKarsten Heimrich 	DrawString("e");
5512fd6cc2SKarsten Heimrich 	SetHighColor(0, 0, 0);
5612fd6cc2SKarsten Heimrich 	DrawString("OS  Version ");
5712fd6cc2SKarsten Heimrich 	DrawString(fVersion.c_str());
5812fd6cc2SKarsten Heimrich 	DrawString(fCopyright.c_str(), BPoint(10.0f, 30.0f));
5912fd6cc2SKarsten Heimrich }
6012fd6cc2SKarsten Heimrich 
AttachedToWindow()6112fd6cc2SKarsten Heimrich void AboutBoxView::AttachedToWindow()
6212fd6cc2SKarsten Heimrich {
6312fd6cc2SKarsten Heimrich 	BRect rect;
6412fd6cc2SKarsten Heimrich 	rect.Set(110, 50, 175, 55);
6512fd6cc2SKarsten Heimrich 	BButton *button = new BButton(rect, "", "OK", new BMessage(kMsgOK));
6612fd6cc2SKarsten Heimrich 	AddChild(button);
6712fd6cc2SKarsten Heimrich 	button->MakeDefault(true);
6812fd6cc2SKarsten Heimrich }
6912fd6cc2SKarsten Heimrich 
7012fd6cc2SKarsten Heimrich class AboutBoxWindow : public BWindow {
7112fd6cc2SKarsten Heimrich public:
7212fd6cc2SKarsten Heimrich 	AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright);
7312fd6cc2SKarsten Heimrich 	virtual void MessageReceived(BMessage *msg);
7412fd6cc2SKarsten Heimrich 	virtual	bool QuitRequested();
7512fd6cc2SKarsten Heimrich };
7612fd6cc2SKarsten Heimrich 
AboutBoxWindow(BRect frame,const char * driver_name,const char * version,const char * copyright)7712fd6cc2SKarsten Heimrich AboutBoxWindow::AboutBoxWindow(BRect frame, const char *driver_name, const char *version, const char *copyright)
780e216008SMichael Pfeiffer 	: BWindow(frame, "", B_TITLED_WINDOW,
790e216008SMichael Pfeiffer 		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE)
8012fd6cc2SKarsten Heimrich {
8112fd6cc2SKarsten Heimrich 	char title[256];
8212fd6cc2SKarsten Heimrich 	sprintf(title, "About %s Driver", driver_name);
8312fd6cc2SKarsten Heimrich 	SetTitle(title);
8412fd6cc2SKarsten Heimrich 	AddChild(new AboutBoxView(Bounds(), driver_name, version, copyright));
8512fd6cc2SKarsten Heimrich }
8612fd6cc2SKarsten Heimrich 
MessageReceived(BMessage * msg)8712fd6cc2SKarsten Heimrich void AboutBoxWindow::MessageReceived(BMessage *msg)
8812fd6cc2SKarsten Heimrich {
8912fd6cc2SKarsten Heimrich 	switch (msg->what) {
9012fd6cc2SKarsten Heimrich 	case kMsgOK:
9112fd6cc2SKarsten Heimrich 		be_app->PostMessage(B_QUIT_REQUESTED);
9212fd6cc2SKarsten Heimrich 		break;
9312fd6cc2SKarsten Heimrich 	}
9412fd6cc2SKarsten Heimrich }
9512fd6cc2SKarsten Heimrich 
QuitRequested()9612fd6cc2SKarsten Heimrich bool AboutBoxWindow::QuitRequested()
9712fd6cc2SKarsten Heimrich {
9812fd6cc2SKarsten Heimrich 	be_app->PostMessage(B_QUIT_REQUESTED);
9912fd6cc2SKarsten Heimrich 	return true;
10012fd6cc2SKarsten Heimrich }
10112fd6cc2SKarsten Heimrich 
AboutBox(const char * signature,const char * driver_name,const char * version,const char * copyright)10212fd6cc2SKarsten Heimrich AboutBox::AboutBox(const char *signature, const char *driver_name, const char *version, const char *copyright)
10312fd6cc2SKarsten Heimrich 	: BApplication(signature)
10412fd6cc2SKarsten Heimrich {
10512fd6cc2SKarsten Heimrich 	BRect rect;
10612fd6cc2SKarsten Heimrich 	rect.Set(100, 80, 400, 170);
10712fd6cc2SKarsten Heimrich 	AboutBoxWindow *window = new AboutBoxWindow(rect, driver_name, version, copyright);
10812fd6cc2SKarsten Heimrich 	window->Show();
10912fd6cc2SKarsten Heimrich }
110