]>
Commit | Line | Data |
---|---|---|
3013b6f4 JS |
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 | |
3013b6f4 JS |
12 | // Copyright: (c) 1998 Julian Smart |
13 | // Licence: wxWindows licence | |
14 | ///////////////////////////////////////////////////////////////////////////// | |
15 | ||
5045ca9e FM |
16 | #ifndef _WXPOEM_H_ |
17 | #define _WXPOEM_H_ | |
18 | ||
19 | ||
3013b6f4 JS |
20 | // Define a new application |
21 | class MyApp: public wxApp | |
22 | { | |
c7bde65d | 23 | public: |
3013b6f4 JS |
24 | bool OnInit(); |
25 | int OnExit(); | |
26 | }; | |
27 | ||
28 | DECLARE_APP(MyApp) | |
29 | ||
30 | // Define a new canvas which can receive some events | |
b23386b2 | 31 | class MyCanvas: public wxWindow |
3013b6f4 | 32 | { |
c7bde65d WS |
33 | public: |
34 | MyCanvas(wxFrame *frame); | |
d3c7fc99 | 35 | virtual ~MyCanvas(); |
3013b6f4 JS |
36 | |
37 | void OnPaint(wxPaintEvent& event); | |
38 | void OnMouseEvent(wxMouseEvent& event); | |
39 | void OnChar(wxKeyEvent& event); | |
40 | ||
c7bde65d WS |
41 | private: |
42 | wxMenu *m_popupMenu; | |
43 | ||
3013b6f4 JS |
44 | DECLARE_EVENT_TABLE() |
45 | }; | |
46 | ||
47 | // Define a new frame | |
48 | class MainWindow: public wxFrame | |
49 | { | |
c7bde65d | 50 | public: |
3013b6f4 | 51 | MyCanvas *canvas; |
5045ca9e FM |
52 | MainWindow(wxFrame *frame, wxWindowID id, const wxString& title, |
53 | const wxPoint& pos, const wxSize& size, long style); | |
d3c7fc99 | 54 | virtual ~MainWindow(); |
3013b6f4 JS |
55 | |
56 | void OnCloseWindow(wxCloseEvent& event); | |
57 | void OnChar(wxKeyEvent& event); | |
508379ee | 58 | void OnPopup(wxCommandEvent& event); |
3013b6f4 JS |
59 | |
60 | // Display next page or poem | |
61 | void NextPage(void); | |
62 | ||
63 | // Display previous page | |
64 | void PreviousPage(void); | |
65 | ||
66 | // User search | |
67 | void Search(bool); | |
68 | ||
69 | // Look in file for string | |
70 | long DoSearch(void); | |
71 | ||
72 | // Do the actual drawing of text (or just calculate size needed) | |
73 | void ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y); | |
74 | ||
75 | // Load the poem | |
76 | void GetIndexLoadPoem(void); | |
77 | void Resize(void); | |
78 | ||
c7bde65d WS |
79 | private: |
80 | ||
81 | wxString m_searchString; | |
82 | wxString m_title; | |
83 | ||
84 | // Preferences | |
85 | void WritePreferences(); | |
86 | void ReadPreferences(); | |
87 | ||
88 | // Fonts | |
89 | void CreateFonts(); | |
90 | wxFont *m_normalFont; | |
91 | wxFont *m_boldFont; | |
92 | wxFont *m_italicFont; | |
93 | ||
3baa2662 WS |
94 | // Icons |
95 | wxIcon *m_corners[4]; | |
96 | ||
17d31882 | 97 | DECLARE_EVENT_TABLE() |
3013b6f4 JS |
98 | }; |
99 | ||
100 | // Menu items | |
17d31882 DS |
101 | enum |
102 | { | |
c7bde65d WS |
103 | POEM_ABOUT = wxID_ABOUT, |
104 | POEM_EXIT = wxID_EXIT, | |
105 | POEM_PREVIOUS = wxID_BACKWARD, | |
106 | POEM_COPY = wxID_COPY, | |
107 | POEM_NEXT = wxID_FORWARD, | |
108 | POEM_NEXT_MATCH = wxID_MORE, | |
109 | POEM_BIGGER_TEXT = wxID_ZOOM_IN, | |
110 | POEM_SMALLER_TEXT = wxID_ZOOM_OUT, | |
111 | POEM_SEARCH = wxID_FIND, | |
112 | POEM_MINIMIZE = wxID_ICONIZE_FRAME | |
17d31882 | 113 | }; |
5045ca9e FM |
114 | |
115 | #endif // _WXPOEM_H_ |