1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/window.h
3 // Purpose: wxWindow class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/region.h"
16 // ----------------------------------------------------------------------------
17 // wxWindow class for Motif - see also wxWindowBase
18 // ----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxWindowX11
: public wxWindowBase
22 friend class WXDLLIMPEXP_FWD_CORE wxDC
;
23 friend class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
26 wxWindowX11() { Init(); }
28 wxWindowX11(wxWindow
*parent
,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
33 const wxString
& name
= wxPanelNameStr
)
36 Create(parent
, id
, pos
, size
, style
, name
);
39 virtual ~wxWindowX11();
41 bool Create(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxPanelNameStr
);
51 virtual void SetLabel(const wxString
& label
);
52 virtual wxString
GetLabel() const;
54 virtual bool Show( bool show
= true );
55 virtual bool Enable( bool enable
= true );
57 virtual void SetFocus();
59 virtual void WarpPointer(int x
, int y
);
61 virtual void Refresh( bool eraseBackground
= true,
62 const wxRect
*rect
= (const wxRect
*) NULL
);
63 virtual void Update();
65 virtual bool SetBackgroundColour( const wxColour
&colour
);
66 virtual bool SetForegroundColour( const wxColour
&colour
);
68 virtual bool SetCursor( const wxCursor
&cursor
);
69 virtual bool SetFont( const wxFont
&font
);
71 virtual int GetCharHeight() const;
72 virtual int GetCharWidth() const;
74 virtual void ScrollWindow( int dx
, int dy
, const wxRect
* rect
= NULL
);
76 #if wxUSE_DRAG_AND_DROP
77 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
78 #endif // wxUSE_DRAG_AND_DROP
80 // Accept files for dragging
81 virtual void DragAcceptFiles(bool accept
);
83 // Get the unique identifier of a window
84 virtual WXWindow
GetHandle() const { return X11GetMainWindow(); }
86 // implementation from now on
87 // --------------------------
92 // Get main X11 window
93 virtual WXWindow
X11GetMainWindow() const;
95 // Get X11 window representing the client area
96 virtual WXWindow
GetClientAreaWindow() const;
98 void SetLastClick(int button
, long timestamp
)
99 { m_lastButton
= button
; m_lastTS
= timestamp
; }
101 int GetLastClickedButton() const { return m_lastButton
; }
102 long GetLastClickTime() const { return m_lastTS
; }
104 // Gives window a chance to do something in response to a size message, e.g.
105 // arrange status bar, toolbar etc.
106 virtual bool PreResize();
108 // Generates paint events from m_updateRegion
109 void SendPaintEvents();
111 // Generates paint events from flag
112 void SendNcPaintEvents();
114 // Generates erase events from m_clearRegion
115 void SendEraseEvents();
117 // Clip to paint region?
118 bool GetClipPaintRegion() { return m_clipPaintRegion
; }
120 // Return clear region
121 wxRegion
&GetClearRegion() { return m_clearRegion
; }
123 void NeedUpdateNcAreaInIdle( bool update
= true ) { m_updateNcArea
= update
; }
125 // Inserting into main window instead of client
126 // window. This is mostly for a wxWindow's own
128 void SetInsertIntoMain( bool insert
= true ) { m_insertIntoMain
= insert
; }
129 bool GetInsertIntoMain() { return m_insertIntoMain
; }
131 // sets the fore/background colour for the given widget
132 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
133 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= false);
135 // I don't want users to override what's done in idle so everything that
136 // has to be done in idle time in order for wxX11 to work is done in
138 virtual void OnInternalIdle();
141 // Responds to colour changes: passes event on to children.
142 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
144 // For double-click detection
145 long m_lastTS
; // last timestamp
146 int m_lastButton
; // last pressed button
149 WXWindow m_mainWindow
;
150 WXWindow m_clientWindow
;
151 bool m_insertIntoMain
;
154 wxRegion m_clearRegion
;
155 bool m_clipPaintRegion
;
157 bool m_needsInputFocus
; // Input focus set in OnIdle
159 // implement the base class pure virtuals
160 virtual void DoGetTextExtent(const wxString
& string
,
163 int *externalLeading
= NULL
,
164 const wxFont
*font
= NULL
) const;
165 virtual void DoClientToScreen( int *x
, int *y
) const;
166 virtual void DoScreenToClient( int *x
, int *y
) const;
167 virtual void DoGetPosition( int *x
, int *y
) const;
168 virtual void DoGetSize( int *width
, int *height
) const;
169 virtual void DoGetClientSize( int *width
, int *height
) const;
170 virtual void DoSetSize(int x
, int y
,
171 int width
, int height
,
172 int sizeFlags
= wxSIZE_AUTO
);
173 virtual void DoSetClientSize(int width
, int height
);
174 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
175 virtual void DoSetSizeHints(int minW
, int minH
,
178 virtual void DoCaptureMouse();
179 virtual void DoReleaseMouse();
182 virtual void DoSetToolTip( wxToolTip
*tip
);
183 #endif // wxUSE_TOOLTIPS
186 // common part of all ctors
189 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
190 wxDECLARE_NO_COPY_CLASS(wxWindowX11
);
191 DECLARE_EVENT_TABLE()
194 // ----------------------------------------------------------------------------
195 // A little class to switch off `size optimization' while an instance of the
196 // object exists: this may be useful to temporarily disable the optimisation
197 // which consists to do nothing when the new size is equal to the old size -
198 // although quite useful usually to avoid flicker, sometimes it leads to
199 // undesired effects.
201 // Usage: create an instance of this class on the stack to disable the size
202 // optimisation, it will be reenabled as soon as the object goes out from scope.
203 // ----------------------------------------------------------------------------
205 class WXDLLIMPEXP_CORE wxNoOptimize
208 wxNoOptimize() { ms_count
++; }
209 ~wxNoOptimize() { ms_count
--; }
211 static bool CanOptimize() { return ms_count
== 0; }
217 #endif // _WX_WINDOW_H_