]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/fontpicker.cpp
Disable some wxWebView tests that fail on the buildbot but not locally.
[wxWidgets.git] / src / gtk / fontpicker.cpp
CommitLineData
ec376c8f
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/fontpicker.cpp
3// Purpose: implementation of wxFontButton
4// Author: Francesco Montorsi
5// Modified By:
6// Created: 15/04/2006
7// Id: $Id$
8// Copyright: (c) Francesco Montorsi
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12
13// ----------------------------------------------------------------------------
14// headers
15// ----------------------------------------------------------------------------
16
17// For compilers that support precompilation, includes "wx.h".
18#include "wx/wxprec.h"
19
03647350 20#if wxUSE_FONTPICKERCTRL
4ce7b1e4 21
ec376c8f
VZ
22#include "wx/fontpicker.h"
23
24#include "wx/fontutil.h" // for wxNativeFontInfo
25#include "wx/gtk/private.h"
26
ec376c8f
VZ
27// ============================================================================
28// implementation
29// ============================================================================
30
ec376c8f
VZ
31//-----------------------------------------------------------------------------
32// "font-set"
33//-----------------------------------------------------------------------------
34
35extern "C" {
36static void gtk_fontbutton_setfont_callback(GtkFontButton *widget,
37 wxFontButton *p)
38{
39 // update the m_selectedFont member of the wxFontButton
40 wxASSERT(p);
41 p->SetNativeFontInfo(gtk_font_button_get_font_name(widget));
42
43 // fire the colour-changed event
44 wxFontPickerEvent event(p, p->GetId(), p->GetSelectedFont());
937013e0 45 p->HandleWindowEvent(event);
ec376c8f
VZ
46}
47}
48
49//-----------------------------------------------------------------------------
50// wxFontButton
51//-----------------------------------------------------------------------------
52
ff654490 53IMPLEMENT_DYNAMIC_CLASS(wxFontButton, wxButton)
ec376c8f
VZ
54
55bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
56 const wxFont &initial,
57 const wxPoint &pos, const wxSize &size,
58 long style, const wxValidator& validator,
59 const wxString &name )
60{
ff654490
VZ
61 if (!PreCreation( parent, pos, size ) ||
62 !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
ec376c8f 63 {
ff654490
VZ
64 wxFAIL_MSG( wxT("wxFontButton creation failed") );
65 return false;
66 }
ec376c8f 67
ff654490 68 m_widget = gtk_font_button_new();
9ff9d30c 69 g_object_ref(m_widget);
ec376c8f 70
ff654490
VZ
71 // set initial font
72 m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
73 UpdateFont();
ec376c8f 74
ff654490
VZ
75 // honour the fontbutton styles
76 bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
77 usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
78 gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
79 gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);
ec376c8f 80
ff654490
VZ
81 gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
82 gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);
ec376c8f 83
ff654490 84 gtk_widget_show(m_widget);
ec376c8f 85
ff654490
VZ
86 // GtkFontButton signals
87 g_signal_connect(m_widget, "font-set",
88 G_CALLBACK(gtk_fontbutton_setfont_callback), this);
ec376c8f
VZ
89
90
ff654490
VZ
91 m_parent->DoAddChild( this );
92
93 PostCreation(size);
94 SetInitialSize(size);
ec376c8f 95
ec376c8f
VZ
96 return true;
97}
98
99wxFontButton::~wxFontButton()
100{
101}
102
103void wxFontButton::UpdateFont()
104{
ff654490
VZ
105 const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
106 wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );
ec376c8f 107
ff654490
VZ
108 const wxString& fontname = info->ToString();
109 gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
ec376c8f
VZ
110}
111
ff654490 112#endif // wxUSE_FONTPICKERCTRL