applied wxNativeFontInfo patch from Derry Bryson (with minor changes)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -96,6 +96,8 @@ public:
|
||||
{ DoEnumerateFamilies(TRUE); }
|
||||
void OnEnumerateEncodings(wxCommandEvent& event);
|
||||
|
||||
void OnCheckNativeToFromString(wxCommandEvent& event);
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
protected:
|
||||
@@ -136,7 +138,8 @@ enum
|
||||
Font_EnumFamilies,
|
||||
Font_EnumFixedFamilies,
|
||||
Font_EnumEncodings,
|
||||
Font_Max
|
||||
Font_CheckNativeToFromString
|
||||
Font_Max,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -157,6 +160,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(Font_EnumFamilies, MyFrame::OnEnumerateFamilies)
|
||||
EVT_MENU(Font_EnumFixedFamilies, MyFrame::OnEnumerateFixedFamilies)
|
||||
EVT_MENU(Font_EnumEncodings, MyFrame::OnEnumerateEncodings)
|
||||
EVT_MENU(Font_CheckNativeToFromString, MyFrame::OnCheckNativeToFromString)
|
||||
|
||||
EVT_SIZE(MyFrame::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
@@ -228,6 +232,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
menuFont->Append(Font_EnumFamiliesForEncoding,
|
||||
"Find font for en&coding...\tCtrl-C",
|
||||
"Find font families for given encoding");
|
||||
menuFont->AppendSeparator();
|
||||
menuFont->Append(Font_CheckNativeToFromString,
|
||||
"Check Native Font Info To/From String");
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
@@ -382,7 +389,7 @@ void MyFrame::OnEnumerateFamiliesForEncoding(wxCommandEvent& WXUNUSED(event))
|
||||
wxFONTENCODING_CP1252,
|
||||
};
|
||||
|
||||
static const char *encodingNames[] =
|
||||
static const wxString encodingNames[] =
|
||||
{
|
||||
"West European (Latin 1)",
|
||||
"Central European (Latin 2)",
|
||||
@@ -397,7 +404,7 @@ void MyFrame::OnEnumerateFamiliesForEncoding(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
int n = wxGetSingleChoiceIndex("Choose an encoding", "Font demo",
|
||||
WXSIZEOF(encodingNames),
|
||||
(char **)encodingNames,
|
||||
encodingNames,
|
||||
this);
|
||||
|
||||
if ( n != -1 )
|
||||
@@ -406,6 +413,27 @@ void MyFrame::OnEnumerateFamiliesForEncoding(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnCheckNativeToFromString(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString fontInfo = m_canvas->GetTextFont().GetNativeFontInfo().ToString();
|
||||
|
||||
if(fontInfo.IsEmpty())
|
||||
wxMessageBox("Native font info string is empty!", "Font demo",
|
||||
wxOK);
|
||||
else
|
||||
{
|
||||
wxNativeFontInfo info;
|
||||
info.FromString(fontInfo);
|
||||
wxFont font(info);
|
||||
if(fontInfo == font.GetNativeFontInfo().ToString())
|
||||
wxMessageBox("wxNativeFontInfo ToString()/FromString() works!",
|
||||
"Font demo", wxOK);
|
||||
else
|
||||
wxMessageBox("wxNativeFontInfo ToString()/FromString() doesn't work!",
|
||||
"Font demo", wxOK);
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::DoResizeFont(int diff)
|
||||
{
|
||||
wxFont fontOld = m_canvas->GetTextFont();
|
||||
@@ -650,6 +678,13 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
|
||||
dc.DrawText(fontInfo, 5, 5);
|
||||
|
||||
if(m_font.Ok())
|
||||
{
|
||||
dc.SetFont(wxFont(m_font.GetNativeFontInfo()));
|
||||
fontInfo.Printf("Native font info: %s", m_font.GetNativeFontInfo().ToString().GetData());
|
||||
dc.DrawText(fontInfo, 5, 5 + dc.GetCharHeight());
|
||||
}
|
||||
|
||||
// prepare to draw the font
|
||||
dc.SetFont(m_font);
|
||||
dc.SetTextForeground(m_colour);
|
||||
|
Reference in New Issue
Block a user