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