]>
Commit | Line | Data |
---|---|---|
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 | #include "wx/region.h" | |
16 | ||
17 | // ---------------------------------------------------------------------------- | |
18 | // wxWindow class for Motif - see also wxWindowBase | |
19 | // ---------------------------------------------------------------------------- | |
20 | ||
21 | class WXDLLIMPEXP_CORE wxWindowX11 : public wxWindowBase | |
22 | { | |
23 | friend class WXDLLEXPORT wxDC; | |
24 | friend class WXDLLEXPORT wxWindowDC; | |
25 | ||
26 | public: | |
27 | wxWindowX11() { Init(); } | |
28 | ||
29 | wxWindowX11(wxWindow *parent, | |
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 | ||
40 | virtual ~wxWindowX11(); | |
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 | ||
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 ); | |
61 | virtual void Update(); | |
62 | ||
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 | ||
78 | virtual void ScrollWindow( int dx, int dy, | |
79 | const wxRect* rect = (wxRect *) NULL ); | |
80 | ||
81 | virtual void DoSetSizeHints(int minW, int minH, | |
82 | int maxW = -1, int maxH = -1, | |
83 | int incW = -1, int incH = -1); | |
84 | ||
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 | |
93 | virtual WXWindow GetHandle() const { return GetMainWindow(); } | |
94 | ||
95 | // implementation from now on | |
96 | // -------------------------- | |
97 | ||
98 | // accessors | |
99 | // --------- | |
100 | ||
101 | // Get main X11 window | |
102 | virtual WXWindow GetMainWindow() const; | |
103 | ||
104 | // Get X11 window representing the client area | |
105 | virtual WXWindow GetClientAreaWindow() const; | |
106 | ||
107 | void SetLastClick(int button, long timestamp) | |
108 | { m_lastButton = button; m_lastTS = timestamp; } | |
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 | ||
117 | // Generates paint events from m_updateRegion | |
118 | void SendPaintEvents(); | |
119 | ||
120 | // Generates paint events from flag | |
121 | void SendNcPaintEvents(); | |
122 | ||
123 | // Generates erase events from m_clearRegion | |
124 | void SendEraseEvents(); | |
125 | ||
126 | // Clip to paint region? | |
127 | bool GetClipPaintRegion() { return m_clipPaintRegion; } | |
128 | ||
129 | // Return clear region | |
130 | wxRegion &GetClearRegion() { return m_clearRegion; } | |
131 | ||
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 | ||
140 | // sets the fore/background colour for the given widget | |
141 | static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour); | |
142 | static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE); | |
143 | ||
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 | ||
149 | protected: | |
150 | // Responds to colour changes: passes event on to children. | |
151 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
152 | ||
153 | // For double-click detection | |
154 | long m_lastTS; // last timestamp | |
155 | int m_lastButton; // last pressed button | |
156 | ||
157 | protected: | |
158 | WXWindow m_mainWindow; | |
159 | WXWindow m_clientWindow; | |
160 | bool m_insertIntoMain; | |
161 | ||
162 | bool m_winCaptured; | |
163 | wxRegion m_clearRegion; | |
164 | bool m_clipPaintRegion; | |
165 | bool m_updateNcArea; | |
166 | bool m_needsInputFocus; // Input focus set in OnIdle | |
167 | ||
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); | |
179 | virtual void DoCaptureMouse(); | |
180 | virtual void DoReleaseMouse(); | |
181 | ||
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 | ||
190 | DECLARE_DYNAMIC_CLASS(wxWindowX11) | |
191 | DECLARE_NO_COPY_CLASS(wxWindowX11) | |
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_ |