nonownedwnd.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/nonownedwnd.h
  3. // Purpose: declares wxNonOwnedWindow class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 2008-03-24
  7. // Copyright: (c) 2008 Stefan Csomor
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MAC_NONOWNEDWND_H_
  11. #define _WX_MAC_NONOWNEDWND_H_
  12. #include "wx/window.h"
  13. #include "wx/graphics.h"
  14. #if wxUSE_SYSTEM_OPTIONS
  15. #define wxMAC_WINDOW_PLAIN_TRANSITION wxT("mac.window-plain-transition")
  16. #endif
  17. //-----------------------------------------------------------------------------
  18. // wxNonOwnedWindow
  19. //-----------------------------------------------------------------------------
  20. // This class represents "non-owned" window. A window is owned by another
  21. // window if it has a parent and is positioned within the parent. For example,
  22. // wxFrame is non-owned, because even though it can have a parent, it's
  23. // location is independent of it. This class is for internal use only, it's
  24. // the base class for wxTopLevelWindow and wxPopupWindow.
  25. class wxNonOwnedWindowImpl;
  26. class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase
  27. {
  28. public:
  29. // constructors and such
  30. wxNonOwnedWindow() { Init(); }
  31. wxNonOwnedWindow(wxWindow *parent,
  32. wxWindowID id,
  33. const wxPoint& pos = wxDefaultPosition,
  34. const wxSize& size = wxDefaultSize,
  35. long style = 0,
  36. const wxString& name = wxPanelNameStr)
  37. {
  38. Init();
  39. (void)Create(parent, id, pos, size, style, name);
  40. }
  41. bool Create(wxWindow *parent,
  42. wxWindowID id,
  43. const wxPoint& pos = wxDefaultPosition,
  44. const wxSize& size = wxDefaultSize,
  45. long style = 0,
  46. const wxString& name = wxPanelNameStr);
  47. bool Create(wxWindow *parent, WXWindow nativeWindow);
  48. virtual ~wxNonOwnedWindow();
  49. virtual void SubclassWin(WXWindow nativeWindow);
  50. virtual void UnsubclassWin();
  51. virtual wxPoint GetClientAreaOrigin() const;
  52. // implement base class pure virtuals
  53. virtual bool SetTransparent(wxByte alpha);
  54. virtual bool CanSetTransparent();
  55. virtual bool SetBackgroundStyle(wxBackgroundStyle style);
  56. virtual void Update();
  57. WXWindow GetWXWindow() const ;
  58. static wxNonOwnedWindow* GetFromWXWindow( WXWindow win );
  59. // implementation from now on
  60. // --------------------------
  61. // These accessors are Mac-specific and don't exist in other ports.
  62. const wxRegion& GetShape() const { return m_shape; }
  63. #if wxUSE_GRAPHICS_CONTEXT
  64. const wxGraphicsPath& GetShapePath() { return m_shapePath; }
  65. #endif // wxUSE_GRAPHICS_CONTEXT
  66. // activation hooks only necessary for MDI Implementation
  67. static void MacDelayedDeactivation(long timestamp);
  68. virtual void MacActivate( long timestamp , bool inIsActivating ) ;
  69. virtual void SetWindowStyleFlag(long flags);
  70. virtual void Raise();
  71. virtual void Lower();
  72. virtual bool Show( bool show = true );
  73. virtual void SetExtraStyle(long exStyle) ;
  74. virtual bool SetBackgroundColour( const wxColour &colour );
  75. wxNonOwnedWindowImpl* GetNonOwnedPeer() const { return m_nowpeer; }
  76. #if wxOSX_USE_COCOA_OR_IPHONE
  77. // override the base class method to return an NSWindow instead of NSView
  78. virtual void *OSXGetViewOrWindow() const;
  79. #endif // Cocoa
  80. // osx specific event handling common for all osx-ports
  81. virtual void HandleActivated( double timestampsec, bool didActivate );
  82. virtual void HandleResized( double timestampsec );
  83. virtual void HandleMoved( double timestampsec );
  84. virtual void HandleResizing( double timestampsec, wxRect* rect );
  85. void WindowWasPainted();
  86. virtual bool Destroy();
  87. protected:
  88. // common part of all ctors
  89. void Init();
  90. virtual void DoGetPosition( int *x, int *y ) const;
  91. virtual void DoGetSize( int *width, int *height ) const;
  92. virtual void DoMoveWindow(int x, int y, int width, int height);
  93. virtual void DoGetClientSize(int *width, int *height) const;
  94. virtual bool OSXShowWithEffect(bool show,
  95. wxShowEffect effect,
  96. unsigned timeout);
  97. virtual bool DoClearShape();
  98. virtual bool DoSetRegionShape(const wxRegion& region);
  99. #if wxUSE_GRAPHICS_CONTEXT
  100. virtual bool DoSetPathShape(const wxGraphicsPath& path);
  101. #endif // wxUSE_GRAPHICS_CONTEXT
  102. virtual void WillBeDestroyed();
  103. wxNonOwnedWindowImpl* m_nowpeer ;
  104. // wxWindowMac* m_macFocus ;
  105. static wxNonOwnedWindow *s_macDeactivateWindow;
  106. private :
  107. static clock_t s_lastFlush;
  108. wxRegion m_shape;
  109. #if wxUSE_GRAPHICS_CONTEXT
  110. wxGraphicsPath m_shapePath;
  111. #endif // wxUSE_GRAPHICS_CONTEXT
  112. };
  113. // list of all frames and modeless dialogs
  114. extern WXDLLIMPEXP_DATA_CORE(wxWindowList) wxModelessWindows;
  115. #endif // _WX_MAC_NONOWNEDWND_H_