]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
3 | // Purpose: wxWindow class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_WINDOW_H_ |
13 | #define _WX_WINDOW_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "window.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/gdicmn.h" | |
20 | #include "wx/icon.h" | |
21 | #include "wx/cursor.h" | |
22 | #include "wx/pen.h" | |
23 | #include "wx/font.h" | |
24 | #include "wx/validate.h" | |
25 | #include "wx/event.h" | |
26 | #include "wx/string.h" | |
27 | #include "wx/list.h" | |
81d66cf3 | 28 | #include "wx/region.h" |
14b72bf5 | 29 | #include "wx/msw/accel.h" |
2bda0e17 KB |
30 | |
31 | #define wxKEY_SHIFT 1 | |
32 | #define wxKEY_CTRL 2 | |
33 | ||
34 | /* | |
35 | * Base class for frame, panel, canvas, panel items, dialog box. | |
36 | * | |
37 | */ | |
38 | ||
39 | /* | |
40 | * Event handler: windows have themselves as their event handlers | |
41 | * by default, but their event handlers could be set to another | |
42 | * object entirely. This separation can reduce the amount of | |
43 | * derivation required, and allow alteration of a window's functionality | |
44 | * (e.g. by a resource editor that temporarily switches event handlers). | |
45 | */ | |
46 | ||
47 | class WXDLLEXPORT wxWindow; | |
48 | class WXDLLEXPORT wxEvent; | |
49 | class WXDLLEXPORT wxCommandEvent; | |
50 | class WXDLLEXPORT wxKeyEvent; | |
51 | class WXDLLEXPORT wxControl; | |
52 | class WXDLLEXPORT wxCursor; | |
53 | class WXDLLEXPORT wxColourMap; | |
54 | class WXDLLEXPORT wxFont; | |
55 | class WXDLLEXPORT wxMenu; | |
1b826605 | 56 | class WXDLLEXPORT wxRect; |
2bda0e17 KB |
57 | class WXDLLEXPORT wxBitmap; |
58 | class WXDLLEXPORT wxSizer; | |
59 | class WXDLLEXPORT wxList; | |
60 | class WXDLLEXPORT wxLayoutConstraints; | |
61 | class WXDLLEXPORT wxMouseEvent; | |
62 | class WXDLLEXPORT wxButton; | |
63 | class WXDLLEXPORT wxColour; | |
64 | class WXDLLEXPORT wxBrush; | |
65 | class WXDLLEXPORT wxPen; | |
66 | class WXDLLEXPORT wxIcon; | |
67 | class WXDLLEXPORT wxDC; | |
68 | class WXDLLEXPORT wxValidator; | |
69 | ||
47d67540 | 70 | #if wxUSE_DRAG_AND_DROP |
b823f5a1 | 71 | class WXDLLEXPORT wxDropTarget; |
2bda0e17 KB |
72 | #endif |
73 | ||
47d67540 | 74 | #if wxUSE_WX_RESOURCES |
2bda0e17 KB |
75 | class WXDLLEXPORT wxResourceTable; |
76 | class WXDLLEXPORT wxItemResource; | |
77 | #endif | |
78 | ||
79 | WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; | |
80 | ||
81 | WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; | |
82 | WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; | |
83 | ||
fd3f686c | 84 | class WXDLLEXPORT wxWindow : public wxEvtHandler |
2bda0e17 KB |
85 | { |
86 | DECLARE_ABSTRACT_CLASS(wxWindow) | |
87 | ||
2bda0e17 KB |
88 | friend class wxDC; |
89 | friend class wxPaintDC; | |
90 | ||
91 | public: | |
fd3f686c VZ |
92 | wxWindow(); |
93 | wxWindow(wxWindow *parent, wxWindowID id, | |
2bda0e17 KB |
94 | const wxPoint& pos = wxDefaultPosition, |
95 | const wxSize& size = wxDefaultSize, | |
debe6624 | 96 | long style = 0, |
2bda0e17 KB |
97 | const wxString& name = wxPanelNameStr) |
98 | { | |
cf65ad8d | 99 | Init(); |
2bda0e17 KB |
100 | Create(parent, id, pos, size, style, name); |
101 | } | |
102 | ||
fd3f686c | 103 | virtual ~wxWindow(); |
2bda0e17 | 104 | |
debe6624 | 105 | bool Create(wxWindow *parent, wxWindowID id, |
2bda0e17 KB |
106 | const wxPoint& pos = wxDefaultPosition, |
107 | const wxSize& size = wxDefaultSize, | |
debe6624 | 108 | long style = 0, |
2bda0e17 KB |
109 | const wxString& name = wxPanelNameStr); |
110 | ||
111 | // Fit the window around the items | |
fd3f686c | 112 | virtual void Fit(); |
2bda0e17 KB |
113 | |
114 | // Show or hide the window | |
debe6624 | 115 | virtual bool Show(bool show); |
2bda0e17 KB |
116 | |
117 | // Is the window shown? | |
fd3f686c | 118 | virtual bool IsShown() const; |
2bda0e17 KB |
119 | |
120 | // Raise the window to the top of the Z order | |
fd3f686c | 121 | virtual void Raise(); |
2bda0e17 KB |
122 | |
123 | // Lower the window to the bottom of the Z order | |
fd3f686c | 124 | virtual void Lower(); |
2bda0e17 KB |
125 | |
126 | // Is the window enabled? | |
fd3f686c | 127 | virtual bool IsEnabled() const; |
2bda0e17 KB |
128 | |
129 | // For compatibility | |
fd3f686c | 130 | inline bool Enabled() const { return IsEnabled(); } |
2bda0e17 KB |
131 | |
132 | // Dialog support: override these and call | |
133 | // base class members to add functionality | |
134 | // that can't be done using validators. | |
135 | ||
136 | // Transfer values to controls. If returns FALSE, | |
137 | // it's an application error (pops up a dialog) | |
fd3f686c | 138 | virtual bool TransferDataToWindow(); |
2bda0e17 KB |
139 | |
140 | // Transfer values from controls. If returns FALSE, | |
141 | // transfer failed: don't quit | |
fd3f686c | 142 | virtual bool TransferDataFromWindow(); |
2bda0e17 KB |
143 | |
144 | // Validate controls. If returns FALSE, | |
145 | // validation failed: don't quit | |
fd3f686c | 146 | virtual bool Validate(); |
2bda0e17 KB |
147 | |
148 | // Return code for dialogs | |
149 | inline void SetReturnCode(int retCode); | |
fd3f686c | 150 | inline int GetReturnCode(); |
2bda0e17 KB |
151 | |
152 | // Set the cursor | |
153 | virtual void SetCursor(const wxCursor& cursor); | |
fd3f686c | 154 | inline virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; }; |
2bda0e17 KB |
155 | |
156 | // Get the window with the focus | |
fd3f686c | 157 | static wxWindow *FindFocus(); |
2bda0e17 KB |
158 | |
159 | // Get character size | |
fd3f686c VZ |
160 | virtual int GetCharHeight() const; |
161 | virtual int GetCharWidth() const; | |
2bda0e17 KB |
162 | |
163 | // Get overall window size | |
164 | virtual void GetSize(int *width, int *height) const; | |
4fabb575 JS |
165 | virtual wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } |
166 | virtual wxRect GetRect() const { int w, h; int x, y; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } | |
2bda0e17 KB |
167 | |
168 | // Get window position, relative to parent (or screen if no parent) | |
169 | virtual void GetPosition(int *x, int *y) const; | |
4fabb575 | 170 | virtual wxPoint GetPosition() const { int x, y; GetPosition(&x, &y); return wxPoint(x, y); } |
2bda0e17 KB |
171 | |
172 | // Get client (application-useable) size | |
173 | virtual void GetClientSize(int *width, int *height) const; | |
4fabb575 | 174 | virtual wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } |
2bda0e17 KB |
175 | |
176 | // Set overall size and position | |
debe6624 | 177 | virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); |
4fabb575 JS |
178 | virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } |
179 | virtual void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) | |
180 | { SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } | |
181 | virtual void SetSize(const wxSize& size) { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); } | |
182 | ||
183 | virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); } | |
184 | virtual void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); } | |
2bda0e17 KB |
185 | |
186 | // Set client size | |
4fabb575 JS |
187 | virtual void SetClientSize(int width, int height); |
188 | virtual void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); } | |
2bda0e17 KB |
189 | |
190 | // Convert client to screen coordinates | |
191 | virtual void ClientToScreen(int *x, int *y) const; | |
4fabb575 JS |
192 | virtual wxPoint ClientToScreen(const wxPoint& pt) const |
193 | { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } | |
2bda0e17 KB |
194 | |
195 | // Convert screen to client coordinates | |
196 | virtual void ScreenToClient(int *x, int *y) const; | |
4fabb575 JS |
197 | virtual wxPoint ScreenToClient(const wxPoint& pt) const |
198 | { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } | |
2bda0e17 KB |
199 | |
200 | // Set the focus to this window | |
fd3f686c | 201 | virtual void SetFocus(); |
2bda0e17 KB |
202 | |
203 | // Capture/release mouse | |
fd3f686c VZ |
204 | virtual void CaptureMouse(); |
205 | virtual void ReleaseMouse(); | |
2bda0e17 KB |
206 | |
207 | // Enable or disable the window | |
debe6624 | 208 | virtual void Enable(bool enable); |
2bda0e17 | 209 | |
47d67540 | 210 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
211 | // Associate a drop target with this window (if the window already had a drop |
212 | // target, it's deleted!) and return the current drop target (may be NULL). | |
213 | void SetDropTarget(wxDropTarget *pDropTarget); | |
214 | wxDropTarget *GetDropTarget() const { return m_pDropTarget; } | |
215 | #endif | |
216 | ||
217 | // Accept files for dragging | |
debe6624 | 218 | virtual void DragAcceptFiles(bool accept); |
2bda0e17 | 219 | |
81d66cf3 JS |
220 | // Update region access |
221 | virtual wxRegion GetUpdateRegion() const; | |
222 | virtual bool IsExposed(int x, int y, int w, int h) const; | |
223 | virtual bool IsExposed(const wxPoint& pt) const; | |
224 | virtual bool IsExposed(const wxRect& rect) const; | |
225 | ||
2bda0e17 KB |
226 | // Set/get the window title |
227 | virtual inline void SetTitle(const wxString& WXUNUSED(title)) {}; | |
fd3f686c | 228 | inline virtual wxString GetTitle() const { return wxString(""); }; |
2bda0e17 KB |
229 | // Most windows have the concept of a label; for frames, this is the |
230 | // title; for items, this is the label or button text. | |
fd3f686c | 231 | inline virtual wxString GetLabel() const { return GetTitle(); } |
2bda0e17 KB |
232 | |
233 | // Set/get the window name (used for resource setting in X) | |
fd3f686c | 234 | inline virtual wxString GetName() const; |
2bda0e17 KB |
235 | inline virtual void SetName(const wxString& name); |
236 | ||
237 | // Centre the window | |
debe6624 JS |
238 | virtual void Centre(int direction) ; |
239 | inline void Center(int direction = wxHORIZONTAL) { Centre(direction); } | |
2bda0e17 KB |
240 | |
241 | // Popup a menu | |
debe6624 | 242 | virtual bool PopupMenu(wxMenu *menu, int x, int y); |
2bda0e17 KB |
243 | |
244 | // Send the window a refresh event | |
1b826605 | 245 | virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL); |
2bda0e17 KB |
246 | |
247 | #if WXWIN_COMPATIBILITY | |
248 | // Set/get scroll attributes | |
debe6624 JS |
249 | virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); |
250 | virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); | |
251 | virtual int OldGetScrollRange(int orient) const; | |
252 | virtual int GetScrollPage(int orient) const; | |
2bda0e17 KB |
253 | #endif |
254 | ||
255 | // New functions that will replace the above. | |
debe6624 JS |
256 | virtual void SetScrollbar(int orient, int pos, int thumbVisible, |
257 | int range, bool refresh = TRUE); | |
2bda0e17 | 258 | |
debe6624 JS |
259 | virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE); |
260 | virtual int GetScrollPos(int orient) const; | |
261 | virtual int GetScrollRange(int orient) const; | |
262 | virtual int GetScrollThumb(int orient) const; | |
2bda0e17 | 263 | |
1b826605 | 264 | virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); |
2bda0e17 KB |
265 | |
266 | // Caret manipulation | |
debe6624 | 267 | virtual void CreateCaret(int w, int h); |
2bda0e17 | 268 | virtual void CreateCaret(const wxBitmap *bitmap); |
fd3f686c | 269 | virtual void DestroyCaret(); |
debe6624 JS |
270 | virtual void ShowCaret(bool show); |
271 | virtual void SetCaretPos(int x, int y); | |
2bda0e17 KB |
272 | virtual void GetCaretPos(int *x, int *y) const; |
273 | ||
274 | // Tell window how much it can be sized | |
debe6624 | 275 | virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); |
2bda0e17 KB |
276 | |
277 | // Set/get the window's identifier | |
278 | inline int GetId() const; | |
debe6624 | 279 | inline void SetId(int id); |
2bda0e17 KB |
280 | |
281 | // Make the window modal (all other windows unresponsive) | |
debe6624 | 282 | virtual void MakeModal(bool modal); |
2bda0e17 KB |
283 | |
284 | // Get the private handle (platform-dependent) | |
fd3f686c | 285 | inline void *GetHandle() const; |
2bda0e17 KB |
286 | |
287 | // Set/get the window's relatives | |
fd3f686c | 288 | inline wxWindow *GetParent() const; |
2bda0e17 | 289 | inline void SetParent(wxWindow *p) ; |
fd3f686c | 290 | inline wxWindow *GetGrandParent() const; |
2bda0e17 | 291 | inline wxList *GetChildren() const; |
4fabb575 JS |
292 | // Set this window to be the child of 'parent'. |
293 | // Returns FALSE it's not possible (some systems | |
294 | // won't allow it) | |
295 | virtual bool Reparent(wxWindow *parent); | |
2bda0e17 KB |
296 | |
297 | // Set/get the window's font | |
298 | virtual void SetFont(const wxFont& f); | |
fd3f686c | 299 | inline virtual wxFont *GetFont() const; |
2bda0e17 KB |
300 | |
301 | // Set/get the window's validator | |
302 | void SetValidator(const wxValidator& validator); | |
fd3f686c | 303 | inline wxValidator *GetValidator() const; |
2bda0e17 KB |
304 | |
305 | // Set/get the window's style | |
debe6624 | 306 | inline void SetWindowStyleFlag(long flag); |
fd3f686c | 307 | inline long GetWindowStyleFlag() const; |
2bda0e17 KB |
308 | |
309 | // Set/get double-clickability | |
310 | // TODO: we probably wish to get rid of this, and | |
311 | // always allow double clicks. | |
debe6624 | 312 | inline void SetDoubleClick(bool flag); |
fd3f686c | 313 | inline bool GetDoubleClick() const; |
debe6624 | 314 | inline void AllowDoubleClick(bool value) { SetDoubleClick(value); } |
2bda0e17 | 315 | |
02e8b2f9 | 316 | // Handle a control command |
2bda0e17 KB |
317 | virtual void OnCommand(wxWindow& win, wxCommandEvent& event); |
318 | ||
319 | // Set/get event handler | |
320 | inline void SetEventHandler(wxEvtHandler *handler); | |
fd3f686c | 321 | inline wxEvtHandler *GetEventHandler() const; |
2bda0e17 KB |
322 | |
323 | // Push/pop event handler (i.e. allow a chain of event handlers | |
324 | // be searched) | |
325 | void PushEventHandler(wxEvtHandler *handler) ; | |
326 | wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ; | |
327 | ||
328 | // Close the window by calling OnClose, posting a deletion | |
debe6624 | 329 | virtual bool Close(bool force = FALSE); |
2bda0e17 KB |
330 | |
331 | // Destroy the window (delayed, if a managed window) | |
fd3f686c | 332 | virtual bool Destroy() ; |
2bda0e17 KB |
333 | |
334 | // Mode for telling default OnSize members to | |
335 | // call Layout(), if not using Sizers, just top-down constraints | |
debe6624 | 336 | inline void SetAutoLayout(bool a); |
fd3f686c | 337 | inline bool GetAutoLayout() const; |
2bda0e17 KB |
338 | |
339 | // Set/get constraints | |
fd3f686c | 340 | inline wxLayoutConstraints *GetConstraints() const; |
2bda0e17 KB |
341 | void SetConstraints(wxLayoutConstraints *c); |
342 | ||
343 | // Set/get window background colour | |
344 | inline virtual void SetBackgroundColour(const wxColour& col); | |
fd3f686c | 345 | inline virtual wxColour GetBackgroundColour() const; |
2bda0e17 KB |
346 | |
347 | // Set/get window foreground colour | |
348 | inline virtual void SetForegroundColour(const wxColour& col); | |
fd3f686c | 349 | inline virtual wxColour GetForegroundColour() const; |
2bda0e17 | 350 | |
2bda0e17 KB |
351 | // For backward compatibility |
352 | inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } | |
353 | inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } | |
fd3f686c VZ |
354 | inline virtual wxFont *GetLabelFont() const { return GetFont(); }; |
355 | inline virtual wxFont *GetButtonFont() const { return GetFont(); }; | |
2bda0e17 KB |
356 | |
357 | // Get the default button, if there is one | |
fd3f686c | 358 | inline virtual wxButton *GetDefaultItem() const; |
2bda0e17 KB |
359 | inline virtual void SetDefaultItem(wxButton *but); |
360 | ||
14b72bf5 | 361 | virtual void SetAcceleratorTable(const wxAcceleratorTable& accel); |
46ccb510 | 362 | inline virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; } |
14b72bf5 | 363 | |
2bda0e17 KB |
364 | // Override to define new behaviour for default action (e.g. double clicking |
365 | // on a listbox) | |
366 | virtual void OnDefaultAction(wxControl *initiatingItem); | |
367 | ||
368 | // Resource loading | |
47d67540 | 369 | #if wxUSE_WX_RESOURCES |
2bda0e17 | 370 | virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); |
fd71308f | 371 | virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = NULL); |
2bda0e17 KB |
372 | #endif |
373 | ||
374 | // Native resource loading | |
debe6624 | 375 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); |
2bda0e17 | 376 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); |
debe6624 JS |
377 | virtual wxWindow* GetWindowChild1(wxWindowID& id); |
378 | virtual wxWindow* GetWindowChild(wxWindowID& id); | |
2bda0e17 KB |
379 | |
380 | virtual void GetTextExtent(const wxString& string, int *x, int *y, | |
381 | int *descent = NULL, | |
382 | int *externalLeading = NULL, | |
debe6624 | 383 | const wxFont *theFont = NULL, bool use16 = FALSE) const; |
2bda0e17 KB |
384 | |
385 | // Is the window retained? | |
fd3f686c | 386 | inline bool IsRetained() const; |
2bda0e17 | 387 | |
2bda0e17 | 388 | // Warp the pointer the given position |
debe6624 | 389 | virtual void WarpPointer(int x_pos, int y_pos) ; |
2bda0e17 KB |
390 | |
391 | // Clear the window | |
fd3f686c | 392 | virtual void Clear(); |
2bda0e17 KB |
393 | |
394 | // Find a window by id or name | |
debe6624 | 395 | virtual wxWindow *FindWindow(long id); |
2bda0e17 KB |
396 | virtual wxWindow *FindWindow(const wxString& name); |
397 | ||
398 | // Constraint operations | |
fd3f686c | 399 | bool Layout(); |
2bda0e17 | 400 | void SetSizer(wxSizer *sizer); // Adds sizer child to this window |
fd3f686c VZ |
401 | inline wxSizer *GetSizer() const ; |
402 | inline wxWindow *GetSizerParent() const ; | |
2bda0e17 KB |
403 | inline void SetSizerParent(wxWindow *win); |
404 | ||
405 | // Do Update UI processing for controls | |
fd3f686c | 406 | void UpdateWindowUI(); |
2bda0e17 | 407 | |
2bda0e17 KB |
408 | void OnEraseBackground(wxEraseEvent& event); |
409 | void OnChar(wxKeyEvent& event); | |
410 | void OnPaint(wxPaintEvent& event); | |
411 | void OnIdle(wxIdleEvent& event); | |
412 | ||
52476186 VZ |
413 | // Does this window want to accept keyboard focus? |
414 | virtual bool AcceptsFocus() const; | |
415 | ||
7f555861 | 416 | virtual void PrepareDC( wxDC &dc ) {}; |
2bda0e17 KB |
417 | public: |
418 | //////////////////////////////////////////////////////////////////////// | |
419 | //// IMPLEMENTATION | |
420 | ||
81d66cf3 JS |
421 | // For implementation purposes - sometimes decorations make the client area |
422 | // smaller | |
423 | virtual wxPoint GetClientAreaOrigin() const; | |
424 | ||
425 | // Makes an adjustment to the window position (for example, a frame that has | |
426 | // a toolbar that it manages itself). | |
427 | virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); | |
428 | ||
2bda0e17 KB |
429 | // Windows subclassing |
430 | void SubclassWin(WXHWND hWnd); | |
fd3f686c VZ |
431 | void UnsubclassWin(); |
432 | virtual long Default(); | |
debe6624 | 433 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
fd3f686c VZ |
434 | |
435 | // returns TRUE if the event was processed | |
436 | virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result); | |
437 | ||
debe6624 JS |
438 | virtual wxWindow *FindItem(int id) const; |
439 | virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ; | |
440 | virtual void PreDelete(WXHDC dc); // Allows system cleanup | |
2bda0e17 | 441 | // TO DO: how many of these need to be virtual? |
fd3f686c | 442 | virtual WXHWND GetHWND() const ; |
2bda0e17 KB |
443 | virtual void SetHWND(WXHWND hWnd); |
444 | ||
445 | // Make a Windows extended style from the given wxWindows window style | |
446 | virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE); | |
447 | // Determine whether 3D effects are wanted | |
448 | virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D); | |
449 | ||
450 | virtual void AddChild(wxWindow *child); // Adds reference to the child object | |
451 | virtual void RemoveChild(wxWindow *child); // Removes reference to child | |
452 | // (but doesn't delete the child object) | |
fd3f686c | 453 | virtual void DestroyChildren(); // Removes and destroys all children |
2bda0e17 | 454 | |
fd3f686c | 455 | inline bool IsBeingDeleted(); |
2bda0e17 KB |
456 | |
457 | // MSW only: TRUE if this control is part of the main control | |
458 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
459 | ||
460 | // Constraint implementation | |
461 | void UnsetConstraints(wxLayoutConstraints *c); | |
fd3f686c | 462 | inline wxList *GetConstraintsInvolvedIn() const ; |
2bda0e17 KB |
463 | // Back-pointer to other windows we're involved with, so if we delete |
464 | // this window, we must delete any constraints we're involved with. | |
465 | void AddConstraintReference(wxWindow *otherWin); | |
466 | void RemoveConstraintReference(wxWindow *otherWin); | |
fd3f686c | 467 | void DeleteRelatedConstraints(); |
2bda0e17 | 468 | |
fd3f686c | 469 | virtual void ResetConstraints(); |
debe6624 | 470 | virtual void SetConstraintSizes(bool recurse = TRUE); |
2bda0e17 KB |
471 | virtual bool LayoutPhase1(int *noChanges); |
472 | virtual bool LayoutPhase2(int *noChanges); | |
debe6624 | 473 | virtual bool DoPhase(int); |
2bda0e17 KB |
474 | // Transforms from sizer coordinate space to actual |
475 | // parent coordinate space | |
476 | virtual void TransformSizerToActual(int *x, int *y) const ; | |
477 | ||
478 | // Set size with transformation to actual coordinates if nec. | |
debe6624 JS |
479 | virtual void SizerSetSize(int x, int y, int w, int h); |
480 | virtual void SizerMove(int x, int y); | |
2bda0e17 KB |
481 | |
482 | // Only set/get the size/position of the constraint (if any) | |
debe6624 JS |
483 | virtual void SetSizeConstraint(int x, int y, int w, int h); |
484 | virtual void MoveConstraint(int x, int y); | |
2bda0e17 KB |
485 | virtual void GetSizeConstraint(int *w, int *h) const ; |
486 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
487 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
488 | ||
fd71308f JS |
489 | // Dialog units translations. Implemented in wincmn.cpp. |
490 | wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; | |
491 | wxPoint ConvertDialogToPixels(const wxPoint& pt) ; | |
492 | inline wxSize ConvertPixelsToDialog(const wxSize& sz) | |
493 | { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
494 | inline wxSize ConvertDialogToPixels(const wxSize& sz) | |
495 | { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
496 | ||
debe6624 | 497 | wxObject *GetChild(int number) const ; |
2bda0e17 | 498 | |
debe6624 JS |
499 | void MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, |
500 | int x, int y, int width, int height, | |
501 | WXDWORD style, const char *dialog_template = NULL, | |
502 | WXDWORD exendedStyle = 0); | |
2bda0e17 KB |
503 | |
504 | // Actually defined in wx_canvs.cc since requires wxCanvas declaration | |
505 | virtual void MSWDeviceToLogical(float *x, float *y) const ; | |
506 | ||
507 | // Create an appropriate wxWindow from a HWND | |
508 | virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); | |
509 | ||
510 | // Make sure the window style reflects the HWND style (roughly) | |
fd3f686c | 511 | virtual void AdoptAttributesFromHWND(); |
2bda0e17 KB |
512 | |
513 | // Setup background and foreground colours correctly | |
fd3f686c | 514 | virtual void SetupColours(); |
2bda0e17 | 515 | |
a02eb1d2 VZ |
516 | // Saves the last message information before calling base version |
517 | virtual bool ProcessEvent(wxEvent& event); | |
518 | ||
2bda0e17 KB |
519 | // Handlers |
520 | virtual void MSWOnCreate(WXLPCREATESTRUCT cs); | |
fd3f686c VZ |
521 | virtual bool MSWOnPaint(); |
522 | virtual WXHICON MSWOnQueryDragIcon() { return 0; } | |
debe6624 | 523 | virtual void MSWOnSize(int x, int y, WXUINT flag); |
2bda0e17 | 524 | virtual void MSWOnWindowPosChanging(void *lpPos); |
debe6624 JS |
525 | virtual void MSWOnHScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); |
526 | virtual void MSWOnVScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); | |
527 | virtual bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
2bda0e17 | 528 | virtual long MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam); |
fd3f686c | 529 | virtual long MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam); |
debe6624 JS |
530 | virtual WXHBRUSH MSWOnCtlColor(WXHDC dc, WXHWND pWnd, WXUINT nCtlColor, |
531 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
532 | virtual bool MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
f7bd2698 JS |
533 | virtual long MSWOnPaletteChanged(WXHWND hWndPalChange); |
534 | virtual long MSWOnQueryNewPalette(); | |
debe6624 JS |
535 | virtual bool MSWOnEraseBkgnd(WXHDC pDC); |
536 | virtual void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu); | |
537 | virtual void MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem); | |
fd3f686c | 538 | virtual bool MSWOnClose(); |
387a3b02 JS |
539 | // Return TRUE to end session, FALSE to veto end session. |
540 | virtual bool MSWOnQueryEndSession(long logOff); | |
541 | virtual bool MSWOnEndSession(bool endSession, long logOff); | |
fd3f686c | 542 | virtual bool MSWOnDestroy(); |
debe6624 JS |
543 | virtual bool MSWOnSetFocus(WXHWND wnd); |
544 | virtual bool MSWOnKillFocus(WXHWND wnd); | |
545 | virtual void MSWOnDropFiles(WXWPARAM wParam); | |
2bda0e17 KB |
546 | virtual bool MSWOnInitDialog(WXHWND hWndFocus); |
547 | virtual void MSWOnShow(bool show, int status); | |
548 | ||
549 | // TODO: rationalise these functions into 1 or 2 which take the | |
550 | // event type as argument. | |
debe6624 JS |
551 | virtual void MSWOnLButtonDown(int x, int y, WXUINT flags); |
552 | virtual void MSWOnLButtonUp(int x, int y, WXUINT flags); | |
553 | virtual void MSWOnLButtonDClick(int x, int y, WXUINT flags); | |
2bda0e17 | 554 | |
debe6624 JS |
555 | virtual void MSWOnMButtonDown(int x, int y, WXUINT flags); |
556 | virtual void MSWOnMButtonUp(int x, int y, WXUINT flags); | |
557 | virtual void MSWOnMButtonDClick(int x, int y, WXUINT flags); | |
2bda0e17 | 558 | |
debe6624 JS |
559 | virtual void MSWOnRButtonDown(int x, int y, WXUINT flags); |
560 | virtual void MSWOnRButtonUp(int x, int y, WXUINT flags); | |
561 | virtual void MSWOnRButtonDClick(int x, int y, WXUINT flags); | |
2bda0e17 | 562 | |
debe6624 JS |
563 | virtual void MSWOnMouseMove(int x, int y, WXUINT flags); |
564 | virtual void MSWOnMouseEnter(int x, int y, WXUINT flags); | |
565 | virtual void MSWOnMouseLeave(int x, int y, WXUINT flags); | |
2bda0e17 | 566 | |
debe6624 | 567 | virtual void MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); |
2bda0e17 | 568 | |
debe6624 JS |
569 | virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); |
570 | virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); | |
2bda0e17 | 571 | |
debe6624 JS |
572 | virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); |
573 | virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); | |
2bda0e17 | 574 | |
debe6624 JS |
575 | virtual void MSWOnJoyDown(int joystick, int x, int y, WXUINT flags); |
576 | virtual void MSWOnJoyUp(int joystick, int x, int y, WXUINT flags); | |
577 | virtual void MSWOnJoyMove(int joystick, int x, int y, WXUINT flags); | |
578 | virtual void MSWOnJoyZMove(int joystick, int z, WXUINT flags); | |
2bda0e17 | 579 | |
52476186 VZ |
580 | virtual long MSWGetDlgCode(); |
581 | ||
2bda0e17 KB |
582 | // Window procedure |
583 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
584 | ||
585 | // Calls an appropriate default window procedure | |
586 | virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
587 | virtual bool MSWProcessMessage(WXMSG* pMsg); | |
57a7b7c1 | 588 | virtual bool MSWTranslateMessage(WXMSG* pMsg); |
fd3f686c | 589 | virtual void MSWDestroyWindow(); |
2bda0e17 KB |
590 | |
591 | // Detach "Window" menu from menu bar so it doesn't get deleted | |
fd3f686c | 592 | void MSWDetachWindowMenu(); |
2bda0e17 KB |
593 | |
594 | inline WXFARPROC MSWGetOldWndProc() const; | |
debe6624 | 595 | inline void MSWSetOldWndProc(WXFARPROC proc); |
2bda0e17 KB |
596 | |
597 | // Define for each class of dialog and control | |
debe6624 | 598 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2bda0e17 KB |
599 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
600 | ||
debe6624 | 601 | inline void SetShowing(bool show); |
fd3f686c VZ |
602 | inline bool IsUserEnabled() const; |
603 | inline bool GetUseCtl3D() const ; | |
604 | inline bool GetTransparentBackground() const ; | |
2bda0e17 KB |
605 | |
606 | // Responds to colour changes: passes event on to children. | |
607 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
608 | ||
609 | // Transfers data to any child controls | |
610 | void OnInitDialog(wxInitDialogEvent& event); | |
611 | ||
612 | // Sends an OnInitDialog event, which in turns transfers data to | |
613 | // to the window via validators. | |
fd3f686c | 614 | virtual void InitDialog(); |
2bda0e17 KB |
615 | |
616 | //////////////////////////////////////////////////////////////////////// | |
617 | //// PROTECTED DATA | |
618 | protected: | |
14b72bf5 | 619 | wxAcceleratorTable m_acceleratorTable; |
2bda0e17 KB |
620 | int m_windowId; |
621 | long m_windowStyle; // Store the window's style | |
622 | wxEvtHandler * m_windowEventHandler; // Usually is 'this' | |
623 | wxLayoutConstraints * m_constraints; // Constraints for this window | |
624 | wxList * m_constraintsInvolvedIn; // List of constraints we're involved in | |
625 | wxSizer * m_windowSizer; // Window's top-level sizer (if any) | |
626 | wxWindow * m_sizerParent; // Window's parent sizer (if any) | |
627 | bool m_autoLayout; // Whether to call Layout() in OnSize | |
628 | wxWindow * m_windowParent; // Each window always knows its parent | |
629 | wxValidator * m_windowValidator; | |
630 | // Old window proc, for subclassed controls | |
631 | WXFARPROC m_oldWndProc; | |
632 | bool m_useCtl3D; // Using CTL3D for this control | |
633 | ||
634 | bool m_inOnSize; // Protection against OnSize reentry | |
bbcdf8bc | 635 | #ifndef _WX_WIN32__ |
2bda0e17 KB |
636 | // Pointer to global memory, for EDIT controls that need |
637 | // special treatment to reduce USER area consumption. | |
638 | WXHGLOBAL m_globalHandle; | |
639 | #endif | |
640 | ||
641 | bool m_winEnabled; | |
642 | int m_minSizeX; | |
643 | int m_minSizeY; | |
644 | int m_maxSizeX; | |
645 | int m_maxSizeY; | |
646 | ||
647 | // Caret data | |
648 | int m_caretWidth; | |
649 | int m_caretHeight; | |
650 | bool m_caretEnabled; | |
651 | bool m_caretShown; | |
2bda0e17 KB |
652 | wxFont m_windowFont; // Window's font |
653 | bool m_isShown; | |
654 | bool m_doubleClickAllowed ; | |
655 | wxCursor m_windowCursor; // Window's cursor | |
656 | bool m_winCaptured; | |
657 | wxString m_windowName; // Window name | |
658 | ||
47d67540 | 659 | #if wxUSE_EXTENDED_STATICS |
2bda0e17 KB |
660 | wxList m_staticItems; |
661 | #endif | |
662 | ||
663 | wxButton * m_defaultItem; | |
2bda0e17 | 664 | wxColour m_backgroundColour ; |
2bda0e17 | 665 | wxColour m_foregroundColour ; |
2bda0e17 KB |
666 | bool m_backgroundTransparent; |
667 | ||
2bda0e17 KB |
668 | int m_xThumbSize; |
669 | int m_yThumbSize; | |
670 | ||
671 | float m_lastXPos; | |
672 | float m_lastYPos; | |
673 | int m_lastEvent; | |
674 | ||
675 | bool m_mouseInWindow; | |
676 | ||
47d67540 | 677 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
678 | wxDropTarget *m_pDropTarget; // the current drop target or NULL |
679 | #endif //USE_DRAG_AND_DROP | |
680 | ||
681 | public: | |
682 | WXHWND m_hWnd; // MS Windows window handle | |
683 | WXUINT m_lastMsg; | |
684 | WXWPARAM m_lastWParam; | |
685 | WXLPARAM m_lastLParam; | |
81d66cf3 JS |
686 | |
687 | wxRegion m_updateRegion; | |
688 | /* | |
1b826605 | 689 | wxRect m_updateRect; // Bounding box for screen damage area |
2bda0e17 KB |
690 | #ifdef __WIN32__ |
691 | WXHRGN m_updateRgn; // NT allows access to the rectangle list | |
692 | #endif | |
81d66cf3 JS |
693 | */ |
694 | ||
57a7b7c1 | 695 | // WXHANDLE m_acceleratorTable; |
2bda0e17 KB |
696 | WXHMENU m_hMenu; // Menu, if any |
697 | wxList * m_children; // Window's children | |
698 | int m_returnCode; | |
699 | bool m_isBeingDeleted; // Fudge because can't access parent | |
700 | // when being deleted | |
701 | ||
fd3f686c VZ |
702 | private: |
703 | // common part of all ctors | |
704 | void Init(); | |
705 | ||
706 | DECLARE_EVENT_TABLE() | |
2bda0e17 KB |
707 | }; |
708 | ||
709 | //////////////////////////////////////////////////////////////////////// | |
710 | //// INLINES | |
711 | ||
fd3f686c | 712 | inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); } |
2bda0e17 | 713 | inline int wxWindow::GetId() const { return m_windowId; } |
debe6624 | 714 | inline void wxWindow::SetId(int id) { m_windowId = id; } |
fd3f686c | 715 | inline wxWindow *wxWindow::GetParent() const { return m_windowParent; } |
2bda0e17 | 716 | inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; } |
fd3f686c | 717 | inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); } |
2bda0e17 | 718 | inline wxList *wxWindow::GetChildren() const { return m_children; } |
fd3f686c VZ |
719 | inline wxFont *wxWindow::GetFont() const { return (wxFont *) & m_windowFont; } |
720 | inline wxString wxWindow::GetName() const { return m_windowName; } | |
2bda0e17 | 721 | inline void wxWindow::SetName(const wxString& name) { m_windowName = name; } |
fd3f686c | 722 | inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; } |
debe6624 JS |
723 | inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; } |
724 | inline void wxWindow::SetDoubleClick(bool flag) { m_doubleClickAllowed = flag; } | |
fd3f686c | 725 | inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed; } |
2bda0e17 | 726 | inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; } |
fd3f686c | 727 | inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; } |
debe6624 | 728 | inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; } |
fd3f686c VZ |
729 | inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; } |
730 | inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; } | |
2bda0e17 | 731 | inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }; |
fd3f686c | 732 | inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; |
2bda0e17 | 733 | inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; |
fd3f686c | 734 | inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; |
2bda0e17 | 735 | |
fd3f686c | 736 | inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } |
2bda0e17 | 737 | inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } |
fd3f686c | 738 | inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); } |
debe6624 | 739 | |
debe6624 | 740 | inline void wxWindow::SetShowing(bool show) { m_isShown = show; } |
fd3f686c VZ |
741 | inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; } |
742 | inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; } | |
743 | inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; } | |
2bda0e17 KB |
744 | inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; } |
745 | inline WXFARPROC wxWindow::MSWGetOldWndProc() const { return m_oldWndProc; } | |
debe6624 | 746 | inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } |
fd3f686c VZ |
747 | inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; } |
748 | inline bool wxWindow::IsUserEnabled() const { return m_winEnabled; } | |
749 | inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D; } | |
750 | inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent; } | |
2bda0e17 | 751 | inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; } |
fd3f686c VZ |
752 | inline int wxWindow::GetReturnCode() { return m_returnCode; } |
753 | inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted; } | |
2bda0e17 KB |
754 | |
755 | // Window specific (so far) | |
fd3f686c | 756 | WXDLLEXPORT wxWindow* wxGetActiveWindow(); |
2bda0e17 | 757 | |
2bda0e17 KB |
758 | WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows; |
759 | ||
184b5d99 JS |
760 | WXDLLEXPORT int wxCharCodeMSWToWX(int keySym); |
761 | WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual); | |
2bda0e17 KB |
762 | |
763 | // Allocates control ids | |
fd3f686c | 764 | WXDLLEXPORT int NewControlId(); |
2bda0e17 KB |
765 | |
766 | #endif | |
bbcdf8bc | 767 | // _WX_WINDOW_H_ |