Native wxBitmapComboBox patch for GTK+
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
145
include/wx/gtk/bmpcbox.h
Normal file
145
include/wx/gtk/bmpcbox.h
Normal file
@@ -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_
|
@@ -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)
|
||||
};
|
||||
|
||||
|
@@ -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()
|
||||
};
|
||||
|
Reference in New Issue
Block a user