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