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_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 virtual 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 wxIDirectFBSurfacePtr
GetDfbSurface();
107 // returns toplevel window the window belongs to
108 wxTopLevelWindowDFB
*GetTLW() const { return m_tlw
; }
110 void OnInternalIdle();
112 virtual bool IsDoubleBuffered() const { return true; }
115 // implement the base class pure virtuals
116 virtual void DoClientToScreen(int *x
, int *y
) const;
117 virtual void DoScreenToClient(int *x
, int *y
) const;
118 virtual void DoGetPosition(int *x
, int *y
) const;
119 virtual void DoGetSize(int *width
, int *height
) const;
120 virtual void DoGetClientSize(int *width
, int *height
) const;
121 virtual void DoSetSize(int x
, int y
,
122 int width
, int height
,
123 int sizeFlags
= wxSIZE_AUTO
);
124 virtual void DoSetClientSize(int width
, int height
);
126 virtual void DoCaptureMouse();
127 virtual void DoReleaseMouse();
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 // 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
);
152 // DirectFB events handling
153 void HandleKeyEvent(const wxDFBWindowEvent
& event_
);
156 // common part of all ctors
158 // counterpart to SetFocus
162 // toplevel window (i.e. DirectFB window) this window belongs to
163 wxTopLevelWindowDFB
*m_tlw
;
166 // subsurface of TLW's surface covered by this window
167 wxIDirectFBSurfacePtr m_surface
;
169 // position of the window (relative to the parent, not used by wxTLW, so
170 // don't access it directly)
173 // number of calls to Freeze() minus number of calls to Thaw()
174 unsigned m_frozenness
;
176 friend class wxTopLevelWindowDFB
; // for HandleXXXEvent
178 DECLARE_DYNAMIC_CLASS(wxWindowDFB
)
179 DECLARE_NO_COPY_CLASS(wxWindowDFB
)
180 DECLARE_EVENT_TABLE()
183 #endif // _WX_DFB_WINDOW_H_