@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
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
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
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
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
@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
@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
@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
@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
@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
@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
@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
@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
<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
// 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
#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
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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_
class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
{
public:
- wxChoice();
+ wxChoice()
+ {
+ Init();
+ }
wxChoice( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
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,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr )
{
- m_strings = (wxSortedArrayString *)NULL;
-
+ Init();
Create(parent, id, pos, size, choices, style, validator, name);
}
virtual ~wxChoice();
// 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,
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)
};
public wxTextEntry
{
public:
- wxComboBox() { m_strings = NULL; }
+ wxComboBox()
+ : wxChoice(), wxTextEntry()
+ {
+ Init();
+ }
wxComboBox(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
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);
}
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
+ : wxChoice(), wxTextEntry()
{
+ Init();
Create(parent, id, value, pos, size, choices, style, validator, name);
}
// 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:
DisableEvents();
}
+ void Init();
+
DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
DECLARE_EVENT_TABLE()
};
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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
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,
long style, const wxValidator& validator,
const wxString &name )
{
- m_strings = NULL;
-
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
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)
int n = wxNOT_FOUND;
- GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
for ( int i = 0; i < count; ++i )
{
n = pos + i;
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);
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();
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 );
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 );
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 );
}
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;
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,
long style, const wxValidator& validator,
const wxString& name )
{
- m_strings = NULL;
-
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
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))
{
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);
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
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());
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);
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);