]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/listbox.h
added HTML printing
[wxWidgets.git] / include / wx / os2 / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.h
3 // Purpose: wxListBox class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
14
15 #include "wx/control.h"
16
17 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr;
18
19 #if wxUSE_OWNER_DRAWN
20 class WXDLLEXPORT wxOwnerDrawn;
21
22 // define the array of list box items
23 #include <wx/dynarray.h>
24
25 WX_DEFINE_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
26 #endif
27
28 // forward decl for GetSelections()
29 class WXDLLEXPORT wxArrayInt;
30
31 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
32
33 // List box item
34 class WXDLLEXPORT wxListBox: public wxControl
35 {
36 DECLARE_DYNAMIC_CLASS(wxListBox)
37 public:
38
39 wxListBox();
40 inline wxListBox(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 int n = 0, const wxString choices[] = NULL,
44 long style = 0,
45 const wxValidator& validator = wxDefaultValidator,
46 const wxString& name = wxListBoxNameStr)
47 {
48 Create(parent, id, pos, size, n, choices, style, validator, name);
49 }
50
51 bool Create(wxWindow *parent, wxWindowID id,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 int n = 0, const wxString choices[] = NULL,
55 long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxListBoxNameStr);
58
59 ~wxListBox();
60
61 bool OS2Command(WXUINT param, WXWORD id);
62
63 #if wxUSE_OWNER_DRAWN
64 bool OS2OnMeasure(WXMEASUREITEMSTRUCT *item);
65 bool OS2OnDraw(WXDRAWITEMSTRUCT *item);
66
67 // plug-in for derived classes
68 virtual wxOwnerDrawn *CreateItem(size_t n);
69
70 // allows to get the item and use SetXXX functions to set it's appearance
71 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
72
73 // get the index of the given item
74 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
75 #endif // wxUSE_OWNER_DRAWN
76
77 virtual void Append(const wxString& item);
78 virtual void Append(const wxString& item, void *clientData);
79 virtual void Set(int n, const wxString* choices, char **clientData = NULL);
80 virtual int FindString(const wxString& s) const ;
81 virtual void Clear();
82 virtual void SetSelection(int n, bool select = TRUE);
83
84 virtual void Deselect(int n);
85
86 // For single choice list item only
87 virtual int GetSelection() const ;
88 virtual void Delete(int n);
89 virtual void *GetClientData(int n) const ;
90 virtual void SetClientData(int n, void *clientData);
91 virtual void SetString(int n, const wxString& s);
92
93 // For single or multiple choice list item
94 virtual int GetSelections(wxArrayInt& aSelections) const;
95 virtual bool Selected(int n) const ;
96 virtual wxString GetString(int n) const ;
97
98 // Set the specified item at the first visible item
99 // or scroll to max range.
100 virtual void SetFirstItem(int n) ;
101 virtual void SetFirstItem(const wxString& s) ;
102
103 virtual void InsertItems(int nItems, const wxString items[], int pos);
104
105 virtual wxString GetStringSelection() const ;
106 virtual bool SetStringSelection(const wxString& s, bool flag = TRUE);
107 virtual int Number() const ;
108
109 void Command(wxCommandEvent& event);
110
111 // OS/2-PM-specific code to set the horizontal extent of
112 // the listbox, if necessary. If s is non-NULL, it's
113 // used to calculate the horizontal extent.
114 // Otherwise, all strings are used.
115 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
116
117 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
118 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
119
120 virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
121 virtual void SetupColours();
122
123 protected:
124 int m_noItems;
125 int m_selected;
126
127 virtual wxSize DoGetBestSize();
128
129 #if wxUSE_OWNER_DRAWN
130 // control items
131 wxListBoxItemsArray m_aItems;
132 #endif
133 private:
134 //Virtual function hiding suppression, do not use
135 virtual wxControl *CreateItem(const wxItemResource* childResource,
136 const wxItemResource* parentResource,
137 const wxResourceTable *table = (const wxResourceTable *) NULL)
138 { return(wxWindowBase::CreateItem(childResource, parentResource, table));};
139 };
140
141 #endif
142 // _WX_LISTBOX_H_