]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/font/font.cpp
Added SetSelectionMode
[wxWidgets.git] / samples / font / font.cpp
index 0ed46b1aa5b115da4a063971b11e0cda8203e754..8c1a0b630a44c4ad9f69db4ab3f84a9a703f4df5 100644 (file)
@@ -235,34 +235,36 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
     SetStatusText("Welcome to wxWindows font demo!");
 }
 
     SetStatusText("Welcome to wxWindows font demo!");
 }
 
+// --------------------------------------------------------
 
 
-// event handlers
-void MyFrame::OnEnumerateEncodings(wxCommandEvent& WXUNUSED(event))
+class MyEncodingEnumerator : public wxFontEnumerator
 {
 {
-    class MyEncodingEnumerator : public wxFontEnumerator
-    {
-    public:
-        MyEncodingEnumerator() { m_n = 0; }
-
-        const wxString& GetText() const { return m_text; }
+public:
+    MyEncodingEnumerator() 
+        { m_n = 0; }
 
 
-    protected:
-        virtual bool OnFontEncoding(const wxString& facename,
-                                    const wxString& encoding)
-        {
-            wxString text;
-            text.Printf("Encoding %d: %s (available in facename '%s')\n",
-                         ++m_n, encoding.c_str(), facename.c_str());
-            m_text += text;
+    const wxString& GetText() const 
+        { return m_text; }
 
 
-            return TRUE;
-        }
+protected:
+    virtual bool OnFontEncoding(const wxString& facename,
+                                const wxString& encoding)
+    {
+        wxString text;
+        text.Printf("Encoding %d: %s (available in facename '%s')\n",
+                    ++m_n, encoding.c_str(), facename.c_str());
+        m_text += text;
+        return TRUE;
+    }
 
 
-    private:
-        size_t m_n;
+private:
+    size_t m_n;
+    wxString m_text;
+};
 
 
-        wxString m_text;
-    } fontEnumerator;
+void MyFrame::OnEnumerateEncodings(wxCommandEvent& WXUNUSED(event))
+{
+    MyEncodingEnumerator fontEnumerator;
 
     fontEnumerator.EnumerateEncodings();
 
 
     fontEnumerator.EnumerateEncodings();
 
@@ -270,28 +272,33 @@ void MyFrame::OnEnumerateEncodings(wxCommandEvent& WXUNUSED(event))
                  fontEnumerator.GetText().c_str());
 }
 
                  fontEnumerator.GetText().c_str());
 }
 
-bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly,
-                                  wxFontEncoding encoding,
-                                  bool silent)
-{
-    class MyFontEnumerator : public wxFontEnumerator
-    {
-    public:
-        bool GotAny() const { return !m_facenames.IsEmpty(); }
+// -------------------------------------------------------------
 
 
-        const wxArrayString& GetFacenames() const { return m_facenames; }
+class MyFontEnumerator : public wxFontEnumerator
+{
+public:
+    bool GotAny() const 
+        { return !m_facenames.IsEmpty(); }
 
 
-    protected:
-        virtual bool OnFacename(const wxString& facename)
-        {
-            m_facenames.Add(facename);
+    const wxArrayString& GetFacenames() const 
+        { return m_facenames; }
 
 
-            return TRUE;
-        }
+protected:
+    virtual bool OnFacename(const wxString& facename)
+    {
+        m_facenames.Add(facename);
+        return TRUE;
+    }
 
     private:
         wxArrayString m_facenames;
 
     private:
         wxArrayString m_facenames;
-    } fontEnumerator;
+} fontEnumerator;
+
+bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly,
+                                  wxFontEncoding encoding,
+                                  bool silent)
+{
+    MyFontEnumerator fontEnumerator;
 
     fontEnumerator.EnumerateFacenames(encoding, fixedWidthOnly);
 
 
     fontEnumerator.EnumerateFacenames(encoding, fixedWidthOnly);
 
@@ -495,21 +502,22 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event))
     if (!wxTheFontMapper->IsEncodingAvailable(fontenc))
     {
         // try to find some similar encoding:
     if (!wxTheFontMapper->IsEncodingAvailable(fontenc))
     {
         // try to find some similar encoding:
-        wxFontEncoding enc2;
-        if (wxTheFontMapper->GetAltForEncoding(fontenc, &enc2, 
-                                       wxEmptyString /*facename*/, FALSE /*interactive*/))
+        wxFontEncoding encAlt;
+        if ( wxTheFontMapper->GetAltForEncoding(fontenc, &encAlt) )
         {
             wxEncodingConverter conv;
             
         {
             wxEncodingConverter conv;
             
-            if (conv.Init(fontenc, enc2))
+            if (conv.Init(fontenc, encAlt))
             {
             {
-                fontenc = enc2;
+                fontenc = encAlt;
                 m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue()));
             }
             else
                 m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue()));
             }
             else
+            {
                 wxLogWarning("Cannot convert from '%s' to '%s'.",
                              wxFontMapper::GetEncodingDescription(fontenc).c_str(),
                 wxLogWarning("Cannot convert from '%s' to '%s'.",
                              wxFontMapper::GetEncodingDescription(fontenc).c_str(),
-                             wxFontMapper::GetEncodingDescription(enc2).c_str());
+                             wxFontMapper::GetEncodingDescription(encAlt).c_str());
+            }
         }
         else
             wxLogWarning("No fonts for encoding '%s' on this system.",
         }
         else
             wxLogWarning("No fonts for encoding '%s' on this system.",