nonownedwnd.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dfb/nonownedwnd.h
  3. // Purpose: declares wxNonOwnedWindow class
  4. // Author: Vaclav Slavik
  5. // Modified by:
  6. // Created: 2006-12-24
  7. // Copyright: (c) 2006 TT-Solutions
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DFB_NONOWNEDWND_H_
  11. #define _WX_DFB_NONOWNEDWND_H_
  12. #include "wx/window.h"
  13. #include "wx/dfb/dfbptr.h"
  14. wxDFB_DECLARE_INTERFACE(IDirectFBWindow);
  15. class wxDfbQueuedPaintRequests;
  16. struct wxDFBWindowEvent;
  17. class wxDFBEventsHandler;
  18. //-----------------------------------------------------------------------------
  19. // wxNonOwnedWindow
  20. //-----------------------------------------------------------------------------
  21. // This class represents "non-owned" window. A window is owned by another
  22. // window if it has a parent and is positioned within the parent. For example,
  23. // wxFrame is non-owned, because even though it can have a parent, it's
  24. // location is independent of it. This class is for internal use only, it's
  25. // the base class for wxTopLevelWindow and wxPopupWindow.
  26. class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase
  27. {
  28. public:
  29. // construction
  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. 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. virtual ~wxNonOwnedWindow();
  48. // implement base class pure virtuals
  49. virtual bool Show(bool show = true);
  50. virtual void Update();
  51. virtual void Raise();
  52. virtual void Lower();
  53. // implementation from now on
  54. // --------------------------
  55. void OnInternalIdle();
  56. wxIDirectFBWindowPtr GetDirectFBWindow() const { return m_dfbwin; }
  57. // Returns true if some invalidated area of the TLW is currently being
  58. // painted
  59. bool IsPainting() const { return m_isPainting; }
  60. protected:
  61. // common part of all ctors
  62. void Init();
  63. virtual wxIDirectFBSurfacePtr ObtainDfbSurface() const;
  64. // overridden wxWindow methods
  65. virtual void DoGetPosition(int *x, int *y) const;
  66. virtual void DoGetSize(int *width, int *height) const;
  67. virtual void DoMoveWindow(int x, int y, int width, int height);
  68. virtual void DoRefreshRect(const wxRect& rect);
  69. // sets DirectFB keyboard focus to this toplevel window (note that DFB
  70. // focus is different from wx: only shown TLWs can have it and not any
  71. // wxWindows as in wx
  72. void SetDfbFocus();
  73. // overridden in wxTopLevelWindowDFB, there's no common handling for wxTLW
  74. // and wxPopupWindow to be done here
  75. virtual void HandleFocusEvent(const wxDFBWindowEvent& WXUNUSED(event_)) {}
  76. private:
  77. // do queued painting in idle time
  78. void HandleQueuedPaintRequests();
  79. // DirectFB events handling
  80. static void HandleDFBWindowEvent(const wxDFBWindowEvent& event_);
  81. protected:
  82. // did we sent wxSizeEvent at least once?
  83. bool m_sizeSet:1;
  84. // window's opacity (0: transparent, 255: opaque)
  85. wxByte m_opacity;
  86. // interface to the underlying DirectFB window
  87. wxIDirectFBWindowPtr m_dfbwin;
  88. private:
  89. // invalidated areas of the TLW that need repainting
  90. wxDfbQueuedPaintRequests *m_toPaint;
  91. // are we currently painting some area of this TLW?
  92. bool m_isPainting;
  93. friend class wxDFBEventsHandler; // for HandleDFBWindowEvent
  94. friend class wxWindowDFB; // for SetDfbFocus
  95. };
  96. #endif // _WX_DFB_NONOWNEDWND_H_