1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFontDialog
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "fontdlg.h"
14 #include "wx/fontdlg.h"
18 #include "wx/msgdlg.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 extern void wxapp_install_idle_handler();
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
34 bool gtk_fontdialog_delete_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxDialog
*win
)
37 wxapp_install_idle_handler();
40 printf( "OnDelete from " );
41 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
42 printf( win->GetClassInfo()->GetClassName() );
51 //-----------------------------------------------------------------------------
52 // "clicked" for OK-button
53 //-----------------------------------------------------------------------------
57 void gtk_fontdialog_ok_callback( GtkWidget
*WXUNUSED(widget
), wxFontDialog
*dialog
)
60 wxapp_install_idle_handler();
62 GtkFontSelectionDialog
*fontdlg
= GTK_FONT_SELECTION_DIALOG(dialog
->m_widget
);
63 GdkFont
*gfont
= gtk_font_selection_dialog_get_font(fontdlg
);
67 wxMessageBox(_("Please choose a valid font."), _("Error"), wxOK
);
71 gchar
*fontname
= gtk_font_selection_dialog_get_font_name(fontdlg
);
72 wxFont
font( gfont
, fontname
);
74 dialog
->m_fontData
.SetChosenFont( font
);
76 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
77 event
.SetEventObject( dialog
);
78 dialog
->GetEventHandler()->ProcessEvent( event
);
80 #endif // GTK+ 1.2 andlater only
82 //-----------------------------------------------------------------------------
83 // "clicked" for Cancel-button
84 //-----------------------------------------------------------------------------
87 void gtk_fontdialog_cancel_callback( GtkWidget
*WXUNUSED(w
), wxFontDialog
*dialog
)
90 wxapp_install_idle_handler();
92 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_CANCEL
);
93 event
.SetEventObject( dialog
);
94 dialog
->GetEventHandler()->ProcessEvent( event
);
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog
,wxDialog
)
103 wxFontDialog::wxFontDialog( wxWindow
*parent
, wxFontData
*WXUNUSED(data
) )
105 m_needParent
= FALSE
;
107 if (!PreCreation( parent
, wxDefaultPosition
, wxDefaultSize
) ||
108 !CreateBase( parent
, -1, wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
,
109 wxDefaultValidator
, wxT("fontdialog") ))
111 wxFAIL_MSG( wxT("wxXX creation failed") );
115 wxFAIL_MSG( wxT("TODO") );
117 wxString
m_message( _("Choose font") );
118 m_widget
= gtk_font_selection_dialog_new( m_message
.mbc_str() );
120 int x
= (gdk_screen_width () - 400) / 2;
121 int y
= (gdk_screen_height () - 400) / 2;
122 gtk_widget_set_uposition( m_widget
, x
, y
);
124 GtkFontSelectionDialog
*sel
= GTK_FONT_SELECTION_DIALOG(m_widget
);
126 gtk_signal_connect( GTK_OBJECT(sel
->ok_button
), "clicked",
127 GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback
), (gpointer
*)this );
129 // strange way to internationalize
130 gtk_label_set( GTK_LABEL( GTK_BUTTON(sel
->ok_button
)->child
), wxConvCurrent
->cWX2MB(_("OK")) );
132 gtk_signal_connect( GTK_OBJECT(sel
->cancel_button
), "clicked",
133 GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback
), (gpointer
*)this );
135 // strange way to internationalize
136 gtk_label_set( GTK_LABEL( GTK_BUTTON(sel
->cancel_button
)->child
), wxConvCurrent
->cWX2MB(_("Cancel")) );
138 gtk_signal_connect( GTK_OBJECT(m_widget
), "delete_event",
139 GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback
), (gpointer
)this );
140 #endif // GTK+ version
143 wxFontDialog::~wxFontDialog()