1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-09-27 12:54:43 -04:00
|
|
|
// Name: wx/gtk/choice.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-26 05:56:58 -05:00
|
|
|
// Id: $Id$
|
1998-10-24 13:12:05 -04:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GTKCHOICEH__
|
|
|
|
#define __GTKCHOICEH__
|
|
|
|
|
2003-07-20 15:32:44 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxSortedArrayString;
|
2004-01-31 13:21:45 -05:00
|
|
|
class WXDLLIMPEXP_BASE wxArrayString;
|
2003-07-20 15:32:44 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxChoice
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-06 03:50:52 -05:00
|
|
|
public:
|
1999-03-16 13:54:24 -05:00
|
|
|
wxChoice();
|
|
|
|
wxChoice( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr )
|
|
|
|
{
|
1999-10-22 09:12:04 -04:00
|
|
|
m_strings = (wxSortedArrayString *)NULL;
|
|
|
|
|
1999-03-16 13:54:24 -05:00
|
|
|
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
|
|
}
|
2004-01-31 13:21:45 -05:00
|
|
|
wxChoice( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr )
|
|
|
|
{
|
|
|
|
m_strings = (wxSortedArrayString *)NULL;
|
|
|
|
|
|
|
|
Create(parent, id, pos, size, choices, style, validator, name);
|
|
|
|
}
|
1999-03-16 13:54:24 -05:00
|
|
|
~wxChoice();
|
|
|
|
bool Create( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = (wxString *) NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr );
|
2004-01-31 13:21:45 -05:00
|
|
|
bool Create( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr );
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-10-18 11:45:28 -04:00
|
|
|
// implement base class pure virtuals
|
1999-03-16 13:54:24 -05:00
|
|
|
void Delete(int n);
|
1999-10-18 11:45:28 -04:00
|
|
|
void Clear();
|
|
|
|
|
|
|
|
int GetSelection() const;
|
2005-08-17 10:22:41 -04:00
|
|
|
int GetCurrentSelection() const { return GetSelection(); }
|
1999-10-18 11:45:28 -04:00
|
|
|
void SetSelection( int n );
|
1999-03-16 13:54:24 -05:00
|
|
|
|
1999-10-18 11:45:28 -04:00
|
|
|
virtual int GetCount() const;
|
2005-09-27 12:54:43 -04:00
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
1999-03-16 13:54:24 -05:00
|
|
|
wxString GetString( int n ) const;
|
1999-10-22 14:00:39 -04:00
|
|
|
void SetString( int n, const wxString& string );
|
1999-03-16 13:54:24 -05:00
|
|
|
|
2004-05-06 13:26:25 -04:00
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
|
|
|
|
1999-11-22 14:44:25 -05:00
|
|
|
protected:
|
1999-10-22 09:12:04 -04:00
|
|
|
wxList m_clientList; // contains the client data for the items
|
1999-03-16 13:54:24 -05:00
|
|
|
|
2004-06-14 13:34:00 -04:00
|
|
|
void DoApplyWidgetStyle(GtkRcStyle *style);
|
1999-10-18 11:45:28 -04:00
|
|
|
virtual int DoAppend(const wxString& item);
|
2003-05-09 08:58:28 -04:00
|
|
|
virtual int DoInsert(const wxString& item, int pos);
|
1999-10-18 11:45:28 -04:00
|
|
|
|
1999-10-22 14:00:39 -04:00
|
|
|
virtual void DoSetItemClientData( int n, void* clientData );
|
|
|
|
virtual void* DoGetItemClientData( int n ) const;
|
|
|
|
virtual void DoSetItemClientObject( int n, wxClientData* clientData );
|
|
|
|
virtual wxClientData* DoGetItemClientObject( int n ) const;
|
1999-10-19 06:51:48 -04:00
|
|
|
|
1999-11-19 16:01:20 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
|
|
|
|
2003-07-08 07:18:42 -04:00
|
|
|
virtual bool IsOwnGtkWindow( GdkWindow *window );
|
2004-05-06 13:26:25 -04:00
|
|
|
|
1999-10-11 06:05:36 -04:00
|
|
|
private:
|
1999-10-22 09:12:04 -04:00
|
|
|
// common part of Create() and DoAppend()
|
2003-05-09 08:58:28 -04:00
|
|
|
int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
|
1999-10-22 09:12:04 -04:00
|
|
|
|
|
|
|
// this array is only used for controls with wxCB_SORT style, so only
|
|
|
|
// allocate it if it's needed (hence using pointer)
|
|
|
|
wxSortedArrayString *m_strings;
|
|
|
|
|
2004-12-18 08:13:52 -05:00
|
|
|
public:
|
2005-09-27 12:54:43 -04:00
|
|
|
// this circumvents a GTK+ 2.0 bug so that the selection is
|
|
|
|
// invalidated properly
|
2004-12-06 07:47:06 -05:00
|
|
|
int m_selection_hack;
|
2004-12-18 08:13:52 -05:00
|
|
|
|
|
|
|
private:
|
1999-10-11 06:05:36 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxChoice)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif // __GTKCHOICEH__
|