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();
79 virtual bool SetCursor(const wxCursor
&cursor
);
80 virtual bool SetFont(const wxFont
&font
) { m_font
= font
; return true; }
82 virtual int GetCharHeight() const;
83 virtual int GetCharWidth() const;
85 #if wxUSE_DRAG_AND_DROP
86 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
88 // Accept files for dragging
89 virtual void DragAcceptFiles(bool accept
);
90 #endif // wxUSE_DRAG_AND_DROP
92 virtual WXWidget
GetHandle() const { return this; }
94 // implementation from now on
95 // --------------------------
97 // Returns DirectFB surface used for rendering of this window
98 wxIDirectFBSurfacePtr
GetDfbSurface();
100 // returns toplevel window the window belongs to
101 wxNonOwnedWindow
*GetTLW() const { return m_tlw
; }
103 void OnInternalIdle();
105 virtual bool IsDoubleBuffered() const { return true; }
108 // implement the base class pure virtuals
109 virtual void DoGetTextExtent(const wxString
& string
,
112 int *externalLeading
= NULL
,
113 const wxFont
*theFont
= NULL
) const;
114 virtual void DoClientToScreen(int *x
, int *y
) const;
115 virtual void DoScreenToClient(int *x
, int *y
) const;
116 virtual void DoGetPosition(int *x
, int *y
) const;
117 virtual void DoGetSize(int *width
, int *height
) const;
118 virtual void DoGetClientSize(int *width
, int *height
) const;
119 virtual void DoSetSize(int x
, int y
,
120 int width
, int height
,
121 int sizeFlags
= wxSIZE_AUTO
);
122 virtual void DoSetClientSize(int width
, int height
);
124 virtual void DoCaptureMouse();
125 virtual void DoReleaseMouse();
127 virtual void DoThaw();
129 // move the window to the specified location and resize it: this is called
130 // from both DoSetSize() and DoSetClientSize() and would usually just call
131 // ::MoveWindow() except for composite controls which will want to arrange
132 // themselves inside the given rectangle
133 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
135 // return DFB surface used to render this window (will be assigned to
136 // m_surface if the window is visible)
137 virtual wxIDirectFBSurfacePtr
ObtainDfbSurface() const;
139 // this method must be called when window's position, size or visibility
140 // changes; it resets m_surface so that ObtainDfbSurface has to be called
141 // next time GetDfbSurface is called
142 void InvalidateDfbSurface();
144 // called by parent to render (part of) the window
145 void PaintWindow(const wxRect
& rect
);
147 // paint window's overlays (if any) on top of window's surface
148 void PaintOverlays(const wxRect
& rect
);
150 // refreshes the entire window (including non-client areas)
151 void DoRefreshWindow();
152 // refreshes given rectangle of the window (in window, _not_ client coords)
153 virtual void DoRefreshRect(const wxRect
& rect
);
154 // refreshes given rectangle; unlike RefreshRect(), the argument is in
155 // window, not client, coords and unlike DoRefreshRect() and like Refresh(),
156 // does nothing if the window is hidden or frozen
157 void RefreshWindowRect(const wxRect
& rect
);
159 // add/remove overlay for this window
160 void AddOverlay(wxOverlayImpl
*overlay
);
161 void RemoveOverlay(wxOverlayImpl
*overlay
);
163 // DirectFB events handling
164 void HandleKeyEvent(const wxDFBWindowEvent
& event_
);
167 // common part of all ctors
169 // counterpart to SetFocus
173 // toplevel window (i.e. DirectFB window) this window belongs to
174 wxNonOwnedWindow
*m_tlw
;
177 // subsurface of TLW's surface covered by this window
178 wxIDirectFBSurfacePtr m_surface
;
180 // position of the window (relative to the parent, not used by wxTLW, so
181 // don't access it directly)
184 // overlays for this window (or NULL if it doesn't have any)
185 wxDfbOverlaysList
*m_overlays
;
187 friend class wxNonOwnedWindow
; // for HandleXXXEvent
188 friend class wxOverlayImpl
; // for Add/RemoveOverlay
189 friend class wxWindowDCImpl
; // for PaintOverlays
191 DECLARE_DYNAMIC_CLASS(wxWindowDFB
)
192 wxDECLARE_NO_COPY_CLASS(wxWindowDFB
);
193 DECLARE_EVENT_TABLE()
196 #endif // _WX_DFB_WINDOW_H_