Did somework on the generic dialogs,
Renamed wxBox -> wxBoxSizer Removed old dialog layout code, git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -46,17 +46,16 @@
|
|||||||
|
|
||||||
busyinfo.cpp G
|
busyinfo.cpp G
|
||||||
caret.cpp G U
|
caret.cpp G U
|
||||||
choicdgg.cpp G R
|
choicdgg.cpp G
|
||||||
colrdlgg.cpp G G
|
colrdlgg.cpp G G
|
||||||
dirdlgg.cpp G 16
|
dirdlgg.cpp G 16
|
||||||
extdlgg.cpp G
|
|
||||||
fontdlgg.cpp G G
|
fontdlgg.cpp G G
|
||||||
gridg.cpp G
|
gridg.cpp G
|
||||||
helpxlp.cpp G G,R
|
helpxlp.cpp G G,R
|
||||||
imaglist.cpp G 16
|
imaglist.cpp G 16
|
||||||
laywin.cpp G
|
laywin.cpp G
|
||||||
listctrl.cpp G 16
|
listctrl.cpp G 16
|
||||||
msgdlgg.cpp G G,R
|
msgdlgg.cpp G G
|
||||||
notebook.cpp G 16,R
|
notebook.cpp G 16,R
|
||||||
panelg.cpp G
|
panelg.cpp G
|
||||||
printps.cpp G PS
|
printps.cpp G PS
|
||||||
@@ -71,7 +70,7 @@ splitter.cpp G
|
|||||||
statusbr.cpp G
|
statusbr.cpp G
|
||||||
tabg.cpp G R
|
tabg.cpp G R
|
||||||
numdlgg.cpp G
|
numdlgg.cpp G
|
||||||
textdlgg.cpp G R
|
textdlgg.cpp G
|
||||||
tipdlg.cpp G
|
tipdlg.cpp G
|
||||||
treectrl.cpp G 16
|
treectrl.cpp G 16
|
||||||
|
|
||||||
@@ -267,7 +266,6 @@ button.cpp R
|
|||||||
checkbox.cpp R
|
checkbox.cpp R
|
||||||
checklst.cpp R
|
checklst.cpp R
|
||||||
choice.cpp R
|
choice.cpp R
|
||||||
choicdlg.cpp R
|
|
||||||
clipbrd.cpp R
|
clipbrd.cpp R
|
||||||
colour.cpp R
|
colour.cpp R
|
||||||
combobox.cpp R
|
combobox.cpp R
|
||||||
@@ -292,7 +290,6 @@ main.cpp R
|
|||||||
mdi.cpp R
|
mdi.cpp R
|
||||||
menu.cpp R
|
menu.cpp R
|
||||||
minifram.cpp R
|
minifram.cpp R
|
||||||
msgdlg.cpp R
|
|
||||||
notebook.cpp R
|
notebook.cpp R
|
||||||
palette.cpp R
|
palette.cpp R
|
||||||
pen.cpp R
|
pen.cpp R
|
||||||
@@ -309,7 +306,6 @@ statline.cpp R
|
|||||||
stattext.cpp R
|
stattext.cpp R
|
||||||
tbargtk.cpp R
|
tbargtk.cpp R
|
||||||
textctrl.cpp R
|
textctrl.cpp R
|
||||||
textdlg.cpp R
|
|
||||||
timer.cpp R
|
timer.cpp R
|
||||||
tooltip.cpp R
|
tooltip.cpp R
|
||||||
utilsgtk.cpp R
|
utilsgtk.cpp R
|
||||||
@@ -434,7 +430,6 @@ dynarray.h I WX
|
|||||||
dynlib.h I WX
|
dynlib.h I WX
|
||||||
event.h I WX
|
event.h I WX
|
||||||
expr.h I WX
|
expr.h I WX
|
||||||
extdlg.h I WX
|
|
||||||
ffile.h I WX
|
ffile.h I WX
|
||||||
file.h I WX
|
file.h I WX
|
||||||
fileconf.h I WX
|
fileconf.h I WX
|
||||||
@@ -575,7 +570,6 @@ button.h I GTK
|
|||||||
checkbox.h I GTK
|
checkbox.h I GTK
|
||||||
checklst.h I GTK
|
checklst.h I GTK
|
||||||
choice.h I GTK
|
choice.h I GTK
|
||||||
choicdlg.h I GTK
|
|
||||||
clipbrd.h I GTK
|
clipbrd.h I GTK
|
||||||
colour.h I GTK
|
colour.h I GTK
|
||||||
combobox.h I GTK
|
combobox.h I GTK
|
||||||
@@ -617,7 +611,6 @@ statline.h I GTK
|
|||||||
stattext.h I GTK
|
stattext.h I GTK
|
||||||
tbargtk.h I GTK
|
tbargtk.h I GTK
|
||||||
textctrl.h I GTK
|
textctrl.h I GTK
|
||||||
textdlg.h I GTK
|
|
||||||
timer.h I GTK
|
timer.h I GTK
|
||||||
tooltip.h I GTK
|
tooltip.h I GTK
|
||||||
treectrl.h I GTK
|
treectrl.h I GTK
|
||||||
|
@@ -58,7 +58,6 @@ wx_include_HEADERS = \
|
|||||||
dynlib.h \
|
dynlib.h \
|
||||||
event.h \
|
event.h \
|
||||||
expr.h \
|
expr.h \
|
||||||
extdlg.h \
|
|
||||||
ffile.h \
|
ffile.h \
|
||||||
file.h \
|
file.h \
|
||||||
fileconf.h \
|
fileconf.h \
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
#ifndef _WX_CHOICDLG_H_BASE_
|
#ifndef _WX_CHOICDLG_H_BASE_
|
||||||
#define _WX_CHOICDLG_H_BASE_
|
#define _WX_CHOICDLG_H_BASE_
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
#include "wx/gtk/choicdlg.h"
|
|
||||||
#else
|
|
||||||
#include "wx/generic/choicdgg.h"
|
#include "wx/generic/choicdgg.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_CHOICDLG_H_BASE_
|
// _WX_CHOICDLG_H_BASE_
|
||||||
|
@@ -24,42 +24,12 @@ public:
|
|||||||
int GetReturnCode() const { return m_returnCode; }
|
int GetReturnCode() const { return m_returnCode; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// functions to help with dialog layout
|
// splits text up at newlines and places the
|
||||||
// ------------------------------------
|
// lines into a vertical wxBoxSizer
|
||||||
|
wxSizer *CreateTextSizer( const wxString &message );
|
||||||
// constants used in dialog layout
|
|
||||||
static const long LAYOUT_X_MARGIN;
|
// places buttons into a horizontal wxBoxSizer
|
||||||
static const long LAYOUT_Y_MARGIN;
|
wxSizer *CreateButtonSizer( long flags );
|
||||||
static const long MARGIN_BETWEEN_BUTTONS;
|
|
||||||
|
|
||||||
// Split the message in lines putting them into the array and calculating
|
|
||||||
// the maximum line width/height which is returned as wxSize.
|
|
||||||
wxSize SplitTextMessage(const wxString& message, wxArrayString *lines);
|
|
||||||
|
|
||||||
// Creates the (possibly multiline) message, assuming each line has the
|
|
||||||
// size sizeText (which can be retrieved from SplitTextMessage). Returns
|
|
||||||
// the bottom border of the multiline text zone.
|
|
||||||
long CreateTextMessage(const wxArrayString& lines,
|
|
||||||
const wxPoint& posText,
|
|
||||||
const wxSize& sizeText);
|
|
||||||
|
|
||||||
// Returns the preferred size for the buttons in the dialog
|
|
||||||
wxSize GetStandardButtonSize(bool hasCancel = TRUE);
|
|
||||||
|
|
||||||
// Create the standard [Ok] and [Cancel] (if hasCancel) buttons centering
|
|
||||||
// them with respect to the dialog width wDialog at vertical position y.
|
|
||||||
// wButton and hButton is the size of the button (which can be retrieved
|
|
||||||
// from GetStandardButtonSize)
|
|
||||||
void CreateStandardButtons(long wDialog,
|
|
||||||
long y,
|
|
||||||
long wButton,
|
|
||||||
long hButton,
|
|
||||||
bool hasCancel = TRUE);
|
|
||||||
|
|
||||||
// Returns the standard height of single line text ctrl (it's not the same
|
|
||||||
// as the height of just text which may be retrieved from
|
|
||||||
// wxGetCharHeight())
|
|
||||||
long GetStandardTextHeight();
|
|
||||||
|
|
||||||
// the return code from modal dialog
|
// the return code from modal dialog
|
||||||
int m_returnCode;
|
int m_returnCode;
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
#ifndef _WX_EXTDLG_H_BASE_
|
|
||||||
#define _WX_EXTDLG_H_BASE_
|
|
||||||
|
|
||||||
#include "wx/generic/extdlgg.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// _WX_EXTDLG_H_BASE_
|
|
@@ -11,7 +11,6 @@ wx_generic_include_HEADERS = \
|
|||||||
colrdlgg.h \
|
colrdlgg.h \
|
||||||
dcpsg.h \
|
dcpsg.h \
|
||||||
dirdlgg.h \
|
dirdlgg.h \
|
||||||
extdlgg.h \
|
|
||||||
fontdlgg.h \
|
fontdlgg.h \
|
||||||
gridg.h \
|
gridg.h \
|
||||||
helpext.h \
|
helpext.h \
|
||||||
|
@@ -80,6 +80,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_selection;
|
int m_selection;
|
||||||
|
int m_dialogStyle;
|
||||||
wxString m_stringSelection;
|
wxString m_stringSelection;
|
||||||
wxListBox *m_listbox;
|
wxListBox *m_listbox;
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
wxTextCtrl *m_textctrl;
|
wxTextCtrl *m_textctrl;
|
||||||
wxString m_value;
|
wxString m_value;
|
||||||
|
int m_dialogStyle;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -15,7 +15,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
checkbox.h \
|
checkbox.h \
|
||||||
checklst.h \
|
checklst.h \
|
||||||
choice.h \
|
choice.h \
|
||||||
choicdlg.h \
|
|
||||||
clipbrd.h \
|
clipbrd.h \
|
||||||
colour.h \
|
colour.h \
|
||||||
combobox.h \
|
combobox.h \
|
||||||
@@ -39,7 +38,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
mdi.h \
|
mdi.h \
|
||||||
menu.h \
|
menu.h \
|
||||||
menuitem.h \
|
menuitem.h \
|
||||||
msgdlg.h \
|
|
||||||
minifram.h \
|
minifram.h \
|
||||||
notebook.h \
|
notebook.h \
|
||||||
palette.h \
|
palette.h \
|
||||||
@@ -57,7 +55,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
stattext.h \
|
stattext.h \
|
||||||
tbargtk.h \
|
tbargtk.h \
|
||||||
textctrl.h \
|
textctrl.h \
|
||||||
textdlg.h \
|
|
||||||
timer.h \
|
timer.h \
|
||||||
tooltip.h \
|
tooltip.h \
|
||||||
treectrl.h \
|
treectrl.h \
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: choicdgg.h
|
|
||||||
// Purpose: Generic choice dialogs
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c)
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __CHOICEDLGH_G__
|
|
||||||
#define __CHOICEDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "choicdgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
|
|
||||||
#define wxCHOICE_HEIGHT 150
|
|
||||||
#define wxCHOICE_WIDTH 200
|
|
||||||
|
|
||||||
#define wxID_LISTBOX 3000
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxSingleChoiceDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog)
|
|
||||||
public:
|
|
||||||
wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
void SetSelection(int sel) ;
|
|
||||||
int GetSelection() const { return m_selection; }
|
|
||||||
wxString GetStringSelection() const { return m_stringSelection; }
|
|
||||||
char *GetSelectionClientData() const { return (char *)m_clientData; }
|
|
||||||
|
|
||||||
void OnOK(wxCommandEvent& event);
|
|
||||||
void OnListBoxDClick(wxCommandEvent& event);
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
|
|
||||||
protected:
|
|
||||||
long m_dialogStyle;
|
|
||||||
int m_selection;
|
|
||||||
wxString m_stringSelection;
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Same as above but gets position in list of strings, instead of string,
|
|
||||||
// or -1 if no selection
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Return client data instead
|
|
||||||
WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **client_data,
|
|
||||||
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1,
|
|
||||||
bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
|
|
||||||
WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption,
|
|
||||||
int n, wxChar *choices[], char **client_data,
|
|
||||||
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1,
|
|
||||||
bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
|
|
||||||
/*
|
|
||||||
WXDLLEXPORT int wxGetMultipleChoice(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices,
|
|
||||||
int nsel, int * selection,
|
|
||||||
wxWindow *parent = NULL, int x = -1 , int y = -1, bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,56 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: msgdlgg.h
|
|
||||||
// Purpose: Generic wxMessageDialog
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c)
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __MSGDLGH_G__
|
|
||||||
#define __MSGDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "msgdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
|
|
||||||
// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO
|
|
||||||
// Returns wxYES/NO/OK/CANCEL
|
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGenericMessageDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxGenericMessageDialog(wxWindow *parent, const wxString& message,
|
|
||||||
const wxString& caption = wxMessageBoxCaptionStr,
|
|
||||||
long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
void OnYes(wxCommandEvent& event);
|
|
||||||
void OnNo(wxCommandEvent& event);
|
|
||||||
void OnCancel(wxCommandEvent& event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxList m_buttons;
|
|
||||||
int m_dialogStyle;
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( __WXMSW__ ) && !defined( __WXMAC__)
|
|
||||||
#define wxMessageDialog wxGenericMessageDialog
|
|
||||||
|
|
||||||
int wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
|
|
||||||
long style = wxOK|wxCENTRE, wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// __MSGDLGH_G__
|
|
@@ -1,52 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: textdlgg.h
|
|
||||||
// Purpose: wxStatusBar class
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __TEXTDLGH_G__
|
|
||||||
#define __TEXTDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "textdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/extdlg.h"
|
|
||||||
|
|
||||||
// Handy dialog functions (will be converted into classes at some point)
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr;
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
|
||||||
|
|
||||||
#define wxID_TEXT 3000
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTextEntryDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
|
|
||||||
protected:
|
|
||||||
long m_dialogStyle;
|
|
||||||
wxString m_value;
|
|
||||||
public:
|
|
||||||
wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
|
|
||||||
const wxString& value = wxEmptyString, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
inline void SetValue(const wxString& val) { m_value = val; }
|
|
||||||
inline wxString GetValue(void) const { return m_value; }
|
|
||||||
|
|
||||||
void OnOK(wxCommandEvent& event);
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
wxString WXDLLEXPORT wxGetTextFromUser(const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
|
|
||||||
const wxString& default_value = wxEmptyString, wxWindow *parent = (wxWindow *) NULL,
|
|
||||||
int x = -1, int y = -1, bool centre = TRUE);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// __TEXTDLGH_G__
|
|
@@ -15,7 +15,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
checkbox.h \
|
checkbox.h \
|
||||||
checklst.h \
|
checklst.h \
|
||||||
choice.h \
|
choice.h \
|
||||||
choicdlg.h \
|
|
||||||
clipbrd.h \
|
clipbrd.h \
|
||||||
colour.h \
|
colour.h \
|
||||||
combobox.h \
|
combobox.h \
|
||||||
@@ -39,7 +38,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
mdi.h \
|
mdi.h \
|
||||||
menu.h \
|
menu.h \
|
||||||
menuitem.h \
|
menuitem.h \
|
||||||
msgdlg.h \
|
|
||||||
minifram.h \
|
minifram.h \
|
||||||
notebook.h \
|
notebook.h \
|
||||||
palette.h \
|
palette.h \
|
||||||
@@ -57,7 +55,6 @@ wx_gtk_include_HEADERS = \
|
|||||||
stattext.h \
|
stattext.h \
|
||||||
tbargtk.h \
|
tbargtk.h \
|
||||||
textctrl.h \
|
textctrl.h \
|
||||||
textdlg.h \
|
|
||||||
timer.h \
|
timer.h \
|
||||||
tooltip.h \
|
tooltip.h \
|
||||||
treectrl.h \
|
treectrl.h \
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: choicdgg.h
|
|
||||||
// Purpose: Generic choice dialogs
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c)
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __CHOICEDLGH_G__
|
|
||||||
#define __CHOICEDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "choicdgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
|
|
||||||
#define wxCHOICE_HEIGHT 150
|
|
||||||
#define wxCHOICE_WIDTH 200
|
|
||||||
|
|
||||||
#define wxID_LISTBOX 3000
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxSingleChoiceDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog)
|
|
||||||
public:
|
|
||||||
wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
void SetSelection(int sel) ;
|
|
||||||
int GetSelection() const { return m_selection; }
|
|
||||||
wxString GetStringSelection() const { return m_stringSelection; }
|
|
||||||
char *GetSelectionClientData() const { return (char *)m_clientData; }
|
|
||||||
|
|
||||||
void OnOK(wxCommandEvent& event);
|
|
||||||
void OnListBoxDClick(wxCommandEvent& event);
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
|
|
||||||
protected:
|
|
||||||
long m_dialogStyle;
|
|
||||||
int m_selection;
|
|
||||||
wxString m_stringSelection;
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Same as above but gets position in list of strings, instead of string,
|
|
||||||
// or -1 if no selection
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Return client data instead
|
|
||||||
WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **client_data,
|
|
||||||
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1,
|
|
||||||
bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
|
|
||||||
WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption,
|
|
||||||
int n, wxChar *choices[], char **client_data,
|
|
||||||
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1,
|
|
||||||
bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
|
|
||||||
/*
|
|
||||||
WXDLLEXPORT int wxGetMultipleChoice(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices,
|
|
||||||
int nsel, int * selection,
|
|
||||||
wxWindow *parent = NULL, int x = -1 , int y = -1, bool centre = TRUE,
|
|
||||||
int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,56 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: msgdlgg.h
|
|
||||||
// Purpose: Generic wxMessageDialog
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c)
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __MSGDLGH_G__
|
|
||||||
#define __MSGDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "msgdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
|
|
||||||
// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO
|
|
||||||
// Returns wxYES/NO/OK/CANCEL
|
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxGenericMessageDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxGenericMessageDialog(wxWindow *parent, const wxString& message,
|
|
||||||
const wxString& caption = wxMessageBoxCaptionStr,
|
|
||||||
long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
void OnYes(wxCommandEvent& event);
|
|
||||||
void OnNo(wxCommandEvent& event);
|
|
||||||
void OnCancel(wxCommandEvent& event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxList m_buttons;
|
|
||||||
int m_dialogStyle;
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( __WXMSW__ ) && !defined( __WXMAC__)
|
|
||||||
#define wxMessageDialog wxGenericMessageDialog
|
|
||||||
|
|
||||||
int wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
|
|
||||||
long style = wxOK|wxCENTRE, wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// __MSGDLGH_G__
|
|
@@ -1,52 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: textdlgg.h
|
|
||||||
// Purpose: wxStatusBar class
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 01/02/97
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __TEXTDLGH_G__
|
|
||||||
#define __TEXTDLGH_G__
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "textdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/extdlg.h"
|
|
||||||
|
|
||||||
// Handy dialog functions (will be converted into classes at some point)
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr;
|
|
||||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
|
||||||
|
|
||||||
#define wxID_TEXT 3000
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTextEntryDialog: public wxDialog
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
|
|
||||||
protected:
|
|
||||||
long m_dialogStyle;
|
|
||||||
wxString m_value;
|
|
||||||
public:
|
|
||||||
wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
|
|
||||||
const wxString& value = wxEmptyString, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
inline void SetValue(const wxString& val) { m_value = val; }
|
|
||||||
inline wxString GetValue(void) const { return m_value; }
|
|
||||||
|
|
||||||
void OnOK(wxCommandEvent& event);
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
wxString WXDLLEXPORT wxGetTextFromUser(const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
|
|
||||||
const wxString& default_value = wxEmptyString, wxWindow *parent = (wxWindow *) NULL,
|
|
||||||
int x = -1, int y = -1, bool centre = TRUE);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// __TEXTDLGH_G__
|
|
@@ -6,7 +6,7 @@
|
|||||||
#elif defined(__WXMOTIF__)
|
#elif defined(__WXMOTIF__)
|
||||||
#include "wx/motif/msgdlg.h"
|
#include "wx/motif/msgdlg.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
#include "wx/gtk/msgdlg.h"
|
#include "wx/generic/msgdlgg.h"
|
||||||
#elif defined(__WXQT__)
|
#elif defined(__WXQT__)
|
||||||
#include "wx/generic/msgdlgg.h"
|
#include "wx/generic/msgdlgg.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
class wxSizerItem;
|
class wxSizerItem;
|
||||||
class wxSizer;
|
class wxSizer;
|
||||||
class wxBox;
|
class wxBoxSizer;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxSizerItem
|
// wxSizerItem
|
||||||
@@ -115,13 +115,13 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxBox
|
// wxBoxSizer
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxBox: public wxSizer
|
class WXDLLEXPORT wxBoxSizer: public wxSizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxBox( int orient );
|
wxBoxSizer( int orient );
|
||||||
|
|
||||||
void RecalcSizes();
|
void RecalcSizes();
|
||||||
wxSize CalcMin();
|
wxSize CalcMin();
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
#ifndef _WX_TEXTDLG_H_BASE_
|
#ifndef _WX_TEXTDLG_H_BASE_
|
||||||
#define _WX_TEXTDLG_H_BASE_
|
#define _WX_TEXTDLG_H_BASE_
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
#include "wx/gtk/textdlg.h"
|
|
||||||
#else
|
|
||||||
#include "wx/generic/textdlgg.h"
|
#include "wx/generic/textdlgg.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// function to get a number from user
|
// function to get a number from user
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include "wx/fontdlg.h"
|
#include "wx/fontdlg.h"
|
||||||
#include "wx/choicdlg.h"
|
#include "wx/choicdlg.h"
|
||||||
#include "wx/tipdlg.h"
|
#include "wx/tipdlg.h"
|
||||||
#include "wx/extdlg.h"
|
|
||||||
|
|
||||||
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
|
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
|
||||||
|
|
||||||
@@ -80,7 +79,6 @@ bool MyApp::OnInit(void)
|
|||||||
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry");
|
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry");
|
||||||
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
|
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
|
||||||
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice");
|
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice");
|
||||||
file_menu->Append(DIALOGS_EXT_DIALOG, "&Extended dialog");
|
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
file_menu->Append(DIALOGS_TIP, "&Tip of the day");
|
file_menu->Append(DIALOGS_TIP, "&Tip of the day");
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
@@ -111,43 +109,6 @@ MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, co
|
|||||||
wxFrame(parent, -1, title, pos, size)
|
wxFrame(parent, -1, title, pos, size)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void MyFrame::ExtDialog(wxCommandEvent& WXUNUSED(event) )
|
|
||||||
{
|
|
||||||
// The standard flags causes this dialog to display a
|
|
||||||
// wxStaticLine under wxMotif and wxGTK, but none under
|
|
||||||
// other platforms. Also, it will not be resizable
|
|
||||||
// anywhere.
|
|
||||||
|
|
||||||
wxExtDialog dialog( this, -1, "Test 1 for wxExtDialog", wxOK|wxFORWARD|wxBACKWARD );
|
|
||||||
dialog.AddButton( new wxButton( &dialog, -1, "Custom") );
|
|
||||||
|
|
||||||
dialog.SetClientWindow( new wxTextCtrl( &dialog, -1, "Test", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ) );
|
|
||||||
|
|
||||||
// query minimal recommended size from the buttons
|
|
||||||
dialog.SetSize( dialog.GetButtonAreaSize().x, 170 );
|
|
||||||
|
|
||||||
dialog.Centre( wxBOTH );
|
|
||||||
dialog.ShowModal();
|
|
||||||
|
|
||||||
// This dialog uses the standard dialog styles but is also
|
|
||||||
// resizable on all platforms and shows a wxStaticLine on
|
|
||||||
// all platforms.
|
|
||||||
|
|
||||||
wxExtDialog dialog2( this, -1, "Test 2 for wxExtDialog",
|
|
||||||
wxOK|wxFORWARD|wxBACKWARD|wxCANCEL,
|
|
||||||
wxDefaultPosition, wxSize(400,170),
|
|
||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxED_BUTTONS_RIGHT | wxED_STATIC_LINE | wxED_CLIENT_MARGIN );
|
|
||||||
|
|
||||||
dialog2.SetClientWindow( new wxTextCtrl( &dialog2, -1, "Test", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ) );
|
|
||||||
|
|
||||||
// query minimal recommended size from the buttons
|
|
||||||
wxSize min_size( dialog2.GetButtonAreaSize() );
|
|
||||||
dialog2.SetSizeHints( min_size.x + 200, min_size.y );
|
|
||||||
|
|
||||||
dialog2.Centre( wxBOTH );
|
|
||||||
dialog2.ShowModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxColourData data;
|
wxColourData data;
|
||||||
@@ -392,7 +353,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
|
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
|
||||||
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
|
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
|
||||||
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
|
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
|
||||||
EVT_MENU(DIALOGS_EXT_DIALOG, MyFrame::ExtDialog)
|
|
||||||
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
|
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
|
||||||
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
|
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
|
||||||
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
|
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
|
||||||
|
@@ -39,7 +39,6 @@ public:
|
|||||||
void FileSave(wxCommandEvent& event);
|
void FileSave(wxCommandEvent& event);
|
||||||
void DirChoose(wxCommandEvent& event);
|
void DirChoose(wxCommandEvent& event);
|
||||||
void ShowTip(wxCommandEvent& event);
|
void ShowTip(wxCommandEvent& event);
|
||||||
void ExtDialog(wxCommandEvent &event);
|
|
||||||
|
|
||||||
#if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW
|
#if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW
|
||||||
void ChooseColourGeneric(wxCommandEvent& event);
|
void ChooseColourGeneric(wxCommandEvent& event);
|
||||||
@@ -74,7 +73,6 @@ public:
|
|||||||
#define DIALOGS_FILE_SAVE 9
|
#define DIALOGS_FILE_SAVE 9
|
||||||
#define DIALOGS_DIR_CHOOSE 10
|
#define DIALOGS_DIR_CHOOSE 10
|
||||||
#define DIALOGS_TIP 11
|
#define DIALOGS_TIP 11
|
||||||
#define DIALOGS_EXT_DIALOG 12
|
|
||||||
#define DIALOGS_NUM_ENTRY 13
|
#define DIALOGS_NUM_ENTRY 13
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -36,154 +36,119 @@
|
|||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/stattext.h"
|
#include "wx/stattext.h"
|
||||||
|
#include "wx/sizer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// constants
|
// wxDialogBase
|
||||||
// ----------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
const long wxDialogBase::LAYOUT_X_MARGIN = 5;
|
wxSizer *wxDialogBase::CreateTextSizer( const wxString &message )
|
||||||
const long wxDialogBase::LAYOUT_Y_MARGIN = 5;
|
|
||||||
|
|
||||||
const long wxDialogBase::MARGIN_BETWEEN_BUTTONS = 3*LAYOUT_X_MARGIN;
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// dialog layout functions
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxSize wxDialogBase::SplitTextMessage(const wxString& message,
|
|
||||||
wxArrayString *lines)
|
|
||||||
{
|
{
|
||||||
wxClientDC dc(this);
|
wxBoxSizer *box = new wxBoxSizer( wxVERTICAL );
|
||||||
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
|
||||||
|
wxString line;
|
||||||
wxString curLine;
|
for (size_t pos = 0; pos < message.Len(); pos++)
|
||||||
long height, width, heightTextMax = 0, widthTextMax = 0;
|
|
||||||
for ( const wxChar *pc = message; ; pc++ )
|
|
||||||
{
|
{
|
||||||
if ( *pc == _T('\n') || !*pc )
|
if (message[pos] == _T('\n'))
|
||||||
{
|
{
|
||||||
#if defined(__VISAGECPP__)
|
if (!line.IsEmpty())
|
||||||
// have two versions of this in wxWindowDC tp avoid function hiding
|
|
||||||
// since there are two of these in wxDCBase, and in turn in wxDC.
|
|
||||||
// VA cannot resolve this so:
|
|
||||||
dc.GetTextExtent(curLine, &width, &height, NULL, NULL, NULL, FALSE);
|
|
||||||
#else
|
|
||||||
dc.GetTextExtent(curLine, &width, &height);
|
|
||||||
#endif
|
|
||||||
if ( width > widthTextMax )
|
|
||||||
widthTextMax = width;
|
|
||||||
if ( height > heightTextMax )
|
|
||||||
heightTextMax = height;
|
|
||||||
|
|
||||||
lines->Add(curLine);
|
|
||||||
|
|
||||||
if ( !*pc )
|
|
||||||
{
|
{
|
||||||
// the end of string
|
wxStaticText *s1 = new wxStaticText( this, -1, line );
|
||||||
break;
|
box->Add( s1 );
|
||||||
|
line = _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
curLine.Empty();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
curLine += *pc;
|
line += message[pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxSize(widthTextMax, heightTextMax);
|
// remaining text behind last '\n'
|
||||||
|
if (!line.IsEmpty())
|
||||||
|
{
|
||||||
|
wxStaticText *s2 = new wxStaticText( this, -1, line );
|
||||||
|
box->Add( s2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxDialogBase::CreateTextMessage(const wxArrayString& lines,
|
wxSizer *wxDialogBase::CreateButtonSizer( long flags )
|
||||||
const wxPoint& posText,
|
|
||||||
const wxSize& sizeText)
|
|
||||||
{
|
{
|
||||||
wxStaticText *text;
|
wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL );
|
||||||
int y = posText.y;
|
|
||||||
size_t nLineCount = lines.GetCount();
|
|
||||||
for ( size_t nLine = 0; nLine < nLineCount; nLine++ )
|
|
||||||
{
|
|
||||||
text = new wxStaticText(this, -1, lines[nLine],
|
|
||||||
wxPoint(posText.x, y),
|
|
||||||
sizeText);
|
|
||||||
y += sizeText.GetHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
return y;
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||||
}
|
int margin = 6;
|
||||||
|
|
||||||
wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
int wButton = 0;
|
|
||||||
GetTextExtent(_("OK"), &wButton, NULL);
|
|
||||||
|
|
||||||
if ( hasCancel )
|
|
||||||
{
|
|
||||||
int width;
|
|
||||||
GetTextExtent(_("Cancel"), &width, NULL);
|
|
||||||
if ( width > wButton )
|
|
||||||
wButton = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( wButton < 75 )
|
|
||||||
{
|
|
||||||
// the minimal acceptable width
|
|
||||||
wButton = 75;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// the width of the button is not just the width of the label...
|
|
||||||
wButton += 2*LAYOUT_X_MARGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a nice looking proportion
|
|
||||||
int hButton = (wButton * 23) / 75;
|
|
||||||
|
|
||||||
return wxSize(wButton, hButton);
|
|
||||||
#else
|
#else
|
||||||
return wxButton::GetDefaultSize();
|
int margin = 10;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
void wxDialogBase::CreateStandardButtons(long wDialog,
|
|
||||||
long y,
|
|
||||||
long wButton,
|
|
||||||
long hButton,
|
|
||||||
bool hasCancel)
|
|
||||||
{
|
|
||||||
// NB: create [Ok] first to get the right tab order
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
wxButton *ok = (wxButton *) NULL;
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
wxButton *cancel = (wxButton *) NULL;
|
||||||
|
wxButton *yes = (wxButton *) NULL;
|
||||||
long x = wDialog / 2;
|
wxButton *no = (wxButton *) NULL;
|
||||||
if ( hasCancel )
|
|
||||||
x -= MARGIN_BETWEEN_BUTTONS / 2 + wButton;
|
if (flags & wxYES_NO)
|
||||||
else
|
|
||||||
x -= wButton / 2;
|
|
||||||
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK"),
|
|
||||||
wxPoint(x, y),
|
|
||||||
wxSize(wButton, hButton) );
|
|
||||||
|
|
||||||
if ( hasCancel )
|
|
||||||
{
|
{
|
||||||
x += MARGIN_BETWEEN_BUTTONS + wButton;
|
yes = new wxButton( this, wxID_YES, _("Yes") );
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"),
|
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
||||||
wxPoint(x, y),
|
no = new wxButton( this, wxID_NO, _("No") );
|
||||||
wxSize(wButton, hButton) );
|
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
} else
|
||||||
|
if (flags & wxYES)
|
||||||
|
{
|
||||||
|
yes = new wxButton( this, wxID_YES, _("Yes") );
|
||||||
|
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
} else
|
||||||
|
if (flags & wxNO)
|
||||||
|
{
|
||||||
|
no = new wxButton( this, wxID_NO, _("No") );
|
||||||
|
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
||||||
}
|
}
|
||||||
|
|
||||||
ok->SetDefault();
|
if (flags & wxOK)
|
||||||
ok->SetFocus();
|
{
|
||||||
|
ok = new wxButton( this, wxID_OK, _("OK") );
|
||||||
|
box->Add( ok, 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & wxFORWARD)
|
||||||
|
box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
|
||||||
|
if (flags & wxBACKWARD)
|
||||||
|
box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
|
||||||
|
if (flags & wxSETUP)
|
||||||
|
box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
|
||||||
|
if (flags & wxMORE)
|
||||||
|
box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
|
||||||
|
if (flags & wxHELP)
|
||||||
|
box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
|
||||||
|
if (flags & wxCANCEL)
|
||||||
|
{
|
||||||
|
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
||||||
|
box->Add( cancel, 0, wxLEFT|wxRIGHT, margin );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & wxNO_DEFAULT) == 0)
|
||||||
|
{
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
ok->SetDefault();
|
||||||
|
ok->SetFocus();
|
||||||
|
}
|
||||||
|
else if (yes)
|
||||||
|
{
|
||||||
|
yes->SetDefault();
|
||||||
|
yes->SetFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxDialogBase::GetStandardTextHeight()
|
|
||||||
{
|
|
||||||
return (3*GetCharHeight()) / 2;
|
|
||||||
}
|
|
||||||
|
@@ -232,15 +232,15 @@ void wxSizer::SetDimension( int x, int y, int width, int height )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// wxBox
|
// wxBoxSizer
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
wxBox::wxBox( int orient )
|
wxBoxSizer::wxBoxSizer( int orient )
|
||||||
{
|
{
|
||||||
m_orient = orient;
|
m_orient = orient;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBox::RecalcSizes()
|
void wxBoxSizer::RecalcSizes()
|
||||||
{
|
{
|
||||||
if (m_children.GetCount() == 0)
|
if (m_children.GetCount() == 0)
|
||||||
{
|
{
|
||||||
@@ -328,7 +328,7 @@ void wxBox::RecalcSizes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxBox::CalcMin()
|
wxSize wxBoxSizer::CalcMin()
|
||||||
{
|
{
|
||||||
if (m_children.GetCount() == 0)
|
if (m_children.GetCount() == 0)
|
||||||
return wxSize(2,2);
|
return wxSize(2,2);
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "wx/listbox.h"
|
#include "wx/listbox.h"
|
||||||
#include "wx/stattext.h"
|
#include "wx/stattext.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
|
#include "wx/sizer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
#if wxUSE_STATLINE
|
||||||
@@ -164,9 +165,17 @@ END_EVENT_TABLE()
|
|||||||
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
|
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||||
#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \
|
#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \
|
||||||
wxDIALOG_MODAL | \
|
wxDIALOG_MODAL | \
|
||||||
wxTAB_TRAVERSAL)
|
wxTAB_TRAVERSAL)
|
||||||
|
#else
|
||||||
|
#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \
|
||||||
|
wxDIALOG_MODAL | \
|
||||||
|
wxRESIZE_BORDER | \
|
||||||
|
wxTAB_TRAVERSAL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
|
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
|
||||||
const wxString& message,
|
const wxString& message,
|
||||||
@@ -225,119 +234,47 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent),
|
|||||||
{
|
{
|
||||||
m_selection = 0;
|
m_selection = 0;
|
||||||
m_clientData = NULL;
|
m_clientData = NULL;
|
||||||
|
m_stringSelection = _T("");
|
||||||
|
|
||||||
// calc the message size
|
m_dialogStyle = style;
|
||||||
// ---------------------
|
|
||||||
|
|
||||||
wxArrayString lines;
|
wxBeginBusyCursor();
|
||||||
wxSize sizeText = SplitTextMessage(message, &lines);
|
|
||||||
long heightTextMax = sizeText.GetHeight(),
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
widthTextMax = sizeText.GetWidth();
|
|
||||||
size_t nLineCount = lines.Count();
|
|
||||||
long hTotalMsg = heightTextMax*nLineCount;
|
|
||||||
|
|
||||||
// calc the button size
|
// 1) text message
|
||||||
// --------------------
|
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
|
||||||
|
|
||||||
// always create the OK button - the code below supposes we do have buttons
|
// 2) list box
|
||||||
// and besides the user should have some way to close this dialog
|
m_listbox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
|
||||||
wxASSERT_MSG( style & wxOK, _T("this dialog should have OK button") );
|
n, choices, wxLB_ALWAYS_SB );
|
||||||
|
m_listbox->SetSelection( m_selection );
|
||||||
bool hasCancel = (style & wxCANCEL) != 0;
|
if (clientData)
|
||||||
|
|
||||||
wxSize sizeButtons = GetStandardButtonSize(hasCancel);
|
|
||||||
|
|
||||||
long wButton = sizeButtons.GetWidth(),
|
|
||||||
hButton = sizeButtons.GetHeight();
|
|
||||||
|
|
||||||
long wTotalButtons = wButton;
|
|
||||||
if ( hasCancel )
|
|
||||||
{
|
|
||||||
wTotalButtons *= 2; // second button
|
|
||||||
wTotalButtons += MARGIN_BETWEEN_BUTTONS; // margin between the 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// listbox and stat line
|
|
||||||
// ---------------------
|
|
||||||
|
|
||||||
// make the listbox at least as tall as the message - otherwise it looks
|
|
||||||
// ugly (the lower limit of 300 for the width is arbitrary OTOH)
|
|
||||||
//
|
|
||||||
// NB: we write "n + 2" because the horiz. scrollbar also takes some place
|
|
||||||
long hListbox = wxMax((n + 2) * heightTextMax, hTotalMsg),
|
|
||||||
wListbox = wxMax(300, wxMax(wTotalButtons, widthTextMax));
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
long hStatLine = wxStaticLine::GetDefaultSize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// now the complete dialog size
|
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
long hDialog = 2*LAYOUT_Y_MARGIN + // top margin
|
|
||||||
hTotalMsg + // message
|
|
||||||
2*LAYOUT_Y_MARGIN + // margin between text and listbox
|
|
||||||
hListbox + // listbox
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
LAYOUT_Y_MARGIN + // margin
|
|
||||||
hStatLine + // separator line
|
|
||||||
#endif
|
|
||||||
2*LAYOUT_Y_MARGIN + // margin between listbox and buttons
|
|
||||||
hButton + // button(s)
|
|
||||||
LAYOUT_Y_MARGIN; // bottom margin
|
|
||||||
|
|
||||||
long wDialog = wxMax(wListbox, wxMax(wTotalButtons, widthTextMax)) +
|
|
||||||
4*LAYOUT_X_MARGIN; // 2 from each side
|
|
||||||
|
|
||||||
// create the controls
|
|
||||||
// -------------------
|
|
||||||
|
|
||||||
// message
|
|
||||||
wxStaticText *text;
|
|
||||||
int y = 2*LAYOUT_Y_MARGIN;
|
|
||||||
for ( size_t nLine = 0; nLine < nLineCount; nLine++ )
|
|
||||||
{
|
|
||||||
text = new wxStaticText(this, -1, lines[nLine],
|
|
||||||
wxPoint(2*LAYOUT_X_MARGIN, y),
|
|
||||||
wxSize(widthTextMax, heightTextMax));
|
|
||||||
y += heightTextMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 2*LAYOUT_X_MARGIN;
|
|
||||||
|
|
||||||
// listbox
|
|
||||||
m_listbox = new wxListBox( this, wxID_LISTBOX,
|
|
||||||
wxPoint(2*LAYOUT_X_MARGIN, y),
|
|
||||||
wxSize(wListbox, hListbox),
|
|
||||||
n, choices,
|
|
||||||
wxLB_HSCROLL);
|
|
||||||
y += hListbox;
|
|
||||||
|
|
||||||
if ( clientData )
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
m_listbox->SetClientData(i, clientData[i]);
|
m_listbox->SetClientData(i, clientData[i]);
|
||||||
}
|
}
|
||||||
|
topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
||||||
|
|
||||||
// separator line
|
|
||||||
#if wxUSE_STATLINE
|
#if wxUSE_STATLINE
|
||||||
(void) new wxStaticLine( this, -1,
|
// 3) static line
|
||||||
wxPoint(2*LAYOUT_X_MARGIN, y + LAYOUT_Y_MARGIN),
|
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
||||||
wxSize(wDialog - 4*LAYOUT_X_MARGIN, hStatLine) );
|
|
||||||
|
|
||||||
y += LAYOUT_Y_MARGIN + hStatLine;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// buttons
|
// 4) buttons
|
||||||
|
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
|
||||||
|
|
||||||
y += 2*LAYOUT_X_MARGIN;
|
topsizer->SetSizeHints( this );
|
||||||
|
topsizer->Fit( this );
|
||||||
CreateStandardButtons(wDialog, y, wButton, hButton, hasCancel);
|
SetSizer( topsizer );
|
||||||
|
SetAutoLayout( TRUE );
|
||||||
SetClientSize( wDialog, hDialog );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
Centre( wxBOTH );
|
||||||
|
|
||||||
|
m_listbox->SetFocus();
|
||||||
|
|
||||||
|
wxEndBusyCursor();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,386 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: extdlgg.cpp
|
|
||||||
// Purpose: extended generic dialog
|
|
||||||
// Author: Robert Roebling
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Robert Roebling
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "extdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
#include "wx/statline.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/generic/extdlgg.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// wxExtDialog
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define BUTTON_AREA_MARGIN 10
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxExtDialog, wxDialog)
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxExtDialog, wxDialog)
|
|
||||||
EVT_SIZE(wxExtDialog::OnSize)
|
|
||||||
EVT_BUTTON(wxID_YES, wxExtDialog::OnYes)
|
|
||||||
EVT_BUTTON(wxID_NO, wxExtDialog::OnNo)
|
|
||||||
EVT_BUTTON(wxID_CANCEL, wxExtDialog::OnCancel)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxExtDialog::wxExtDialog( wxWindow *parent, wxWindowID id,
|
|
||||||
const wxString& title, long extraStyle,
|
|
||||||
const wxPoint& pos, const wxSize& size,
|
|
||||||
long style, const wxString &name )
|
|
||||||
{
|
|
||||||
Create( parent, id, title, extraStyle, pos, size, style, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxExtDialog::Create( wxWindow *parent, wxWindowID id,
|
|
||||||
const wxString& title, long extraStyle,
|
|
||||||
const wxPoint& pos, const wxSize& size,
|
|
||||||
long style, const wxString &name )
|
|
||||||
{
|
|
||||||
if (!wxDialog::Create( parent, id, title, pos, size, style, name ))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
m_extraStyle = extraStyle;
|
|
||||||
|
|
||||||
m_clientWindowMargin = 10;
|
|
||||||
|
|
||||||
if (m_windowStyle & wxED_BUTTONS_RIGHT)
|
|
||||||
{
|
|
||||||
m_spacePerButton.x = wxButton::GetDefaultSize().x + 18;
|
|
||||||
m_spacePerButton.y = wxButton::GetDefaultSize().y + 8;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_spacePerButton.x = wxButton::GetDefaultSize().x + 8;
|
|
||||||
m_spacePerButton.y = wxButton::GetDefaultSize().y + 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
|
||||||
// Under Motif and GTK, the default button has a big frame around
|
|
||||||
// it and to avoid overlapping buttons we make the margin bigger.
|
|
||||||
// We could give other platforms a bigger margin as well, but this
|
|
||||||
// wouldn't be standard L&F.
|
|
||||||
m_spacePerButton.x += 10;
|
|
||||||
m_spacePerButton.y += 10;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
wxButton *yes = (wxButton *) NULL;
|
|
||||||
wxButton *no = (wxButton *) NULL;
|
|
||||||
|
|
||||||
|
|
||||||
if (m_extraStyle & wxYES_NO)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
m_buttons.Append( yes );
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
m_buttons.Append( no );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_extraStyle & wxYES)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
m_buttons.Append( yes );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_extraStyle & wxNO)
|
|
||||||
{
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
m_buttons.Append( no );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_extraStyle & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
m_buttons.Append( ok );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_extraStyle & wxFORWARD)
|
|
||||||
AddButton( new wxButton( this, wxID_FORWARD, _("Forward") ) );
|
|
||||||
|
|
||||||
if (m_extraStyle & wxBACKWARD)
|
|
||||||
AddButton( new wxButton( this, wxID_BACKWARD, _("Backward") ) );
|
|
||||||
|
|
||||||
if (m_extraStyle & wxSETUP)
|
|
||||||
AddButton( new wxButton( this, wxID_SETUP, _("Setup") ) );
|
|
||||||
|
|
||||||
if (m_extraStyle & wxMORE)
|
|
||||||
AddButton( new wxButton( this, wxID_MORE, _("More...") ) );
|
|
||||||
|
|
||||||
if (m_extraStyle & wxHELP)
|
|
||||||
AddButton( new wxButton( this, wxID_HELP, _("Help") ) );
|
|
||||||
|
|
||||||
if (m_extraStyle & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
m_buttons.Append( cancel );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((m_extraStyle & wxNO_DEFAULT) == 0)
|
|
||||||
{
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
ok->SetDefault();
|
|
||||||
ok->SetFocus();
|
|
||||||
}
|
|
||||||
else if (yes)
|
|
||||||
{
|
|
||||||
yes->SetDefault();
|
|
||||||
yes->SetFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (style & wxED_STATIC_LINE)
|
|
||||||
{
|
|
||||||
int line_style = wxLI_HORIZONTAL;
|
|
||||||
if (style & wxED_BUTTONS_RIGHT) line_style = wxLI_VERTICAL;
|
|
||||||
|
|
||||||
m_statLine = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, line_style );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_statLine = (wxStaticLine*) NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_extraStyle & wxCENTRE)
|
|
||||||
Centre( wxBOTH );
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::AddButton( wxButton *button )
|
|
||||||
{
|
|
||||||
m_buttons.Append( button );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::SetDefaultButton( wxWindowID button )
|
|
||||||
{
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxButton *but = (wxButton*) node->Data();
|
|
||||||
if (but->GetId() == button)
|
|
||||||
{
|
|
||||||
but->SetDefault();
|
|
||||||
but->SetFocus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::EnableButton( wxWindowID button, bool enable )
|
|
||||||
{
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxButton *but = (wxButton*) node->Data();
|
|
||||||
if (but->GetId() == button)
|
|
||||||
{
|
|
||||||
but->Enable(enable);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxExtDialog::ButtonIsEnabled( wxWindowID button )
|
|
||||||
{
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxButton *but = (wxButton*) node->Data();
|
|
||||||
if (but->GetId() == button)
|
|
||||||
return but->IsEnabled();
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
|
|
||||||
{
|
|
||||||
wxSize client_size( GetClientSize() );
|
|
||||||
wxSize button_area( LayoutButtons() );
|
|
||||||
|
|
||||||
if (HasFlag(wxED_BUTTONS_RIGHT))
|
|
||||||
client_size.x -= button_area.x;
|
|
||||||
else
|
|
||||||
client_size.y -= button_area.y;
|
|
||||||
|
|
||||||
if (m_clientWindow)
|
|
||||||
{
|
|
||||||
if (m_windowStyle & wxED_CLIENT_MARGIN)
|
|
||||||
m_clientWindow->SetSize( m_clientWindowMargin,
|
|
||||||
m_clientWindowMargin,
|
|
||||||
client_size.x - 2*m_clientWindowMargin,
|
|
||||||
client_size.y - 2*m_clientWindowMargin );
|
|
||||||
else
|
|
||||||
m_clientWindow->SetSize( 0, 0, client_size.x, client_size.y );
|
|
||||||
|
|
||||||
if (m_clientWindow->GetAutoLayout())
|
|
||||||
m_clientWindow->Layout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::OnYes(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
EndModal( wxID_YES );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::OnNo(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
EndModal( wxID_NO );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxExtDialog::OnCancel(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
/* allow cancellation via ESC/Close button except if
|
|
||||||
only YES and NO are specified. */
|
|
||||||
if ((m_extraStyle & wxYES_NO) != wxYES_NO || (m_extraStyle & wxCANCEL))
|
|
||||||
{
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize wxExtDialog::GetButtonAreaSize()
|
|
||||||
{
|
|
||||||
if (m_buttons.GetCount() == 0) return wxSize(0,0);
|
|
||||||
|
|
||||||
wxSize ret(0,0);
|
|
||||||
|
|
||||||
if (m_windowStyle & wxED_BUTTONS_RIGHT)
|
|
||||||
{
|
|
||||||
ret.x = m_spacePerButton.x;
|
|
||||||
ret.y = m_buttons.GetCount()*m_spacePerButton.y + 2*BUTTON_AREA_MARGIN;
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
ret.x += wxStaticLine::GetDefaultSize();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret.x = m_buttons.GetCount()*m_spacePerButton.x + 2*BUTTON_AREA_MARGIN;
|
|
||||||
ret.y = m_spacePerButton.y;
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
ret.y += wxStaticLine::GetDefaultSize();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize wxExtDialog::LayoutButtons()
|
|
||||||
{
|
|
||||||
if (m_buttons.GetCount() == 0) return wxSize(0,0);
|
|
||||||
|
|
||||||
wxSize area_used( GetButtonAreaSize() );
|
|
||||||
wxSize client_area( GetClientSize() );
|
|
||||||
|
|
||||||
if (m_windowStyle & wxED_BUTTONS_RIGHT)
|
|
||||||
{
|
|
||||||
area_used.y = client_area.y;
|
|
||||||
wxSize area_used_by_buttons( area_used );
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
area_used_by_buttons.x -= wxStaticLine::GetDefaultSize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int space_for_each_button = (client_area.y-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount();
|
|
||||||
int n = 0;
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxButton *button = (wxButton*)node->Data();
|
|
||||||
|
|
||||||
wxSize button_size( button->GetSize() );
|
|
||||||
if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x;
|
|
||||||
|
|
||||||
int center_of_button_y = n*space_for_each_button + space_for_each_button/2;
|
|
||||||
int button_y = BUTTON_AREA_MARGIN + center_of_button_y - button_size.y/2;
|
|
||||||
|
|
||||||
int center_of_button_x = client_area.x - area_used_by_buttons.x/2;
|
|
||||||
int button_x = center_of_button_x - button_size.x/2;
|
|
||||||
|
|
||||||
button->SetSize( button_x, button_y, button_size.x, button_size.y );
|
|
||||||
|
|
||||||
node = node->Next();
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
m_statLine->SetSize( client_area.x - area_used_by_buttons.x - wxStaticLine::GetDefaultSize(),
|
|
||||||
0,
|
|
||||||
wxStaticLine::GetDefaultSize(),
|
|
||||||
client_area.y );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
area_used.x = client_area.x;
|
|
||||||
wxSize area_used_by_buttons( area_used );
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
area_used_by_buttons.y -= wxStaticLine::GetDefaultSize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int space_for_each_button = (client_area.x-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount();
|
|
||||||
int n = 0;
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxButton *button = (wxButton*)node->Data();
|
|
||||||
|
|
||||||
wxSize button_size( button->GetSize() );
|
|
||||||
if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x;
|
|
||||||
|
|
||||||
int center_of_button_x = n*space_for_each_button + space_for_each_button/2;
|
|
||||||
int button_x = BUTTON_AREA_MARGIN + center_of_button_x - button_size.x/2;
|
|
||||||
|
|
||||||
int center_of_button_y = client_area.y - area_used_by_buttons.y/2;
|
|
||||||
int button_y = center_of_button_y - button_size.y/2;
|
|
||||||
|
|
||||||
button->SetSize( button_x, button_y, button_size.x, button_size.y );
|
|
||||||
|
|
||||||
node = node->Next();
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
if (m_statLine)
|
|
||||||
m_statLine->SetSize( 0,
|
|
||||||
client_area.y - area_used_by_buttons.y - wxStaticLine::GetDefaultSize(),
|
|
||||||
client_area.x,
|
|
||||||
wxStaticLine::GetDefaultSize() );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return area_used;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -29,7 +29,8 @@
|
|||||||
#include "wx/layout.h"
|
#include "wx/layout.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
# include "wx/app.h"
|
#include "wx/sizer.h"
|
||||||
|
#include "wx/app.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -66,170 +67,37 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
|
|||||||
|
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
wxLayoutConstraints *c;
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
SetAutoLayout(TRUE);
|
|
||||||
|
|
||||||
wxStaticBitmap *icon = new wxStaticBitmap(this, -1,
|
wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );
|
||||||
wxTheApp->GetStdIcon(style & wxICON_MASK));
|
|
||||||
const int iconSize = icon->GetBitmap().GetWidth();
|
// 1) icon
|
||||||
|
if (style & wxICON_MASK)
|
||||||
// split the message in lines
|
|
||||||
// --------------------------
|
|
||||||
|
|
||||||
wxArrayString lines;
|
|
||||||
wxSize sizeText = SplitTextMessage(message, &lines);
|
|
||||||
long widthTextMax = sizeText.GetWidth(),
|
|
||||||
heightTextMax = sizeText.GetHeight();
|
|
||||||
size_t nLineCount = lines.GetCount();
|
|
||||||
|
|
||||||
// calculate the total dialog size
|
|
||||||
enum
|
|
||||||
{
|
{
|
||||||
Btn_Ok,
|
wxStaticBitmap *icon = new wxStaticBitmap(
|
||||||
Btn_Yes,
|
this, -1, wxTheApp->GetStdIcon(style & wxICON_MASK));
|
||||||
Btn_No,
|
icon_text->Add( icon, 0, wxCENTER );
|
||||||
Btn_Cancel,
|
|
||||||
Btn_Max
|
|
||||||
};
|
|
||||||
wxButton *buttons[Btn_Max] = { NULL, NULL, NULL, NULL };
|
|
||||||
int nDefaultBtn = -1;
|
|
||||||
|
|
||||||
// some checks are in order...
|
|
||||||
wxASSERT_MSG( !(style & wxOK) || !(style & wxYES_NO),
|
|
||||||
"don't create dialog with both Yes/No and Ok buttons!" );
|
|
||||||
|
|
||||||
wxASSERT_MSG( (style & wxOK ) || (style & wxYES_NO),
|
|
||||||
"don't create dialog with only the Cancel button!" );
|
|
||||||
|
|
||||||
if ( style & wxYES_NO ) {
|
|
||||||
buttons[Btn_Yes] = new wxButton(this, wxID_YES, _("Yes"));
|
|
||||||
buttons[Btn_No] = new wxButton(this, wxID_NO, _("No"));
|
|
||||||
|
|
||||||
|
|
||||||
if(style & wxNO_DEFAULT)
|
|
||||||
nDefaultBtn = Btn_No;
|
|
||||||
else
|
|
||||||
nDefaultBtn = Btn_Yes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2) text
|
||||||
|
icon_text->Add( CreateTextSizer( message ), 0, wxCENTER | wxLEFT, 10 );
|
||||||
|
|
||||||
|
topsizer->Add( icon_text, 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
|
||||||
|
|
||||||
|
#if wxUSE_STATLINE
|
||||||
|
// 3) static line
|
||||||
|
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
||||||
|
#endif
|
||||||
|
|
||||||
if (style & wxOK) {
|
// 4) buttons
|
||||||
buttons[Btn_Ok] = new wxButton(this, wxID_OK, _("OK"));
|
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
|
||||||
|
|
||||||
if ( nDefaultBtn == -1 )
|
topsizer->SetSizeHints( this );
|
||||||
nDefaultBtn = Btn_Ok;
|
topsizer->Fit( this );
|
||||||
}
|
SetSizer( topsizer );
|
||||||
|
SetAutoLayout( TRUE );
|
||||||
|
|
||||||
if (style & wxCANCEL) {
|
Centre( wxBOTH | wxCENTER_FRAME);
|
||||||
buttons[Btn_Cancel] = new wxButton(this, wxID_CANCEL, _("Cancel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the longest caption and also calc the number of buttons
|
|
||||||
size_t nBtn, nButtons = 0;
|
|
||||||
int width, widthBtnMax = 0;
|
|
||||||
for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) {
|
|
||||||
if ( buttons[nBtn] ) {
|
|
||||||
nButtons++;
|
|
||||||
GetTextExtent(buttons[nBtn]->GetLabel(), &width, NULL);
|
|
||||||
if ( width > widthBtnMax )
|
|
||||||
widthBtnMax = width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now we can place the buttons
|
|
||||||
if ( widthBtnMax < 75 )
|
|
||||||
widthBtnMax = 75;
|
|
||||||
else
|
|
||||||
widthBtnMax += 10;
|
|
||||||
long heightButton = widthBtnMax*23/75;
|
|
||||||
|
|
||||||
// *1.2 baselineskip
|
|
||||||
heightTextMax *= 12;
|
|
||||||
heightTextMax /= 10;
|
|
||||||
|
|
||||||
long widthButtonsTotal = nButtons * (widthBtnMax + LAYOUT_X_MARGIN) -
|
|
||||||
LAYOUT_X_MARGIN;
|
|
||||||
|
|
||||||
// the size of the dialog
|
|
||||||
long widthDlg = wxMax(widthTextMax + iconSize + 4*LAYOUT_X_MARGIN,
|
|
||||||
wxMax(widthButtonsTotal, width)) +
|
|
||||||
2*LAYOUT_X_MARGIN,
|
|
||||||
heightDlg = 8*LAYOUT_Y_MARGIN + heightButton +
|
|
||||||
heightTextMax*(nLineCount + 1);
|
|
||||||
|
|
||||||
// create the controls
|
|
||||||
// -------------------
|
|
||||||
|
|
||||||
// the icon first
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
c->width.Absolute(iconSize);
|
|
||||||
c->height.Absolute(iconSize);
|
|
||||||
c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN);
|
|
||||||
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
|
|
||||||
icon->SetConstraints(c);
|
|
||||||
|
|
||||||
wxStaticText *text = NULL;
|
|
||||||
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
if ( text == NULL )
|
|
||||||
c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN);
|
|
||||||
else
|
|
||||||
c->top.Below(text);
|
|
||||||
|
|
||||||
c->left.RightOf(icon, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->width.Absolute(widthTextMax);
|
|
||||||
c->height.Absolute(heightTextMax);
|
|
||||||
text = new wxStaticText(this, -1, lines[nLine]);
|
|
||||||
text->SetConstraints(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the buttons
|
|
||||||
wxButton *btnPrevious = (wxButton *)NULL;
|
|
||||||
for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) {
|
|
||||||
if ( buttons[nBtn] ) {
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
|
|
||||||
if ( btnPrevious ) {
|
|
||||||
c->left.RightOf(btnPrevious, LAYOUT_X_MARGIN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->left.SameAs(this, wxLeft,
|
|
||||||
(widthDlg - widthButtonsTotal) / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
c->width.Absolute(widthBtnMax);
|
|
||||||
c->top.Below(text, 4*LAYOUT_Y_MARGIN);
|
|
||||||
c->height.Absolute(heightButton);
|
|
||||||
buttons[nBtn]->SetConstraints(c);
|
|
||||||
|
|
||||||
btnPrevious = buttons[nBtn];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set default button
|
|
||||||
// ------------------
|
|
||||||
|
|
||||||
if ( nDefaultBtn != -1 ) {
|
|
||||||
buttons[nDefaultBtn]->SetDefault();
|
|
||||||
buttons[nDefaultBtn]->SetFocus();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wxFAIL_MSG( "can't find default button for this dialog." );
|
|
||||||
}
|
|
||||||
|
|
||||||
// position the controls and the dialog itself
|
|
||||||
// -------------------------------------------
|
|
||||||
|
|
||||||
SetClientSize(widthDlg, heightDlg);
|
|
||||||
|
|
||||||
// SetSizeHints() wants the size of the whole dialog, not just client size
|
|
||||||
wxSize sizeTotal = GetSize(),
|
|
||||||
sizeClient = GetClientSize();
|
|
||||||
SetSizeHints(widthDlg + sizeTotal.GetWidth() - sizeClient.GetWidth(),
|
|
||||||
heightDlg + sizeTotal.GetHeight() - sizeClient.GetHeight());
|
|
||||||
|
|
||||||
Layout();
|
|
||||||
|
|
||||||
Centre(wxCENTER_FRAME | wxBOTH);
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
}
|
}
|
||||||
|
@@ -48,35 +48,6 @@
|
|||||||
// this is where wxGetNumberFromUser() is declared
|
// this is where wxGetNumberFromUser() is declared
|
||||||
#include "wx/generic/textdlgg.h"
|
#include "wx/generic/textdlgg.h"
|
||||||
|
|
||||||
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
|
|
||||||
{
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private classes
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -137,15 +108,13 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
|
|||||||
|
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
wxBox *topsizer = new wxBox( wxVERTICAL );
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
// 1) text message
|
// 1) text message
|
||||||
wxBox *textsizer = new wxBox( wxVERTICAL );
|
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
|
||||||
wxSplitMessage2( message, this, textsizer );
|
|
||||||
topsizer->Add( textsizer, 0, wxALL, 10 );
|
|
||||||
|
|
||||||
// 2) prompt and text ctrl
|
// 2) prompt and text ctrl
|
||||||
wxBox *inputsizer = new wxBox( wxHORIZONTAL );
|
wxBoxSizer *inputsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
// prompt if any
|
// prompt if any
|
||||||
if (!prompt.IsEmpty())
|
if (!prompt.IsEmpty())
|
||||||
inputsizer->Add( new wxStaticText( this, -1, prompt ), 0, wxCENTER | wxLEFT, 10 );
|
inputsizer->Add( new wxStaticText( this, -1, prompt ), 0, wxCENTER | wxLEFT, 10 );
|
||||||
@@ -162,26 +131,9 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
|
|||||||
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// 4) buttons
|
// 4) buttons
|
||||||
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
|
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
// if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
// if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
|
|
||||||
|
|
||||||
SetSizer( topsizer );
|
SetSizer( topsizer );
|
||||||
SetAutoLayout( TRUE );
|
SetAutoLayout( TRUE );
|
||||||
|
|
||||||
@@ -190,9 +142,6 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
|
|||||||
|
|
||||||
Centre( wxBOTH );
|
Centre( wxBOTH );
|
||||||
|
|
||||||
if (ok)
|
|
||||||
ok->SetDefault();
|
|
||||||
|
|
||||||
m_spinctrl->SetFocus();
|
m_spinctrl->SetFocus();
|
||||||
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include "wx/stattext.h"
|
#include "wx/stattext.h"
|
||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
|
#include "wx/sizer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
#if wxUSE_STATLINE
|
||||||
@@ -77,55 +78,38 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
|
|||||||
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL),
|
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL),
|
||||||
m_value(value)
|
m_value(value)
|
||||||
{
|
{
|
||||||
// calculate the sizes
|
m_dialogStyle = style;
|
||||||
// -------------------
|
m_value = value;
|
||||||
|
|
||||||
wxArrayString lines;
|
wxBeginBusyCursor();
|
||||||
wxSize sizeText = SplitTextMessage(message, &lines);
|
|
||||||
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
wxSize sizeBtn = GetStandardButtonSize();
|
// 1) text message
|
||||||
|
topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
|
||||||
|
|
||||||
|
// 2) text ctrl
|
||||||
|
m_textctrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
|
||||||
|
topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
||||||
|
|
||||||
long wText = wxMax(4*sizeBtn.GetWidth(), sizeText.GetWidth());
|
#if wxUSE_STATLINE
|
||||||
long hText = GetStandardTextHeight();
|
// 3) static line
|
||||||
|
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
||||||
|
#endif
|
||||||
|
|
||||||
long wDialog = 4*LAYOUT_X_MARGIN + wText;
|
// 4) buttons
|
||||||
long hDialog = 2*LAYOUT_Y_MARGIN +
|
topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
|
||||||
sizeText.GetHeight() * lines.GetCount() +
|
|
||||||
2*LAYOUT_Y_MARGIN +
|
topsizer->SetSizeHints( this );
|
||||||
hText +
|
topsizer->Fit( this );
|
||||||
2*LAYOUT_Y_MARGIN +
|
SetSizer( topsizer );
|
||||||
sizeBtn.GetHeight() +
|
SetAutoLayout( TRUE );
|
||||||
2*LAYOUT_Y_MARGIN;
|
|
||||||
|
|
||||||
// create the controls
|
Centre( wxBOTH );
|
||||||
// -------------------
|
|
||||||
|
|
||||||
// message
|
|
||||||
long x = 2*LAYOUT_X_MARGIN;
|
|
||||||
long y = CreateTextMessage(lines,
|
|
||||||
wxPoint(x, 2*LAYOUT_Y_MARGIN),
|
|
||||||
sizeText);
|
|
||||||
|
|
||||||
y += 2*LAYOUT_X_MARGIN;
|
|
||||||
|
|
||||||
// text ctrl
|
|
||||||
m_textctrl = new wxTextCtrl(this, wxID_TEXT, m_value,
|
|
||||||
wxPoint(x, y),
|
|
||||||
wxSize(wText, hText));
|
|
||||||
y += hText + 2*LAYOUT_X_MARGIN;
|
|
||||||
|
|
||||||
// and buttons
|
|
||||||
CreateStandardButtons(wDialog, y, sizeBtn.GetWidth(), sizeBtn.GetHeight());
|
|
||||||
|
|
||||||
// set the dialog size and position
|
|
||||||
SetClientSize(wDialog, hDialog);
|
|
||||||
if ( pos == wxDefaultPosition )
|
|
||||||
{
|
|
||||||
// centre the dialog if no explicit position given
|
|
||||||
Centre(wxBOTH | wxCENTER_FRAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_textctrl->SetFocus();
|
m_textctrl->SetFocus();
|
||||||
|
|
||||||
|
wxEndBusyCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
|
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
|
||||||
|
@@ -37,10 +37,10 @@
|
|||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/layout.h"
|
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#include "wx/statbmp.h"
|
#include "wx/statbmp.h"
|
||||||
|
#include "wx/sizer.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/statline.h"
|
#include "wx/statline.h"
|
||||||
@@ -164,12 +164,13 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
|
|||||||
{
|
{
|
||||||
m_tipProvider = tipProvider;
|
m_tipProvider = tipProvider;
|
||||||
|
|
||||||
wxSize sizeBtn = GetStandardButtonSize();
|
// 1) create all controls in tab order
|
||||||
wxLayoutConstraints *c;
|
|
||||||
|
|
||||||
// create the controls in the right order, then set the constraints
|
|
||||||
wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("&Close"));
|
wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("&Close"));
|
||||||
|
|
||||||
m_checkbox = new wxCheckBox(this, -1, _("&Show tips at startup"));
|
m_checkbox = new wxCheckBox(this, -1, _("&Show tips at startup"));
|
||||||
|
m_checkbox->SetValue(showAtStartup);
|
||||||
|
|
||||||
wxButton *btnNext = new wxButton(this, wxID_NEXT_TIP, _("&Next"));
|
wxButton *btnNext = new wxButton(this, wxID_NEXT_TIP, _("&Next"));
|
||||||
|
|
||||||
wxTextCtrl *text = new wxTextCtrl(this, -1, _("Did you know..."),
|
wxTextCtrl *text = new wxTextCtrl(this, -1, _("Did you know..."),
|
||||||
@@ -179,7 +180,7 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
|
|||||||
text->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE));
|
text->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE));
|
||||||
|
|
||||||
m_text = new wxTextCtrl(this, -1, _T(""),
|
m_text = new wxTextCtrl(this, -1, _T(""),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxSize(200, 160),
|
||||||
wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER);
|
wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER);
|
||||||
m_text->SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL));
|
m_text->SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL));
|
||||||
|
|
||||||
@@ -189,63 +190,35 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
|
|||||||
#include "wx/generic/tip.xpm"
|
#include "wx/generic/tip.xpm"
|
||||||
wxIcon icon(tipIcon);
|
wxIcon icon(tipIcon);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxStaticBitmap *bmp = new wxStaticBitmap(this, -1, icon);
|
wxStaticBitmap *bmp = new wxStaticBitmap(this, -1, icon);
|
||||||
|
|
||||||
const int iconSize = icon.GetWidth();
|
// 2) put them in boxes
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
c->top.SameAs(this, wxTop, 2*LAYOUT_Y_MARGIN);
|
|
||||||
c->left.RightOf(bmp, 2*LAYOUT_X_MARGIN);
|
wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );
|
||||||
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
|
icon_text->Add( bmp, 0, wxCENTER );
|
||||||
c->height.Absolute(2*text->GetSize().GetHeight());
|
icon_text->Add( text, 1, wxCENTER | wxLEFT, 10 );
|
||||||
text->SetConstraints(c);
|
topsizer->Add( icon_text, 0, wxEXPAND | wxALL, 10 );
|
||||||
|
|
||||||
|
topsizer->Add( m_text, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
wxBoxSizer *bottom = new wxBoxSizer( wxHORIZONTAL );
|
||||||
c->centreY.SameAs(text, wxCentreY);
|
bottom->Add( m_checkbox, 0, wxCENTER );
|
||||||
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
|
bottom->Add( btnNext, 0, wxCENTER | wxLEFT, 10 );
|
||||||
c->width.Absolute(iconSize);
|
bottom->Add( btnClose, 0, wxCENTER | wxLEFT, 10 );
|
||||||
c->height.Absolute(iconSize);
|
topsizer->Add( bottom, 0, wxALIGN_RIGHT | wxALL, 10 );
|
||||||
bmp->SetConstraints(c);
|
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->width.Absolute(sizeBtn.GetWidth());
|
|
||||||
c->height.Absolute(sizeBtn.GetHeight());
|
|
||||||
btnClose->SetConstraints(c);
|
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->right.LeftOf(btnClose, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->width.Absolute(sizeBtn.GetWidth());
|
|
||||||
c->height.Absolute(sizeBtn.GetHeight());
|
|
||||||
btnNext->SetConstraints(c);
|
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->width.AsIs();
|
|
||||||
c->height.AsIs();
|
|
||||||
m_checkbox->SetConstraints(c);
|
|
||||||
m_checkbox->SetValue(showAtStartup);
|
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
|
||||||
c->top.Below(text);
|
|
||||||
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
|
|
||||||
c->bottom.Above(btnClose, -2*LAYOUT_Y_MARGIN);
|
|
||||||
m_text->SetConstraints(c);
|
|
||||||
|
|
||||||
SetTipText();
|
SetTipText();
|
||||||
|
|
||||||
|
SetAutoLayout(TRUE);
|
||||||
|
SetSizer( topsizer );
|
||||||
|
|
||||||
|
topsizer->SetSizeHints( this );
|
||||||
|
topsizer->Fit( this );
|
||||||
|
|
||||||
Centre(wxBOTH | wxCENTER_FRAME);
|
Centre(wxBOTH | wxCENTER_FRAME);
|
||||||
|
|
||||||
wxSize size(5*sizeBtn.GetWidth(), 10*sizeBtn.GetHeight());
|
|
||||||
SetSize(size);
|
|
||||||
SetSizeHints(size.x, size.y);
|
|
||||||
|
|
||||||
SetAutoLayout(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \
|
|||||||
\
|
\
|
||||||
busyinfo.cpp \
|
busyinfo.cpp \
|
||||||
caret.cpp \
|
caret.cpp \
|
||||||
|
choicdgg.cpp \
|
||||||
colrdlgg.cpp \
|
colrdlgg.cpp \
|
||||||
dcpsg.cpp \
|
dcpsg.cpp \
|
||||||
dirdlgg.cpp \
|
dirdlgg.cpp \
|
||||||
extdlgg.cpp \
|
|
||||||
fontdlgg.cpp \
|
fontdlgg.cpp \
|
||||||
gridg.cpp \
|
gridg.cpp \
|
||||||
helpext.cpp \
|
helpext.cpp \
|
||||||
@@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
imaglist.cpp \
|
imaglist.cpp \
|
||||||
laywin.cpp \
|
laywin.cpp \
|
||||||
listctrl.cpp \
|
listctrl.cpp \
|
||||||
|
msgdlgg.cpp \
|
||||||
numdlgg.cpp \
|
numdlgg.cpp \
|
||||||
panelg.cpp \
|
panelg.cpp \
|
||||||
printps.cpp \
|
printps.cpp \
|
||||||
@@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
splitter.cpp \
|
splitter.cpp \
|
||||||
statusbr.cpp \
|
statusbr.cpp \
|
||||||
tabg.cpp \
|
tabg.cpp \
|
||||||
|
textdlgg.cpp \
|
||||||
tipdlg.cpp \
|
tipdlg.cpp \
|
||||||
treectrl.cpp \
|
treectrl.cpp \
|
||||||
\
|
\
|
||||||
@@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
checkbox.cpp \
|
checkbox.cpp \
|
||||||
checklst.cpp \
|
checklst.cpp \
|
||||||
choice.cpp \
|
choice.cpp \
|
||||||
choicdlg.cpp \
|
|
||||||
clipbrd.cpp \
|
clipbrd.cpp \
|
||||||
colour.cpp \
|
colour.cpp \
|
||||||
combobox.cpp \
|
combobox.cpp \
|
||||||
@@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
mdi.cpp \
|
mdi.cpp \
|
||||||
menu.cpp \
|
menu.cpp \
|
||||||
minifram.cpp \
|
minifram.cpp \
|
||||||
msgdlg.cpp \
|
|
||||||
notebook.cpp \
|
notebook.cpp \
|
||||||
palette.cpp \
|
palette.cpp \
|
||||||
pen.cpp \
|
pen.cpp \
|
||||||
@@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
stattext.cpp \
|
stattext.cpp \
|
||||||
tbargtk.cpp \
|
tbargtk.cpp \
|
||||||
textctrl.cpp \
|
textctrl.cpp \
|
||||||
textdlg.cpp \
|
|
||||||
timer.cpp \
|
timer.cpp \
|
||||||
tooltip.cpp \
|
tooltip.cpp \
|
||||||
utilsgtk.cpp \
|
utilsgtk.cpp \
|
||||||
|
@@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
|
|||||||
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
|
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
|
||||||
|
|
||||||
wxSize newSize = size;
|
wxSize newSize = size;
|
||||||
if (newSize.x == -1) newSize.x = 12+x;
|
if (newSize.x == -1)
|
||||||
if (newSize.y == -1) newSize.y = 11+y;
|
{
|
||||||
|
newSize.x = 12+x;
|
||||||
|
if (newSize.x < 80) newSize.x = 80;
|
||||||
|
}
|
||||||
|
if (newSize.y == -1)
|
||||||
|
{
|
||||||
|
newSize.y = 11+y;
|
||||||
|
if (newSize.x < 26) newSize.x = 26;
|
||||||
|
}
|
||||||
|
|
||||||
SetSize( newSize.x, newSize.y );
|
SetSize( newSize.x, newSize.y );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
|
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
|
||||||
|
@@ -1,332 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: choicdgg.cpp
|
|
||||||
// Purpose: Choice dialogs
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "choicdgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/listbox.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/sizer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
#include "wx/statline.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/gtk/choicdlg.h"
|
|
||||||
|
|
||||||
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
|
|
||||||
{
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return dialog.GetStringSelection();
|
|
||||||
else
|
|
||||||
return _T("");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
|
|
||||||
char *choices[], wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
strings[i] = choices[i];
|
|
||||||
}
|
|
||||||
wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent,
|
|
||||||
x, y, centre, width, height));
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return dialog.GetSelection();
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
|
|
||||||
wxChar *choices[], wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
for ( int i = 0; i < n; i++)
|
|
||||||
strings[i] = choices[i];
|
|
||||||
int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent,
|
|
||||||
x, y, centre, width, height);
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, char **client_data, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return (wxChar *)dialog.GetSelectionClientData();
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
|
|
||||||
wxChar *choices[], char **client_data, wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
strings[i] = choices[i];
|
|
||||||
}
|
|
||||||
wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent,
|
|
||||||
x, y, centre, width, height);
|
|
||||||
delete[] strings;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Multiple choice dialog contributed by Robert Cowell
|
|
||||||
*
|
|
||||||
|
|
||||||
The new data passed are in the "int nsel" and "int * selection"
|
|
||||||
|
|
||||||
The idea is to make a multiple selection from list of strings.
|
|
||||||
The returned value is the total number selected. initialily there
|
|
||||||
are nsel selected, with indices stored in
|
|
||||||
selection[0],...,selection[nsel-1] which appear highlighted to
|
|
||||||
begin with. On exit with value i
|
|
||||||
selection[0..i-1] contains the indices of the selected items.
|
|
||||||
(Some prior selectecions might be deselected.)
|
|
||||||
Thus selection must be as big as choices, in case all items are
|
|
||||||
selected.
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
int wxGetMultipleChoice(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices,
|
|
||||||
int nsel, int * selection,
|
|
||||||
wxWindow *parent , int x , int y, bool centre,
|
|
||||||
int width, int height)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// wxSingleChoiceDialog
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
|
|
||||||
EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
|
|
||||||
{
|
|
||||||
Create(parent, message, caption, n, choices, clientData, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
|
|
||||||
{
|
|
||||||
Create(parent, message, caption, choices, clientData, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData, long style, const wxPoint& pos)
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[choices.Number()];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < choices.Number(); i++)
|
|
||||||
{
|
|
||||||
strings[i] = (char *)choices.Nth(i)->Data();
|
|
||||||
}
|
|
||||||
bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos);
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message,
|
|
||||||
const wxString& WXUNUSED(caption), int n,
|
|
||||||
const wxString *choices, char **clientData, long style,
|
|
||||||
const wxPoint& WXUNUSED(pos) )
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
m_selection = 0;
|
|
||||||
m_stringSelection = _T("");
|
|
||||||
m_clientData = NULL;
|
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
wxBox *topsizer = new wxBox( wxVERTICAL );
|
|
||||||
|
|
||||||
// 1) text message
|
|
||||||
wxBox *textsizer = new wxBox( wxVERTICAL );
|
|
||||||
wxSplitMessage2( message, this, textsizer );
|
|
||||||
topsizer->Add( textsizer, 0, wxALL, 10 );
|
|
||||||
|
|
||||||
// 2) list box
|
|
||||||
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
|
|
||||||
n, choices, wxLB_ALWAYS_SB );
|
|
||||||
listBox->SetSelection( m_selection );
|
|
||||||
if (clientData)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
listBox->SetClientData(i, clientData[i]);
|
|
||||||
}
|
|
||||||
topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
|
||||||
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
// 3) static line
|
|
||||||
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// 4) buttons
|
|
||||||
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
|
|
||||||
|
|
||||||
topsizer->SetSizeHints( this );
|
|
||||||
topsizer->Fit( this );
|
|
||||||
SetSizer( topsizer );
|
|
||||||
SetAutoLayout( TRUE );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
ok->SetDefault();
|
|
||||||
|
|
||||||
listBox->SetFocus();
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the selection
|
|
||||||
void wxSingleChoiceDialog::SetSelection(int sel)
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if (listBox)
|
|
||||||
{
|
|
||||||
listBox->SetSelection(sel);
|
|
||||||
}
|
|
||||||
m_selection = sel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if ( listBox )
|
|
||||||
{
|
|
||||||
m_selection = listBox->GetSelection();
|
|
||||||
m_stringSelection = listBox->GetStringSelection();
|
|
||||||
m_clientData = listBox->GetClientData(m_selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if ( listBox )
|
|
||||||
{
|
|
||||||
m_selection = listBox->GetSelection();
|
|
||||||
m_stringSelection = listBox->GetStringSelection();
|
|
||||||
m_clientData = listBox->GetClientData(m_selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# This file was automatically generated by tmake at 19:48, 1999/08/10
|
# This file was automatically generated by tmake at 09:46, 1999/08/11
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
|
|||||||
GTK_GENERICOBJS = \
|
GTK_GENERICOBJS = \
|
||||||
../generic/busyinfo.o \
|
../generic/busyinfo.o \
|
||||||
../generic/caret.o \
|
../generic/caret.o \
|
||||||
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/imaglist.o \
|
../generic/imaglist.o \
|
||||||
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
|
|||||||
../generic/scrolwin.o \
|
../generic/scrolwin.o \
|
||||||
../generic/splitter.o \
|
../generic/splitter.o \
|
||||||
../generic/statusbr.o \
|
../generic/statusbr.o \
|
||||||
|
../generic/textdlgg.o \
|
||||||
../generic/tipdlg.o \
|
../generic/tipdlg.o \
|
||||||
../generic/treectrl.o
|
../generic/treectrl.o
|
||||||
|
|
||||||
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/button.o \
|
../gtk/button.o \
|
||||||
../gtk/checkbox.o \
|
../gtk/checkbox.o \
|
||||||
../gtk/checklst.o \
|
../gtk/checklst.o \
|
||||||
../gtk/choicdlg.o \
|
|
||||||
../gtk/choice.o \
|
../gtk/choice.o \
|
||||||
../gtk/clipbrd.o \
|
../gtk/clipbrd.o \
|
||||||
../gtk/colour.o \
|
../gtk/colour.o \
|
||||||
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/stattext.o \
|
../gtk/stattext.o \
|
||||||
../gtk/tbargtk.o \
|
../gtk/tbargtk.o \
|
||||||
../gtk/textctrl.o \
|
../gtk/textctrl.o \
|
||||||
../gtk/textdlg.o \
|
|
||||||
../gtk/timer.o \
|
../gtk/timer.o \
|
||||||
../gtk/tooltip.o \
|
../gtk/tooltip.o \
|
||||||
../gtk/utilsgtk.o \
|
../gtk/utilsgtk.o \
|
||||||
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
|
|||||||
../generic/choicdgg.o \
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/helpxlp.o \
|
../generic/helpxlp.o \
|
||||||
|
@@ -1,197 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: msgdlgg.cpp
|
|
||||||
// Purpose: wxGenericMessageDialog
|
|
||||||
// Author: Julian Smart, Robert Roebling
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "msgdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/listbox.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/statbmp.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/layout.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/bitmap.h"
|
|
||||||
#include "wx/app.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "wx/gtk/msgdlg.h"
|
|
||||||
#include "wx/statline.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
|
||||||
// New dialog box implementations
|
|
||||||
|
|
||||||
// Split message, using constraints to position controls
|
|
||||||
wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x )
|
|
||||||
{
|
|
||||||
int y = 15;
|
|
||||||
int w = 50;
|
|
||||||
wxString line( _T("") );
|
|
||||||
for (uint pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
|
|
||||||
wxSize size1( s1->GetSize() );
|
|
||||||
if (size1.x > w) w = size1.x;
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
y += 18;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
|
|
||||||
wxSize size2( s2->GetSize() );
|
|
||||||
if (size2.x > w) w = size2.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 18;
|
|
||||||
|
|
||||||
return wxSize(w+15+text_pos_x,y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
|
|
||||||
EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
|
|
||||||
EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message,
|
|
||||||
const wxString& caption, long style, const wxPoint& pos) :
|
|
||||||
wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
|
|
||||||
int text_pos_x = 15;
|
|
||||||
|
|
||||||
if (m_dialogStyle & wxICON_MASK)
|
|
||||||
text_pos_x += 80;
|
|
||||||
|
|
||||||
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
|
|
||||||
|
|
||||||
if (m_dialogStyle & wxICON_MASK)
|
|
||||||
{
|
|
||||||
if (message_size.y < 50) message_size.y = 50;
|
|
||||||
(void) new wxStaticBitmap( this, -1,
|
|
||||||
wxTheApp->GetStdIcon(m_dialogStyle
|
|
||||||
& wxICON_MASK),
|
|
||||||
wxPoint(15,message_size.y/2-16) );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
wxButton *yes = (wxButton *) NULL;
|
|
||||||
wxButton *no = (wxButton *) NULL;
|
|
||||||
|
|
||||||
int y = message_size.y + 30;
|
|
||||||
|
|
||||||
if (style & wxYES_NO)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( yes );
|
|
||||||
no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( no );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( ok );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( cancel );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
ok->SetDefault();
|
|
||||||
ok->SetFocus();
|
|
||||||
}
|
|
||||||
else if (yes)
|
|
||||||
{
|
|
||||||
yes->SetDefault();
|
|
||||||
yes->SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = m_buttons.GetCount() * 100;
|
|
||||||
if (message_size.x > w) w = message_size.x;
|
|
||||||
int space = w / (m_buttons.GetCount()*2);
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow*)node->Data();
|
|
||||||
int x = (n*2+1)*space - 40 + 15;
|
|
||||||
win->Move( x, -1 );
|
|
||||||
node = node->Next();
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
int edge_margin = 7;
|
|
||||||
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SetSize( w+30, y+40 );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
EndModal( wxID_YES );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
EndModal( wxID_NO );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
/* Allow cancellation via ESC/Close button except if
|
|
||||||
only YES and NO are specified. */
|
|
||||||
if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) )
|
|
||||||
{
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,146 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: textdlgg.cpp
|
|
||||||
// Purpose: wxTextEntryDialog
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "textdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/textctrl.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/sizer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
#include "wx/statline.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/gtk/textdlg.h"
|
|
||||||
|
|
||||||
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
|
|
||||||
{
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// wxTextEntryDialog
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxString& value, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
m_value = value;
|
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
wxBox *topsizer = new wxBox( wxVERTICAL );
|
|
||||||
|
|
||||||
// 1) text message
|
|
||||||
wxBox *textsizer = new wxBox( wxVERTICAL );
|
|
||||||
wxSplitMessage2( message, this, textsizer );
|
|
||||||
topsizer->Add( textsizer, 0, wxALL, 10 );
|
|
||||||
|
|
||||||
// 2) text ctrl
|
|
||||||
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
|
|
||||||
topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
// 3) static line
|
|
||||||
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// 4) buttons
|
|
||||||
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
|
|
||||||
|
|
||||||
topsizer->SetSizeHints( this );
|
|
||||||
topsizer->Fit( this );
|
|
||||||
SetSizer( topsizer );
|
|
||||||
SetAutoLayout( TRUE );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
ok->SetDefault();
|
|
||||||
|
|
||||||
textCtrl->SetFocus();
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
|
|
||||||
{
|
|
||||||
wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT);
|
|
||||||
if ( textCtrl )
|
|
||||||
m_value = textCtrl->GetValue();
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
@@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \
|
|||||||
\
|
\
|
||||||
busyinfo.cpp \
|
busyinfo.cpp \
|
||||||
caret.cpp \
|
caret.cpp \
|
||||||
|
choicdgg.cpp \
|
||||||
colrdlgg.cpp \
|
colrdlgg.cpp \
|
||||||
dcpsg.cpp \
|
dcpsg.cpp \
|
||||||
dirdlgg.cpp \
|
dirdlgg.cpp \
|
||||||
extdlgg.cpp \
|
|
||||||
fontdlgg.cpp \
|
fontdlgg.cpp \
|
||||||
gridg.cpp \
|
gridg.cpp \
|
||||||
helpext.cpp \
|
helpext.cpp \
|
||||||
@@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
imaglist.cpp \
|
imaglist.cpp \
|
||||||
laywin.cpp \
|
laywin.cpp \
|
||||||
listctrl.cpp \
|
listctrl.cpp \
|
||||||
|
msgdlgg.cpp \
|
||||||
numdlgg.cpp \
|
numdlgg.cpp \
|
||||||
panelg.cpp \
|
panelg.cpp \
|
||||||
printps.cpp \
|
printps.cpp \
|
||||||
@@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
splitter.cpp \
|
splitter.cpp \
|
||||||
statusbr.cpp \
|
statusbr.cpp \
|
||||||
tabg.cpp \
|
tabg.cpp \
|
||||||
|
textdlgg.cpp \
|
||||||
tipdlg.cpp \
|
tipdlg.cpp \
|
||||||
treectrl.cpp \
|
treectrl.cpp \
|
||||||
\
|
\
|
||||||
@@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
checkbox.cpp \
|
checkbox.cpp \
|
||||||
checklst.cpp \
|
checklst.cpp \
|
||||||
choice.cpp \
|
choice.cpp \
|
||||||
choicdlg.cpp \
|
|
||||||
clipbrd.cpp \
|
clipbrd.cpp \
|
||||||
colour.cpp \
|
colour.cpp \
|
||||||
combobox.cpp \
|
combobox.cpp \
|
||||||
@@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
mdi.cpp \
|
mdi.cpp \
|
||||||
menu.cpp \
|
menu.cpp \
|
||||||
minifram.cpp \
|
minifram.cpp \
|
||||||
msgdlg.cpp \
|
|
||||||
notebook.cpp \
|
notebook.cpp \
|
||||||
palette.cpp \
|
palette.cpp \
|
||||||
pen.cpp \
|
pen.cpp \
|
||||||
@@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \
|
|||||||
stattext.cpp \
|
stattext.cpp \
|
||||||
tbargtk.cpp \
|
tbargtk.cpp \
|
||||||
textctrl.cpp \
|
textctrl.cpp \
|
||||||
textdlg.cpp \
|
|
||||||
timer.cpp \
|
timer.cpp \
|
||||||
tooltip.cpp \
|
tooltip.cpp \
|
||||||
utilsgtk.cpp \
|
utilsgtk.cpp \
|
||||||
|
@@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
|
|||||||
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
|
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );
|
||||||
|
|
||||||
wxSize newSize = size;
|
wxSize newSize = size;
|
||||||
if (newSize.x == -1) newSize.x = 12+x;
|
if (newSize.x == -1)
|
||||||
if (newSize.y == -1) newSize.y = 11+y;
|
{
|
||||||
|
newSize.x = 12+x;
|
||||||
|
if (newSize.x < 80) newSize.x = 80;
|
||||||
|
}
|
||||||
|
if (newSize.y == -1)
|
||||||
|
{
|
||||||
|
newSize.y = 11+y;
|
||||||
|
if (newSize.x < 26) newSize.x = 26;
|
||||||
|
}
|
||||||
|
|
||||||
SetSize( newSize.x, newSize.y );
|
SetSize( newSize.x, newSize.y );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
|
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
|
||||||
|
@@ -1,332 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: choicdgg.cpp
|
|
||||||
// Purpose: Choice dialogs
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "choicdgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/listbox.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/sizer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
#include "wx/statline.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/gtk/choicdlg.h"
|
|
||||||
|
|
||||||
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
|
|
||||||
{
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return dialog.GetStringSelection();
|
|
||||||
else
|
|
||||||
return _T("");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n,
|
|
||||||
char *choices[], wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
strings[i] = choices[i];
|
|
||||||
}
|
|
||||||
wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent,
|
|
||||||
x, y, centre, width, height));
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return dialog.GetSelection();
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n,
|
|
||||||
wxChar *choices[], wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
for ( int i = 0; i < n; i++)
|
|
||||||
strings[i] = choices[i];
|
|
||||||
int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent,
|
|
||||||
x, y, centre, width, height);
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
|
|
||||||
const wxString *choices, char **client_data, wxWindow *parent,
|
|
||||||
int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre),
|
|
||||||
int WXUNUSED(width), int WXUNUSED(height) )
|
|
||||||
{
|
|
||||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
|
||||||
return (wxChar *)dialog.GetSelectionClientData();
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overloaded for backward compatibility
|
|
||||||
wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n,
|
|
||||||
wxChar *choices[], char **client_data, wxWindow *parent,
|
|
||||||
int x, int y, bool centre,
|
|
||||||
int width, int height )
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[n];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
strings[i] = choices[i];
|
|
||||||
}
|
|
||||||
wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent,
|
|
||||||
x, y, centre, width, height);
|
|
||||||
delete[] strings;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Multiple choice dialog contributed by Robert Cowell
|
|
||||||
*
|
|
||||||
|
|
||||||
The new data passed are in the "int nsel" and "int * selection"
|
|
||||||
|
|
||||||
The idea is to make a multiple selection from list of strings.
|
|
||||||
The returned value is the total number selected. initialily there
|
|
||||||
are nsel selected, with indices stored in
|
|
||||||
selection[0],...,selection[nsel-1] which appear highlighted to
|
|
||||||
begin with. On exit with value i
|
|
||||||
selection[0..i-1] contains the indices of the selected items.
|
|
||||||
(Some prior selectecions might be deselected.)
|
|
||||||
Thus selection must be as big as choices, in case all items are
|
|
||||||
selected.
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
int wxGetMultipleChoice(const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices,
|
|
||||||
int nsel, int * selection,
|
|
||||||
wxWindow *parent , int x , int y, bool centre,
|
|
||||||
int width, int height)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// wxSingleChoiceDialog
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK)
|
|
||||||
EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
int n, const wxString *choices, char **clientData, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
|
|
||||||
{
|
|
||||||
Create(parent, message, caption, n, choices, clientData, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
|
|
||||||
{
|
|
||||||
Create(parent, message, caption, choices, clientData, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxStringList& choices, char **clientData, long style, const wxPoint& pos)
|
|
||||||
{
|
|
||||||
wxString *strings = new wxString[choices.Number()];
|
|
||||||
int i;
|
|
||||||
for ( i = 0; i < choices.Number(); i++)
|
|
||||||
{
|
|
||||||
strings[i] = (char *)choices.Nth(i)->Data();
|
|
||||||
}
|
|
||||||
bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos);
|
|
||||||
delete[] strings;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message,
|
|
||||||
const wxString& WXUNUSED(caption), int n,
|
|
||||||
const wxString *choices, char **clientData, long style,
|
|
||||||
const wxPoint& WXUNUSED(pos) )
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
m_selection = 0;
|
|
||||||
m_stringSelection = _T("");
|
|
||||||
m_clientData = NULL;
|
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
wxBox *topsizer = new wxBox( wxVERTICAL );
|
|
||||||
|
|
||||||
// 1) text message
|
|
||||||
wxBox *textsizer = new wxBox( wxVERTICAL );
|
|
||||||
wxSplitMessage2( message, this, textsizer );
|
|
||||||
topsizer->Add( textsizer, 0, wxALL, 10 );
|
|
||||||
|
|
||||||
// 2) list box
|
|
||||||
wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) ,
|
|
||||||
n, choices, wxLB_ALWAYS_SB );
|
|
||||||
listBox->SetSelection( m_selection );
|
|
||||||
if (clientData)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
listBox->SetClientData(i, clientData[i]);
|
|
||||||
}
|
|
||||||
topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
|
||||||
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
// 3) static line
|
|
||||||
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// 4) buttons
|
|
||||||
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
|
|
||||||
|
|
||||||
topsizer->SetSizeHints( this );
|
|
||||||
topsizer->Fit( this );
|
|
||||||
SetSizer( topsizer );
|
|
||||||
SetAutoLayout( TRUE );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
ok->SetDefault();
|
|
||||||
|
|
||||||
listBox->SetFocus();
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the selection
|
|
||||||
void wxSingleChoiceDialog::SetSelection(int sel)
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if (listBox)
|
|
||||||
{
|
|
||||||
listBox->SetSelection(sel);
|
|
||||||
}
|
|
||||||
m_selection = sel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if ( listBox )
|
|
||||||
{
|
|
||||||
m_selection = listBox->GetSelection();
|
|
||||||
m_stringSelection = listBox->GetStringSelection();
|
|
||||||
m_clientData = listBox->GetClientData(m_selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
|
|
||||||
if ( listBox )
|
|
||||||
{
|
|
||||||
m_selection = listBox->GetSelection();
|
|
||||||
m_stringSelection = listBox->GetStringSelection();
|
|
||||||
m_clientData = listBox->GetClientData(m_selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# This file was automatically generated by tmake at 19:48, 1999/08/10
|
# This file was automatically generated by tmake at 09:46, 1999/08/11
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
|
|||||||
GTK_GENERICOBJS = \
|
GTK_GENERICOBJS = \
|
||||||
../generic/busyinfo.o \
|
../generic/busyinfo.o \
|
||||||
../generic/caret.o \
|
../generic/caret.o \
|
||||||
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/imaglist.o \
|
../generic/imaglist.o \
|
||||||
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
|
|||||||
../generic/scrolwin.o \
|
../generic/scrolwin.o \
|
||||||
../generic/splitter.o \
|
../generic/splitter.o \
|
||||||
../generic/statusbr.o \
|
../generic/statusbr.o \
|
||||||
|
../generic/textdlgg.o \
|
||||||
../generic/tipdlg.o \
|
../generic/tipdlg.o \
|
||||||
../generic/treectrl.o
|
../generic/treectrl.o
|
||||||
|
|
||||||
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/button.o \
|
../gtk/button.o \
|
||||||
../gtk/checkbox.o \
|
../gtk/checkbox.o \
|
||||||
../gtk/checklst.o \
|
../gtk/checklst.o \
|
||||||
../gtk/choicdlg.o \
|
|
||||||
../gtk/choice.o \
|
../gtk/choice.o \
|
||||||
../gtk/clipbrd.o \
|
../gtk/clipbrd.o \
|
||||||
../gtk/colour.o \
|
../gtk/colour.o \
|
||||||
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/stattext.o \
|
../gtk/stattext.o \
|
||||||
../gtk/tbargtk.o \
|
../gtk/tbargtk.o \
|
||||||
../gtk/textctrl.o \
|
../gtk/textctrl.o \
|
||||||
../gtk/textdlg.o \
|
|
||||||
../gtk/timer.o \
|
../gtk/timer.o \
|
||||||
../gtk/tooltip.o \
|
../gtk/tooltip.o \
|
||||||
../gtk/utilsgtk.o \
|
../gtk/utilsgtk.o \
|
||||||
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
|
|||||||
../generic/choicdgg.o \
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/helpxlp.o \
|
../generic/helpxlp.o \
|
||||||
|
@@ -1,197 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: msgdlgg.cpp
|
|
||||||
// Purpose: wxGenericMessageDialog
|
|
||||||
// Author: Julian Smart, Robert Roebling
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "msgdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/listbox.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/statbmp.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/layout.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/bitmap.h"
|
|
||||||
#include "wx/app.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "wx/gtk/msgdlg.h"
|
|
||||||
#include "wx/statline.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
|
||||||
// New dialog box implementations
|
|
||||||
|
|
||||||
// Split message, using constraints to position controls
|
|
||||||
wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x )
|
|
||||||
{
|
|
||||||
int y = 15;
|
|
||||||
int w = 50;
|
|
||||||
wxString line( _T("") );
|
|
||||||
for (uint pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
|
|
||||||
wxSize size1( s1->GetSize() );
|
|
||||||
if (size1.x > w) w = size1.x;
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
y += 18;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) );
|
|
||||||
wxSize size2( s2->GetSize() );
|
|
||||||
if (size2.x > w) w = size2.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 18;
|
|
||||||
|
|
||||||
return wxSize(w+15+text_pos_x,y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes)
|
|
||||||
EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo)
|
|
||||||
EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message,
|
|
||||||
const wxString& caption, long style, const wxPoint& pos) :
|
|
||||||
wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
|
|
||||||
int text_pos_x = 15;
|
|
||||||
|
|
||||||
if (m_dialogStyle & wxICON_MASK)
|
|
||||||
text_pos_x += 80;
|
|
||||||
|
|
||||||
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
|
|
||||||
|
|
||||||
if (m_dialogStyle & wxICON_MASK)
|
|
||||||
{
|
|
||||||
if (message_size.y < 50) message_size.y = 50;
|
|
||||||
(void) new wxStaticBitmap( this, -1,
|
|
||||||
wxTheApp->GetStdIcon(m_dialogStyle
|
|
||||||
& wxICON_MASK),
|
|
||||||
wxPoint(15,message_size.y/2-16) );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
wxButton *yes = (wxButton *) NULL;
|
|
||||||
wxButton *no = (wxButton *) NULL;
|
|
||||||
|
|
||||||
int y = message_size.y + 30;
|
|
||||||
|
|
||||||
if (style & wxYES_NO)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( yes );
|
|
||||||
no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( no );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( ok );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) );
|
|
||||||
m_buttons.Append( cancel );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
ok->SetDefault();
|
|
||||||
ok->SetFocus();
|
|
||||||
}
|
|
||||||
else if (yes)
|
|
||||||
{
|
|
||||||
yes->SetDefault();
|
|
||||||
yes->SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = m_buttons.GetCount() * 100;
|
|
||||||
if (message_size.x > w) w = message_size.x;
|
|
||||||
int space = w / (m_buttons.GetCount()*2);
|
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
wxNode *node = m_buttons.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow*)node->Data();
|
|
||||||
int x = (n*2+1)*space - 40 + 15;
|
|
||||||
win->Move( x, -1 );
|
|
||||||
node = node->Next();
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
int edge_margin = 7;
|
|
||||||
(void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SetSize( w+30, y+40 );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
EndModal( wxID_YES );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
EndModal( wxID_NO );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
/* Allow cancellation via ESC/Close button except if
|
|
||||||
only YES and NO are specified. */
|
|
||||||
if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) )
|
|
||||||
{
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,146 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: textdlgg.cpp
|
|
||||||
// Purpose: wxTextEntryDialog
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 04/01/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
|
||||||
// Licence: wxWindows license
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "textdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#pragma hdrstop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/utils.h"
|
|
||||||
#include "wx/dialog.h"
|
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/stattext.h"
|
|
||||||
#include "wx/textctrl.h"
|
|
||||||
#include "wx/intl.h"
|
|
||||||
#include "wx/sizer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
#include "wx/statline.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/gtk/textdlg.h"
|
|
||||||
|
|
||||||
static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer )
|
|
||||||
{
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( parent, -1, line );
|
|
||||||
sizer->Add( s2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// wxTextEntryDialog
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
|
|
||||||
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
const wxString& value, long style, const wxPoint& pos):
|
|
||||||
wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
|
|
||||||
{
|
|
||||||
m_dialogStyle = style;
|
|
||||||
m_value = value;
|
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
wxBox *topsizer = new wxBox( wxVERTICAL );
|
|
||||||
|
|
||||||
// 1) text message
|
|
||||||
wxBox *textsizer = new wxBox( wxVERTICAL );
|
|
||||||
wxSplitMessage2( message, this, textsizer );
|
|
||||||
topsizer->Add( textsizer, 0, wxALL, 10 );
|
|
||||||
|
|
||||||
// 2) text ctrl
|
|
||||||
wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1));
|
|
||||||
topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
|
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
|
||||||
// 3) static line
|
|
||||||
topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// 4) buttons
|
|
||||||
wxBox *buttonsizer = new wxBox( wxHORIZONTAL );
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
if (style & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 );
|
|
||||||
|
|
||||||
topsizer->SetSizeHints( this );
|
|
||||||
topsizer->Fit( this );
|
|
||||||
SetSizer( topsizer );
|
|
||||||
SetAutoLayout( TRUE );
|
|
||||||
|
|
||||||
Centre( wxBOTH );
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
ok->SetDefault();
|
|
||||||
|
|
||||||
textCtrl->SetFocus();
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
|
|
||||||
{
|
|
||||||
wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT);
|
|
||||||
if ( textCtrl )
|
|
||||||
m_value = textCtrl->GetValue();
|
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# This file was automatically generated by tmake at 19:48, 1999/08/10
|
# This file was automatically generated by tmake at 09:46, 1999/08/11
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs
|
|||||||
GTK_GENERICOBJS = \
|
GTK_GENERICOBJS = \
|
||||||
../generic/busyinfo.o \
|
../generic/busyinfo.o \
|
||||||
../generic/caret.o \
|
../generic/caret.o \
|
||||||
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/imaglist.o \
|
../generic/imaglist.o \
|
||||||
@@ -123,6 +123,7 @@ GTK_GENERICOBJS = \
|
|||||||
../generic/scrolwin.o \
|
../generic/scrolwin.o \
|
||||||
../generic/splitter.o \
|
../generic/splitter.o \
|
||||||
../generic/statusbr.o \
|
../generic/statusbr.o \
|
||||||
|
../generic/textdlgg.o \
|
||||||
../generic/tipdlg.o \
|
../generic/tipdlg.o \
|
||||||
../generic/treectrl.o
|
../generic/treectrl.o
|
||||||
|
|
||||||
@@ -216,7 +217,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/button.o \
|
../gtk/button.o \
|
||||||
../gtk/checkbox.o \
|
../gtk/checkbox.o \
|
||||||
../gtk/checklst.o \
|
../gtk/checklst.o \
|
||||||
../gtk/choicdlg.o \
|
|
||||||
../gtk/choice.o \
|
../gtk/choice.o \
|
||||||
../gtk/clipbrd.o \
|
../gtk/clipbrd.o \
|
||||||
../gtk/colour.o \
|
../gtk/colour.o \
|
||||||
@@ -260,7 +260,6 @@ GTK_GUIOBJS = \
|
|||||||
../gtk/stattext.o \
|
../gtk/stattext.o \
|
||||||
../gtk/tbargtk.o \
|
../gtk/tbargtk.o \
|
||||||
../gtk/textctrl.o \
|
../gtk/textctrl.o \
|
||||||
../gtk/textdlg.o \
|
|
||||||
../gtk/timer.o \
|
../gtk/timer.o \
|
||||||
../gtk/tooltip.o \
|
../gtk/tooltip.o \
|
||||||
../gtk/utilsgtk.o \
|
../gtk/utilsgtk.o \
|
||||||
@@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \
|
|||||||
../generic/choicdgg.o \
|
../generic/choicdgg.o \
|
||||||
../generic/colrdlgg.o \
|
../generic/colrdlgg.o \
|
||||||
../generic/dirdlgg.o \
|
../generic/dirdlgg.o \
|
||||||
../generic/extdlgg.o \
|
|
||||||
../generic/fontdlgg.o \
|
../generic/fontdlgg.o \
|
||||||
../generic/gridg.o \
|
../generic/gridg.o \
|
||||||
../generic/helpxlp.o \
|
../generic/helpxlp.o \
|
||||||
|
Reference in New Issue
Block a user