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