xref: /haiku/src/apps/sudoku/Sudoku.cpp (revision d9cebac2b77547b7064f22497514eecd2d047160)
1 /*
2  * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "SudokuWindow.h"
8 
9 #include <stdlib.h>
10 
11 #include <Alert.h>
12 #include <Application.h>
13 #include <TextView.h>
14 
15 
16 class Sudoku : public BApplication {
17 public:
18 	Sudoku();
19 	virtual ~Sudoku();
20 
21 	virtual void ReadyToRun();
22 
23 	virtual void RefsReceived(BMessage *message);
24 	virtual void MessageReceived(BMessage *message);
25 
26 	virtual void AboutRequested();
27 
28 private:
29 	SudokuWindow* fWindow;
30 };
31 
32 
33 const char* kSignature = "application/x-vnd.Haiku-Sudoku";
34 
35 
36 Sudoku::Sudoku()
37 	: BApplication(kSignature)
38 {
39 }
40 
41 
42 Sudoku::~Sudoku()
43 {
44 }
45 
46 
47 void
48 Sudoku::ReadyToRun()
49 {
50 	fWindow = new SudokuWindow();
51 	fWindow->Show();
52 }
53 
54 
55 void
56 Sudoku::RefsReceived(BMessage* message)
57 {
58 	fWindow->PostMessage(message);
59 }
60 
61 
62 void
63 Sudoku::MessageReceived(BMessage* message)
64 {
65 	BApplication::MessageReceived(message);
66 }
67 
68 
69 void
70 Sudoku::AboutRequested()
71 {
72 	BAlert *alert = new BAlert("about", "Sudoku\n"
73 		"\twritten by Axel Dörfler\n"
74 		"\tCopyright 2007, Haiku Inc.\n", "Ok");
75 	BTextView *view = alert->TextView();
76 	BFont font;
77 
78 	view->SetStylable(true);
79 
80 	view->GetFont(&font);
81 	font.SetSize(18);
82 	font.SetFace(B_BOLD_FACE);
83 	view->SetFontAndColor(0, 6, &font);
84 
85 	alert->Go();
86 }
87 
88 
89 //	#pragma mark -
90 
91 
92 int
93 main(int /*argc*/, char** /*argv*/)
94 {
95 	srand(system_time());
96 
97 	Sudoku sudoku;
98 	sudoku.Run();
99 
100 	return 0;
101 }
102