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