]>
Commit | Line | Data |
---|---|---|
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 | ||
30 | #define wxKEY_SHIFT 1 | |
31 | #define wxKEY_CTRL 2 | |
32 | ||
33 | /* | |
34 | * Base class for frame, panel, canvas, panel items, dialog box. | |
35 | * | |
36 | */ | |
37 | ||
38 | /* | |
39 | * Event handler: windows have themselves as their event handlers | |
40 | * by default, but their event handlers could be set to another | |
41 | * object entirely. This separation can reduce the amount of | |
42 | * derivation required, and allow alteration of a window's functionality | |
43 | * (e.g. by a resource editor that temporarily switches event handlers). | |
44 | */ | |
45 | ||
46 | class WXDLLEXPORT wxWindow; | |
47 | class WXDLLEXPORT wxEvent; | |
48 | class WXDLLEXPORT wxCommandEvent; | |
49 | class WXDLLEXPORT wxKeyEvent; | |
50 | class WXDLLEXPORT wxControl; | |
51 | class WXDLLEXPORT wxCursor; | |
52 | class WXDLLEXPORT wxColourMap; | |
53 | class WXDLLEXPORT wxFont; | |
54 | class WXDLLEXPORT wxMenu; | |
55 | class WXDLLEXPORT wxRectangle; | |
56 | class WXDLLEXPORT wxBitmap; | |
57 | class WXDLLEXPORT wxSizer; | |
58 | class WXDLLEXPORT wxList; | |
59 | class WXDLLEXPORT wxLayoutConstraints; | |
60 | class WXDLLEXPORT wxMouseEvent; | |
61 | class WXDLLEXPORT wxButton; | |
62 | class WXDLLEXPORT wxColour; | |
63 | class WXDLLEXPORT wxBrush; | |
64 | class WXDLLEXPORT wxPen; | |
65 | class WXDLLEXPORT wxIcon; | |
66 | class WXDLLEXPORT wxDC; | |
67 | class WXDLLEXPORT wxValidator; | |
68 | ||
69 | #if USE_DRAG_AND_DROP | |
70 | class WXDLLEXPORT wxDropTarget; | |
71 | #endif | |
72 | ||
73 | #if USE_WX_RESOURCES | |
74 | class WXDLLEXPORT wxResourceTable; | |
75 | class WXDLLEXPORT wxItemResource; | |
76 | #endif | |
77 | ||
78 | WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; | |
79 | ||
80 | WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; | |
81 | WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; | |
82 | ||
83 | class WXDLLEXPORT wxWindow: public wxEvtHandler | |
84 | { | |
85 | DECLARE_ABSTRACT_CLASS(wxWindow) | |
86 | ||
87 | friend class wxDC; | |
88 | friend class wxPaintDC; | |
89 | ||
90 | public: | |
91 | wxWindow(void); | |
92 | inline wxWindow(wxWindow *parent, wxWindowID id, | |
93 | const wxPoint& pos = wxDefaultPosition, | |
94 | const wxSize& size = wxDefaultSize, | |
95 | long style = 0, | |
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 | ||
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(void); | |
112 | ||
113 | // Show or hide the window | |
114 | virtual bool Show(bool show); | |
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 | |
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(void); | |
187 | ||
188 | // Capture/release mouse | |
189 | virtual void CaptureMouse(void); | |
190 | virtual void ReleaseMouse(void); | |
191 | ||
192 | // Enable or disable the window | |
193 | virtual void Enable(bool enable); | |
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 | |
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(void) 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(void) const { return GetTitle(); } | |
217 | ||
218 | // Set/get the window name (used for resource setting in X) | |
219 | inline virtual wxString GetName(void) 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 wxRectangle *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 wxRectangle *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(void); | |
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(void) const; | |
271 | ||
272 | // Set/get the window's relatives | |
273 | inline wxWindow *GetParent(void) const; | |
274 | inline void SetParent(wxWindow *p) ; | |
275 | inline wxWindow *GetGrandParent(void) 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(void) const; | |
281 | ||
282 | // Set/get the window's validator | |
283 | void SetValidator(const wxValidator& validator); | |
284 | inline wxValidator *GetValidator(void) const; | |
285 | ||
286 | // Set/get the window's style | |
287 | inline void SetWindowStyleFlag(long flag); | |
288 | inline long GetWindowStyleFlag(void) 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(void) const; | |
295 | inline void AllowDoubleClick(bool value) { SetDoubleClick(value); } | |
296 | ||
297 | // Old way to 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(void) 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(void) ; | |
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(void) const; | |
319 | ||
320 | // Set/get constraints | |
321 | inline wxLayoutConstraints *GetConstraints(void) 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(void) const; | |
327 | ||
328 | // Set/get window foreground colour | |
329 | inline virtual void SetForegroundColour(const wxColour& col); | |
330 | inline virtual wxColour GetForegroundColour(void) const; | |
331 | ||
332 | // TODO: are these really necessary??? | |
333 | // Set/get window default background colour (for children to inherit) | |
334 | inline virtual void SetDefaultBackgroundColour(const wxColour& col); | |
335 | inline virtual wxColour GetDefaultBackgroundColour(void) const; | |
336 | ||
337 | // Set/get window default foreground colour (for children to inherit) | |
338 | inline virtual void SetDefaultForegroundColour(const wxColour& col); | |
339 | inline virtual wxColour GetDefaultForegroundColour(void) const; | |
340 | ||
341 | // For backward compatibility | |
342 | inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } | |
343 | inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } | |
344 | inline virtual wxFont *GetLabelFont(void) const { return GetFont(); }; | |
345 | inline virtual wxFont *GetButtonFont(void) const { return GetFont(); }; | |
346 | ||
347 | // Get the default button, if there is one | |
348 | inline virtual wxButton *GetDefaultItem(void) const; | |
349 | inline virtual void SetDefaultItem(wxButton *but); | |
350 | ||
351 | // Override to define new behaviour for default action (e.g. double clicking | |
352 | // on a listbox) | |
353 | virtual void OnDefaultAction(wxControl *initiatingItem); | |
354 | ||
355 | // Resource loading | |
356 | #if USE_WX_RESOURCES | |
357 | virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); | |
358 | virtual wxControl *CreateItem(const wxItemResource *childResource, const wxResourceTable *table = NULL); | |
359 | #endif | |
360 | ||
361 | // Native resource loading | |
362 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); | |
363 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); | |
364 | virtual wxWindow* GetWindowChild1(wxWindowID& id); | |
365 | virtual wxWindow* GetWindowChild(wxWindowID& id); | |
366 | ||
367 | virtual void GetTextExtent(const wxString& string, int *x, int *y, | |
368 | int *descent = NULL, | |
369 | int *externalLeading = NULL, | |
370 | const wxFont *theFont = NULL, bool use16 = FALSE) const; | |
371 | ||
372 | // Is the window retained? | |
373 | inline bool IsRetained(void) const; | |
374 | ||
375 | // Warp the pointer the given position | |
376 | virtual void WarpPointer(int x_pos, int y_pos) ; | |
377 | ||
378 | // Clear the window | |
379 | virtual void Clear(void); | |
380 | ||
381 | // Find a window by id or name | |
382 | virtual wxWindow *FindWindow(long id); | |
383 | virtual wxWindow *FindWindow(const wxString& name); | |
384 | ||
385 | // Constraint operations | |
386 | bool Layout(void); | |
387 | void SetSizer(wxSizer *sizer); // Adds sizer child to this window | |
388 | inline wxSizer *GetSizer(void) const ; | |
389 | inline wxWindow *GetSizerParent(void) const ; | |
390 | inline void SetSizerParent(wxWindow *win); | |
391 | ||
392 | // Do Update UI processing for controls | |
393 | void UpdateWindowUI(void); | |
394 | ||
395 | void OnEraseBackground(wxEraseEvent& event); | |
396 | void OnChar(wxKeyEvent& event); | |
397 | void OnPaint(wxPaintEvent& event); | |
398 | void OnIdle(wxIdleEvent& event); | |
399 | ||
400 | // Does this window want to accept keyboard focus? | |
401 | virtual bool AcceptsFocus() const; | |
402 | ||
403 | public: | |
404 | //////////////////////////////////////////////////////////////////////// | |
405 | //// IMPLEMENTATION | |
406 | ||
407 | // For implementation purposes - sometimes decorations make the client area | |
408 | // smaller | |
409 | virtual wxPoint GetClientAreaOrigin() const; | |
410 | ||
411 | // Makes an adjustment to the window position (for example, a frame that has | |
412 | // a toolbar that it manages itself). | |
413 | virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); | |
414 | ||
415 | // Windows subclassing | |
416 | void SubclassWin(WXHWND hWnd); | |
417 | void UnsubclassWin(void); | |
418 | virtual long Default(void); | |
419 | virtual bool MSWCommand(WXUINT param, WXWORD id); | |
420 | virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam); | |
421 | virtual wxWindow *FindItem(int id) const; | |
422 | virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ; | |
423 | virtual void PreDelete(WXHDC dc); // Allows system cleanup | |
424 | // TO DO: how many of these need to be virtual? | |
425 | virtual WXHWND GetHWND(void) const ; | |
426 | virtual void SetHWND(WXHWND hWnd); | |
427 | ||
428 | // Make a Windows extended style from the given wxWindows window style | |
429 | virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE); | |
430 | // Determine whether 3D effects are wanted | |
431 | virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D); | |
432 | ||
433 | virtual void AddChild(wxWindow *child); // Adds reference to the child object | |
434 | virtual void RemoveChild(wxWindow *child); // Removes reference to child | |
435 | // (but doesn't delete the child object) | |
436 | virtual void DestroyChildren(void); // Removes and destroys all children | |
437 | ||
438 | inline bool IsBeingDeleted(void); | |
439 | ||
440 | // MSW only: TRUE if this control is part of the main control | |
441 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
442 | ||
443 | // Constraint implementation | |
444 | void UnsetConstraints(wxLayoutConstraints *c); | |
445 | inline wxList *GetConstraintsInvolvedIn(void) const ; | |
446 | // Back-pointer to other windows we're involved with, so if we delete | |
447 | // this window, we must delete any constraints we're involved with. | |
448 | void AddConstraintReference(wxWindow *otherWin); | |
449 | void RemoveConstraintReference(wxWindow *otherWin); | |
450 | void DeleteRelatedConstraints(void); | |
451 | ||
452 | virtual void ResetConstraints(void); | |
453 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
454 | virtual bool LayoutPhase1(int *noChanges); | |
455 | virtual bool LayoutPhase2(int *noChanges); | |
456 | virtual bool DoPhase(int); | |
457 | // Transforms from sizer coordinate space to actual | |
458 | // parent coordinate space | |
459 | virtual void TransformSizerToActual(int *x, int *y) const ; | |
460 | ||
461 | // Set size with transformation to actual coordinates if nec. | |
462 | virtual void SizerSetSize(int x, int y, int w, int h); | |
463 | virtual void SizerMove(int x, int y); | |
464 | ||
465 | // Only set/get the size/position of the constraint (if any) | |
466 | virtual void SetSizeConstraint(int x, int y, int w, int h); | |
467 | virtual void MoveConstraint(int x, int y); | |
468 | virtual void GetSizeConstraint(int *w, int *h) const ; | |
469 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
470 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
471 | ||
472 | wxObject *GetChild(int number) const ; | |
473 | ||
474 | void MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, | |
475 | int x, int y, int width, int height, | |
476 | WXDWORD style, const char *dialog_template = NULL, | |
477 | WXDWORD exendedStyle = 0); | |
478 | ||
479 | // Actually defined in wx_canvs.cc since requires wxCanvas declaration | |
480 | virtual void MSWDeviceToLogical(float *x, float *y) const ; | |
481 | ||
482 | // Create an appropriate wxWindow from a HWND | |
483 | virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); | |
484 | ||
485 | // Make sure the window style reflects the HWND style (roughly) | |
486 | virtual void AdoptAttributesFromHWND(void); | |
487 | ||
488 | // Setup background and foreground colours correctly | |
489 | virtual void SetupColours(void); | |
490 | ||
491 | // Saves the last message information before calling base version | |
492 | virtual bool ProcessEvent(wxEvent& event); | |
493 | ||
494 | // Handlers | |
495 | virtual void MSWOnCreate(WXLPCREATESTRUCT cs); | |
496 | virtual bool MSWOnPaint(void); | |
497 | virtual WXHICON MSWOnQueryDragIcon(void) { return 0; } | |
498 | virtual void MSWOnSize(int x, int y, WXUINT flag); | |
499 | virtual void MSWOnWindowPosChanging(void *lpPos); | |
500 | virtual void MSWOnHScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); | |
501 | virtual void MSWOnVScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); | |
502 | virtual bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
503 | virtual long MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam); | |
504 | virtual bool MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam); | |
505 | virtual WXHBRUSH MSWOnCtlColor(WXHDC dc, WXHWND pWnd, WXUINT nCtlColor, | |
506 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
507 | virtual bool MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
508 | virtual long MSWOnPaletteChanged(WXHWND hWndPalChange); | |
509 | virtual long MSWOnQueryNewPalette(); | |
510 | virtual bool MSWOnEraseBkgnd(WXHDC pDC); | |
511 | virtual void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu); | |
512 | virtual void MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem); | |
513 | virtual bool MSWOnClose(void); | |
514 | virtual bool MSWOnDestroy(void); | |
515 | virtual bool MSWOnSetFocus(WXHWND wnd); | |
516 | virtual bool MSWOnKillFocus(WXHWND wnd); | |
517 | virtual void MSWOnDropFiles(WXWPARAM wParam); | |
518 | virtual bool MSWOnInitDialog(WXHWND hWndFocus); | |
519 | virtual void MSWOnShow(bool show, int status); | |
520 | ||
521 | // TODO: rationalise these functions into 1 or 2 which take the | |
522 | // event type as argument. | |
523 | virtual void MSWOnLButtonDown(int x, int y, WXUINT flags); | |
524 | virtual void MSWOnLButtonUp(int x, int y, WXUINT flags); | |
525 | virtual void MSWOnLButtonDClick(int x, int y, WXUINT flags); | |
526 | ||
527 | virtual void MSWOnMButtonDown(int x, int y, WXUINT flags); | |
528 | virtual void MSWOnMButtonUp(int x, int y, WXUINT flags); | |
529 | virtual void MSWOnMButtonDClick(int x, int y, WXUINT flags); | |
530 | ||
531 | virtual void MSWOnRButtonDown(int x, int y, WXUINT flags); | |
532 | virtual void MSWOnRButtonUp(int x, int y, WXUINT flags); | |
533 | virtual void MSWOnRButtonDClick(int x, int y, WXUINT flags); | |
534 | ||
535 | virtual void MSWOnMouseMove(int x, int y, WXUINT flags); | |
536 | virtual void MSWOnMouseEnter(int x, int y, WXUINT flags); | |
537 | virtual void MSWOnMouseLeave(int x, int y, WXUINT flags); | |
538 | ||
539 | virtual void MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); | |
540 | ||
541 | virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); | |
542 | virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); | |
543 | ||
544 | virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); | |
545 | virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); | |
546 | ||
547 | virtual void MSWOnJoyDown(int joystick, int x, int y, WXUINT flags); | |
548 | virtual void MSWOnJoyUp(int joystick, int x, int y, WXUINT flags); | |
549 | virtual void MSWOnJoyMove(int joystick, int x, int y, WXUINT flags); | |
550 | virtual void MSWOnJoyZMove(int joystick, int z, WXUINT flags); | |
551 | ||
552 | virtual long MSWGetDlgCode(); | |
553 | ||
554 | // Window procedure | |
555 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
556 | ||
557 | // Calls an appropriate default window procedure | |
558 | virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
559 | virtual bool MSWProcessMessage(WXMSG* pMsg); | |
560 | virtual bool MSWTranslateMessage(WXMSG* pMsg); | |
561 | virtual void MSWDestroyWindow(void); | |
562 | ||
563 | // Detach "Window" menu from menu bar so it doesn't get deleted | |
564 | void MSWDetachWindowMenu(void); | |
565 | ||
566 | inline WXFARPROC MSWGetOldWndProc() const; | |
567 | inline void MSWSetOldWndProc(WXFARPROC proc); | |
568 | ||
569 | // Define for each class of dialog and control | |
570 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
571 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
572 | ||
573 | inline void SetShowing(bool show); | |
574 | inline bool IsUserEnabled(void) const; | |
575 | inline bool GetUseCtl3D(void) const ; | |
576 | inline bool GetTransparentBackground(void) const ; | |
577 | ||
578 | // Responds to colour changes: passes event on to children. | |
579 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
580 | ||
581 | // Transfers data to any child controls | |
582 | void OnInitDialog(wxInitDialogEvent& event); | |
583 | ||
584 | // Sends an OnInitDialog event, which in turns transfers data to | |
585 | // to the window via validators. | |
586 | virtual void InitDialog(void); | |
587 | ||
588 | //////////////////////////////////////////////////////////////////////// | |
589 | //// PROTECTED DATA | |
590 | protected: | |
591 | int m_windowId; | |
592 | long m_windowStyle; // Store the window's style | |
593 | wxEvtHandler * m_windowEventHandler; // Usually is 'this' | |
594 | wxLayoutConstraints * m_constraints; // Constraints for this window | |
595 | wxList * m_constraintsInvolvedIn; // List of constraints we're involved in | |
596 | wxSizer * m_windowSizer; // Window's top-level sizer (if any) | |
597 | wxWindow * m_sizerParent; // Window's parent sizer (if any) | |
598 | bool m_autoLayout; // Whether to call Layout() in OnSize | |
599 | wxWindow * m_windowParent; // Each window always knows its parent | |
600 | wxValidator * m_windowValidator; | |
601 | // Old window proc, for subclassed controls | |
602 | WXFARPROC m_oldWndProc; | |
603 | bool m_useCtl3D; // Using CTL3D for this control | |
604 | ||
605 | bool m_inOnSize; // Protection against OnSize reentry | |
606 | #ifndef _WX_WIN32__ | |
607 | // Pointer to global memory, for EDIT controls that need | |
608 | // special treatment to reduce USER area consumption. | |
609 | WXHGLOBAL m_globalHandle; | |
610 | #endif | |
611 | ||
612 | bool m_winEnabled; | |
613 | int m_minSizeX; | |
614 | int m_minSizeY; | |
615 | int m_maxSizeX; | |
616 | int m_maxSizeY; | |
617 | ||
618 | // Caret data | |
619 | int m_caretWidth; | |
620 | int m_caretHeight; | |
621 | bool m_caretEnabled; | |
622 | bool m_caretShown; | |
623 | wxFont m_windowFont; // Window's font | |
624 | bool m_isShown; | |
625 | bool m_doubleClickAllowed ; | |
626 | wxCursor m_windowCursor; // Window's cursor | |
627 | bool m_winCaptured; | |
628 | wxString m_windowName; // Window name | |
629 | ||
630 | #if USE_EXTENDED_STATICS | |
631 | wxList m_staticItems; | |
632 | #endif | |
633 | ||
634 | wxButton * m_defaultItem; | |
635 | ||
636 | wxColour m_backgroundColour ; | |
637 | wxColour m_defaultBackgroundColour; | |
638 | ||
639 | wxColour m_foregroundColour ; | |
640 | wxColour m_defaultForegroundColour; | |
641 | ||
642 | bool m_backgroundTransparent; | |
643 | ||
644 | int m_xThumbSize; | |
645 | int m_yThumbSize; | |
646 | ||
647 | float m_lastXPos; | |
648 | float m_lastYPos; | |
649 | int m_lastEvent; | |
650 | ||
651 | bool m_mouseInWindow; | |
652 | ||
653 | #if USE_DRAG_AND_DROP | |
654 | wxDropTarget *m_pDropTarget; // the current drop target or NULL | |
655 | #endif //USE_DRAG_AND_DROP | |
656 | ||
657 | public: | |
658 | WXHWND m_hWnd; // MS Windows window handle | |
659 | WXUINT m_lastMsg; | |
660 | WXWPARAM m_lastWParam; | |
661 | WXLPARAM m_lastLParam; | |
662 | ||
663 | wxRegion m_updateRegion; | |
664 | /* | |
665 | wxRectangle m_updateRect; // Bounding box for screen damage area | |
666 | #ifdef __WIN32__ | |
667 | WXHRGN m_updateRgn; // NT allows access to the rectangle list | |
668 | #endif | |
669 | */ | |
670 | ||
671 | // WXHANDLE m_acceleratorTable; | |
672 | WXHMENU m_hMenu; // Menu, if any | |
673 | wxList * m_children; // Window's children | |
674 | int m_returnCode; | |
675 | bool m_isBeingDeleted; // Fudge because can't access parent | |
676 | // when being deleted | |
677 | ||
678 | DECLARE_EVENT_TABLE() | |
679 | }; | |
680 | ||
681 | //////////////////////////////////////////////////////////////////////// | |
682 | //// INLINES | |
683 | ||
684 | inline void *wxWindow::GetHandle(void) const { return (void *)GetHWND(); } | |
685 | inline int wxWindow::GetId() const { return m_windowId; } | |
686 | inline void wxWindow::SetId(int id) { m_windowId = id; } | |
687 | inline wxWindow *wxWindow::GetParent(void) const { return m_windowParent; } | |
688 | inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; } | |
689 | inline wxWindow *wxWindow::GetGrandParent(void) const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); } | |
690 | inline wxList *wxWindow::GetChildren() const { return m_children; } | |
691 | inline wxFont *wxWindow::GetFont(void) const { return (wxFont *) & m_windowFont; } | |
692 | inline wxString wxWindow::GetName(void) const { return m_windowName; } | |
693 | inline void wxWindow::SetName(const wxString& name) { m_windowName = name; } | |
694 | inline long wxWindow::GetWindowStyleFlag(void) const { return m_windowStyle; } | |
695 | inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; } | |
696 | inline void wxWindow::SetDoubleClick(bool flag) { m_doubleClickAllowed = flag; } | |
697 | inline bool wxWindow::GetDoubleClick(void) const { return m_doubleClickAllowed; } | |
698 | inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; } | |
699 | inline wxEvtHandler *wxWindow::GetEventHandler(void) const { return m_windowEventHandler; } | |
700 | inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; } | |
701 | inline bool wxWindow::GetAutoLayout(void) const { return m_autoLayout; } | |
702 | inline wxLayoutConstraints *wxWindow::GetConstraints(void) const { return m_constraints; } | |
703 | inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }; | |
704 | inline wxColour wxWindow::GetBackgroundColour(void) const { return m_backgroundColour; }; | |
705 | inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; | |
706 | inline wxColour wxWindow::GetForegroundColour(void) const { return m_foregroundColour; }; | |
707 | inline void wxWindow::SetDefaultForegroundColour(const wxColour& col) { m_defaultForegroundColour = col; }; | |
708 | inline wxColour wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour; }; | |
709 | inline void wxWindow::SetDefaultBackgroundColour(const wxColour& col) { m_defaultBackgroundColour = col; }; | |
710 | inline wxColour wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour; }; | |
711 | ||
712 | inline wxButton *wxWindow::GetDefaultItem(void) const { return m_defaultItem; } | |
713 | inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } | |
714 | inline bool wxWindow::IsRetained(void) const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); } | |
715 | ||
716 | inline void wxWindow::SetShowing(bool show) { m_isShown = show; } | |
717 | inline wxList *wxWindow::GetConstraintsInvolvedIn(void) const { return m_constraintsInvolvedIn; } | |
718 | inline wxSizer *wxWindow::GetSizer(void) const { return m_windowSizer; } | |
719 | inline wxWindow *wxWindow::GetSizerParent(void) const { return m_sizerParent; } | |
720 | inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; } | |
721 | inline WXFARPROC wxWindow::MSWGetOldWndProc() const { return m_oldWndProc; } | |
722 | inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } | |
723 | inline wxValidator *wxWindow::GetValidator(void) const { return m_windowValidator; } | |
724 | inline bool wxWindow::IsUserEnabled(void) const { return m_winEnabled; } | |
725 | inline bool wxWindow::GetUseCtl3D(void) const { return m_useCtl3D; } | |
726 | inline bool wxWindow::GetTransparentBackground(void) const { return m_backgroundTransparent; } | |
727 | inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; } | |
728 | inline int wxWindow::GetReturnCode(void) { return m_returnCode; } | |
729 | inline bool wxWindow::IsBeingDeleted(void) { return m_isBeingDeleted; } | |
730 | ||
731 | // Window specific (so far) | |
732 | wxWindow* WXDLLEXPORT wxGetActiveWindow(void); | |
733 | ||
734 | WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows; | |
735 | ||
736 | int WXDLLEXPORT wxCharCodeMSWToWX(int keySym); | |
737 | int WXDLLEXPORT wxCharCodeWXToMSW(int id, bool *IsVirtual); | |
738 | ||
739 | // Allocates control ids | |
740 | int WXDLLEXPORT NewControlId(void); | |
741 | ||
742 | #endif | |
743 | // _WX_WINDOW_H_ |