X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c6b729603574178f21453728c0db4ea3e5c6a777..fec34ef52dad898e72dd488f939ea0db5ec09ead:/samples/font/font.cpp diff --git a/samples/font/font.cpp b/samples/font/font.cpp index 316878bdfb..f6c8d5f32d 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -36,11 +36,11 @@ #ifdef __WXMAC__ #undef wxFontDialog - #include "wx/mac/fontdlg.h" + #include "wx/osx/fontdlg.h" #endif // used as title for several dialog boxes -static const wxChar SAMPLE_TITLE[] = "wxWidgets Font Sample"; +static const wxChar SAMPLE_TITLE[] = _T("wxWidgets Font Sample"); // ---------------------------------------------------------------------------- // private classes @@ -105,6 +105,7 @@ public: void OnwxPointerFont(wxCommandEvent& event); + void OnTestTextValue(wxCommandEvent& event); void OnViewMsg(wxCommandEvent& event); void OnSelectFont(wxCommandEvent& event); void OnEnumerateFamiliesForEncoding(wxCommandEvent& event); @@ -153,6 +154,8 @@ enum Font_Quit = 1, Font_About, Font_ViewMsg, + Font_TestTextValue, + Font_IncSize, Font_DecSize, Font_Bold, @@ -185,6 +188,7 @@ enum // simple menu events like this the static method is much simpler. BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Font_Quit, MyFrame::OnQuit) + EVT_MENU(Font_TestTextValue, MyFrame::OnTestTextValue) EVT_MENU(Font_ViewMsg, MyFrame::OnViewMsg) EVT_MENU(Font_About, MyFrame::OnAbout) @@ -230,6 +234,9 @@ IMPLEMENT_APP(MyApp) // `Main program' equivalent: the program execution "starts" here bool MyApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + // Create the main application window MyFrame *frame = new MyFrame(wxT("Font wxWidgets demo"), wxPoint(50, 50), wxSize(600, 400)); @@ -252,13 +259,15 @@ bool MyApp::OnInit() MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size), m_textctrl(NULL) { - m_fontSize = 12; + m_fontSize = wxNORMAL_FONT->GetPointSize(); SetIcon(wxIcon(sample_xpm)); // create a menu bar wxMenu *menuFile = new wxMenu; + menuFile->Append(Font_TestTextValue, wxT("&Test text value"), + wxT("Verify that getting and setting text value doesn't change it")); menuFile->Append(Font_ViewMsg, wxT("&View...\tCtrl-V"), wxT("View an email message file")); menuFile->AppendSeparator(); @@ -439,7 +448,8 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, if ( !facename.empty() ) { - wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, + wxFont font(wxNORMAL_FONT->GetPointSize(), + wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, facename, encoding); DoChangeFont(font); @@ -679,6 +689,16 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) Close(true); } +void MyFrame::OnTestTextValue(wxCommandEvent& WXUNUSED(event)) +{ + wxString value = m_textctrl->GetValue(); + m_textctrl->SetValue(value); + if ( m_textctrl->GetValue() != value ) + { + wxLogError(wxT("Text value changed after getting and setting it")); + } +} + void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_FILEDLG @@ -780,7 +800,8 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) // and now create the correct font if ( !DoEnumerateFamilies(false, fontenc, true /* silent */) ) { - wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, + wxFont font(wxNORMAL_FONT->GetPointSize(), + wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false /* !underlined */, wxEmptyString /* facename */, fontenc); if ( font.Ok() ) @@ -798,9 +819,9 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(wxT("wxWidgets font demo\n") - wxT("(c) 1999 Vadim Zeitlin"), - wxT("About Font"), + wxMessageBox(wxT("wxWidgets font sample\n") + wxT("(c) 1999-2006 Vadim Zeitlin"), + wxString(wxT("About ")) + SAMPLE_TITLE, wxOK | wxICON_INFORMATION, this); } @@ -873,7 +894,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.SetTextForeground(m_colour); // the size of one cell (Normally biggest char + small margin) - long maxCharWidth, maxCharHeight; + wxCoord maxCharWidth, maxCharHeight; dc.GetTextExtent(wxT("W"), &maxCharWidth, &maxCharHeight); int w = maxCharWidth + 5, h = maxCharHeight + 4; @@ -886,7 +907,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) { wxChar c = (wxChar)(32 * (i + 1) + j); - long charWidth, charHeight; + wxCoord charWidth, charHeight; dc.GetTextExtent(c, &charWidth, &charHeight); dc.DrawText (