From e78c1d7855d1fefcdbff0e093e21e5cf101ca604 Mon Sep 17 00:00:00 2001 From: Robert Roebling <robert@roebling.de> Date: Tue, 27 May 2008 10:17:56 +0000 Subject: [PATCH] Native wxBitmapComboBox patch for GTK+ git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 65 ++++--- build/bakefiles/files.bkl | 2 + include/wx/bmpcbox.h | 4 +- include/wx/gtk/bmpcbox.h | 145 +++++++++++++++ include/wx/gtk/choice.h | 20 ++- include/wx/gtk/combobox.h | 20 ++- src/gtk/bmpcbox.cpp | 361 ++++++++++++++++++++++++++++++++++++++ src/gtk/choice.cpp | 36 ++-- src/gtk/combobox.cpp | 57 +++--- 9 files changed, 643 insertions(+), 67 deletions(-) create mode 100644 include/wx/gtk/bmpcbox.h create mode 100644 src/gtk/bmpcbox.cpp diff --git a/Makefile.in b/Makefile.in index 23481bfcd5..0f83882659 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3011,6 +3011,7 @@ COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_HDR = \ @COND_TOOLKIT_X11@ wx/unix/joystick.h wx/unix/sound.h wx/unix/taskbarx11.h COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_ADVANCED_PLATFORM_NATIVE_HDR = \ wx/gtk/animate.h \ + wx/gtk/bmpcbox.h \ wx/gtk/calctrl.h \ wx/gtk/dataview.h \ wx/gtk/hyperlink.h @@ -5387,6 +5388,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = \ monodll_aboutdlg.o \ monodll_animate.o \ + monodll_bmpcbox.o \ monodll_calctrl.o \ monodll_dataview.o \ monodll_hyperlink.o @@ -7310,6 +7312,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_1 = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = \ monolib_aboutdlg.o \ monolib_animate.o \ + monolib_bmpcbox.o \ monolib_calctrl.o \ monolib_dataview.o \ monolib_hyperlink.o @@ -11070,6 +11073,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_2 = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = \ advdll_aboutdlg.o \ advdll_animate.o \ + advdll_bmpcbox.o \ advdll_calctrl.o \ advdll_dataview.o \ advdll_hyperlink.o @@ -11153,6 +11157,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_3 = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = \ advlib_aboutdlg.o \ advlib_animate.o \ + advlib_bmpcbox.o \ advlib_calctrl.o \ advlib_dataview.o \ advlib_hyperlink.o @@ -18130,6 +18135,15 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monodll_eggtrayicon.o: $(srcdir)/src/gtk1/eggtrayicon.c $(MONODLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@ $(CCC) -c -o $@ $(MONODLL_CFLAGS) $(srcdir)/src/gtk1/eggtrayicon.c +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@monodll_bmpcbox.o: $(srcdir)/src/gtk/bmpcbox.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/bmpcbox.cpp + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@monodll_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp @@ -18139,12 +18153,6 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_calctrl.o: $(srcdir)/src/msw/calctrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/calctrl.cpp -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_datecontrols.o: $(srcdir)/src/msw/datecontrols.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/datecontrols.cpp @@ -22681,6 +22689,15 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@monolib_eggtrayicon.o: $(srcdir)/src/gtk1/eggtrayicon.c $(MONOLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1@ $(CCC) -c -o $@ $(MONOLIB_CFLAGS) $(srcdir)/src/gtk1/eggtrayicon.c +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@monolib_bmpcbox.o: $(srcdir)/src/gtk/bmpcbox.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/bmpcbox.cpp + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@monolib_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp @@ -22690,12 +22707,6 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_calctrl.o: $(srcdir)/src/msw/calctrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/calctrl.cpp -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_datecontrols.o: $(srcdir)/src/msw/datecontrols.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/datecontrols.cpp @@ -30901,6 +30912,15 @@ advdll_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@advdll_eggtrayicon.o: $(srcdir)/src/gtk1/eggtrayicon.c $(ADVDLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@ $(CCC) -c -o $@ $(ADVDLL_CFLAGS) $(srcdir)/src/gtk1/eggtrayicon.c +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@advdll_bmpcbox.o: $(srcdir)/src/gtk/bmpcbox.cpp $(ADVDLL_ODEP) +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/gtk/bmpcbox.cpp + +@COND_TOOLKIT_MSW_WXUNIV_0@advdll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVDLL_ODEP) +@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + +@COND_TOOLKIT_WINCE_WXUNIV_0@advdll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVDLL_ODEP) +@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@advdll_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp @@ -30910,12 +30930,6 @@ advdll_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@advdll_calctrl.o: $(srcdir)/src/msw/calctrl.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/calctrl.cpp -@COND_TOOLKIT_MSW_WXUNIV_0@advdll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVDLL_ODEP) -@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - -@COND_TOOLKIT_WINCE_WXUNIV_0@advdll_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVDLL_ODEP) -@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - @COND_TOOLKIT_MSW_WXUNIV_0@advdll_datecontrols.o: $(srcdir)/src/msw/datecontrols.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/datecontrols.cpp @@ -31186,6 +31200,15 @@ advlib_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@advlib_eggtrayicon.o: $(srcdir)/src/gtk1/eggtrayicon.c $(ADVLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_@ $(CCC) -c -o $@ $(ADVLIB_CFLAGS) $(srcdir)/src/gtk1/eggtrayicon.c +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@advlib_bmpcbox.o: $(srcdir)/src/gtk/bmpcbox.cpp $(ADVLIB_ODEP) +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/gtk/bmpcbox.cpp + +@COND_TOOLKIT_MSW_WXUNIV_0@advlib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVLIB_ODEP) +@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + +@COND_TOOLKIT_WINCE_WXUNIV_0@advlib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVLIB_ODEP) +@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp + @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@advlib_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp @@ -31195,12 +31218,6 @@ advlib_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@advlib_calctrl.o: $(srcdir)/src/msw/calctrl.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/calctrl.cpp -@COND_TOOLKIT_MSW_WXUNIV_0@advlib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVLIB_ODEP) -@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - -@COND_TOOLKIT_WINCE_WXUNIV_0@advlib_bmpcbox.o: $(srcdir)/src/msw/bmpcbox.cpp $(ADVLIB_ODEP) -@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/bmpcbox.cpp - @COND_TOOLKIT_MSW_WXUNIV_0@advlib_datecontrols.o: $(srcdir)/src/msw/datecontrols.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/datecontrols.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 738b28084a..3ed76e2370 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2999,12 +2999,14 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! <set var="ADVANCED_GTK_NATIVE_SRC" hints="files"> src/gtk/aboutdlg.cpp src/gtk/animate.cpp + src/gtk/bmpcbox.cpp src/gtk/calctrl.cpp src/gtk/dataview.cpp src/gtk/hyperlink.cpp </set> <set var="ADVANCED_GTK_NATIVE_HDR" hints="files"> wx/gtk/animate.h + wx/gtk/bmpcbox.h wx/gtk/calctrl.h wx/gtk/dataview.h wx/gtk/hyperlink.h diff --git a/include/wx/bmpcbox.h b/include/wx/bmpcbox.h index 79010ec0a2..9e8bb9026a 100644 --- a/include/wx/bmpcbox.h +++ b/include/wx/bmpcbox.h @@ -25,7 +25,7 @@ class WXDLLIMPEXP_FWD_CORE wxItemContainer; // Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which // wxBitmapComboBox implementation utilizes ownerdrawn combobox // (either native or generic). -#if 1 +#if !defined(__WXGTK__) #define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED #endif @@ -112,6 +112,8 @@ private: #include "wx/generic/bmpcbox.h" #elif defined(__WXMSW__) #include "wx/msw/bmpcbox.h" +#elif defined(__WXGTK__) + #include "wx/gtk/bmpcbox.h" #else #include "wx/generic/bmpcbox.h" #endif diff --git a/include/wx/gtk/bmpcbox.h b/include/wx/gtk/bmpcbox.h new file mode 100644 index 0000000000..b0555904f7 --- /dev/null +++ b/include/wx/gtk/bmpcbox.h @@ -0,0 +1,145 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/gtk/bmpcbox.h +// Purpose: wxBitmapComboBox +// Author: Jaakko Salli +// Created: 2008-05-19 +// RCS-ID: $Id: +// Copyright: (c) 2008 Jaakko Salli +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GTK_BMPCBOX_H_ +#define _WX_GTK_BMPCBOX_H_ + + +#include "wx/combobox.h" + +// ---------------------------------------------------------------------------- +// wxBitmapComboBox: a wxComboBox that allows images to be shown +// in front of string items. +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_ADV wxBitmapComboBox : public wxComboBox, + public wxBitmapComboBoxBase +{ +public: + // ctors and such + wxBitmapComboBox() : wxComboBox(), wxBitmapComboBoxBase() + { + Init(); + } + + wxBitmapComboBox(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, + const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapComboBoxNameStr) + : wxComboBox(), + wxBitmapComboBoxBase() + { + Init(); + + (void)Create(parent, id, value, pos, size, n, + choices, style, validator, name); + } + + wxBitmapComboBox(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapComboBoxNameStr); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + int n, + const wxString choices[], + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapComboBoxNameStr); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxBitmapComboBoxNameStr); + + virtual ~wxBitmapComboBox(); + + // Sets the image for the given item. + virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap); + + // Returns the image of the item with the given index. + virtual wxBitmap GetItemBitmap(unsigned int n) const; + + // Returns size of the image used in list + virtual wxSize GetBitmapSize() const + { + return m_bitmapSize; + } + + // Adds item with image to the end of the combo box. + int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap); + int Append(const wxString& item, const wxBitmap& bitmap, void *clientData); + int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData); + + // Inserts item with image into the list before pos. Not valid for wxCB_SORT + // styles, use Append instead. + int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos); + int Insert(const wxString& item, const wxBitmap& bitmap, + unsigned int pos, void *clientData); + int Insert(const wxString& item, const wxBitmap& bitmap, + unsigned int pos, wxClientData *clientData); + + // Override some wxTextEntry interface. + virtual void WriteText(const wxString& value); + + virtual wxString GetValue() const; + virtual void Remove(long from, long to); + + virtual void SetInsertionPoint(long pos); + virtual long GetInsertionPoint() const; + virtual long GetLastPosition() const; + + virtual void SetSelection(long from, long to); + virtual void GetSelection(long *from, long *to) const; + + virtual void SetSelection(int n) { wxComboBox::SetSelection(n); } + virtual int GetSelection() const { return wxComboBox::GetSelection(); } + + virtual bool IsEditable() const; + virtual void SetEditable(bool editable); + +protected: + + virtual GtkWidget* GetConnectWidget(); + virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; + + virtual void GTKCreateComboBoxWidget(); + virtual void GTKInsertComboBoxTextItem( unsigned int n, const wxString& text ); + + wxSize m_bitmapSize; + int m_bitmapCellIndex; + +private: + void Init(); + + DECLARE_DYNAMIC_CLASS(wxBitmapComboBox) +}; + +#endif // _WX_GTK_BMPCBOX_H_ diff --git a/include/wx/gtk/choice.h b/include/wx/gtk/choice.h index 6da310248b..a9d9cc8e95 100644 --- a/include/wx/gtk/choice.h +++ b/include/wx/gtk/choice.h @@ -20,7 +20,10 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase { public: - wxChoice(); + wxChoice() + { + Init(); + } wxChoice( wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -29,8 +32,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxChoiceNameStr ) { - m_strings = (wxSortedArrayString *)NULL; - + Init(); Create(parent, id, pos, size, n, choices, style, validator, name); } wxChoice( wxWindow *parent, wxWindowID id, @@ -41,8 +43,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxChoiceNameStr ) { - m_strings = (wxSortedArrayString *)NULL; - + Init(); Create(parent, id, pos, size, choices, style, validator, name); } virtual ~wxChoice(); @@ -85,6 +86,9 @@ protected: // contains the client data for the items wxArrayPtrVoid m_clientData; + // index to GtkListStore cell which displays the item text + int m_stringCellIndex; + virtual wxSize DoGetBestSize() const; virtual int DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, @@ -96,7 +100,13 @@ protected: virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; + // in derived classes, implement this to insert list store entry + // with all items default except text + virtual void GTKInsertComboBoxTextItem( unsigned int n, const wxString& text ); + private: + void Init(); + DECLARE_DYNAMIC_CLASS(wxChoice) }; diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index 430a3c0fa8..438dc7c3ad 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -23,7 +23,11 @@ class WXDLLIMPEXP_CORE wxComboBox : public wxChoice, public wxTextEntry { public: - wxComboBox() { m_strings = NULL; } + wxComboBox() + : wxChoice(), wxTextEntry() + { + Init(); + } wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, @@ -33,7 +37,9 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) + : wxChoice(), wxTextEntry() { + Init(); Create(parent, id, value, pos, size, n, choices, style, validator, name); } @@ -45,7 +51,9 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr) + : wxChoice(), wxTextEntry() { + Init(); Create(parent, id, value, pos, size, choices, style, validator, name); } @@ -123,8 +131,14 @@ protected: // override this and return true. virtual bool UseGTKStyleBase() const { return true; } + // Override in derived classes to create combo box widgets with + // custom list stores. + virtual void GTKCreateComboBoxWidget(); + // return the GtkEntry part of the combobox - GtkEntry *GetEntry() const; + GtkEntry *GetEntry() const { return m_entry; } + + GtkEntry* m_entry; private: // From wxTextEntry: @@ -138,6 +152,8 @@ private: DisableEvents(); } + void Init(); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) DECLARE_EVENT_TABLE() }; diff --git a/src/gtk/bmpcbox.cpp b/src/gtk/bmpcbox.cpp new file mode 100644 index 0000000000..88e4dcb9a6 --- /dev/null +++ b/src/gtk/bmpcbox.cpp @@ -0,0 +1,361 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/gtk/bmpcboxg.cpp +// Purpose: wxBitmapComboBox +// Author: Jaakko Salli +// Created: 2008-05-19 +// RCS-ID: $Id: +// Copyright: (c) 2008 Jaakko Salli +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_BITMAPCOMBOBOX + +#include "wx/bmpcbox.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" +#endif + +#include "wx/gtk/private.h" + +#ifdef __WXGTK24__ + #include "wx/gtk/win_gtk.h" + + #include <gobject/gvaluecollector.h> + #include <gtk/gtktreemodel.h> +#endif + + +// ============================================================================ +// implementation +// ============================================================================ + + +IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBox, wxComboBox) + + +// ---------------------------------------------------------------------------- +// wxBitmapComboBox creation +// ---------------------------------------------------------------------------- + +void wxBitmapComboBox::Init() +{ + m_bitmapCellIndex = 0; + m_stringCellIndex = 1; + m_bitmapSize = wxSize(0, 0); +} + +wxBitmapComboBox::wxBitmapComboBox(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator, + const wxString& name) + : wxComboBox(), + wxBitmapComboBoxBase() +{ + Init(); + + Create(parent,id,value,pos,size,choices,style,validator,name); +} + +bool wxBitmapComboBox::Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + const wxArrayString& choices, + long style, + const wxValidator& validator, + const wxString& name) +{ + wxCArrayString chs(choices); + return Create(parent, id, value, pos, size, chs.GetCount(), + chs.GetStrings(), style, validator, name); +} + +bool wxBitmapComboBox::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 ( !wxComboBox::Create(parent, id, value, pos, size, + n, choices, style, validator, name) ) + return false; + + // Select 'value' in entry-less mode + if ( !GetEntry() ) + { + int n = FindString(value); + if ( n != wxNOT_FOUND ) + SetSelection(n); + } + + return true; +} + +void wxBitmapComboBox::GTKCreateComboBoxWidget() +{ + GtkListStore *store; + + store = gtk_list_store_new( 2, G_TYPE_OBJECT, G_TYPE_STRING ); + + if ( HasFlag(wxCB_READONLY) ) + { + m_widget = gtk_combo_box_new_with_model( GTK_TREE_MODEL(store) ); + } + 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 ); + } + + // 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) ); + + GtkCellRenderer* imageRenderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(m_widget), + imageRenderer, FALSE); + gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(m_widget), + imageRenderer, "pixbuf", 0); + + GtkCellRenderer* textRenderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_end( GTK_CELL_LAYOUT(m_widget), + textRenderer, TRUE ); + gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(m_widget), + textRenderer, "text", 1); +} + +wxBitmapComboBox::~wxBitmapComboBox() +{ +} + +GtkWidget* wxBitmapComboBox::GetConnectWidget() +{ + if ( GetEntry() ) + return wxComboBox::GetConnectWidget(); + + return wxChoice::GetConnectWidget(); +} + +GdkWindow *wxBitmapComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const +{ + if ( GetEntry() ) + return wxComboBox::GTKGetWindow(windows); + + return wxChoice::GTKGetWindow(windows); +} + +// ---------------------------------------------------------------------------- +// Item manipulation +// ---------------------------------------------------------------------------- + +void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) +{ + if ( bitmap.IsOk() ) + { + if ( m_bitmapSize.x == 0 ) + { + m_bitmapSize.x = bitmap.GetWidth(); + m_bitmapSize.y = bitmap.GetHeight(); + } + + GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); + GtkTreeModel *model = gtk_combo_box_get_model( combobox ); + GtkTreeIter iter; + + if ( gtk_tree_model_iter_nth_child( model, &iter, NULL, n ) ) + { + GValue value0 = { 0, }; + g_value_init( &value0, G_TYPE_OBJECT ); + g_value_set_object( &value0, bitmap.GetPixbuf() ); + gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, + m_bitmapCellIndex, &value0 ); + g_value_unset( &value0 ); + } + } +} + +wxBitmap wxBitmapComboBox::GetItemBitmap(unsigned int n) const +{ + wxBitmap bitmap; + + GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); + GtkTreeModel *model = gtk_combo_box_get_model( combobox ); + GtkTreeIter iter; + + if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n)) + { + GValue value = { 0, }; + gtk_tree_model_get_value( model, &iter, + m_bitmapCellIndex, &value ); + GdkPixbuf* pixbuf = (GdkPixbuf*) g_value_get_object( &value ); + if ( pixbuf ) + { + g_object_ref( pixbuf ); + bitmap.SetPixbuf( pixbuf ); + } + g_value_unset( &value ); + } + + return bitmap; +} + +int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap) +{ + const int n = wxComboBox::Append(item); + if ( n != wxNOT_FOUND ) + SetItemBitmap(n, bitmap); + return n; +} + +int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, + void *clientData) +{ + const int n = wxComboBox::Append(item, clientData); + if ( n != wxNOT_FOUND ) + SetItemBitmap(n, bitmap); + return n; +} + +int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, + wxClientData *clientData) +{ + const int n = wxComboBox::Append(item, clientData); + if ( n != wxNOT_FOUND ) + SetItemBitmap(n, bitmap); + return n; +} + +int wxBitmapComboBox::Insert(const wxString& item, + const wxBitmap& bitmap, + unsigned int pos) +{ + const int n = wxComboBox::Insert(item, pos); + if ( n != wxNOT_FOUND ) + SetItemBitmap(n, bitmap); + return n; +} + +int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, + unsigned int pos, wxClientData *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 ); + GtkTreeModel *model = gtk_combo_box_get_model( combobox ); + GtkListStore *store = GTK_LIST_STORE( model ); + GtkTreeIter iter; + + gtk_list_store_insert( store, &iter, n ); + + GValue value = { 0, }; + g_value_init( &value, G_TYPE_STRING ); + g_value_set_string( &value, wxGTK_CONV( text ) ); + gtk_list_store_set_value( store, &iter, m_stringCellIndex, &value ); + g_value_unset( &value ); +} + +// ---------------------------------------------------------------------------- +// wxTextEntry interface override +// ---------------------------------------------------------------------------- + +void wxBitmapComboBox::WriteText(const wxString& value) +{ + if ( GetEntry() ) + wxComboBox::WriteText(value); +} + +wxString wxBitmapComboBox::GetValue() const +{ + if ( GetEntry() ) + return wxComboBox::GetValue(); + + return GetStringSelection(); +} + +void wxBitmapComboBox::Remove(long from, long to) +{ + if ( GetEntry() ) + wxComboBox::Remove(from, to); +} + +void wxBitmapComboBox::SetInsertionPoint(long pos) +{ + if ( GetEntry() ) + wxComboBox::SetInsertionPoint(pos); +} + +long wxBitmapComboBox::GetInsertionPoint() const +{ + if ( GetEntry() ) + return wxComboBox::GetInsertionPoint(); + + return 0; + } +long wxBitmapComboBox::GetLastPosition() const +{ + if ( GetEntry() ) + return wxComboBox::GetLastPosition(); + + return 0; + } + +void wxBitmapComboBox::SetSelection(long from, long to) +{ + if ( GetEntry() ) + wxComboBox::SetSelection(from, to); +} + +void wxBitmapComboBox::GetSelection(long *from, long *to) const +{ + if ( GetEntry() ) + wxComboBox::GetSelection(from, to); +} + +bool wxBitmapComboBox::IsEditable() const +{ + if ( GetEntry() ) + return wxTextEntry::IsEditable(); + + return false; +} + +void wxBitmapComboBox::SetEditable(bool editable) +{ + if ( GetEntry() ) + wxComboBox::SetEditable(editable); +} + +#endif // wxUSE_BITMAPCOMBOBOX diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 4fbc3417c0..af58e5c2ce 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -40,9 +40,10 @@ gtk_choice_changed_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControlWithItems) -wxChoice::wxChoice() - : m_strings(NULL) +void wxChoice::Init() { + m_strings = (wxSortedArrayString *)NULL; + m_stringCellIndex = 0; } bool wxChoice::Create( wxWindow *parent, wxWindowID id, @@ -63,8 +64,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, long style, const wxValidator& validator, const wxString &name ) { - m_strings = NULL; - if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { @@ -117,6 +116,11 @@ void wxChoice::SendSelectionChangedEvent(wxEventType evt_type) HandleWindowEvent( event ); } +void wxChoice::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text ) +{ + gtk_combo_box_insert_text( GTK_COMBO_BOX( m_widget ), n, wxGTK_CONV( text ) ); +} + int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, unsigned int pos, void **clientData, wxClientDataType type) @@ -130,7 +134,6 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, int n = wxNOT_FOUND; - GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); for ( int i = 0; i < count; ++i ) { n = pos + i; @@ -139,7 +142,7 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items, if(m_strings) n = m_strings->Add(items[i]); - gtk_combo_box_insert_text( combobox, n, wxGTK_CONV( items[i] ) ); + GTKInsertComboBoxTextItem( n, items[i] ); m_clientData.Insert( NULL, n ); AssignNewItemClientData(n, clientData, i, type); @@ -166,9 +169,9 @@ void wxChoice::DoClear() DisableEvents(); - const unsigned int count = GetCount(); - for (unsigned int i = 0; i < count; i++) - gtk_combo_box_remove_text( GTK_COMBO_BOX(m_widget), 0 ); + GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); + GtkTreeModel* model = gtk_combo_box_get_model( combobox ); + gtk_list_store_clear(GTK_LIST_STORE(model)); m_clientData.Clear(); @@ -185,7 +188,14 @@ void wxChoice::DoDeleteOneItem(unsigned int n) wxCHECK_RET( m_widget != NULL, wxT("invalid control") ); wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") ); - gtk_combo_box_remove_text( GTK_COMBO_BOX( m_widget ), n ); + GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); + GtkTreeModel* model = gtk_combo_box_get_model( combobox ); + GtkListStore* store = GTK_LIST_STORE(model); + GtkTreeIter iter; + gtk_tree_model_iter_nth_child( model, &iter, + NULL, (gint) n ); + gtk_list_store_remove( store, &iter ); + m_clientData.RemoveAt( n ); if ( m_strings ) m_strings->RemoveAt( n ); @@ -207,7 +217,7 @@ int wxChoice::FindString( const wxString &item, bool bCase ) const do { GValue value = { 0, }; - gtk_tree_model_get_value( model, &iter, 0, &value ); + gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value ); wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) ); g_value_unset( &value ); @@ -240,7 +250,7 @@ void wxChoice::SetString(unsigned int n, const wxString &text) GValue value = { 0, }; g_value_init( &value, G_TYPE_STRING ); g_value_set_string( &value, wxGTK_CONV( text ) ); - gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, 0, &value ); + gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, m_stringCellIndex, &value ); g_value_unset( &value ); } @@ -259,7 +269,7 @@ wxString wxChoice::GetString(unsigned int n) const if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n)) { GValue value = { 0, }; - gtk_tree_model_get_value( model, &iter, 0, &value ); + gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value ); wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) ); g_value_unset( &value ); return tmp; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 88a9c2fd29..30a9824ea4 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -72,6 +72,11 @@ BEGIN_EVENT_TABLE(wxComboBox, wxChoice) EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll) END_EVENT_TABLE() +void wxComboBox::Init() +{ + m_entry = NULL; +} + bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, @@ -91,8 +96,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, long style, const wxValidator& validator, const wxString& name ) { - m_strings = NULL; - if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { @@ -103,12 +106,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, if (HasFlag(wxCB_SORT)) m_strings = new wxSortedArrayString(); - m_widget = gtk_combo_box_entry_new_text(); - - // Set it up to trigger default item on enter key press - GtkWidget *widget = gtk_bin_get_child(GTK_BIN(m_widget)); - gtk_entry_set_activates_default(GTK_ENTRY(widget), - !HasFlag(wxTE_PROCESS_ENTER)); + GTKCreateComboBoxWidget(); if (HasFlag(wxBORDER_NONE)) { @@ -118,23 +116,34 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, GtkEntry * const entry = GetEntry(); - gtk_entry_set_editable( entry, TRUE ); + if ( entry ) + { + // Set it up to trigger default item on enter key press + gtk_entry_set_activates_default( entry, + !HasFlag(wxTE_PROCESS_ENTER) ); + + gtk_entry_set_editable( entry, TRUE ); + } Append(n, choices); m_parent->DoAddChild( this ); - m_focusWidget = GTK_WIDGET( entry ); + if ( entry ) + m_focusWidget = GTK_WIDGET( entry ); PostCreation(size); - gtk_entry_set_text( entry, wxGTK_CONV(value) ); + if ( entry ) + { + gtk_entry_set_text( entry, wxGTK_CONV(value) ); - if (style & wxCB_READONLY) - gtk_entry_set_editable( entry, FALSE ); + if (style & wxCB_READONLY) + gtk_entry_set_editable( entry, FALSE ); - g_signal_connect_after (entry, "changed", - G_CALLBACK (gtkcombobox_text_changed_callback), this); + g_signal_connect_after (entry, "changed", + G_CALLBACK (gtkcombobox_text_changed_callback), this); + } g_signal_connect_after (m_widget, "changed", G_CALLBACK (gtkcombobox_changed_callback), this); @@ -144,9 +153,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, return true; } -GtkEntry *wxComboBox::GetEntry() const +void wxComboBox::GTKCreateComboBoxWidget() { - return GTK_ENTRY(GTK_BIN(m_widget)->child); + m_widget = gtk_combo_box_entry_new_text(); + + m_entry = GTK_ENTRY(GTK_BIN(m_widget)->child); } GtkEditable *wxComboBox::GetEditable() const @@ -159,7 +170,7 @@ void wxComboBox::OnChar( wxKeyEvent &event ) switch ( event.GetKeyCode() ) { case WXK_RETURN: - if ( HasFlag(wxTE_PROCESS_ENTER) ) + if ( HasFlag(wxTE_PROCESS_ENTER) && GetEntry() ) { // GTK automatically selects an item if its in the list wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId()); @@ -182,8 +193,9 @@ void wxComboBox::OnChar( wxKeyEvent &event ) void wxComboBox::DisableEvents() { - g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child, - (gpointer)gtkcombobox_text_changed_callback, this); + if ( GetEntry() ) + g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child, + (gpointer)gtkcombobox_text_changed_callback, this); g_signal_handlers_block_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); @@ -191,8 +203,9 @@ void wxComboBox::DisableEvents() void wxComboBox::EnableEvents() { - g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child, - (gpointer)gtkcombobox_text_changed_callback, this); + if ( GetEntry() ) + g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child, + (gpointer)gtkcombobox_text_changed_callback, this); g_signal_handlers_unblock_by_func(m_widget, (gpointer)gtkcombobox_changed_callback, this); -- 2.47.2