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