]>
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 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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();
67 virtual bool SetBackgroundColour( const wxColour
&colour
);
68 virtual bool SetForegroundColour( const wxColour
&colour
);
70 virtual bool SetCursor( const wxCursor
&cursor
);
71 virtual bool SetFont( const wxFont
&font
);
73 virtual int GetCharHeight() const;
74 virtual int GetCharWidth() const;
75 virtual void GetTextExtent(const wxString
& string
,
77 int *descent
= (int *) NULL
,
78 int *externalLeading
= (int *) NULL
,
79 const wxFont
*theFont
= (const wxFont
*) NULL
)
82 virtual void ScrollWindow( int dx
, int dy
,
83 const wxRect
* rect
= (wxRect
*) NULL
);
85 virtual void SetSizeHints(int minW
, int minH
,
86 int maxW
= -1, int maxH
= -1,
87 int incW
= -1, int incH
= -1);
88 void SetSizeHints( const wxSize
& minSize
,
89 const wxSize
& maxSize
=wxDefaultSize
,
90 const wxSize
& incSize
=wxDefaultSize
)
91 { wxWindowBase::SetSizeHints(minSize
, maxSize
, incSize
); }
92 #if wxUSE_DRAG_AND_DROP
93 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
94 #endif // wxUSE_DRAG_AND_DROP
96 // Accept files for dragging
97 virtual void DragAcceptFiles(bool accept
);
99 // Get the unique identifier of a window
100 virtual WXWindow
GetHandle() const { return GetMainWindow(); }
102 // implementation from now on
103 // --------------------------
108 // Get main X11 window
109 virtual WXWindow
GetMainWindow() const;
111 // Get X11 window representing the client area
112 virtual WXWindow
GetClientAreaWindow() const;
114 void SetLastClick(int button
, long timestamp
)
115 { m_lastButton
= button
; m_lastTS
= timestamp
; }
117 int GetLastClickedButton() const { return m_lastButton
; }
118 long GetLastClickTime() const { return m_lastTS
; }
120 // Gives window a chance to do something in response to a size message, e.g.
121 // arrange status bar, toolbar etc.
122 virtual bool PreResize();
124 // Generates paint events from m_updateRegion
125 void SendPaintEvents();
127 // Generates paint events from flag
128 void SendNcPaintEvents();
130 // Generates erase events from m_clearRegion
131 void SendEraseEvents();
133 // Clip to paint region?
134 bool GetClipPaintRegion() { return m_clipPaintRegion
; }
136 // Return clear region
137 wxRegion
&GetClearRegion() { return m_clearRegion
; }
139 void NeedUpdateNcAreaInIdle( bool update
= TRUE
) { m_updateNcArea
= update
; }
141 // Inserting into main window instead of client
142 // window. This is mostly for a wxWindow's own
144 void SetInsertIntoMain( bool insert
= TRUE
) { m_insertIntoMain
= insert
; }
145 bool GetInsertIntoMain() { return m_insertIntoMain
; }
147 // sets the fore/background colour for the given widget
148 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
149 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= FALSE
);
151 // For implementation purposes - sometimes decorations make the client area
153 virtual wxPoint
GetClientAreaOrigin() const;
155 // I don't want users to override what's done in idle so everything that
156 // has to be done in idle time in order for wxX11 to work is done in
158 virtual void OnInternalIdle();
161 // Responds to colour changes: passes event on to children.
162 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
164 // For double-click detection
165 long m_lastTS
; // last timestamp
166 int m_lastButton
; // last pressed button
169 WXWindow m_mainWindow
;
170 WXWindow m_clientWindow
;
171 bool m_insertIntoMain
;
174 wxRegion m_clearRegion
;
175 bool m_clipPaintRegion
;
177 bool m_needsInputFocus
; // Input focus set in OnIdle
179 // implement the base class pure virtuals
180 virtual void DoClientToScreen( int *x
, int *y
) const;
181 virtual void DoScreenToClient( int *x
, int *y
) const;
182 virtual void DoGetPosition( int *x
, int *y
) const;
183 virtual void DoGetSize( int *width
, int *height
) const;
184 virtual void DoGetClientSize( int *width
, int *height
) const;
185 virtual void DoSetSize(int x
, int y
,
186 int width
, int height
,
187 int sizeFlags
= wxSIZE_AUTO
);
188 virtual void DoSetClientSize(int width
, int height
);
189 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
190 virtual void DoCaptureMouse();
191 virtual void DoReleaseMouse();
194 virtual void DoSetToolTip( wxToolTip
*tip
);
195 #endif // wxUSE_TOOLTIPS
198 // common part of all ctors
201 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
202 DECLARE_NO_COPY_CLASS(wxWindowX11
)
203 DECLARE_EVENT_TABLE()
206 // ----------------------------------------------------------------------------
207 // A little class to switch off `size optimization' while an instance of the
208 // object exists: this may be useful to temporarily disable the optimisation
209 // which consists to do nothing when the new size is equal to the old size -
210 // although quite useful usually to avoid flicker, sometimes it leads to
211 // undesired effects.
213 // Usage: create an instance of this class on the stack to disable the size
214 // optimisation, it will be reenabled as soon as the object goes out from scope.
215 // ----------------------------------------------------------------------------
217 class WXDLLEXPORT wxNoOptimize
220 wxNoOptimize() { ms_count
++; }
221 ~wxNoOptimize() { ms_count
--; }
223 static bool CanOptimize() { return ms_count
== 0; }