1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/listbox.h
3 // Purpose: wxListBox class declaration
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef __GTKLISTBOXH__
10 #define __GTKLISTBOXH__
14 typedef struct _GtkList GtkList
;
16 class WXDLLIMPEXP_FWD_BASE wxSortedArrayString
;
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxListBox
: public wxListBoxBase
27 wxListBox( wxWindow
*parent
, wxWindowID id
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
30 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
& name
= wxListBoxNameStr
)
35 #if wxUSE_CHECKLISTBOX
36 m_hasCheckBoxes
= false;
37 #endif // wxUSE_CHECKLISTBOX
38 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
40 wxListBox( wxWindow
*parent
, wxWindowID id
,
43 const wxArrayString
& choices
,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxListBoxNameStr
)
48 #if wxUSE_CHECKLISTBOX
49 m_hasCheckBoxes
= false;
50 #endif // wxUSE_CHECKLISTBOX
51 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
55 bool Create(wxWindow
*parent
, wxWindowID id
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
58 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxListBoxNameStr
);
62 bool Create(wxWindow
*parent
, wxWindowID id
,
65 const wxArrayString
& choices
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
& name
= wxListBoxNameStr
);
70 // implement base class pure virtuals
71 virtual void DoClear();
72 virtual void DoDeleteOneItem(unsigned int n
);
74 virtual unsigned int GetCount() const;
75 virtual wxString
GetString(unsigned int n
) const;
76 virtual void SetString(unsigned int n
, const wxString
& s
);
77 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
79 virtual bool IsSelected(int n
) const;
80 virtual void DoSetSelection(int n
, bool select
);
81 virtual int GetSelection() const;
82 virtual int GetSelections(wxArrayInt
& aSelections
) const;
84 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
86 void **clientData
, wxClientDataType type
);
88 virtual void DoSetFirstItem(int n
);
90 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
91 virtual void* DoGetItemClientData(unsigned int n
) const;
93 static wxVisualAttributes
94 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
96 // implementation from now on
98 void GtkAddItem( const wxString
&item
, int pos
=-1 );
99 int GtkGetIndex( GtkWidget
*item
) const;
100 GtkWidget
*GetConnectWidget();
101 bool IsOwnGtkWindow( GdkWindow
*window
);
102 void DoApplyWidgetStyle(GtkRcStyle
*style
);
103 void OnInternalIdle();
106 void ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
);
107 #endif // wxUSE_TOOLTIPS
112 #if wxUSE_CHECKLISTBOX
113 bool m_hasCheckBoxes
;
114 #endif // wxUSE_CHECKLISTBOX
119 virtual void FixUpMouseEvent(GtkWidget
*widget
, wxCoord
& x
, wxCoord
& y
);
122 virtual wxSize
DoGetBestSize() const;
124 // return the string label for the given item
125 wxString
GetRealLabel(struct _GList
*item
) const;
127 // Widgets that use the style->base colour for the BG colour should
128 // override this and return true.
129 virtual bool UseGTKStyleBase() const { return true; }
132 // this array is only used for controls with wxCB_SORT style, so only
133 // allocate it if it's needed (hence using pointer)
134 wxSortedArrayString
*m_strings
;
136 DECLARE_DYNAMIC_CLASS(wxListBox
)
139 #endif // __GTKLISTBOXH__