]>
Commit | Line | Data |
---|---|---|
83df96d6 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
3 | // Purpose: wxWindow class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_WINDOW_H_ | |
13 | #define _WX_WINDOW_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "window.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/region.h" | |
20 | ||
21 | // ---------------------------------------------------------------------------- | |
22 | // wxWindow class for Motif - see also wxWindowBase | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
bc797f4c | 25 | class wxWindowX11 : public wxWindowBase |
83df96d6 JS |
26 | { |
27 | friend class WXDLLEXPORT wxDC; | |
28 | friend class WXDLLEXPORT wxWindowDC; | |
29 | ||
30 | public: | |
bc797f4c | 31 | wxWindowX11() { Init(); } |
83df96d6 | 32 | |
bc797f4c | 33 | wxWindowX11(wxWindow *parent, |
83df96d6 JS |
34 | wxWindowID id, |
35 | const wxPoint& pos = wxDefaultPosition, | |
36 | const wxSize& size = wxDefaultSize, | |
37 | long style = 0, | |
38 | const wxString& name = wxPanelNameStr) | |
39 | { | |
40 | Init(); | |
41 | Create(parent, id, pos, size, style, name); | |
42 | } | |
43 | ||
f79bd02d | 44 | virtual ~wxWindowX11(); |
83df96d6 JS |
45 | |
46 | bool Create(wxWindow *parent, | |
47 | wxWindowID id, | |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | long style = 0, | |
51 | const wxString& name = wxPanelNameStr); | |
52 | ||
83df96d6 JS |
53 | virtual void Raise(); |
54 | virtual void Lower(); | |
55 | ||
56 | virtual bool Show( bool show = TRUE ); | |
57 | virtual bool Enable( bool enable = TRUE ); | |
58 | ||
59 | virtual void SetFocus(); | |
60 | ||
61 | virtual void WarpPointer(int x, int y); | |
62 | ||
63 | virtual void Refresh( bool eraseBackground = TRUE, | |
64 | const wxRect *rect = (const wxRect *) NULL ); | |
d02cb44e RR |
65 | virtual void Update(); |
66 | ||
83df96d6 JS |
67 | virtual void Clear(); |
68 | ||
69 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
70 | virtual bool SetForegroundColour( const wxColour &colour ); | |
71 | ||
72 | virtual bool SetCursor( const wxCursor &cursor ); | |
73 | virtual bool SetFont( const wxFont &font ); | |
74 | ||
75 | virtual int GetCharHeight() const; | |
76 | virtual int GetCharWidth() const; | |
77 | virtual void GetTextExtent(const wxString& string, | |
78 | int *x, int *y, | |
79 | int *descent = (int *) NULL, | |
80 | int *externalLeading = (int *) NULL, | |
81 | const wxFont *theFont = (const wxFont *) NULL) | |
82 | const; | |
83 | ||
83df96d6 JS |
84 | virtual void ScrollWindow( int dx, int dy, |
85 | const wxRect* rect = (wxRect *) NULL ); | |
86 | ||
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 | |
93 | ||
94 | // Accept files for dragging | |
95 | virtual void DragAcceptFiles(bool accept); | |
96 | ||
97 | // Get the unique identifier of a window | |
bc797f4c | 98 | virtual WXWindow GetHandle() const { return GetMainWindow(); } |
83df96d6 JS |
99 | |
100 | // implementation from now on | |
101 | // -------------------------- | |
102 | ||
103 | // accessors | |
104 | // --------- | |
105 | ||
ab6b6b15 | 106 | // Get main X11 window |
bc797f4c | 107 | virtual WXWindow GetMainWindow() const; |
83df96d6 | 108 | |
ab6b6b15 RR |
109 | // Get X11 window representing the client area |
110 | virtual WXWindow GetClientWindow() const; | |
83df96d6 | 111 | |
83df96d6 | 112 | void SetLastClick(int button, long timestamp) |
ba696cfa | 113 | { m_lastButton = button; m_lastTS = timestamp; } |
83df96d6 JS |
114 | |
115 | int GetLastClickedButton() const { return m_lastButton; } | |
116 | long GetLastClickTime() const { return m_lastTS; } | |
117 | ||
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(); | |
121 | ||
887dd52f RR |
122 | // Generates paint events from m_updateRegion |
123 | void SendPaintEvents(); | |
124 | ||
ab6b6b15 RR |
125 | // Generates paint events from flag |
126 | void SendNcPaintEvents(); | |
127 | ||
887dd52f RR |
128 | // Generates erase events from m_clearRegion |
129 | void SendEraseEvents(); | |
83df96d6 | 130 | |
3cd0b8c5 RR |
131 | // Clip to paint region? |
132 | bool GetClipPaintRegion() { return m_clipPaintRegion; } | |
133 | ||
ba696cfa RR |
134 | // Return clear region |
135 | wxRegion &GetClearRegion() { return m_clearRegion; } | |
136 | ||
ab6b6b15 RR |
137 | void NeedUpdateNcAreaInIdle( bool update = TRUE ) { m_updateNcArea = update; } |
138 | ||
139 | // Inserting into main window instead of client | |
140 | // window. This is mostly for a wxWindow's own | |
141 | // scrollbars. | |
142 | void SetInsertIntoMain( bool insert = TRUE ) { m_insertIntoMain = insert; } | |
143 | bool GetInsertIntoMain() { return m_insertIntoMain; } | |
144 | ||
83df96d6 | 145 | // sets the fore/background colour for the given widget |
bc797f4c JS |
146 | static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour); |
147 | static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE); | |
83df96d6 JS |
148 | |
149 | // For implementation purposes - sometimes decorations make the client area | |
150 | // smaller | |
151 | virtual wxPoint GetClientAreaOrigin() const; | |
152 | ||
0d1dff01 RR |
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 | |
155 | // OnInternalIdle | |
156 | virtual void OnInternalIdle(); | |
157 | ||
158 | // For compatibility across platforms (not in event table) | |
159 | void OnIdle(wxIdleEvent& WXUNUSED(event)) {} | |
83df96d6 | 160 | |
0d1dff01 | 161 | protected: |
83df96d6 JS |
162 | // Responds to colour changes: passes event on to children. |
163 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
164 | ||
83df96d6 JS |
165 | // For double-click detection |
166 | long m_lastTS; // last timestamp | |
167 | int m_lastButton; // last pressed button | |
168 | ||
83df96d6 | 169 | protected: |
ab6b6b15 RR |
170 | WXWindow m_mainWindow; |
171 | WXWindow m_clientWindow; | |
172 | bool m_insertIntoMain; | |
173 | ||
174 | bool m_winCaptured; | |
1934d291 RR |
175 | wxRegion m_clearRegion; |
176 | bool m_clipPaintRegion; | |
ab6b6b15 | 177 | bool m_updateNcArea; |
3a0b23eb | 178 | bool m_needsInputFocus; // Input focus set in OnIdle |
b513212d | 179 | |
83df96d6 JS |
180 | // implement the base class pure virtuals |
181 | virtual void DoClientToScreen( int *x, int *y ) const; | |
182 | virtual void DoScreenToClient( int *x, int *y ) const; | |
183 | virtual void DoGetPosition( int *x, int *y ) const; | |
184 | virtual void DoGetSize( int *width, int *height ) const; | |
185 | virtual void DoGetClientSize( int *width, int *height ) const; | |
186 | virtual void DoSetSize(int x, int y, | |
187 | int width, int height, | |
188 | int sizeFlags = wxSIZE_AUTO); | |
189 | virtual void DoSetClientSize(int width, int height); | |
190 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
83df96d6 JS |
191 | virtual void DoCaptureMouse(); |
192 | virtual void DoReleaseMouse(); | |
7edcafa4 | 193 | |
83df96d6 JS |
194 | #if wxUSE_TOOLTIPS |
195 | virtual void DoSetToolTip( wxToolTip *tip ); | |
196 | #endif // wxUSE_TOOLTIPS | |
197 | ||
198 | private: | |
199 | // common part of all ctors | |
200 | void Init(); | |
201 | ||
bc797f4c JS |
202 | DECLARE_DYNAMIC_CLASS(wxWindowX11) |
203 | DECLARE_NO_COPY_CLASS(wxWindowX11) | |
83df96d6 JS |
204 | DECLARE_EVENT_TABLE() |
205 | }; | |
206 | ||
207 | // ---------------------------------------------------------------------------- | |
208 | // A little class to switch off `size optimization' while an instance of the | |
209 | // object exists: this may be useful to temporarily disable the optimisation | |
210 | // which consists to do nothing when the new size is equal to the old size - | |
211 | // although quite useful usually to avoid flicker, sometimes it leads to | |
212 | // undesired effects. | |
213 | // | |
214 | // Usage: create an instance of this class on the stack to disable the size | |
215 | // optimisation, it will be reenabled as soon as the object goes out from scope. | |
216 | // ---------------------------------------------------------------------------- | |
217 | ||
218 | class WXDLLEXPORT wxNoOptimize | |
219 | { | |
220 | public: | |
221 | wxNoOptimize() { ms_count++; } | |
222 | ~wxNoOptimize() { ms_count--; } | |
223 | ||
224 | static bool CanOptimize() { return ms_count == 0; } | |
225 | ||
226 | protected: | |
227 | static int ms_count; | |
228 | }; | |
229 | ||
230 | #endif | |
231 | // _WX_WINDOW_H_ |