moved all wxDialog event handlers to wxDialogBase to avoid code duplication
(sixplication?) among ports; as a side effect added public wxDialog methods to wxDialogBase as well and moved EndDialog() (previously implemented by wxMSW, wxMotif, wxMac and wxCocoa but not the other ports) to wxDialogBase too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,7 +25,6 @@ WXDLLEXPORT_DATA(extern const wxChar) wxDialogNameStr[];
|
||||
class WXDLLEXPORT wxDialog : public wxDialogBase, protected wxCocoaNSPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_COCOA_OWNER(NSPanel,NSWindow,NSWindow)
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
@@ -93,20 +92,6 @@ public:
|
||||
|
||||
// may be called to terminate the dialog with the given return code
|
||||
virtual void EndModal(int retCode);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Event handlers
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// end either modal or modeless dialog
|
||||
void EndDialog(int rc);
|
||||
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_DIALOG_H_
|
||||
|
@@ -41,7 +41,11 @@ public:
|
||||
wxDialogBase() { Init(); }
|
||||
virtual ~wxDialogBase() { }
|
||||
|
||||
void Init();
|
||||
// public wxDialog API, to be implemented by the derived classes
|
||||
virtual int ShowModal() = 0;
|
||||
virtual void EndModal(int retCode) = 0;
|
||||
virtual bool IsModal() const = 0;
|
||||
|
||||
|
||||
// Modal dialogs have a return code - usually the id of the last
|
||||
// pressed button
|
||||
@@ -84,6 +88,10 @@ protected:
|
||||
// could do something different if needed
|
||||
virtual bool IsEscapeKey(const wxKeyEvent& event);
|
||||
|
||||
// end either modal or modeless dialog, for the modal dialog rc is used as
|
||||
// the dialog return code
|
||||
void EndDialog(int rc);
|
||||
|
||||
|
||||
// The return code from modal dialog
|
||||
int m_returnCode;
|
||||
@@ -95,9 +103,24 @@ protected:
|
||||
int m_escapeId;
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// handle Esc key presses
|
||||
void OnCharHook(wxKeyEvent& event);
|
||||
|
||||
// handle closing the dialog window
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// handle the standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// update the background colour
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDialogBase)
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_CONTROL_CONTAINER();
|
||||
|
@@ -47,12 +47,6 @@ public:
|
||||
const wxString &name = wxDialogNameStr );
|
||||
~wxDialog() {}
|
||||
|
||||
void OnApply( wxCommandEvent &event );
|
||||
void OnCancel( wxCommandEvent &event );
|
||||
void OnOK( wxCommandEvent &event );
|
||||
void OnPaint( wxPaintEvent& event );
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
|
||||
virtual bool Show( bool show = TRUE );
|
||||
virtual int ShowModal();
|
||||
virtual void EndModal( int retCode );
|
||||
@@ -64,12 +58,10 @@ public:
|
||||
|
||||
bool m_modalShowing;
|
||||
|
||||
protected:
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
};
|
||||
|
||||
|
@@ -78,24 +78,13 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// event handlers
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
// show modal dialog and enter modal loop
|
||||
void DoShowModal();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
bool m_isModalStyle;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -57,18 +57,8 @@ public:
|
||||
virtual void ChangeFont(bool keepOriginalSize = true);
|
||||
virtual void ChangeBackgroundColour();
|
||||
virtual void ChangeForegroundColour();
|
||||
inline WXWidget GetTopWidget() const { return m_mainWidget; }
|
||||
inline WXWidget GetClientWidget() const { return m_mainWidget; }
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
WXWidget GetTopWidget() const { return m_mainWidget; }
|
||||
WXWidget GetClientWidget() const { return m_mainWidget; }
|
||||
|
||||
private:
|
||||
virtual bool XmDoCreateTLW(wxWindow* parent,
|
||||
|
@@ -85,17 +85,6 @@ public:
|
||||
|
||||
virtual void Raise();
|
||||
|
||||
// event handlers
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
#ifdef __POCKETPC__
|
||||
// Responds to the OK button in a PocketPC titlebar. This
|
||||
// can be overridden, or you can change the id used for
|
||||
@@ -132,9 +121,6 @@ protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// end either modal or modeless dialog
|
||||
void EndDialog(int rc);
|
||||
|
||||
private:
|
||||
wxWindow* m_oldFocus;
|
||||
bool m_endModalCalled; // allow for closing within InitDialog
|
||||
@@ -147,7 +133,6 @@ private:
|
||||
wxDialogModalData *m_modalData;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxDialog)
|
||||
};
|
||||
|
||||
|
@@ -65,23 +65,6 @@ public:
|
||||
// override some base class virtuals
|
||||
virtual bool Show(bool show = true);
|
||||
|
||||
//
|
||||
// Event handlers
|
||||
//
|
||||
void OnCloseWindow(wxCloseEvent& rEvent);
|
||||
|
||||
//
|
||||
// Standard buttons
|
||||
//
|
||||
void OnOK(wxCommandEvent& rEvent);
|
||||
void OnApply(wxCommandEvent& rEvent);
|
||||
void OnCancel(wxCommandEvent& rEvent);
|
||||
|
||||
//
|
||||
// Responds to colour changes
|
||||
//
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
|
||||
|
||||
//
|
||||
// Callbacks
|
||||
//
|
||||
@@ -125,9 +108,6 @@ protected:
|
||||
//
|
||||
void Init(void);
|
||||
|
||||
// end either modal or modeless dialog
|
||||
void EndDialog(int rc);
|
||||
|
||||
private:
|
||||
wxWindow* m_pOldFocus;
|
||||
bool m_endModalCalled; // allow for closing within InitDialog
|
||||
|
@@ -63,15 +63,6 @@ public:
|
||||
|
||||
virtual void Raise();
|
||||
|
||||
// event handlers
|
||||
void OnCharHook(wxKeyEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
protected:
|
||||
// find the window to use as parent for this dialog if none has been
|
||||
// specified explicitly by the user
|
||||
|
@@ -33,13 +33,6 @@ static wxWindowList wxModalDialogs;
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxDialog,NSPanel,NSWindow,NSWindow)
|
||||
|
||||
void wxDialog::Init()
|
||||
@@ -177,68 +170,3 @@ void wxDialog::EndModal(int retCode)
|
||||
Show(false);
|
||||
}
|
||||
|
||||
void wxDialog::EndDialog(int retCode)
|
||||
{
|
||||
if(IsModal())
|
||||
EndModal(retCode);
|
||||
else
|
||||
Show(false);
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
// ALWAYS VETO THIS EVENT!!!!
|
||||
event.Veto();
|
||||
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
{
|
||||
wxLogDebug(wxT("WARNING: Attempting to recursively call Close for dialog"));
|
||||
return;
|
||||
}
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxLogTrace(wxTRACE_COCOA,wxT("Sending Cancel Event"));
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndDialog(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& event)
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
wxLogTrace(wxTRACE_COCOA,wxT("Cancelled!"));
|
||||
EndDialog(wxID_CANCEL);
|
||||
}
|
||||
|
@@ -99,7 +99,14 @@ private:
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow)
|
||||
EVT_BUTTON(wxID_OK, wxDialogBase::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialogBase::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialogBase::OnCancel)
|
||||
|
||||
EVT_CLOSE(wxDialogBase::OnCloseWindow)
|
||||
|
||||
EVT_CHAR_HOOK(wxDialogBase::OnCharHook)
|
||||
|
||||
WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -437,6 +444,14 @@ bool wxDialogBase::EmulateButtonClickIfPresent(int id)
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDialogBase::EndDialog(int rc)
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(rc);
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
|
||||
bool wxDialogBase::IsEscapeKey(const wxKeyEvent& event)
|
||||
{
|
||||
// for most platforms, Esc key is used to close the dialogs
|
||||
@@ -473,3 +488,59 @@ void wxDialogBase::OnCharHook(wxKeyEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxDialogBase::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndDialog(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialogBase::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() )
|
||||
TransferDataFromWindow();
|
||||
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialogBase::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndDialog(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default, which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close(). We wouldn't want to destroy the dialog by default, since
|
||||
// the dialog may have been created on the stack. However, this does mean
|
||||
// that calling dialog->Close() won't delete the dialog unless the handler
|
||||
// for wxID_CANCEL does so. So use Destroy() if you want to be sure to
|
||||
// destroy the dialog. The default OnCancel (above) simply ends a modal
|
||||
// dialog, and hides a modeless dialog.
|
||||
|
||||
// VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
|
||||
// lists here? don't dare to change it now, but should be done later!
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
@@ -36,13 +36,6 @@ extern int g_openDialogs;
|
||||
// wxDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog,wxDialogBase)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow)
|
||||
|
||||
void wxDialog::Init()
|
||||
@@ -76,75 +69,6 @@ bool wxDialog::Create( wxWindow *parent,
|
||||
return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
Show(false);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (Validate() && TransferDataFromWindow())
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_OK);
|
||||
Show(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
{
|
||||
// yes
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
|
||||
static wxList s_closing;
|
||||
|
||||
if (s_closing.Member(this))
|
||||
return; // no loops
|
||||
|
||||
s_closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
s_closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
bool wxDialog::Show( bool show )
|
||||
{
|
||||
if (!show && IsModal())
|
||||
|
@@ -204,58 +204,3 @@ void wxDialog::EndModal(int retCode)
|
||||
SetModal(false);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
@@ -71,15 +71,6 @@ extern wxList wxModelessWindows; // Frames and modeless dialogs
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
wxDialog::wxDialog()
|
||||
{
|
||||
m_modalShowing = false;
|
||||
@@ -347,69 +338,6 @@ void wxDialog::EndModal(int retCode)
|
||||
SetModal(false);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_OK);
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_OK);
|
||||
this->Show(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_CANCEL);
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(false);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
@@ -418,12 +346,6 @@ bool wxDialog::Destroy()
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxDialog::ChangeFont(bool keepOriginalSize)
|
||||
{
|
||||
wxWindow::ChangeFont(keepOriginalSize);
|
||||
|
@@ -109,16 +109,6 @@ wxCONSTRUCTOR_6( wxDialog , wxWindow* , Parent , wxWindowID , Id , wxString , Ti
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
#endif
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDialogModalData
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -377,76 +367,10 @@ void wxDialog::EndModal(int retCode)
|
||||
Hide();
|
||||
}
|
||||
|
||||
void wxDialog::EndDialog(int rc)
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(rc);
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndDialog(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() )
|
||||
TransferDataFromWindow();
|
||||
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndDialog(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default, which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close(). We wouldn't want to destroy the dialog by default, since
|
||||
// the dialog may have been created on the stack. However, this does mean
|
||||
// that calling dialog->Close() won't delete the dialog unless the handler
|
||||
// for wxID_CANCEL does so. So use Destroy() if you want to be sure to
|
||||
// destroy the dialog. The default OnCancel (above) simply ends a modal
|
||||
// dialog, and hides a modeless dialog.
|
||||
|
||||
// VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
|
||||
// lists here? don't dare to change it now, but should be done later!
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#ifdef __POCKETPC__
|
||||
// Responds to the OK button in a PocketPC titlebar. This
|
||||
// can be overridden, or you can change the id used for
|
||||
|
@@ -328,79 +328,6 @@ void wxDialog::EndModal(
|
||||
Hide();
|
||||
} // end of wxDialog::EndModal
|
||||
|
||||
void wxDialog::EndDialog(int rc)
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(rc);
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent& WXUNUSED(rEvent) )
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
} // end of wxDialog::OnApply
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK( wxCommandEvent& WXUNUSED(rEvent) )
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndDialog(wxID_OK);
|
||||
}
|
||||
} // end of wxDialog::OnOK
|
||||
|
||||
void wxDialog::OnCancel( wxCommandEvent& WXUNUSED(rEvent) )
|
||||
{
|
||||
EndDialog(wxID_CANCEL);
|
||||
} // end of wxDialog::OnCancel
|
||||
|
||||
void wxDialog::OnCloseWindow( wxCloseEvent& WXUNUSED(rEvent) )
|
||||
{
|
||||
//
|
||||
// We'll send a Cancel message by default, which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
//
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
//
|
||||
|
||||
//
|
||||
// Ugh??? This is not good but until I figure out a global list it'll have to do
|
||||
//
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent vCancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
|
||||
vCancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(vCancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
} // end of wxDialog::OnCloseWindow
|
||||
|
||||
void wxDialog::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(rEvent) )
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
} // end of wxDialog::OnSysColourChanged
|
||||
|
||||
MRESULT wxDialog::OS2WindowProc( WXUINT uMessage, WXWPARAM wParam, WXLPARAM lParam )
|
||||
{
|
||||
MRESULT rc = 0;
|
||||
|
@@ -100,14 +100,6 @@ wxCONSTRUCTOR_6( wxDialog , wxWindow* , Parent , wxWindowID , Id , wxString , Ti
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
#endif
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDialogModalData
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -190,23 +182,3 @@ void wxDialog::EndModal(int retCode)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin event handlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user