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