dialog.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/dialog.h
  3. // Purpose: wxDialog class
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2002/12/15
  7. // Copyright: David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_COCOA_DIALOG_H_
  11. #define _WX_COCOA_DIALOG_H_
  12. #include "wx/defs.h"
  13. // NOTE: we don't need panel.h, but other things expect it to be included
  14. #include "wx/panel.h"
  15. #include "wx/cocoa/NSPanel.h"
  16. // ========================================================================
  17. // wxDialog
  18. // ========================================================================
  19. class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase, protected wxCocoaNSPanel
  20. {
  21. DECLARE_DYNAMIC_CLASS(wxDialog)
  22. WX_DECLARE_COCOA_OWNER(NSPanel,NSWindow,NSWindow)
  23. // ------------------------------------------------------------------------
  24. // initialization
  25. // ------------------------------------------------------------------------
  26. public:
  27. wxDialog() { Init(); }
  28. #if WXWIN_COMPATIBILITY_2_6
  29. // Constructor with a modal flag, but no window id - the old convention
  30. wxDialog(wxWindow *parent,
  31. const wxString& title, bool WXUNUSED(modal),
  32. int x = wxDefaultCoord, int y= wxDefaultCoord, int width = 500, int height = 500,
  33. long style = wxDEFAULT_DIALOG_STYLE,
  34. const wxString& name = wxDialogNameStr)
  35. {
  36. Init();
  37. Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, height),
  38. style, name);
  39. }
  40. #endif // WXWIN_COMPATIBILITY_2_6
  41. // Constructor with no modal flag - the new convention.
  42. wxDialog(wxWindow *parent, wxWindowID winid,
  43. const wxString& title,
  44. const wxPoint& pos = wxDefaultPosition,
  45. const wxSize& size = wxDefaultSize,
  46. long style = wxDEFAULT_DIALOG_STYLE,
  47. const wxString& name = wxDialogNameStr)
  48. {
  49. Init();
  50. Create(parent, winid, title, pos, size, style, name);
  51. }
  52. bool Create(wxWindow *parent, wxWindowID winid,
  53. const wxString& title,
  54. const wxPoint& pos = wxDefaultPosition,
  55. const wxSize& size = wxDefaultSize,
  56. long style = wxDEFAULT_DIALOG_STYLE,
  57. const wxString& name = wxDialogNameStr);
  58. virtual ~wxDialog();
  59. protected:
  60. void Init();
  61. // ------------------------------------------------------------------------
  62. // Cocoa specifics
  63. // ------------------------------------------------------------------------
  64. protected:
  65. virtual void CocoaDelegate_windowWillClose(void);
  66. virtual bool Cocoa_canBecomeMainWindow(bool &canBecome)
  67. { canBecome = true; return true; }
  68. // ------------------------------------------------------------------------
  69. // Implementation
  70. // ------------------------------------------------------------------------
  71. public:
  72. virtual bool Show(bool show = true);
  73. void SetModal(bool flag);
  74. virtual bool IsModal() const { return m_isModal; }
  75. bool m_isModal;
  76. // For now, same as Show(true) but returns return code
  77. virtual int ShowModal();
  78. // may be called to terminate the dialog with the given return code
  79. virtual void EndModal(int retCode);
  80. };
  81. #endif // _WX_COCOA_DIALOG_H_