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