]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wxpoem.h | |
3 | // Purpose: A small C++ program which displays a random poem on | |
4 | // execution. It also allows search for poems containing a | |
5 | // string. | |
6 | // It requires winpoem.dat and creates winpoem.idx. | |
7 | // Original version (WinPoem) written in 1994. | |
8 | // This has not been rewritten in a long time so | |
9 | // beware, inelegant code! | |
10 | // Author: Julian Smart | |
11 | // Created: 12/12/98 | |
12 | // RCS-ID: $Id$ | |
13 | // Copyright: (c) 1998 Julian Smart | |
14 | // Licence: wxWindows licence | |
15 | ///////////////////////////////////////////////////////////////////////////// | |
16 | ||
17 | #ifdef __GNUG__ | |
18 | #pragma interface "wxpoem.h" | |
19 | #endif | |
20 | ||
21 | // Define a new application | |
22 | class MyApp: public wxApp | |
23 | { | |
24 | public: | |
25 | bool OnInit(); | |
26 | int OnExit(); | |
27 | }; | |
28 | ||
29 | DECLARE_APP(MyApp) | |
30 | ||
31 | // Define a new canvas which can receive some events | |
32 | class MyCanvas: public wxWindow | |
33 | { | |
34 | public: | |
35 | MyCanvas(wxFrame *frame, wxWindowID id, const wxPoint& pos, const wxSize& size); | |
36 | ||
37 | void OnPaint(wxPaintEvent& event); | |
38 | void OnMouseEvent(wxMouseEvent& event); | |
39 | void OnChar(wxKeyEvent& event); | |
40 | ||
41 | DECLARE_EVENT_TABLE() | |
42 | }; | |
43 | ||
44 | // Define a new frame | |
45 | class MainWindow: public wxFrame | |
46 | { | |
47 | public: | |
48 | MyCanvas *canvas; | |
49 | MainWindow(wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style); | |
50 | ~MainWindow(); | |
51 | ||
52 | void OnCloseWindow(wxCloseEvent& event); | |
53 | void OnChar(wxKeyEvent& event); | |
54 | ||
55 | // Display next page or poem | |
56 | void NextPage(void); | |
57 | ||
58 | // Display previous page | |
59 | void PreviousPage(void); | |
60 | ||
61 | // User search | |
62 | void Search(bool); | |
63 | ||
64 | // Look in file for string | |
65 | long DoSearch(void); | |
66 | ||
67 | // Do the actual drawing of text (or just calculate size needed) | |
68 | void ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y); | |
69 | ||
70 | // Load the poem | |
71 | void GetIndexLoadPoem(void); | |
72 | void Resize(void); | |
73 | ||
74 | DECLARE_EVENT_TABLE() | |
75 | }; | |
76 | ||
77 | // Menu items | |
78 | #define POEM_NEXT 100 | |
79 | #define POEM_PREVIOUS 101 | |
80 | #define POEM_COPY 102 | |
81 | #define POEM_SEARCH 103 | |
82 | #define POEM_NEXT_MATCH 104 | |
83 | #define POEM_ABOUT 105 | |
84 | #define POEM_EXIT 106 | |
85 | #define POEM_COMPILE 107 | |
86 | #define POEM_HELP_CONTENTS 108 | |
87 | #define POEM_BIGGER_TEXT 109 | |
88 | #define POEM_SMALLER_TEXT 110 | |
89 | #define POEM_MINIMIZE 111 | |
90 | ||
91 |