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