]>
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(__APPLE__)
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 ScrollWindow( int dx
, int dy
,
85 const wxRect
* rect
= (wxRect
*) NULL
);
87 virtual void SetSizeHints(int minW
, int minH
,
88 int maxW
= -1, int maxH
= -1,
89 int incW
= -1, int incH
= -1);
90 #if wxUSE_DRAG_AND_DROP
91 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
92 #endif // wxUSE_DRAG_AND_DROP
94 // Accept files for dragging
95 virtual void DragAcceptFiles(bool accept
);
97 // Get the unique identifier of a window
98 virtual WXWindow
GetHandle() const { return GetMainWindow(); }
100 // implementation from now on
101 // --------------------------
106 // Get main X11 window
107 virtual WXWindow
GetMainWindow() const;
109 // Get X11 window representing the client area
110 virtual WXWindow
GetClientAreaWindow() const;
112 void SetLastClick(int button
, long timestamp
)
113 { m_lastButton
= button
; m_lastTS
= timestamp
; }
115 int GetLastClickedButton() const { return m_lastButton
; }
116 long GetLastClickTime() const { return m_lastTS
; }
118 // Gives window a chance to do something in response to a size message, e.g.
119 // arrange status bar, toolbar etc.
120 virtual bool PreResize();
122 // Generates paint events from m_updateRegion
123 void SendPaintEvents();
125 // Generates paint events from flag
126 void SendNcPaintEvents();
128 // Generates erase events from m_clearRegion
129 void SendEraseEvents();
131 // Clip to paint region?
132 bool GetClipPaintRegion() { return m_clipPaintRegion
; }
134 // Return clear region
135 wxRegion
&GetClearRegion() { return m_clearRegion
; }
137 void NeedUpdateNcAreaInIdle( bool update
= TRUE
) { m_updateNcArea
= update
; }
139 // Inserting into main window instead of client
140 // window. This is mostly for a wxWindow's own
142 void SetInsertIntoMain( bool insert
= TRUE
) { m_insertIntoMain
= insert
; }
143 bool GetInsertIntoMain() { return m_insertIntoMain
; }
145 // sets the fore/background colour for the given widget
146 static void DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
);
147 static void DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
= FALSE
);
149 // For implementation purposes - sometimes decorations make the client area
151 virtual wxPoint
GetClientAreaOrigin() const;
153 // I don't want users to override what's done in idle so everything that
154 // has to be done in idle time in order for wxX11 to work is done in
156 virtual void OnInternalIdle();
159 // Responds to colour changes: passes event on to children.
160 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
162 // For double-click detection
163 long m_lastTS
; // last timestamp
164 int m_lastButton
; // last pressed button
167 WXWindow m_mainWindow
;
168 WXWindow m_clientWindow
;
169 bool m_insertIntoMain
;
172 wxRegion m_clearRegion
;
173 bool m_clipPaintRegion
;
175 bool m_needsInputFocus
; // Input focus set in OnIdle
177 // implement the base class pure virtuals
178 virtual void DoClientToScreen( int *x
, int *y
) const;
179 virtual void DoScreenToClient( int *x
, int *y
) const;
180 virtual void DoGetPosition( int *x
, int *y
) const;
181 virtual void DoGetSize( int *width
, int *height
) const;
182 virtual void DoGetClientSize( int *width
, int *height
) const;
183 virtual void DoSetSize(int x
, int y
,
184 int width
, int height
,
185 int sizeFlags
= wxSIZE_AUTO
);
186 virtual void DoSetClientSize(int width
, int height
);
187 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
188 virtual void DoCaptureMouse();
189 virtual void DoReleaseMouse();
192 virtual void DoSetToolTip( wxToolTip
*tip
);
193 #endif // wxUSE_TOOLTIPS
196 // common part of all ctors
199 DECLARE_DYNAMIC_CLASS(wxWindowX11
)
200 DECLARE_NO_COPY_CLASS(wxWindowX11
)
201 DECLARE_EVENT_TABLE()
204 // ----------------------------------------------------------------------------
205 // A little class to switch off `size optimization' while an instance of the
206 // object exists: this may be useful to temporarily disable the optimisation
207 // which consists to do nothing when the new size is equal to the old size -
208 // although quite useful usually to avoid flicker, sometimes it leads to
209 // undesired effects.
211 // Usage: create an instance of this class on the stack to disable the size
212 // optimisation, it will be reenabled as soon as the object goes out from scope.
213 // ----------------------------------------------------------------------------
215 class WXDLLEXPORT wxNoOptimize
218 wxNoOptimize() { ms_count
++; }
219 ~wxNoOptimize() { ms_count
--; }
221 static bool CanOptimize() { return ms_count
== 0; }