1998-12-12 18:50:16 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wxpoem.h
|
|
|
|
// Purpose: A small C++ program which displays a random poem on
|
|
|
|
// execution. It also allows search for poems containing a
|
|
|
|
// string.
|
|
|
|
// It requires winpoem.dat and creates winpoem.idx.
|
|
|
|
// Original version (WinPoem) written in 1994.
|
|
|
|
// This has not been rewritten in a long time so
|
|
|
|
// beware, inelegant code!
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Created: 12/12/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-09-07 12:28:46 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1998-12-12 18:50:16 +00:00
|
|
|
#pragma interface "wxpoem.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Define a new application
|
|
|
|
class MyApp: public wxApp
|
|
|
|
{
|
2005-03-15 20:33:42 +00:00
|
|
|
public:
|
1998-12-12 18:50:16 +00:00
|
|
|
bool OnInit();
|
|
|
|
int OnExit();
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_APP(MyApp)
|
|
|
|
|
|
|
|
// Define a new canvas which can receive some events
|
1999-02-26 18:04:12 +00:00
|
|
|
class MyCanvas: public wxWindow
|
1998-12-12 18:50:16 +00:00
|
|
|
{
|
2005-03-15 20:33:42 +00:00
|
|
|
public:
|
|
|
|
MyCanvas(wxFrame *frame);
|
2004-02-09 20:01:55 +00:00
|
|
|
~MyCanvas();
|
1998-12-12 18:50:16 +00:00
|
|
|
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
|
|
|
void OnChar(wxKeyEvent& event);
|
|
|
|
|
2005-03-15 20:33:42 +00:00
|
|
|
private:
|
|
|
|
wxMenu *m_popupMenu;
|
|
|
|
|
1998-12-12 18:50:16 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame
|
|
|
|
class MainWindow: public wxFrame
|
|
|
|
{
|
2005-03-15 20:33:42 +00:00
|
|
|
public:
|
1998-12-12 18:50:16 +00:00
|
|
|
MyCanvas *canvas;
|
|
|
|
MainWindow(wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
|
2005-03-21 20:22:39 +00:00
|
|
|
~MainWindow();
|
1998-12-12 18:50:16 +00:00
|
|
|
|
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
void OnChar(wxKeyEvent& event);
|
1999-11-04 15:59:39 +00:00
|
|
|
void OnPopup(wxCommandEvent& event);
|
1998-12-12 18:50:16 +00:00
|
|
|
|
|
|
|
// Display next page or poem
|
|
|
|
void NextPage(void);
|
|
|
|
|
|
|
|
// Display previous page
|
|
|
|
void PreviousPage(void);
|
|
|
|
|
|
|
|
// User search
|
|
|
|
void Search(bool);
|
|
|
|
|
|
|
|
// Look in file for string
|
|
|
|
long DoSearch(void);
|
|
|
|
|
|
|
|
// Do the actual drawing of text (or just calculate size needed)
|
|
|
|
void ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y);
|
|
|
|
|
|
|
|
// Load the poem
|
|
|
|
void GetIndexLoadPoem(void);
|
|
|
|
void Resize(void);
|
|
|
|
|
2005-03-15 20:33:42 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
wxString m_searchString;
|
|
|
|
wxString m_title;
|
|
|
|
|
|
|
|
// Preferences
|
|
|
|
void WritePreferences();
|
|
|
|
void ReadPreferences();
|
|
|
|
|
|
|
|
// Fonts
|
|
|
|
void CreateFonts();
|
|
|
|
wxFont *m_normalFont;
|
|
|
|
wxFont *m_boldFont;
|
|
|
|
wxFont *m_italicFont;
|
|
|
|
|
2005-03-21 20:22:39 +00:00
|
|
|
// Icons
|
|
|
|
wxIcon *m_corners[4];
|
|
|
|
|
2004-02-09 20:01:55 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-12-12 18:50:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Menu items
|
2004-02-09 20:01:55 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-03-15 20:33:42 +00:00
|
|
|
POEM_ABOUT = wxID_ABOUT,
|
|
|
|
POEM_EXIT = wxID_EXIT,
|
|
|
|
POEM_PREVIOUS = wxID_BACKWARD,
|
|
|
|
POEM_COPY = wxID_COPY,
|
|
|
|
POEM_NEXT = wxID_FORWARD,
|
|
|
|
POEM_NEXT_MATCH = wxID_MORE,
|
|
|
|
POEM_BIGGER_TEXT = wxID_ZOOM_IN,
|
|
|
|
POEM_SMALLER_TEXT = wxID_ZOOM_OUT,
|
|
|
|
POEM_SEARCH = wxID_FIND,
|
|
|
|
POEM_MINIMIZE = wxID_ICONIZE_FRAME
|
2004-02-09 20:01:55 +00:00
|
|
|
};
|