]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/fontpicker.cpp
Fix typo in error message given if wxUSE_CAIRO is undefined.
[wxWidgets.git] / src / gtk / fontpicker.cpp
index 5c7f24b383c00cb0fa7e97801c66013a6c4b47b9..7eef011a453851b28b299b3a60a65605c29c97f5 100644 (file)
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#if wxUSE_FONTPICKERCTRL && defined(__WXGTK24__)
+#if wxUSE_FONTPICKERCTRL
 
 #include "wx/fontpicker.h"
 
 #include "wx/fontutil.h"        // for wxNativeFontInfo
 #include "wx/gtk/private.h"
 
 
 #include "wx/fontpicker.h"
 
 #include "wx/fontutil.h"        // for wxNativeFontInfo
 #include "wx/gtk/private.h"
 
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
 // ============================================================================
 // implementation
 // ============================================================================
 // ============================================================================
 // implementation
 // ============================================================================
@@ -45,7 +42,7 @@ static void gtk_fontbutton_setfont_callback(GtkFontButton *widget,
 
     // fire the colour-changed event
     wxFontPickerEvent event(p, p->GetId(), p->GetSelectedFont());
 
     // fire the colour-changed event
     wxFontPickerEvent event(p, p->GetId(), p->GetSelectedFont());
-    p->GetEventHandler()->ProcessEvent(event);
+    p->HandleWindowEvent(event);
 }
 }
 
 }
 }
 
@@ -53,7 +50,7 @@ static void gtk_fontbutton_setfont_callback(GtkFontButton *widget,
 // wxFontButton
 //-----------------------------------------------------------------------------
 
 // wxFontButton
 //-----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxFontButton, wxGenericFontButton)
+IMPLEMENT_DYNAMIC_CLASS(wxFontButton, wxButton)
 
 bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
                         const wxFont &initial,
 
 bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
                         const wxFont &initial,
@@ -61,47 +58,41 @@ bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
                         long style, const wxValidator& validator,
                         const wxString &name )
 {
                         long style, const wxValidator& validator,
                         const wxString &name )
 {
-    if (!gtk_check_version(2,4,0))
+    if (!PreCreation( parent, pos, size ) ||
+        !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
     {
     {
-        m_needParent = true;
+        wxFAIL_MSG( wxT("wxFontButton creation failed") );
+        return false;
+    }
 
 
-        if (!PreCreation( parent, pos, size ) ||
-            !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
-        {
-            wxFAIL_MSG( wxT("wxFontButton creation failed") );
-            return false;
-        }
+    m_widget = gtk_font_button_new();
+    g_object_ref(m_widget);
 
 
-        m_widget = gtk_font_button_new();
+    // set initial font
+    m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
+    UpdateFont();
 
 
-        // set initial font
-        m_selectedFont = initial;
-        UpdateFont();
+    // honour the fontbutton styles
+    bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
+         usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
+    gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
+    gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);
 
 
-        // honour the fontbutton styles
-        bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
-             usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
-        gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
-        gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);
+    gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
+    gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);
 
 
-        gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
-        gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);
+    gtk_widget_show(m_widget);
 
 
-        gtk_widget_show( GTK_WIDGET(m_widget) );
+    // GtkFontButton signals
+    g_signal_connect(m_widget, "font-set",
+                    G_CALLBACK(gtk_fontbutton_setfont_callback), this);
 
 
-        // GtkFontButton signals
-        g_signal_connect(m_widget, "font-set",
-                        G_CALLBACK(gtk_fontbutton_setfont_callback), this);
 
 
+    m_parent->DoAddChild( this );
 
 
-        m_parent->DoAddChild( this );
+    PostCreation(size);
+    SetInitialSize(size);
 
 
-        PostCreation(size);
-        SetBestSize(size);
-    }
-    else
-        return wxGenericFontButton::Create(parent, id, initial, pos, size,
-                                           style, validator, name);
     return true;
 }
 
     return true;
 }
 
@@ -111,16 +102,11 @@ wxFontButton::~wxFontButton()
 
 void wxFontButton::UpdateFont()
 {
 
 void wxFontButton::UpdateFont()
 {
-    if (!gtk_check_version(2,4,0))
-    {
-        const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
-        wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );
+    const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
+    wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );
 
 
-        const wxString& fontname = info->ToString();
-        gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
-    }
-    else
-        wxGenericFontButton::UpdateFont();
+    const wxString& fontname = info->ToString();
+    gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
 }
 
 }
 
-#endif      // wxUSE_FONTPICKERCTRL && defined(__WXGTK24__)
+#endif // wxUSE_FONTPICKERCTRL