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