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