1999-10-22 14:00:39 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
|
|
|
|
// Purpose: wxControlWithItems interface
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 22.10.99
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-10-22 14:00:39 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_CTRLSUB_H_BASE_
|
|
|
|
#define _WX_CTRLSUB_H_BASE_
|
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if wxUSE_CONTROLS
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
#include "wx/arrstr.h"
|
1999-10-22 14:00:39 -04:00
|
|
|
#include "wx/control.h" // base class
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2001-06-26 16:59:19 -04:00
|
|
|
// wxItemContainer defines an interface which is implemented by all controls
|
1999-10-22 14:00:39 -04:00
|
|
|
// which have string subitems each of which may be selected.
|
|
|
|
//
|
2005-02-13 14:01:17 -05:00
|
|
|
// It is decomposed in wxItemContainerImmutable which omits all methods
|
|
|
|
// adding/removing items and is used by wxRadioBox and wxItemContainer itself.
|
|
|
|
//
|
2001-06-26 16:59:19 -04:00
|
|
|
// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
|
|
|
|
// implements an extended interface deriving from this one)
|
1999-10-22 14:00:39 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2005-02-13 14:01:17 -05:00
|
|
|
class WXDLLEXPORT wxItemContainerImmutable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxItemContainerImmutable() { }
|
|
|
|
virtual ~wxItemContainerImmutable();
|
|
|
|
|
|
|
|
// accessing strings
|
|
|
|
// -----------------
|
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
virtual unsigned int GetCount() const = 0;
|
2005-02-13 14:01:17 -05:00
|
|
|
bool IsEmpty() const { return GetCount() == 0; }
|
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
virtual wxString GetString(unsigned int n) const = 0;
|
2005-02-13 14:01:17 -05:00
|
|
|
wxArrayString GetStrings() const;
|
2006-03-23 17:05:23 -05:00
|
|
|
virtual void SetString(unsigned int n, const wxString& s) = 0;
|
2005-09-27 12:54:43 -04:00
|
|
|
|
|
|
|
// finding string natively is either case sensitive or insensitive
|
|
|
|
// but never both so fall back to this base version for not
|
|
|
|
// supported search type
|
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const
|
|
|
|
{
|
2006-03-23 17:05:23 -05:00
|
|
|
unsigned int count = GetCount();
|
2005-09-27 12:54:43 -04:00
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
for ( unsigned int i = 0; i < count ; ++i )
|
2005-09-27 12:54:43 -04:00
|
|
|
{
|
|
|
|
if (GetString(i).IsSameAs( s , bCase ))
|
2006-03-23 17:05:23 -05:00
|
|
|
return (int)i;
|
2005-09-27 12:54:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
}
|
2005-02-13 14:01:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
// selection
|
|
|
|
// ---------
|
|
|
|
|
|
|
|
virtual void SetSelection(int n) = 0;
|
|
|
|
virtual int GetSelection() const = 0;
|
|
|
|
|
|
|
|
// set selection to the specified string, return false if not found
|
|
|
|
bool SetStringSelection(const wxString& s);
|
|
|
|
|
|
|
|
// return the selected string or empty string if none
|
|
|
|
wxString GetStringSelection() const;
|
|
|
|
|
|
|
|
// this is the same as SetSelection( for single-selection controls but
|
|
|
|
// reads better for multi-selection ones
|
|
|
|
void Select(int n) { SetSelection(n); }
|
|
|
|
|
2005-02-23 11:39:25 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// check that the index is valid
|
2007-07-26 09:54:14 -04:00
|
|
|
bool IsValid(unsigned int n) const { return n < GetCount(); }
|
|
|
|
bool IsValidInsert(unsigned int n) const { return n <= GetCount(); }
|
2005-02-13 14:01:17 -05:00
|
|
|
};
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxItemContainer extends wxItemContainerImmutable interface with methods
|
|
|
|
// for adding/removing items.
|
|
|
|
//
|
|
|
|
// Classes deriving from this one must override DoInsertItems() to implement
|
|
|
|
// adding items to the control. This can often be implemented more efficiently
|
|
|
|
// than simply looping over the elements and inserting them but if this is not
|
|
|
|
// the case, the generic DoInsertItemsInLoop can be used in implementation, but
|
|
|
|
// in this case DoInsertItem() needs to be overridden.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2005-02-13 14:01:17 -05:00
|
|
|
class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
|
1999-10-22 14:00:39 -04:00
|
|
|
{
|
2007-07-26 09:54:14 -04:00
|
|
|
private:
|
|
|
|
// AppendItems() and InsertItems() helpers just call DoAppend/InsertItems()
|
|
|
|
// after doing some checks
|
|
|
|
//
|
|
|
|
// NB: they're defined here so that they're inlined when used in public part
|
|
|
|
int AppendItems(const wxArrayStringsAdapter& items,
|
|
|
|
void **clientData,
|
|
|
|
wxClientDataType type)
|
|
|
|
{
|
|
|
|
if ( items.IsEmpty() )
|
|
|
|
return wxNOT_FOUND;
|
|
|
|
|
|
|
|
return DoAppendItems(items, clientData, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
int AppendItems(const wxArrayStringsAdapter& items)
|
|
|
|
{
|
|
|
|
return AppendItems(items, NULL, wxClientData_None);
|
|
|
|
}
|
|
|
|
|
|
|
|
int AppendItems(const wxArrayStringsAdapter& items, void **clientData)
|
|
|
|
{
|
2007-09-16 19:12:27 -04:00
|
|
|
wxASSERT_MSG( GetClientDataType() != wxClientData_Object,
|
2007-07-26 09:54:14 -04:00
|
|
|
_T("can't mix different types of client data") );
|
|
|
|
|
|
|
|
return AppendItems(items, clientData, wxClientData_Void);
|
|
|
|
}
|
|
|
|
|
|
|
|
int AppendItems(const wxArrayStringsAdapter& items,
|
|
|
|
wxClientData **clientData)
|
|
|
|
{
|
2007-09-16 19:12:27 -04:00
|
|
|
wxASSERT_MSG( GetClientDataType() != wxClientData_Void,
|
2007-07-26 09:54:14 -04:00
|
|
|
_T("can't mix different types of client data") );
|
|
|
|
|
|
|
|
return AppendItems(items, wx_reinterpret_cast(void **, clientData),
|
|
|
|
wxClientData_Object);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsertItems(const wxArrayStringsAdapter& items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData,
|
|
|
|
wxClientDataType type)
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( !IsSorted(), _T("can't insert items in sorted control") );
|
|
|
|
|
|
|
|
wxCHECK_MSG( pos <= GetCount(), wxNOT_FOUND,
|
|
|
|
_T("position out of range") );
|
|
|
|
|
|
|
|
// not all derived classes handle empty arrays correctly in
|
|
|
|
// DoInsertItems() and besides it really doesn't make much sense to do
|
|
|
|
// this (for append it could correspond to creating an initially empty
|
|
|
|
// control but why would anybody need to insert 0 items?)
|
|
|
|
wxCHECK_MSG( !items.IsEmpty(), wxNOT_FOUND,
|
|
|
|
_T("need something to insert") );
|
|
|
|
|
|
|
|
return DoInsertItems(items, pos, clientData, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsertItems(const wxArrayStringsAdapter& items, unsigned int pos)
|
|
|
|
{
|
|
|
|
return InsertItems(items, pos, NULL, wxClientData_None);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsertItems(const wxArrayStringsAdapter& items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData)
|
|
|
|
{
|
2007-09-16 19:12:27 -04:00
|
|
|
wxASSERT_MSG( GetClientDataType() != wxClientData_Object,
|
2007-07-26 09:54:14 -04:00
|
|
|
_T("can't mix different types of client data") );
|
|
|
|
|
|
|
|
return InsertItems(items, pos, clientData, wxClientData_Void);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsertItems(const wxArrayStringsAdapter& items,
|
|
|
|
unsigned int pos,
|
|
|
|
wxClientData **clientData)
|
|
|
|
{
|
2007-09-16 19:12:27 -04:00
|
|
|
wxASSERT_MSG( GetClientDataType() != wxClientData_Void,
|
2007-07-26 09:54:14 -04:00
|
|
|
_T("can't mix different types of client data") );
|
|
|
|
|
|
|
|
return InsertItems(items, pos,
|
|
|
|
wx_reinterpret_cast(void **, clientData),
|
|
|
|
wxClientData_Object);
|
|
|
|
}
|
|
|
|
|
1999-10-22 14:00:39 -04:00
|
|
|
public:
|
2004-01-15 08:49:22 -05:00
|
|
|
wxItemContainer() { m_clientDataItemsType = wxClientData_None; }
|
2002-01-07 16:52:28 -05:00
|
|
|
virtual ~wxItemContainer();
|
1999-10-22 14:00:39 -04:00
|
|
|
|
|
|
|
// adding items
|
|
|
|
// ------------
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
// append single item, return its position in the control (which can be
|
|
|
|
// different from the last one if the control is sorted)
|
2001-06-26 16:59:19 -04:00
|
|
|
int Append(const wxString& item)
|
2007-07-26 09:54:14 -04:00
|
|
|
{ return AppendItems(item); }
|
2001-06-26 16:59:19 -04:00
|
|
|
int Append(const wxString& item, void *clientData)
|
2007-07-26 09:54:14 -04:00
|
|
|
{ return AppendItems(item, &clientData); }
|
2001-06-26 16:59:19 -04:00
|
|
|
int Append(const wxString& item, wxClientData *clientData)
|
2007-07-26 09:54:14 -04:00
|
|
|
{ return AppendItems(item, &clientData); }
|
|
|
|
|
|
|
|
// append several items at once to the control, return the position of the
|
|
|
|
// last item appended
|
|
|
|
int Append(const wxArrayString& items)
|
|
|
|
{ return AppendItems(items); }
|
|
|
|
int Append(const wxArrayString& items, void **clientData)
|
|
|
|
{ return AppendItems(items, clientData); }
|
|
|
|
int Append(const wxArrayString& items, wxClientData **clientData)
|
|
|
|
{ return AppendItems(items, clientData); }
|
|
|
|
int Append(unsigned int n, const wxString *items)
|
|
|
|
{ return AppendItems(wxArrayStringsAdapter(n, items)); }
|
|
|
|
int Append(unsigned int n, const wxString *items, void **clientData)
|
|
|
|
{ return AppendItems(wxArrayStringsAdapter(n, items), clientData); }
|
|
|
|
int Append(unsigned int n,
|
|
|
|
const wxString *items,
|
|
|
|
wxClientData **clientData)
|
|
|
|
{ return AppendItems(wxArrayStringsAdapter(n, items), clientData); }
|
|
|
|
|
|
|
|
// only for RTTI needs (separate name)
|
|
|
|
void AppendString(const wxString& item)
|
|
|
|
{ Append(item); }
|
|
|
|
|
|
|
|
|
|
|
|
// inserting items: not for sorted controls!
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
// insert single item at the given position, return its effective position
|
2006-03-23 17:05:23 -05:00
|
|
|
int Insert(const wxString& item, unsigned int pos)
|
2007-07-26 09:54:14 -04:00
|
|
|
{ return InsertItems(item, pos); }
|
|
|
|
int Insert(const wxString& item, unsigned int pos, void *clientData)
|
|
|
|
{ return InsertItems(item, pos, &clientData); }
|
|
|
|
int Insert(const wxString& item, unsigned int pos, wxClientData *clientData)
|
|
|
|
{ return InsertItems(item, pos, &clientData); }
|
|
|
|
|
|
|
|
// insert several items at once into the control, return the index of the
|
|
|
|
// last item inserted
|
|
|
|
int Insert(const wxArrayString& items, unsigned int pos)
|
|
|
|
{ return InsertItems(items, pos); }
|
|
|
|
int Insert(const wxArrayString& items, unsigned int pos, void **clientData)
|
|
|
|
{ return InsertItems(items, pos, clientData); }
|
|
|
|
int Insert(const wxArrayString& items,
|
|
|
|
unsigned int pos,
|
|
|
|
wxClientData **clientData)
|
|
|
|
{ return InsertItems(items, pos, clientData); }
|
|
|
|
int Insert(unsigned int n, const wxString *items, unsigned int pos)
|
|
|
|
{ return InsertItems(wxArrayStringsAdapter(n, items), pos); }
|
|
|
|
int Insert(unsigned int n,
|
|
|
|
const wxString *items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData)
|
|
|
|
{ return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); }
|
|
|
|
int Insert(unsigned int n,
|
|
|
|
const wxString *items,
|
|
|
|
unsigned int pos,
|
|
|
|
wxClientData **clientData)
|
|
|
|
{ return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); }
|
|
|
|
|
|
|
|
|
|
|
|
// replacing items
|
|
|
|
// ---------------
|
|
|
|
|
|
|
|
void Set(const wxArrayString& items)
|
|
|
|
{ Clear(); Append(items); }
|
|
|
|
void Set(const wxArrayString& items, void **clientData)
|
|
|
|
{ Clear(); Append(items, clientData); }
|
|
|
|
void Set(const wxArrayString& items, wxClientData **clientData)
|
|
|
|
{ Clear(); Append(items, clientData); }
|
|
|
|
void Set(unsigned int n, const wxString *items)
|
|
|
|
{ Clear(); Append(n, items); }
|
|
|
|
void Set(unsigned int n, const wxString *items, void **clientData)
|
|
|
|
{ Clear(); Append(n, items, clientData); }
|
|
|
|
void Set(unsigned int n, const wxString *items, wxClientData **clientData)
|
|
|
|
{ Clear(); Append(n, items, clientData); }
|
2003-05-09 08:58:28 -04:00
|
|
|
|
1999-10-22 14:00:39 -04:00
|
|
|
// deleting items
|
|
|
|
// --------------
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
void Clear();
|
|
|
|
void Delete(unsigned int pos);
|
1999-10-22 14:00:39 -04:00
|
|
|
|
|
|
|
|
2007-09-16 19:12:27 -04:00
|
|
|
// various accessors
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
// The control may maintain its items in a sorted order in which case
|
|
|
|
// items are automatically inserted at the right position when they are
|
|
|
|
// inserted or appended. Derived classes have to override this method if
|
|
|
|
// they implement sorting, typically by returning HasFlag(wxXX_SORT)
|
|
|
|
virtual bool IsSorted() const { return false; }
|
|
|
|
|
|
|
|
|
1999-10-22 14:00:39 -04:00
|
|
|
// client data stuff
|
2007-07-26 09:54:14 -04:00
|
|
|
// -----------------
|
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
void SetClientData(unsigned int n, void* clientData);
|
|
|
|
void* GetClientData(unsigned int n) const;
|
1999-10-22 14:00:39 -04:00
|
|
|
|
2006-03-23 17:05:23 -05:00
|
|
|
void SetClientObject(unsigned int n, wxClientData* clientData);
|
|
|
|
wxClientData* GetClientObject(unsigned int n) const;
|
1999-10-22 14:00:39 -04:00
|
|
|
|
2007-09-16 19:12:27 -04:00
|
|
|
// return the type of client data stored in this control: usually it just
|
|
|
|
// returns m_clientDataItemsType but must be overridden in the controls
|
|
|
|
// which delegate their client data storage to another one (e.g. wxChoice
|
|
|
|
// in wxUniv which stores data in wxListBox which it uses anyhow); don't
|
|
|
|
// forget to override SetClientDataType() if you override this one
|
|
|
|
//
|
|
|
|
// NB: for this to work no code should ever access m_clientDataItemsType
|
|
|
|
// directly but only via this function!
|
|
|
|
virtual wxClientDataType GetClientDataType() const
|
|
|
|
{ return m_clientDataItemsType; }
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
bool HasClientData() const
|
2007-09-16 19:12:27 -04:00
|
|
|
{ return GetClientDataType() != wxClientData_None; }
|
1999-10-22 14:00:39 -04:00
|
|
|
bool HasClientObjectData() const
|
2007-09-16 19:12:27 -04:00
|
|
|
{ return GetClientDataType() == wxClientData_Object; }
|
1999-10-22 14:00:39 -04:00
|
|
|
bool HasClientUntypedData() const
|
2007-09-16 19:12:27 -04:00
|
|
|
{ return GetClientDataType() == wxClientData_Void; }
|
2007-07-26 09:54:14 -04:00
|
|
|
|
1999-10-22 14:00:39 -04:00
|
|
|
protected:
|
2007-07-26 09:54:14 -04:00
|
|
|
// there is usually no need to override this method but you can do it if it
|
|
|
|
// is more convenient to only do "real" insertions in DoInsertItems() and
|
|
|
|
// to implement items appending here (in which case DoInsertItems() should
|
|
|
|
// call this method if pos == GetCount() as it can still be called in this
|
|
|
|
// case if public Insert() is called with such position)
|
|
|
|
virtual int DoAppendItems(const wxArrayStringsAdapter& items,
|
|
|
|
void **clientData,
|
|
|
|
wxClientDataType type)
|
|
|
|
{
|
|
|
|
return DoInsertItems(items, GetCount(), clientData, type);
|
|
|
|
}
|
1999-10-22 14:00:39 -04:00
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
// this method must be implemented to insert the items into the control at
|
|
|
|
// position pos which can be GetCount() meaning that the items should be
|
|
|
|
// appended; for the sorted controls the position can be ignored
|
|
|
|
//
|
|
|
|
// the derived classes typically use AssignNewItemClientData() to
|
|
|
|
// associate the data with the items as they're being inserted
|
|
|
|
//
|
|
|
|
// the method should return the index of the position the last item was
|
|
|
|
// inserted into or wxNOT_FOUND if an error occurred
|
|
|
|
virtual int DoInsertItems(const wxArrayStringsAdapter & items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData,
|
|
|
|
wxClientDataType type) = 0;
|
|
|
|
|
|
|
|
// before the client data is set for the first time for the control which
|
|
|
|
// hadn't had it before, DoInitItemClientData() is called which gives the
|
|
|
|
// derived class the possibility to initialize its client data storage only
|
|
|
|
// when client data is really used
|
|
|
|
virtual void DoInitItemClientData() { }
|
|
|
|
virtual void DoSetItemClientData(unsigned int n, void *clientData) = 0;
|
|
|
|
virtual void *DoGetItemClientData(unsigned int n) const = 0;
|
|
|
|
|
|
|
|
virtual void DoClear() = 0;
|
|
|
|
virtual void DoDeleteOneItem(unsigned int pos) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// methods useful for the derived classes which don't have any better way
|
|
|
|
// of adding multiple items to the control than doing it one by one: such
|
|
|
|
// classes should call DoInsertItemsInLoop() from their DoInsert() and
|
|
|
|
// override DoInsertOneItem() to perform the real insertion
|
|
|
|
virtual int DoInsertOneItem(const wxString& item, unsigned int pos);
|
|
|
|
int DoInsertItemsInLoop(const wxArrayStringsAdapter& items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData,
|
|
|
|
wxClientDataType type);
|
|
|
|
|
|
|
|
|
|
|
|
// helper for DoInsertItems(): n is the index into clientData, pos is the
|
|
|
|
// position of the item in the control
|
|
|
|
void AssignNewItemClientData(unsigned int pos,
|
|
|
|
void **clientData,
|
|
|
|
unsigned int n,
|
|
|
|
wxClientDataType type);
|
|
|
|
|
|
|
|
// free the client object associated with the item at given position and
|
|
|
|
// set it to NULL (must only be called if HasClientObjectData())
|
|
|
|
void ResetItemClientObject(unsigned int n);
|
1999-10-22 14:00:39 -04:00
|
|
|
|
2007-09-16 19:12:27 -04:00
|
|
|
// set the type of the client data stored in this control: override this if
|
|
|
|
// you override GetClientDataType()
|
|
|
|
virtual void SetClientDataType(wxClientDataType clientDataItemsType)
|
|
|
|
{
|
|
|
|
m_clientDataItemsType = clientDataItemsType;
|
|
|
|
}
|
2006-05-06 11:48:27 -04:00
|
|
|
|
2007-09-16 19:12:27 -04:00
|
|
|
private:
|
1999-10-22 14:00:39 -04:00
|
|
|
// the type of the client data for the items
|
|
|
|
wxClientDataType m_clientDataItemsType;
|
|
|
|
};
|
|
|
|
|
2003-09-20 14:34:57 -04:00
|
|
|
// this macro must (unfortunately) be used in any class deriving from both
|
|
|
|
// wxItemContainer and wxControl because otherwise there is ambiguity when
|
|
|
|
// calling GetClientXXX() functions -- the compiler can't choose between the
|
|
|
|
// two versions
|
|
|
|
#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \
|
|
|
|
void SetClientData(void *data) \
|
2006-10-22 18:09:16 -04:00
|
|
|
{ wxEvtHandler::SetClientData(data); } \
|
2003-09-20 14:34:57 -04:00
|
|
|
void *GetClientData() const \
|
2006-10-22 18:09:16 -04:00
|
|
|
{ return wxEvtHandler::GetClientData(); } \
|
2003-09-20 14:34:57 -04:00
|
|
|
void SetClientObject(wxClientData *data) \
|
2006-10-22 18:09:16 -04:00
|
|
|
{ wxEvtHandler::SetClientObject(data); } \
|
2003-09-20 14:34:57 -04:00
|
|
|
wxClientData *GetClientObject() const \
|
2006-10-22 18:09:16 -04:00
|
|
|
{ return wxEvtHandler::GetClientObject(); } \
|
2006-03-23 17:05:23 -05:00
|
|
|
void SetClientData(unsigned int n, void* clientData) \
|
2003-09-20 14:34:57 -04:00
|
|
|
{ wxItemContainer::SetClientData(n, clientData); } \
|
2006-03-23 17:05:23 -05:00
|
|
|
void* GetClientData(unsigned int n) const \
|
2003-09-20 14:34:57 -04:00
|
|
|
{ return wxItemContainer::GetClientData(n); } \
|
2006-03-23 17:05:23 -05:00
|
|
|
void SetClientObject(unsigned int n, wxClientData* clientData) \
|
2003-09-20 14:34:57 -04:00
|
|
|
{ wxItemContainer::SetClientObject(n, clientData); } \
|
2006-03-23 17:05:23 -05:00
|
|
|
wxClientData* GetClientObject(unsigned int n) const \
|
2003-09-20 14:34:57 -04:00
|
|
|
{ return wxItemContainer::GetClientObject(n); }
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
class WXDLLEXPORT wxControlWithItemsBase : public wxControl,
|
|
|
|
public wxItemContainer
|
2001-06-26 16:59:19 -04:00
|
|
|
{
|
|
|
|
public:
|
2007-07-26 09:54:14 -04:00
|
|
|
wxControlWithItemsBase() { }
|
2003-09-20 14:34:57 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// we have to redefine these functions here to avoid ambiguities in classes
|
|
|
|
// deriving from us which would arise otherwise because both base classses
|
|
|
|
// have the methods with the same names - hopefully, a smart compiler can
|
|
|
|
// optimize away these simple inline wrappers so we don't suffer much from
|
|
|
|
// this
|
2003-09-20 14:34:57 -04:00
|
|
|
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
2003-07-21 20:24:07 -04:00
|
|
|
|
2003-10-16 06:00:12 -04:00
|
|
|
// usually the controls like list/combo boxes have their own background
|
|
|
|
// colour
|
|
|
|
virtual bool ShouldInheritColours() const { return false; }
|
|
|
|
|
2004-05-03 08:40:29 -04:00
|
|
|
protected:
|
2006-05-06 11:48:27 -04:00
|
|
|
// fill in the client object or data field of the event as appropriate
|
|
|
|
//
|
|
|
|
// calls InitCommandEvent() and, if n != wxNOT_FOUND, also sets the per
|
|
|
|
// item client data
|
|
|
|
void InitCommandEventWithItems(wxCommandEvent& event, int n);
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
private:
|
2007-07-26 09:54:14 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxControlWithItemsBase)
|
2001-06-26 16:59:19 -04:00
|
|
|
};
|
|
|
|
|
2007-07-26 09:54:14 -04:00
|
|
|
// define the platform-specific wxControlWithItems class
|
|
|
|
#if defined(__WXMSW__)
|
|
|
|
#include "wx/msw/ctrlsub.h"
|
|
|
|
#elif defined(__WXMOTIF__)
|
|
|
|
#include "wx/motif/ctrlsub.h"
|
|
|
|
#else
|
2007-07-31 18:03:08 -04:00
|
|
|
class WXDLLEXPORT wxControlWithItems : public wxControlWithItemsBase
|
2007-07-26 09:54:14 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxControlWithItems() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_ABSTRACT_CLASS(wxControlWithItems)
|
|
|
|
DECLARE_NO_COPY_CLASS(wxControlWithItems)
|
|
|
|
};
|
|
|
|
#endif
|
2005-02-13 12:08:27 -05:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_CONTROLS
|
1999-10-22 14:00:39 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // _WX_CTRLSUB_H_BASE_
|