1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/choicdgg.h
3 // Purpose: Generic choice dialogs
4 // Author: Julian Smart
5 // Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __CHOICEDLGH_G__
13 #define __CHOICEDLGH_G__
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "choicdgg.h"
19 #include "wx/dynarray.h"
20 #include "wx/dialog.h"
22 class WXDLLEXPORT wxListBox
;
24 // ----------------------------------------------------------------------------
25 // some (ugly...) constants
26 // ----------------------------------------------------------------------------
28 #define wxCHOICE_HEIGHT 150
29 #define wxCHOICE_WIDTH 200
31 #define wxCHOICEDLG_STYLE \
32 (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
34 // ----------------------------------------------------------------------------
35 // wxAnyChoiceDialog: a base class for dialogs containing a listbox
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxAnyChoiceDialog
: public wxDialog
43 wxAnyChoiceDialog(wxWindow
*parent
,
44 const wxString
& message
,
45 const wxString
& caption
,
46 int n
, const wxString
*choices
,
47 long styleDlg
= wxCHOICEDLG_STYLE
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 long styleLbox
= wxLB_ALWAYS_SB
);
51 bool Create(wxWindow
*parent
,
52 const wxString
& message
,
53 const wxString
& caption
,
54 int n
, const wxString
*choices
,
55 long styleDlg
= wxCHOICEDLG_STYLE
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 long styleLbox
= wxLB_ALWAYS_SB
);
62 DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog
)
65 // ----------------------------------------------------------------------------
66 // wxSingleChoiceDialog: a dialog with single selection listbox
67 // ----------------------------------------------------------------------------
69 class WXDLLEXPORT wxSingleChoiceDialog
: public wxAnyChoiceDialog
72 wxSingleChoiceDialog();
74 wxSingleChoiceDialog(wxWindow
*parent
,
75 const wxString
& message
,
76 const wxString
& caption
,
78 const wxString
*choices
,
79 char **clientData
= (char **)NULL
,
80 long style
= wxCHOICEDLG_STYLE
,
81 const wxPoint
& pos
= wxDefaultPosition
);
83 bool Create(wxWindow
*parent
,
84 const wxString
& message
,
85 const wxString
& caption
,
87 const wxString
*choices
,
88 char **clientData
= (char **)NULL
,
89 long style
= wxCHOICEDLG_STYLE
,
90 const wxPoint
& pos
= wxDefaultPosition
);
92 void SetSelection(int sel
);
93 int GetSelection() const { return m_selection
; }
94 wxString
GetStringSelection() const { return m_stringSelection
; }
96 // obsolete function (NB: no need to make it return wxChar, it's untyped)
97 char *GetSelectionClientData() const { return (char *)m_clientData
; }
99 // implementation from now on
100 void OnOK(wxCommandEvent
& event
);
101 void OnListBoxDClick(wxCommandEvent
& event
);
105 wxString m_stringSelection
;
108 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog
)
109 DECLARE_EVENT_TABLE()
112 // ----------------------------------------------------------------------------
113 // wxMultiChoiceDialog: a dialog with multi selection listbox
114 // ----------------------------------------------------------------------------
116 class WXDLLEXPORT wxMultiChoiceDialog
: public wxAnyChoiceDialog
119 wxMultiChoiceDialog();
121 wxMultiChoiceDialog(wxWindow
*parent
,
122 const wxString
& message
,
123 const wxString
& caption
,
125 const wxString
*choices
,
126 long style
= wxCHOICEDLG_STYLE
,
127 const wxPoint
& pos
= wxDefaultPosition
);
129 bool Create(wxWindow
*parent
,
130 const wxString
& message
,
131 const wxString
& caption
,
133 const wxString
*choices
,
134 long style
= wxCHOICEDLG_STYLE
,
135 const wxPoint
& pos
= wxDefaultPosition
);
137 void SetSelections(const wxArrayInt
& selections
);
138 wxArrayInt
GetSelections() const { return m_selections
; }
140 // implementation from now on
141 virtual bool TransferDataFromWindow();
144 wxArrayInt m_selections
;
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog
)
150 // ----------------------------------------------------------------------------
151 // wrapper functions which can be used to get selection(s) from the user
152 // ----------------------------------------------------------------------------
154 // get the user selection as a string
155 WXDLLEXPORT wxString
wxGetSingleChoice(const wxString
& message
,
156 const wxString
& caption
,
157 const wxArrayString
& choices
,
158 wxWindow
*parent
= (wxWindow
*) NULL
,
162 int width
= wxCHOICE_WIDTH
,
163 int height
= wxCHOICE_HEIGHT
);
165 WXDLLEXPORT wxString
wxGetSingleChoice(const wxString
& message
,
166 const wxString
& caption
,
167 int n
, const wxString
*choices
,
168 wxWindow
*parent
= (wxWindow
*) NULL
,
172 int width
= wxCHOICE_WIDTH
,
173 int height
= wxCHOICE_HEIGHT
);
175 // Same as above but gets position in list of strings, instead of string,
176 // or -1 if no selection
177 WXDLLEXPORT
int wxGetSingleChoiceIndex(const wxString
& message
,
178 const wxString
& caption
,
179 const wxArrayString
& choices
,
180 wxWindow
*parent
= (wxWindow
*) NULL
,
184 int width
= wxCHOICE_WIDTH
,
185 int height
= wxCHOICE_HEIGHT
);
187 WXDLLEXPORT
int wxGetSingleChoiceIndex(const wxString
& message
,
188 const wxString
& caption
,
189 int n
, const wxString
*choices
,
190 wxWindow
*parent
= (wxWindow
*) NULL
,
194 int width
= wxCHOICE_WIDTH
,
195 int height
= wxCHOICE_HEIGHT
);
197 // Return client data instead or NULL if cancelled
198 WXDLLEXPORT
void* wxGetSingleChoiceData(const wxString
& message
,
199 const wxString
& caption
,
200 const wxArrayString
& choices
,
202 wxWindow
*parent
= (wxWindow
*) NULL
,
203 int x
= -1, int y
= -1,
205 int width
= wxCHOICE_WIDTH
,
206 int height
= wxCHOICE_HEIGHT
);
208 WXDLLEXPORT
void* wxGetSingleChoiceData(const wxString
& message
,
209 const wxString
& caption
,
210 int n
, const wxString
*choices
,
212 wxWindow
*parent
= (wxWindow
*) NULL
,
213 int x
= -1, int y
= -1,
215 int width
= wxCHOICE_WIDTH
,
216 int height
= wxCHOICE_HEIGHT
);
218 // fill the array with the indices of the chosen items, it will be empty
219 // if no items were selected or Cancel was pressed - return the number of
221 WXDLLEXPORT
size_t wxGetMultipleChoices(wxArrayInt
& selections
,
222 const wxString
& message
,
223 const wxString
& caption
,
224 int n
, const wxString
*choices
,
225 wxWindow
*parent
= (wxWindow
*) NULL
,
229 int width
= wxCHOICE_WIDTH
,
230 int height
= wxCHOICE_HEIGHT
);
232 WXDLLEXPORT
size_t wxGetMultipleChoices(wxArrayInt
& selections
,
233 const wxString
& message
,
234 const wxString
& caption
,
235 const wxArrayString
& choices
,
236 wxWindow
*parent
= (wxWindow
*) NULL
,
240 int width
= wxCHOICE_WIDTH
,
241 int height
= wxCHOICE_HEIGHT
);
243 #endif // __CHOICEDLGH_G__