]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/window.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "window.h"
19 #include "wx/region.h"
21 // ----------------------------------------------------------------------------
22 // wxWindow class for Motif - see also wxWindowBase
23 // ----------------------------------------------------------------------------
25 class wxWindowX11
: public wxWindowBase
27 friend class WXDLLEXPORT wxDC
;
28 friend class WXDLLEXPORT wxWindowDC
;
31 wxWindowX11() { Init(); }
33 wxWindowX11(wxWindow
*parent
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
38 const wxString
& name
= wxPanelNameStr
)
41 Create(parent
, id
, pos
, size
, style
, name
);
44 virtual ~wxWindowX11();
46 bool Create(wxWindow
*parent
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
51 const wxString
& name
= wxPanelNameStr
);
56 virtual bool Show( bool show
= TRUE
);
57 virtual bool Enable( bool enable
= TRUE
);
59 virtual void SetFocus();
61 virtual void WarpPointer(int x
, int y
);
63 virtual void Refresh( bool eraseBackground
= TRUE
,
64 const wxRect
*rect
= (const wxRect
*) NULL
);
65 virtual void Update();
69 virtual bool SetBackgroundColour( const wxColour
&colour
);
70 virtual bool SetForegroundColour( const wxColour
&colour
);
72 virtual bool SetCursor( const wxCursor
&cursor
);
73 virtual bool SetFont( const wxFont
&font
);
75 virtual int GetCharHeight() const;
76 virtual int GetCharWidth() const;
77 virtual void GetTextExtent(const wxString
& string
,
79 int *descent
= (int *) NULL
,
80 int *externalLeading
= (int *) NULL
,
81 const wxFont
*theFont
= (const wxFont
*) NULL
)
84 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
85 int range
, bool refresh
= TRUE
);
86 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
87 virtual int GetScrollPos( int orient
) const;
88 virtual int GetScrollThumb( int orient
) const;
89 virtual int GetScrollRange( int orient
) const;
90 virtual void ScrollWindow( int dx
, int dy
,
91 const wxRect
* rect
= (wxRect
*) NULL
);
93 virtual void SetSizeHints(int minW
, int minH
,
94 int maxW
= -1, int maxH
= -1,
95 int incW
= -1, int incH
= -1);
96 #if wxUSE_DRAG_AND_DROP
97 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
98 #endif // wxUSE_DRAG_AND_DROP
100 // Accept files for dragging
101 virtual void DragAcceptFiles(bool accept
);
103 // Get the unique identifier of a window
104 virtual WXWindow
GetHandle() const { return GetMainWindow(); }
106 // implementation from now on
107 // --------------------------
112 // Get main widget for this window, e.g. a text widget
113 virtual WXWindow
GetMainWindow() const;
115 // Get the underlying X window and display
116 WXWindow
GetXWindow() const;
117 WXDisplay
*GetXDisplay() const;
119 void SetLastClick(int button
, long timestamp
)
120 { m_lastButton
= button
; m_lastTS
= timestamp
; }
122 int GetLastClickedButton() const { return m_lastButton
; }
123 long GetLastClickTime() const { return m_lastTS
; }
125 // Gives window a chance to do something in response to a size message, e.g.
126 // arrange status bar, toolbar etc.
127 virtual bool PreResize();
129 // Generates paint events
130 void X11SendPaintEvents();
132 // sets the fore/background colour for the given widget
133 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
134 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= FALSE
);
136 // For implementation purposes - sometimes decorations make the client area
138 virtual wxPoint
GetClientAreaOrigin() const;
141 // event handlers (not virtual by design)
142 void OnIdle(wxIdleEvent
& event
);
144 // Makes an adjustment to the window position (for example, a frame that has
145 // a toolbar that it manages itself).
146 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
148 // Responds to colour changes: passes event on to children.
149 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
151 // For double-click detection
152 long m_lastTS
; // last timestamp
153 int m_lastButton
; // last pressed button
156 WXWindow m_mainWidget
;
158 wxRegion m_clearRegion
;
159 bool m_clipPaintRegion
;
161 bool m_winCaptured
; // ????
163 // implement the base class pure virtuals
164 virtual void DoClientToScreen( int *x
, int *y
) const;
165 virtual void DoScreenToClient( int *x
, int *y
) const;
166 virtual void DoGetPosition( int *x
, int *y
) const;
167 virtual void DoGetSize( int *width
, int *height
) const;
168 virtual void DoGetClientSize( int *width
, int *height
) const;
169 virtual void DoSetSize(int x
, int y
,
170 int width
, int height
,
171 int sizeFlags
= wxSIZE_AUTO
);
172 virtual void DoSetClientSize(int width
, int height
);
173 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
174 virtual bool DoPopupMenu(wxMenu
*menu
, int x
, int y
);
176 virtual void DoCaptureMouse();
177 virtual void DoReleaseMouse();
180 virtual void DoSetToolTip( wxToolTip
*tip
);
181 #endif // wxUSE_TOOLTIPS
184 // common part of all ctors
187 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
188 DECLARE_NO_COPY_CLASS(wxWindowX11
)
189 DECLARE_EVENT_TABLE()
192 // ----------------------------------------------------------------------------
193 // A little class to switch off `size optimization' while an instance of the
194 // object exists: this may be useful to temporarily disable the optimisation
195 // which consists to do nothing when the new size is equal to the old size -
196 // although quite useful usually to avoid flicker, sometimes it leads to
197 // undesired effects.
199 // Usage: create an instance of this class on the stack to disable the size
200 // optimisation, it will be reenabled as soon as the object goes out from scope.
201 // ----------------------------------------------------------------------------
203 class WXDLLEXPORT wxNoOptimize
206 wxNoOptimize() { ms_count
++; }
207 ~wxNoOptimize() { ms_count
--; }
209 static bool CanOptimize() { return ms_count
== 0; }