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