1999-06-29 12:34:18 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/dialog.h
|
|
|
|
// Purpose: wxDialogBase class
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29.06.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-06-29 12:34:18 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_DIALOG_H_BASE_
|
|
|
|
#define _WX_DIALOG_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-06-28 22:04:40 +00:00
|
|
|
#include "wx/defs.h"
|
2001-09-15 22:13:08 +00:00
|
|
|
#include "wx/containr.h"
|
|
|
|
#include "wx/toplevel.h"
|
1999-06-28 22:04:40 +00:00
|
|
|
|
2004-12-31 18:57:25 +00:00
|
|
|
class WXDLLEXPORT wxSizer;
|
|
|
|
class WXDLLEXPORT wxStdDialogButtonSizer;
|
|
|
|
|
2004-04-13 12:22:34 +00:00
|
|
|
#define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window
|
|
|
|
|
2004-04-18 10:32:20 +00:00
|
|
|
#ifdef __WXWINCE__
|
2005-04-02 21:40:59 +00:00
|
|
|
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER)
|
2005-03-14 17:15:06 +00:00
|
|
|
#else
|
|
|
|
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
|
2004-04-18 10:32:20 +00:00
|
|
|
#endif
|
2004-04-13 12:22:34 +00:00
|
|
|
|
2006-01-16 14:59:55 +00:00
|
|
|
extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[];
|
2003-05-12 19:52:43 +00:00
|
|
|
|
2001-09-15 22:13:08 +00:00
|
|
|
class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
|
1999-06-28 21:39:49 +00:00
|
|
|
{
|
1999-06-29 12:34:18 +00:00
|
|
|
public:
|
2006-01-15 10:06:15 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// all flags allowed in wxDialogBase::CreateButtonSizer()
|
|
|
|
ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT
|
|
|
|
};
|
|
|
|
|
2004-01-15 13:49:22 +00:00
|
|
|
wxDialogBase() { Init(); }
|
2001-09-24 00:34:14 +00:00
|
|
|
virtual ~wxDialogBase() { }
|
|
|
|
|
2006-08-20 14:02:51 +00:00
|
|
|
// define public wxDialog methods to be implemented by the derived classes
|
2006-08-19 22:56:11 +00:00
|
|
|
virtual int ShowModal() = 0;
|
|
|
|
virtual void EndModal(int retCode) = 0;
|
|
|
|
virtual bool IsModal() const = 0;
|
|
|
|
|
2001-09-24 00:34:14 +00:00
|
|
|
|
2005-03-14 17:15:06 +00:00
|
|
|
// Modal dialogs have a return code - usually the id of the last
|
1999-06-29 12:34:18 +00:00
|
|
|
// pressed button
|
|
|
|
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
|
|
|
|
int GetReturnCode() const { return m_returnCode; }
|
|
|
|
|
2006-08-20 10:30:26 +00:00
|
|
|
// Set the identifier for the affirmative button: this button will close
|
|
|
|
// the dialog after validating data and calling TransferDataFromWindow()
|
|
|
|
void SetAffirmativeId(int affirmativeId);
|
2005-03-14 17:15:06 +00:00
|
|
|
int GetAffirmativeId() const { return m_affirmativeId; }
|
|
|
|
|
2006-08-20 10:30:26 +00:00
|
|
|
// Set identifier for Esc key translation: the button with this id will
|
|
|
|
// close the dialog without doing anything else; special value wxID_NONE
|
|
|
|
// means to not handle Esc at all while wxID_ANY means to map Esc to
|
|
|
|
// wxID_CANCEL if present and GetAffirmativeId() otherwise
|
|
|
|
void SetEscapeId(int escapeId);
|
2005-07-14 23:07:10 +00:00
|
|
|
int GetEscapeId() const { return m_escapeId; }
|
|
|
|
|
2003-05-23 18:59:07 +00:00
|
|
|
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
1999-08-11 11:53:40 +00:00
|
|
|
// splits text up at newlines and places the
|
|
|
|
// lines into a vertical wxBoxSizer
|
|
|
|
wxSizer *CreateTextSizer( const wxString &message );
|
2003-05-23 18:59:07 +00:00
|
|
|
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
2001-09-24 00:34:14 +00:00
|
|
|
|
1999-08-11 11:53:40 +00:00
|
|
|
// places buttons into a horizontal wxBoxSizer
|
2006-01-15 10:06:15 +00:00
|
|
|
wxSizer *CreateButtonSizer( long flags,
|
|
|
|
bool separated = false,
|
|
|
|
wxCoord distance = 0 );
|
|
|
|
#if wxUSE_BUTTON
|
2004-12-31 18:57:25 +00:00
|
|
|
wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_BUTTON
|
1999-06-29 12:34:18 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
protected:
|
2006-08-19 22:36:10 +00:00
|
|
|
// emulate click of a button with the given id if it's present in the dialog
|
|
|
|
//
|
|
|
|
// return true if button was "clicked" or false if we don't have it
|
|
|
|
bool EmulateButtonClickIfPresent(int id);
|
|
|
|
|
|
|
|
// this function is used by OnCharHook() to decide whether the given key
|
|
|
|
// should close the dialog
|
|
|
|
//
|
|
|
|
// for most platforms the default implementation (which just checks for
|
|
|
|
// Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
|
|
|
|
// could do something different if needed
|
|
|
|
virtual bool IsEscapeKey(const wxKeyEvent& event);
|
|
|
|
|
2006-08-19 22:56:11 +00:00
|
|
|
// end either modal or modeless dialog, for the modal dialog rc is used as
|
|
|
|
// the dialog return code
|
|
|
|
void EndDialog(int rc);
|
|
|
|
|
2006-08-20 10:30:26 +00:00
|
|
|
// call Validate() and TransferDataFromWindow() and close dialog with
|
|
|
|
// wxID_OK return code
|
|
|
|
void AcceptAndClose();
|
|
|
|
|
2006-08-19 22:36:10 +00:00
|
|
|
|
2005-03-14 17:15:06 +00:00
|
|
|
// The return code from modal dialog
|
1999-06-29 12:34:18 +00:00
|
|
|
int m_returnCode;
|
2001-09-15 22:13:08 +00:00
|
|
|
|
2005-03-14 17:15:06 +00:00
|
|
|
// The identifier for the affirmative button (usually wxID_OK)
|
|
|
|
int m_affirmativeId;
|
|
|
|
|
2005-09-25 20:17:01 +00:00
|
|
|
// The identifier for cancel button (usually wxID_CANCEL)
|
|
|
|
int m_escapeId;
|
|
|
|
|
2006-08-19 22:36:10 +00:00
|
|
|
private:
|
2006-08-19 22:56:11 +00:00
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2006-08-19 22:36:10 +00:00
|
|
|
// handle Esc key presses
|
|
|
|
void OnCharHook(wxKeyEvent& event);
|
|
|
|
|
2006-08-19 22:56:11 +00:00
|
|
|
// handle closing the dialog window
|
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
|
|
|
|
// handle the standard buttons
|
2006-08-20 14:02:51 +00:00
|
|
|
void OnButton(wxCommandEvent& event);
|
2006-08-19 22:56:11 +00:00
|
|
|
|
|
|
|
// update the background colour
|
|
|
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
|
|
|
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(wxDialogBase)
|
2001-09-15 22:13:08 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
WX_DECLARE_CONTROL_CONTAINER();
|
1999-06-28 21:39:49 +00:00
|
|
|
};
|
|
|
|
|
2001-09-15 22:13:08 +00:00
|
|
|
|
2001-11-28 18:22:16 +00:00
|
|
|
#if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
|
2001-09-18 22:33:38 +00:00
|
|
|
#include "wx/univ/dialog.h"
|
|
|
|
#else
|
2004-12-20 12:44:22 +00:00
|
|
|
#if defined(__WXPALMOS__)
|
2004-10-19 13:40:30 +00:00
|
|
|
#include "wx/palmos/dialog.h"
|
|
|
|
#elif defined(__WXMSW__)
|
2001-09-18 22:33:38 +00:00
|
|
|
#include "wx/msw/dialog.h"
|
|
|
|
#elif defined(__WXMOTIF__)
|
|
|
|
#include "wx/motif/dialog.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK20__)
|
2001-09-18 22:33:38 +00:00
|
|
|
#include "wx/gtk/dialog.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/dialog.h"
|
2001-09-18 22:33:38 +00:00
|
|
|
#elif defined(__WXMAC__)
|
|
|
|
#include "wx/mac/dialog.h"
|
2003-03-22 06:18:36 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/dialog.h"
|
2001-09-18 22:33:38 +00:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/dialog.h"
|
|
|
|
#endif
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_DIALOG_H_BASE_
|