Exemplo n.º 1
0
int wxComboBox::DoAppend( const wxString &item )
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );

#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
    {
        GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
        gtk_combo_box_append_text( combobox,  wxGTK_CONV( item ) );
    }
    else
#endif
    {
        DisableEvents();

        GtkWidget *list = GTK_COMBO(m_widget)->list;
        GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );

        gtk_container_add( GTK_CONTAINER(list), list_item );

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );
        }

        // Apply current widget style to the new list_item
        GtkRcStyle *style = CreateWidgetStyle();
        if (style)
        {
            gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
            GtkBin *bin = GTK_BIN( list_item );
            GtkWidget *label = GTK_WIDGET( bin->child );
            gtk_widget_modify_style( label, style );
            gtk_rc_style_unref( style );
        }

        gtk_widget_show( list_item );

        EnableEvents();
    }

    const unsigned int count = GetCount();

    if ( m_clientDataList.GetCount() < count )
        m_clientDataList.Append( (wxObject*) NULL );
    if ( m_clientObjectList.GetCount() < count )
        m_clientObjectList.Append( (wxObject*) NULL );

    InvalidateBestSize();

    return count - 1;
}
Exemplo n.º 2
0
void FileDialog::SetWildcard(const wxString& wildCard)
{
#if defined(__WXGTK24__) && (!defined(__WXGPE__))
   if (!gtk_check_version(2,4,0))
   {
      // parse filters
      wxArrayString wildDescriptions, wildFilters;
      if (!wxParseCommonDialogsFilter(wildCard, wildDescriptions, wildFilters))
      {
         wxFAIL_MSG( wxT("FileDialog::SetWildCard - bad wildcard string") );
      }
      else
      {
         // Parsing went fine. Set m_wildCard to be returned by FileDialogBase::GetWildcard
         m_wildCard = wildCard;
         
         GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
         
         // empty current filter list:
         GSList* ifilters = gtk_file_chooser_list_filters(chooser);
         GSList* filters = ifilters;
         
         while (ifilters)
         {
            gtk_file_chooser_remove_filter(chooser,GTK_FILE_FILTER(ifilters->data));
            ifilters = ifilters->next;
         }
         g_slist_free(filters);
         
         // add parsed to GtkChooser
         for (size_t n = 0; n < wildFilters.GetCount(); ++n)
         {
            GtkFileFilter* filter = gtk_file_filter_new();
            gtk_file_filter_set_name(filter, wxGTK_CONV(wildDescriptions[n]));
            
            wxStringTokenizer exttok(wildFilters[n], wxT(";"));
            while (exttok.HasMoreTokens())
            {
               wxString token = exttok.GetNextToken();
               gtk_file_filter_add_pattern(filter, wxGTK_CONV(token));
            }
            
            gtk_file_chooser_add_filter(chooser, filter);
         }
         
         // Reset the filter index
         SetFilterIndex(0);
      }
   }
   else
#endif
      wxGenericFileDialog::SetWildcard( wildCard );
}
Exemplo n.º 3
0
bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
{
    wxString str( wxReplaceUnderscore( title ) );

    // This doesn't have much effect right now.
    menu->SetTitle( str );

    // The "m_owner" is the "menu item"
    menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
    GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
    // set new text
    gtk_label_set_text( label, wxGTK_CONV( str ) );
    // reparse key accel
    guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) );
    if (accel_key != GDK_VoidSymbol)
    {
        gtk_widget_add_accelerator (menu->m_owner,
                                    "activate_item",
                                    m_accel, //gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menubar)),
                                    accel_key,
                                    GDK_MOD1_MASK,
                                    GTK_ACCEL_LOCKED);
    }

    gtk_widget_show( menu->m_owner );

    gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );

    if (pos == -1)
        gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner );
    else
        gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );

    gtk_signal_connect( GTK_OBJECT(menu->m_owner), "activate",
                        GTK_SIGNAL_FUNC(gtk_menu_open_callback),
                        (gpointer)menu );

    if (m_menuBarFrame)
    {
        AttachToFrame( menu, m_menuBarFrame );

            // OPTIMISE ME:  we should probably cache this, or pass it
            //               directly, but for now this is a minimal
            //               change to validate the new dynamic sizing.
            //               see (and refactor :) similar code in Remove
            //               below.

            m_menuBarFrame->UpdateMenuBarSize();
    }

    return true;
}
Exemplo n.º 4
0
void wxCheckBox::SetLabel( const wxString& label )
{
    wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") );

    wxControl::SetLabel( label );

#ifdef __WXGTK20__
    wxString label2 = PrepareLabelMnemonics( label );
    gtk_label_set_text_with_mnemonic( GTK_LABEL(m_widgetLabel), wxGTK_CONV( label2 ) );
#else
    gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
#endif
}
Exemplo n.º 5
0
void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
{
    menu->SetLayoutDirection(GetLayoutDirection());

#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
    // if the menu has only one item, append it directly to the top level menu
    // instead of inserting a useless submenu
    if ( menu->GetMenuItemCount() == 1 )
    {
        wxMenuItem * const item = menu->FindItemByPosition(0);

        // remove both mnemonics and accelerator: neither is useful under Maemo
        const wxString str(wxStripMenuCodes(item->GetItemLabel()));

        if ( item->IsSubMenu() )
        {
            GtkAppend(item->GetSubMenu(), str, pos);
            return;
        }

        menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );

        g_signal_connect(menu->m_owner, "activate",
                         G_CALLBACK(menuitem_activate), item);
        item->SetMenuItem(menu->m_owner);
    }
    else
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    {
        const wxString str(wxConvertMnemonicsToGTK(title));

        // This doesn't have much effect right now.
        menu->SetTitle( str );

        // The "m_owner" is the "menu item"
        menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );

        gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
    }
    g_object_ref(menu->m_owner);

    gtk_widget_show( menu->m_owner );

    if (pos == -1)
        gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner );
    else
        gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );

    if ( m_menuBarFrame )
        AttachToFrame( menu, m_menuBarFrame );
}
Exemplo n.º 6
0
bool wxFontDialog::DoCreate(wxWindow *parent)
{
    m_needParent = false;

    if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
        !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
                     wxDefaultValidator, wxT("fontdialog") ))
    {
        wxFAIL_MSG( wxT("wxFontDialog creation failed") );
        return false;
    }

    wxString m_message( _("Choose font") );
    m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) );

    if (parent)
        gtk_window_set_transient_for(GTK_WINDOW(m_widget),
                                     GTK_WINDOW(parent->m_widget));

    GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget);

    g_signal_connect (sel->ok_button, "clicked",
                      G_CALLBACK (gtk_fontdialog_ok_callback), this);

    g_signal_connect (sel->cancel_button, "clicked",
                      G_CALLBACK (gtk_fontdialog_cancel_callback), this);

    g_signal_connect (m_widget, "delete_event",
                      G_CALLBACK (gtk_fontdialog_delete_callback), this);

    wxFont font = m_fontData.GetInitialFont();
    if( font.Ok() )
    {
        const wxNativeFontInfo *info = font.GetNativeFontInfo();

        if ( info )
        {

            const wxString& fontname = info->ToString();
            gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname));
        }
        else
        {
            // this is not supposed to happen!
            wxFAIL_MSG(_T("font is ok but no native font info?"));
        }
    }

    return true;
}
Exemplo n.º 7
0
void wxChoice::SetString(unsigned int n, const wxString& str )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );

    GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
    unsigned int count = 0;
    GList *child = menu_shell->children;
    while (child)
    {
        GtkBin *bin = GTK_BIN( child->data );
        if (count == n)
        {
            GtkLabel *label = NULL;
            if (bin->child)
                label = GTK_LABEL(bin->child);
            if (!label)
                label = GTK_LABEL( BUTTON_CHILD(m_widget) );

            wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );

            gtk_label_set_text( label, wxGTK_CONV( str ) );

            return;
        }
        child = child->next;
        count++;
    }
}
Exemplo n.º 8
0
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
{
    if (data)
        m_data = *data;

    m_parent = GetParentForModalDialog(parent, 0);
    GtkWindow * const parentGTK = m_parent ? GTK_WINDOW(m_parent->m_widget)
                                           : NULL;

#if wxUSE_LIBHILDON
    m_widget = hildon_color_selector_new(parentGTK);
#elif wxUSE_LIBHILDON2 // !wxUSE_LIBHILDON
    m_widget = hildon_color_chooser_dialog_new();
#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    wxString title(_("Choose colour"));
    m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON

    g_object_ref(m_widget);

    if ( parentGTK )
    {
        gtk_window_set_transient_for(GTK_WINDOW(m_widget), parentGTK);
    }

#if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    GtkColorSelection* sel = GTK_COLOR_SELECTION(
        gtk_color_selection_dialog_get_color_selection(
        GTK_COLOR_SELECTION_DIALOG(m_widget)));
    gtk_color_selection_set_has_palette(sel, true);
