1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/region.h"
17 // ----------------------------------------------------------------------------
18 // wxWindow class for Motif - see also wxWindowBase
19 // ----------------------------------------------------------------------------
21 class WXDLLIMPEXP_CORE wxWindowX11
: public wxWindowBase
23 friend class WXDLLEXPORT wxDC
;
24 friend class WXDLLEXPORT wxWindowDC
;
27 wxWindowX11() { Init(); }
29 wxWindowX11(wxWindow
*parent
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
34 const wxString
& name
= wxPanelNameStr
)
37 Create(parent
, id
, pos
, size
, style
, name
);
40 virtual ~wxWindowX11();
42 bool Create(wxWindow
*parent
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
47 const wxString
& name
= wxPanelNameStr
);
52 virtual bool Show( bool show
= TRUE
);
53 virtual bool Enable( bool enable
= TRUE
);
55 virtual void SetFocus();
57 virtual void WarpPointer(int x
, int y
);
59 virtual void Refresh( bool eraseBackground
= TRUE
,
60 const wxRect
*rect
= (const wxRect
*) NULL
);
61 virtual void Update();
63 virtual bool SetBackgroundColour( const wxColour
&colour
);
64 virtual bool SetForegroundColour( const wxColour
&colour
);
66 virtual bool SetCursor( const wxCursor
&cursor
);
67 virtual bool SetFont( const wxFont
&font
);
69 virtual int GetCharHeight() const;
70 virtual int GetCharWidth() const;
71 virtual void GetTextExtent(const wxString
& string
,
73 int *descent
= (int *) NULL
,
74 int *externalLeading
= (int *) NULL
,
75 const wxFont
*theFont
= (const wxFont
*) NULL
)
78 virtual void ScrollWindow( int dx
, int dy
,
79 const wxRect
* rect
= (wxRect
*) NULL
);
81 virtual void DoSetSizeHints(int minW
, int minH
,
82 int maxW
= -1, int maxH
= -1,
83 int incW
= -1, int incH
= -1);
85 #if wxUSE_DRAG_AND_DROP
86 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
87 #endif // wxUSE_DRAG_AND_DROP
89 // Accept files for dragging
90 virtual void DragAcceptFiles(bool accept
);
92 // Get the unique identifier of a window
93 virtual WXWindow
GetHandle() const { return GetMainWindow(); }
95 // implementation from now on
96 // --------------------------
101 // Get main X11 window
102 virtual WXWindow
GetMainWindow() const;
104 // Get X11 window representing the client area
105 virtual WXWindow
GetClientAreaWindow() const;
107 void SetLastClick(int button
, long timestamp
)
108 { m_lastButton
= button
; m_lastTS
= timestamp
; }
110 int GetLastClickedButton() const { return m_lastButton
; }
111 long GetLastClickTime() const { return m_lastTS
; }
113 // Gives window a chance to do something in response to a size message, e.g.
114 // arrange status bar, toolbar etc.
115 virtual bool PreResize();
117 // Generates paint events from m_updateRegion
118 void SendPaintEvents();
120 // Generates paint events from flag
121 void SendNcPaintEvents();
123 // Generates erase events from m_clearRegion
124 void SendEraseEvents();
126 // Clip to paint region?
127 bool GetClipPaintRegion() { return m_clipPaintRegion
; }
129 // Return clear region
130 wxRegion
&GetClearRegion() { return m_clearRegion
; }
132 void NeedUpdateNcAreaInIdle( bool update
= TRUE
) { m_updateNcArea
= update
; }
134 // Inserting into main window instead of client
135 // window. This is mostly for a wxWindow's own
137 void SetInsertIntoMain( bool insert
= TRUE
) { m_insertIntoMain
= insert
; }
138 bool GetInsertIntoMain() { return m_insertIntoMain
; }
140 // sets the fore/background colour for the given widget
141 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
142 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= FALSE
);
144 // I don't want users to override what's done in idle so everything that
145 // has to be done in idle time in order for wxX11 to work is done in
147 virtual void OnInternalIdle();
150 // Responds to colour changes: passes event on to children.
151 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
153 // For double-click detection
154 long m_lastTS
; // last timestamp
155 int m_lastButton
; // last pressed button
158 WXWindow m_mainWindow
;
159 WXWindow m_clientWindow
;
160 bool m_insertIntoMain
;
163 wxRegion m_clearRegion
;
164 bool m_clipPaintRegion
;
166 bool m_needsInputFocus
; // Input focus set in OnIdle
168 // implement the base class pure virtuals
169 virtual void DoClientToScreen( int *x
, int *y
) const;
170 virtual void DoScreenToClient( int *x
, int *y
) const;
171 virtual void DoGetPosition( int *x
, int *y
) const;
172 virtual void DoGetSize( int *width
, int *height
) const;
173 virtual void DoGetClientSize( int *width
, int *height
) const;
174 virtual void DoSetSize(int x
, int y
,
175 int width
, int height
,
176 int sizeFlags
= wxSIZE_AUTO
);
177 virtual void DoSetClientSize(int width
, int height
);
178 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
179 virtual void DoCaptureMouse();
180 virtual void DoReleaseMouse();
183 virtual void DoSetToolTip( wxToolTip
*tip
);
184 #endif // wxUSE_TOOLTIPS
187 // common part of all ctors
190 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
191 DECLARE_NO_COPY_CLASS(wxWindowX11
)
192 DECLARE_EVENT_TABLE()
195 // ----------------------------------------------------------------------------
196 // A little class to switch off `size optimization' while an instance of the
197 // object exists: this may be useful to temporarily disable the optimisation
198 // which consists to do nothing when the new size is equal to the old size -
199 // although quite useful usually to avoid flicker, sometimes it leads to
200 // undesired effects.
202 // Usage: create an instance of this class on the stack to disable the size
203 // optimisation, it will be reenabled as soon as the object goes out from scope.
204 // ----------------------------------------------------------------------------
206 class WXDLLEXPORT wxNoOptimize
209 wxNoOptimize() { ms_count
++; }
210 ~wxNoOptimize() { ms_count
--; }
212 static bool CanOptimize() { return ms_count
== 0; }