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