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