1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/window.h
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 WXDLLIMPEXP_FWD_CORE wxDC
;
24 friend class WXDLLIMPEXP_FWD_CORE 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 void SetLabel(const wxString
& label
);
53 virtual wxString
GetLabel() const;
55 virtual bool Show( bool show
= true );
56 virtual bool Enable( bool enable
= true );
58 virtual void SetFocus();
60 virtual void WarpPointer(int x
, int y
);
62 virtual void Refresh( bool eraseBackground
= true,
63 const wxRect
*rect
= (const wxRect
*) NULL
);
64 virtual void Update();
66 virtual bool SetBackgroundColour( const wxColour
&colour
);
67 virtual bool SetForegroundColour( const wxColour
&colour
);
69 virtual bool SetCursor( const wxCursor
&cursor
);
70 virtual bool SetFont( const wxFont
&font
);
72 virtual int GetCharHeight() const;
73 virtual int GetCharWidth() const;
74 virtual void GetTextExtent(const wxString
& string
,
77 int *externalLeading
= NULL
,
78 const wxFont
*theFont
= (const wxFont
*) NULL
)
81 virtual void ScrollWindow( int dx
, int dy
,
82 const wxRect
* rect
= NULL
);
84 #if wxUSE_DRAG_AND_DROP
85 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
86 #endif // wxUSE_DRAG_AND_DROP
88 // Accept files for dragging
89 virtual void DragAcceptFiles(bool accept
);
91 // Get the unique identifier of a window
92 virtual WXWindow
GetHandle() const { return GetMainWindow(); }
94 // implementation from now on
95 // --------------------------
100 // Get main X11 window
101 virtual WXWindow
GetMainWindow() const;
103 // Get X11 window representing the client area
104 virtual WXWindow
GetClientAreaWindow() const;
106 void SetLastClick(int button
, long timestamp
)
107 { m_lastButton
= button
; m_lastTS
= timestamp
; }
109 int GetLastClickedButton() const { return m_lastButton
; }
110 long GetLastClickTime() const { return m_lastTS
; }
112 // Gives window a chance to do something in response to a size message, e.g.
113 // arrange status bar, toolbar etc.
114 virtual bool PreResize();
116 // Generates paint events from m_updateRegion
117 void SendPaintEvents();
119 // Generates paint events from flag
120 void SendNcPaintEvents();
122 // Generates erase events from m_clearRegion
123 void SendEraseEvents();
125 // Clip to paint region?
126 bool GetClipPaintRegion() { return m_clipPaintRegion
; }
128 // Return clear region
129 wxRegion
&GetClearRegion() { return m_clearRegion
; }
131 void NeedUpdateNcAreaInIdle( bool update
= true ) { m_updateNcArea
= update
; }
133 // Inserting into main window instead of client
134 // window. This is mostly for a wxWindow's own
136 void SetInsertIntoMain( bool insert
= true ) { m_insertIntoMain
= insert
; }
137 bool GetInsertIntoMain() { return m_insertIntoMain
; }
139 // sets the fore/background colour for the given widget
140 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
141 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= false);
143 // I don't want users to override what's done in idle so everything that
144 // has to be done in idle time in order for wxX11 to work is done in
146 virtual void OnInternalIdle();
149 // Responds to colour changes: passes event on to children.
150 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
152 // For double-click detection
153 long m_lastTS
; // last timestamp
154 int m_lastButton
; // last pressed button
157 WXWindow m_mainWindow
;
158 WXWindow m_clientWindow
;
159 bool m_insertIntoMain
;
162 wxRegion m_clearRegion
;
163 bool m_clipPaintRegion
;
165 bool m_needsInputFocus
; // Input focus set in OnIdle
167 // implement the base class pure virtuals
168 virtual void DoClientToScreen( int *x
, int *y
) const;
169 virtual void DoScreenToClient( int *x
, int *y
) const;
170 virtual void DoGetPosition( int *x
, int *y
) const;
171 virtual void DoGetSize( int *width
, int *height
) const;
172 virtual void DoGetClientSize( int *width
, int *height
) const;
173 virtual void DoSetSize(int x
, int y
,
174 int width
, int height
,
175 int sizeFlags
= wxSIZE_AUTO
);
176 virtual void DoSetClientSize(int width
, int height
);
177 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
178 virtual void DoSetSizeHints(int minW
, int minH
,
181 virtual void DoCaptureMouse();
182 virtual void DoReleaseMouse();
185 virtual void DoSetToolTip( wxToolTip
*tip
);
186 #endif // wxUSE_TOOLTIPS
189 // common part of all ctors
192 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
193 wxDECLARE_NO_COPY_CLASS(wxWindowX11
);
194 DECLARE_EVENT_TABLE()
197 // ----------------------------------------------------------------------------
198 // A little class to switch off `size optimization' while an instance of the
199 // object exists: this may be useful to temporarily disable the optimisation
200 // which consists to do nothing when the new size is equal to the old size -
201 // although quite useful usually to avoid flicker, sometimes it leads to
202 // undesired effects.
204 // Usage: create an instance of this class on the stack to disable the size
205 // optimisation, it will be reenabled as soon as the object goes out from scope.
206 // ----------------------------------------------------------------------------
208 class WXDLLIMPEXP_CORE wxNoOptimize
211 wxNoOptimize() { ms_count
++; }
212 ~wxNoOptimize() { ms_count
--; }
214 static bool CanOptimize() { return ms_count
== 0; }
220 #endif // _WX_WINDOW_H_