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