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