]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.h | |
3 | // Purpose: wxWindow class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
cc2b7472 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_WINDOW_H_ |
13 | #define _WX_WINDOW_H_ | |
2bda0e17 | 14 | |
cc2b7472 VZ |
15 | // --------------------------------------------------------------------------- |
16 | // headers | |
17 | // --------------------------------------------------------------------------- | |
18 | ||
2bda0e17 | 19 | #ifdef __GNUG__ |
cc2b7472 | 20 | #pragma interface "window.h" |
2bda0e17 KB |
21 | #endif |
22 | ||
cc2b7472 VZ |
23 | // windows.h #defines the following identifiers which are also used in wxWin |
24 | #ifdef GetCharWidth | |
25 | #undef GetCharWidth | |
2bda0e17 KB |
26 | #endif |
27 | ||
cc2b7472 VZ |
28 | #ifdef FindWindow |
29 | #undef FindWindow | |
2bda0e17 KB |
30 | #endif |
31 | ||
cc2b7472 VZ |
32 | // --------------------------------------------------------------------------- |
33 | // forward declarations | |
34 | // --------------------------------------------------------------------------- | |
2bda0e17 | 35 | |
cc2b7472 | 36 | class WXDLLEXPORT wxButton; |
2bda0e17 | 37 | |
cc2b7472 VZ |
38 | // --------------------------------------------------------------------------- |
39 | // constants | |
40 | // --------------------------------------------------------------------------- | |
1e6d9499 | 41 | |
cc2b7472 VZ |
42 | // FIXME does anybody use those? they're unused by wxWindows... |
43 | enum | |
1e6d9499 | 44 | { |
cc2b7472 VZ |
45 | wxKEY_SHIFT = 1, |
46 | wxKEY_CTRL = 2 | |
1e6d9499 JS |
47 | }; |
48 | ||
cc2b7472 VZ |
49 | // --------------------------------------------------------------------------- |
50 | // wxWindow declaration for MSW | |
51 | // --------------------------------------------------------------------------- | |
52 | class WXDLLEXPORT wxWindow : public wxWindowBase | |
1e6d9499 | 53 | { |
cc2b7472 | 54 | DECLARE_DYNAMIC_CLASS(wxWindow); |
2bda0e17 KB |
55 | |
56 | public: | |
cc2b7472 VZ |
57 | wxWindow() { Init(); } |
58 | ||
59 | wxWindow(wxWindow *parent, | |
60 | wxWindowID id, | |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, | |
63 | long style = 0, | |
64 | const wxString& name = wxPanelNameStr) | |
bfc6fde4 VZ |
65 | { |
66 | Init(); | |
67 | Create(parent, id, pos, size, style, name); | |
68 | } | |
2bda0e17 | 69 | |
bfc6fde4 | 70 | virtual ~wxWindow(); |
2bda0e17 | 71 | |
cc2b7472 VZ |
72 | bool Create(wxWindow *parent, |
73 | wxWindowID id, | |
74 | const wxPoint& pos = wxDefaultPosition, | |
75 | const wxSize& size = wxDefaultSize, | |
76 | long style = 0, | |
77 | const wxString& name = wxPanelNameStr); | |
bfc6fde4 | 78 | |
cc2b7472 | 79 | // implement base class pure virtuals |
bfc6fde4 | 80 | virtual void Raise(); |
bfc6fde4 VZ |
81 | virtual void Lower(); |
82 | ||
cc2b7472 VZ |
83 | virtual bool Show( bool show = TRUE ); |
84 | virtual bool Enable( bool enable = TRUE ); | |
bfc6fde4 | 85 | |
cc2b7472 | 86 | virtual void SetFocus(); |
bfc6fde4 | 87 | |
cc2b7472 | 88 | virtual bool Reparent( wxWindow *newParent ); |
bfc6fde4 | 89 | |
cc2b7472 VZ |
90 | virtual void WarpPointer(int x, int y); |
91 | virtual void CaptureMouse(); | |
92 | virtual void ReleaseMouse(); | |
bfc6fde4 | 93 | |
cc2b7472 VZ |
94 | virtual void Refresh( bool eraseBackground = TRUE, |
95 | const wxRect *rect = (const wxRect *) NULL ); | |
96 | virtual void Clear(); | |
bfc6fde4 | 97 | |
cc2b7472 VZ |
98 | virtual bool SetCursor( const wxCursor &cursor ); |
99 | virtual bool SetFont( const wxFont &font ); | |
bfc6fde4 | 100 | |
bfc6fde4 VZ |
101 | virtual int GetCharHeight() const; |
102 | virtual int GetCharWidth() const; | |
cc2b7472 VZ |
103 | virtual void GetTextExtent(const wxString& string, |
104 | int *x, int *y, | |
105 | int *descent = (int *) NULL, | |
106 | int *externalLeading = (int *) NULL, | |
107 | const wxFont *theFont = (const wxFont *) NULL) | |
108 | const; | |
109 | ||
110 | virtual void ClientToScreen( int *x, int *y ) const; | |
111 | virtual void ScreenToClient( int *x, int *y ) const; | |
112 | ||
113 | virtual bool PopupMenu( wxMenu *menu, int x, int y ); | |
114 | ||
115 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
116 | int range, bool refresh = TRUE ); | |
117 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); | |
118 | virtual int GetScrollPos( int orient ) const; | |
119 | virtual int GetScrollThumb( int orient ) const; | |
120 | virtual int GetScrollRange( int orient ) const; | |
121 | virtual void ScrollWindow( int dx, int dy, | |
122 | const wxRect* rect = (wxRect *) NULL ); | |
2bda0e17 | 123 | |
47d67540 | 124 | #if wxUSE_DRAG_AND_DROP |
cc2b7472 VZ |
125 | virtual void SetDropTarget( wxDropTarget *dropTarget ); |
126 | #endif // wxUSE_DRAG_AND_DROP | |
9f3362c4 | 127 | |
bfc6fde4 VZ |
128 | // Accept files for dragging |
129 | virtual void DragAcceptFiles(bool accept); | |
2bda0e17 | 130 | |
2bda0e17 | 131 | #if WXWIN_COMPATIBILITY |
bfc6fde4 VZ |
132 | // Set/get scroll attributes |
133 | virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); | |
134 | virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); | |
135 | virtual int OldGetScrollRange(int orient) const; | |
136 | virtual int GetScrollPage(int orient) const; | |
cc2b7472 | 137 | #endif // WXWIN_COMPATIBILITY |
bfc6fde4 | 138 | |
cc2b7472 | 139 | // caret manipulation (MSW only) |
bfc6fde4 VZ |
140 | virtual void CreateCaret(int w, int h); |
141 | virtual void CreateCaret(const wxBitmap *bitmap); | |
142 | virtual void DestroyCaret(); | |
143 | virtual void ShowCaret(bool show); | |
144 | virtual void SetCaretPos(int x, int y); | |
145 | virtual void GetCaretPos(int *x, int *y) const; | |
146 | ||
cc2b7472 VZ |
147 | // event handlers (FIXME: shouldn't they be inside WXWIN_COMPATIBILITY?) |
148 | // Handle a control command | |
bfc6fde4 VZ |
149 | virtual void OnCommand(wxWindow& win, wxCommandEvent& event); |
150 | ||
cc2b7472 VZ |
151 | // Override to define new behaviour for default action (e.g. double |
152 | // clicking on a listbox) | |
bfc6fde4 VZ |
153 | virtual void OnDefaultAction(wxControl *initiatingItem); |
154 | ||
cc2b7472 VZ |
155 | // Native resource loading (implemented in src/msw/nativdlg.cpp) |
156 | // FIXME: should they really be all virtual? | |
bfc6fde4 VZ |
157 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); |
158 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); | |
cc2b7472 VZ |
159 | virtual wxWindow* GetWindowChild1(wxWindowID id); |
160 | virtual wxWindow* GetWindowChild(wxWindowID id); | |
2bda0e17 | 161 | |
cc2b7472 VZ |
162 | // implementation from now on |
163 | // -------------------------- | |
2bda0e17 | 164 | |
cc2b7472 VZ |
165 | // simple accessors |
166 | // ---------------- | |
2bda0e17 | 167 | |
cc2b7472 VZ |
168 | WXHWND GetHWND() const { return GetHandle(); } |
169 | void SetHWND(WXHWND hWnd) { m_widget = hWnd; } | |
2bda0e17 | 170 | |
cc2b7472 VZ |
171 | bool GetUseCtl3D() const { return m_useCtl3D; } |
172 | bool GetTransparentBackground() const { return m_backgroundTransparent; } | |
173 | void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } | |
2bda0e17 | 174 | |
cc2b7472 VZ |
175 | // event handlers |
176 | // -------------- | |
bfc6fde4 VZ |
177 | void OnEraseBackground(wxEraseEvent& event); |
178 | void OnKeyDown(wxKeyEvent& event); | |
179 | void OnKeyUp(wxKeyEvent& event); | |
180 | void OnPaint(wxPaintEvent& event); | |
181 | void OnChar(wxKeyEvent& event); | |
182 | void OnIdle(wxIdleEvent& event); | |
2bda0e17 | 183 | |
cc2b7472 VZ |
184 | // a window may have a default button |
185 | // TODO move into wxPanel and/or wxFrame | |
186 | wxButton *GetDefaultItem() const { return m_btnDefault; } | |
187 | void SetDefaultItem(wxButton *btn) { m_btnDefault = btn; } | |
52476186 | 188 | |
2bda0e17 | 189 | public: |
bfc6fde4 VZ |
190 | // For implementation purposes - sometimes decorations make the client area |
191 | // smaller | |
192 | virtual wxPoint GetClientAreaOrigin() const; | |
193 | ||
194 | // Makes an adjustment to the window position (for example, a frame that has | |
195 | // a toolbar that it manages itself). | |
196 | virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); | |
197 | ||
198 | // Windows subclassing | |
199 | void SubclassWin(WXHWND hWnd); | |
200 | void UnsubclassWin(); | |
201 | virtual long Default(); | |
202 | virtual bool MSWCommand(WXUINT param, WXWORD id); | |
203 | ||
204 | // returns TRUE if the event was processed | |
205 | virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result); | |
206 | ||
207 | virtual wxWindow *FindItem(int id) const; | |
208 | virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ; | |
209 | virtual void PreDelete(WXHDC dc); // Allows system cleanup | |
bfc6fde4 VZ |
210 | |
211 | // Make a Windows extended style from the given wxWindows window style | |
212 | virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE); | |
213 | // Determine whether 3D effects are wanted | |
214 | virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D); | |
215 | ||
bfc6fde4 VZ |
216 | // MSW only: TRUE if this control is part of the main control |
217 | virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; | |
218 | ||
bfc6fde4 VZ |
219 | wxObject *GetChild(int number) const ; |
220 | ||
221 | void MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, | |
222 | int x, int y, int width, int height, | |
223 | WXDWORD style, const char *dialog_template = NULL, | |
224 | WXDWORD exendedStyle = 0); | |
225 | ||
226 | // Actually defined in wx_canvs.cc since requires wxCanvas declaration | |
227 | virtual void MSWDeviceToLogical(float *x, float *y) const ; | |
228 | ||
229 | // Create an appropriate wxWindow from a HWND | |
230 | virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); | |
231 | ||
232 | // Make sure the window style reflects the HWND style (roughly) | |
233 | virtual void AdoptAttributesFromHWND(); | |
234 | ||
235 | // Setup background and foreground colours correctly | |
236 | virtual void SetupColours(); | |
237 | ||
238 | // Saves the last message information before calling base version | |
239 | virtual bool ProcessEvent(wxEvent& event); | |
240 | ||
241 | // Handlers | |
242 | virtual void MSWOnCreate(WXLPCREATESTRUCT cs); | |
243 | virtual bool MSWOnPaint(); | |
244 | virtual WXHICON MSWOnQueryDragIcon() { return 0; } | |
245 | virtual void MSWOnSize(int x, int y, WXUINT flag); | |
246 | virtual void MSWOnWindowPosChanging(void *lpPos); | |
247 | virtual void MSWOnHScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); | |
248 | virtual void MSWOnVScroll(WXWORD nSBCode, WXWORD pos, WXHWND control); | |
249 | virtual bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
250 | virtual long MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam); | |
251 | virtual long MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam); | |
252 | virtual WXHBRUSH MSWOnCtlColor(WXHDC dc, WXHWND pWnd, WXUINT nCtlColor, | |
253 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
254 | virtual bool MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
255 | virtual long MSWOnPaletteChanged(WXHWND hWndPalChange); | |
256 | virtual long MSWOnQueryNewPalette(); | |
257 | virtual bool MSWOnEraseBkgnd(WXHDC pDC); | |
258 | virtual void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu); | |
259 | virtual void MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem); | |
260 | virtual bool MSWOnClose(); | |
261 | // Return TRUE to end session, FALSE to veto end session. | |
262 | virtual bool MSWOnQueryEndSession(long logOff); | |
263 | virtual bool MSWOnEndSession(bool endSession, long logOff); | |
264 | virtual bool MSWOnDestroy(); | |
265 | virtual bool MSWOnSetFocus(WXHWND wnd); | |
266 | virtual bool MSWOnKillFocus(WXHWND wnd); | |
267 | virtual void MSWOnDropFiles(WXWPARAM wParam); | |
268 | virtual bool MSWOnInitDialog(WXHWND hWndFocus); | |
269 | virtual void MSWOnShow(bool show, int status); | |
270 | ||
271 | // TODO: rationalise these functions into 1 or 2 which take the | |
272 | // event type as argument. | |
273 | virtual void MSWOnLButtonDown(int x, int y, WXUINT flags); | |
274 | virtual void MSWOnLButtonUp(int x, int y, WXUINT flags); | |
275 | virtual void MSWOnLButtonDClick(int x, int y, WXUINT flags); | |
276 | ||
277 | virtual void MSWOnMButtonDown(int x, int y, WXUINT flags); | |
278 | virtual void MSWOnMButtonUp(int x, int y, WXUINT flags); | |
279 | virtual void MSWOnMButtonDClick(int x, int y, WXUINT flags); | |
280 | ||
281 | virtual void MSWOnRButtonDown(int x, int y, WXUINT flags); | |
282 | virtual void MSWOnRButtonUp(int x, int y, WXUINT flags); | |
283 | virtual void MSWOnRButtonDClick(int x, int y, WXUINT flags); | |
284 | ||
285 | virtual void MSWOnMouseMove(int x, int y, WXUINT flags); | |
286 | virtual void MSWOnMouseEnter(int x, int y, WXUINT flags); | |
287 | virtual void MSWOnMouseLeave(int x, int y, WXUINT flags); | |
288 | ||
289 | // These return TRUE if an event handler was found, FALSE otherwise (not processed) | |
290 | virtual bool MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); | |
4d91c1d1 VZ |
291 | virtual bool MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam); |
292 | virtual bool MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam); | |
bfc6fde4 VZ |
293 | |
294 | virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); | |
295 | virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); | |
296 | ||
297 | virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); | |
298 | virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); | |
299 | ||
300 | virtual void MSWOnJoyDown(int joystick, int x, int y, WXUINT flags); | |
301 | virtual void MSWOnJoyUp(int joystick, int x, int y, WXUINT flags); | |
302 | virtual void MSWOnJoyMove(int joystick, int x, int y, WXUINT flags); | |
303 | virtual void MSWOnJoyZMove(int joystick, int z, WXUINT flags); | |
304 | ||
305 | virtual long MSWGetDlgCode(); | |
306 | ||
307 | // Window procedure | |
308 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
309 | ||
310 | // Calls an appropriate default window procedure | |
311 | virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
312 | virtual bool MSWProcessMessage(WXMSG* pMsg); | |
313 | virtual bool MSWTranslateMessage(WXMSG* pMsg); | |
314 | virtual void MSWDestroyWindow(); | |
315 | ||
316 | // Detach "Window" menu from menu bar so it doesn't get deleted | |
317 | void MSWDetachWindowMenu(); | |
318 | ||
319 | inline WXFARPROC MSWGetOldWndProc() const; | |
320 | inline void MSWSetOldWndProc(WXFARPROC proc); | |
321 | ||
322 | // Define for each class of dialog and control | |
323 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
324 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
325 | ||
cc2b7472 VZ |
326 | #if WXWIN_COMPATIBILITY |
327 | void SetShowing(bool show) { (void)Show(show); } | |
328 | bool IsUserEnabled() const { return IsEnabled(); } | |
329 | #endif // WXWIN_COMPATIBILITY | |
bfc6fde4 VZ |
330 | |
331 | // Responds to colour changes: passes event on to children. | |
332 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
333 | ||
cc2b7472 VZ |
334 | // remember the parameters of the last message |
335 | void PushLastMessage(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) | |
336 | { | |
337 | m_lastMsg = msg; | |
338 | m_lastWParam = wParam; | |
339 | m_lastLParam = lParam; | |
340 | } | |
bfc6fde4 | 341 | |
2bda0e17 | 342 | protected: |
cc2b7472 | 343 | // the old window proc (we subclass all windows) |
bfc6fde4 | 344 | WXFARPROC m_oldWndProc; |
2bda0e17 | 345 | |
cc2b7472 VZ |
346 | // additional (MSW specific) flags |
347 | bool m_useCtl3D:1; // Using CTL3D for this control | |
348 | bool m_inOnSize:1; // Protection against OnSize reentry | |
349 | bool m_backgroundTransparent:1; | |
350 | bool m_mouseInWindow:1; | |
351 | bool m_doubleClickAllowed:1; | |
352 | bool m_winCaptured:1; | |
bfc6fde4 VZ |
353 | |
354 | // Caret data | |
cc2b7472 VZ |
355 | bool m_caretEnabled:1; |
356 | bool m_caretShown:1; | |
bfc6fde4 VZ |
357 | int m_caretWidth; |
358 | int m_caretHeight; | |
2bda0e17 | 359 | |
cc2b7472 | 360 | // the size of one page for scrolling |
bfc6fde4 VZ |
361 | int m_xThumbSize; |
362 | int m_yThumbSize; | |
2bda0e17 | 363 | |
cc2b7472 VZ |
364 | // the coordinates of the last mouse event and the typoe of it |
365 | long m_lastMouseX, | |
366 | m_lastMouseY; | |
367 | int m_lastMouseEvent; | |
2bda0e17 | 368 | |
cc2b7472 | 369 | // the parameters of the last message used in Default() |
bfc6fde4 VZ |
370 | WXUINT m_lastMsg; |
371 | WXWPARAM m_lastWParam; | |
372 | WXLPARAM m_lastLParam; | |
373 | ||
bfc6fde4 | 374 | WXHMENU m_hMenu; // Menu, if any |
bfc6fde4 | 375 | |
cc2b7472 VZ |
376 | wxButton *m_btnDefault; |
377 | ||
378 | // implement the base class pure virtuals | |
379 | virtual void DoGetPosition( int *x, int *y ) const; | |
380 | virtual void DoGetSize( int *width, int *height ) const; | |
381 | virtual void DoGetClientSize( int *width, int *height ) const; | |
382 | virtual void DoSetSize(int x, int y, | |
383 | int width, int height, | |
384 | int sizeFlags = wxSIZE_AUTO); | |
bfc6fde4 | 385 | virtual void DoSetClientSize(int width, int height); |
2bda0e17 | 386 | |
cc2b7472 VZ |
387 | #if wxUSE_TOOLTIPS |
388 | virtual void DoSetToolTip( wxToolTip *tip ); | |
389 | #endif // wxUSE_TOOLTIPS | |
390 | ||
fd3f686c VZ |
391 | private: |
392 | // common part of all ctors | |
393 | void Init(); | |
394 | ||
395 | DECLARE_EVENT_TABLE() | |
2bda0e17 KB |
396 | }; |
397 | ||
cc2b7472 VZ |
398 | // --------------------------------------------------------------------------- |
399 | // global functions | |
400 | // --------------------------------------------------------------------------- | |
2bda0e17 | 401 | |
cc2b7472 | 402 | // kbd code translation |
184b5d99 JS |
403 | WXDLLEXPORT int wxCharCodeMSWToWX(int keySym); |
404 | WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual); | |
2bda0e17 | 405 | |
2bda0e17 | 406 | #endif |
bbcdf8bc | 407 | // _WX_WINDOW_H_ |