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