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