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