dialog.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/univ/dialog.h
  3. // Purpose: wxDialog class
  4. // Author: Vaclav Slavik
  5. // Created: 2001/09/16
  6. // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_UNIV_DIALOG_H_
  10. #define _WX_UNIV_DIALOG_H_
  11. extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[];
  12. class WXDLLIMPEXP_FWD_CORE wxWindowDisabler;
  13. class WXDLLIMPEXP_FWD_CORE wxEventLoop;
  14. // Dialog boxes
  15. class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase
  16. {
  17. public:
  18. wxDialog() { Init(); }
  19. // Constructor with no modal flag - the new convention.
  20. wxDialog(wxWindow *parent, wxWindowID id,
  21. const wxString& title,
  22. const wxPoint& pos = wxDefaultPosition,
  23. const wxSize& size = wxDefaultSize,
  24. long style = wxDEFAULT_DIALOG_STYLE,
  25. const wxString& name = wxDialogNameStr)
  26. {
  27. Init();
  28. Create(parent, id, title, pos, size, style, name);
  29. }
  30. bool Create(wxWindow *parent, wxWindowID id,
  31. const wxString& title,
  32. const wxPoint& pos = wxDefaultPosition,
  33. const wxSize& size = wxDefaultSize,
  34. long style = wxDEFAULT_DIALOG_STYLE,
  35. const wxString& name = wxDialogNameStr);
  36. virtual ~wxDialog();
  37. // is the dialog in modal state right now?
  38. virtual bool IsModal() const;
  39. // For now, same as Show(true) but returns return code
  40. virtual int ShowModal();
  41. // may be called to terminate the dialog with the given return code
  42. virtual void EndModal(int retCode);
  43. // returns true if we're in a modal loop
  44. bool IsModalShowing() const;
  45. virtual bool Show(bool show = true);
  46. // implementation only from now on
  47. // -------------------------------
  48. // event handlers
  49. void OnCloseWindow(wxCloseEvent& event);
  50. void OnOK(wxCommandEvent& event);
  51. void OnApply(wxCommandEvent& event);
  52. void OnCancel(wxCommandEvent& event);
  53. protected:
  54. // common part of all ctors
  55. void Init();
  56. private:
  57. // while we are showing a modal dialog we disable the other windows using
  58. // this object
  59. wxWindowDisabler *m_windowDisabler;
  60. // modal dialog runs its own event loop
  61. wxEventLoop *m_eventLoop;
  62. // is modal right now?
  63. bool m_isShowingModal;
  64. DECLARE_DYNAMIC_CLASS(wxDialog)
  65. DECLARE_EVENT_TABLE()
  66. };
  67. #endif
  68. // _WX_UNIV_DIALOG_H_