示例#1
0
void wxButton::SetLabel( const wxString &lbl )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid button") );

    wxString label(lbl);

    if (label.empty() && wxIsStockID(m_windowId))
        label = wxGetStockLabel(m_windowId);

    wxControl::SetLabel(label);

    if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label))
    {
        const char *stock = wxGetStockGtkID(m_windowId);
        if (stock)
        {
            gtk_button_set_label(GTK_BUTTON(m_widget), stock);
            gtk_button_set_use_stock(GTK_BUTTON(m_widget), TRUE);
            return;
        }
    }

    const wxString labelGTK = GTKConvertMnemonics(label);
    gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));
    gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE);

    GTKApplyWidgetStyle( false );
}
示例#2
0
void wxToggleButton::SetLabel(const wxString& label)
{
    wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));

    wxControl::SetLabel(label);

    const wxString labelGTK = GTKConvertMnemonics(label);

    gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));

    GTKApplyWidgetStyle( false );
}
示例#3
0
void wxControl::PostCreation(const wxSize& size)
{
    wxWindow::PostCreation();

    // NB: GetBestSize needs to know the style, otherwise it will assume
    //     default font and if the user uses a different font, determined
    //     best size will be different (typically, smaller) than the desired
    //     size. This call ensure that a style is available at the time
    //     GetBestSize is called.
    gtk_widget_ensure_style(m_widget);

    GTKApplyWidgetStyle();
    SetInitialSize(size);
}
示例#4
0
void wxToggleButton::SetLabel(const wxString& label)
{
    wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));

    wxAnyButton::SetLabel(label);

    if ( HasFlag(wxBU_NOTEXT) )
    {
        // Don't try to update the label for a button not showing it, this is
        // unnecessary and can also actually replace the image we show with the
        // label entirely breaking the button code, see #13693.
        return;
    }

    const wxString labelGTK = GTKConvertMnemonics(label);

    gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));

    GTKApplyWidgetStyle( false );
}
示例#5
0
void wxButton::SetLabel( const wxString &lbl )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid button") );

    wxString label(lbl);

    if (label.empty() && wxIsStockID(m_windowId))
        label = wxGetStockLabel(m_windowId);

    wxAnyButton::SetLabel(label);

    // don't use label if it was explicitly disabled
    if ( HasFlag(wxBU_NOTEXT) )
        return;

#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0)
    if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label))
    {
        const char *stock = wxGetStockGtkID(m_windowId);
        if (stock)
        {
            gtk_button_set_label(GTK_BUTTON(m_widget), stock);
            gtk_button_set_use_stock(GTK_BUTTON(m_widget), TRUE);
            return;
        }
    }
#endif // GTK < 3.10

    // this call is necessary if the button had been initially created without
    // a (text) label -- then we didn't use gtk_button_new_with_mnemonic() and
    // so "use-underline" GtkButton property remained unset
    gtk_button_set_use_underline(GTK_BUTTON(m_widget), TRUE);
    const wxString labelGTK = GTKConvertMnemonics(label);
    gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));
#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0)
    gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE);
#endif // GTK < 3.10

    GTKApplyWidgetStyle( false );
}
示例#6
0
void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
    // Hildon window uses a single menu instead of a menu bar, so wxMenuBar is
    // the same as menu in this case
    m_widget =
    m_menubar = gtk_menu_new();
#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
        !CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
    {
        wxFAIL_MSG( wxT("wxMenuBar creation failed") );
        return;
    }

    m_menubar = gtk_menu_bar_new();

    if (style & wxMB_DOCKABLE)
    {
        m_widget = gtk_handle_box_new();
        gtk_container_add(GTK_CONTAINER(m_widget), m_menubar);
        gtk_widget_show(m_menubar);
    }
    else
    {
        m_widget = m_menubar;
    }

    PostCreation();

    GTKApplyWidgetStyle();
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2

    g_object_ref(m_widget);

    for (size_t i = 0; i < n; ++i )
        Append(menus[i], titles[i]);
}