]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/listbox.h
Change GetC to return an int so that it can return wxEOF on error.
[wxWidgets.git] / include / wx / cocoa / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/listbox.h
3 // Purpose: wxListBox class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_LISTBOX_H__
13 #define __WX_COCOA_LISTBOX_H__
14
15 #include "wx/cocoa/NSTableView.h"
16
17 #include "wx/dynarray.h"
18
19 // ========================================================================
20 // wxListBox
21 // ========================================================================
22 class WXDLLEXPORT wxListBox: public wxListBoxBase, protected wxCocoaNSTableView
23 {
24 DECLARE_DYNAMIC_CLASS(wxListBox)
25 DECLARE_EVENT_TABLE()
26 WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
27 // ------------------------------------------------------------------------
28 // initialization
29 // ------------------------------------------------------------------------
30 public:
31 wxListBox() { m_cocoaItems = NULL; m_cocoaDataSource = NULL; }
32 wxListBox(wxWindow *parent, wxWindowID winid,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize,
35 int n = 0, const wxString choices[] = NULL,
36 long style = 0,
37 const wxValidator& validator = wxDefaultValidator,
38 const wxString& name = wxListBoxNameStr)
39 {
40 Create(parent, winid, pos, size, n, choices, style, validator, name);
41 }
42 wxListBox(wxWindow *parent, wxWindowID winid,
43 const wxPoint& pos,
44 const wxSize& size,
45 const wxArrayString& choices,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxListBoxNameStr)
49 {
50 Create(parent, winid, pos, size, choices, style, validator, name);
51 }
52
53 bool Create(wxWindow *parent, wxWindowID winid,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 int n = 0, const wxString choices[] = NULL,
57 long style = 0,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString& name = wxListBoxNameStr);
60 bool Create(wxWindow *parent, wxWindowID winid,
61 const wxPoint& pos,
62 const wxSize& size,
63 const wxArrayString& choices,
64 long style = 0,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = wxListBoxNameStr);
67 virtual ~wxListBox();
68
69 // ------------------------------------------------------------------------
70 // Cocoa callbacks
71 // ------------------------------------------------------------------------
72 protected:
73 virtual int CocoaDataSource_numberOfRows();
74 virtual struct objc_object* CocoaDataSource_objectForTableColumn(
75 WX_NSTableColumn tableColumn, int rowIndex);
76 WX_NSMutableArray m_cocoaItems;
77 wxArrayPtrVoid m_itemClientData;
78 struct objc_object *m_cocoaDataSource;
79 // ------------------------------------------------------------------------
80 // Implementation
81 // ------------------------------------------------------------------------
82 public:
83 // pure virtuals from wxListBoxBase
84 virtual bool IsSelected(int n) const;
85 virtual int GetSelections(wxArrayInt& aSelections) const;
86 protected:
87 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
88 virtual void DoSetItems(const wxArrayString& items, void **clientData);
89 virtual void DoSetFirstItem(int n);
90 virtual void DoSetSelection(int n, bool select);
91
92 // pure virtuals from wxItemContainer
93 public:
94 // deleting items
95 virtual void Clear();
96 virtual void Delete(unsigned int n);
97 // accessing strings
98 virtual unsigned int GetCount() const;
99 virtual wxString GetString(unsigned int n) const;
100 virtual void SetString(unsigned int n, const wxString& s);
101 virtual int FindString(const wxString& s, bool bCase = false) const;
102 // selection
103 virtual int GetSelection() const;
104 protected:
105 virtual int DoAppend(const wxString& item);
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 };
111
112 #endif // __WX_COCOA_LISTBOX_H__