window.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dfb/window.h
  3. // Purpose: wxWindow class
  4. // Author: Vaclav Slavik
  5. // Created: 2006-08-10
  6. // Copyright: (c) 2006 REA Elektronik GmbH
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DFB_WINDOW_H_
  10. #define _WX_DFB_WINDOW_H_
  11. // ---------------------------------------------------------------------------
  12. // headers
  13. // ---------------------------------------------------------------------------
  14. #include "wx/dfb/dfbptr.h"
  15. wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
  16. struct wxDFBWindowEvent;
  17. class WXDLLIMPEXP_FWD_CORE wxFont;
  18. class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
  19. class wxOverlayImpl;
  20. class wxDfbOverlaysList;
  21. // ---------------------------------------------------------------------------
  22. // wxWindow
  23. // ---------------------------------------------------------------------------
  24. class WXDLLIMPEXP_CORE wxWindowDFB : public wxWindowBase
  25. {
  26. public:
  27. wxWindowDFB() { Init(); }
  28. wxWindowDFB(wxWindow *parent,
  29. wxWindowID id,
  30. const wxPoint& pos = wxDefaultPosition,
  31. const wxSize& size = wxDefaultSize,
  32. long style = 0,
  33. const wxString& name = wxPanelNameStr)
  34. {
  35. Init();
  36. Create(parent, id, pos, size, style, name);
  37. }
  38. virtual ~wxWindowDFB();
  39. bool Create(wxWindow *parent,
  40. wxWindowID id,
  41. const wxPoint& pos = wxDefaultPosition,
  42. const wxSize& size = wxDefaultSize,
  43. long style = 0,
  44. const wxString& name = wxPanelNameStr);
  45. // implement base class (pure) virtual methods
  46. // -------------------------------------------
  47. virtual void SetLabel( const wxString &WXUNUSED(label) ) {}
  48. virtual wxString GetLabel() const { return wxEmptyString; }
  49. virtual void Raise();
  50. virtual void Lower();
  51. virtual bool Show(bool show = true);
  52. virtual void SetFocus();
  53. virtual bool Reparent(wxWindowBase *newParent);
  54. virtual void WarpPointer(int x, int y);
  55. virtual void Refresh(bool eraseBackground = true,
  56. const wxRect *rect = (const wxRect *) NULL);
  57. virtual void Update();
  58. virtual bool SetCursor(const wxCursor &cursor);
  59. virtual bool SetFont(const wxFont &font) { m_font = font; return true; }
  60. virtual int GetCharHeight() const;
  61. virtual int GetCharWidth() const;
  62. #if wxUSE_DRAG_AND_DROP
  63. virtual void SetDropTarget(wxDropTarget *dropTarget);
  64. // Accept files for dragging
  65. virtual void DragAcceptFiles(bool accept);
  66. #endif // wxUSE_DRAG_AND_DROP
  67. virtual WXWidget GetHandle() const { return this; }
  68. // implementation from now on
  69. // --------------------------
  70. // Returns DirectFB surface used for rendering of this window
  71. wxIDirectFBSurfacePtr GetDfbSurface();
  72. // returns toplevel window the window belongs to
  73. wxNonOwnedWindow *GetTLW() const { return m_tlw; }
  74. virtual bool IsDoubleBuffered() const { return true; }
  75. protected:
  76. // implement the base class pure virtuals
  77. virtual void DoGetTextExtent(const wxString& string,
  78. int *x, int *y,
  79. int *descent = NULL,
  80. int *externalLeading = NULL,
  81. const wxFont *theFont = NULL) const;
  82. virtual void DoClientToScreen(int *x, int *y) const;
  83. virtual void DoScreenToClient(int *x, int *y) const;
  84. virtual void DoGetPosition(int *x, int *y) const;
  85. virtual void DoGetSize(int *width, int *height) const;
  86. virtual void DoGetClientSize(int *width, int *height) const;
  87. virtual void DoSetSize(int x, int y,
  88. int width, int height,
  89. int sizeFlags = wxSIZE_AUTO);
  90. virtual void DoSetClientSize(int width, int height);
  91. virtual void DoCaptureMouse();
  92. virtual void DoReleaseMouse();
  93. virtual void DoThaw();
  94. // move the window to the specified location and resize it: this is called
  95. // from both DoSetSize() and DoSetClientSize() and would usually just call
  96. // ::MoveWindow() except for composite controls which will want to arrange
  97. // themselves inside the given rectangle
  98. virtual void DoMoveWindow(int x, int y, int width, int height);
  99. // return DFB surface used to render this window (will be assigned to
  100. // m_surface if the window is visible)
  101. virtual wxIDirectFBSurfacePtr ObtainDfbSurface() const;
  102. // this method must be called when window's position, size or visibility
  103. // changes; it resets m_surface so that ObtainDfbSurface has to be called
  104. // next time GetDfbSurface is called
  105. void InvalidateDfbSurface();
  106. // called by parent to render (part of) the window
  107. void PaintWindow(const wxRect& rect);
  108. // paint window's overlays (if any) on top of window's surface
  109. void PaintOverlays(const wxRect& rect);
  110. // refreshes the entire window (including non-client areas)
  111. void DoRefreshWindow();
  112. // refreshes given rectangle of the window (in window, _not_ client coords)
  113. virtual void DoRefreshRect(const wxRect& rect);
  114. // refreshes given rectangle; unlike RefreshRect(), the argument is in
  115. // window, not client, coords and unlike DoRefreshRect() and like Refresh(),
  116. // does nothing if the window is hidden or frozen
  117. void RefreshWindowRect(const wxRect& rect);
  118. // add/remove overlay for this window
  119. void AddOverlay(wxOverlayImpl *overlay);
  120. void RemoveOverlay(wxOverlayImpl *overlay);
  121. // DirectFB events handling
  122. void HandleKeyEvent(const wxDFBWindowEvent& event_);
  123. private:
  124. // common part of all ctors
  125. void Init();
  126. // counterpart to SetFocus
  127. void DFBKillFocus();
  128. protected:
  129. // toplevel window (i.e. DirectFB window) this window belongs to
  130. wxNonOwnedWindow *m_tlw;
  131. private:
  132. // subsurface of TLW's surface covered by this window
  133. wxIDirectFBSurfacePtr m_surface;
  134. // position of the window (relative to the parent, not used by wxTLW, so
  135. // don't access it directly)
  136. wxRect m_rect;
  137. // overlays for this window (or NULL if it doesn't have any)
  138. wxDfbOverlaysList *m_overlays;
  139. friend class wxNonOwnedWindow; // for HandleXXXEvent
  140. friend class wxOverlayImpl; // for Add/RemoveOverlay
  141. friend class wxWindowDCImpl; // for PaintOverlays
  142. DECLARE_DYNAMIC_CLASS(wxWindowDFB)
  143. wxDECLARE_NO_COPY_CLASS(wxWindowDFB);
  144. DECLARE_EVENT_TABLE()
  145. };
  146. #endif // _WX_DFB_WINDOW_H_