1///////////////////////////////////////////////////////////////////////////// 2// Name: wx/mac/classic/listbox.h 3// Purpose: wxListBox class 4// Author: Stefan Csomor 5// Modified by: 6// Created: 1998-01-01 7// RCS-ID: $Id: listbox.h 38319 2006-03-23 22:05:23Z VZ $ 8// Copyright: (c) Stefan Csomor 9// Licence: wxWindows licence 10///////////////////////////////////////////////////////////////////////////// 11 12 13#ifndef _WX_LISTBOX_H_ 14#define _WX_LISTBOX_H_ 15 16// ---------------------------------------------------------------------------- 17// simple types 18// ---------------------------------------------------------------------------- 19#include "wx/dynarray.h" 20#include "wx/arrstr.h" 21 22#if wxUSE_OWNER_DRAWN 23 class WXDLLEXPORT wxOwnerDrawn; 24 25 // define the array of list box items 26 #include "wx/dynarray.h" 27 28 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); 29#endif // wxUSE_OWNER_DRAWN 30 31// forward decl for GetSelections() 32class wxArrayInt; 33 34// List box item 35 36WX_DEFINE_ARRAY( char * , wxListDataArray ) ; 37 38// ---------------------------------------------------------------------------- 39// List box control 40// ---------------------------------------------------------------------------- 41 42class WXDLLEXPORT wxListBox : public wxListBoxBase 43{ 44public: 45 // ctors and such 46 wxListBox(); 47 wxListBox(wxWindow *parent, wxWindowID id, 48 const wxPoint& pos = wxDefaultPosition, 49 const wxSize& size = wxDefaultSize, 50 int n = 0, const wxString choices[] = NULL, 51 long style = 0, 52 const wxValidator& validator = wxDefaultValidator, 53 const wxString& name = wxListBoxNameStr) 54 { 55 Create(parent, id, pos, size, n, choices, style, validator, name); 56 } 57 wxListBox(wxWindow *parent, wxWindowID id, 58 const wxPoint& pos, 59 const wxSize& size, 60 const wxArrayString& choices, 61 long style = 0, 62 const wxValidator& validator = wxDefaultValidator, 63 const wxString& name = wxListBoxNameStr) 64 { 65 Create(parent, id, pos, size, choices, style, validator, name); 66 } 67 68 bool Create(wxWindow *parent, wxWindowID id, 69 const wxPoint& pos = wxDefaultPosition, 70 const wxSize& size = wxDefaultSize, 71 int n = 0, const wxString choices[] = NULL, 72 long style = 0, 73 const wxValidator& validator = wxDefaultValidator, 74 const wxString& name = wxListBoxNameStr); 75 bool Create(wxWindow *parent, wxWindowID id, 76 const wxPoint& pos, 77 const wxSize& size, 78 const wxArrayString& choices, 79 long style = 0, 80 const wxValidator& validator = wxDefaultValidator, 81 const wxString& name = wxListBoxNameStr); 82 83 virtual ~wxListBox(); 84 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL); 85 86 // implement base class pure virtuals 87 virtual void Clear(); 88 virtual void Delete(unsigned int n); 89 90 virtual unsigned int GetCount() const; 91 virtual wxString GetString(unsigned int n) const; 92 virtual void SetString(unsigned int n, const wxString& s); 93 virtual int FindString(const wxString& s, bool bCase = false) const; 94 95 virtual bool IsSelected(int n) const; 96 virtual void DoSetSelection(int n, bool select); 97 virtual int GetSelection() const; 98 virtual int GetSelections(wxArrayInt& aSelections) const; 99 100 virtual int DoAppend(const wxString& item); 101 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos); 102 virtual void DoSetItems(const wxArrayString& items, void **clientData); 103 104 virtual void DoSetFirstItem(int n); 105 106 virtual void DoSetItemClientData(unsigned int n, void* clientData); 107 virtual void* DoGetItemClientData(unsigned int n) const; 108 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); 109 virtual wxClientData* DoGetItemClientObject(unsigned int n) const; 110 virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ; 111 112 // wxCheckListBox support 113#if wxUSE_OWNER_DRAWN 114 // plug-in for derived classes 115 virtual wxOwnerDrawn *CreateItem(size_t n); 116 117 // allows to get the item and use SetXXX functions to set it's appearance 118 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } 119 120 // get the index of the given item 121 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } 122#endif // wxUSE_OWNER_DRAWN 123 124 // Windows callbacks 125 126 virtual void SetupColours(); 127 virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ; 128 virtual bool MacCanFocus() const { return true ; } 129 void OnChar(wxKeyEvent& event); 130 131 void* m_macList ; 132 wxArrayString m_stringArray ; 133 wxListDataArray m_dataArray ; 134 wxArrayInt m_selectionPreImage ; 135 void MacSetRedraw( bool doDraw ) ; 136protected: 137 void MacDestroy() ; 138 void MacDelete( int n ) ; 139 void MacInsert( int n , const wxString& item) ; 140 void MacAppend( const wxString& item) ; 141 void MacSet( int n , const wxString& item ) ; 142 void MacClear() ; 143 void MacSetSelection( int n , bool select ) ; 144 int MacGetSelection() const ; 145 int MacGetSelections(wxArrayInt& aSelections) const ; 146 bool MacIsSelected( int n ) const ; 147 void MacScrollTo( int n ) ; 148 void OnSize( wxSizeEvent &size ) ; 149 void MacDoClick() ; 150 void MacDoDoubleClick() ; 151 152 // do we have multiple selections? 153 bool HasMultipleSelection() const; 154 155 // free memory (common part of Clear() and dtor) 156 // prevent collision with some BSD definitions of macro Free() 157 void FreeData(); 158 159 unsigned int m_noItems; 160 int m_selected; 161 wxString m_typeIn ; 162 long m_lastTypeIn ; 163 164 virtual wxSize DoGetBestSize() const; 165 166#if wxUSE_OWNER_DRAWN 167 // control items 168 wxListBoxItemsArray m_aItems; 169#endif 170 171private: 172 DECLARE_DYNAMIC_CLASS(wxListBox) 173 DECLARE_EVENT_TABLE() 174}; 175 176#endif 177 // _WX_LISTBOX_H_ 178