1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dfb/window.h
3 // Purpose: wxWindow class
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_DFB_WINDOW_H_
12 #define _WX_DFB_WINDOW_H_
14 // ---------------------------------------------------------------------------
16 // ---------------------------------------------------------------------------
18 #include "wx/dfb/dfbptr.h"
20 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
21 struct wxDFBWindowEvent
;
23 class WXDLLIMPEXP_FWD_CORE wxFont
;
24 class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow
;
27 class wxDfbOverlaysList
;
29 // ---------------------------------------------------------------------------
31 // ---------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxWindowDFB
: public wxWindowBase
36 wxWindowDFB() { Init(); }
38 wxWindowDFB(wxWindow
*parent
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
43 const wxString
& name
= wxPanelNameStr
)
46 Create(parent
, id
, pos
, size
, style
, name
);
49 virtual ~wxWindowDFB();
51 bool Create(wxWindow
*parent
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
56 const wxString
& name
= wxPanelNameStr
);
58 // implement base class (pure) virtual methods
59 // -------------------------------------------
61 virtual void SetLabel( const wxString
&WXUNUSED(label
) ) {}
62 virtual wxString
GetLabel() const { return wxEmptyString
; }
67 virtual bool Show(bool show
= true);
69 virtual void SetFocus();
71 virtual bool Reparent(wxWindowBase
*newParent
);
73 virtual void WarpPointer(int x
, int y
);
75 virtual void Refresh(bool eraseBackground
= true,
76 const wxRect
*rect
= (const wxRect
*) NULL
);
77 virtual void Update();
78 virtual void Freeze();
80 virtual bool IsFrozen() const { return m_frozenness
> 0; }
82 virtual bool SetCursor(const wxCursor
&cursor
);
83 virtual bool SetFont(const wxFont
&font
) { m_font
= font
; return true; }
85 virtual int GetCharHeight() const;
86 virtual int GetCharWidth() const;
87 virtual void GetTextExtent(const wxString
& string
,
89 int *descent
= (int *) NULL
,
90 int *externalLeading
= (int *) NULL
,
91 const wxFont
*theFont
= (const wxFont
*) NULL
)
94 #if wxUSE_DRAG_AND_DROP
95 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
97 // Accept files for dragging
98 virtual void DragAcceptFiles(bool accept
);
99 #endif // wxUSE_DRAG_AND_DROP
101 virtual WXWidget
GetHandle() const { return this; }
103 // implementation from now on
104 // --------------------------
106 // Returns DirectFB surface used for rendering of this window
107 wxIDirectFBSurfacePtr
GetDfbSurface();
109 // returns toplevel window the window belongs to
110 wxNonOwnedWindow
*GetTLW() const { return m_tlw
; }
112 void OnInternalIdle();
114 virtual bool IsDoubleBuffered() const { return true; }
117 // implement the base class pure virtuals
118 virtual void DoClientToScreen(int *x
, int *y
) const;
119 virtual void DoScreenToClient(int *x
, int *y
) const;
120 virtual void DoGetPosition(int *x
, int *y
) const;
121 virtual void DoGetSize(int *width
, int *height
) const;
122 virtual void DoGetClientSize(int *width
, int *height
) const;
123 virtual void DoSetSize(int x
, int y
,
124 int width
, int height
,
125 int sizeFlags
= wxSIZE_AUTO
);
126 virtual void DoSetClientSize(int width
, int height
);
128 virtual void DoCaptureMouse();
129 virtual void DoReleaseMouse();
131 // move the window to the specified location and resize it: this is called
132 // from both DoSetSize() and DoSetClientSize() and would usually just call
133 // ::MoveWindow() except for composite controls which will want to arrange
134 // themselves inside the given rectangle
135 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
137 // return DFB surface used to render this window (will be assigned to
138 // m_surface if the window is visible)
139 virtual wxIDirectFBSurfacePtr
ObtainDfbSurface() const;
141 // this method must be called when window's position, size or visibility
142 // changes; it resets m_surface so that ObtainDfbSurface has to be called
143 // next time GetDfbSurface is called
144 void InvalidateDfbSurface();
146 // called by parent to render (part of) the window
147 void PaintWindow(const wxRect
& rect
);
149 // paint window's overlays (if any) on top of window's surface
150 void PaintOverlays(const wxRect
& rect
);
152 // refreshes the entire window (including non-client areas)
153 void DoRefreshWindow();
154 // refreshes given rectangle of the window (in window, _not_ client coords)
155 virtual void DoRefreshRect(const wxRect
& rect
);
156 // refreshes given rectangle; unlike RefreshRect(), the argument is in
157 // window, not client, coords and unlike DoRefreshRect() and like Refresh(),
158 // does nothing if the window is hidden or frozen
159 void RefreshWindowRect(const wxRect
& rect
);
161 // add/remove overlay for this window
162 void AddOverlay(wxOverlayImpl
*overlay
);
163 void RemoveOverlay(wxOverlayImpl
*overlay
);
165 // DirectFB events handling
166 void HandleKeyEvent(const wxDFBWindowEvent
& event_
);
169 // common part of all ctors
171 // counterpart to SetFocus
175 // toplevel window (i.e. DirectFB window) this window belongs to
176 wxNonOwnedWindow
*m_tlw
;
179 // subsurface of TLW's surface covered by this window
180 wxIDirectFBSurfacePtr m_surface
;
182 // position of the window (relative to the parent, not used by wxTLW, so
183 // don't access it directly)
186 // number of calls to Freeze() minus number of calls to Thaw()
187 unsigned m_frozenness
;
189 // overlays for this window (or NULL if it doesn't have any)
190 wxDfbOverlaysList
*m_overlays
;
192 friend class wxNonOwnedWindow
; // for HandleXXXEvent
193 friend class wxOverlayImpl
; // for Add/RemoveOverlay
194 friend class wxWindowDC
; // for PaintOverlays
196 DECLARE_DYNAMIC_CLASS(wxWindowDFB
)
197 DECLARE_NO_COPY_CLASS(wxWindowDFB
)
198 DECLARE_EVENT_TABLE()
201 #endif // _WX_DFB_WINDOW_H_