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