1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dfb/window.h
3 // Purpose: wxWindow class
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_DFB_WINDOW_H_
11 #define _WX_DFB_WINDOW_H_
13 // ---------------------------------------------------------------------------
15 // ---------------------------------------------------------------------------
17 #include "wx/dfb/dfbptr.h"
19 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
20 struct wxDFBWindowEvent
;
22 class WXDLLIMPEXP_FWD_CORE wxFont
;
23 class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow
;
26 class wxDfbOverlaysList
;
28 // ---------------------------------------------------------------------------
30 // ---------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxWindowDFB
: public wxWindowBase
35 wxWindowDFB() { Init(); }
37 wxWindowDFB(wxWindow
*parent
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
42 const wxString
& name
= wxPanelNameStr
)
45 Create(parent
, id
, pos
, size
, style
, name
);
48 virtual ~wxWindowDFB();
50 bool Create(wxWindow
*parent
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
,
55 const wxString
& name
= wxPanelNameStr
);
57 // implement base class (pure) virtual methods
58 // -------------------------------------------
60 virtual void SetLabel( const wxString
&WXUNUSED(label
) ) {}
61 virtual wxString
GetLabel() const { return wxEmptyString
; }
66 virtual bool Show(bool show
= true);
68 virtual void SetFocus();
70 virtual bool Reparent(wxWindowBase
*newParent
);
72 virtual void WarpPointer(int x
, int y
);
74 virtual void Refresh(bool eraseBackground
= true,
75 const wxRect
*rect
= (const wxRect
*) NULL
);
76 virtual void Update();
78 virtual bool SetCursor(const wxCursor
&cursor
);
79 virtual bool SetFont(const wxFont
&font
) { m_font
= font
; return true; }
81 virtual int GetCharHeight() const;
82 virtual int GetCharWidth() const;
84 #if wxUSE_DRAG_AND_DROP
85 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
87 // Accept files for dragging
88 virtual void DragAcceptFiles(bool accept
);
89 #endif // wxUSE_DRAG_AND_DROP
91 virtual WXWidget
GetHandle() const { return this; }
93 // implementation from now on
94 // --------------------------
96 // Returns DirectFB surface used for rendering of this window
97 wxIDirectFBSurfacePtr
GetDfbSurface();
99 // returns toplevel window the window belongs to
100 wxNonOwnedWindow
*GetTLW() const { return m_tlw
; }
102 virtual bool IsDoubleBuffered() const { return true; }
105 // implement the base class pure virtuals
106 virtual void DoGetTextExtent(const wxString
& string
,
109 int *externalLeading
= NULL
,
110 const wxFont
*theFont
= NULL
) const;
111 virtual void DoClientToScreen(int *x
, int *y
) const;
112 virtual void DoScreenToClient(int *x
, int *y
) const;
113 virtual void DoGetPosition(int *x
, int *y
) const;
114 virtual void DoGetSize(int *width
, int *height
) const;
115 virtual void DoGetClientSize(int *width
, int *height
) const;
116 virtual void DoSetSize(int x
, int y
,
117 int width
, int height
,
118 int sizeFlags
= wxSIZE_AUTO
);
119 virtual void DoSetClientSize(int width
, int height
);
121 virtual void DoCaptureMouse();
122 virtual void DoReleaseMouse();
124 virtual void DoThaw();
126 // move the window to the specified location and resize it: this is called
127 // from both DoSetSize() and DoSetClientSize() and would usually just call
128 // ::MoveWindow() except for composite controls which will want to arrange
129 // themselves inside the given rectangle
130 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
132 // return DFB surface used to render this window (will be assigned to
133 // m_surface if the window is visible)
134 virtual wxIDirectFBSurfacePtr
ObtainDfbSurface() const;
136 // this method must be called when window's position, size or visibility
137 // changes; it resets m_surface so that ObtainDfbSurface has to be called
138 // next time GetDfbSurface is called
139 void InvalidateDfbSurface();
141 // called by parent to render (part of) the window
142 void PaintWindow(const wxRect
& rect
);
144 // paint window's overlays (if any) on top of window's surface
145 void PaintOverlays(const wxRect
& rect
);
147 // refreshes the entire window (including non-client areas)
148 void DoRefreshWindow();
149 // refreshes given rectangle of the window (in window, _not_ client coords)
150 virtual void DoRefreshRect(const wxRect
& rect
);
151 // refreshes given rectangle; unlike RefreshRect(), the argument is in
152 // window, not client, coords and unlike DoRefreshRect() and like Refresh(),
153 // does nothing if the window is hidden or frozen
154 void RefreshWindowRect(const wxRect
& rect
);
156 // add/remove overlay for this window
157 void AddOverlay(wxOverlayImpl
*overlay
);
158 void RemoveOverlay(wxOverlayImpl
*overlay
);
160 // DirectFB events handling
161 void HandleKeyEvent(const wxDFBWindowEvent
& event_
);
164 // common part of all ctors
166 // counterpart to SetFocus
170 // toplevel window (i.e. DirectFB window) this window belongs to
171 wxNonOwnedWindow
*m_tlw
;
174 // subsurface of TLW's surface covered by this window
175 wxIDirectFBSurfacePtr m_surface
;
177 // position of the window (relative to the parent, not used by wxTLW, so
178 // don't access it directly)
181 // overlays for this window (or NULL if it doesn't have any)
182 wxDfbOverlaysList
*m_overlays
;
184 friend class wxNonOwnedWindow
; // for HandleXXXEvent
185 friend class wxOverlayImpl
; // for Add/RemoveOverlay
186 friend class wxWindowDCImpl
; // for PaintOverlays
188 DECLARE_DYNAMIC_CLASS(wxWindowDFB
)
189 wxDECLARE_NO_COPY_CLASS(wxWindowDFB
);
190 DECLARE_EVENT_TABLE()
193 #endif // _WX_DFB_WINDOW_H_