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