]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/stc/stctest.cpp
8c27905685988659e74416e9684007019675a5d6
[wxWidgets.git] / contrib / samples / stc / stctest.cpp
1 //////////////////////////////////////////////////////////////////////////////
2 // File: app.cpp
3 // Purpose: STC test application
4 // Maintainer: Otto Wyss
5 // Created: 2003-09-01
6 // RCS-ID: $Id$
7 // Copyright: (c) wxGuide
8 // Licence: wxWindows licence
9 //////////////////////////////////////////////////////////////////////////////
10
11 //----------------------------------------------------------------------------
12 // headers
13 //----------------------------------------------------------------------------
14
15 // For compilers that support precompilation, includes <wx/wx.h>.
16 #include <wx/wxprec.h>
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 // for all others, include the necessary headers (this file is usually all you
23 // need because it includes almost all 'standard' wxWindows headers)
24 #ifndef WX_PRECOMP
25 #include <wx/wx.h>
26 #endif
27
28 //! wxWindows headers
29 #include <wx/config.h> // configuration support
30 #include <wx/filedlg.h> // file dialog support
31 #include <wx/filename.h> // filename support
32 #include <wx/notebook.h> // notebook support
33 #include <wx/settings.h> // system settings
34 #include <wx/string.h> // strings support
35
36 //! application headers
37 #include "defsext.h" // Additional definitions
38 #include "edit.h" // Edit module
39 #include "prefs.h" // Prefs
40
41
42 //----------------------------------------------------------------------------
43 // resources
44 //----------------------------------------------------------------------------
45
46 // the application icon (under Windows and OS/2 it is in resources)
47 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
48 #include "mondrian.xpm"
49 #endif
50
51 //============================================================================
52 // declarations
53 //============================================================================
54
55 #define APP_NAME _T("STC-Test")
56 #define APP_DESCR _("See http://wxguide.sourceforge.net/indexedit.html")
57
58 #define APP_MAINT _T("Otto Wyss")
59 #define APP_VENDOR _T("wxWindows")
60 #define APP_COPYRIGTH _T("(C) 2003 Otto Wyss")
61 #define APP_LICENCE _T("wxWindows")
62
63 #define APP_VERSION _T("0.1.alpha")
64 #define APP_BUILD __DATE__
65
66 #define APP_WEBSITE _T("http://www.wxWindows.org")
67 #define APP_MAIL _T("mailto://???")
68
69 #define NONAME _("<untitled>")
70
71 class AppBook;
72
73
74 //----------------------------------------------------------------------------
75 //! global application name
76 wxString *g_appname = NULL;
77
78 //! global print data, to remember settings during the session
79 wxPrintData *g_printData = (wxPrintData*) NULL;
80 wxPageSetupData *g_pageSetupData = (wxPageSetupData*) NULL;
81
82
83 //----------------------------------------------------------------------------
84 //! application APP_VENDOR-APP_NAME.
85 class App: public wxApp {
86 friend class AppFrame;
87
88 public:
89 //! the main function called durning application start
90 virtual bool OnInit ();
91
92 //! application exit function
93 virtual int OnExit ();
94
95 private:
96 //! frame window
97 AppFrame* m_frame;
98
99 };
100
101 // created dynamically by wxWindows
102 DECLARE_APP (App);
103
104 //----------------------------------------------------------------------------
105 //! frame of the application APP_VENDOR-APP_NAME.
106 class AppFrame: public wxFrame {
107 friend class App;
108 friend class AppBook;
109 friend class AppAbout;
110
111 public:
112 //! constructor
113 AppFrame (const wxString &title);
114
115 //! destructor
116 ~AppFrame ();
117
118 //! event handlers
119 //! common
120 void OnClose (wxCloseEvent &event);
121 void OnAbout (wxCommandEvent &event);
122 void OnExit (wxCommandEvent &event);
123 void OnTimerEvent (wxTimerEvent &event);
124 //! file
125 void OnFileNew (wxCommandEvent &event);
126 void OnFileNewFrame (wxCommandEvent &event);
127 void OnFileOpen (wxCommandEvent &event);
128 void OnFileOpenFrame (wxCommandEvent &event);
129 void OnFileSave (wxCommandEvent &event);
130 void OnFileSaveAs (wxCommandEvent &event);
131 void OnFileClose (wxCommandEvent &event);
132 //! properties
133 void OnProperties (wxCommandEvent &event);
134 //! print
135 void OnPrintSetup (wxCommandEvent &event);
136 void OnPrintPreview (wxCommandEvent &event);
137 void OnPrint (wxCommandEvent &event);
138 //! edit events
139 void OnEdit (wxCommandEvent &event);
140
141 private:
142 // edit object
143 Edit *m_edit;
144 void FileOpen (wxString fname);
145
146 //! creates the application menu bar
147 wxMenuBar *m_menuBar;
148 void CreateMenu ();
149
150 // print preview position and size
151 wxRect DeterminePrintSize ();
152
153 DECLARE_EVENT_TABLE()
154 };
155
156 //----------------------------------------------------------------------------
157 //! about box of the application APP_VENDOR-APP_NAME
158 class AppAbout: public wxDialog {
159
160 public:
161 //! constructor
162 AppAbout (wxWindow *parent,
163 int milliseconds = 0,
164 long style = 0);
165
166 //! destructor
167 ~AppAbout ();
168
169 // event handlers
170 void OnTimerEvent (wxTimerEvent &event);
171
172 private:
173 // timer
174 wxTimer *m_timer;
175
176 DECLARE_EVENT_TABLE()
177 };
178
179
180 //============================================================================
181 // implementation
182 //============================================================================
183
184 IMPLEMENT_APP (App)
185
186 //----------------------------------------------------------------------------
187 // App
188 //----------------------------------------------------------------------------
189
190 bool App::OnInit () {
191
192 wxInitAllImageHandlers();
193
194 // set application and vendor name
195 SetAppName (APP_NAME);
196 SetVendorName (APP_VENDOR);
197 g_appname = new wxString ();
198 g_appname->Append (APP_VENDOR);
199 g_appname->Append (_T("-"));
200 g_appname->Append (APP_NAME);
201
202 // initialize print data and setup
203 g_printData = new wxPrintData;
204 g_pageSetupData = new wxPageSetupDialogData;
205
206 // create application frame
207 m_frame = new AppFrame (*g_appname);
208
209 // open application frame
210 m_frame->Layout ();
211 m_frame->Show (true);
212 SetTopWindow (m_frame);
213
214 return true;
215 }
216
217 int App::OnExit () {
218
219 // delete global appname
220 delete g_appname;
221
222 // delete global print data and setup
223 if (g_printData) delete g_printData;
224 if (g_pageSetupData) delete g_pageSetupData;
225
226 return 0;
227 }
228
229 //----------------------------------------------------------------------------
230 // AppFrame
231 //----------------------------------------------------------------------------
232
233 BEGIN_EVENT_TABLE (AppFrame, wxFrame)
234 // common
235 EVT_CLOSE ( AppFrame::OnClose)
236 // file
237 EVT_MENU (wxID_OPEN, AppFrame::OnFileOpen)
238 EVT_MENU (wxID_SAVE, AppFrame::OnFileSave)
239 EVT_MENU (wxID_SAVEAS, AppFrame::OnFileSaveAs)
240 EVT_MENU (wxID_CLOSE, AppFrame::OnFileClose)
241 // properties
242 EVT_MENU (myID_PROPERTIES, AppFrame::OnProperties)
243 // print and exit
244 EVT_MENU (wxID_PRINT_SETUP, AppFrame::OnPrintSetup)
245 EVT_MENU (wxID_PREVIEW, AppFrame::OnPrintPreview)
246 EVT_MENU (wxID_PRINT, AppFrame::OnPrint)
247 EVT_MENU (wxID_EXIT, AppFrame::OnExit)
248 // edit
249 EVT_MENU (wxID_CLEAR, AppFrame::OnEdit)
250 EVT_MENU (wxID_CUT, AppFrame::OnEdit)
251 EVT_MENU (wxID_COPY, AppFrame::OnEdit)
252 EVT_MENU (wxID_PASTE, AppFrame::OnEdit)
253 EVT_MENU (myID_INDENTINC, AppFrame::OnEdit)
254 EVT_MENU (myID_INDENTRED, AppFrame::OnEdit)
255 EVT_MENU (wxID_SELECTALL, AppFrame::OnEdit)
256 EVT_MENU (myID_SELECTLINE, AppFrame::OnEdit)
257 EVT_MENU (wxID_REDO, AppFrame::OnEdit)
258 EVT_MENU (wxID_UNDO, AppFrame::OnEdit)
259 // find
260 EVT_MENU (wxID_FIND, AppFrame::OnEdit)
261 EVT_MENU (myID_FINDNEXT, AppFrame::OnEdit)
262 EVT_MENU (myID_REPLACE, AppFrame::OnEdit)
263 EVT_MENU (myID_REPLACENEXT, AppFrame::OnEdit)
264 EVT_MENU (myID_BRACEMATCH, AppFrame::OnEdit)
265 EVT_MENU (myID_GOTO, AppFrame::OnEdit)
266 // view
267 EVT_MENU_RANGE (myID_HILIGHTFIRST, myID_HILIGHTLAST,
268 AppFrame::OnEdit)
269 EVT_MENU (myID_DISPLAYEOL, AppFrame::OnEdit)
270 EVT_MENU (myID_INDENTGUIDE, AppFrame::OnEdit)
271 EVT_MENU (myID_LINENUMBER, AppFrame::OnEdit)
272 EVT_MENU (myID_LONGLINEON, AppFrame::OnEdit)
273 EVT_MENU (myID_WHITESPACE, AppFrame::OnEdit)
274 EVT_MENU (myID_FOLDTOGGLE, AppFrame::OnEdit)
275 EVT_MENU (myID_OVERTYPE, AppFrame::OnEdit)
276 EVT_MENU (myID_READONLY, AppFrame::OnEdit)
277 EVT_MENU (myID_WRAPMODEON, AppFrame::OnEdit)
278 // extra
279 EVT_MENU (myID_CHANGELOWER, AppFrame::OnEdit)
280 EVT_MENU (myID_CHANGEUPPER, AppFrame::OnEdit)
281 EVT_MENU (myID_CONVERTCR, AppFrame::OnEdit)
282 EVT_MENU (myID_CONVERTCRLF, AppFrame::OnEdit)
283 EVT_MENU (myID_CONVERTLF, AppFrame::OnEdit)
284 EVT_MENU (myID_CHARSETANSI, AppFrame::OnEdit)
285 EVT_MENU (myID_CHARSETMAC, AppFrame::OnEdit)
286 // help
287 EVT_MENU (wxID_ABOUT, AppFrame::OnAbout)
288 END_EVENT_TABLE ()
289
290 AppFrame::AppFrame (const wxString &title)
291 : wxFrame ((wxFrame *)NULL, -1, title, wxDefaultPosition, wxSize(600,400),
292 wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) {
293
294 // intitialize important variables
295 m_edit = NULL;
296
297 // set icon and background
298 SetTitle (*g_appname);
299 SetIcon (wxICON (mondrian));
300 SetBackgroundColour (_T("WHITE"));
301
302 // about box shown for 1 seconds
303 AppAbout (this, 1000);
304
305 // create menu
306 m_menuBar = new wxMenuBar;
307 CreateMenu ();
308
309 // open first page
310 m_edit = new Edit (this, -1);
311 m_edit->SetFocus();
312
313 }
314
315 AppFrame::~AppFrame () {
316 }
317
318 // common event handlers
319 void AppFrame::OnClose (wxCloseEvent &event) {
320 wxCommandEvent evt;
321 OnFileClose (evt);
322 if (m_edit && m_edit->Modified()) {
323 if (event.CanVeto()) event.Veto (true);
324 return;
325 }
326 Destroy();
327 }
328
329 void AppFrame::OnAbout (wxCommandEvent &WXUNUSED(event)) {
330 AppAbout (this);
331 }
332
333 void AppFrame::OnExit (wxCommandEvent &WXUNUSED(event)) {
334 Close (true);
335 }
336
337 // file event handlers
338 void AppFrame::OnFileOpen (wxCommandEvent &WXUNUSED(event)) {
339 if (!m_edit) return;
340 wxString fname;
341 wxFileDialog dlg (this, _T("Open file"), _T(""), _T(""), _T("Any file (*)|*"),
342 wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR);
343 if (dlg.ShowModal() != wxID_OK) return;
344 fname = dlg.GetPath ();
345 FileOpen (fname);
346 }
347
348 void AppFrame::OnFileSave (wxCommandEvent &WXUNUSED(event)) {
349 if (!m_edit) return;
350 if (!m_edit->Modified()) {
351 wxMessageBox (_("There is nothing to save!"), _("Save file"),
352 wxOK | wxICON_EXCLAMATION);
353 return;
354 }
355 m_edit->SaveFile ();
356 }
357
358 void AppFrame::OnFileSaveAs (wxCommandEvent &WXUNUSED(event)) {
359 if (!m_edit) return;
360 wxString filename = wxEmptyString;
361 wxFileDialog dlg (this, _T("Save file"), _T(""), _T(""), _T("Any file (*)|*"), wxSAVE|wxOVERWRITE_PROMPT);
362 if (dlg.ShowModal() != wxID_OK) return;
363 filename = dlg.GetPath();
364 m_edit->SaveFile (filename);
365 }
366
367 void AppFrame::OnFileClose (wxCommandEvent &WXUNUSED(event)) {
368 if (!m_edit) return;
369 if (m_edit->Modified()) {
370 if (wxMessageBox (_("Text is not saved, save before closing?"), _("Close"),
371 wxYES_NO | wxICON_QUESTION) == wxYES) {
372 m_edit->SaveFile();
373 if (m_edit->Modified()) {
374 wxMessageBox (_("Text could not be saved!"), _("Close abort"),
375 wxOK | wxICON_EXCLAMATION);
376 return;
377 }
378 }
379 }
380 }
381
382 // properties event handlers
383 void AppFrame::OnProperties (wxCommandEvent &WXUNUSED(event)) {
384 if (!m_edit) return;
385 EditProperties (m_edit, 0);
386 }
387
388 // print event handlers
389 void AppFrame::OnPrintSetup (wxCommandEvent &WXUNUSED(event)) {
390 (*g_pageSetupData) = * g_printData;
391 wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
392 pageSetupDialog.ShowModal();
393 (*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
394 (*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
395 }
396
397 void AppFrame::OnPrintPreview (wxCommandEvent &WXUNUSED(event)) {
398 wxPrintDialogData printDialogData( *g_printData);
399 wxPrintPreview *preview =
400 new wxPrintPreview (new EditPrint (m_edit),
401 new EditPrint (m_edit),
402 &printDialogData);
403 if (!preview->Ok()) {
404 delete preview;
405 wxMessageBox (_("There was a problem with previewing.\n\
406 Perhaps your current printer is not correctly?"),
407 _("Previewing"), wxOK);
408 return;
409 }
410 wxRect rect = DeterminePrintSize();
411 wxPreviewFrame *frame = new wxPreviewFrame (preview, this, _("Print Preview"));
412 frame->SetSize (rect);
413 frame->Centre(wxBOTH);
414 frame->Initialize();
415 frame->Show(true);
416 }
417
418 void AppFrame::OnPrint (wxCommandEvent &WXUNUSED(event)) {
419 wxPrintDialogData printDialogData( *g_printData);
420 wxPrinter printer (&printDialogData);
421 EditPrint printout (m_edit);
422 if (!printer.Print (this, &printout, true)) {
423 if (wxPrinter::GetLastError() == wxPRINTER_ERROR) {
424 wxMessageBox (_("There was a problem with printing.\n\
425 Perhaps your current printer is not correctly?"),
426 _("Previewing"), wxOK);
427 return;
428 }
429 }
430 (*g_printData) = printer.GetPrintDialogData().GetPrintData();
431 }
432
433 // edit events
434 void AppFrame::OnEdit (wxCommandEvent &event) {
435 if (m_edit) m_edit->ProcessEvent (event);
436 }
437
438 // private functions
439 void AppFrame::CreateMenu () {
440
441 // File menu
442 wxMenu *menuFile = new wxMenu;
443 menuFile->Append (wxID_OPEN, _("&Open ..\tCtrl+O"));
444 menuFile->Append (wxID_SAVE, _("&Save\tCtrl+S"));
445 menuFile->Append (wxID_SAVEAS, _("Save &as ..\tCtrl+Shift+S"));
446 menuFile->Append (wxID_CLOSE, _("&Close\tCtrl+W"));
447 menuFile->AppendSeparator();
448 menuFile->Append (myID_PROPERTIES, _("Proper&ties ..\tCtrl+I"));
449 menuFile->AppendSeparator();
450 menuFile->Append (wxID_PRINT_SETUP, _("Print Set&up .."));
451 menuFile->Append (wxID_PREVIEW, _("Print Pre&view\tCtrl+Shift+P"));
452 menuFile->Append (wxID_PRINT, _("&Print ..\tCtrl+P"));
453 menuFile->AppendSeparator();
454 menuFile->Append (wxID_EXIT, _("&Quit\tCtrl+Q"));
455
456 // Edit menu
457 wxMenu *menuEdit = new wxMenu;
458 menuEdit->Append (wxID_UNDO, _("&Undo\tCtrl+Z"));
459 menuEdit->Append (wxID_REDO, _("&Redo\tCtrl+Shift+Z"));
460 menuEdit->AppendSeparator();
461 menuEdit->Append (wxID_CUT, _("Cu&t\tCtrl+X"));
462 menuEdit->Append (wxID_COPY, _("&Copy\tCtrl+C"));
463 menuEdit->Append (wxID_PASTE, _("&Paste\tCtrl+V"));
464 menuEdit->Append (wxID_CLEAR, _("&Delete\tDel"));
465 menuEdit->AppendSeparator();
466 menuEdit->Append (wxID_FIND, _("&Find\tCtrl+F"));
467 menuEdit->Enable (wxID_FIND, false);
468 menuEdit->Append (myID_FINDNEXT, _("Find &next\tF3"));
469 menuEdit->Enable (myID_FINDNEXT, false);
470 menuEdit->Append (myID_REPLACE, _("&Replace\tCtrl+H"));
471 menuEdit->Enable (myID_REPLACE, false);
472 menuEdit->Append (myID_REPLACENEXT, _("Replace &again\tShift+F4"));
473 menuEdit->Enable (myID_REPLACENEXT, false);
474 menuEdit->AppendSeparator();
475 menuEdit->Append (myID_BRACEMATCH, _("&Match brace\tCtrl+M"));
476 menuEdit->Append (myID_GOTO, _("&Goto\tCtrl+G"));
477 menuEdit->Enable (myID_GOTO, false);
478 menuEdit->AppendSeparator();
479 menuEdit->Append (myID_INDENTINC, _("&Indent increase\tTab"));
480 menuEdit->Append (myID_INDENTRED, _("I&ndent reduce\tBksp"));
481 menuEdit->AppendSeparator();
482 menuEdit->Append (wxID_SELECTALL, _("&Select all\tCtrl+A"));
483 menuEdit->Append (myID_SELECTLINE, _("Select &line\tCtrl+L"));
484
485 // hilight submenu
486 wxMenu *menuHilight = new wxMenu;
487 int Nr;
488 for (Nr = 0; Nr < g_LanguagePrefsSize; Nr++) {
489 menuHilight->Append (myID_HILIGHTFIRST + Nr,
490 g_LanguagePrefs [Nr].name);
491 }
492
493 // charset submenu
494 wxMenu *menuCharset = new wxMenu;
495 menuCharset->Append (myID_CHARSETANSI, _("&ANSI (Windows)"));
496 menuCharset->Append (myID_CHARSETMAC, _("&MAC (Macintosh)"));
497
498 // View menu
499 wxMenu *menuView = new wxMenu;
500 menuView->Append (myID_HILIGHTLANG, _("&Hilight language .."), menuHilight);
501 menuView->AppendSeparator();
502 menuView->AppendCheckItem (myID_FOLDTOGGLE, _("&Toggle current fold\tCtrl+T"));
503 menuView->AppendCheckItem (myID_OVERTYPE, _("&Overwrite mode\tIns"));
504 menuView->AppendCheckItem (myID_WRAPMODEON, _("&Wrap mode\tCtrl+U"));
505 menuView->AppendSeparator();
506 menuView->AppendCheckItem (myID_DISPLAYEOL, _("Show line &endings"));
507 menuView->AppendCheckItem (myID_INDENTGUIDE, _("Show &indent guides"));
508 menuView->AppendCheckItem (myID_LINENUMBER, _("Show line &numbers"));
509 menuView->AppendCheckItem (myID_LONGLINEON, _("Show &long line marker"));
510 menuView->AppendCheckItem (myID_WHITESPACE, _("Show white&space"));
511 menuView->AppendSeparator();
512 menuView->Append (myID_USECHARSET, _("Use &code page of .."), menuCharset);
513
514 // change case submenu
515 wxMenu *menuChangeCase = new wxMenu;
516 menuChangeCase->Append (myID_CHANGEUPPER, _("&Upper case"));
517 menuChangeCase->Append (myID_CHANGELOWER, _("&Lower case"));
518
519 // convert EOL submenu
520 wxMenu *menuConvertEOL = new wxMenu;
521 menuConvertEOL->Append (myID_CONVERTCR, _("CR (&Linux)"));
522 menuConvertEOL->Append (myID_CONVERTCRLF, _("CR+LF (&Windows)"));
523 menuConvertEOL->Append (myID_CONVERTLF, _("LF (&Macintosh)"));
524
525 // Extra menu
526 wxMenu *menuExtra = new wxMenu;
527 menuExtra->AppendCheckItem (myID_READONLY, _("&Readonly mode"));
528 menuExtra->AppendSeparator();
529 menuExtra->Append (myID_CHANGECASE, _("Change &case to .."), menuChangeCase);
530 menuExtra->AppendSeparator();
531 menuExtra->Append (myID_CONVERTEOL, _("Convert line &endings to .."), menuConvertEOL);
532
533 // Window menu
534 wxMenu *menuWindow = new wxMenu;
535 menuWindow->Append (myID_PAGEPREV, _("&Previous\tCtrl+Shift+Tab"));
536 menuWindow->Append (myID_PAGENEXT, _("&Next\tCtrl+Tab"));
537
538 // Help menu
539 wxMenu *menuHelp = new wxMenu;
540 menuHelp->Append (wxID_ABOUT, _("&About ..\tShift+F1"));
541
542 // construct menu
543 m_menuBar->Append (menuFile, _("&File"));
544 m_menuBar->Append (menuEdit, _("&Edit"));
545 m_menuBar->Append (menuView, _("&View"));
546 m_menuBar->Append (menuExtra, _("E&xtra"));
547 m_menuBar->Append (menuWindow, _("&Window"));
548 m_menuBar->Append (menuHelp, _("&Help"));
549 SetMenuBar (m_menuBar);
550
551 }
552
553 void AppFrame::FileOpen (wxString fname) {
554 wxFileName w(fname); w.Normalize(); fname = w.GetFullPath();
555 m_edit->LoadFile (fname);
556 }
557
558 wxRect AppFrame::DeterminePrintSize () {
559
560 wxSize scr = wxGetDisplaySize();
561
562 // determine position and size (shifting 16 left and down)
563 wxRect rect = GetRect();
564 rect.x += 16;
565 rect.y += 16;
566 rect.width = wxMin (rect.width, (scr.x - rect.x));
567 rect.height = wxMin (rect.height, (scr.x - rect.y));
568
569 return rect;
570 }
571
572
573 //----------------------------------------------------------------------------
574 // AppAbout
575 //----------------------------------------------------------------------------
576
577 BEGIN_EVENT_TABLE (AppAbout, wxDialog)
578 EVT_TIMER (myID_ABOUTTIMER, AppAbout::OnTimerEvent)
579 END_EVENT_TABLE ()
580
581 AppAbout::AppAbout (wxWindow *parent,
582 int milliseconds,
583 long style)
584 : wxDialog (parent, -1, wxEmptyString,
585 wxDefaultPosition, wxDefaultSize,
586 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
587
588 // set timer if any
589 m_timer = NULL;
590 if (milliseconds > 0) {
591 m_timer = new wxTimer (this, myID_ABOUTTIMER);
592 m_timer->Start (milliseconds, wxTIMER_ONE_SHOT);
593 }
594
595 // sets the application title
596 SetTitle (_("About .."));
597
598 // about info
599 wxGridSizer *aboutinfo = new wxGridSizer (2, 0, 2);
600 aboutinfo->Add (new wxStaticText(this, -1, _("Written by: ")),
601 0, wxALIGN_LEFT);
602 aboutinfo->Add (new wxStaticText(this, -1, APP_MAINT),
603 1, wxEXPAND | wxALIGN_LEFT);
604 aboutinfo->Add (new wxStaticText(this, -1, _("Version: ")),
605 0, wxALIGN_LEFT);
606 aboutinfo->Add (new wxStaticText(this, -1, APP_VERSION),
607 1, wxEXPAND | wxALIGN_LEFT);
608 aboutinfo->Add (new wxStaticText(this, -1, _("Licence type: ")),
609 0, wxALIGN_LEFT);
610 aboutinfo->Add (new wxStaticText(this, -1, APP_LICENCE),
611 1, wxEXPAND | wxALIGN_LEFT);
612 aboutinfo->Add (new wxStaticText(this, -1, _("Copyright: ")),
613 0, wxALIGN_LEFT);
614 aboutinfo->Add (new wxStaticText(this, -1, APP_COPYRIGTH),
615 1, wxEXPAND | wxALIGN_LEFT);
616
617 // about icontitle//info
618 wxBoxSizer *aboutpane = new wxBoxSizer (wxHORIZONTAL);
619 wxBitmap bitmap = wxBitmap(wxICON (mondrian));
620 aboutpane->Add (new wxStaticBitmap (this, -1, bitmap),
621 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 20);
622 aboutpane->Add (aboutinfo, 1, wxEXPAND);
623 aboutpane->Add (60, 0);
624
625 // about complete
626 wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL);
627 totalpane->Add (0, 20);
628 wxStaticText *appname = new wxStaticText(this, -1, *g_appname);
629 appname->SetFont (wxFont (24, wxDEFAULT, wxNORMAL, wxBOLD));
630 totalpane->Add (appname, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 40);
631 totalpane->Add (0, 10);
632 totalpane->Add (aboutpane, 0, wxEXPAND | wxALL, 4);
633 totalpane->Add (new wxStaticText(this, -1, APP_DESCR),
634 0, wxALIGN_CENTER | wxALL, 10);
635 wxButton *okButton = new wxButton (this, wxID_OK, _("OK"));
636 okButton->SetDefault();
637 totalpane->Add (okButton, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
638
639 SetSizerAndFit (totalpane);
640
641 CenterOnScreen();
642 ShowModal();
643 }
644
645 AppAbout::~AppAbout () {
646 if (m_timer) {
647 delete m_timer;
648 m_timer = NULL;
649 }
650 }
651
652 //----------------------------------------------------------------------------
653 // event handlers
654 void AppAbout::OnTimerEvent (wxTimerEvent &event) {
655 if (m_timer) delete m_timer;
656 m_timer = NULL;
657 EndModal (wxID_OK);
658 }
659