]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/window.h
fixes to previous fixes for Sun's CC 5.0
[wxWidgets.git] / include / wx / motif / window.h
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;
56 class WXDLLEXPORT wxRect;
57 class WXDLLEXPORT wxBitmap;
58 class WXDLLEXPORT wxSizer;
59 class WXDLLEXPORT wxList;
60 class WXDLLEXPORT wxLayoutConstraints;
61 class WXDLLEXPORT wxMouseEvent;
62 class WXDLLEXPORT wxButton;
63 class WXDLLEXPORT wxColour;
64 class WXDLLEXPORT wxBrush;
65 class WXDLLEXPORT wxPen;
66 class WXDLLEXPORT wxIcon;
67 class WXDLLEXPORT wxDC;
68 class WXDLLEXPORT wxValidator;
69
70 #if wxUSE_DRAG_AND_DROP
71 class WXDLLEXPORT wxDropTarget;
72 #endif
73
74 #if wxUSE_WX_RESOURCES
75 class WXDLLEXPORT wxResourceTable;
76 class WXDLLEXPORT wxItemResource;
77 #endif
78
79 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
80
81 WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
82 WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
83
84 //-----------------------------------------------------------------------------
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
111 class WXDLLEXPORT wxWindow: public wxEvtHandler
112 {
113 DECLARE_ABSTRACT_CLASS(wxWindow)
114
115 friend class WXDLLEXPORT wxDC;
116 friend class WXDLLEXPORT wxWindowDC;
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;
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); }
194
195 // Get window position, relative to parent (or screen if no parent)
196 virtual void GetPosition(int *x, int *y) const;
197 virtual wxPoint GetPosition() const { int x, y; GetPosition(&x, &y); return wxPoint(x, y); }
198
199 // Get client (application-useable) size
200 virtual void GetClientSize(int *width, int *height) const;
201 virtual wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
202
203 // Set overall size and position
204 virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
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); }
212
213 // Set client size
214 virtual void SetClientSize(int width, int size);
215 virtual void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); }
216
217 // Convert client to screen coordinates
218 virtual void ClientToScreen(int *x, int *y) const;
219 virtual wxPoint ClientToScreen(const wxPoint& pt) const
220 { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
221
222 // Convert screen to client coordinates
223 virtual void ScreenToClient(int *x, int *y) const;
224 virtual wxPoint ScreenToClient(const wxPoint& pt) const
225 { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
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
237 #if wxUSE_DRAG_AND_DROP
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
247 // Update region access
248 virtual wxRegion& GetUpdateRegion() const;
249 virtual bool IsExposed(int x, int y, int w, int h) const;
250 virtual bool IsExposed(const wxPoint& pt) const;
251 virtual bool IsExposed(const wxRect& rect) const;
252
253 // Set/get the window title
254 virtual inline void SetTitle(const wxString& WXUNUSED(title)) {};
255 inline virtual wxString GetTitle() const { return wxString(""); };
256 // Most windows have the concept of a label; for frames, this is the
257 // title; for items, this is the label or button text.
258 inline virtual wxString GetLabel() const { return GetTitle(); }
259
260 // Set/get the window name (used for resource setting in X)
261 inline virtual wxString GetName() const;
262 inline virtual void SetName(const wxString& name);
263
264 // Centre the window
265 virtual void Centre(int direction) ;
266 inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
267
268 // Popup a menu
269 virtual bool PopupMenu(wxMenu *menu, int x, int y);
270
271 // Send the window a refresh event
272 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
273
274 // New functions that will replace the above.
275 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
276 int range, bool refresh = TRUE);
277
278 // Helper functions for Motif
279 void CreateScrollbar(int orientation);
280 void DestroyScrollbar(int orientation);
281
282 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
283 virtual int GetScrollPos(int orient) const;
284 virtual int GetScrollRange(int orient) const;
285 virtual int GetScrollThumb(int orient) const;
286
287 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
288
289 // Caret manipulation
290 virtual void CreateCaret(int w, int h);
291 virtual void CreateCaret(const wxBitmap *bitmap);
292 virtual void DestroyCaret();
293 virtual void ShowCaret(bool show);
294 virtual void SetCaretPos(int x, int y);
295 virtual void GetCaretPos(int *x, int *y) const;
296
297 // Tell window how much it can be sized
298 virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1);
299
300 // Set/get the window's identifier
301 inline int GetId() const;
302 inline void SetId(int id);
303
304 virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
305 inline virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; }
306
307 // Make the window modal (all other windows unresponsive)
308 virtual void MakeModal(bool modal);
309
310 // Get the private handle (platform-dependent)
311 inline void *GetHandle() const;
312
313 // Set/get the window's relatives
314 inline wxWindow *GetParent() const;
315 inline void SetParent(wxWindow *p) ;
316 inline wxWindow *GetGrandParent() const;
317 inline wxList& GetChildren() const;
318 // Reparents this window to have the new parent.
319 virtual bool Reparent(wxWindow* parent);
320
321 // Set/get the window's font
322 virtual void SetFont(const wxFont& f);
323 inline virtual wxFont& GetFont() const;
324
325 // Set/get the window's validator
326 void SetValidator(const wxValidator& validator);
327 inline wxValidator *GetValidator() const;
328
329 virtual void SetClientObject( wxClientData *data );
330 virtual wxClientData *GetClientObject();
331
332 virtual void SetClientData( void *data );
333 virtual void *GetClientData();
334
335 // Set/get the window's style
336 inline void SetWindowStyleFlag(long flag);
337 inline long GetWindowStyleFlag() const;
338
339 // Handle a control command
340 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
341
342 // Set/get event handler
343 inline void SetEventHandler(wxEvtHandler *handler);
344 inline wxEvtHandler *GetEventHandler() const;
345
346 // Push/pop event handler (i.e. allow a chain of event handlers
347 // be searched)
348 void PushEventHandler(wxEvtHandler *handler) ;
349 wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
350
351 // Close the window by calling OnClose, posting a deletion
352 virtual bool Close(bool force = FALSE);
353
354 // Destroy the window (delayed, if a managed window)
355 virtual bool Destroy() ;
356
357 // Mode for telling default OnSize members to
358 // call Layout(), if not using Sizers, just top-down constraints
359 inline void SetAutoLayout(bool a);
360 inline bool GetAutoLayout() const;
361
362 // Set/get constraints
363 inline wxLayoutConstraints *GetConstraints() const;
364 void SetConstraints(wxLayoutConstraints *c);
365
366 // Set/get window background colour
367 virtual void SetBackgroundColour(const wxColour& col);
368 inline virtual wxColour GetBackgroundColour() const;
369
370 // Set/get window foreground colour
371 virtual void SetForegroundColour(const wxColour& col);
372 inline virtual wxColour GetForegroundColour() const;
373
374 // Get the default button, if there is one
375 inline virtual wxButton *GetDefaultItem() const;
376 inline virtual void SetDefaultItem(wxButton *but);
377
378 // Override to define new behaviour for default action (e.g. double clicking
379 // on a listbox)
380 virtual void OnDefaultAction(wxControl *initiatingItem);
381
382 // Resource loading
383 #if wxUSE_WX_RESOURCES
384 virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL);
385 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
386 const wxResourceTable *table = (const wxResourceTable *) NULL);
387 #endif
388
389 virtual void GetTextExtent(const wxString& string, int *x, int *y,
390 int *descent = NULL,
391 int *externalLeading = NULL,
392 const wxFont *theFont = NULL, bool use16 = FALSE) const;
393
394 // Is the window retained?
395 inline bool IsRetained() const;
396
397 // Warp the pointer the given position
398 virtual void WarpPointer(int x_pos, int y_pos) ;
399
400 // Clear the window
401 virtual void Clear();
402
403 // Find a window by id or name
404 virtual wxWindow *FindWindow(long id);
405 virtual wxWindow *FindWindow(const wxString& name);
406
407 // Constraint operations
408 bool Layout();
409 void SetSizer(wxSizer *sizer); // Adds sizer child to this window
410 inline wxSizer *GetSizer() const ;
411 inline wxWindow *GetSizerParent() const ;
412 inline void SetSizerParent(wxWindow *win);
413
414 // Do Update UI processing for controls
415 void UpdateWindowUI();
416
417 void OnEraseBackground(wxEraseEvent& event);
418 void OnChar(wxKeyEvent& event);
419 void OnKeyDown(wxKeyEvent& event);
420 void OnKeyUp(wxKeyEvent& event);
421 void OnPaint(wxPaintEvent& event);
422 void OnIdle(wxIdleEvent& event);
423
424 // Does this window want to accept keyboard focus?
425 virtual bool AcceptsFocus() const;
426
427 virtual void PrepareDC( wxDC & WXUNUSED(dc) ) {};
428
429
430 public:
431 ////////////////////////////////////////////////////////////////////////
432 //// IMPLEMENTATION
433
434 // For implementation purposes - sometimes decorations make the client area
435 // smaller
436 virtual wxPoint GetClientAreaOrigin() const;
437
438 // Makes an adjustment to the window position (for example, a frame that has
439 // a toolbar that it manages itself).
440 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
441
442 // Executes the default message
443 virtual long Default();
444
445 /* TODO: you may need something like this
446 // Determine whether 3D effects are wanted
447 virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
448 */
449
450 virtual void AddChild(wxWindow *child); // Adds reference to the child object
451 virtual void RemoveChild(wxWindow *child); // Removes reference to child
452 // (but doesn't delete the child object)
453 virtual void DestroyChildren(); // Removes and destroys all children
454
455 inline bool IsBeingDeleted() const { return FALSE; } // TODO: Should probably eliminate this
456
457 // Constraint implementation
458 void UnsetConstraints(wxLayoutConstraints *c);
459 inline wxList *GetConstraintsInvolvedIn() const ;
460 // Back-pointer to other windows we're involved with, so if we delete
461 // this window, we must delete any constraints we're involved with.
462 void AddConstraintReference(wxWindow *otherWin);
463 void RemoveConstraintReference(wxWindow *otherWin);
464 void DeleteRelatedConstraints();
465
466 virtual void ResetConstraints();
467 virtual void SetConstraintSizes(bool recurse = TRUE);
468 virtual bool LayoutPhase1(int *noChanges);
469 virtual bool LayoutPhase2(int *noChanges);
470 virtual bool DoPhase(int);
471 // Transforms from sizer coordinate space to actual
472 // parent coordinate space
473 virtual void TransformSizerToActual(int *x, int *y) const ;
474
475 // Set size with transformation to actual coordinates if nec.
476 virtual void SizerSetSize(int x, int y, int w, int h);
477 virtual void SizerMove(int x, int y);
478
479 // Only set/get the size/position of the constraint (if any)
480 virtual void SetSizeConstraint(int x, int y, int w, int h);
481 virtual void MoveConstraint(int x, int y);
482 virtual void GetSizeConstraint(int *w, int *h) const ;
483 virtual void GetClientSizeConstraint(int *w, int *h) const ;
484 virtual void GetPositionConstraint(int *x, int *y) const ;
485
486 // Dialog units translations. Implemented in wincmn.cpp.
487 wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
488 wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
489 inline wxSize ConvertPixelsToDialog(const wxSize& sz)
490 { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
491 inline wxSize ConvertDialogToPixels(const wxSize& sz)
492 { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
493
494 wxObject *GetChild(int number) const ;
495
496 // Generates a new id for controls
497 static int NewControlId();
498
499 // Responds to colour changes: passes event on to children.
500 void OnSysColourChanged(wxSysColourChangedEvent& event);
501
502 // Transfers data to any child controls
503 void OnInitDialog(wxInitDialogEvent& event);
504
505 // Sends an OnInitDialog event, which in turns transfers data to
506 // to the window via validators.
507 virtual void InitDialog();
508
509 /// Motif-specific
510
511 void ClearUpdateRects();
512 void CanvasGetSize(int* width, int* height) const; // If have drawing area
513 void CanvasGetClientSize(int *width, int *height) const;
514 void CanvasGetPosition(int *x, int *y) const; // If have drawing area
515 void CanvasSetClientSize(int width, int size);
516 void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
517
518 // Gives window a chance to do something in response to a size
519 // message, e.g. arrange status bar, toolbar etc.
520 virtual bool PreResize() { return TRUE; }
521
522 // Get main widget for this window, e.g. a text widget
523 virtual WXWidget GetMainWidget() const;
524 // Get the widget that corresponds to the label (for font setting, label setting etc.)
525 virtual WXWidget GetLabelWidget() const { return GetMainWidget(); }
526 // Get the client widget for this window (something we can
527 // create other windows on)
528 virtual WXWidget GetClientWidget() const;
529 // Get the top widget for this window, e.g. the scrolled widget parent
530 // of a multi-line text widget. Top means, top in the window hierarchy
531 // that implements this window.
532 virtual WXWidget GetTopWidget() const;
533 virtual void SetMainWidget(WXWidget w) { m_mainWidget = w; }
534 bool CanAddEventHandler() const { return m_canAddEventHandler; }
535 void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; }
536
537 // Get the underlying X window and display
538 virtual WXWindow GetXWindow() const;
539 virtual WXDisplay *GetXDisplay() const;
540
541 virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
542 inline int GetPixmapWidth() const { return m_pixmapWidth; }
543 inline int GetPixmapHeight() const { return m_pixmapHeight; }
544
545 // Change properties
546 virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden)
547 virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
548 virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
549 // These to be overridden as needed (may change several widgets)
550 virtual void ChangeBackgroundColour(); // Change background and foreground colour using current
551 // background colour setting (Motif generates
552 // foreground based on background)
553 virtual void ChangeForegroundColour(); // Change foreground colour using current
554 // foreground colour setting
555
556 // Adds the widget to the hash table and adds event handlers.
557 bool AttachWidget (wxWindow* parent, WXWidget mainWidget,
558 WXWidget formWidget, int x, int y, int width, int height);
559 bool DetachWidget(WXWidget widget);
560
561 // Generates a paint event
562 virtual void DoPaint();
563
564 // How to implement accelerators. If we find a key event,
565 // translate to wxWindows wxKeyEvent form. Find a widget for the window.
566 // Now find a wxWindow for the widget. If there isn't one, go up the widget hierarchy
567 // trying to find one. Once one is found, call ProcessAccelerator for the
568 // window. If it returns TRUE (processed the event), skip the X event,
569 // otherwise carry on up the wxWindows window hierarchy calling ProcessAccelerator.
570 // If all return FALSE, process the X event as normal.
571 // Eventually we can implement OnCharHook the same way, but concentrate on accelerators
572 // for now.
573 // ProcessAccelerator must look at the current accelerator table, and try to find
574 // what menu id or window (beneath it) has this ID. Then construct an appropriate command
575 // event and send it.
576 virtual bool ProcessAccelerator(wxKeyEvent& event);
577
578 ////////////////////////////////////////////////////////////////////////
579 //// PROTECTED DATA
580 protected:
581 int m_windowId;
582 long m_windowStyle; // Store the window's style
583 wxEvtHandler * m_windowEventHandler; // Usually is 'this'
584 wxLayoutConstraints * m_constraints; // Constraints for this window
585 wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
586 wxSizer * m_windowSizer; // Window's top-level sizer (if any)
587 wxWindow * m_sizerParent; // Window's parent sizer (if any)
588 bool m_autoLayout; // Whether to call Layout() in OnSize
589 wxWindow * m_windowParent; // Each window always knows its parent
590 wxValidator * m_windowValidator;
591 int m_minSizeX;
592 int m_minSizeY;
593 int m_maxSizeX;
594 int m_maxSizeY;
595
596 // Caret data
597 int m_caretWidth;
598 int m_caretHeight;
599 bool m_caretEnabled;
600 bool m_caretShown;
601 wxFont m_windowFont; // Window's font
602 wxCursor m_windowCursor; // Window's cursor
603 wxString m_windowName; // Window name
604
605 wxButton * m_defaultItem;
606
607 wxColour m_backgroundColour ;
608 wxColour m_foregroundColour ;
609 wxAcceleratorTable m_acceleratorTable;
610 wxClientData* m_clientObject;
611 void* m_clientData;
612
613 #if wxUSE_DRAG_AND_DROP
614 wxDropTarget *m_pDropTarget; // the current drop target or NULL
615 #endif //USE_DRAG_AND_DROP
616
617 public:
618 wxRegion m_updateRegion;
619 wxList * m_children; // Window's children
620 int m_returnCode;
621
622 public:
623 /// Motif-specific
624 bool m_canAddEventHandler;
625 bool m_button1Pressed;
626 bool m_button2Pressed;
627 bool m_button3Pressed;
628 // For double-click detection
629 long m_lastTS; // last timestamp
630 int m_lastButton; // last pressed button
631 wxList m_updateRects; // List of wxRects representing damaged region
632 bool m_isShown;
633 protected:
634 WXWidget m_mainWidget;
635 WXWidget m_hScrollBar;
636 WXWidget m_vScrollBar;
637 WXWidget m_borderWidget;
638 WXWidget m_scrolledWindow;
639 WXWidget m_drawingArea;
640 bool m_winCaptured;
641 bool m_hScroll;
642 bool m_vScroll;
643 WXPixmap m_backingPixmap;
644 int m_pixmapWidth;
645 int m_pixmapHeight;
646 int m_pixmapOffsetX;
647 int m_pixmapOffsetY;
648 int m_scrollPosX; // Store the last scroll pos,
649 int m_scrollPosY; // since in wxWin the pos isn't
650 // set automatically by system
651
652 DECLARE_EVENT_TABLE()
653 };
654
655 ////////////////////////////////////////////////////////////////////////
656 //// INLINES
657
658 inline void *wxWindow::GetHandle() const { return (void *)NULL; }
659 inline int wxWindow::GetId() const { return m_windowId; }
660 inline void wxWindow::SetId(int id) { m_windowId = id; }
661 inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
662 inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
663 inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); }
664 inline wxList& wxWindow::GetChildren() const { return (wxList&) * m_children; }
665 inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; }
666 inline wxString wxWindow::GetName() const { return m_windowName; }
667 inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
668 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }
669 inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; }
670 inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
671 inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; }
672 inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
673 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
674 inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
675 inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
676 inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
677
678 inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
679 inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
680 inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
681
682 inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; }
683 inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; }
684 inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; }
685 inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
686 inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; }
687 inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
688 inline int wxWindow::GetReturnCode() { return m_returnCode; }
689
690 // Get the active window.
691 wxWindow* WXDLLEXPORT wxGetActiveWindow();
692
693 WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
694
695 // A little class to switch off size optimization while an instance of the object
696 // exists
697 class WXDLLEXPORT wxNoOptimize: public wxObject
698 {
699 public:
700 wxNoOptimize();
701 ~wxNoOptimize();
702
703 static bool CanOptimize();
704
705 protected:
706 static int m_count;
707 };
708
709 #endif
710 // _WX_WINDOW_H_