]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/fontdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/fontdlg.cpp
3 // Purpose: wxFontDialog
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
12 #if wxUSE_FONTDLG && !defined(__WXGPE__)
14 #include "wx/fontdlg.h"
20 #include "wx/fontutil.h"
21 #include "wx/gtk/private.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
28 static void response(GtkDialog
* dialog
, int response_id
, wxFontDialog
* win
)
31 if (response_id
== GTK_RESPONSE_OK
)
34 #if GTK_CHECK_VERSION(3,2,0)
35 if (gtk_check_version(3,2,0) == NULL
)
37 wxNativeFontInfo info
;
38 info
.description
= gtk_font_chooser_get_font_desc(GTK_FONT_CHOOSER(dialog
));
39 win
->GetFontData().SetChosenFont(wxFont(info
));
44 GtkFontSelectionDialog
* sel
= GTK_FONT_SELECTION_DIALOG(dialog
);
45 wxGtkString
name(gtk_font_selection_dialog_get_font_name(sel
));
46 win
->GetFontData().SetChosenFont(wxFont(wxString::FromUTF8(name
)));
57 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
61 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
, wxDialog
)
63 bool wxFontDialog::DoCreate(wxWindow
*parent
)
65 parent
= GetParentForModalDialog(parent
, 0);
67 if (!PreCreation( parent
, wxDefaultPosition
, wxDefaultSize
) ||
68 !CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
,
69 wxDefaultValidator
, wxT("fontdialog") ))
71 wxFAIL_MSG( wxT("wxFontDialog creation failed") );
75 const wxString
message(_("Choose font"));
76 GtkWindow
* gtk_parent
= NULL
;
78 gtk_parent
= GTK_WINDOW(parent
->m_widget
);
80 #if GTK_CHECK_VERSION(3,2,0)
81 if (gtk_check_version(3,2,0) == NULL
)
82 m_widget
= gtk_font_chooser_dialog_new(wxGTK_CONV(message
), gtk_parent
);
86 m_widget
= gtk_font_selection_dialog_new(wxGTK_CONV(message
));
88 gtk_window_set_transient_for(GTK_WINDOW(m_widget
), gtk_parent
);
90 g_object_ref(m_widget
);
92 g_signal_connect(m_widget
, "response", G_CALLBACK(response
), this);
94 wxFont font
= m_fontData
.GetInitialFont();
97 const wxNativeFontInfo
*info
= font
.GetNativeFontInfo();
101 #if GTK_CHECK_VERSION(3,2,0)
102 if (gtk_check_version(3,2,0) == NULL
)
103 gtk_font_chooser_set_font_desc(GTK_FONT_CHOOSER(m_widget
), info
->description
);
107 const wxString
& fontname
= info
->ToString();
108 GtkFontSelectionDialog
* sel
= GTK_FONT_SELECTION_DIALOG(m_widget
);
109 gtk_font_selection_dialog_set_font_name(sel
, wxGTK_CONV(fontname
));
114 // this is not supposed to happen!
115 wxFAIL_MSG(wxT("font is ok but no native font info?"));
122 wxFontDialog::~wxFontDialog()
126 #endif // wxUSE_FONTDLG && !__WXGPE__