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