1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Generic choice dialogs
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __CHOICEDLGH_G__
13 #define __CHOICEDLGH_G__
16 #pragma interface "choicdgg.h"
20 #include "wx/dialog.h"
21 #include "wx/listbox.h"
23 #define wxCHOICE_HEIGHT 150
24 #define wxCHOICE_WIDTH 200
26 #define wxCHOICEDLG_STYLE (wxDEFAULT_DIALOG_STYLE|wxOK | wxCANCEL | wxCENTRE)
28 class WXDLLEXPORT wxSingleChoiceDialog
: public wxDialog
30 DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog
)
33 wxSingleChoiceDialog(wxWindow
*parent
,
34 const wxString
& message
,
35 const wxString
& caption
,
37 const wxString
*choices
,
38 char **clientData
= (char **)NULL
,
39 long style
= wxCHOICEDLG_STYLE
,
40 const wxPoint
& pos
= wxDefaultPosition
);
42 wxSingleChoiceDialog(wxWindow
*parent
,
43 const wxString
& message
,
44 const wxString
& caption
,
45 const wxStringList
& choices
,
46 char **clientData
= (char **)NULL
,
47 long style
= wxCHOICEDLG_STYLE
,
48 const wxPoint
& pos
= wxDefaultPosition
);
50 bool Create(wxWindow
*parent
,
51 const wxString
& message
,
52 const wxString
& caption
,
54 const wxString
*choices
,
55 char **clientData
= (char **)NULL
,
56 long style
= wxCHOICEDLG_STYLE
,
57 const wxPoint
& pos
= wxDefaultPosition
);
59 bool Create(wxWindow
*parent
,
60 const wxString
& message
,
61 const wxString
& caption
,
62 const wxStringList
& choices
,
63 char **clientData
= (char **)NULL
,
64 long style
= wxCHOICEDLG_STYLE
,
65 const wxPoint
& pos
= wxDefaultPosition
);
67 void SetSelection(int sel
) ;
68 int GetSelection() const { return m_selection
; }
69 wxString
GetStringSelection() const { return m_stringSelection
; }
71 // get client data associated with selection
72 void *GetClientData() const { return m_clientData
; }
74 // obsolete function (NB: no need to make it return wxChar, it's untyped)
75 char *GetSelectionClientData() const { return (char *)m_clientData
; }
77 // implementation from now on
78 void OnOK(wxCommandEvent
& event
);
79 void OnListBoxDClick(wxCommandEvent
& event
);
84 wxString m_stringSelection
;
91 WXDLLEXPORT wxString
wxGetSingleChoice(const wxString
& message
, const wxString
& caption
,
92 int n
, const wxString
*choices
, wxWindow
*parent
= (wxWindow
*) NULL
,
93 int x
= -1, int y
= -1, bool centre
= TRUE
,
94 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
96 WXDLLEXPORT wxString
wxGetSingleChoice(const wxString
& message
, const wxString
& caption
,
97 int n
, wxChar
*choices
[], wxWindow
*parent
= (wxWindow
*) NULL
,
98 int x
= -1, int y
= -1, bool centre
= TRUE
,
99 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
101 // Same as above but gets position in list of strings, instead of string,
102 // or -1 if no selection
103 WXDLLEXPORT
int wxGetSingleChoiceIndex(const wxString
& message
, const wxString
& caption
,
104 int n
, const wxString
*choices
, wxWindow
*parent
= (wxWindow
*) NULL
,
105 int x
= -1, int y
= -1, bool centre
= TRUE
,
106 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
108 WXDLLEXPORT
int wxGetSingleChoiceIndex(const wxString
& message
, const wxString
& caption
,
109 int n
, wxChar
*choices
[], wxWindow
*parent
= (wxWindow
*) NULL
,
110 int x
= -1, int y
= -1, bool centre
= TRUE
,
111 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
113 // Return client data instead
114 // FIXME: this is horrible, using "char *" instead of "void *" belongs to the 70s!
115 WXDLLEXPORT wxChar
* wxGetSingleChoiceData(const wxString
& message
, const wxString
& caption
,
116 int n
, const wxString
*choices
, char **client_data
,
117 wxWindow
*parent
= (wxWindow
*) NULL
, int x
= -1, int y
= -1,
119 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
121 WXDLLEXPORT wxChar
* wxGetSingleChoiceData(const wxString
& message
, const wxString
& caption
,
122 int n
, wxChar
*choices
[], char **client_data
,
123 wxWindow
*parent
= (wxWindow
*) NULL
, int x
= -1, int y
= -1,
125 int width
= wxCHOICE_WIDTH
, int height
= wxCHOICE_HEIGHT
);
128 WXDLLEXPORT int wxGetMultipleChoice(const wxString& message, const wxString& caption,
129 int n, const wxString *choices,
130 int nsel, int * selection,
131 wxWindow *parent = NULL, int x = -1 , int y = -1, bool centre = TRUE,
132 int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);