dialog.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/dialog.h
  3. // Purpose: wxDialog class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DIALOG_H_
  11. #define _WX_DIALOG_H_
  12. #include "wx/panel.h"
  13. // this option is always enabled (there doesn't seem to be any good reason to
  14. // disable it) for desktop Windows versions but Windows CE dialogs are usually
  15. // not resizable and never show resize gripper anyhow so don't use it there
  16. #ifdef __WXWINCE__
  17. #define wxUSE_DIALOG_SIZEGRIP 0
  18. #else
  19. #define wxUSE_DIALOG_SIZEGRIP 1
  20. #endif
  21. extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[];
  22. class WXDLLIMPEXP_FWD_CORE wxDialogModalData;
  23. #if wxUSE_TOOLBAR && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
  24. class WXDLLIMPEXP_FWD_CORE wxToolBar;
  25. extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[];
  26. #endif
  27. // Dialog boxes
  28. class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase
  29. {
  30. public:
  31. wxDialog() { Init(); }
  32. // full ctor
  33. wxDialog(wxWindow *parent, wxWindowID id,
  34. const wxString& title,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize,
  37. long style = wxDEFAULT_DIALOG_STYLE,
  38. const wxString& name = wxDialogNameStr)
  39. {
  40. Init();
  41. (void)Create(parent, id, title, pos, size, style, name);
  42. }
  43. bool Create(wxWindow *parent, wxWindowID id,
  44. const wxString& title,
  45. const wxPoint& pos = wxDefaultPosition,
  46. const wxSize& size = wxDefaultSize,
  47. long style = wxDEFAULT_DIALOG_STYLE,
  48. const wxString& name = wxDialogNameStr);
  49. virtual ~wxDialog();
  50. // return true if we're showing the dialog modally
  51. virtual bool IsModal() const { return m_modalData != NULL; }
  52. // show the dialog modally and return the value passed to EndModal()
  53. virtual int ShowModal();
  54. // may be called to terminate the dialog with the given return code
  55. virtual void EndModal(int retCode);
  56. // we treat dialog toolbars specially under Windows CE
  57. #if wxUSE_TOOLBAR && defined(__POCKETPC__)
  58. // create main toolbar by calling OnCreateToolBar()
  59. virtual wxToolBar* CreateToolBar(long style = -1,
  60. wxWindowID winid = wxID_ANY,
  61. const wxString& name = wxToolBarNameStr);
  62. // return a new toolbar
  63. virtual wxToolBar *OnCreateToolBar(long style,
  64. wxWindowID winid,
  65. const wxString& name );
  66. // get the main toolbar
  67. wxToolBar *GetToolBar() const { return m_dialogToolBar; }
  68. #endif // wxUSE_TOOLBAR && __POCKETPC__
  69. // implementation only from now on
  70. // -------------------------------
  71. // override some base class virtuals
  72. virtual bool Show(bool show = true);
  73. #if wxUSE_DIALOG_SIZEGRIP
  74. virtual void SetWindowStyleFlag(long style);
  75. #endif // wxUSE_DIALOG_SIZEGRIP
  76. #ifdef __POCKETPC__
  77. // Responds to the OK button in a PocketPC titlebar. This
  78. // can be overridden, or you can change the id used for
  79. // sending the event with SetAffirmativeId. Returns false
  80. // if the event was not processed.
  81. virtual bool DoOK();
  82. #endif
  83. // Windows callbacks
  84. WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
  85. protected:
  86. // common part of all ctors
  87. void Init();
  88. private:
  89. #if wxUSE_DIALOG_SIZEGRIP
  90. // these functions deal with the gripper window shown in the corner of
  91. // resizable dialogs
  92. void CreateGripper();
  93. void DestroyGripper();
  94. void ShowGripper(bool show);
  95. void ResizeGripper();
  96. // this function is used to adjust Z-order of new children relative to the
  97. // gripper if we have one
  98. void OnWindowCreate(wxWindowCreateEvent& event);
  99. // gripper window for a resizable dialog, NULL if we're not resizable
  100. WXHWND m_hGripper;
  101. #endif // wxUSE_DIALOG_SIZEGRIP
  102. #if wxUSE_TOOLBAR && defined(__POCKETPC__)
  103. wxToolBar* m_dialogToolBar;
  104. #endif
  105. // this pointer is non-NULL only while the modal event loop is running
  106. wxDialogModalData *m_modalData;
  107. DECLARE_DYNAMIC_CLASS(wxDialog)
  108. wxDECLARE_NO_COPY_CLASS(wxDialog);
  109. };
  110. #endif
  111. // _WX_DIALOG_H_