]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
e766c8a9 | 3 | // Purpose: wxWindowMac |
e9576ca5 SC |
4 | // Author: AUTHOR |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
6264b550 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/setup.h" | |
17 | #include "wx/menu.h" | |
5fde6fcc | 18 | #include "wx/window.h" |
e9576ca5 SC |
19 | #include "wx/dc.h" |
20 | #include "wx/dcclient.h" | |
14c9cbdb | 21 | #include "wx/utils.h" |
e9576ca5 SC |
22 | #include "wx/app.h" |
23 | #include "wx/panel.h" | |
24 | #include "wx/layout.h" | |
25 | #include "wx/dialog.h" | |
26 | #include "wx/listbox.h" | |
03e11df5 GD |
27 | #include "wx/scrolbar.h" |
28 | #include "wx/statbox.h" | |
e9576ca5 SC |
29 | #include "wx/button.h" |
30 | #include "wx/settings.h" | |
31 | #include "wx/msgdlg.h" | |
32 | #include "wx/frame.h" | |
519cb848 SC |
33 | #include "wx/notebook.h" |
34 | #include "wx/tabctrl.h" | |
2f1ae414 | 35 | #include "wx/tooltip.h" |
c809f3be | 36 | #include "wx/statusbr.h" |
e9576ca5 | 37 | #include "wx/menuitem.h" |
4ac219f6 | 38 | #include "wx/spinctrl.h" |
e9576ca5 | 39 | #include "wx/log.h" |
467e3168 | 40 | #include "wx/geometry.h" |
e9576ca5 | 41 | |
7c551d95 SC |
42 | #if wxUSE_CARET |
43 | #include "wx/caret.h" | |
44 | #endif // wxUSE_CARET | |
45 | ||
519cb848 SC |
46 | #define wxWINDOW_HSCROLL 5998 |
47 | #define wxWINDOW_VSCROLL 5997 | |
48 | #define MAC_SCROLLBAR_SIZE 16 | |
49 | ||
d497dca4 | 50 | #include "wx/mac/uma.h" |
66a09d47 SC |
51 | #ifndef __DARWIN__ |
52 | #include <Windows.h> | |
53 | #include <ToolUtils.h> | |
54 | #endif | |
519cb848 | 55 | |
e9576ca5 SC |
56 | #if wxUSE_DRAG_AND_DROP |
57 | #include "wx/dnd.h" | |
58 | #endif | |
59 | ||
60 | #include <string.h> | |
61 | ||
62 | extern wxList wxPendingDelete; | |
e766c8a9 | 63 | wxWindowMac* gFocusWindow = NULL ; |
e9576ca5 | 64 | |
fc0daf84 SC |
65 | #ifdef __WXUNIVERSAL__ |
66 | IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase) | |
67 | #else // __WXMAC__ | |
68 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) | |
69 | #endif // __WXUNIVERSAL__/__WXMAC__ | |
70 | ||
2f1ae414 | 71 | #if !USE_SHARED_LIBRARY |
fc0daf84 SC |
72 | |
73 | BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) | |
1c310985 | 74 | EVT_NC_PAINT(wxWindowMac::OnNcPaint) |
e766c8a9 SC |
75 | EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) |
76 | EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged) | |
77 | EVT_INIT_DIALOG(wxWindowMac::OnInitDialog) | |
78 | EVT_IDLE(wxWindowMac::OnIdle) | |
79 | EVT_SET_FOCUS(wxWindowMac::OnSetFocus) | |
e9576ca5 SC |
80 | END_EVENT_TABLE() |
81 | ||
2f1ae414 | 82 | #endif |
e9576ca5 | 83 | |
94abc21f SC |
84 | #define wxMAC_DEBUG_REDRAW 0 |
85 | #ifndef wxMAC_DEBUG_REDRAW | |
86 | #define wxMAC_DEBUG_REDRAW 0 | |
87 | #endif | |
88 | ||
1c310985 | 89 | #define wxMAC_USE_THEME_BORDER 0 |
e9576ca5 | 90 | |
e7549107 SC |
91 | |
92 | // =========================================================================== | |
93 | // implementation | |
94 | // =========================================================================== | |
95 | ||
e7549107 SC |
96 | |
97 | // ---------------------------------------------------------------------------- | |
98 | // constructors and such | |
99 | // ---------------------------------------------------------------------------- | |
100 | ||
e766c8a9 | 101 | void wxWindowMac::Init() |
519cb848 | 102 | { |
e7549107 SC |
103 | // generic |
104 | InitBase(); | |
105 | ||
106 | // MSW specific | |
107 | m_doubleClickAllowed = 0; | |
108 | m_winCaptured = FALSE; | |
109 | ||
110 | m_isBeingDeleted = FALSE; | |
111 | ||
112 | m_useCtl3D = FALSE; | |
113 | m_mouseInWindow = FALSE; | |
114 | ||
115 | m_xThumbSize = 0; | |
116 | m_yThumbSize = 0; | |
117 | m_backgroundTransparent = FALSE; | |
118 | ||
119 | // as all windows are created with WS_VISIBLE style... | |
120 | m_isShown = TRUE; | |
121 | ||
6264b550 | 122 | m_x = 0; |
14c9cbdb | 123 | m_y = 0 ; |
6264b550 RR |
124 | m_width = 0 ; |
125 | m_height = 0 ; | |
e7549107 | 126 | |
6264b550 RR |
127 | m_hScrollBar = NULL ; |
128 | m_vScrollBar = NULL ; | |
d84afea9 GD |
129 | |
130 | m_label = wxEmptyString; | |
e9576ca5 SC |
131 | } |
132 | ||
133 | // Destructor | |
e766c8a9 | 134 | wxWindowMac::~wxWindowMac() |
e9576ca5 | 135 | { |
fdaf613a SC |
136 | // deleting a window while it is shown invalidates the region |
137 | if ( IsShown() ) { | |
e766c8a9 | 138 | wxWindowMac* iter = this ; |
fdaf613a | 139 | while( iter ) { |
1c310985 | 140 | if ( iter->IsTopLevel() ) |
fdaf613a SC |
141 | { |
142 | Refresh() ; | |
143 | break ; | |
144 | } | |
145 | iter = iter->GetParent() ; | |
14c9cbdb | 146 | |
fdaf613a SC |
147 | } |
148 | } | |
14c9cbdb | 149 | |
e7549107 SC |
150 | m_isBeingDeleted = TRUE; |
151 | ||
d4380aaf SC |
152 | #ifndef __WXUNIVERSAL__ |
153 | // VS: make sure there's no wxFrame with last focus set to us: | |
154 | for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) | |
155 | { | |
156 | wxFrame *frame = wxDynamicCast(win, wxFrame); | |
157 | if ( frame ) | |
158 | { | |
159 | if ( frame->GetLastFocus() == this ) | |
160 | { | |
161 | frame->SetLastFocus((wxWindow*)NULL); | |
162 | } | |
163 | break; | |
164 | } | |
165 | } | |
166 | #endif // __WXUNIVERSAL__ | |
167 | ||
6264b550 RR |
168 | if ( s_lastMouseWindow == this ) |
169 | { | |
170 | s_lastMouseWindow = NULL ; | |
171 | } | |
fd76aa8d SC |
172 | |
173 | wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; | |
174 | if ( frame ) | |
175 | { | |
176 | if ( frame->GetLastFocus() == this ) | |
177 | frame->SetLastFocus( NULL ) ; | |
178 | } | |
e7549107 SC |
179 | |
180 | if ( gFocusWindow == this ) | |
e9576ca5 | 181 | { |
6264b550 | 182 | gFocusWindow = NULL ; |
e9576ca5 | 183 | } |
519cb848 | 184 | |
e7549107 SC |
185 | if ( m_parent ) |
186 | m_parent->RemoveChild(this); | |
e9576ca5 SC |
187 | |
188 | DestroyChildren(); | |
e9576ca5 SC |
189 | } |
190 | ||
191 | // Constructor | |
e766c8a9 | 192 | bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, |
e9576ca5 SC |
193 | const wxPoint& pos, |
194 | const wxSize& size, | |
195 | long style, | |
196 | const wxString& name) | |
197 | { | |
e766c8a9 | 198 | wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") ); |
e9576ca5 | 199 | |
e7549107 | 200 | if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) |
e9576ca5 SC |
201 | return FALSE; |
202 | ||
e7549107 | 203 | parent->AddChild(this); |
e9576ca5 | 204 | |
6264b550 RR |
205 | m_x = (int)pos.x; |
206 | m_y = (int)pos.y; | |
207 | AdjustForParentClientOrigin(m_x, m_y, wxSIZE_USE_EXISTING); | |
208 | m_width = WidthDefault( size.x ); | |
209 | m_height = HeightDefault( size.y ) ; | |
e766c8a9 | 210 | #ifndef __WXUNIVERSAL__ |
14c9cbdb RD |
211 | // Don't give scrollbars to wxControls unless they ask for them |
212 | if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) || | |
213 | (IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL))) | |
6264b550 RR |
214 | { |
215 | MacCreateScrollBars( style ) ; | |
216 | } | |
e766c8a9 | 217 | #endif |
e9576ca5 SC |
218 | return TRUE; |
219 | } | |
220 | ||
e766c8a9 | 221 | void wxWindowMac::SetFocus() |
e9576ca5 | 222 | { |
6264b550 RR |
223 | if ( gFocusWindow == this ) |
224 | return ; | |
14c9cbdb | 225 | |
6264b550 RR |
226 | if ( AcceptsFocus() ) |
227 | { | |
228 | if (gFocusWindow ) | |
229 | { | |
230 | #if wxUSE_CARET | |
231 | // Deal with caret | |
232 | if ( gFocusWindow->m_caret ) | |
233 | { | |
234 | gFocusWindow->m_caret->OnKillFocus(); | |
235 | } | |
236 | #endif // wxUSE_CARET | |
e766c8a9 | 237 | #ifndef __WXUNIVERSAL__ |
6264b550 RR |
238 | wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; |
239 | if ( control && control->GetMacControl() ) | |
240 | { | |
76a5e5d2 | 241 | UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNoPart ) ; |
6264b550 RR |
242 | control->MacRedrawControl() ; |
243 | } | |
244 | #endif | |
245 | wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId); | |
246 | event.SetEventObject(gFocusWindow); | |
247 | gFocusWindow->GetEventHandler()->ProcessEvent(event) ; | |
248 | } | |
249 | gFocusWindow = this ; | |
250 | { | |
251 | #if wxUSE_CARET | |
252 | // Deal with caret | |
253 | if ( m_caret ) | |
254 | { | |
255 | m_caret->OnSetFocus(); | |
256 | } | |
257 | #endif // wxUSE_CARET | |
258 | // panel wants to track the window which was the last to have focus in it | |
c1fb8167 | 259 | wxChildFocusEvent eventFocus(this); |
1c310985 | 260 | GetEventHandler()->ProcessEvent(eventFocus); |
c1fb8167 | 261 | |
e766c8a9 | 262 | #ifndef __WXUNIVERSAL__ |
6264b550 RR |
263 | wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; |
264 | if ( control && control->GetMacControl() ) | |
265 | { | |
f6c29ee0 | 266 | UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNextPart ) ; |
6264b550 | 267 | } |
e766c8a9 | 268 | #endif |
6264b550 RR |
269 | wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); |
270 | event.SetEventObject(this); | |
271 | GetEventHandler()->ProcessEvent(event) ; | |
272 | } | |
273 | } | |
e9576ca5 SC |
274 | } |
275 | ||
e766c8a9 | 276 | bool wxWindowMac::Enable(bool enable) |
e9576ca5 | 277 | { |
e7549107 SC |
278 | if ( !wxWindowBase::Enable(enable) ) |
279 | return FALSE; | |
e7549107 | 280 | |
1c310985 | 281 | MacSuperEnabled( enable ) ; |
e7549107 SC |
282 | |
283 | return TRUE; | |
e9576ca5 SC |
284 | } |
285 | ||
4116c221 | 286 | void wxWindowMac::DoCaptureMouse() |
e9576ca5 | 287 | { |
519cb848 | 288 | wxTheApp->s_captureWindow = this ; |
e9576ca5 SC |
289 | } |
290 | ||
90b959ae SC |
291 | wxWindow* wxWindowBase::GetCapture() |
292 | { | |
293 | return wxTheApp->s_captureWindow ; | |
294 | } | |
295 | ||
4116c221 | 296 | void wxWindowMac::DoReleaseMouse() |
e9576ca5 | 297 | { |
519cb848 | 298 | wxTheApp->s_captureWindow = NULL ; |
e9576ca5 SC |
299 | } |
300 | ||
e9576ca5 SC |
301 | #if wxUSE_DRAG_AND_DROP |
302 | ||
e766c8a9 | 303 | void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) |
e9576ca5 | 304 | { |
a07c1212 SC |
305 | if ( m_dropTarget != 0 ) { |
306 | delete m_dropTarget; | |
e9576ca5 SC |
307 | } |
308 | ||
a07c1212 SC |
309 | m_dropTarget = pDropTarget; |
310 | if ( m_dropTarget != 0 ) | |
e9576ca5 SC |
311 | { |
312 | // TODO | |
313 | } | |
314 | } | |
315 | ||
316 | #endif | |
317 | ||
318 | // Old style file-manager drag&drop | |
e766c8a9 | 319 | void wxWindowMac::DragAcceptFiles(bool accept) |
e9576ca5 SC |
320 | { |
321 | // TODO | |
322 | } | |
323 | ||
324 | // Get total size | |
e766c8a9 | 325 | void wxWindowMac::DoGetSize(int *x, int *y) const |
e9576ca5 | 326 | { |
9453cf2b SC |
327 | if(x) *x = m_width ; |
328 | if(y) *y = m_height ; | |
e9576ca5 SC |
329 | } |
330 | ||
e766c8a9 | 331 | void wxWindowMac::DoGetPosition(int *x, int *y) const |
e9576ca5 | 332 | { |
9453cf2b | 333 | int xx,yy; |
14c9cbdb | 334 | |
9453cf2b SC |
335 | xx = m_x ; |
336 | yy = m_y ; | |
1c310985 | 337 | if ( !IsTopLevel() && GetParent()) |
519cb848 SC |
338 | { |
339 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
9453cf2b SC |
340 | xx -= pt.x; |
341 | yy -= pt.y; | |
519cb848 | 342 | } |
9453cf2b SC |
343 | if(x) *x = xx; |
344 | if(y) *y = yy; | |
e9576ca5 SC |
345 | } |
346 | ||
e766c8a9 SC |
347 | #if wxUSE_MENUS |
348 | bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) | |
51abe921 | 349 | { |
6264b550 | 350 | menu->SetInvokingWindow(this); |
51abe921 | 351 | menu->UpdateUI(); |
6264b550 | 352 | ClientToScreen( &x , &y ) ; |
51abe921 | 353 | |
76a5e5d2 SC |
354 | ::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ; |
355 | long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ; | |
2b5f62a0 VZ |
356 | if ( HiWord(menuResult) != 0 ) |
357 | { | |
358 | MenuCommand id ; | |
359 | GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ; | |
360 | ||
361 | wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id ); | |
362 | event.m_timeStamp = TickCount() ; | |
363 | event.SetEventObject(this->GetEventHandler()); | |
364 | event.SetInt( id ); | |
365 | GetEventHandler()->ProcessEvent(event); | |
366 | } | |
6264b550 RR |
367 | ::DeleteMenu( menu->MacGetMenuId() ) ; |
368 | menu->SetInvokingWindow(NULL); | |
51abe921 SC |
369 | |
370 | return TRUE; | |
371 | } | |
e766c8a9 | 372 | #endif |
51abe921 | 373 | |
e766c8a9 | 374 | void wxWindowMac::DoScreenToClient(int *x, int *y) const |
e9576ca5 | 375 | { |
76a5e5d2 | 376 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
519cb848 | 377 | |
6264b550 | 378 | Point localwhere = {0,0} ; |
9453cf2b SC |
379 | |
380 | if(x) localwhere.h = * x ; | |
381 | if(y) localwhere.v = * y ; | |
519cb848 | 382 | |
14c9cbdb | 383 | GrafPtr port ; |
6264b550 RR |
384 | ::GetPort( &port ) ; |
385 | ::SetPort( UMAGetWindowPort( window ) ) ; | |
386 | ::GlobalToLocal( &localwhere ) ; | |
387 | ::SetPort( port ) ; | |
519cb848 | 388 | |
9453cf2b SC |
389 | if(x) *x = localwhere.h ; |
390 | if(y) *y = localwhere.v ; | |
14c9cbdb | 391 | |
2078220e SC |
392 | MacRootWindowToWindow( x , y ) ; |
393 | if ( x ) | |
05ac7ac5 | 394 | *x -= MacGetLeftBorderSize() ; |
2078220e | 395 | if ( y ) |
05ac7ac5 | 396 | *y -= MacGetTopBorderSize() ; |
e9576ca5 SC |
397 | } |
398 | ||
e766c8a9 | 399 | void wxWindowMac::DoClientToScreen(int *x, int *y) const |
e9576ca5 | 400 | { |
76a5e5d2 | 401 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
14c9cbdb | 402 | |
2078220e | 403 | if ( x ) |
05ac7ac5 | 404 | *x += MacGetLeftBorderSize() ; |
2078220e | 405 | if ( y ) |
05ac7ac5 | 406 | *y += MacGetTopBorderSize() ; |
14c9cbdb | 407 | |
2078220e | 408 | MacWindowToRootWindow( x , y ) ; |
14c9cbdb | 409 | |
6264b550 | 410 | Point localwhere = { 0,0 }; |
9453cf2b SC |
411 | if(x) localwhere.h = * x ; |
412 | if(y) localwhere.v = * y ; | |
14c9cbdb RD |
413 | |
414 | GrafPtr port ; | |
6264b550 RR |
415 | ::GetPort( &port ) ; |
416 | ::SetPort( UMAGetWindowPort( window ) ) ; | |
7d9d1fd7 | 417 | |
6264b550 RR |
418 | ::LocalToGlobal( &localwhere ) ; |
419 | ::SetPort( port ) ; | |
9453cf2b SC |
420 | if(x) *x = localwhere.h ; |
421 | if(y) *y = localwhere.v ; | |
519cb848 SC |
422 | } |
423 | ||
e766c8a9 | 424 | void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const |
519cb848 | 425 | { |
1c310985 SC |
426 | wxPoint origin = GetClientAreaOrigin() ; |
427 | if(x) *x += origin.x ; | |
428 | if(y) *y += origin.y ; | |
14c9cbdb | 429 | |
1c310985 SC |
430 | MacWindowToRootWindow( x , y ) ; |
431 | } | |
432 | ||
433 | void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const | |
434 | { | |
435 | wxPoint origin = GetClientAreaOrigin() ; | |
436 | MacRootWindowToWindow( x , y ) ; | |
437 | if(x) *x -= origin.x ; | |
438 | if(y) *y -= origin.y ; | |
439 | } | |
440 | ||
441 | void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const | |
442 | { | |
443 | if ( !IsTopLevel() ) | |
6264b550 | 444 | { |
1c310985 SC |
445 | if(x) *x += m_x ; |
446 | if(y) *y += m_y ; | |
447 | GetParent()->MacWindowToRootWindow( x , y ) ; | |
6264b550 | 448 | } |
519cb848 SC |
449 | } |
450 | ||
1c310985 | 451 | void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const |
519cb848 | 452 | { |
1c310985 | 453 | if ( !IsTopLevel() ) |
6264b550 | 454 | { |
1c310985 SC |
455 | if(x) *x -= m_x ; |
456 | if(y) *y -= m_y ; | |
457 | GetParent()->MacRootWindowToWindow( x , y ) ; | |
6264b550 | 458 | } |
e9576ca5 SC |
459 | } |
460 | ||
e766c8a9 | 461 | bool wxWindowMac::SetCursor(const wxCursor& cursor) |
e9576ca5 | 462 | { |
6618870d | 463 | if (m_cursor == cursor) |
e7549107 | 464 | return FALSE; |
6618870d SC |
465 | |
466 | if (wxNullCursor == cursor) | |
467 | { | |
468 | if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) | |
469 | return FALSE ; | |
470 | } | |
471 | else | |
472 | { | |
473 | if ( ! wxWindowBase::SetCursor( cursor ) ) | |
474 | return FALSE ; | |
475 | } | |
e7549107 SC |
476 | |
477 | wxASSERT_MSG( m_cursor.Ok(), | |
478 | wxT("cursor must be valid after call to the base version")); | |
479 | ||
480 | Point pt ; | |
e766c8a9 | 481 | wxWindowMac *mouseWin ; |
e7549107 | 482 | GetMouse( &pt ) ; |
14c9cbdb | 483 | |
e7549107 SC |
484 | // Change the cursor NOW if we're within the correct window |
485 | ||
486 | if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) | |
e9576ca5 | 487 | { |
6264b550 RR |
488 | if ( mouseWin == this && !wxIsBusy() ) |
489 | { | |
490 | m_cursor.MacInstall() ; | |
491 | } | |
e9576ca5 | 492 | } |
e7549107 SC |
493 | |
494 | return TRUE ; | |
e9576ca5 SC |
495 | } |
496 | ||
497 | ||
498 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
e766c8a9 | 499 | void wxWindowMac::DoGetClientSize(int *x, int *y) const |
e9576ca5 | 500 | { |
9453cf2b SC |
501 | int ww, hh; |
502 | ww = m_width ; | |
503 | hh = m_height ; | |
519cb848 | 504 | |
6264b550 RR |
505 | ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
506 | hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ); | |
14c9cbdb | 507 | |
2f1ae414 SC |
508 | if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) |
509 | { | |
14c9cbdb | 510 | int x1 = 0 ; |
6264b550 RR |
511 | int y1 = 0 ; |
512 | int w = m_width ; | |
513 | int h = m_height ; | |
14c9cbdb | 514 | |
6264b550 RR |
515 | MacClientToRootWindow( &x1 , &y1 ) ; |
516 | MacClientToRootWindow( &w , &h ) ; | |
14c9cbdb | 517 | |
6264b550 | 518 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 519 | |
6264b550 RR |
520 | int totW = 10000 , totH = 10000; |
521 | while( iter ) | |
522 | { | |
1c310985 | 523 | if ( iter->IsTopLevel() ) |
6264b550 RR |
524 | { |
525 | totW = iter->m_width ; | |
526 | totH = iter->m_height ; | |
527 | break ; | |
528 | } | |
529 | ||
530 | iter = iter->GetParent() ; | |
14c9cbdb RD |
531 | } |
532 | ||
6264b550 RR |
533 | if (m_hScrollBar && m_hScrollBar->IsShown() ) |
534 | { | |
535 | hh -= MAC_SCROLLBAR_SIZE; | |
536 | if ( h-y1 >= totH ) | |
537 | { | |
538 | hh += 1 ; | |
539 | } | |
540 | } | |
541 | if (m_vScrollBar && m_vScrollBar->IsShown() ) | |
542 | { | |
543 | ww -= MAC_SCROLLBAR_SIZE; | |
544 | if ( w-x1 >= totW ) | |
545 | { | |
546 | ww += 1 ; | |
547 | } | |
548 | } | |
2f1ae414 | 549 | } |
9453cf2b SC |
550 | if(x) *x = ww; |
551 | if(y) *y = hh; | |
519cb848 SC |
552 | } |
553 | ||
51abe921 SC |
554 | |
555 | // ---------------------------------------------------------------------------- | |
556 | // tooltips | |
557 | // ---------------------------------------------------------------------------- | |
558 | ||
559 | #if wxUSE_TOOLTIPS | |
560 | ||
e766c8a9 | 561 | void wxWindowMac::DoSetToolTip(wxToolTip *tooltip) |
51abe921 SC |
562 | { |
563 | wxWindowBase::DoSetToolTip(tooltip); | |
564 | ||
6264b550 RR |
565 | if ( m_tooltip ) |
566 | m_tooltip->SetWindow(this); | |
51abe921 SC |
567 | } |
568 | ||
569 | #endif // wxUSE_TOOLTIPS | |
570 | ||
e766c8a9 | 571 | void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) |
51abe921 | 572 | { |
6264b550 RR |
573 | int former_x = m_x ; |
574 | int former_y = m_y ; | |
575 | int former_w = m_width ; | |
576 | int former_h = m_height ; | |
14c9cbdb | 577 | |
519cb848 SC |
578 | int actualWidth = width; |
579 | int actualHeight = height; | |
580 | int actualX = x; | |
581 | int actualY = y; | |
14c9cbdb RD |
582 | |
583 | if ((m_minWidth != -1) && (actualWidth < m_minWidth)) | |
6264b550 | 584 | actualWidth = m_minWidth; |
14c9cbdb | 585 | if ((m_minHeight != -1) && (actualHeight < m_minHeight)) |
6264b550 | 586 | actualHeight = m_minHeight; |
14c9cbdb | 587 | if ((m_maxWidth != -1) && (actualWidth > m_maxWidth)) |
6264b550 | 588 | actualWidth = m_maxWidth; |
14c9cbdb | 589 | if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) |
6264b550 RR |
590 | actualHeight = m_maxHeight; |
591 | ||
592 | bool doMove = false ; | |
593 | bool doResize = false ; | |
14c9cbdb | 594 | |
6264b550 RR |
595 | if ( actualX != former_x || actualY != former_y ) |
596 | { | |
597 | doMove = true ; | |
598 | } | |
599 | if ( actualWidth != former_w || actualHeight != former_h ) | |
600 | { | |
601 | doResize = true ; | |
602 | } | |
603 | ||
604 | if ( doMove || doResize ) | |
605 | { | |
1c310985 | 606 | // erase former position |
de043984 | 607 | |
2b5f62a0 VZ |
608 | bool partialRepaint = false ; |
609 | ||
610 | if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) | |
611 | { | |
612 | wxPoint oldPos( m_x , m_y ) ; | |
613 | wxPoint newPos( actualX , actualY ) ; | |
614 | MacWindowToRootWindow( &oldPos.x , &oldPos.y ) ; | |
615 | MacWindowToRootWindow( &newPos.x , &newPos.y ) ; | |
616 | if ( oldPos == newPos ) | |
617 | { | |
618 | partialRepaint = true ; | |
619 | RgnHandle oldRgn,newRgn,diffRgn ; | |
620 | oldRgn = NewRgn() ; | |
621 | newRgn = NewRgn() ; | |
622 | diffRgn = NewRgn() ; | |
623 | SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ; | |
624 | SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ; | |
625 | DiffRgn( newRgn , oldRgn , diffRgn ) ; | |
626 | InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; | |
627 | DiffRgn( oldRgn , newRgn , diffRgn ) ; | |
628 | InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ; | |
629 | DisposeRgn(oldRgn) ; | |
630 | DisposeRgn(newRgn) ; | |
631 | DisposeRgn(diffRgn) ; | |
632 | } | |
633 | } | |
634 | ||
635 | if ( !partialRepaint ) | |
636 | Refresh() ; | |
1c310985 | 637 | |
6264b550 RR |
638 | m_x = actualX ; |
639 | m_y = actualY ; | |
640 | m_width = actualWidth ; | |
641 | m_height = actualHeight ; | |
de043984 | 642 | |
327788ac SC |
643 | // update any low-level frame-relative positions |
644 | ||
645 | MacUpdateDimensions() ; | |
1c310985 | 646 | // erase new position |
de043984 | 647 | |
2b5f62a0 VZ |
648 | if ( !partialRepaint ) |
649 | Refresh() ; | |
1c310985 SC |
650 | if ( doMove ) |
651 | wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified | |
652 | ||
6264b550 RR |
653 | MacRepositionScrollBars() ; |
654 | if ( doMove ) | |
655 | { | |
656 | wxPoint point(m_x, m_y); | |
657 | wxMoveEvent event(point, m_windowId); | |
658 | event.SetEventObject(this); | |
659 | GetEventHandler()->ProcessEvent(event) ; | |
660 | } | |
661 | if ( doResize ) | |
662 | { | |
663 | MacRepositionScrollBars() ; | |
664 | wxSize size(m_width, m_height); | |
665 | wxSizeEvent event(size, m_windowId); | |
666 | event.SetEventObject(this); | |
667 | GetEventHandler()->ProcessEvent(event); | |
668 | } | |
669 | } | |
14c9cbdb | 670 | |
954fc50b SC |
671 | } |
672 | ||
673 | // set the size of the window: if the dimensions are positive, just use them, | |
674 | // but if any of them is equal to -1, it means that we must find the value for | |
675 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
676 | // which case -1 is a valid value for x and y) | |
677 | // | |
678 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
679 | // the width/height to best suit our contents, otherwise we reuse the current | |
680 | // width/height | |
681 | void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) | |
682 | { | |
683 | // get the current size and position... | |
684 | int currentX, currentY; | |
685 | GetPosition(¤tX, ¤tY); | |
14c9cbdb | 686 | |
954fc50b SC |
687 | int currentW,currentH; |
688 | GetSize(¤tW, ¤tH); | |
689 | ||
690 | // ... and don't do anything (avoiding flicker) if it's already ok | |
691 | if ( x == currentX && y == currentY && | |
692 | width == currentW && height == currentH ) | |
693 | { | |
6264b550 | 694 | MacRepositionScrollBars() ; // we might have a real position shift |
954fc50b SC |
695 | return; |
696 | } | |
697 | ||
698 | if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) | |
699 | x = currentX; | |
700 | if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) | |
701 | y = currentY; | |
702 | ||
703 | AdjustForParentClientOrigin(x, y, sizeFlags); | |
704 | ||
705 | wxSize size(-1, -1); | |
706 | if ( width == -1 ) | |
707 | { | |
708 | if ( sizeFlags & wxSIZE_AUTO_WIDTH ) | |
709 | { | |
710 | size = DoGetBestSize(); | |
711 | width = size.x; | |
712 | } | |
713 | else | |
714 | { | |
715 | // just take the current one | |
716 | width = currentW; | |
717 | } | |
718 | } | |
719 | ||
720 | if ( height == -1 ) | |
721 | { | |
722 | if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) | |
723 | { | |
724 | if ( size.x == -1 ) | |
725 | { | |
726 | size = DoGetBestSize(); | |
727 | } | |
728 | //else: already called DoGetBestSize() above | |
729 | ||
730 | height = size.y; | |
731 | } | |
732 | else | |
733 | { | |
734 | // just take the current one | |
735 | height = currentH; | |
736 | } | |
737 | } | |
738 | ||
739 | DoMoveWindow(x, y, width, height); | |
740 | ||
e9576ca5 | 741 | } |
e9576ca5 SC |
742 | // For implementation purposes - sometimes decorations make the client area |
743 | // smaller | |
519cb848 | 744 | |
e766c8a9 | 745 | wxPoint wxWindowMac::GetClientAreaOrigin() const |
e9576ca5 | 746 | { |
5b781a67 | 747 | return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) ); |
e9576ca5 SC |
748 | } |
749 | ||
d84afea9 | 750 | void wxWindowMac::SetTitle(const wxString& title) |
e9576ca5 | 751 | { |
ed60b502 | 752 | m_label = title ; |
519cb848 SC |
753 | } |
754 | ||
d84afea9 | 755 | wxString wxWindowMac::GetTitle() const |
519cb848 | 756 | { |
ed60b502 | 757 | return m_label ; |
519cb848 SC |
758 | } |
759 | ||
e766c8a9 | 760 | bool wxWindowMac::Show(bool show) |
e9576ca5 | 761 | { |
e7549107 SC |
762 | if ( !wxWindowBase::Show(show) ) |
763 | return FALSE; | |
764 | ||
baf52e1c SC |
765 | /* |
766 | WindowRef window = (WindowRef) MacGetRootWindow() ; | |
767 | wxWindowMac* win = wxFindWinFromMacWindow( window ) ; | |
768 | if ( win == NULL && win->m_isBeingDeleted ) | |
769 | return FALSE ; | |
14c9cbdb | 770 | */ |
6264b550 | 771 | MacSuperShown( show ) ; |
14c9cbdb RD |
772 | Refresh() ; |
773 | /* | |
6264b550 RR |
774 | if ( !show ) |
775 | { | |
6264b550 | 776 | if ( win && !win->m_isBeingDeleted ) |
14c9cbdb | 777 | Refresh() ; |
6264b550 RR |
778 | } |
779 | else | |
780 | { | |
14c9cbdb | 781 | Refresh() ; |
6264b550 | 782 | } |
baf52e1c | 783 | */ |
e7549107 | 784 | return TRUE; |
e9576ca5 SC |
785 | } |
786 | ||
14c9cbdb | 787 | void wxWindowMac::MacSuperShown( bool show ) |
8208e181 | 788 | { |
6264b550 RR |
789 | wxNode *node = GetChildren().First(); |
790 | while ( node ) | |
791 | { | |
792 | wxWindowMac *child = (wxWindowMac *)node->Data(); | |
793 | if ( child->m_isShown ) | |
794 | child->MacSuperShown( show ) ; | |
795 | node = node->Next(); | |
796 | } | |
8208e181 SC |
797 | } |
798 | ||
14c9cbdb | 799 | void wxWindowMac::MacSuperEnabled( bool enabled ) |
1c310985 | 800 | { |
1c469f7f SC |
801 | if ( !IsTopLevel() ) |
802 | { | |
14c9cbdb | 803 | // to be absolutely correct we'd have to invalidate (with eraseBkground |
1c469f7f SC |
804 | // because unter MacOSX the frames are drawn with an addXXX mode) |
805 | // the borders area | |
806 | } | |
1c310985 SC |
807 | wxNode *node = GetChildren().First(); |
808 | while ( node ) | |
809 | { | |
810 | wxWindowMac *child = (wxWindowMac *)node->Data(); | |
811 | if ( child->m_isShown ) | |
812 | child->MacSuperEnabled( enabled ) ; | |
813 | node = node->Next(); | |
814 | } | |
815 | } | |
816 | ||
14c9cbdb | 817 | bool wxWindowMac::MacIsReallyShown() const |
c809f3be | 818 | { |
6264b550 RR |
819 | if ( m_isShown && (m_parent != NULL) ) { |
820 | return m_parent->MacIsReallyShown(); | |
821 | } | |
822 | return m_isShown; | |
14c9cbdb | 823 | /* |
6264b550 RR |
824 | bool status = m_isShown ; |
825 | wxWindowMac * win = this ; | |
826 | while ( status && win->m_parent != NULL ) | |
827 | { | |
828 | win = win->m_parent ; | |
829 | status = win->m_isShown ; | |
830 | } | |
831 | return status ; | |
5fde6fcc | 832 | */ |
c809f3be SC |
833 | } |
834 | ||
e766c8a9 | 835 | int wxWindowMac::GetCharHeight() const |
e9576ca5 | 836 | { |
6264b550 RR |
837 | wxClientDC dc ( (wxWindowMac*)this ) ; |
838 | return dc.GetCharHeight() ; | |
e9576ca5 SC |
839 | } |
840 | ||
e766c8a9 | 841 | int wxWindowMac::GetCharWidth() const |
e9576ca5 | 842 | { |
6264b550 RR |
843 | wxClientDC dc ( (wxWindowMac*)this ) ; |
844 | return dc.GetCharWidth() ; | |
e9576ca5 SC |
845 | } |
846 | ||
e766c8a9 | 847 | void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y, |
e7549107 | 848 | int *descent, int *externalLeading, const wxFont *theFont ) const |
e9576ca5 | 849 | { |
e7549107 SC |
850 | const wxFont *fontToUse = theFont; |
851 | if ( !fontToUse ) | |
852 | fontToUse = &m_font; | |
14c9cbdb | 853 | |
e766c8a9 | 854 | wxClientDC dc( (wxWindowMac*) this ) ; |
7c74e7fe | 855 | long lx,ly,ld,le ; |
5fde6fcc | 856 | dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ; |
2f1ae414 | 857 | if ( externalLeading ) |
6264b550 | 858 | *externalLeading = le ; |
2f1ae414 | 859 | if ( descent ) |
6264b550 | 860 | *descent = ld ; |
2f1ae414 | 861 | if ( x ) |
6264b550 | 862 | *x = lx ; |
2f1ae414 | 863 | if ( y ) |
6264b550 | 864 | *y = ly ; |
e9576ca5 SC |
865 | } |
866 | ||
0a67a93b | 867 | /* |
14c9cbdb | 868 | * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect |
1c310985 SC |
869 | * we always intersect with the entire window, not only with the client area |
870 | */ | |
14c9cbdb | 871 | |
e766c8a9 | 872 | void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) |
e9576ca5 | 873 | { |
94abc21f | 874 | if ( MacGetTopLevelWindow() == NULL ) |
9a456218 | 875 | return ; |
14c9cbdb | 876 | |
9a456218 RR |
877 | wxPoint client = GetClientAreaOrigin(); |
878 | int x1 = -client.x; | |
879 | int y1 = -client.y; | |
880 | int x2 = m_width - client.x; | |
881 | int y2 = m_height - client.y; | |
882 | ||
883 | if (IsKindOf( CLASSINFO(wxButton))) | |
884 | { | |
885 | // buttons have an "aura" | |
886 | y1 -= 5; | |
887 | x1 -= 5; | |
888 | y2 += 5; | |
889 | x2 += 5; | |
890 | } | |
891 | ||
892 | Rect clientrect = { y1, x1, y2, x2 }; | |
14c9cbdb | 893 | |
1c310985 | 894 | if ( rect ) |
6264b550 | 895 | { |
1c310985 | 896 | Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; |
14c9cbdb | 897 | SectRect( &clientrect , &r , &clientrect ) ; |
6264b550 | 898 | } |
14c9cbdb | 899 | |
1c310985 | 900 | if ( !EmptyRect( &clientrect ) ) |
e9576ca5 | 901 | { |
1c310985 | 902 | int top = 0 , left = 0 ; |
14c9cbdb | 903 | |
1c310985 SC |
904 | MacClientToRootWindow( &left , &top ) ; |
905 | OffsetRect( &clientrect , left , top ) ; | |
14c9cbdb | 906 | |
1c310985 | 907 | MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ; |
e9576ca5 SC |
908 | } |
909 | } | |
910 | ||
e7549107 SC |
911 | #if wxUSE_CARET && WXWIN_COMPATIBILITY |
912 | // --------------------------------------------------------------------------- | |
e9576ca5 | 913 | // Caret manipulation |
e7549107 SC |
914 | // --------------------------------------------------------------------------- |
915 | ||
e766c8a9 | 916 | void wxWindowMac::CreateCaret(int w, int h) |
e9576ca5 | 917 | { |
e7549107 | 918 | SetCaret(new wxCaret(this, w, h)); |
e9576ca5 SC |
919 | } |
920 | ||
e766c8a9 | 921 | void wxWindowMac::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) |
e9576ca5 | 922 | { |
e7549107 | 923 | wxFAIL_MSG("not implemented"); |
e9576ca5 SC |
924 | } |
925 | ||
e766c8a9 | 926 | void wxWindowMac::ShowCaret(bool show) |
e9576ca5 | 927 | { |
e7549107 SC |
928 | wxCHECK_RET( m_caret, "no caret to show" ); |
929 | ||
930 | m_caret->Show(show); | |
e9576ca5 SC |
931 | } |
932 | ||
e766c8a9 | 933 | void wxWindowMac::DestroyCaret() |
e9576ca5 | 934 | { |
e7549107 | 935 | SetCaret(NULL); |
e9576ca5 SC |
936 | } |
937 | ||
e766c8a9 | 938 | void wxWindowMac::SetCaretPos(int x, int y) |
e9576ca5 | 939 | { |
e7549107 SC |
940 | wxCHECK_RET( m_caret, "no caret to move" ); |
941 | ||
942 | m_caret->Move(x, y); | |
e9576ca5 SC |
943 | } |
944 | ||
e766c8a9 | 945 | void wxWindowMac::GetCaretPos(int *x, int *y) const |
e9576ca5 | 946 | { |
e7549107 SC |
947 | wxCHECK_RET( m_caret, "no caret to get position of" ); |
948 | ||
949 | m_caret->GetPosition(x, y); | |
e9576ca5 | 950 | } |
e7549107 | 951 | #endif // wxUSE_CARET |
e9576ca5 | 952 | |
e766c8a9 | 953 | wxWindowMac *wxGetActiveWindow() |
e9576ca5 | 954 | { |
519cb848 | 955 | // actually this is a windows-only concept |
e9576ca5 SC |
956 | return NULL; |
957 | } | |
958 | ||
e9576ca5 | 959 | // Coordinates relative to the window |
e766c8a9 | 960 | void wxWindowMac::WarpPointer (int x_pos, int y_pos) |
e9576ca5 | 961 | { |
519cb848 | 962 | // We really dont move the mouse programmatically under mac |
e9576ca5 SC |
963 | } |
964 | ||
14c9cbdb | 965 | const wxBrush& wxWindowMac::MacGetBackgroundBrush() |
e9576ca5 | 966 | { |
a756f210 | 967 | if ( m_backgroundColour == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) |
1c310985 | 968 | { |
94abc21f | 969 | m_macBackgroundBrush.SetMacTheme( kThemeBrushDocumentWindowBackground ) ; |
1c310985 | 970 | } |
a756f210 | 971 | else if ( m_backgroundColour == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) ) |
94abc21f SC |
972 | { |
973 | // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether | |
974 | // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have | |
975 | // either a non gray background color or a non control window | |
14c9cbdb | 976 | |
76a5e5d2 | 977 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
14c9cbdb | 978 | |
94abc21f SC |
979 | wxWindowMac* parent = GetParent() ; |
980 | while( parent ) | |
981 | { | |
982 | if ( parent->MacGetRootWindow() != window ) | |
983 | { | |
984 | // we are in a different window on the mac system | |
985 | parent = NULL ; | |
986 | break ; | |
987 | } | |
988 | ||
989 | { | |
14c9cbdb | 990 | if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) |
a756f210 | 991 | && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) |
94abc21f SC |
992 | { |
993 | // if we have any other colours in the hierarchy | |
994 | m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ; | |
995 | break ; | |
996 | } | |
997 | // if we have the normal colours in the hierarchy but another control etc. -> use it's background | |
998 | if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) | |
999 | { | |
7d9d1fd7 SC |
1000 | Rect extent = { 0 , 0 , 0 , 0 } ; |
1001 | int x , y ; | |
1002 | x = y = 0 ; | |
baf52e1c | 1003 | wxSize size = parent->GetSize() ; |
7d9d1fd7 SC |
1004 | parent->MacClientToRootWindow( &x , &y ) ; |
1005 | extent.left = x ; | |
1006 | extent.top = y ; | |
1007 | extent.top-- ; | |
1008 | extent.right = x + size.x ; | |
1009 | extent.bottom = y + size.y ; | |
76a5e5d2 | 1010 | m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive |
94abc21f SC |
1011 | break ; |
1012 | } | |
1013 | } | |
1014 | parent = parent->GetParent() ; | |
1015 | } | |
1016 | if ( !parent ) | |
1017 | { | |
1018 | m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive | |
1019 | } | |
1020 | } | |
1021 | else | |
1022 | { | |
1023 | m_macBackgroundBrush.SetColour( m_backgroundColour ) ; | |
1024 | } | |
1025 | ||
1026 | return m_macBackgroundBrush ; | |
14c9cbdb | 1027 | |
94abc21f SC |
1028 | } |
1029 | ||
1030 | void wxWindowMac::OnEraseBackground(wxEraseEvent& event) | |
1031 | { | |
1032 | event.GetDC()->Clear() ; | |
1c310985 SC |
1033 | } |
1034 | ||
1035 | void wxWindowMac::OnNcPaint( wxNcPaintEvent& event ) | |
1036 | { | |
de043984 SC |
1037 | wxWindowDC dc(this) ; |
1038 | wxMacPortSetter helper(&dc) ; | |
14c9cbdb | 1039 | |
76a5e5d2 | 1040 | MacPaintBorders( dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y) ; |
e9576ca5 SC |
1041 | } |
1042 | ||
e766c8a9 | 1043 | int wxWindowMac::GetScrollPos(int orient) const |
e9576ca5 | 1044 | { |
1c310985 SC |
1045 | if ( orient == wxHORIZONTAL ) |
1046 | { | |
1047 | if ( m_hScrollBar ) | |
1048 | return m_hScrollBar->GetThumbPosition() ; | |
1049 | } | |
1050 | else | |
1051 | { | |
1052 | if ( m_vScrollBar ) | |
1053 | return m_vScrollBar->GetThumbPosition() ; | |
1054 | } | |
e9576ca5 SC |
1055 | return 0; |
1056 | } | |
1057 | ||
1058 | // This now returns the whole range, not just the number | |
1059 | // of positions that we can scroll. | |
e766c8a9 | 1060 | int wxWindowMac::GetScrollRange(int orient) const |
e9576ca5 | 1061 | { |
1c310985 SC |
1062 | if ( orient == wxHORIZONTAL ) |
1063 | { | |
1064 | if ( m_hScrollBar ) | |
1065 | return m_hScrollBar->GetRange() ; | |
1066 | } | |
1067 | else | |
1068 | { | |
1069 | if ( m_vScrollBar ) | |
1070 | return m_vScrollBar->GetRange() ; | |
1071 | } | |
e9576ca5 SC |
1072 | return 0; |
1073 | } | |
1074 | ||
e766c8a9 | 1075 | int wxWindowMac::GetScrollThumb(int orient) const |
e9576ca5 | 1076 | { |
1c310985 SC |
1077 | if ( orient == wxHORIZONTAL ) |
1078 | { | |
1079 | if ( m_hScrollBar ) | |
1080 | return m_hScrollBar->GetThumbSize() ; | |
1081 | } | |
1082 | else | |
1083 | { | |
1084 | if ( m_vScrollBar ) | |
1085 | return m_vScrollBar->GetThumbSize() ; | |
1086 | } | |
e9576ca5 SC |
1087 | return 0; |
1088 | } | |
1089 | ||
e766c8a9 | 1090 | void wxWindowMac::SetScrollPos(int orient, int pos, bool refresh) |
e9576ca5 | 1091 | { |
1c310985 | 1092 | if ( orient == wxHORIZONTAL ) |
6264b550 | 1093 | { |
1c310985 SC |
1094 | if ( m_hScrollBar ) |
1095 | m_hScrollBar->SetThumbPosition( pos ) ; | |
6264b550 RR |
1096 | } |
1097 | else | |
1098 | { | |
1c310985 SC |
1099 | if ( m_vScrollBar ) |
1100 | m_vScrollBar->SetThumbPosition( pos ) ; | |
6264b550 | 1101 | } |
2f1ae414 SC |
1102 | } |
1103 | ||
14c9cbdb | 1104 | void wxWindowMac::MacPaintBorders( int left , int top ) |
2f1ae414 | 1105 | { |
1c310985 | 1106 | if( IsTopLevel() ) |
6264b550 | 1107 | return ; |
14c9cbdb | 1108 | |
6264b550 RR |
1109 | RGBColor white = { 0xFFFF, 0xFFFF , 0xFFFF } ; |
1110 | RGBColor black = { 0x0000, 0x0000 , 0x0000 } ; | |
1111 | RGBColor face = { 0xDDDD, 0xDDDD , 0xDDDD } ; | |
1112 | RGBColor shadow = { 0x4444, 0x4444 , 0x4444 } ; | |
1113 | PenNormal() ; | |
2f1ae414 SC |
1114 | |
1115 | if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) | |
1116 | { | |
1c310985 | 1117 | #if wxMAC_USE_THEME_BORDER |
ed60b502 RR |
1118 | Rect rect = { top , left , m_height + top , m_width + left } ; |
1119 | SInt32 border = 0 ; | |
1120 | /* | |
1121 | GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; | |
1122 | InsetRect( &rect , border , border ); | |
1c310985 SC |
1123 | DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; |
1124 | */ | |
14c9cbdb | 1125 | |
1c310985 SC |
1126 | DrawThemePrimaryGroup(&rect ,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; |
1127 | #else | |
ed60b502 | 1128 | bool sunken = HasFlag( wxSUNKEN_BORDER ) ; |
653b2449 | 1129 | RGBForeColor( &face ); |
7d9d1fd7 SC |
1130 | MoveTo( left + 0 , top + m_height - 2 ); |
1131 | LineTo( left + 0 , top + 0 ); | |
1132 | LineTo( left + m_width - 2 , top + 0 ); | |
653b2449 | 1133 | |
7d9d1fd7 SC |
1134 | MoveTo( left + 2 , top + m_height - 3 ); |
1135 | LineTo( left + m_width - 3 , top + m_height - 3 ); | |
1136 | LineTo( left + m_width - 3 , top + 2 ); | |
653b2449 SC |
1137 | |
1138 | RGBForeColor( sunken ? &face : &black ); | |
7d9d1fd7 SC |
1139 | MoveTo( left + 0 , top + m_height - 1 ); |
1140 | LineTo( left + m_width - 1 , top + m_height - 1 ); | |
1141 | LineTo( left + m_width - 1 , top + 0 ); | |
653b2449 SC |
1142 | |
1143 | RGBForeColor( sunken ? &shadow : &white ); | |
7d9d1fd7 SC |
1144 | MoveTo( left + 1 , top + m_height - 3 ); |
1145 | LineTo( left + 1, top + 1 ); | |
1146 | LineTo( left + m_width - 3 , top + 1 ); | |
653b2449 SC |
1147 | |
1148 | RGBForeColor( sunken ? &white : &shadow ); | |
7d9d1fd7 SC |
1149 | MoveTo( left + 1 , top + m_height - 2 ); |
1150 | LineTo( left + m_width - 2 , top + m_height - 2 ); | |
1151 | LineTo( left + m_width - 2 , top + 1 ); | |
653b2449 SC |
1152 | |
1153 | RGBForeColor( sunken ? &black : &face ); | |
7d9d1fd7 SC |
1154 | MoveTo( left + 2 , top + m_height - 4 ); |
1155 | LineTo( left + 2 , top + 2 ); | |
1156 | LineTo( left + m_width - 4 , top + 2 ); | |
1c310985 | 1157 | #endif |
8208e181 SC |
1158 | } |
1159 | else if (HasFlag(wxSIMPLE_BORDER)) | |
1160 | { | |
ed60b502 | 1161 | Rect rect = { top , left , m_height + top , m_width + left } ; |
6264b550 RR |
1162 | RGBForeColor( &black ) ; |
1163 | FrameRect( &rect ) ; | |
2f1ae414 | 1164 | } |
8208e181 SC |
1165 | } |
1166 | ||
abda5788 SC |
1167 | void wxWindowMac::RemoveChild( wxWindowBase *child ) |
1168 | { | |
1169 | if ( child == m_hScrollBar ) | |
1170 | m_hScrollBar = NULL ; | |
1171 | if ( child == m_vScrollBar ) | |
1172 | m_vScrollBar = NULL ; | |
14c9cbdb | 1173 | |
abda5788 SC |
1174 | wxWindowBase::RemoveChild( child ) ; |
1175 | } | |
1176 | ||
e9576ca5 | 1177 | // New function that will replace some of the above. |
e766c8a9 | 1178 | void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, |
e9576ca5 SC |
1179 | int range, bool refresh) |
1180 | { | |
6264b550 RR |
1181 | if ( orient == wxHORIZONTAL ) |
1182 | { | |
1183 | if ( m_hScrollBar ) | |
1184 | { | |
1185 | if ( range == 0 || thumbVisible >= range ) | |
1186 | { | |
1187 | if ( m_hScrollBar->IsShown() ) | |
1188 | m_hScrollBar->Show(false) ; | |
1189 | } | |
1190 | else | |
1191 | { | |
1192 | if ( !m_hScrollBar->IsShown() ) | |
1193 | m_hScrollBar->Show(true) ; | |
1194 | m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
1195 | } | |
1196 | } | |
1197 | } | |
1198 | else | |
1199 | { | |
1200 | if ( m_vScrollBar ) | |
1201 | { | |
1202 | if ( range == 0 || thumbVisible >= range ) | |
1203 | { | |
1204 | if ( m_vScrollBar->IsShown() ) | |
1205 | m_vScrollBar->Show(false) ; | |
1206 | } | |
1207 | else | |
1208 | { | |
1209 | if ( !m_vScrollBar->IsShown() ) | |
1210 | m_vScrollBar->Show(true) ; | |
1211 | m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
1212 | } | |
1213 | } | |
1214 | } | |
1215 | MacRepositionScrollBars() ; | |
e9576ca5 SC |
1216 | } |
1217 | ||
1218 | // Does a physical scroll | |
e766c8a9 | 1219 | void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) |
e9576ca5 | 1220 | { |
de043984 SC |
1221 | wxClientDC dc(this) ; |
1222 | wxMacPortSetter helper(&dc) ; | |
1223 | ||
6264b550 RR |
1224 | { |
1225 | int width , height ; | |
1226 | GetClientSize( &width , &height ) ; | |
1227 | ||
de043984 | 1228 | Rect scrollrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(height) , dc.XLOG2DEVMAC(width) } ; |
6264b550 RR |
1229 | RgnHandle updateRgn = NewRgn() ; |
1230 | ClipRect( &scrollrect ) ; | |
1231 | if ( rect ) | |
1232 | { | |
14c9cbdb | 1233 | Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) , |
de043984 | 1234 | dc.XLOG2DEVMAC(rect->x + rect->width) } ; |
14c9cbdb | 1235 | SectRect( &scrollrect , &r , &scrollrect ) ; |
6264b550 RR |
1236 | } |
1237 | ScrollRect( &scrollrect , dx , dy , updateRgn ) ; | |
76a5e5d2 | 1238 | InvalWindowRgn( (WindowRef) MacGetRootWindow() , updateRgn ) ; |
6264b550 RR |
1239 | DisposeRgn( updateRgn ) ; |
1240 | } | |
14c9cbdb | 1241 | |
6264b550 RR |
1242 | for (wxNode *node = GetChildren().First(); node; node = node->Next()) |
1243 | { | |
1244 | wxWindowMac *child = (wxWindowMac*)node->Data(); | |
1245 | if (child == m_vScrollBar) continue; | |
1246 | if (child == m_hScrollBar) continue; | |
1247 | if (child->IsTopLevel()) continue; | |
327788ac | 1248 | |
6264b550 RR |
1249 | int x,y; |
1250 | child->GetPosition( &x, &y ); | |
1251 | int w,h; | |
1252 | child->GetSize( &w, &h ); | |
1253 | child->SetSize( x+dx, y+dy, w, h ); | |
1254 | } | |
14c9cbdb | 1255 | |
e9576ca5 SC |
1256 | } |
1257 | ||
e766c8a9 | 1258 | void wxWindowMac::MacOnScroll(wxScrollEvent &event ) |
7c74e7fe | 1259 | { |
6264b550 RR |
1260 | if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar ) |
1261 | { | |
1262 | wxScrollWinEvent wevent; | |
1263 | wevent.SetPosition(event.GetPosition()); | |
1264 | wevent.SetOrientation(event.GetOrientation()); | |
1265 | wevent.m_eventObject = this; | |
14c9cbdb | 1266 | |
6264b550 RR |
1267 | if (event.m_eventType == wxEVT_SCROLL_TOP) { |
1268 | wevent.m_eventType = wxEVT_SCROLLWIN_TOP; | |
1269 | } else | |
1270 | if (event.m_eventType == wxEVT_SCROLL_BOTTOM) { | |
1271 | wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; | |
1272 | } else | |
1273 | if (event.m_eventType == wxEVT_SCROLL_LINEUP) { | |
1274 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; | |
1275 | } else | |
1276 | if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) { | |
1277 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; | |
1278 | } else | |
1279 | if (event.m_eventType == wxEVT_SCROLL_PAGEUP) { | |
1280 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; | |
1281 | } else | |
1282 | if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) { | |
1283 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; | |
1284 | } else | |
1285 | if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) { | |
1286 | wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; | |
1287 | } | |
14c9cbdb | 1288 | |
6264b550 | 1289 | GetEventHandler()->ProcessEvent(wevent); |
7c74e7fe SC |
1290 | } |
1291 | } | |
1292 | ||
e9576ca5 | 1293 | // Get the window with the focus |
e766c8a9 | 1294 | wxWindowMac *wxWindowBase::FindFocus() |
e9576ca5 | 1295 | { |
6264b550 | 1296 | return gFocusWindow ; |
519cb848 SC |
1297 | } |
1298 | ||
e7549107 | 1299 | #if WXWIN_COMPATIBILITY |
e9576ca5 SC |
1300 | // If nothing defined for this, try the parent. |
1301 | // E.g. we may be a button loaded from a resource, with no callback function | |
1302 | // defined. | |
e766c8a9 | 1303 | void wxWindowMac::OnCommand(wxWindowMac& win, wxCommandEvent& event) |
e9576ca5 | 1304 | { |
e7549107 SC |
1305 | if ( GetEventHandler()->ProcessEvent(event) ) |
1306 | return; | |
1307 | if ( m_parent ) | |
1308 | m_parent->GetEventHandler()->OnCommand(win, event); | |
e9576ca5 | 1309 | } |
e7549107 | 1310 | #endif // WXWIN_COMPATIBILITY_2 |
e9576ca5 | 1311 | |
e7549107 | 1312 | #if WXWIN_COMPATIBILITY |
e766c8a9 | 1313 | wxObject* wxWindowMac::GetChild(int number) const |
e9576ca5 | 1314 | { |
e7549107 SC |
1315 | // Return a pointer to the Nth object in the Panel |
1316 | wxNode *node = GetChildren().First(); | |
1317 | int n = number; | |
1318 | while (node && n--) | |
1319 | node = node->Next(); | |
1320 | if ( node ) | |
519cb848 | 1321 | { |
e7549107 SC |
1322 | wxObject *obj = (wxObject *)node->Data(); |
1323 | return(obj); | |
519cb848 SC |
1324 | } |
1325 | else | |
e7549107 | 1326 | return NULL; |
e9576ca5 | 1327 | } |
e7549107 | 1328 | #endif // WXWIN_COMPATIBILITY |
e9576ca5 | 1329 | |
e766c8a9 | 1330 | void wxWindowMac::OnSetFocus(wxFocusEvent& event) |
7810c95b SC |
1331 | { |
1332 | // panel wants to track the window which was the last to have focus in it, | |
1333 | // so we want to set ourselves as the window which last had focus | |
1334 | // | |
1335 | // notice that it's also important to do it upwards the tree becaus | |
1336 | // otherwise when the top level panel gets focus, it won't set it back to | |
1337 | // us, but to some other sibling | |
14c9cbdb | 1338 | |
c1fb8167 SC |
1339 | // CS:don't know if this is still needed: |
1340 | //wxChildFocusEvent eventFocus(this); | |
1341 | //(void)GetEventHandler()->ProcessEvent(eventFocus); | |
7810c95b SC |
1342 | |
1343 | event.Skip(); | |
1344 | } | |
1345 | ||
e766c8a9 | 1346 | void wxWindowMac::Clear() |
e9576ca5 | 1347 | { |
1c310985 SC |
1348 | wxClientDC dc(this); |
1349 | wxBrush brush(GetBackgroundColour(), wxSOLID); | |
1350 | dc.SetBackground(brush); | |
1351 | dc.Clear(); | |
e9576ca5 SC |
1352 | } |
1353 | ||
e7549107 | 1354 | // Setup background and foreground colours correctly |
e766c8a9 | 1355 | void wxWindowMac::SetupColours() |
e9576ca5 | 1356 | { |
e7549107 SC |
1357 | if ( GetParent() ) |
1358 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
e9576ca5 SC |
1359 | } |
1360 | ||
e766c8a9 | 1361 | void wxWindowMac::OnIdle(wxIdleEvent& event) |
e9576ca5 | 1362 | { |
519cb848 SC |
1363 | /* |
1364 | // Check if we need to send a LEAVE event | |
1365 | if (m_mouseInWindow) | |
1366 | { | |
1367 | POINT pt; | |
1368 | ::GetCursorPos(&pt); | |
1369 | if (::WindowFromPoint(pt) != (HWND) GetHWND()) | |
1370 | { | |
1371 | // Generate a LEAVE event | |
1372 | m_mouseInWindow = FALSE; | |
1373 | MSWOnMouseLeave(pt.x, pt.y, 0); | |
1374 | } | |
e9576ca5 SC |
1375 | } |
1376 | */ | |
1377 | ||
1378 | // This calls the UI-update mechanism (querying windows for | |
1379 | // menu/toolbar/control state information) | |
6264b550 | 1380 | UpdateWindowUI(); |
e9576ca5 SC |
1381 | } |
1382 | ||
1383 | // Raise the window to the top of the Z order | |
e766c8a9 | 1384 | void wxWindowMac::Raise() |
e9576ca5 | 1385 | { |
e9576ca5 SC |
1386 | } |
1387 | ||
1388 | // Lower the window to the bottom of the Z order | |
e766c8a9 | 1389 | void wxWindowMac::Lower() |
e9576ca5 | 1390 | { |
e9576ca5 SC |
1391 | } |
1392 | ||
e766c8a9 | 1393 | void wxWindowMac::DoSetClientSize(int width, int height) |
519cb848 | 1394 | { |
6264b550 RR |
1395 | if ( width != -1 || height != -1 ) |
1396 | { | |
14c9cbdb | 1397 | |
6264b550 RR |
1398 | if ( width != -1 && m_vScrollBar ) |
1399 | width += MAC_SCROLLBAR_SIZE ; | |
1400 | if ( height != -1 && m_vScrollBar ) | |
1401 | height += MAC_SCROLLBAR_SIZE ; | |
519cb848 | 1402 | |
6264b550 RR |
1403 | width += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
1404 | height += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ; | |
2f1ae414 | 1405 | |
6264b550 RR |
1406 | DoSetSize( -1 , -1 , width , height ) ; |
1407 | } | |
519cb848 SC |
1408 | } |
1409 | ||
519cb848 | 1410 | |
e766c8a9 | 1411 | wxWindowMac* wxWindowMac::s_lastMouseWindow = NULL ; |
519cb848 | 1412 | |
14c9cbdb | 1413 | bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) |
519cb848 | 1414 | { |
a07c1212 SC |
1415 | if ( IsTopLevel() ) |
1416 | { | |
1417 | if ((point.x < 0) || (point.y < 0) || | |
1418 | (point.x > (m_width)) || (point.y > (m_height))) | |
1419 | return FALSE; | |
1420 | } | |
1421 | else | |
1422 | { | |
1423 | if ((point.x < m_x) || (point.y < m_y) || | |
1424 | (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) | |
1425 | return FALSE; | |
1426 | } | |
14c9cbdb | 1427 | |
76a5e5d2 | 1428 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
519cb848 | 1429 | |
6264b550 | 1430 | wxPoint newPoint( point ) ; |
519cb848 | 1431 | |
a07c1212 SC |
1432 | if ( !IsTopLevel() ) |
1433 | { | |
1434 | newPoint.x -= m_x; | |
1435 | newPoint.y -= m_y; | |
1436 | } | |
14c9cbdb | 1437 | |
6264b550 RR |
1438 | for (wxNode *node = GetChildren().First(); node; node = node->Next()) |
1439 | { | |
1440 | wxWindowMac *child = (wxWindowMac*)node->Data(); | |
1441 | // added the m_isShown test --dmazzoni | |
1c310985 | 1442 | if ( child->MacGetRootWindow() == window && child->m_isShown ) |
6264b550 RR |
1443 | { |
1444 | if (child->MacGetWindowFromPointSub(newPoint , outWin )) | |
1445 | return TRUE; | |
1446 | } | |
1447 | } | |
519cb848 | 1448 | |
6264b550 RR |
1449 | *outWin = this ; |
1450 | return TRUE; | |
519cb848 SC |
1451 | } |
1452 | ||
14c9cbdb | 1453 | bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin ) |
519cb848 | 1454 | { |
6264b550 | 1455 | WindowRef window ; |
14c9cbdb | 1456 | |
6264b550 RR |
1457 | Point pt = { screenpoint.y , screenpoint.x } ; |
1458 | if ( ::FindWindow( pt , &window ) == 3 ) | |
1459 | { | |
14c9cbdb | 1460 | |
a07c1212 SC |
1461 | wxWindowMac* win = wxFindWinFromMacWindow( window ) ; |
1462 | if ( win ) | |
1463 | { | |
ed60b502 RR |
1464 | // No, this yields the CLIENT are, we need the whole frame. RR. |
1465 | // point = win->ScreenToClient( point ) ; | |
14c9cbdb RD |
1466 | |
1467 | GrafPtr port; | |
ed60b502 RR |
1468 | ::GetPort( &port ) ; |
1469 | ::SetPort( UMAGetWindowPort( window ) ) ; | |
1470 | ::GlobalToLocal( &pt ) ; | |
1471 | ::SetPort( port ) ; | |
1472 | ||
1473 | wxPoint point( pt.h, pt.v ) ; | |
14c9cbdb | 1474 | |
6264b550 | 1475 | return win->MacGetWindowFromPointSub( point , outWin ) ; |
a07c1212 | 1476 | } |
6264b550 RR |
1477 | } |
1478 | return FALSE ; | |
519cb848 SC |
1479 | } |
1480 | ||
1481 | extern int wxBusyCursorCount ; | |
32b5be3d | 1482 | static wxWindow *gs_lastWhich = NULL; |
519cb848 | 1483 | |
467e3168 SC |
1484 | bool wxWindowMac::MacSetupCursor( const wxPoint& pt) |
1485 | { | |
1486 | // first trigger a set cursor event | |
1487 | ||
1488 | wxPoint clientorigin = GetClientAreaOrigin() ; | |
1489 | wxSize clientsize = GetClientSize() ; | |
1490 | wxCursor cursor ; | |
1491 | if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) | |
1492 | { | |
1493 | wxSetCursorEvent event( pt.x , pt.y ); | |
1494 | ||
1495 | bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); | |
1496 | if ( processedEvtSetCursor && event.HasCursor() ) | |
1497 | { | |
1498 | cursor = event.GetCursor() ; | |
1499 | } | |
1500 | else | |
1501 | { | |
1502 | ||
1503 | // the test for processedEvtSetCursor is here to prevent using m_cursor | |
1504 | // if the user code caught EVT_SET_CURSOR() and returned nothing from | |
1505 | // it - this is a way to say that our cursor shouldn't be used for this | |
1506 | // point | |
1507 | if ( !processedEvtSetCursor && m_cursor.Ok() ) | |
1508 | { | |
1509 | cursor = m_cursor ; | |
1510 | } | |
1511 | if ( wxIsBusy() ) | |
1512 | { | |
1513 | } | |
1514 | else | |
1515 | { | |
1516 | if ( !GetParent() ) | |
1517 | cursor = *wxSTANDARD_CURSOR ; | |
1518 | } | |
1519 | } | |
1520 | if ( cursor.Ok() ) | |
1521 | cursor.MacInstall() ; | |
1522 | } | |
1523 | return cursor.Ok() ; | |
1524 | } | |
1525 | ||
e766c8a9 | 1526 | bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) |
519cb848 | 1527 | { |
6264b550 RR |
1528 | if ((event.m_x < m_x) || (event.m_y < m_y) || |
1529 | (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height))) | |
1530 | return FALSE; | |
14c9cbdb | 1531 | |
6264b550 | 1532 | |
327788ac | 1533 | if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */) |
14c9cbdb RD |
1534 | return FALSE ; |
1535 | ||
76a5e5d2 | 1536 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
6264b550 RR |
1537 | |
1538 | event.m_x -= m_x; | |
1539 | event.m_y -= m_y; | |
14c9cbdb | 1540 | |
6264b550 RR |
1541 | int x = event.m_x ; |
1542 | int y = event.m_y ; | |
1543 | ||
1544 | for (wxNode *node = GetChildren().First(); node; node = node->Next()) | |
1545 | { | |
1546 | wxWindowMac *child = (wxWindowMac*)node->Data(); | |
1c310985 | 1547 | if ( child->MacGetRootWindow() == window && child->IsShown() && child->IsEnabled() ) |
6264b550 RR |
1548 | { |
1549 | if (child->MacDispatchMouseEvent(event)) | |
1550 | return TRUE; | |
1551 | } | |
7810c95b | 1552 | } |
2f1ae414 | 1553 | |
467e3168 SC |
1554 | wxWindow* cursorTarget = this ; |
1555 | wxPoint cursorPoint( x , y ) ; | |
14c9cbdb | 1556 | |
467e3168 | 1557 | while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) |
6264b550 | 1558 | { |
467e3168 SC |
1559 | cursorTarget = cursorTarget->GetParent() ; |
1560 | if ( cursorTarget ) | |
1561 | cursorPoint += cursorTarget->GetPosition() ; | |
6264b550 | 1562 | } |
467e3168 SC |
1563 | event.m_x = x ; |
1564 | event.m_y = y ; | |
1565 | event.SetEventObject( this ) ; | |
14c9cbdb | 1566 | |
6264b550 RR |
1567 | if ( event.GetEventType() == wxEVT_LEFT_DOWN ) |
1568 | { | |
1569 | // set focus to this window | |
1570 | if (AcceptsFocus() && FindFocus()!=this) | |
1571 | SetFocus(); | |
1572 | } | |
14c9cbdb | 1573 | |
2f1ae414 | 1574 | #if wxUSE_TOOLTIPS |
14c9cbdb | 1575 | if ( event.GetEventType() == wxEVT_MOTION |
6264b550 RR |
1576 | || event.GetEventType() == wxEVT_ENTER_WINDOW |
1577 | || event.GetEventType() == wxEVT_LEAVE_WINDOW ) | |
2f1ae414 SC |
1578 | wxToolTip::RelayEvent( this , event); |
1579 | #endif // wxUSE_TOOLTIPS | |
ed60b502 | 1580 | |
32b5be3d RR |
1581 | if (gs_lastWhich != this) |
1582 | { | |
1583 | gs_lastWhich = this; | |
14c9cbdb | 1584 | |
32b5be3d RR |
1585 | // Double clicks must always occur on the same window |
1586 | if (event.GetEventType() == wxEVT_LEFT_DCLICK) | |
1587 | event.SetEventType( wxEVT_LEFT_DOWN ); | |
1588 | if (event.GetEventType() == wxEVT_RIGHT_DCLICK) | |
1589 | event.SetEventType( wxEVT_RIGHT_DOWN ); | |
14c9cbdb | 1590 | |
32b5be3d RR |
1591 | // Same for mouse up events |
1592 | if (event.GetEventType() == wxEVT_LEFT_UP) | |
1593 | return TRUE; | |
1594 | if (event.GetEventType() == wxEVT_RIGHT_UP) | |
1595 | return TRUE; | |
1596 | } | |
1597 | ||
6264b550 | 1598 | GetEventHandler()->ProcessEvent( event ) ; |
ed60b502 | 1599 | |
6264b550 | 1600 | return TRUE; |
519cb848 SC |
1601 | } |
1602 | ||
e766c8a9 | 1603 | wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) |
2f1ae414 | 1604 | { |
6264b550 RR |
1605 | if ( m_tooltip ) |
1606 | { | |
1607 | return m_tooltip->GetTip() ; | |
1608 | } | |
1609 | return "" ; | |
2f1ae414 | 1610 | } |
6264b550 | 1611 | |
1c310985 | 1612 | void wxWindowMac::Update() |
519cb848 | 1613 | { |
1c310985 SC |
1614 | wxTopLevelWindowMac* win = MacGetTopLevelWindow( ) ; |
1615 | if ( win ) | |
f1759123 | 1616 | { |
1c310985 | 1617 | win->MacUpdate( 0 ) ; |
bec721ec | 1618 | #if TARGET_API_MAC_CARBON |
ed60b502 RR |
1619 | if ( QDIsPortBuffered( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) ) ) |
1620 | { | |
1621 | QDFlushPortBuffer( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) , NULL ) ; | |
1622 | } | |
bec721ec | 1623 | #endif |
ed60b502 | 1624 | } |
519cb848 SC |
1625 | } |
1626 | ||
14c9cbdb | 1627 | wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const |
519cb848 | 1628 | { |
1c310985 | 1629 | wxTopLevelWindowMac* win = NULL ; |
76a5e5d2 | 1630 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
1c310985 | 1631 | if ( window ) |
6264b550 | 1632 | { |
1c310985 | 1633 | win = wxFindWinFromMacWindow( window ) ; |
14c9cbdb | 1634 | } |
1c310985 | 1635 | return win ; |
519cb848 SC |
1636 | } |
1637 | ||
7372fd0a | 1638 | const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings ) |
94abc21f SC |
1639 | { |
1640 | RgnHandle visRgn = NewRgn() ; | |
de043984 | 1641 | RgnHandle tempRgn = NewRgn() ; |
be0b002a | 1642 | RgnHandle tempStaticBoxRgn = NewRgn() ; |
14c9cbdb | 1643 | |
94abc21f SC |
1644 | SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ; |
1645 | ||
de043984 SC |
1646 | //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox |
1647 | if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) | |
94abc21f | 1648 | { |
de043984 SC |
1649 | int borderTop = 14 ; |
1650 | int borderOther = 4 ; | |
14c9cbdb | 1651 | |
be0b002a SC |
1652 | SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ; |
1653 | DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ; | |
de043984 | 1654 | } |
94abc21f | 1655 | |
a07c1212 | 1656 | if ( !IsTopLevel() ) |
de043984 | 1657 | { |
a07c1212 SC |
1658 | wxWindow* parent = GetParent() ; |
1659 | while( parent ) | |
1660 | { | |
1661 | wxSize size = parent->GetSize() ; | |
1662 | int x , y ; | |
1663 | x = y = 0 ; | |
1664 | parent->MacWindowToRootWindow( &x, &y ) ; | |
1665 | MacRootWindowToWindow( &x , &y ) ; | |
b8f2db1f SC |
1666 | |
1667 | SetRectRgn( tempRgn , | |
1668 | x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , | |
1669 | x + size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), | |
1670 | y + size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; | |
1671 | ||
a07c1212 SC |
1672 | SectRgn( visRgn , tempRgn , visRgn ) ; |
1673 | if ( parent->IsTopLevel() ) | |
1674 | break ; | |
1675 | parent = parent->GetParent() ; | |
1676 | } | |
de043984 | 1677 | } |
7372fd0a | 1678 | if ( respectChildrenAndSiblings ) |
de043984 | 1679 | { |
7372fd0a SC |
1680 | if ( GetWindowStyle() & wxCLIP_CHILDREN ) |
1681 | { | |
1682 | for (wxNode *node = GetChildren().First(); node; node = node->Next()) | |
94abc21f | 1683 | { |
7372fd0a | 1684 | wxWindowMac *child = (wxWindowMac*)node->Data(); |
14c9cbdb | 1685 | |
7372fd0a SC |
1686 | if ( !child->IsTopLevel() && child->IsShown() ) |
1687 | { | |
1688 | SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; | |
be0b002a SC |
1689 | if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) ) |
1690 | { | |
1691 | int borderTop = 14 ; | |
1692 | int borderOther = 4 ; | |
1693 | ||
1694 | SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; | |
1695 | DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; | |
1696 | } | |
7372fd0a SC |
1697 | DiffRgn( visRgn , tempRgn , visRgn ) ; |
1698 | } | |
94abc21f | 1699 | } |
7372fd0a | 1700 | } |
94abc21f | 1701 | |
7372fd0a SC |
1702 | if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) |
1703 | { | |
1704 | bool thisWindowThrough = false ; | |
1705 | for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) | |
94abc21f | 1706 | { |
7372fd0a SC |
1707 | wxWindowMac *sibling = (wxWindowMac*)node->Data(); |
1708 | if ( sibling == this ) | |
1709 | { | |
1710 | thisWindowThrough = true ; | |
1711 | continue ; | |
1712 | } | |
1713 | if( !thisWindowThrough ) | |
1714 | { | |
1715 | continue ; | |
1716 | } | |
1717 | ||
1718 | if ( !sibling->IsTopLevel() && sibling->IsShown() ) | |
1719 | { | |
1720 | SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; | |
be0b002a SC |
1721 | if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) ) |
1722 | { | |
1723 | int borderTop = 14 ; | |
1724 | int borderOther = 4 ; | |
1725 | ||
1726 | SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ; | |
1727 | DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; | |
1728 | } | |
7372fd0a SC |
1729 | DiffRgn( visRgn , tempRgn , visRgn ) ; |
1730 | } | |
94abc21f | 1731 | } |
7372fd0a | 1732 | } |
94abc21f SC |
1733 | } |
1734 | m_macVisibleRegion = visRgn ; | |
1735 | DisposeRgn( visRgn ) ; | |
de043984 | 1736 | DisposeRgn( tempRgn ) ; |
be0b002a | 1737 | DisposeRgn( tempStaticBoxRgn ) ; |
94abc21f SC |
1738 | return m_macVisibleRegion ; |
1739 | } | |
1740 | ||
76a5e5d2 | 1741 | void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) |
519cb848 | 1742 | { |
76a5e5d2 | 1743 | RgnHandle updatergn = (RgnHandle) updatergnr ; |
6264b550 | 1744 | // updatergn is always already clipped to our boundaries |
94abc21f | 1745 | // it is in window coordinates, not in client coordinates |
14c9cbdb | 1746 | |
76a5e5d2 | 1747 | WindowRef window = (WindowRef) MacGetRootWindow() ; |
6264b550 RR |
1748 | |
1749 | { | |
94abc21f | 1750 | // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates |
1c310985 SC |
1751 | RgnHandle ownUpdateRgn = NewRgn() ; |
1752 | CopyRgn( updatergn , ownUpdateRgn ) ; | |
14c9cbdb | 1753 | |
76a5e5d2 | 1754 | SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ; |
14c9cbdb | 1755 | |
94abc21f | 1756 | // newupdate is the update region in client coordinates |
1c310985 SC |
1757 | RgnHandle newupdate = NewRgn() ; |
1758 | wxSize point = GetClientSize() ; | |
1759 | wxPoint origin = GetClientAreaOrigin() ; | |
1c310985 SC |
1760 | SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ; |
1761 | SectRgn( newupdate , ownUpdateRgn , newupdate ) ; | |
1762 | OffsetRgn( newupdate , -origin.x , -origin.y ) ; | |
1763 | m_updateRegion = newupdate ; | |
1764 | DisposeRgn( newupdate ) ; // it's been cloned to m_updateRegion | |
14c9cbdb | 1765 | |
e8788ed0 | 1766 | if ( erase && !EmptyRgn(ownUpdateRgn) ) |
14c9cbdb | 1767 | { |
1c310985 | 1768 | wxWindowDC dc(this); |
e8788ed0 | 1769 | dc.SetClippingRegion(wxRegion(ownUpdateRgn)); |
1c310985 SC |
1770 | wxEraseEvent eevent( GetId(), &dc ); |
1771 | eevent.SetEventObject( this ); | |
1772 | GetEventHandler()->ProcessEvent( eevent ); | |
1773 | ||
1774 | wxNcPaintEvent eventNc( GetId() ); | |
1775 | eventNc.SetEventObject( this ); | |
1776 | GetEventHandler()->ProcessEvent( eventNc ); | |
6264b550 | 1777 | } |
14c9cbdb | 1778 | DisposeRgn( ownUpdateRgn ) ; |
1c310985 | 1779 | if ( !m_updateRegion.Empty() ) |
6264b550 | 1780 | { |
1c310985 SC |
1781 | wxPaintEvent event; |
1782 | event.m_timeStamp = time ; | |
1783 | event.SetEventObject(this); | |
14c9cbdb RD |
1784 | GetEventHandler()->ProcessEvent(event); |
1785 | } | |
6264b550 | 1786 | } |
14c9cbdb | 1787 | |
1c310985 | 1788 | // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively |
14c9cbdb RD |
1789 | |
1790 | RgnHandle childupdate = NewRgn() ; | |
6264b550 RR |
1791 | for (wxNode *node = GetChildren().First(); node; node = node->Next()) |
1792 | { | |
94abc21f SC |
1793 | // calculate the update region for the child windows by intersecting the window rectangle with our own |
1794 | // passed in update region and then offset it to be client-wise window coordinates again | |
6264b550 RR |
1795 | wxWindowMac *child = (wxWindowMac*)node->Data(); |
1796 | SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; | |
1797 | SectRgn( childupdate , updatergn , childupdate ) ; | |
1798 | OffsetRgn( childupdate , -child->m_x , -child->m_y ) ; | |
1c310985 | 1799 | if ( child->MacGetRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) ) |
6264b550 RR |
1800 | { |
1801 | // because dialogs may also be children | |
1c310985 | 1802 | child->MacRedraw( childupdate , time , erase ) ; |
6264b550 RR |
1803 | } |
1804 | } | |
1805 | DisposeRgn( childupdate ) ; | |
1806 | // eventually a draw grow box here | |
14c9cbdb | 1807 | |
519cb848 SC |
1808 | } |
1809 | ||
76a5e5d2 | 1810 | WXHWND wxWindowMac::MacGetRootWindow() const |
519cb848 | 1811 | { |
6264b550 | 1812 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 1813 | |
6264b550 RR |
1814 | while( iter ) |
1815 | { | |
1c310985 SC |
1816 | if ( iter->IsTopLevel() ) |
1817 | return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ; | |
519cb848 | 1818 | |
6264b550 | 1819 | iter = iter->GetParent() ; |
14c9cbdb | 1820 | } |
6264b550 RR |
1821 | wxASSERT_MSG( 1 , "No valid mac root window" ) ; |
1822 | return NULL ; | |
519cb848 SC |
1823 | } |
1824 | ||
14c9cbdb | 1825 | void wxWindowMac::MacCreateScrollBars( long style ) |
519cb848 | 1826 | { |
6264b550 | 1827 | wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; |
14c9cbdb | 1828 | |
6264b550 RR |
1829 | bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; |
1830 | int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; | |
1831 | int width, height ; | |
1832 | GetClientSize( &width , &height ) ; | |
14c9cbdb | 1833 | |
6264b550 RR |
1834 | wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ; |
1835 | wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ; | |
1836 | wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ; | |
1837 | wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ; | |
14c9cbdb RD |
1838 | |
1839 | m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint, | |
6264b550 RR |
1840 | vSize , wxVERTICAL); |
1841 | ||
1842 | if ( style & wxVSCROLL ) | |
1843 | { | |
14c9cbdb | 1844 | |
6264b550 RR |
1845 | } |
1846 | else | |
1847 | { | |
1848 | m_vScrollBar->Show(false) ; | |
1849 | } | |
14c9cbdb | 1850 | m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint, |
6264b550 RR |
1851 | hSize , wxHORIZONTAL); |
1852 | if ( style & wxHSCROLL ) | |
1853 | { | |
1854 | } | |
1855 | else | |
1856 | { | |
1857 | m_hScrollBar->Show(false) ; | |
1858 | } | |
14c9cbdb | 1859 | |
6264b550 RR |
1860 | // because the create does not take into account the client area origin |
1861 | MacRepositionScrollBars() ; // we might have a real position shift | |
519cb848 SC |
1862 | } |
1863 | ||
e766c8a9 | 1864 | void wxWindowMac::MacRepositionScrollBars() |
519cb848 | 1865 | { |
6264b550 RR |
1866 | bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ; |
1867 | int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ; | |
14c9cbdb | 1868 | |
6264b550 | 1869 | // get real client area |
14c9cbdb RD |
1870 | |
1871 | int width = m_width ; | |
6264b550 RR |
1872 | int height = m_height ; |
1873 | ||
1874 | width -= MacGetLeftBorderSize() + MacGetRightBorderSize(); | |
1875 | height -= MacGetTopBorderSize() + MacGetBottomBorderSize(); | |
14c9cbdb | 1876 | |
6264b550 RR |
1877 | wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ; |
1878 | wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ; | |
1879 | wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ; | |
1880 | wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ; | |
14c9cbdb RD |
1881 | |
1882 | int x = 0 ; | |
6264b550 RR |
1883 | int y = 0 ; |
1884 | int w = m_width ; | |
1885 | int h = m_height ; | |
14c9cbdb | 1886 | |
6264b550 RR |
1887 | MacClientToRootWindow( &x , &y ) ; |
1888 | MacClientToRootWindow( &w , &h ) ; | |
14c9cbdb | 1889 | |
6264b550 | 1890 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 1891 | |
6264b550 RR |
1892 | int totW = 10000 , totH = 10000; |
1893 | while( iter ) | |
1894 | { | |
1c310985 | 1895 | if ( iter->IsTopLevel() ) |
6264b550 RR |
1896 | { |
1897 | totW = iter->m_width ; | |
1898 | totH = iter->m_height ; | |
1899 | break ; | |
1900 | } | |
1901 | ||
1902 | iter = iter->GetParent() ; | |
14c9cbdb RD |
1903 | } |
1904 | ||
6264b550 RR |
1905 | if ( x == 0 ) |
1906 | { | |
1907 | hPoint.x = -1 ; | |
1908 | hSize.x += 1 ; | |
1909 | } | |
1910 | if ( y == 0 ) | |
1911 | { | |
1912 | vPoint.y = -1 ; | |
1913 | vSize.y += 1 ; | |
1914 | } | |
14c9cbdb | 1915 | |
6264b550 RR |
1916 | if ( w-x >= totW ) |
1917 | { | |
1918 | hSize.x += 1 ; | |
1919 | vPoint.x += 1 ; | |
1920 | } | |
14c9cbdb | 1921 | |
6264b550 RR |
1922 | if ( h-y >= totH ) |
1923 | { | |
1924 | vSize.y += 1 ; | |
1925 | hPoint.y += 1 ; | |
1926 | } | |
1927 | ||
1928 | if ( m_vScrollBar ) | |
1929 | { | |
1930 | m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE); | |
1931 | } | |
1932 | if ( m_hScrollBar ) | |
1933 | { | |
1934 | m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE); | |
1935 | } | |
519cb848 SC |
1936 | } |
1937 | ||
e766c8a9 | 1938 | bool wxWindowMac::AcceptsFocus() const |
7c551d95 SC |
1939 | { |
1940 | return MacCanFocus() && wxWindowBase::AcceptsFocus(); | |
1941 | } | |
519cb848 | 1942 | |
14c9cbdb | 1943 | WXWidget wxWindowMac::MacGetContainerForEmbedding() |
519cb848 | 1944 | { |
1c310985 | 1945 | return GetParent()->MacGetContainerForEmbedding() ; |
519cb848 SC |
1946 | } |
1947 | ||
14c9cbdb | 1948 | void wxWindowMac::MacSuperChangedPosition() |
519cb848 | 1949 | { |
6264b550 | 1950 | // only window-absolute structures have to be moved i.e. controls |
519cb848 | 1951 | |
6264b550 RR |
1952 | wxNode *node = GetChildren().First(); |
1953 | while ( node ) | |
1954 | { | |
1955 | wxWindowMac *child = (wxWindowMac *)node->Data(); | |
1956 | child->MacSuperChangedPosition() ; | |
1957 | node = node->Next(); | |
1958 | } | |
519cb848 | 1959 | } |
519cb848 | 1960 | |
14c9cbdb | 1961 | void wxWindowMac::MacTopLevelWindowChangedPosition() |
a3bf4a62 | 1962 | { |
6264b550 | 1963 | // only screen-absolute structures have to be moved i.e. glcanvas |
a3bf4a62 | 1964 | |
6264b550 RR |
1965 | wxNode *node = GetChildren().First(); |
1966 | while ( node ) | |
1967 | { | |
1968 | wxWindowMac *child = (wxWindowMac *)node->Data(); | |
1969 | child->MacTopLevelWindowChangedPosition() ; | |
1970 | node = node->Next(); | |
1971 | } | |
a3bf4a62 | 1972 | } |
e766c8a9 | 1973 | long wxWindowMac::MacGetLeftBorderSize( ) const |
2f1ae414 | 1974 | { |
1c310985 | 1975 | if( IsTopLevel() ) |
6264b550 | 1976 | return 0 ; |
2f1ae414 SC |
1977 | |
1978 | if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER ) | |
1979 | { | |
ed60b502 | 1980 | SInt32 border = 3 ; |
1c310985 | 1981 | #if wxMAC_USE_THEME_BORDER |
14c9cbdb | 1982 | #if TARGET_CARBON |
ed60b502 | 1983 | GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; |
1c310985 SC |
1984 | #endif |
1985 | #endif | |
ed60b502 | 1986 | return border ; |
2f1ae414 SC |
1987 | } |
1988 | else if ( m_windowStyle &wxDOUBLE_BORDER) | |
1989 | { | |
ed60b502 | 1990 | SInt32 border = 3 ; |
1c310985 | 1991 | #if wxMAC_USE_THEME_BORDER |
14c9cbdb | 1992 | #if TARGET_CARBON |
ed60b502 | 1993 | GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; |
1c310985 SC |
1994 | #endif |
1995 | #endif | |
ed60b502 | 1996 | return border ; |
2f1ae414 SC |
1997 | } |
1998 | else if (m_windowStyle &wxSIMPLE_BORDER) | |
1999 | { | |
6264b550 | 2000 | return 1 ; |
2f1ae414 | 2001 | } |
6264b550 | 2002 | return 0 ; |
2f1ae414 SC |
2003 | } |
2004 | ||
e766c8a9 | 2005 | long wxWindowMac::MacGetRightBorderSize( ) const |
5b781a67 | 2006 | { |
1c310985 SC |
2007 | // they are all symmetric in mac themes |
2008 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
2009 | } |
2010 | ||
e766c8a9 | 2011 | long wxWindowMac::MacGetTopBorderSize( ) const |
5b781a67 | 2012 | { |
1c310985 SC |
2013 | // they are all symmetric in mac themes |
2014 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
2015 | } |
2016 | ||
e766c8a9 | 2017 | long wxWindowMac::MacGetBottomBorderSize( ) const |
5b781a67 | 2018 | { |
1c310985 SC |
2019 | // they are all symmetric in mac themes |
2020 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
2021 | } |
2022 | ||
14c9cbdb | 2023 | long wxWindowMac::MacRemoveBordersFromStyle( long style ) |
2f1ae414 | 2024 | { |
6264b550 | 2025 | return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ; |
2f1ae414 | 2026 | } |
0a67a93b | 2027 | |
e766c8a9 | 2028 | // Find the wxWindowMac at the current mouse position, returning the mouse |
3723b7b1 | 2029 | // position. |
e766c8a9 | 2030 | wxWindowMac* wxFindWindowAtPointer(wxPoint& pt) |
3723b7b1 | 2031 | { |
59a12e90 | 2032 | pt = wxGetMousePosition(); |
e766c8a9 | 2033 | wxWindowMac* found = wxFindWindowAtPoint(pt); |
59a12e90 | 2034 | return found; |
3723b7b1 JS |
2035 | } |
2036 | ||
2037 | // Get the current mouse position. | |
2038 | wxPoint wxGetMousePosition() | |
2039 | { | |
57591e0e JS |
2040 | int x, y; |
2041 | wxGetMousePosition(& x, & y); | |
2042 | return wxPoint(x, y); | |
3723b7b1 JS |
2043 | } |
2044 |