/////////////////////////////////////////////////////////////////////////////
-// Name: src/gtk/bmpcboxg.cpp
+// Name: src/gtk/bmpcbox.cpp
// Purpose: wxBitmapComboBox
// Author: Jaakko Salli
// Created: 2008-05-19
-// RCS-ID: $Id:
// Copyright: (c) 2008 Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/log.h"
#endif
+#include <gtk/gtk.h>
#include "wx/gtk/private.h"
-#ifdef __WXGTK24__
- #include "wx/gtk/win_gtk.h"
-
- #include <gobject/gvaluecollector.h>
- #include <gtk/gtktreemodel.h>
-#endif
-
-
// ============================================================================
// implementation
// ============================================================================
{
m_bitmapCellIndex = 0;
m_stringCellIndex = 1;
- m_bitmapSize = wxSize(0, 0);
+ m_bitmapSize = wxSize(-1, -1);
}
wxBitmapComboBox::wxBitmapComboBox(wxWindow *parent,
// Select 'value' in entry-less mode
if ( !GetEntry() )
{
- int n = FindString(value);
- if ( n != wxNOT_FOUND )
- SetSelection(n);
+ int i = FindString(value);
+ if (i != wxNOT_FOUND)
+ SetSelection(i);
}
return true;
}
else
{
+#ifdef __WXGTK3__
+ m_widget = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(m_widget), m_stringCellIndex);
+#else
m_widget = gtk_combo_box_entry_new_with_model( GTK_TREE_MODEL(store), m_stringCellIndex );
- m_entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
- gtk_entry_set_editable( m_entry, TRUE );
+#endif
+ m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
+ gtk_editable_set_editable(GTK_EDITABLE(m_entry), true);
}
+ g_object_ref(m_widget);
// This must be called as gtk_combo_box_entry_new_with_model adds
// automatically adds one text column.
- gtk_cell_layout_clear( GTK_CELL_LAYOUT(m_widget) );
+ gtk_cell_layout_clear( GTK_CELL_LAYOUT(m_widget) );
GtkCellRenderer* imageRenderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(m_widget),
{
if ( GetEntry() )
return wxComboBox::GTKGetWindow(windows);
-
+
return wxChoice::GTKGetWindow(windows);
}
+wxSize wxBitmapComboBox::DoGetBestSize() const
+{
+ wxSize best = wxComboBox::DoGetBestSize();
+
+ int delta = GetBitmapSize().y - GetCharHeight();
+ if ( delta > 0 )
+ {
+ best.y += delta;
+ CacheBestSize(best);
+ }
+ return best;
+}
+
// ----------------------------------------------------------------------------
// Item manipulation
// ----------------------------------------------------------------------------
{
if ( bitmap.IsOk() )
{
- if ( m_bitmapSize.x == 0 )
+ if ( m_bitmapSize.x < 0 )
{
m_bitmapSize.x = bitmap.GetWidth();
m_bitmapSize.y = bitmap.GetHeight();
if ( pixbuf )
{
g_object_ref( pixbuf );
- bitmap.SetPixbuf( pixbuf );
+ bitmap = wxBitmap(pixbuf);
}
g_value_unset( &value );
}
return n;
}
+int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap,
+ unsigned int pos, void *clientData)
+{
+ const int n = wxComboBox::Insert(item, pos, clientData);
+ if ( n != wxNOT_FOUND )
+ SetItemBitmap(n, bitmap);
+ return n;
+}
+
void wxBitmapComboBox::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text )
{
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
{
if ( GetEntry() )
wxComboBox::WriteText(value);
+ else
+ SetStringSelection(value);
}
wxString wxBitmapComboBox::GetValue() const