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/ifacehelpers.h"
20 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
21 struct wxDFBWindowEvent
;
23 class WXDLLIMPEXP_CORE wxFont
;
24 class WXDLLIMPEXP_CORE wxTopLevelWindowDFB
;
26 // ---------------------------------------------------------------------------
28 // ---------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxWindowDFB
: public wxWindowBase
33 wxWindowDFB() { Init(); }
35 wxWindowDFB(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
40 const wxString
& name
= wxPanelNameStr
)
43 Create(parent
, id
, pos
, size
, style
, name
);
46 virtual ~wxWindowDFB();
48 bool Create(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxPanelNameStr
);
55 // implement base class (pure) virtual methods
56 // -------------------------------------------
58 virtual void SetLabel( const wxString
&WXUNUSED(label
) ) {}
59 virtual wxString
GetLabel() const { return wxEmptyString
; }
64 virtual bool Show(bool show
= true);
66 virtual void SetFocus();
68 virtual bool Reparent(wxWindowBase
*newParent
);
70 virtual void WarpPointer(int x
, int y
);
72 virtual void Refresh(bool eraseBackground
= true,
73 const wxRect
*rect
= (const wxRect
*) NULL
);
74 virtual void Update();
76 virtual void Freeze();
78 bool IsFrozen() const { return m_frozenness
> 0; }
80 virtual bool SetCursor(const wxCursor
&cursor
);
81 virtual bool SetFont(const wxFont
&font
) { m_font
= font
; return true; }
83 virtual int GetCharHeight() const;
84 virtual int GetCharWidth() const;
85 virtual void GetTextExtent(const wxString
& string
,
87 int *descent
= (int *) NULL
,
88 int *externalLeading
= (int *) NULL
,
89 const wxFont
*theFont
= (const wxFont
*) NULL
)
92 #if wxUSE_DRAG_AND_DROP
93 virtual void SetDropTarget(wxDropTarget
*dropTarget
);
95 // Accept files for dragging
96 virtual void DragAcceptFiles(bool accept
);
97 #endif // wxUSE_DRAG_AND_DROP
99 virtual WXWidget
GetHandle() const { return this; }
101 // implementation from now on
102 // --------------------------
104 // Returns DirectFB surface used for rendering of this window
105 IDirectFBSurfacePtr
GetDfbSurface();
107 // returns toplevel window the window belongs to
108 wxTopLevelWindowDFB
*GetTLW() const { return m_tlw
; }
110 void OnInternalIdle();
113 // implement the base class pure virtuals
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 // move the window to the specified location and resize it: this is called
128 // from both DoSetSize() and DoSetClientSize() and would usually just call
129 // ::MoveWindow() except for composite controls which will want to arrange
130 // themselves inside the given rectangle
131 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
133 // return DFB surface used to render this window (will be assigned to
134 // m_surface if the window is visible)
135 virtual IDirectFBSurfacePtr
ObtainDfbSurface() const;
137 // this method must be called when window's position, size or visibility
138 // changes; it resets m_surface so that ObtainDfbSurface has to be called
139 // next time GetDfbSurface is called
140 void InvalidateDfbSurface();
142 // called by parent to render (part of) the window
143 void PaintWindow(const wxRect
& rect
, bool eraseBackground
);
145 // implementation of Refresh()
146 void DoRefreshWindow(bool eraseBack
= true);
147 virtual void DoRefreshRect(const wxRect
& rect
, bool eraseBack
= true);
149 // DirectFB events handling
150 void HandleKeyEvent(const wxDFBWindowEvent
& event_
);
153 // common part of all ctors
155 // counterpart to SetFocus
159 // toplevel window (i.e. DirectFB window) this window belongs to
160 wxTopLevelWindowDFB
*m_tlw
;
163 // subsurface of TLW's surface covered by this window
164 IDirectFBSurfacePtr m_surface
;
166 // position of the window (relative to the parent, not used by wxTLW, so
167 // don't access it directly)
170 // number of calls to Freeze() minus number of calls to Thaw()
171 unsigned m_frozenness
;
173 friend class wxTopLevelWindowDFB
; // for HandleXXXEvent
175 DECLARE_DYNAMIC_CLASS(wxWindowDFB
)
176 DECLARE_NO_COPY_CLASS(wxWindowDFB
)
177 DECLARE_EVENT_TABLE()
181 #endif // _WX_DFB_WINDOW_H_