1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-11-03 15:52:17 -05:00
|
|
|
// Name: wx/generic/choicdgg.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose: Generic choice dialogs
|
|
|
|
// Author: Julian Smart
|
2000-11-03 15:52:17 -05:00
|
|
|
// Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
|
1998-05-20 10:01:55 -04:00
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
2000-11-03 15:52:17 -05:00
|
|
|
// Copyright: (c) wxWindows team
|
1999-06-28 17:39:49 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __CHOICEDLGH_G__
|
|
|
|
#define __CHOICEDLGH_G__
|
|
|
|
|
2002-08-31 07:29:13 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1999-06-25 17:28:25 -04:00
|
|
|
#pragma interface "choicdgg.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
#include "wx/dynarray.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#include "wx/dialog.h"
|
1999-10-23 19:40:55 -04:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxListBox;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// some (ugly...) constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#define wxCHOICE_HEIGHT 150
|
|
|
|
#define wxCHOICE_WIDTH 200
|
|
|
|
|
2003-04-17 18:23:49 -04:00
|
|
|
#define wxCHOICEDLG_STYLE \
|
|
|
|
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxAnyChoiceDialog: a base class for dialogs containing a listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2000-11-03 15:52:17 -05:00
|
|
|
public:
|
|
|
|
wxAnyChoiceDialog() { }
|
|
|
|
|
|
|
|
wxAnyChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
long styleDlg = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
long styleLbox = wxLB_ALWAYS_SB)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, n, choices,
|
|
|
|
styleDlg, pos, styleLbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
long styleDlg = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
long styleLbox = wxLB_ALWAYS_SB);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxListBox *m_listbox;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
|
2000-11-03 15:52:17 -05:00
|
|
|
};
|
1999-06-25 17:28:25 -04:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSingleChoiceDialog: a dialog with single selection listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
|
|
|
|
{
|
1998-05-20 10:01:55 -04:00
|
|
|
public:
|
2000-11-03 15:52:17 -05:00
|
|
|
wxSingleChoiceDialog()
|
|
|
|
{
|
|
|
|
m_selection = -1;
|
|
|
|
}
|
|
|
|
|
1999-06-25 17:28:25 -04:00
|
|
|
wxSingleChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
|
|
|
|
|
|
|
void SetSelection(int sel);
|
|
|
|
int GetSelection() const { return m_selection; }
|
|
|
|
wxString GetStringSelection() const { return m_stringSelection; }
|
|
|
|
|
|
|
|
// obsolete function (NB: no need to make it return wxChar, it's untyped)
|
|
|
|
char *GetSelectionClientData() const { return (char *)m_clientData; }
|
|
|
|
|
|
|
|
// implementation from now on
|
|
|
|
void OnOK(wxCommandEvent& event);
|
|
|
|
void OnListBoxDClick(wxCommandEvent& event);
|
|
|
|
|
|
|
|
// old, deprecated methods
|
2001-07-07 07:23:24 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2
|
1999-06-25 17:28:25 -04:00
|
|
|
wxSingleChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxStringList& choices,
|
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
2000-11-03 15:52:17 -05:00
|
|
|
const wxStringList& choices,
|
1999-06-25 17:28:25 -04:00
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
2000-11-03 15:52:17 -05:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_selection;
|
|
|
|
wxString m_stringSelection;
|
|
|
|
|
|
|
|
private:
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
|
2000-11-03 15:52:17 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMultiChoiceDialog: a dialog with multi selection listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxMultiChoiceDialog() { }
|
|
|
|
|
|
|
|
wxMultiChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, n, choices, style, pos);
|
|
|
|
}
|
1999-06-25 17:28:25 -04:00
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
2000-11-03 15:52:17 -05:00
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
1999-06-25 17:28:25 -04:00
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
void SetSelections(const wxArrayInt& selections);
|
|
|
|
wxArrayInt GetSelections() const { return m_selections; }
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-06-25 17:28:25 -04:00
|
|
|
// implementation from now on
|
2000-11-03 16:11:41 -05:00
|
|
|
virtual bool TransferDataFromWindow();
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
protected:
|
2000-11-03 15:52:17 -05:00
|
|
|
wxArrayInt m_selections;
|
1999-06-25 17:28:25 -04:00
|
|
|
|
|
|
|
private:
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wrapper functions which can be used to get selection(s) from the user
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// get the user selection as a string
|
|
|
|
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Same as above but gets position in list of strings, instead of string,
|
|
|
|
// or -1 if no selection
|
2000-11-03 15:52:17 -05:00
|
|
|
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
// Return client data instead or NULL if cancelled
|
|
|
|
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
void **client_data,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1, int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
void **client_data,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1, int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
// fill the array with the indices of the chosen items, it will be empty
|
|
|
|
// if no items were selected or Cancel was pressed - return the number of
|
|
|
|
// selections
|
|
|
|
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// these methods are for backwards compatibility only, not documented and
|
|
|
|
// deprecated
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2001-07-07 07:23:24 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2
|
2000-11-08 18:58:42 -05:00
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, wxChar *choices[],
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, wxChar *choices[],
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1,
|
|
|
|
int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, wxChar **choices,
|
|
|
|
void **client_data,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
|
|
|
int x = -1, int y = -1,
|
|
|
|
bool centre = TRUE,
|
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
|
2000-11-08 18:58:42 -05:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2
|
|
|
|
|
2000-11-03 15:52:17 -05:00
|
|
|
#endif // __CHOICEDLGH_G__
|
1998-05-20 10:01:55 -04:00
|
|
|
|