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