1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-11-03 20:52:17 +00:00
|
|
|
// Name: wx/generic/choicdgg.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose: Generic choice dialogs
|
|
|
|
// Author: Julian Smart
|
2000-11-03 20:52:17 +00:00
|
|
|
// Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
|
1998-05-20 14:01:55 +00:00
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 14:56:36 +00:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __CHOICEDLGH_G__
|
|
|
|
#define __CHOICEDLGH_G__
|
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-06-25 21:28:25 +00:00
|
|
|
#pragma interface "choicdgg.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
#include "wx/dynarray.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#include "wx/dialog.h"
|
1999-10-23 23:40:55 +00:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxListBox;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// some (ugly...) constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#define wxCHOICE_HEIGHT 150
|
|
|
|
#define wxCHOICE_WIDTH 200
|
|
|
|
|
2003-04-17 22:23:49 +00:00
|
|
|
#define wxCHOICEDLG_STYLE \
|
|
|
|
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxAnyChoiceDialog: a base class for dialogs containing a listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
2000-11-03 20:52:17 +00:00
|
|
|
public:
|
2004-01-15 13:49:22 +00:00
|
|
|
wxAnyChoiceDialog() { }
|
2000-11-03 20:52:17 +00:00
|
|
|
|
|
|
|
wxAnyChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
long styleDlg = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2004-01-15 13:49:22 +00:00
|
|
|
long styleLbox = wxLB_ALWAYS_SB)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, n, choices,
|
|
|
|
styleDlg, pos, styleLbox);
|
|
|
|
}
|
2004-01-31 18:21:45 +00:00
|
|
|
wxAnyChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long styleDlg = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
long styleLbox = wxLB_ALWAYS_SB)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, choices,
|
|
|
|
styleDlg, pos, styleLbox);
|
|
|
|
}
|
2000-11-03 20:52:17 +00:00
|
|
|
|
|
|
|
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);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long styleDlg = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
long styleLbox = wxLB_ALWAYS_SB);
|
2000-11-03 20:52:17 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxListBox *m_listbox;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
|
2000-11-03 20:52:17 +00:00
|
|
|
};
|
1999-06-25 21:28:25 +00:00
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSingleChoiceDialog: a dialog with single selection listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
|
|
|
|
{
|
1998-05-20 14:01:55 +00:00
|
|
|
public:
|
2004-01-15 13:49:22 +00:00
|
|
|
wxSingleChoiceDialog()
|
|
|
|
{
|
|
|
|
m_selection = -1;
|
|
|
|
}
|
2000-11-03 20:52:17 +00:00
|
|
|
|
1999-06-25 21:28:25 +00: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);
|
2004-01-31 18:21:45 +00:00
|
|
|
wxSingleChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
1999-06-25 21:28:25 +00:00
|
|
|
|
2000-11-03 20:52:17 +00: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);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
char **clientData = (char **)NULL,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
2000-11-03 20:52:17 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_selection;
|
|
|
|
wxString m_stringSelection;
|
|
|
|
|
|
|
|
private:
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSingleChoiceDialog)
|
2000-11-03 20:52:17 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMultiChoiceDialog: a dialog with multi selection listbox
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
|
|
|
|
{
|
|
|
|
public:
|
2004-01-15 13:49:22 +00:00
|
|
|
wxMultiChoiceDialog() { }
|
2000-11-03 20:52:17 +00:00
|
|
|
|
|
|
|
wxMultiChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
2004-01-15 13:49:22 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, n, choices, style, pos);
|
|
|
|
}
|
2004-01-31 18:21:45 +00:00
|
|
|
wxMultiChoiceDialog(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition)
|
|
|
|
{
|
|
|
|
(void)Create(parent, message, caption, choices, style, pos);
|
|
|
|
}
|
1999-06-25 21:28:25 +00:00
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
2000-11-03 20:52:17 +00:00
|
|
|
int n,
|
|
|
|
const wxString *choices,
|
1999-06-25 21:28:25 +00:00
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = wxCHOICEDLG_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
void SetSelections(const wxArrayInt& selections);
|
|
|
|
wxArrayInt GetSelections() const { return m_selections; }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-06-25 21:28:25 +00:00
|
|
|
// implementation from now on
|
2000-11-03 21:11:41 +00:00
|
|
|
virtual bool TransferDataFromWindow();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
protected:
|
2000-11-03 20:52:17 +00:00
|
|
|
wxArrayInt m_selections;
|
1999-06-25 21:28:25 +00:00
|
|
|
|
|
|
|
private:
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMultiChoiceDialog)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2000-11-03 20:52:17 +00: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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2000-11-03 20:52:17 +00:00
|
|
|
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
int n, const wxString *choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Same as above but gets position in list of strings, instead of string,
|
|
|
|
// or -1 if no selection
|
2000-11-03 20:52:17 +00:00
|
|
|
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
wxWindow *parent = (wxWindow *) NULL,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
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,
|
2004-07-20 10:09:47 +00:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2004-06-17 16:22:36 +00:00
|
|
|
bool centre = true,
|
2000-11-03 20:52:17 +00:00
|
|
|
int width = wxCHOICE_WIDTH,
|
|
|
|
int height = wxCHOICE_HEIGHT);
|
|
|
|
|
|
|
|
#endif // __CHOICEDLGH_G__
|
1998-05-20 14:01:55 +00:00
|
|
|
|