wxpoem.h 2.7 KB

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