]> git.saurik.com Git - wxWidgets.git/blame - samples/font/font.cpp
Added a flag to avoid Capture/Release asserts
[wxWidgets.git] / samples / font / font.cpp
CommitLineData
1ccd74da
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: font.cpp
3// Purpose: wxFont demo
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 30.09.99
7// RCS-ID: $Id$
36f210c8 8// Copyright: (c) 1999 Vadim Zeitlin
1ccd74da
VZ
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx/wx.h".
13#include <wx/wxprec.h>
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19// for all others, include the necessary headers (this file is usually all you
20// need because it includes almost all <standard< wxWindows headers
21#ifndef WX_PRECOMP
22 #include <wx/wx.h>
23
24 #include <wx/log.h>
25#endif
26
36f210c8 27#include <wx/choicdlg.h>
1ccd74da 28#include <wx/fontdlg.h>
ddc8c2e3 29#include <wx/fontenum.h>
3c1866e8 30#include <wx/fontmap.h>
7337790c 31#include <wx/encconv.h>
3c1866e8 32#include <wx/textfile.h>
1ccd74da
VZ
33
34// ----------------------------------------------------------------------------
35// private classes
36// ----------------------------------------------------------------------------
37
38// Define a new application type, each program should derive a class from wxApp
39class MyApp : public wxApp
40{
41public:
42 // override base class virtuals
43 // ----------------------------
44
45 // this one is called on application startup and is a good place for the app
46 // initialization (doing it here and not in the ctor allows to have an error
47 // return: if OnInit() returns false, the application terminates)
48 virtual bool OnInit();
49};
50
51// MyCanvas is a canvas on which we show the font sample
52class MyCanvas: public wxWindow
53{
54public:
55 MyCanvas( wxWindow *parent );
56 ~MyCanvas();
57
58 // accessors for the frame
59 const wxFont& GetTextFont() const { return m_font; }
60 const wxColour& GetColour() const { return m_colour; }
61 void SetTextFont(const wxFont& font) { m_font = font; }
62 void SetColour(const wxColour& colour) { m_colour = colour; }
63
64 // event handlers
65 void OnPaint( wxPaintEvent &event );
66
67private:
68 wxColour m_colour;
69 wxFont m_font;
70
71 DECLARE_EVENT_TABLE()
72};
73
74// Define a new frame type: this is going to be our main frame
75class MyFrame : public wxFrame
76{
77public:
78 // ctor(s)
79 MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
80
81 // accessors
82 MyCanvas *GetCanvas() const { return m_canvas; }
83
84 // event handlers (these functions should _not_ be virtual)
85 void OnQuit(wxCommandEvent& event);
86 void OnAbout(wxCommandEvent& event);
f6bcfd97
BP
87 void OnIncFont(wxCommandEvent& event) { DoResizeFont(+2); }
88 void OnDecFont(wxCommandEvent& event) { DoResizeFont(-2); }
89
3c1866e8 90 void OnViewMsg(wxCommandEvent& event);
1ccd74da 91 void OnSelectFont(wxCommandEvent& event);
36f210c8 92 void OnEnumerateFamiliesForEncoding(wxCommandEvent& event);
ddc8c2e3
VZ
93 void OnEnumerateFamilies(wxCommandEvent& WXUNUSED(event))
94 { DoEnumerateFamilies(FALSE); }
95 void OnEnumerateFixedFamilies(wxCommandEvent& WXUNUSED(event))
96 { DoEnumerateFamilies(TRUE); }
d111a89a 97 void OnEnumerateEncodings(wxCommandEvent& event);
1ccd74da 98
36f210c8
VZ
99 void OnSize(wxSizeEvent& event);
100
1ccd74da 101protected:
7beba2fc
VZ
102 bool DoEnumerateFamilies(bool fixedWidthOnly,
103 wxFontEncoding encoding = wxFONTENCODING_SYSTEM,
104 bool silent = FALSE);
36f210c8 105
f6bcfd97 106 void DoResizeFont(int diff);
a1d58ddc
VZ
107 void DoChangeFont(const wxFont& font, const wxColour& col = wxNullColour);
108
36f210c8 109 void Resize(const wxSize& size, const wxFont& font = wxNullFont);
ddc8c2e3 110
f6bcfd97
BP
111 size_t m_fontSize; // in points
112
36f210c8
VZ
113 wxTextCtrl *m_textctrl;
114 MyCanvas *m_canvas;
1ccd74da
VZ
115
116private:
117 // any class wishing to process wxWindows events must use this macro
118 DECLARE_EVENT_TABLE()
119};
120
1ccd74da
VZ
121// ----------------------------------------------------------------------------
122// constants
123// ----------------------------------------------------------------------------
124
125// IDs for the controls and the menu commands
126enum
127{
128 // menu items
129 Font_Quit = 1,
130 Font_About,
3c1866e8 131 Font_ViewMsg,
f6bcfd97
BP
132 Font_IncSize,
133 Font_DecSize,
1ccd74da 134 Font_Choose = 100,
36f210c8 135 Font_EnumFamiliesForEncoding,
ddc8c2e3
VZ
136 Font_EnumFamilies,
137 Font_EnumFixedFamilies,
d111a89a 138 Font_EnumEncodings,
ddc8c2e3 139 Font_Max
1ccd74da
VZ
140};
141
142// ----------------------------------------------------------------------------
143// event tables and other macros for wxWindows
144// ----------------------------------------------------------------------------
145
146// the event tables connect the wxWindows events with the functions (event
147// handlers) which process them. It can be also done at run-time, but for the
148// simple menu events like this the static method is much simpler.
149BEGIN_EVENT_TABLE(MyFrame, wxFrame)
150 EVT_MENU(Font_Quit, MyFrame::OnQuit)
151 EVT_MENU(Font_About, MyFrame::OnAbout)
f6bcfd97
BP
152 EVT_MENU(Font_IncSize, MyFrame::OnIncFont)
153 EVT_MENU(Font_DecSize, MyFrame::OnDecFont)
3c1866e8 154 EVT_MENU(Font_ViewMsg, MyFrame::OnViewMsg)
1ccd74da 155 EVT_MENU(Font_Choose, MyFrame::OnSelectFont)
36f210c8 156 EVT_MENU(Font_EnumFamiliesForEncoding, MyFrame::OnEnumerateFamiliesForEncoding)
ddc8c2e3
VZ
157 EVT_MENU(Font_EnumFamilies, MyFrame::OnEnumerateFamilies)
158 EVT_MENU(Font_EnumFixedFamilies, MyFrame::OnEnumerateFixedFamilies)
d111a89a 159 EVT_MENU(Font_EnumEncodings, MyFrame::OnEnumerateEncodings)
36f210c8
VZ
160
161 EVT_SIZE(MyFrame::OnSize)
1ccd74da
VZ
162END_EVENT_TABLE()
163
164// Create a new application object: this macro will allow wxWindows to create
165// the application object during program execution (it's better than using a
166// static object for many reasons) and also declares the accessor function
167// wxGetApp() which will return the reference of the right type (i.e. MyApp and
168// not wxApp)
169IMPLEMENT_APP(MyApp)
170
171// ============================================================================
172// implementation
173// ============================================================================
174
175// ----------------------------------------------------------------------------
176// the application class
177// ----------------------------------------------------------------------------
178
179// `Main program' equivalent: the program execution "starts" here
180bool MyApp::OnInit()
181{
182 // Create the main application window
ddc8c2e3 183 MyFrame *frame = new MyFrame("Font wxWindows demo",
1ccd74da
VZ
184 wxPoint(50, 50), wxSize(450, 340));
185
186 // Show it and tell the application that it's our main window
187 frame->Show(TRUE);
188 SetTopWindow(frame);
189
190 // success: wxApp::OnRun() will be called which will enter the main message
191 // loop and the application will run. If we returned FALSE here, the
192 // application would exit immediately.
193 return TRUE;
194}
195
196// ----------------------------------------------------------------------------
197// main frame
198// ----------------------------------------------------------------------------
199
200// frame constructor
201MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
a1d58ddc 202 : wxFrame((wxFrame *)NULL, -1, title, pos, size), m_textctrl(NULL)
1ccd74da 203{
f6bcfd97
BP
204 m_fontSize = 12;
205
1ccd74da
VZ
206 // create a menu bar
207 wxMenu *menuFile = new wxMenu;
208
3c1866e8
VZ
209 menuFile->Append(Font_ViewMsg, "&View...\tCtrl-V",
210 "View an email message file");
211 menuFile->AppendSeparator();
1ccd74da
VZ
212 menuFile->Append(Font_About, "&About...\tCtrl-A", "Show about dialog");
213 menuFile->AppendSeparator();
214 menuFile->Append(Font_Quit, "E&xit\tAlt-X", "Quit this program");
215
216 wxMenu *menuFont = new wxMenu;
f6bcfd97
BP
217 menuFont->Append(Font_IncSize, "&Increase font size by 2 points\tCtrl-I");
218 menuFont->Append(Font_DecSize, "&Decrease font size by 2 points\tCtrl-D");
219 menuFont->AppendSeparator();
ddc8c2e3 220 menuFont->Append(Font_Choose, "&Select font...\tCtrl-S",
1ccd74da 221 "Select a standard font");
ddc8c2e3 222 menuFont->AppendSeparator();
d111a89a 223 menuFont->Append(Font_EnumFamilies, "Enumerate font &families\tCtrl-F");
ddc8c2e3 224 menuFont->Append(Font_EnumFixedFamilies,
f6bcfd97 225 "Enumerate fi&xed font families\tCtrl-X");
d111a89a
VZ
226 menuFont->Append(Font_EnumEncodings,
227 "Enumerate &encodings\tCtrl-E");
36f210c8
VZ
228 menuFont->Append(Font_EnumFamiliesForEncoding,
229 "Find font for en&coding...\tCtrl-C",
230 "Find font families for given encoding");
1ccd74da
VZ
231
232 // now append the freshly created menu to the menu bar...
233 wxMenuBar *menuBar = new wxMenuBar;
234 menuBar->Append(menuFile, "&File");
235 menuBar->Append(menuFont, "F&ont");
236
237 // ... and attach this menu bar to the frame
238 SetMenuBar(menuBar);
239
36f210c8
VZ
240 m_textctrl = new wxTextCtrl(this, -1,
241 "Paste text here to see how it looks\n"
242 "like in the given font",
243 wxDefaultPosition, wxDefaultSize,
244 wxTE_MULTILINE);
245
1ccd74da
VZ
246 m_canvas = new MyCanvas(this);
247
248 // create a status bar just for fun (by default with 1 pane only)
a1d58ddc
VZ
249 CreateStatusBar();
250 SetStatusText("Welcome to wxWindows font demo!");
1ccd74da
VZ
251}
252
e680a378 253// --------------------------------------------------------
1ccd74da 254
e680a378 255class MyEncodingEnumerator : public wxFontEnumerator
d111a89a 256{
e680a378
RR
257public:
258 MyEncodingEnumerator()
259 { m_n = 0; }
d111a89a 260
e680a378
RR
261 const wxString& GetText() const
262 { return m_text; }
d111a89a 263
e680a378
RR
264protected:
265 virtual bool OnFontEncoding(const wxString& facename,
266 const wxString& encoding)
267 {
268 wxString text;
269 text.Printf("Encoding %d: %s (available in facename '%s')\n",
270 ++m_n, encoding.c_str(), facename.c_str());
271 m_text += text;
272 return TRUE;
273 }
d111a89a 274
e680a378
RR
275private:
276 size_t m_n;
277 wxString m_text;
278};
d111a89a 279
e680a378
RR
280void MyFrame::OnEnumerateEncodings(wxCommandEvent& WXUNUSED(event))
281{
282 MyEncodingEnumerator fontEnumerator;
d111a89a
VZ
283
284 fontEnumerator.EnumerateEncodings();
285
286 wxLogMessage("Enumerating all available encodings:\n%s",
287 fontEnumerator.GetText().c_str());
288}
1ccd74da 289
e680a378 290// -------------------------------------------------------------
36f210c8 291
e680a378
RR
292class MyFontEnumerator : public wxFontEnumerator
293{
294public:
295 bool GotAny() const
296 { return !m_facenames.IsEmpty(); }
d111a89a 297
e680a378
RR
298 const wxArrayString& GetFacenames() const
299 { return m_facenames; }
ddc8c2e3 300
e680a378
RR
301protected:
302 virtual bool OnFacename(const wxString& facename)
303 {
304 m_facenames.Add(facename);
305 return TRUE;
306 }
ddc8c2e3
VZ
307
308 private:
a1d58ddc 309 wxArrayString m_facenames;
e680a378
RR
310} fontEnumerator;
311
312bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly,
313 wxFontEncoding encoding,
314 bool silent)
315{
316 MyFontEnumerator fontEnumerator;
ddc8c2e3 317
3c1866e8 318 fontEnumerator.EnumerateFacenames(encoding, fixedWidthOnly);
d111a89a 319
36f210c8
VZ
320 if ( fontEnumerator.GotAny() )
321 {
ea9144a3
VZ
322 int nFacenames = fontEnumerator.GetFacenames().GetCount();
323 if ( !silent )
324 {
325 wxLogStatus(this, "Found %d %sfonts",
326 nFacenames, fixedWidthOnly ? "fixed width " : "");
327 }
a1d58ddc 328
ea9144a3 329 wxString facename;
7beba2fc 330 if ( silent )
ea9144a3
VZ
331 {
332 // choose the first
333 facename = fontEnumerator.GetFacenames().Item(0);
334 }
7beba2fc 335 else
ea9144a3
VZ
336 {
337 // let the user choose
338 wxString *facenames = new wxString[nFacenames];
339 int n;
340 for ( n = 0; n < nFacenames; n++ )
341 facenames[n] = fontEnumerator.GetFacenames().Item(n);
342
7beba2fc
VZ
343 n = wxGetSingleChoiceIndex("Choose a facename", "Font demo",
344 nFacenames, facenames, this);
ea9144a3
VZ
345
346 if ( n != -1 )
347 facename = facenames[n];
348
349 delete [] facenames;
350 }
351
352 if ( !facename.IsEmpty() )
a1d58ddc 353 {
ea9144a3
VZ
354 wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
355 wxFONTWEIGHT_NORMAL, FALSE, facename, encoding);
a1d58ddc
VZ
356
357 DoChangeFont(font);
358 }
359
7beba2fc 360 return TRUE;
36f210c8 361 }
7beba2fc 362 else if ( !silent )
36f210c8
VZ
363 {
364 wxLogWarning("No such fonts found.");
365 }
7beba2fc
VZ
366
367 return FALSE;
ddc8c2e3
VZ
368}
369
36f210c8 370void MyFrame::OnEnumerateFamiliesForEncoding(wxCommandEvent& WXUNUSED(event))
1ccd74da 371{
36f210c8
VZ
372 static wxFontEncoding encodings[] =
373 {
374 wxFONTENCODING_ISO8859_1,
375 wxFONTENCODING_ISO8859_2,
376 wxFONTENCODING_ISO8859_5,
377 wxFONTENCODING_ISO8859_7,
378 wxFONTENCODING_ISO8859_15,
379 wxFONTENCODING_KOI8,
380 wxFONTENCODING_CP1250,
381 wxFONTENCODING_CP1251,
382 wxFONTENCODING_CP1252,
383 };
384
385 static const char *encodingNames[] =
386 {
387 "West European (Latin 1)",
388 "Central European (Latin 2)",
389 "Cyrillic (Latin 5)",
390 "Greek (Latin 7)",
391 "West European new (Latin 0)",
392 "KOI8-R",
393 "Windows Latin 2",
394 "Windows Cyrillic",
395 "Windows Latin 1",
396 };
397
398 int n = wxGetSingleChoiceIndex("Choose an encoding", "Font demo",
a1d58ddc
VZ
399 WXSIZEOF(encodingNames),
400 (char **)encodingNames,
36f210c8
VZ
401 this);
402
403 if ( n != -1 )
404 {
405 DoEnumerateFamilies(FALSE, encodings[n]);
406 }
1ccd74da
VZ
407}
408
f6bcfd97
BP
409void MyFrame::DoResizeFont(int diff)
410{
411 wxFont fontOld = m_canvas->GetTextFont();
412
413 DoChangeFont(
414 wxFont(
415 fontOld.GetPointSize() + diff,
416 fontOld.GetFamily(),
417 fontOld.GetStyle(),
418 fontOld.GetWeight(),
419 fontOld.GetUnderlined(),
420 fontOld.GetFaceName(),
421 fontOld.GetEncoding()
422 )
423 );
424}
425
a1d58ddc
VZ
426void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
427{
428 Resize(GetSize(), font);
429
430 m_canvas->SetTextFont(font);
431 if ( col.Ok() )
432 m_canvas->SetColour(col);
433 m_canvas->Refresh();
434
435 m_textctrl->SetFont(font);
436 if ( col.Ok() )
437 m_textctrl->SetForegroundColour(col);
438}
439
1ccd74da
VZ
440void MyFrame::OnSelectFont(wxCommandEvent& WXUNUSED(event))
441{
442 wxFontData data;
443 data.SetInitialFont(m_canvas->GetTextFont());
444 data.SetColour(m_canvas->GetColour());
445
446 wxFontDialog dialog(this, &data);
447 if ( dialog.ShowModal() == wxID_OK )
448 {
449 wxFontData retData = dialog.GetFontData();
36f210c8
VZ
450 wxFont font = retData.GetChosenFont();
451 wxColour colour = retData.GetColour();
452
a1d58ddc 453 DoChangeFont(font, colour);
1ccd74da
VZ
454 }
455}
456
457void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
458{
459 // TRUE is to force the frame to close
460 Close(TRUE);
461}
462
3c1866e8
VZ
463void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event))
464{
465 // first, choose the file
466 static wxString s_dir, s_file;
467 wxFileDialog dialog(this, "Open an email message file",
468 s_dir, s_file);
469 if ( dialog.ShowModal() != wxID_OK )
470 return;
471
472 // save for the next time
473 s_dir = dialog.GetDirectory();
474 s_file = dialog.GetFilename();
475
476 wxString filename = dialog.GetPath();
477
478 // load it and search for Content-Type header
479 wxTextFile file(filename);
480 if ( !file.Open() )
481 return;
482
483 wxString charset;
484
485 static const char *prefix = "Content-Type: text/plain; charset=";
486 const size_t len = strlen(prefix);
487
488 size_t n, count = file.GetLineCount();
489 for ( n = 0; n < count; n++ )
490 {
491 wxString line = file[n];
492
493 if ( !line )
494 {
495 // if it is an email message, headers are over, no need to parse
496 // all the file
497 break;
498 }
499
500 if ( line.Left(len) == prefix )
501 {
502 // found!
503 const char *pc = line.c_str() + len;
504 if ( *pc == '"' )
505 pc++;
506
507 while ( *pc && *pc != '"' )
508 {
509 charset += *pc++;
510 }
511
512 break;
513 }
514 }
515
516 if ( !charset )
517 {
518 wxLogError("The file '%s' doesn't contain charset information.",
519 filename.c_str());
520
521 return;
522 }
523
524 // ok, now get the corresponding encoding
7beba2fc 525 wxFontEncoding fontenc = wxTheFontMapper->CharsetToEncoding(charset);
3c1866e8
VZ
526 if ( fontenc == wxFONTENCODING_SYSTEM )
527 {
528 wxLogError("Charset '%s' is unsupported.", charset.c_str());
529 return;
530 }
531
7337790c
VS
532 m_textctrl->LoadFile(filename);
533
534 if (!wxTheFontMapper->IsEncodingAvailable(fontenc))
535 {
536 // try to find some similar encoding:
3e2dd3db
VZ
537 wxFontEncoding encAlt;
538 if ( wxTheFontMapper->GetAltForEncoding(fontenc, &encAlt) )
7337790c
VS
539 {
540 wxEncodingConverter conv;
541
3e2dd3db 542 if (conv.Init(fontenc, encAlt))
7337790c 543 {
3e2dd3db 544 fontenc = encAlt;
7337790c
VS
545 m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue()));
546 }
547 else
3e2dd3db 548 {
7337790c
VS
549 wxLogWarning("Cannot convert from '%s' to '%s'.",
550 wxFontMapper::GetEncodingDescription(fontenc).c_str(),
3e2dd3db
VZ
551 wxFontMapper::GetEncodingDescription(encAlt).c_str());
552 }
7337790c
VS
553 }
554 else
555 wxLogWarning("No fonts for encoding '%s' on this system.",
556 wxFontMapper::GetEncodingDescription(fontenc).c_str());
557 }
558
3c1866e8 559 // and now create the correct font
7beba2fc
VZ
560 if ( !DoEnumerateFamilies(FALSE, fontenc, TRUE /* silent */) )
561 {
ea9144a3 562 wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
7beba2fc
VZ
563 wxFONTWEIGHT_NORMAL, FALSE /* !underlined */,
564 wxEmptyString /* facename */, fontenc);
565 if ( font.Ok() )
566 {
567 DoChangeFont(font);
568 }
569 else
570 {
571 wxLogWarning("No fonts for encoding '%s' on this system.",
572 wxFontMapper::GetEncodingDescription(fontenc).c_str());
573 }
574 }
3c1866e8
VZ
575}
576
1ccd74da
VZ
577void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
578{
36f210c8
VZ
579 wxMessageBox("wxWindows font demo\n"
580 "(c) 1999 Vadim Zeitlin",
581 "About Font",
1ccd74da
VZ
582 wxOK | wxICON_INFORMATION, this);
583}
584
36f210c8
VZ
585void MyFrame::OnSize(wxSizeEvent& event)
586{
587 wxSize size = event.GetSize();
588
589 Resize(size);
717a57c2
VZ
590
591 event.Skip();
36f210c8
VZ
592}
593
594void MyFrame::Resize(const wxSize& size, const wxFont& font)
595{
a1d58ddc
VZ
596 if ( !m_textctrl )
597 return;
598
36f210c8
VZ
599 wxCoord h;
600 if ( font.Ok() )
601 {
602 wxClientDC dc(this);
603 dc.SetFont(font);
604
3c1866e8 605 h = 10*(dc.GetCharHeight() + 1);
36f210c8
VZ
606 }
607 else
608 {
609 h = m_textctrl->GetSize().y;
610 }
611
612 m_textctrl->SetSize(0, 0, size.x, h);
613 m_canvas->SetSize(0, h, size.x, size.y - h);
614}
1ccd74da
VZ
615
616// ----------------------------------------------------------------------------
617// MyCanvas
618// ----------------------------------------------------------------------------
619
620BEGIN_EVENT_TABLE(MyCanvas, wxWindow)
621 EVT_PAINT(MyCanvas::OnPaint)
622END_EVENT_TABLE()
623
624MyCanvas::MyCanvas( wxWindow *parent )
11c7d5b6
VZ
625 : wxWindow( parent, -1 ),
626 m_colour(*wxRED), m_font(*wxNORMAL_FONT)
1ccd74da 627{
1ccd74da
VZ
628}
629
630MyCanvas::~MyCanvas()
631{
632}
633
634void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
635{
636 wxPaintDC dc(this);
637 PrepareDC(dc);
638
639 // set background
640 dc.SetBackground(wxBrush("white", wxSOLID));
641 dc.Clear();
642
643 // output the font name/info
644 wxString fontInfo;
f6bcfd97
BP
645 fontInfo.Printf("Font size is %d points, family is %s, style %s, weight %s",
646 m_font.GetPointSize(),
1ccd74da
VZ
647 m_font.GetFamilyString().c_str(),
648 m_font.GetStyleString().c_str(),
649 m_font.GetWeightString().c_str());
650
651 dc.DrawText(fontInfo, 5, 5);
652
653 // prepare to draw the font
654 dc.SetFont(m_font);
655 dc.SetTextForeground(m_colour);
656
657 // the size of one cell (char + small margin)
658 int w = dc.GetCharWidth() + 5,
659 h = dc.GetCharHeight() + 4;
660
661 // the origin for our table
662 int x = 5,
36f210c8 663 y = 2*h;
1ccd74da
VZ
664
665 // print all font symbols from 32 to 256 in 7 rows of 32 chars each
666 for ( int i = 1; i < 8; i++ )
667 {
668 for ( int j = 0; j < 32; j++ )
669 {
670 dc.DrawText(char(32*i + j), x + w*j, y + h*i);
671 }
672 }
673
674 // draw the lines between them
675 dc.SetPen(wxPen(wxColour("blue"), 1, wxSOLID));
676 int l;
677
678 // horizontal
679 y += h;
680 for ( l = 0; l < 8; l++ )
681 {
682 int yl = y + h*l - 2;
683 dc.DrawLine(x - 2, yl, x + 32*w - 2, yl);
684 }
685
686 // and vertical
687 for ( l = 0; l < 33; l++ )
688 {
689 int xl = x + w*l - 2;
690 dc.DrawLine(xl, y, xl, y + 7*h - 2);
691 }
692}