]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
3 | // Purpose: wxWindow class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
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/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; | |
16e93305 | 56 | class WXDLLEXPORT wxRect; |
9b6dbb09 JS |
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 | ||
47d67540 | 70 | #if wxUSE_DRAG_AND_DROP |
9b6dbb09 JS |
71 | class WXDLLEXPORT wxDropTarget; |
72 | #endif | |
73 | ||
47d67540 | 74 | #if wxUSE_WX_RESOURCES |
9b6dbb09 JS |
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 | ||
3dd4e4e0 JS |
84 | //----------------------------------------------------------------------------- |
85 | // wxClientData | |
86 | //----------------------------------------------------------------------------- | |
87 | ||
88 | class wxClientData | |
89 | { | |
90 | public: | |
91 | wxClientData() { } | |
92 | virtual ~wxClientData() { } | |
93 | }; | |
94 | ||
95 | //----------------------------------------------------------------------------- | |
96 | // wxStringClientData | |
97 | //----------------------------------------------------------------------------- | |
98 | ||
99 | class wxStringClientData: public wxClientData | |
100 | { | |
101 | public: | |
102 | wxStringClientData() { } | |
103 | wxStringClientData( wxString &data ) { m_data = data; } | |
104 | void SetData( wxString &data ) { m_data = data; } | |
105 | wxString GetData() const { return m_data; } | |
106 | ||
107 | private: | |
108 | wxString m_data; | |
109 | }; | |
110 | ||
9b6dbb09 JS |
111 | class WXDLLEXPORT wxWindow: public wxEvtHandler |
112 | { | |
113 | DECLARE_ABSTRACT_CLASS(wxWindow) | |
114 | ||
16c1f7f3 JS |
115 | friend class WXDLLEXPORT wxDC; |
116 | friend class WXDLLEXPORT wxWindowDC; | |
9b6dbb09 JS |
117 | |
118 | public: | |
119 | wxWindow(); | |
120 | inline wxWindow(wxWindow *parent, wxWindowID id, | |
121 | const wxPoint& pos = wxDefaultPosition, | |
122 | const wxSize& size = wxDefaultSize, | |
123 | long style = 0, | |
124 | const wxString& name = wxPanelNameStr) | |
125 | { | |
126 | m_children = new wxList; | |
127 | Create(parent, id, pos, size, style, name); | |
128 | } | |
129 | ||
130 | virtual ~wxWindow(); | |
131 | ||
132 | bool Create(wxWindow *parent, wxWindowID id, | |
133 | const wxPoint& pos = wxDefaultPosition, | |
134 | const wxSize& size = wxDefaultSize, | |
135 | long style = 0, | |
136 | const wxString& name = wxPanelNameStr); | |
137 | ||
138 | // Fit the window around the items | |
139 | virtual void Fit(); | |
140 | ||
141 | // Show or hide the window | |
142 | virtual bool Show(bool show); | |
143 | ||
144 | // Is the window shown? | |
145 | virtual bool IsShown() const; | |
146 | ||
147 | // Raise the window to the top of the Z order | |
148 | virtual void Raise(); | |
149 | ||
150 | // Lower the window to the bottom of the Z order | |
151 | virtual void Lower(); | |
152 | ||
153 | // Is the window enabled? | |
154 | virtual bool IsEnabled() const; | |
155 | ||
156 | // For compatibility | |
157 | inline bool Enabled() const { return IsEnabled(); } | |
158 | ||
159 | // Dialog support: override these and call | |
160 | // base class members to add functionality | |
161 | // that can't be done using validators. | |
162 | ||
163 | // Transfer values to controls. If returns FALSE, | |
164 | // it's an application error (pops up a dialog) | |
165 | virtual bool TransferDataToWindow(); | |
166 | ||
167 | // Transfer values from controls. If returns FALSE, | |
168 | // transfer failed: don't quit | |
169 | virtual bool TransferDataFromWindow(); | |
170 | ||
171 | // Validate controls. If returns FALSE, | |
172 | // validation failed: don't quit | |
173 | virtual bool Validate(); | |
174 | ||
175 | // Return code for dialogs | |
176 | inline void SetReturnCode(int retCode); | |
177 | inline int GetReturnCode(); | |
178 | ||
179 | // Set the cursor | |
180 | virtual void SetCursor(const wxCursor& cursor); | |
181 | inline virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; }; | |
182 | ||
183 | // Get the window with the focus | |
184 | static wxWindow *FindFocus(); | |
185 | ||
186 | // Get character size | |
187 | virtual int GetCharHeight() const; | |
188 | virtual int GetCharWidth() const; | |
189 | ||
190 | // Get overall window size | |
191 | virtual void GetSize(int *width, int *height) const; | |
4fabb575 JS |
192 | virtual wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } |
193 | virtual wxRect GetRect() const { int w, h; int x, y; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } | |
9b6dbb09 JS |
194 | |
195 | // Get window position, relative to parent (or screen if no parent) | |
196 | virtual void GetPosition(int *x, int *y) const; | |
4fabb575 | 197 | virtual wxPoint GetPosition() const { int x, y; GetPosition(&x, &y); return wxPoint(x, y); } |
9b6dbb09 JS |
198 | |
199 | // Get client (application-useable) size | |
200 | virtual void GetClientSize(int *width, int *height) const; | |
4fabb575 | 201 | virtual wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } |
9b6dbb09 JS |
202 | |
203 | // Set overall size and position | |
204 | virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
4fabb575 JS |
205 | virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } |
206 | virtual void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) | |
207 | { SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } | |
208 | virtual void SetSize(const wxSize& size) { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); } | |
209 | ||
210 | virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); } | |
211 | virtual void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); } | |
9b6dbb09 JS |
212 | |
213 | // Set client size | |
214 | virtual void SetClientSize(int width, int size); | |
4fabb575 | 215 | virtual void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); } |
9b6dbb09 JS |
216 | |
217 | // Convert client to screen coordinates | |
218 | virtual void ClientToScreen(int *x, int *y) const; | |
4fabb575 JS |
219 | virtual wxPoint ClientToScreen(const wxPoint& pt) const |
220 | { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } | |
9b6dbb09 JS |
221 | |
222 | // Convert screen to client coordinates | |
223 | virtual void ScreenToClient(int *x, int *y) const; | |
4fabb575 JS |
224 | virtual wxPoint ScreenToClient(const wxPoint& pt) const |
225 | { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } | |
9b6dbb09 JS |
226 | |
227 | // Set the focus to this window | |
228 | virtual void SetFocus(); | |
229 | ||
230 | // Capture/release mouse | |
231 | virtual void CaptureMouse(); | |
232 | virtual void ReleaseMouse(); | |
233 | ||
234 | // Enable or disable the window | |
235 | virtual void Enable(bool enable); | |
236 | ||
47d67540 | 237 | #if wxUSE_DRAG_AND_DROP |
9b6dbb09 JS |
238 | // Associate a drop target with this window (if the window already had a drop |
239 | // target, it's deleted!) and return the current drop target (may be NULL). | |
240 | void SetDropTarget(wxDropTarget *pDropTarget); | |
241 | wxDropTarget *GetDropTarget() const { return m_pDropTarget; } | |
242 | #endif | |
243 | ||
244 | // Accept files for dragging | |
245 | virtual void DragAcceptFiles(bool accept); | |
246 | ||
1f112209 JS |
247 | // tooltips |
248 | // create a tooltip with this text | |
249 | void SetToolTip(const wxString& tip); | |
250 | ||
251 | // TODO | |
252 | #if 0 | |
253 | // pointer may be NULL to remove the tooltip | |
254 | void SetToolTip(wxToolTip *tooltip); | |
255 | // get the current tooltip (may return NULL if none) | |
256 | wxToolTip* GetToolTip() const { return m_tooltip; } | |
257 | #endif | |
258 | ||
9b6dbb09 | 259 | // Update region access |
55acd85e | 260 | virtual wxRegion& GetUpdateRegion() const; |
9b6dbb09 JS |
261 | virtual bool IsExposed(int x, int y, int w, int h) const; |
262 | virtual bool IsExposed(const wxPoint& pt) const; | |
263 | virtual bool IsExposed(const wxRect& rect) const; | |
264 | ||
265 | // Set/get the window title | |
266 | virtual inline void SetTitle(const wxString& WXUNUSED(title)) {}; | |
267 | inline virtual wxString GetTitle() const { return wxString(""); }; | |
268 | // Most windows have the concept of a label; for frames, this is the | |
269 | // title; for items, this is the label or button text. | |
270 | inline virtual wxString GetLabel() const { return GetTitle(); } | |
271 | ||
272 | // Set/get the window name (used for resource setting in X) | |
273 | inline virtual wxString GetName() const; | |
274 | inline virtual void SetName(const wxString& name); | |
275 | ||
276 | // Centre the window | |
277 | virtual void Centre(int direction) ; | |
278 | inline void Center(int direction = wxHORIZONTAL) { Centre(direction); } | |
279 | ||
280 | // Popup a menu | |
281 | virtual bool PopupMenu(wxMenu *menu, int x, int y); | |
282 | ||
283 | // Send the window a refresh event | |
16e93305 | 284 | virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL); |
9b6dbb09 JS |
285 | |
286 | // New functions that will replace the above. | |
287 | virtual void SetScrollbar(int orient, int pos, int thumbVisible, | |
288 | int range, bool refresh = TRUE); | |
289 | ||
88150e60 JS |
290 | // Helper functions for Motif |
291 | void CreateScrollbar(int orientation); | |
292 | void DestroyScrollbar(int orientation); | |
293 | ||
9b6dbb09 JS |
294 | virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE); |
295 | virtual int GetScrollPos(int orient) const; | |
296 | virtual int GetScrollRange(int orient) const; | |
297 | virtual int GetScrollThumb(int orient) const; | |
298 | ||
16e93305 | 299 | virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); |
9b6dbb09 JS |
300 | |
301 | // Caret manipulation | |
302 | virtual void CreateCaret(int w, int h); | |
303 | virtual void CreateCaret(const wxBitmap *bitmap); | |
304 | virtual void DestroyCaret(); | |
305 | virtual void ShowCaret(bool show); | |
306 | virtual void SetCaretPos(int x, int y); | |
307 | virtual void GetCaretPos(int *x, int *y) const; | |
308 | ||
309 | // Tell window how much it can be sized | |
310 | virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); | |
311 | ||
312 | // Set/get the window's identifier | |
313 | inline int GetId() const; | |
314 | inline void SetId(int id); | |
315 | ||
316 | virtual void SetAcceleratorTable(const wxAcceleratorTable& accel); | |
317 | inline virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; } | |
318 | ||
319 | // Make the window modal (all other windows unresponsive) | |
320 | virtual void MakeModal(bool modal); | |
321 | ||
322 | // Get the private handle (platform-dependent) | |
323 | inline void *GetHandle() const; | |
324 | ||
325 | // Set/get the window's relatives | |
326 | inline wxWindow *GetParent() const; | |
327 | inline void SetParent(wxWindow *p) ; | |
328 | inline wxWindow *GetGrandParent() const; | |
c0ed460c | 329 | inline wxList& GetChildren() const; |
4fabb575 JS |
330 | // Reparents this window to have the new parent. |
331 | virtual bool Reparent(wxWindow* parent); | |
9b6dbb09 JS |
332 | |
333 | // Set/get the window's font | |
334 | virtual void SetFont(const wxFont& f); | |
c0ed460c | 335 | inline virtual wxFont& GetFont() const; |
9b6dbb09 JS |
336 | |
337 | // Set/get the window's validator | |
338 | void SetValidator(const wxValidator& validator); | |
339 | inline wxValidator *GetValidator() const; | |
340 | ||
3dd4e4e0 JS |
341 | virtual void SetClientObject( wxClientData *data ); |
342 | virtual wxClientData *GetClientObject(); | |
343 | ||
344 | virtual void SetClientData( void *data ); | |
345 | virtual void *GetClientData(); | |
346 | ||
9b6dbb09 JS |
347 | // Set/get the window's style |
348 | inline void SetWindowStyleFlag(long flag); | |
349 | inline long GetWindowStyleFlag() const; | |
350 | ||
02e8b2f9 JS |
351 | // Handle a control command |
352 | virtual void OnCommand(wxWindow& win, wxCommandEvent& event); | |
353 | ||
9b6dbb09 JS |
354 | // Set/get event handler |
355 | inline void SetEventHandler(wxEvtHandler *handler); | |
356 | inline wxEvtHandler *GetEventHandler() const; | |
357 | ||
358 | // Push/pop event handler (i.e. allow a chain of event handlers | |
359 | // be searched) | |
360 | void PushEventHandler(wxEvtHandler *handler) ; | |
361 | wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ; | |
362 | ||
363 | // Close the window by calling OnClose, posting a deletion | |
364 | virtual bool Close(bool force = FALSE); | |
365 | ||
366 | // Destroy the window (delayed, if a managed window) | |
367 | virtual bool Destroy() ; | |
368 | ||
369 | // Mode for telling default OnSize members to | |
370 | // call Layout(), if not using Sizers, just top-down constraints | |
371 | inline void SetAutoLayout(bool a); | |
372 | inline bool GetAutoLayout() const; | |
373 | ||
374 | // Set/get constraints | |
375 | inline wxLayoutConstraints *GetConstraints() const; | |
376 | void SetConstraints(wxLayoutConstraints *c); | |
377 | ||
378 | // Set/get window background colour | |
0d57be45 | 379 | virtual void SetBackgroundColour(const wxColour& col); |
9b6dbb09 JS |
380 | inline virtual wxColour GetBackgroundColour() const; |
381 | ||
382 | // Set/get window foreground colour | |
0d57be45 | 383 | virtual void SetForegroundColour(const wxColour& col); |
9b6dbb09 JS |
384 | inline virtual wxColour GetForegroundColour() const; |
385 | ||
9b6dbb09 JS |
386 | // Get the default button, if there is one |
387 | inline virtual wxButton *GetDefaultItem() const; | |
388 | inline virtual void SetDefaultItem(wxButton *but); | |
389 | ||
390 | // Override to define new behaviour for default action (e.g. double clicking | |
391 | // on a listbox) | |
392 | virtual void OnDefaultAction(wxControl *initiatingItem); | |
393 | ||
394 | // Resource loading | |
47d67540 | 395 | #if wxUSE_WX_RESOURCES |
9b6dbb09 | 396 | virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); |
fd71308f JS |
397 | virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, |
398 | const wxResourceTable *table = (const wxResourceTable *) NULL); | |
9b6dbb09 JS |
399 | #endif |
400 | ||
401 | virtual void GetTextExtent(const wxString& string, int *x, int *y, | |
402 | int *descent = NULL, | |
403 | int *externalLeading = NULL, | |
404 | const wxFont *theFont = NULL, bool use16 = FALSE) const; | |
405 | ||
406 | // Is the window retained? | |
407 | inline bool IsRetained() const; | |
408 | ||
409 | // Warp the pointer the given position | |
410 | virtual void WarpPointer(int x_pos, int y_pos) ; | |
411 | ||
412 | // Clear the window | |
413 | virtual void Clear(); | |
414 | ||
415 | // Find a window by id or name | |
416 | virtual wxWindow *FindWindow(long id); | |
417 | virtual wxWindow *FindWindow(const wxString& name); | |
418 | ||
419 | // Constraint operations | |
420 | bool Layout(); | |
421 | void SetSizer(wxSizer *sizer); // Adds sizer child to this window | |
422 | inline wxSizer *GetSizer() const ; | |
423 | inline wxWindow *GetSizerParent() const ; | |
424 | inline void SetSizerParent(wxWindow *win); | |
425 | ||
426 | // Do Update UI processing for controls | |
427 | void UpdateWindowUI(); | |
428 | ||
429 | void OnEraseBackground(wxEraseEvent& event); | |
430 | void OnChar(wxKeyEvent& event); | |
4ce81a75 JS |
431 | void OnKeyDown(wxKeyEvent& event); |
432 | void OnKeyUp(wxKeyEvent& event); | |
9b6dbb09 JS |
433 | void OnPaint(wxPaintEvent& event); |
434 | void OnIdle(wxIdleEvent& event); | |
435 | ||
436 | // Does this window want to accept keyboard focus? | |
437 | virtual bool AcceptsFocus() const; | |
438 | ||
ea57084d | 439 | virtual void PrepareDC( wxDC & WXUNUSED(dc) ) {}; |
9b6dbb09 JS |
440 | |
441 | ||
442 | public: | |
443 | //////////////////////////////////////////////////////////////////////// | |
444 | //// IMPLEMENTATION | |
445 | ||
446 | // For implementation purposes - sometimes decorations make the client area | |
447 | // smaller | |
448 | virtual wxPoint GetClientAreaOrigin() const; | |
449 | ||
450 | // Makes an adjustment to the window position (for example, a frame that has | |
451 | // a toolbar that it manages itself). | |
452 | virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); | |
453 | ||
454 | // Executes the default message | |
455 | virtual long Default(); | |
456 | ||
457 | /* TODO: you may need something like this | |
458 | // Determine whether 3D effects are wanted | |
459 | virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D); | |
460 | */ | |
461 | ||
462 | virtual void AddChild(wxWindow *child); // Adds reference to the child object | |
463 | virtual void RemoveChild(wxWindow *child); // Removes reference to child | |
464 | // (but doesn't delete the child object) | |
465 | virtual void DestroyChildren(); // Removes and destroys all children | |
466 | ||
467 | inline bool IsBeingDeleted() const { return FALSE; } // TODO: Should probably eliminate this | |
468 | ||
469 | // Constraint implementation | |
470 | void UnsetConstraints(wxLayoutConstraints *c); | |
471 | inline wxList *GetConstraintsInvolvedIn() const ; | |
472 | // Back-pointer to other windows we're involved with, so if we delete | |
473 | // this window, we must delete any constraints we're involved with. | |
474 | void AddConstraintReference(wxWindow *otherWin); | |
475 | void RemoveConstraintReference(wxWindow *otherWin); | |
476 | void DeleteRelatedConstraints(); | |
477 | ||
478 | virtual void ResetConstraints(); | |
479 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
480 | virtual bool LayoutPhase1(int *noChanges); | |
481 | virtual bool LayoutPhase2(int *noChanges); | |
482 | virtual bool DoPhase(int); | |
483 | // Transforms from sizer coordinate space to actual | |
484 | // parent coordinate space | |
485 | virtual void TransformSizerToActual(int *x, int *y) const ; | |
486 | ||
487 | // Set size with transformation to actual coordinates if nec. | |
488 | virtual void SizerSetSize(int x, int y, int w, int h); | |
489 | virtual void SizerMove(int x, int y); | |
490 | ||
491 | // Only set/get the size/position of the constraint (if any) | |
492 | virtual void SetSizeConstraint(int x, int y, int w, int h); | |
493 | virtual void MoveConstraint(int x, int y); | |
494 | virtual void GetSizeConstraint(int *w, int *h) const ; | |
495 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
496 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
497 | ||
fd71308f JS |
498 | // Dialog units translations. Implemented in wincmn.cpp. |
499 | wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; | |
500 | wxPoint ConvertDialogToPixels(const wxPoint& pt) ; | |
501 | inline wxSize ConvertPixelsToDialog(const wxSize& sz) | |
502 | { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
503 | inline wxSize ConvertDialogToPixels(const wxSize& sz) | |
504 | { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } | |
505 | ||
9b6dbb09 JS |
506 | wxObject *GetChild(int number) const ; |
507 | ||
508 | // Generates a new id for controls | |
509 | static int NewControlId(); | |
510 | ||
511 | // Responds to colour changes: passes event on to children. | |
512 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
513 | ||
514 | // Transfers data to any child controls | |
515 | void OnInitDialog(wxInitDialogEvent& event); | |
516 | ||
517 | // Sends an OnInitDialog event, which in turns transfers data to | |
518 | // to the window via validators. | |
519 | virtual void InitDialog(); | |
520 | ||
50414e24 JS |
521 | /// Motif-specific |
522 | ||
55acd85e | 523 | void ClearUpdateRects(); |
50414e24 JS |
524 | void CanvasGetSize(int* width, int* height) const; // If have drawing area |
525 | void CanvasGetClientSize(int *width, int *height) const; | |
526 | void CanvasGetPosition(int *x, int *y) const; // If have drawing area | |
527 | void CanvasSetClientSize(int width, int size); | |
528 | void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
9b6dbb09 JS |
529 | |
530 | // Gives window a chance to do something in response to a size | |
531 | // message, e.g. arrange status bar, toolbar etc. | |
532 | virtual bool PreResize() { return TRUE; } | |
533 | ||
02e8b2f9 | 534 | // Get main widget for this window, e.g. a text widget |
9b6dbb09 | 535 | virtual WXWidget GetMainWidget() const; |
a4294b78 | 536 | // Get the widget that corresponds to the label (for font setting, label setting etc.) |
47bc1060 | 537 | virtual WXWidget GetLabelWidget() const { return GetMainWidget(); } |
50414e24 JS |
538 | // Get the client widget for this window (something we can |
539 | // create other windows on) | |
540 | virtual WXWidget GetClientWidget() const; | |
02e8b2f9 JS |
541 | // Get the top widget for this window, e.g. the scrolled widget parent |
542 | // of a multi-line text widget. Top means, top in the window hierarchy | |
543 | // that implements this window. | |
544 | virtual WXWidget GetTopWidget() const; | |
9b6dbb09 | 545 | virtual void SetMainWidget(WXWidget w) { m_mainWidget = w; } |
02e8b2f9 JS |
546 | bool CanAddEventHandler() const { return m_canAddEventHandler; } |
547 | void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } | |
9b6dbb09 JS |
548 | |
549 | // Get the underlying X window and display | |
550 | virtual WXWindow GetXWindow() const; | |
551 | virtual WXDisplay *GetXDisplay() const; | |
16c1f7f3 | 552 | |
dfc54541 | 553 | virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; } |
16c1f7f3 JS |
554 | inline int GetPixmapWidth() const { return m_pixmapWidth; } |
555 | inline int GetPixmapHeight() const { return m_pixmapHeight; } | |
9b6dbb09 | 556 | |
02e8b2f9 | 557 | // Change properties |
4b5f3fe6 | 558 | virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) |
0d57be45 JS |
559 | virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); |
560 | virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); | |
561 | // These to be overridden as needed (may change several widgets) | |
562 | virtual void ChangeBackgroundColour(); // Change background and foreground colour using current | |
563 | // background colour setting (Motif generates | |
564 | // foreground based on background) | |
565 | virtual void ChangeForegroundColour(); // Change foreground colour using current | |
566 | // foreground colour setting | |
02e8b2f9 JS |
567 | |
568 | // Adds the widget to the hash table and adds event handlers. | |
569 | bool AttachWidget (wxWindow* parent, WXWidget mainWidget, | |
570 | WXWidget formWidget, int x, int y, int width, int height); | |
571 | bool DetachWidget(WXWidget widget); | |
572 | ||
50414e24 JS |
573 | // Generates a paint event |
574 | virtual void DoPaint(); | |
575 | ||
8aa04e8b JS |
576 | // How to implement accelerators. If we find a key event, |
577 | // translate to wxWindows wxKeyEvent form. Find a widget for the window. | |
578 | // Now find a wxWindow for the widget. If there isn't one, go up the widget hierarchy | |
579 | // trying to find one. Once one is found, call ProcessAccelerator for the | |
580 | // window. If it returns TRUE (processed the event), skip the X event, | |
581 | // otherwise carry on up the wxWindows window hierarchy calling ProcessAccelerator. | |
582 | // If all return FALSE, process the X event as normal. | |
583 | // Eventually we can implement OnCharHook the same way, but concentrate on accelerators | |
584 | // for now. | |
585 | // ProcessAccelerator must look at the current accelerator table, and try to find | |
586 | // what menu id or window (beneath it) has this ID. Then construct an appropriate command | |
587 | // event and send it. | |
588 | virtual bool ProcessAccelerator(wxKeyEvent& event); | |
589 | ||
9b6dbb09 JS |
590 | //////////////////////////////////////////////////////////////////////// |
591 | //// PROTECTED DATA | |
592 | protected: | |
593 | int m_windowId; | |
594 | long m_windowStyle; // Store the window's style | |
595 | wxEvtHandler * m_windowEventHandler; // Usually is 'this' | |
596 | wxLayoutConstraints * m_constraints; // Constraints for this window | |
597 | wxList * m_constraintsInvolvedIn; // List of constraints we're involved in | |
598 | wxSizer * m_windowSizer; // Window's top-level sizer (if any) | |
599 | wxWindow * m_sizerParent; // Window's parent sizer (if any) | |
600 | bool m_autoLayout; // Whether to call Layout() in OnSize | |
601 | wxWindow * m_windowParent; // Each window always knows its parent | |
602 | wxValidator * m_windowValidator; | |
603 | int m_minSizeX; | |
604 | int m_minSizeY; | |
605 | int m_maxSizeX; | |
606 | int m_maxSizeY; | |
607 | ||
608 | // Caret data | |
609 | int m_caretWidth; | |
610 | int m_caretHeight; | |
611 | bool m_caretEnabled; | |
612 | bool m_caretShown; | |
613 | wxFont m_windowFont; // Window's font | |
614 | wxCursor m_windowCursor; // Window's cursor | |
615 | wxString m_windowName; // Window name | |
616 | ||
617 | wxButton * m_defaultItem; | |
618 | ||
619 | wxColour m_backgroundColour ; | |
620 | wxColour m_foregroundColour ; | |
9b6dbb09 | 621 | wxAcceleratorTable m_acceleratorTable; |
3dd4e4e0 JS |
622 | wxClientData* m_clientObject; |
623 | void* m_clientData; | |
9b6dbb09 | 624 | |
47d67540 | 625 | #if wxUSE_DRAG_AND_DROP |
9b6dbb09 JS |
626 | wxDropTarget *m_pDropTarget; // the current drop target or NULL |
627 | #endif //USE_DRAG_AND_DROP | |
628 | ||
629 | public: | |
630 | wxRegion m_updateRegion; | |
631 | wxList * m_children; // Window's children | |
632 | int m_returnCode; | |
633 | ||
634 | public: | |
50414e24 | 635 | /// Motif-specific |
02e8b2f9 | 636 | bool m_canAddEventHandler; |
9b6dbb09 JS |
637 | bool m_button1Pressed; |
638 | bool m_button2Pressed; | |
639 | bool m_button3Pressed; | |
50414e24 JS |
640 | // For double-click detection |
641 | long m_lastTS; // last timestamp | |
642 | int m_lastButton; // last pressed button | |
16e93305 | 643 | wxList m_updateRects; // List of wxRects representing damaged region |
dfc54541 | 644 | bool m_isShown; |
9b6dbb09 JS |
645 | protected: |
646 | WXWidget m_mainWidget; | |
50414e24 JS |
647 | WXWidget m_hScrollBar; |
648 | WXWidget m_vScrollBar; | |
649 | WXWidget m_borderWidget; | |
650 | WXWidget m_scrolledWindow; | |
651 | WXWidget m_drawingArea; | |
9b6dbb09 | 652 | bool m_winCaptured; |
50414e24 JS |
653 | bool m_hScroll; |
654 | bool m_vScroll; | |
50414e24 JS |
655 | WXPixmap m_backingPixmap; |
656 | int m_pixmapWidth; | |
657 | int m_pixmapHeight; | |
658 | int m_pixmapOffsetX; | |
659 | int m_pixmapOffsetY; | |
47bc1060 JS |
660 | int m_scrollPosX; // Store the last scroll pos, |
661 | int m_scrollPosY; // since in wxWin the pos isn't | |
662 | // set automatically by system | |
9b6dbb09 JS |
663 | |
664 | DECLARE_EVENT_TABLE() | |
665 | }; | |
666 | ||
667 | //////////////////////////////////////////////////////////////////////// | |
668 | //// INLINES | |
669 | ||
670 | inline void *wxWindow::GetHandle() const { return (void *)NULL; } | |
671 | inline int wxWindow::GetId() const { return m_windowId; } | |
672 | inline void wxWindow::SetId(int id) { m_windowId = id; } | |
673 | inline wxWindow *wxWindow::GetParent() const { return m_windowParent; } | |
674 | inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; } | |
675 | inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); } | |
c0ed460c JS |
676 | inline wxList& wxWindow::GetChildren() const { return (wxList&) * m_children; } |
677 | inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; } | |
9b6dbb09 JS |
678 | inline wxString wxWindow::GetName() const { return m_windowName; } |
679 | inline void wxWindow::SetName(const wxString& name) { m_windowName = name; } | |
680 | inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; } | |
681 | inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; } | |
682 | inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; } | |
683 | inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; } | |
684 | inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; } | |
685 | inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; } | |
686 | inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; } | |
9b6dbb09 | 687 | inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; |
9b6dbb09 | 688 | inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; |
9b6dbb09 JS |
689 | |
690 | inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } | |
691 | inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } | |
692 | inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); } | |
693 | ||
694 | inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; } | |
695 | inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; } | |
696 | inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; } | |
697 | inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; } | |
698 | inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; } | |
699 | inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; } | |
700 | inline int wxWindow::GetReturnCode() { return m_returnCode; } | |
701 | ||
702 | // Get the active window. | |
703 | wxWindow* WXDLLEXPORT wxGetActiveWindow(); | |
704 | ||
705 | WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows; | |
706 | ||
88150e60 JS |
707 | // A little class to switch off size optimization while an instance of the object |
708 | // exists | |
709 | class WXDLLEXPORT wxNoOptimize: public wxObject | |
710 | { | |
711 | public: | |
712 | wxNoOptimize(); | |
713 | ~wxNoOptimize(); | |
714 | ||
715 | static bool CanOptimize(); | |
716 | ||
717 | protected: | |
718 | static int m_count; | |
719 | }; | |
720 | ||
9b6dbb09 JS |
721 | #endif |
722 | // _WX_WINDOW_H_ |