setting the font of a dialog widget



Hi,

Thanks in advance.

I'd like to set the font size of a general widget in a dialog box as part of
the initialization of the dialog.  I'm not using Glade -- I'm building the
dialog by hand (actually auto-converting from a Windows resource file, but
that's not relevant).  If the widget I'm trying to set happens to be a
Gtk::Label, then it works.  But other widgets (e.g. Gtk::Frame or
Gtk::Checkbutton) don't and just seem to use their default font no matter
what.  For example:


class LXMyDialog : public LXDialog
{
public:
    LXMyDialog();

private:
    Gtk::Fixed m_Fixed;
    Gtk::Frame m_Frame
};


LXMyDialog::LXMyDialog()
{
    // Add the fixed widget to the dialog and size it properly
    get_vbox()->add(m_Fixed);
    m_Fixed.set_size_request( 566, 500 );

    // Initialize the label so font is twice as big as default (this is the
part that doesn't seem to work)
    Glib::RefPtr<Pango::Context> pPango = m_Frame.get_pango_context();
    Pango::FontDescription fontD = pPango->get_font_description();
    fontD.set_size(2 * fontD.get_size());
    m_Frame.modify_font(fontD);

    m_Frame.set_label("Frame:");
    m_Frame.set_size_request(532, 50);
    m_Fixed.put(m_Frame, 12, 16);

    show_all_children();
}

(If I replace the above Gtk::Frame with Gtk::Label, it all works as I would
expect)

Again, thanks for any ideas you may have...

-Garth

-- 
Garth Upshaw
Garth's KidStuff



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]