]>
git.saurik.com Git - wxWidgets.git/blob - demos/poem/wxpoem.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: A small C++ program which displays a random poem on
4 // execution. It also allows search for poems containing a
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
13 // Copyright: (c) 1998 Julian Smart
14 // Licence: wxWindows licence
15 /////////////////////////////////////////////////////////////////////////////
18 #pragma implementation "wxpoem.h"
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
36 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXX11__)
37 #include "corner1.xpm"
38 #include "corner2.xpm"
39 #include "corner3.xpm"
40 #include "corner4.xpm"
55 #define buf_size 10000
56 #define DEFAULT_POETRY_DAT "wxpoem"
57 #define DEFAULT_POETRY_IND "wxpoem"
58 #define DEFAULT_CHAR_HEIGHT 18
59 #define DEFAULT_FONT "Swiss"
60 #define DEFAULT_X_POS 0
61 #define DEFAULT_Y_POS 0
62 #define BORDER_SIZE 30
63 #define THIN_LINE_BORDER 10
64 #define THICK_LINE_BORDER 16
65 #define THICK_LINE_WIDTH 2
66 #define SHADOW_OFFSET 1
70 static char *poem_buffer
; // Storage for each poem
71 static char line
[150]; // Storage for a line
72 static char title
[150]; // Remember the title
73 static char *search_string
= NULL
; // The search string
74 static int pages
[30]; // For multipage poems -
75 // store the start of each page
76 static long last_poem_start
= 0; // Start of last found poem
77 static long last_find
= -1; // Point in file of last found
79 static bool search_ok
= FALSE
; // Search was successful
80 static bool same_search
= FALSE
; // Searching on same string
82 static long poem_index
[600]; // Index of poem starts
83 static long nitems
= 0; // Number of poems
84 static int char_height
= DEFAULT_CHAR_HEIGHT
; // Actual height
85 static int index_ptr
= -1; // Pointer into index
86 static int poem_height
, poem_width
; // Size of poem
87 static int XPos
; // Startup X position
88 static int YPos
; // Startup Y position
89 static int pointSize
= 12; // Font size
91 static char *index_filename
= NULL
; // Index filename
92 static char *data_filename
= NULL
; // Data filename
93 static char error_buf
[300]; // Error message buffer
94 static bool loaded_ok
= FALSE
; // Poem loaded ok
95 static bool index_ok
= FALSE
; // Index loaded ok
97 static bool paging
= FALSE
; // Are we paging?
98 static int current_page
= 0; // Currently viewed page
100 wxIcon
*Corner1
= NULL
;
101 wxIcon
*Corner2
= NULL
;
102 wxIcon
*Corner3
= NULL
;
103 wxIcon
*Corner4
= NULL
;
106 wxFont
*NormalFont
= NULL
;
107 wxFont
*BoldFont
= NULL
;
108 wxFont
*ItalicFont
= NULL
;
111 wxPen
*GreyPen
= NULL
;
112 wxPen
*DarkGreyPen
= NULL
;
113 wxPen
*WhitePen
= NULL
;
116 wxBitmap
*backingBitmap
= NULL
;
118 void PoetryError(char *, char *caption
="wxPoem Error");
119 void PoetryNotify(char *Msg
, char *caption
="wxPoem");
121 bool LoadPoem(char *, long);
123 int LoadIndex(char *);
125 void WritePreferences();
126 void ReadPreferences();
127 void FindMax(int *max_thing
, int thing
);
130 void CopyToClipboard(HWND
, char *);
133 wxMenu
*popupMenu
= NULL
;
136 wxHelpController
*HelpController
= NULL
;
141 MainWindow
*TheMainWindow
= NULL
;
146 NormalFont
= wxTheFontList
->FindOrCreateFont(pointSize
, wxSWISS
, wxNORMAL
, wxNORMAL
);
147 BoldFont
= wxTheFontList
->FindOrCreateFont(pointSize
, wxSWISS
, wxNORMAL
, wxBOLD
);
148 ItalicFont
= wxTheFontList
->FindOrCreateFont(pointSize
, wxSWISS
, wxITALIC
, wxNORMAL
);
151 BEGIN_EVENT_TABLE(MainWindow
, wxFrame
)
152 EVT_CLOSE(MainWindow::OnCloseWindow
)
153 EVT_CHAR(MainWindow::OnChar
)
154 EVT_MENU(-1, MainWindow::OnPopup
)
157 MainWindow::MainWindow(wxFrame
*frame
, wxWindowID id
, const wxString
& title
,
158 const wxPoint
& pos
, const wxSize
& size
, long style
):
159 wxFrame(frame
, id
, title
, pos
, size
, style
)
163 MainWindow::~MainWindow()
165 // Note: this must be done before the main window/canvas are destroyed
166 // or we get an error (no parent window for menu item button)
171 // Read the poetry buffer, either for finding the size
172 // or for writing to a bitmap (not to the window directly,
173 // since that displays messily)
174 // If DrawIt is true, we draw, otherwise we just determine the
175 // size the window should be.
176 void MainWindow::ScanBuffer(wxDC
*dc
, bool DrawIt
, int *max_x
, int *max_y
)
178 int i
= pages
[current_page
];
185 bool page_break
= FALSE
;
192 y
= (*max_y
- poem_height
)/2;
197 if (DrawIt
&& wxColourDisplay())
199 dc
->SetBrush(*wxLIGHT_GREY_BRUSH
);
200 dc
->SetPen(*GreyPen
);
201 dc
->DrawRectangle(0, 0, width
, height
);
202 dc
->SetBackgroundMode(wxTRANSPARENT
);
205 // See what ACTUAL char height is
206 dc
->SetFont(* NormalFont
);
209 dc
->GetTextExtent("X", &xx
, &yy
);
210 char_height
= (int)yy
;
212 if (current_page
== 0)
214 else if (title
[0] != 0)
216 dc
->SetFont(* BoldFont
);
217 dc
->GetTextExtent(title
, &xx
, &yy
);
218 FindMax(&curr_width
, (int)xx
);
223 dc
->SetFont(* BoldFont
);
225 // Change text to BLACK!
226 dc
->SetTextForeground(* wxBLACK
);
227 dc
->DrawText(title
, x
, y
);
228 // Change text to WHITE!
229 dc
->SetTextForeground(* wxWHITE
);
230 dc
->DrawText(title
, x
-SHADOW_OFFSET
, y
-SHADOW_OFFSET
);
236 while (ch
!= 0 && !page_break
)
239 #if defined(__WXMSW__) || defined(__WXMAC__)
240 while (((ch
= poem_buffer
[i
]) != 13) && (ch
!= 0))
242 while (((ch
= poem_buffer
[i
]) != 10) && (ch
!= 0))
250 #if defined(__WXMSW__) || defined(__WXMAC__)
259 // Add another to skip the linefeed
262 // If a single newline on its own, put a space in
284 dc
->SetFont(* BoldFont
);
287 strcpy(title
, line_ptr
);
288 strcat(title
, " (cont'd)");
290 dc
->GetTextExtent(line_ptr
, &xx
, &yy
);
291 FindMax(&curr_width
, (int)xx
);
296 dc
->SetFont(* BoldFont
);
298 // Change text to BLACK!
299 dc
->SetTextForeground(* wxBLACK
);
300 dc
->DrawText(line_ptr
, x
, y
);
302 // Change text to WHITE!
303 dc
->SetTextForeground(* wxWHITE
);
304 dc
->DrawText(line_ptr
, x
-SHADOW_OFFSET
, y
-SHADOW_OFFSET
);
305 dc
->SetTextForeground(* wxWHITE
);
311 dc
->SetFont(* ItalicFont
);
313 dc
->GetTextExtent(line_ptr
, &xx
, &yy
);
314 FindMax(&curr_width
, (int)xx
);
319 dc
->SetTextForeground(* wxBLACK
);
320 dc
->DrawText(line_ptr
, x
, y
);
324 // Default: just ignore this line
331 dc
->SetFont(* NormalFont
);
333 dc
->GetTextExtent(line
, &xx
, &yy
);
334 FindMax(&curr_width
, (int)xx
);
338 int x
= (int)((width
- xx
)/2.0);
339 dc
->SetFont(* NormalFont
);
340 dc
->SetTextForeground(* wxBLACK
);
341 dc
->DrawText(line
, x
, y
);
351 char *cont
= "(cont'd)";
353 dc
->SetFont(* NormalFont
);
355 dc
->GetTextExtent(cont
, &xx
, &yy
);
356 FindMax(&curr_width
, (int)xx
);
359 int x
= (int)((width
- xx
)/2.0);
360 dc
->SetFont(* NormalFont
);
361 dc
->SetTextForeground(* wxBLACK
);
362 dc
->DrawText(cont
, x
, y
);
367 *max_x
= (int)curr_width
;
368 *max_y
= (int)(y
-char_height
);
371 pages
[current_page
+1] = i
;
377 // Draw dark grey thick border
378 if (wxColourDisplay())
380 dc
->SetBrush(*wxGREY_BRUSH
);
381 dc
->SetPen(*wxGREY_PEN
);
384 dc
->DrawRectangle(0, 0, THIN_LINE_BORDER
, height
);
386 dc
->DrawRectangle(THIN_LINE_BORDER
, 0, width
-THIN_LINE_BORDER
, THIN_LINE_BORDER
);
388 dc
->DrawRectangle(width
-THIN_LINE_BORDER
, THIN_LINE_BORDER
, width
, height
-THIN_LINE_BORDER
);
390 dc
->DrawRectangle(THIN_LINE_BORDER
, height
-THIN_LINE_BORDER
, width
-THIN_LINE_BORDER
, height
);
393 // Have grey background, plus 3-d border -
394 // One black rectangle.
395 // Inside this, left and top sides - dark grey. Bottom and right -
398 // Change pen to black
399 dc
->SetPen(*wxBLACK_PEN
);
400 dc
->DrawLine(THIN_LINE_BORDER
, THIN_LINE_BORDER
, width
-THIN_LINE_BORDER
, THIN_LINE_BORDER
);
401 dc
->DrawLine(width
-THIN_LINE_BORDER
, THIN_LINE_BORDER
, width
-THIN_LINE_BORDER
, height
-THIN_LINE_BORDER
);
402 dc
->DrawLine(width
-THIN_LINE_BORDER
, height
-THIN_LINE_BORDER
, THIN_LINE_BORDER
, height
-THIN_LINE_BORDER
);
403 dc
->DrawLine(THIN_LINE_BORDER
, height
-THIN_LINE_BORDER
, THIN_LINE_BORDER
, THIN_LINE_BORDER
);
405 // Right and bottom white lines - 'grey' (black!) if
406 // we're running on a mono display.
407 if (wxColourDisplay())
408 dc
->SetPen(*WhitePen
);
410 dc
->SetPen(*DarkGreyPen
);
412 dc
->DrawLine(width
-THICK_LINE_BORDER
, THICK_LINE_BORDER
,
413 width
-THICK_LINE_BORDER
, height
-THICK_LINE_BORDER
);
414 dc
->DrawLine(width
-THICK_LINE_BORDER
, height
-THICK_LINE_BORDER
,
415 THICK_LINE_BORDER
, height
-THICK_LINE_BORDER
);
417 // Left and top grey lines
418 dc
->SetPen(*DarkGreyPen
);
419 dc
->DrawLine(THICK_LINE_BORDER
, height
-THICK_LINE_BORDER
,
420 THICK_LINE_BORDER
, THICK_LINE_BORDER
);
421 dc
->DrawLine(THICK_LINE_BORDER
, THICK_LINE_BORDER
,
422 width
-THICK_LINE_BORDER
, THICK_LINE_BORDER
);
426 dc
->DrawIcon(* Corner1
, 0, 0);
427 dc
->DrawIcon(* Corner2
, int(width
-32), 0);
429 int y2
= height
- 32;
431 dc
->DrawIcon(* Corner3
, 0, y2
);
432 dc
->DrawIcon(* Corner4
, x2
, y2
);
437 // Get an index (randomly generated) and load the poem
438 void MainWindow::GetIndexLoadPoem(void)
441 index_ptr
= GetIndex();
444 loaded_ok
= LoadPoem(data_filename
, -1);
447 // Find the size of the poem and resize the window accordingly
448 void MainWindow::Resize(void)
450 wxClientDC
dc(canvas
);
453 ScanBuffer(& dc
, FALSE
, &poem_width
, &poem_height
);
454 int x
= poem_width
+ (2*BORDER_SIZE
);
455 int y
= poem_height
+ (2*BORDER_SIZE
);
459 // In case client size isn't what we set it to...
461 GetClientSize(&xx
, &yy
);
464 if (backingBitmap
) delete backingBitmap
;
465 backingBitmap
= new wxBitmap(x
, yy
);
466 memDC
.SelectObject(* backingBitmap
);
469 TheMainWindow
->ScanBuffer(&memDC
, TRUE
, &xx
, &yy
);
473 void FindMax(int *max_thing
, int thing
)
475 if (thing
> *max_thing
)
480 void MainWindow::NextPage(void)
493 void MainWindow::PreviousPage(void)
495 if (current_page
> 0)
502 // Search for a string
503 void MainWindow::Search(bool ask
)
507 if (ask
|| !search_string
)
509 wxString s
= wxGetTextFromUser("Enter search string", "Search", (const char*) search_string
);
512 if (search_string
) delete[] search_string
;
513 search_string
= copystring(s
);
515 } else search_ok
= FALSE
;
523 if (search_string
&& search_ok
)
525 position
= DoSearch();
528 loaded_ok
= LoadPoem(data_filename
, position
);
534 PoetryNotify("Search string not found.");
539 // Copy a string to the clipboard
541 void CopyToClipboard(HWND handle
, char *s
)
543 int length
= strlen(s
);
544 HANDLE hGlobalMemory
= GlobalAlloc(GHND
, (DWORD
) length
+ 1);
547 #ifdef __WINDOWS_386__
548 LPSTR lpGlobalMemory
= MK_FP32(GlobalLock(hGlobalMemory
));
550 LPSTR lpGlobalMemory
= (LPSTR
)GlobalLock(hGlobalMemory
);
553 for (i
= 0; i
< length
; i
++)
571 lpGlobalMemory
[j
] = s
[i
];
576 GlobalUnlock(hGlobalMemory
);
577 OpenClipboard(handle
);
579 SetClipboardData(CF_TEXT
, hGlobalMemory
);
587 poem_buffer
= new char[buf_size
];
589 GreyPen
= new wxPen("LIGHT GREY", THICK_LINE_WIDTH
, wxSOLID
);
590 DarkGreyPen
= new wxPen("GREY", THICK_LINE_WIDTH
, wxSOLID
);
591 WhitePen
= new wxPen("WHITE", THICK_LINE_WIDTH
, wxSOLID
);
594 HelpController
= new wxHelpController();
595 HelpController
->Initialize("wxpoem");
602 // Seed the random number generator
605 (void)time(¤t_time
);
606 srand((unsigned int)current_time
);
611 TheMainWindow
= new MainWindow(NULL
, 500, "wxPoem", wxPoint(XPos
, YPos
), wxSize(100, 100), wxCAPTION
|wxMINIMIZE_BOX
|wxSYSTEM_MENU
);
614 TheMainWindow
->SetIcon(Icon("wxpoem"));
617 TheMainWindow
->canvas
= new MyCanvas(TheMainWindow
, 501, wxDefaultPosition
, wxDefaultSize
);
619 popupMenu
= new wxMenu
;
620 popupMenu
->Append(POEM_NEXT
, "Next poem/page");
621 popupMenu
->Append(POEM_PREVIOUS
, "Previous page");
622 popupMenu
->AppendSeparator();
623 popupMenu
->Append(POEM_SEARCH
, "Search");
624 popupMenu
->Append(POEM_NEXT_MATCH
, "Next match");
625 popupMenu
->Append(POEM_COPY
, "Copy to clipboard");
626 popupMenu
->Append(POEM_MINIMIZE
, "Minimize");
627 popupMenu
->AppendSeparator();
628 popupMenu
->Append(POEM_BIGGER_TEXT
, "Bigger text");
629 popupMenu
->Append(POEM_SMALLER_TEXT
, "Smaller text");
630 popupMenu
->AppendSeparator();
631 popupMenu
->Append(POEM_ABOUT
, "About wxPoem");
632 popupMenu
->AppendSeparator();
633 popupMenu
->Append(POEM_EXIT
, "Exit");
637 index_filename
= copystring(argv
[1]);
638 data_filename
= copystring(argv
[1]);
642 index_filename
= DEFAULT_POETRY_IND
;
643 data_filename
= DEFAULT_POETRY_DAT
;
648 Corner1
= new wxIcon("icon_1");
649 Corner2
= new wxIcon("icon_2");
650 Corner3
= new wxIcon("icon_3");
651 Corner4
= new wxIcon("icon_4");
653 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXX11__)
654 Corner1
= new wxIcon( corner1_xpm
);
655 Corner2
= new wxIcon( corner2_xpm
);
656 Corner3
= new wxIcon( corner3_xpm
);
657 Corner4
= new wxIcon( corner4_xpm
);
660 TheMainWindow
->GetIndexLoadPoem();
661 TheMainWindow
->Resize();
662 TheMainWindow
->Show(TRUE
);
670 delete backingBitmap
;
672 delete HelpController
;
683 // Causes crash since they're deleted by the global font list
690 delete[] poem_buffer
;
692 delete[] search_string
;
697 void MainWindow::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
703 void MainWindow::OnChar(wxKeyEvent
& event
)
705 canvas
->OnChar(event
);
708 BEGIN_EVENT_TABLE(MyCanvas
, wxWindow
)
709 EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent
)
710 EVT_CHAR(MyCanvas::OnChar
)
711 EVT_PAINT(MyCanvas::OnPaint
)
714 // Define a constructor for my canvas
715 MyCanvas::MyCanvas(wxFrame
*frame
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
):
716 wxWindow(frame
, id
, pos
, size
)
720 // Define the repainting behaviour
721 void MyCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
))
728 TheMainWindow
->GetClientSize(&xx
, &yy
);
730 dc
.DrawBitmap(* backingBitmap
, 0, 0);
733 memDC
.SelectObject(* backingBitmap
);
734 dc
.Blit(0, 0, backingBitmap
->GetWidth(), backingBitmap
->GetHeight(), &memDC
, 0, 0);
739 void MyCanvas::OnMouseEvent(wxMouseEvent
& event
)
741 static int startPosX
, startPosY
, startFrameX
, startFrameY
;
744 event
.GetPosition(&x
, &y
);
746 if (event
.RightDown())
748 // Versions from wxWin 1.67 are probably OK
749 PopupMenu(popupMenu
, (int)x
, (int)y
);
751 else if (event
.LeftDown())
753 this->CaptureMouse();
756 ClientToScreen(&x1
, &y1
);
759 GetParent()->GetPosition(&startFrameX
, &startFrameY
);
761 else if (event
.LeftUp())
762 this->ReleaseMouse();
763 else if (event
.Dragging() && event
.LeftIsDown())
767 ClientToScreen(&x1
, &y1
);
769 int dX
= x1
- startPosX
;
770 int dY
= y1
- startPosY
;
771 GetParent()->Move(startFrameX
+ dX
, startFrameY
+ dY
);
775 // Process characters
776 void MyCanvas::OnChar(wxKeyEvent
& event
)
778 switch (event
.KeyCode())
783 TheMainWindow
->Search(FALSE
);
788 TheMainWindow
->Search(TRUE
);
792 TheMainWindow
->NextPage();
795 TheMainWindow
->Close(TRUE
);
802 int LoadIndex(char *file_name
)
811 sprintf(buf
, "%s.idx", file_name
);
812 if (! (file_name
&& (index_file
= fopen(buf
, "r"))))
816 fscanf(index_file
, "%ld", &nitems
);
818 for (i
= 0; i
< nitems
; i
++)
820 fscanf(index_file
, "%ld", &data
);
821 poem_index
[i
] = data
;
834 indexn
= (int)(rand() % nitems
);
836 if ((indexn
< 0) || (indexn
> nitems
))
837 { PoetryError("No such poem!");
845 void ReadPreferences()
847 wxGetResource("wxPoem", "FontSize", &pointSize
);
848 wxGetResource("wxPoem", "X", &XPos
);
849 wxGetResource("wxPoem", "Y", &YPos
);
852 // Write preferences to disk
853 void WritePreferences()
856 TheMainWindow
->GetPosition(&XPos
, &YPos
);
857 wxWriteResource("wxPoem", "FontSize", pointSize
);
858 wxWriteResource("wxPoem", "X", XPos
);
859 wxWriteResource("wxPoem", "Y", YPos
);
863 // Load a poem from given file, at given point in file.
864 // If position is > -1, use this for the position in the
865 // file, otherwise use index[index_ptr] to find the correct position.
866 bool LoadPoem(char *file_name
, long position
)
880 sprintf(buf
, "%s.dat", file_name
);
882 if (! (file_name
&& (data_file
= fopen(buf
, "r"))))
884 sprintf(error_buf
, "Data file %s not found.", buf
);
885 PoetryError(error_buf
);
893 data
= poem_index
[index_ptr
];
895 fseek(data_file
, data
, SEEK_SET
);
899 while ((ch
!= EOF
) && (ch
!= '#'))
901 ch
= getc(data_file
);
902 // Add a linefeed so it will copy to the clipboard ok
914 sprintf(error_buf
, "%s", "Poetry buffer exceeded.");
915 PoetryError(error_buf
);
920 poem_buffer
[i
-1] = 0;
926 long MainWindow::DoSearch(void)
936 long previous_poem_start
;
939 int search_length
= strlen(search_string
);
943 find_start
= last_find
+ 1;
944 previous_poem_start
= last_poem_start
;
950 previous_poem_start
= -1;
954 sprintf(buf
, "%s.dat", data_filename
);
956 if (! (data_filename
&& (file
= fopen(buf
, "r"))))
958 sprintf(error_buf
, "Poetry data file %s not found\n", buf
);
959 PoetryError(error_buf
);
963 fseek(file
, find_start
, SEEK_SET
);
965 while ((ch
!= EOF
) && !found
)
968 ch
|= 0x0020; // Make lower case
970 // Only match if we're looking at a different poem
971 // (no point in displaying the same poem again)
972 if ((ch
== search_string
[i
]) && (last_poem_start
!= previous_poem_start
))
975 last_find
= ftell(file
);
976 if (i
== search_length
-1)
986 last_poem_start
= ftell(file
);
995 return last_poem_start
;
1001 // Set up poetry filenames, preferences, load the index
1002 // Load index (or compile it if none found)
1005 index_ok
= (LoadIndex(index_filename
) != 0);
1006 if (!index_ok
|| (nitems
== 0))
1008 PoetryError("Index file not found; will compile new one", "wxPoem");
1009 index_ok
= Compile();
1014 void PoetryError(char *msg
, char *caption
)
1016 wxMessageBox(msg
, caption
, wxOK
|wxICON_EXCLAMATION
);
1019 // Notification (change icon to something appropriate!)
1020 void PoetryNotify(char *Msg
, char *caption
)
1022 wxMessageBox(Msg
, caption
, wxOK
| wxICON_INFORMATION
);
1025 // Build up and save an index into the poetry data file, for
1026 // rapid random access
1036 sprintf(buf
, "%s.dat", data_filename
);
1038 if (! (data_filename
&& (file
= fopen(buf
, "r"))))
1040 sprintf(error_buf
, "Poetry data file %s not found\n", buf
);
1041 PoetryError(error_buf
);
1048 poem_index
[nitems
] = 0;
1061 poem_index
[nitems
] = data
;
1068 sprintf(buf
, "%s.idx", index_filename
);
1069 if (! (data_filename
&& (file
= fopen(buf
, "w"))))
1071 sprintf(error_buf
, "Poetry index file %s cannot be created\n", buf
);
1072 PoetryError(error_buf
);
1076 fprintf(file
, "%ld\n\n", nitems
);
1077 for (j
= 0; j
< nitems
; j
++)
1078 fprintf(file
, "%ld\n", poem_index
[j
]);
1081 PoetryNotify("Poetry index compiled.");
1085 void MainWindow::OnPopup(wxCommandEvent
& event
)
1087 switch (event
.GetId())
1090 // Another poem/page
1091 TheMainWindow
->NextPage();
1095 TheMainWindow
->PreviousPage();
1098 // Search - with dialog
1099 TheMainWindow
->Search(TRUE
);
1101 case POEM_NEXT_MATCH
:
1102 // Search - without dialog (next match)
1103 TheMainWindow
->Search(FALSE
);
1106 TheMainWindow
->Iconize(TRUE
);
1110 // Copy current poem to the clipboard
1111 CopyToClipboard((HWND
) TheMainWindow
->GetHWND(), poem_buffer
);
1118 case POEM_BIGGER_TEXT
:
1122 TheMainWindow
->Resize();
1125 case POEM_SMALLER_TEXT
:
1131 TheMainWindow
->Resize();
1135 case POEM_HELP_CONTENTS
:
1138 HelpController
->LoadFile("wxpoem");
1139 HelpController
->DisplayContents();
1140 #endif // wxUSE_HELP
1145 (void)wxMessageBox("wxPoem Version 1.1\nJulian Smart (c) 1995",
1146 "About wxPoem", wxOK
, TheMainWindow
);
1151 TheMainWindow
->Close(TRUE
);