bool wxStatusBarGeneric::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { style |= wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE; if ( !wxWindow::Create(parent, id, wxDefaultPosition, wxDefaultSize, style, name) ) return false; // The status bar should have a themed background SetThemeEnabled( true ); InitColours(); int height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height); SetFieldsCount(1); #if defined( __WXGTK20__ ) #if GTK_CHECK_VERSION(2,12,0) if (HasFlag(wxSTB_SHOW_TIPS) && wx_is_at_least_gtk2(12)) { g_object_set(m_widget, "has-tooltip", TRUE, NULL); g_signal_connect(m_widget, "query-tooltip", G_CALLBACK(statusbar_query_tooltip), this); } #endif #endif return true; }
static unsigned int GetEntryTextLength(GtkEntry* entry) { #if GTK_CHECK_VERSION(2, 14, 0) if ( wx_is_at_least_gtk2(14) ) { return gtk_entry_get_text_length(entry); } #endif // GTK+ 2.14+ return strlen(gtk_entry_get_text(entry)); }
bool wxChoice::GTKHandleFocusOut() { if ( wx_is_at_least_gtk2(10) ) { gboolean isShown; g_object_get( m_widget, "popup-shown", &isShown, NULL ); // Don't send "focus lost" events if the focus is grabbed by our own // popup, it counts as part of this window, even though wx doesn't know // about it (and can't, because GtkComboBox doesn't expose it). if ( isShown ) return true; } return wxChoiceBase::GTKHandleFocusOut(); }
bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBox creation failed") ); return false; } m_widget = GTKCreateFrame(label); g_object_ref(m_widget); // only base SetLabel needs to be called after GTKCreateFrame wxControl::SetLabel(label); m_parent->DoAddChild( this ); PostCreation(size); // need to set non default alignment? gfloat xalign = 0; if ( style & wxALIGN_CENTER ) xalign = 0.5; else if ( style & wxALIGN_RIGHT ) xalign = 1.0; gtk_frame_set_label_align(GTK_FRAME(m_widget), xalign, 0.5); #ifndef __WXGTK3__ if (!wx_is_at_least_gtk2(12)) { // we connect this signal to perform label-clipping as GTK >= 2.12 does g_signal_connect(m_widget, "size_allocate", G_CALLBACK(size_allocate), NULL); } #endif m_container.DisableSelfFocus(); return true; }
int wxListBox::GetTopItem() const { int idx = wxNOT_FOUND; #if GTK_CHECK_VERSION(2,8,0) wxGtkTreePath start; if ( wx_is_at_least_gtk2(8) && gtk_tree_view_get_visible_range(m_treeview, start.ByRef(), NULL)) { gint *ptr = gtk_tree_path_get_indices(start); if ( ptr ) idx = *ptr; } #endif return idx; }
wxString wxGTKMimeTypesManagerImpl::GetIconFromMimeType(const wxString& mime) { wxString icon; #if GTK_CHECK_VERSION(2,14,0) if (!wx_is_at_least_gtk2(14)) return icon; wxGtkString type(g_content_type_from_mime_type(mime.utf8_str())); wxGtkObject<GIcon> gicon(g_content_type_get_icon(type)); if ( !gicon ) return icon; GtkIconTheme *theme(gtk_icon_theme_get_default()); if ( !theme ) return icon; // Notice that we can't use wxGtkObject here because a special function // needs to be used for freeing this object prior to GTK+ 3.8. GtkIconInfo* const giconinfo = gtk_icon_theme_lookup_by_gicon ( theme, gicon, 256, GTK_ICON_LOOKUP_NO_SVG ); if ( giconinfo ) { icon = wxString::FromUTF8(gtk_icon_info_get_filename(giconinfo)); wxGCC_WARNING_SUPPRESS(deprecated-declarations) gtk_icon_info_free(giconinfo); wxGCC_WARNING_RESTORE() } #endif // GTK_CHECK_VERSION(2,14,0) return icon; }
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); return false; } if (HasFlag(wxCB_SORT)) m_strings = new wxGtkCollatedArrayString(); GTKCreateComboBoxWidget(); if (HasFlag(wxBORDER_NONE)) { // Doesn't seem to work // g_object_set (m_widget, "has-frame", FALSE, NULL); } GtkEntry * const entry = GetEntry(); if ( entry ) { // Set it up to trigger default item on enter key press gtk_entry_set_activates_default( entry, !HasFlag(wxTE_PROCESS_ENTER) ); gtk_editable_set_editable(GTK_EDITABLE(entry), true); #ifdef __WXGTK3__ gtk_entry_set_width_chars(entry, 0); #endif } Append(n, choices); m_parent->DoAddChild( this ); if ( entry ) m_focusWidget = GTK_WIDGET( entry ); PostCreation(size); if ( entry ) { if (style & wxCB_READONLY) { // this will assert and do nothing if the value is not in our list // of strings which is the desired behaviour (for consistency with // wxMSW and also because it doesn't make sense to have a string // which is not a possible choice in a read-only combobox) SetStringSelection(value); gtk_editable_set_editable(GTK_EDITABLE(entry), false); } else // editable combobox { // any value is accepted, even if it's not in our list gtk_entry_set_text( entry, wxGTK_CONV(value) ); } g_signal_connect_after (entry, "changed", G_CALLBACK (gtkcombobox_text_changed_callback), this); GTKConnectInsertTextSignal(entry); GTKConnectClipboardSignals(GTK_WIDGET(entry)); } g_signal_connect_after (m_widget, "changed", G_CALLBACK (gtkcombobox_changed_callback), this); if ( wx_is_at_least_gtk2(10) ) { g_signal_connect (m_widget, "notify::popup-shown", G_CALLBACK (gtkcombobox_popupshown_callback), this); } return true; }