#endif // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2

    return true;
}
Exemplo n.º 9
0
void wxInfoBar::ShowMessage(const wxString& msg, int flags)
{
    if ( !UseNative() )
    {
        wxInfoBarGeneric::ShowMessage(msg, flags);
        return;
    }

    // if we don't have any buttons, create a standard close one to give the
    // user at least some way to close the bar
    if ( m_impl->m_buttons.empty() && !m_impl->m_close )
    {
        m_impl->m_close = GTKAddButton(wxID_CLOSE);
    }

    GtkMessageType type;
    if ( wxGTKImpl::ConvertMessageTypeFromWX(flags, &type) )
        gtk_info_bar_set_message_type(GTK_INFO_BAR(m_widget), type);
    gtk_label_set_text(GTK_LABEL(m_impl->m_label), wxGTK_CONV(msg));

    if ( !IsShown() )
        Show();

    UpdateParent();
}
Exemplo n.º 10
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);

    const wxString labelGTK = GTKConvertMnemonics(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;
        }
    }

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

    ApplyWidgetStyle( false );
}
Exemplo n.º 11
0
void wxStaticBox::SetLabel( const wxString &label )
{
    wxControl::SetLabel( label );

    gtk_frame_set_label( GTK_FRAME( m_widget ),
                         m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
}
Exemplo n.º 12
0
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
                            const wxString &label, const wxPoint &pos,
                            const wxSize &size, long style,
                            const wxValidator& validator,
                            const wxString &name)
{
    m_needParent = true;
    m_acceptsFocus = true;

    m_blockEvent = false;

    if (!PreCreation(parent, pos, size) ||
        !CreateBase(parent, id, pos, size, style, validator, name )) {
        wxFAIL_MSG(wxT("wxToggleButton creation failed"));
        return false;
    }

    wxControl::SetLabel(label);

    // Create the gtk widget.
    m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) );

    gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
                       GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
                       (gpointer *)this);

    m_parent->DoAddChild(this);

    PostCreation(size);

    return true;
}
Exemplo n.º 13
0
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
{
    if (data)
        m_data = *data;

    m_parent = GetParentForModalDialog(parent, 0);
    GtkWindow * const parentGTK = m_parent ? GTK_WINDOW(m_parent->m_widget)
                                           : NULL;

    wxString title(_("Choose colour"));
    m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));

    g_object_ref(m_widget);

    if ( parentGTK )
    {
        gtk_window_set_transient_for(GTK_WINDOW(m_widget), parentGTK);
    }

    GtkColorSelection* sel = GTK_COLOR_SELECTION(
        gtk_color_selection_dialog_get_color_selection(
        GTK_COLOR_SELECTION_DIALOG(m_widget)));
    gtk_color_selection_set_has_palette(sel, true);

    return true;
}
Exemplo n.º 14
0
void wxHyperlinkCtrl::SetURL(const wxString &uri)
{
    if ( UseNative() )
        gtk_link_button_set_uri(GTK_LINK_BUTTON(m_widget), wxGTK_CONV(uri));
    else
        wxGenericHyperlinkCtrl::SetURL(uri);
}
Exemplo n.º 15
0
void wxTextCtrl::DoSetValue( const wxString &value, int flags )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if ( !(flags & SetValue_SendEvent) )
    {
        // do not generate events
        IgnoreNextTextUpdate();
    }

    if (m_windowStyle & wxTE_MULTILINE)
    {
        gint len = gtk_text_get_length( GTK_TEXT(m_text) );
        gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
        len = 0;
        gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.length(), &len );
    }
    else
    {
        gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) );
    }

    // GRG, Jun/2000: Changed this after a lot of discussion in
    //   the lists. wxWidgets 2.2 will have a set of flags to
    //   customize this behaviour.
    SetInsertionPoint(0);

    m_modified = false;
}
Exemplo n.º 16
0
bool wxDirDialog::Create(wxWindow* parent,
                         const wxString& title,
                         const wxString& defaultPath,
                         long style,
                         const wxPoint& pos,
                         const wxSize& WXUNUSED(sz),
                         const wxString& WXUNUSED(name))
{
    m_message = title;

    parent = GetParentForModalDialog(parent, style);

    if (!PreCreation(parent, pos, wxDefaultSize) ||
        !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
                wxDefaultValidator, wxT("dirdialog")))
    {
        wxFAIL_MSG( wxT("wxDirDialog creation failed") );
        return false;
    }

    GtkWindow* gtk_parent = NULL;
    if (parent)
        gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );

    m_widget = gtk_file_chooser_dialog_new(
                   wxGTK_CONV(m_message),
                   gtk_parent,
                   GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                   GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                   NULL);
    g_object_ref(m_widget);

    gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
