wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / dfb / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dfb/window.h
3 // Purpose: wxWindow class
4 // Author: Vaclav Slavik
5 // Created: 2006-08-10
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_DFB_WINDOW_H_
11 #define _WX_DFB_WINDOW_H_
12
13 // ---------------------------------------------------------------------------
14 // headers
15 // ---------------------------------------------------------------------------
16
17 #include "wx/dfb/dfbptr.h"
18
19 wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
20 struct wxDFBWindowEvent;
21
22 class WXDLLIMPEXP_FWD_CORE wxFont;
23 class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
24
25 class wxOverlayImpl;
26 class wxDfbOverlaysList;
27
28 // ---------------------------------------------------------------------------
29 // wxWindow
30 // ---------------------------------------------------------------------------
31
32 class WXDLLIMPEXP_CORE wxWindowDFB : public wxWindowBase
33 {
34 public:
35 wxWindowDFB() { Init(); }
36
37 wxWindowDFB(wxWindow *parent,
38 wxWindowID id,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxString& name = wxPanelNameStr)
43 {
44 Init();
45 Create(parent, id, pos, size, style, name);
46 }
47
48 virtual ~wxWindowDFB();
49
50 bool Create(wxWindow *parent,
51 wxWindowID id,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 long style = 0,
55 const wxString& name = wxPanelNameStr);
56
57 // implement base class (pure) virtual methods
58 // -------------------------------------------
59
60 virtual void SetLabel( const wxString &WXUNUSED(label) ) {}
61 virtual wxString GetLabel() const { return wxEmptyString; }
62
63 virtual void Raise();
64 virtual void Lower();
65
66 virtual bool Show(bool show = true);
67
68 virtual void SetFocus();
69
70 virtual bool Reparent(wxWindowBase *newParent);
71
72 virtual void WarpPointer(int x, int y);
73
74 virtual void Refresh(bool eraseBackground = true,
75 const wxRect *rect = (const wxRect *) NULL);
76 virtual void Update();
77
78 virtual bool SetCursor(const wxCursor &cursor);
79 virtual bool SetFont(const wxFont &font) { m_font = font; return true; }
80
81 virtual int GetCharHeight() const;
82 virtual int GetCharWidth() const;
83
84 #if wxUSE_DRAG_AND_DROP
85 virtual void SetDropTarget(wxDropTarget *dropTarget);
86
87 // Accept files for dragging
88 virtual void DragAcceptFiles(bool accept);
89 #endif // wxUSE_DRAG_AND_DROP
90
91 virtual WXWidget GetHandle() const { return this; }
92
93 // implementation from now on
94 // --------------------------
95
96 // Returns DirectFB surface used for rendering of this window
97 wxIDirectFBSurfacePtr GetDfbSurface();
98
99 // returns toplevel window the window belongs to
100 wxNonOwnedWindow *GetTLW() const { return m_tlw; }
101
102 virtual bool IsDoubleBuffered() const { return true; }
103
104 protected:
105 // implement the base class pure virtuals
106 virtual void DoGetTextExtent(const wxString& string,
107 int *x, int *y,
108 int *descent = NULL,
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);
120
121 virtual void DoCaptureMouse();
122 virtual void DoReleaseMouse();
123
124 virtual void DoThaw();
125
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);
131
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;
135
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();
140
141 // called by parent to render (part of) the window
142 void PaintWindow(const wxRect& rect);
143
144 // paint window's overlays (if any) on top of window's surface
145 void PaintOverlays(const wxRect& rect);
146
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);
155
156 // add/remove overlay for this window
157 void AddOverlay(wxOverlayImpl *overlay);
158 void RemoveOverlay(wxOverlayImpl *overlay);
159
160 // DirectFB events handling
161 void HandleKeyEvent(const wxDFBWindowEvent& event_);
162
163 private:
164 // common part of all ctors
165 void Init();
166 // counterpart to SetFocus
167 void DFBKillFocus();
168
169 protected:
170 // toplevel window (i.e. DirectFB window) this window belongs to
171 wxNonOwnedWindow *m_tlw;
172
173 private:
174 // subsurface of TLW's surface covered by this window
175 wxIDirectFBSurfacePtr m_surface;
176
177 // position of the window (relative to the parent, not used by wxTLW, so
178 // don't access it directly)
179 wxRect m_rect;
180
181 // overlays for this window (or NULL if it doesn't have any)
182 wxDfbOverlaysList *m_overlays;
183
184 friend class wxNonOwnedWindow; // for HandleXXXEvent
185 friend class wxOverlayImpl; // for Add/RemoveOverlay
186 friend class wxWindowDCImpl; // for PaintOverlays
187
188 DECLARE_DYNAMIC_CLASS(wxWindowDFB)
189 wxDECLARE_NO_COPY_CLASS(wxWindowDFB);
190 DECLARE_EVENT_TABLE()
191 };
192
193 #endif // _WX_DFB_WINDOW_H_