]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/dfb/window.h | |
3 | // Purpose: wxWindow class | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2006-08-10 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2006 REA Elektronik GmbH | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_DFB_WINDOW_H_ | |
12 | #define _WX_DFB_WINDOW_H_ | |
13 | ||
14 | // --------------------------------------------------------------------------- | |
15 | // headers | |
16 | // --------------------------------------------------------------------------- | |
17 | ||
18 | #include "wx/dfb/dfbptr.h" | |
19 | ||
20 | wxDFB_DECLARE_INTERFACE(IDirectFBSurface); | |
21 | struct wxDFBWindowEvent; | |
22 | ||
23 | class WXDLLIMPEXP_FWD_CORE wxFont; | |
24 | class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow; | |
25 | ||
26 | class wxOverlayImpl; | |
27 | class wxDfbOverlaysList; | |
28 | ||
29 | // --------------------------------------------------------------------------- | |
30 | // wxWindow | |
31 | // --------------------------------------------------------------------------- | |
32 | ||
33 | class WXDLLIMPEXP_CORE wxWindowDFB : public wxWindowBase | |
34 | { | |
35 | public: | |
36 | wxWindowDFB() { Init(); } | |
37 | ||
38 | wxWindowDFB(wxWindow *parent, | |
39 | wxWindowID id, | |
40 | const wxPoint& pos = wxDefaultPosition, | |
41 | const wxSize& size = wxDefaultSize, | |
42 | long style = 0, | |
43 | const wxString& name = wxPanelNameStr) | |
44 | { | |
45 | Init(); | |
46 | Create(parent, id, pos, size, style, name); | |
47 | } | |
48 | ||
49 | virtual ~wxWindowDFB(); | |
50 | ||
51 | bool Create(wxWindow *parent, | |
52 | wxWindowID id, | |
53 | const wxPoint& pos = wxDefaultPosition, | |
54 | const wxSize& size = wxDefaultSize, | |
55 | long style = 0, | |
56 | const wxString& name = wxPanelNameStr); | |
57 | ||
58 | // implement base class (pure) virtual methods | |
59 | // ------------------------------------------- | |
60 | ||
61 | virtual void SetLabel( const wxString &WXUNUSED(label) ) {} | |
62 | virtual wxString GetLabel() const { return wxEmptyString; } | |
63 | ||
64 | virtual void Raise(); | |
65 | virtual void Lower(); | |
66 | ||
67 | virtual bool Show(bool show = true); | |
68 | ||
69 | virtual void SetFocus(); | |
70 | ||
71 | virtual bool Reparent(wxWindowBase *newParent); | |
72 | ||
73 | virtual void WarpPointer(int x, int y); | |
74 | ||
75 | virtual void Refresh(bool eraseBackground = true, | |
76 | const wxRect *rect = (const wxRect *) NULL); | |
77 | virtual void Update(); | |
78 | ||
79 | virtual bool SetCursor(const wxCursor &cursor); | |
80 | virtual bool SetFont(const wxFont &font) { m_font = font; return true; } | |
81 | ||
82 | virtual int GetCharHeight() const; | |
83 | virtual int GetCharWidth() const; | |
84 | virtual void GetTextExtent(const wxString& string, | |
85 | int *x, int *y, | |
86 | int *descent = NULL, | |
87 | int *externalLeading = NULL, | |
88 | const wxFont *theFont = (const wxFont *) NULL) | |
89 | const; | |
90 | ||
91 | #if wxUSE_DRAG_AND_DROP | |
92 | virtual void SetDropTarget(wxDropTarget *dropTarget); | |
93 | ||
94 | // Accept files for dragging | |
95 | virtual void DragAcceptFiles(bool accept); | |
96 | #endif // wxUSE_DRAG_AND_DROP | |
97 | ||
98 | virtual WXWidget GetHandle() const { return this; } | |
99 | ||
100 | // implementation from now on | |
101 | // -------------------------- | |
102 | ||
103 | // Returns DirectFB surface used for rendering of this window | |
104 | wxIDirectFBSurfacePtr GetDfbSurface(); | |
105 | ||
106 | // returns toplevel window the window belongs to | |
107 | wxNonOwnedWindow *GetTLW() const { return m_tlw; } | |
108 | ||
109 | void OnInternalIdle(); | |
110 | ||
111 | virtual bool IsDoubleBuffered() const { return true; } | |
112 | ||
113 | protected: | |
114 | // implement the base class pure virtuals | |
115 | virtual void DoClientToScreen(int *x, int *y) const; | |
116 | virtual void DoScreenToClient(int *x, int *y) const; | |
117 | virtual void DoGetPosition(int *x, int *y) const; | |
118 | virtual void DoGetSize(int *width, int *height) const; | |
119 | virtual void DoGetClientSize(int *width, int *height) const; | |
120 | virtual void DoSetSize(int x, int y, | |
121 | int width, int height, | |
122 | int sizeFlags = wxSIZE_AUTO); | |
123 | virtual void DoSetClientSize(int width, int height); | |
124 | ||
125 | virtual void DoCaptureMouse(); | |
126 | virtual void DoReleaseMouse(); | |
127 | ||
128 | virtual void DoThaw(); | |
129 | ||
130 | // move the window to the specified location and resize it: this is called | |
131 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
132 | // ::MoveWindow() except for composite controls which will want to arrange | |
133 | // themselves inside the given rectangle | |
134 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
135 | ||
136 | // return DFB surface used to render this window (will be assigned to | |
137 | // m_surface if the window is visible) | |
138 | virtual wxIDirectFBSurfacePtr ObtainDfbSurface() const; | |
139 | ||
140 | // this method must be called when window's position, size or visibility | |
141 | // changes; it resets m_surface so that ObtainDfbSurface has to be called | |
142 | // next time GetDfbSurface is called | |
143 | void InvalidateDfbSurface(); | |
144 | ||
145 | // called by parent to render (part of) the window | |
146 | void PaintWindow(const wxRect& rect); | |
147 | ||
148 | // paint window's overlays (if any) on top of window's surface | |
149 | void PaintOverlays(const wxRect& rect); | |
150 | ||
151 | // refreshes the entire window (including non-client areas) | |
152 | void DoRefreshWindow(); | |
153 | // refreshes given rectangle of the window (in window, _not_ client coords) | |
154 | virtual void DoRefreshRect(const wxRect& rect); | |
155 | // refreshes given rectangle; unlike RefreshRect(), the argument is in | |
156 | // window, not client, coords and unlike DoRefreshRect() and like Refresh(), | |
157 | // does nothing if the window is hidden or frozen | |
158 | void RefreshWindowRect(const wxRect& rect); | |
159 | ||
160 | // add/remove overlay for this window | |
161 | void AddOverlay(wxOverlayImpl *overlay); | |
162 | void RemoveOverlay(wxOverlayImpl *overlay); | |
163 | ||
164 | // DirectFB events handling | |
165 | void HandleKeyEvent(const wxDFBWindowEvent& event_); | |
166 | ||
167 | private: | |
168 | // common part of all ctors | |
169 | void Init(); | |
170 | // counterpart to SetFocus | |
171 | void DFBKillFocus(); | |
172 | ||
173 | protected: | |
174 | // toplevel window (i.e. DirectFB window) this window belongs to | |
175 | wxNonOwnedWindow *m_tlw; | |
176 | ||
177 | private: | |
178 | // subsurface of TLW's surface covered by this window | |
179 | wxIDirectFBSurfacePtr m_surface; | |
180 | ||
181 | // position of the window (relative to the parent, not used by wxTLW, so | |
182 | // don't access it directly) | |
183 | wxRect m_rect; | |
184 | ||
185 | // overlays for this window (or NULL if it doesn't have any) | |
186 | wxDfbOverlaysList *m_overlays; | |
187 | ||
188 | friend class wxNonOwnedWindow; // for HandleXXXEvent | |
189 | friend class wxOverlayImpl; // for Add/RemoveOverlay | |
190 | friend class wxWindowDCImpl; // for PaintOverlays | |
191 | ||
192 | DECLARE_DYNAMIC_CLASS(wxWindowDFB) | |
193 | wxDECLARE_NO_COPY_CLASS(wxWindowDFB); | |
194 | DECLARE_EVENT_TABLE() | |
195 | }; | |
196 | ||
197 | #endif // _WX_DFB_WINDOW_H_ |