]> git.saurik.com Git - wxWidgets.git/blame - demos/poem/wxpoem.h
comment out test code
[wxWidgets.git] / demos / poem / wxpoem.h
CommitLineData
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
3013b6f4
JS
17// Define a new application
18class MyApp: public wxApp
19{
c7bde65d 20public:
3013b6f4
JS
21 bool OnInit();
22 int OnExit();
23};
24
25DECLARE_APP(MyApp)
26
27// Define a new canvas which can receive some events
b23386b2 28class MyCanvas: public wxWindow
3013b6f4 29{
c7bde65d
WS
30public:
31 MyCanvas(wxFrame *frame);
d3c7fc99 32 virtual ~MyCanvas();
3013b6f4
JS
33
34 void OnPaint(wxPaintEvent& event);
35 void OnMouseEvent(wxMouseEvent& event);
36 void OnChar(wxKeyEvent& event);
37
c7bde65d
WS
38private:
39 wxMenu *m_popupMenu;
40
3013b6f4
JS
41 DECLARE_EVENT_TABLE()
42};
43
44// Define a new frame
45class MainWindow: public wxFrame
46{
c7bde65d 47public:
3013b6f4
JS
48 MyCanvas *canvas;
49 MainWindow(wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
d3c7fc99 50 virtual ~MainWindow();
3013b6f4
JS
51
52 void OnCloseWindow(wxCloseEvent& event);
53 void OnChar(wxKeyEvent& event);
508379ee 54 void OnPopup(wxCommandEvent& event);
3013b6f4
JS
55
56 // Display next page or poem
57 void NextPage(void);
58
59 // Display previous page
60 void PreviousPage(void);
61
62 // User search
63 void Search(bool);
64
65 // Look in file for string
66 long DoSearch(void);
67
68 // Do the actual drawing of text (or just calculate size needed)
69 void ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y);
70
71 // Load the poem
72 void GetIndexLoadPoem(void);
73 void Resize(void);
74
c7bde65d
WS
75private:
76
77 wxString m_searchString;
78 wxString m_title;
79
80 // Preferences
81 void WritePreferences();
82 void ReadPreferences();
83
84 // Fonts
85 void CreateFonts();
86 wxFont *m_normalFont;
87 wxFont *m_boldFont;
88 wxFont *m_italicFont;
89
3baa2662
WS
90 // Icons
91 wxIcon *m_corners[4];
92
17d31882 93 DECLARE_EVENT_TABLE()
3013b6f4
JS
94};
95
96// Menu items
17d31882
DS
97enum
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};