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