]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/fontdlg.cpp
added the makefile for tex2rtf compilation using configure, fixed compilation
[wxWidgets.git] / src / gtk1 / fontdlg.cpp
CommitLineData
6dfaa4e5
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: fontdlg.cpp
3// Purpose: wxFontDialog
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "fontdlg.h"
12#endif
13
14#include "wx/fontdlg.h"
15#include "wx/utils.h"
16#include "wx/intl.h"
17#include "wx/debug.h"
18#include "wx/msgdlg.h"
19
20#include "gtk/gtk.h"
21
22//-----------------------------------------------------------------------------
23// idle system
24//-----------------------------------------------------------------------------
25
26extern void wxapp_install_idle_handler();
27extern bool g_isIdle;
28
29//-----------------------------------------------------------------------------
30// "delete_event"
31//-----------------------------------------------------------------------------
32
33static
34bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
35{
0b862e20 36 if (g_isIdle)
6dfaa4e5
RR
37 wxapp_install_idle_handler();
38
39/*
40 printf( "OnDelete from " );
41 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
42 printf( win->GetClassInfo()->GetClassName() );
43 printf( ".\n" );
44*/
45
46 win->Close();
47
48 return TRUE;
49}
50
51//-----------------------------------------------------------------------------
52// "clicked" for OK-button
53//-----------------------------------------------------------------------------
54
0b862e20 55#ifdef __WXGTK12__
6dfaa4e5
RR
56static
57void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog )
58{
0b862e20 59 if (g_isIdle)
6dfaa4e5
RR
60 wxapp_install_idle_handler();
61
62 GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
63 GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg);
0b862e20 64
6dfaa4e5
RR
65 if (!gfont)
66 {
67 wxMessageBox(_("Please choose a valid font."), _("Error"), wxOK);
68 return;
69 }
0b862e20 70
6dfaa4e5
RR
71 gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg);
72 wxFont font( gfont, fontname );
73 g_free( fontname );
74 dialog->m_fontData.SetChosenFont( font );
0b862e20 75
6dfaa4e5
RR
76 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
77 event.SetEventObject( dialog );
78 dialog->GetEventHandler()->ProcessEvent( event );
79}
0b862e20 80#endif // GTK+ 1.2 andlater only
6dfaa4e5
RR
81
82//-----------------------------------------------------------------------------
83// "clicked" for Cancel-button
84//-----------------------------------------------------------------------------
85
86static
87void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog )
88{
0b862e20 89 if (g_isIdle)
6dfaa4e5
RR
90 wxapp_install_idle_handler();
91
92 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
93 event.SetEventObject( dialog );
94 dialog->GetEventHandler()->ProcessEvent( event );
95}
96
97//-----------------------------------------------------------------------------
98// wxFontDialog
99//-----------------------------------------------------------------------------
100
101IMPLEMENT_DYNAMIC_CLASS(wxFontDialog,wxDialog)
102
5e0201ea 103wxFontDialog::wxFontDialog( wxWindow *parent, wxFontData *WXUNUSED(data) )
6dfaa4e5
RR
104{
105 m_needParent = FALSE;
106
107 if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
0b862e20 108 !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
223d09f6 109 wxDefaultValidator, wxT("fontdialog") ))
6dfaa4e5 110 {
223d09f6 111 wxFAIL_MSG( wxT("wxXX creation failed") );
0b862e20 112 return;
6dfaa4e5 113 }
0b862e20 114#ifndef __WXGTK12__
223d09f6 115 wxFAIL_MSG( wxT("TODO") );
0b862e20 116#else // GTK+ 1.2
6dfaa4e5
RR
117 wxString m_message( _("Choose font") );
118 m_widget = gtk_font_selection_dialog_new( m_message.mbc_str() );
119
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 );
123
124 GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget);
0b862e20 125
6dfaa4e5
RR
126 gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
127 GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
128
129 // strange way to internationalize
130 gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) );
131
132 gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
133 GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
0b862e20 134
6dfaa4e5
RR
135 // strange way to internationalize
136 gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) );
0b862e20 137
6dfaa4e5
RR
138 gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
139 GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );
0b862e20 140#endif // GTK+ version
6dfaa4e5
RR
141}
142
143wxFontDialog::~wxFontDialog()
144{
145}
146