#if GTK_CHECK_VERSION(2,18,0)
#ifndef __WXGTK3__
    if (gtk_check_version(2,18,0) == NULL)
#endif
    {
        gtk_file_chooser_set_create_folders(
            GTK_FILE_CHOOSER(m_widget), (style & wxDD_DIR_MUST_EXIST) == 0);
    }
#endif

    // local-only property could be set to false to allow non-local files to be loaded.
    // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere
    // and the GtkFileChooserDialog should probably also be created with a backend,
    // e.g. "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
    // Currently local-only is kept as the default - true:
    // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);

    g_signal_connect (m_widget, "response",
        G_CALLBACK (gtk_dirdialog_response_callback), this);

    if ( !defaultPath.empty() )
        SetPath(defaultPath);

    return true;
}
Exemplo n.º 17
0
void wxStaticText::DoSetLabel(const wxString& str)
{
    // this function looks like GTKSetLabelForLabel() but here we just want to modify
    // the GTK control without altering any internal wxStaticText variable
    
    const wxString labelGTK = GTKConvertMnemonics(str);
    gtk_label_set_text_with_mnemonic(GTK_LABEL(m_widget), wxGTK_CONV(labelGTK));
}
Exemplo n.º 18
0
void wxControl::GTKSetLabelForLabel(GtkLabel *w, const wxString& label)
{
    // save the original label
    wxControlBase::SetLabel(label);

    const wxString labelGTK = GTKConvertMnemonics(label);
    gtk_label_set_text_with_mnemonic(w, wxGTK_CONV(labelGTK));
}
Exemplo n.º 19
0
void wxCollapsiblePane::SetLabel(const wxString &str)
{
    gtk_expander_set_label(GTK_EXPANDER(m_widget), wxGTK_CONV(str));

    // FIXME: we need to update our collapsed width in some way but using GetBestSize()
    // we may get the size of the control with the pane size summed up if we are expanded!
    //m_szCollapsed.x = GetBestSize().x;
}
Exemplo n.º 20
0
void wxRadioBox::SetLabel( const wxString& label )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );

    wxControl::SetLabel( label );

    gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
}
Exemplo n.º 21
0
void wxToggleButton::SetLabel(const wxString& label)
{
    wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));

    wxControl::SetLabel(label);

    gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) );
}
Exemplo n.º 22
0
void wxFontButton::UpdateFont()
{
    const wxNativeFontInfo *info = m_selectedFont.GetNativeFontInfo();
    wxASSERT_MSG( info, wxT("The fontbutton's internal font is not valid ?") );

    const wxString& fontname = info->ToString();
    gtk_font_button_set_font_name(GTK_FONT_BUTTON(m_widget), wxGTK_CONV(fontname));
}
Exemplo n.º 23
0
bool wxDirDialog::Create(wxWindow* parent,
                         const wxString& title,
                         const wxString& defaultPath,
                         long style,
                         const wxPoint& pos,
                         const wxSize& WXUNUSED(sz),
                         const wxString& WXUNUSED(name))
{
    m_message = title;

    parent = GetParentForModalDialog(parent, style);

    if (!PreCreation(parent, pos, wxDefaultSize) ||
        !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
                wxDefaultValidator, wxT("dirdialog")))
    {
        wxFAIL_MSG( wxT("wxDirDialog creation failed") );
        return false;
    }

    GtkWindow* gtk_parent = NULL;
    if (parent)
        gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );

    m_widget = gtk_file_chooser_dialog_new(
                   wxGTK_CONV(m_message),
                   gtk_parent,
                   GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                   GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                   NULL);
    g_object_ref(m_widget);

    gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);

    // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys
    // the dialog when the user press ESC on the dialog: in that case a second call to
    // ShowModal() would result in a bunch of Gtk-CRITICAL errors...
    g_signal_connect (m_widget,
                    "delete_event",
                    G_CALLBACK (gtk_widget_hide_on_delete),
                    (gpointer)this);

    // local-only property could be set to false to allow non-local files to be loaded.
    // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere
    // and the GtkFileChooserDialog should probably also be created with a backend,
    // e.g. "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend).
    // Currently local-only is kept as the default - true:
    // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true);

    g_signal_connect (m_widget, "response",
        G_CALLBACK (gtk_dirdialog_response_callback), this);

    if ( !defaultPath.empty() )
        SetPath(defaultPath);

    return true;
}
Exemplo n.º 24
0
bool wxRadioButton::Create( wxWindow *parent,
                            wxWindowID id,
                            const wxString& label,
                            const wxPoint& pos,
                            const wxSize& size,
                            long style,
                            const wxValidator& validator,
                            const wxString& name )
{
    m_acceptsFocus = TRUE;
    m_needParent = TRUE;

    m_blockEvent = FALSE;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxRadioButton creation failed") );
        return FALSE;
    }

    GSList* radioButtonGroup = NULL;
    if (!HasFlag(wxRB_GROUP))
    {
        // search backward for last group start
        wxRadioButton *chief = NULL;
        wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast();
        while (node)
        {
            wxWindow *child = node->GetData();
            if (child->IsRadioButton())
            {
                chief = (wxRadioButton*) child;
                if (child->HasFlag(wxRB_GROUP))
                    break;
            }
            node = node->GetPrevious();
        }
        if (chief)
        {
            // we are part of the group started by chief
            radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) );
        }
    }

    m_widget = gtk_radio_button_new_with_label( radioButtonGroup, wxGTK_CONV( label ) );

    SetLabel(label);

    gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
      GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );

    m_parent->DoAddChild( this );

    PostCreation(size);

    return TRUE;
}
Exemplo n.º 25
0
void wxComboBox::SetValue( const wxString& value )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );

    GtkWidget *entry = GTK_COMBO(m_widget)->entry;
    gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( value ) );

    InvalidateBestSize();
}
Exemplo n.º 26
0
bool wxNotebook::SetPageText( size_t page, const wxString &text )
{
    wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index");

    GtkLabel* label = GTK_LABEL(GetNotebookPage(page)->m_label);
    gtk_label_set_text(label, wxGTK_CONV(text));

    return true;
}
Exemplo n.º 27
0
GtkWidget *wxInfoBar::GTKAddButton(wxWindowID btnid, const wxString& label)
{
    // as GTK+ lays out the buttons vertically, adding another button changes
    // our best size (at least in vertical direction)
    InvalidateBestSize();

    GtkWidget* button = gtk_info_bar_add_button(GTK_INFO_BAR(m_widget),
#ifdef __WXGTK4__
        wxGTK_CONV(label.empty() ? wxConvertMnemonicsToGTK(wxGetStockLabel(btnid)) : label),
#else
        label.empty() ? wxGetStockGtkID(btnid) : static_cast<const char*>(wxGTK_CONV(label)),
#endif
        btnid);

    wxASSERT_MSG( button, "unexpectedly failed to add button to info bar" );

    return button;
}
Exemplo n.º 28
0
void wxControl::GTKSetLabelForLabel(GtkLabel *w, const wxString& label)
{
    // don't call the virtual function which might call this one back again
    wxControl::SetLabel(label);

    const wxString labelGTK = GTKRemoveMnemonics(label);

    gtk_label_set(w, wxGTK_CONV(labelGTK));
}
Exemplo n.º 29
0
void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label)
{
    wxControl::SetLabel(label);

    const wxString labelGTK = GTKRemoveMnemonics(label);

    gtk_frame_set_label(w, labelGTK.empty() ? (const char *)NULL
                        : wxGTK_CONV(labelGTK));
}
Exemplo n.º 30
0
void wxRadioBox::DoSetItemToolTip(unsigned int n, wxToolTip *tooltip)
{
    wxCharBuffer buf;
    if ( !tooltip )
        tooltip = GetToolTip();
    if ( tooltip )
        buf = wxGTK_CONV(tooltip->GetTip());

    wxToolTip::GTKApply(GTK_WIDGET(m_buttonsInfo[n]->button), buf);
}