applied patch #931719: "ESC closes dialog instead of combobox dropdown" (closes patch...
[wxWidgets.git] / include / wx / msw / choice.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: choice.h
3 // Purpose: wxChoice class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin to derive from wxChoiceBase
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CHOICE_H_
13 #define _WX_CHOICE_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choice.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // Choice item
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxChoice : public wxChoiceBase
24 {
25 public:
26 // ctors
27 wxChoice() { }
28 virtual ~wxChoice();
29
30 wxChoice(wxWindow *parent,
31 wxWindowID id,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 int n = 0, const wxString choices[] = NULL,
35 long style = 0,
36 const wxValidator& validator = wxDefaultValidator,
37 const wxString& name = wxChoiceNameStr)
38 {
39 Create(parent, id, pos, size, n, choices, style, validator, name);
40 }
41 wxChoice(wxWindow *parent,
42 wxWindowID id,
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 = wxChoiceNameStr)
49 {
50 Create(parent, id, pos, size, choices, style, validator, name);
51 }
52
53 bool Create(wxWindow *parent,
54 wxWindowID id,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 int n = 0, const wxString choices[] = NULL,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxChoiceNameStr);
61 bool Create(wxWindow *parent,
62 wxWindowID id,
63 const wxPoint& pos,
64 const wxSize& size,
65 const wxArrayString& choices,
66 long style = 0,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxChoiceNameStr);
69
70 // implement base class pure virtuals
71 virtual int DoAppend(const wxString& item);
72 virtual int DoInsert(const wxString& item, int pos);
73 virtual void Delete(int n);
74 virtual void Clear();
75
76 virtual int GetCount() const;
77 virtual int GetSelection() const;
78 virtual void SetSelection(int n);
79
80 virtual int FindString(const wxString& s) const;
81 virtual wxString GetString(int n) const;
82 virtual void SetString(int n, const wxString& s);
83
84 // MSW only
85 virtual bool MSWCommand(WXUINT param, WXWORD id);
86 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
87 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
88 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
89
90 protected:
91 virtual void DoMoveWindow(int x, int y, int width, int height);
92 virtual void DoSetItemClientData( int n, void* clientData );
93 virtual void* DoGetItemClientData( int n ) const;
94 virtual void DoSetItemClientObject( int n, wxClientData* clientData );
95 virtual wxClientData* DoGetItemClientObject( int n ) const;
96
97 // MSW implementation
98 virtual wxSize DoGetBestSize() const;
99 virtual void DoGetSize(int *w, int *h) const;
100 virtual void DoSetSize(int x, int y,
101 int width, int height,
102 int sizeFlags = wxSIZE_AUTO);
103
104 virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
105
106 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
107
108 // update the height of the drop down list to fit the number of items we
109 // have (without changing the visible height)
110 void UpdateVisibleHeight();
111
112 // create and initialize the control
113 bool CreateAndInit(wxWindow *parent, wxWindowID id,
114 const wxPoint& pos,
115 const wxSize& size,
116 int n, const wxString choices[],
117 long style,
118 const wxValidator& validator,
119 const wxString& name);
120
121 // free all memory we have (used by Clear() and dtor)
122 void Free();
123
124 DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice)
125 };
126
127 #endif // _WX_CHOICE_H_