]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
e766c8a9 | 3 | // Purpose: wxWindowMac |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 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" | |
03e11df5 GD |
26 | #include "wx/scrolbar.h" |
27 | #include "wx/statbox.h" | |
e9576ca5 SC |
28 | #include "wx/button.h" |
29 | #include "wx/settings.h" | |
30 | #include "wx/msgdlg.h" | |
31 | #include "wx/frame.h" | |
2f1ae414 | 32 | #include "wx/tooltip.h" |
c809f3be | 33 | #include "wx/statusbr.h" |
e9576ca5 | 34 | #include "wx/menuitem.h" |
4ac219f6 | 35 | #include "wx/spinctrl.h" |
e9576ca5 | 36 | #include "wx/log.h" |
467e3168 | 37 | #include "wx/geometry.h" |
00627198 | 38 | #include "wx/textctrl.h" |
e9576ca5 | 39 | |
facd6764 SC |
40 | #include "wx/toolbar.h" |
41 | #include "wx/dc.h" | |
42 | ||
7c551d95 SC |
43 | #if wxUSE_CARET |
44 | #include "wx/caret.h" | |
45 | #endif // wxUSE_CARET | |
46 | ||
db7a550b SC |
47 | #define MAC_SCROLLBAR_SIZE 15 |
48 | #define MAC_SMALL_SCROLLBAR_SIZE 11 | |
519cb848 | 49 | |
d497dca4 | 50 | #include "wx/mac/uma.h" |
66a09d47 SC |
51 | #ifndef __DARWIN__ |
52 | #include <Windows.h> | |
53 | #include <ToolUtils.h> | |
1d879215 DS |
54 | #include <Scrap.h> |
55 | #include <MacTextEditor.h> | |
66a09d47 | 56 | #endif |
519cb848 | 57 | |
41218df1 | 58 | #if TARGET_API_MAC_OSX |
facd6764 | 59 | #ifndef __HIVIEW__ |
8b573fb8 | 60 | #include <HIToolbox/HIView.h> |
facd6764 | 61 | #endif |
41218df1 | 62 | #endif |
facd6764 | 63 | |
e9576ca5 SC |
64 | #if wxUSE_DRAG_AND_DROP |
65 | #include "wx/dnd.h" | |
66 | #endif | |
67 | ||
68 | #include <string.h> | |
69 | ||
70 | extern wxList wxPendingDelete; | |
71 | ||
fc0daf84 SC |
72 | #ifdef __WXUNIVERSAL__ |
73 | IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase) | |
74 | #else // __WXMAC__ | |
75 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) | |
76 | #endif // __WXUNIVERSAL__/__WXMAC__ | |
77 | ||
2f1ae414 | 78 | #if !USE_SHARED_LIBRARY |
fc0daf84 SC |
79 | |
80 | BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) | |
facd6764 SC |
81 | EVT_NC_PAINT(wxWindowMac::OnNcPaint) |
82 | EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) | |
83 | // TODO EVT_PAINT(wxWindowMac::OnPaint) | |
5ca0d812 SC |
84 | EVT_SET_FOCUS(wxWindowMac::OnSetFocus) |
85 | EVT_KILL_FOCUS(wxWindowMac::OnSetFocus) | |
facd6764 | 86 | EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent) |
e9576ca5 SC |
87 | END_EVENT_TABLE() |
88 | ||
2f1ae414 | 89 | #endif |
e9576ca5 | 90 | |
94abc21f SC |
91 | #define wxMAC_DEBUG_REDRAW 0 |
92 | #ifndef wxMAC_DEBUG_REDRAW | |
93 | #define wxMAC_DEBUG_REDRAW 0 | |
94 | #endif | |
95 | ||
5ca0d812 | 96 | #define wxMAC_USE_THEME_BORDER 1 |
e9576ca5 | 97 | |
42ef83fa SC |
98 | // --------------------------------------------------------------------------- |
99 | // Utility Routines to move between different coordinate systems | |
100 | // --------------------------------------------------------------------------- | |
101 | ||
102 | /* | |
103 | * Right now we have the following setup : | |
104 | * a border that is not part of the native control is always outside the | |
105 | * control's border (otherwise we loose all native intelligence, future ways | |
106 | * may be to have a second embedding control responsible for drawing borders | |
107 | * and backgrounds eventually) | |
108 | * so all this border calculations have to be taken into account when calling | |
109 | * native methods or getting native oriented data | |
110 | * so we have three coordinate systems here | |
111 | * wx client coordinates | |
112 | * wx window coordinates (including window frames) | |
113 | * native coordinates | |
114 | */ | |
8b573fb8 | 115 | |
42ef83fa SC |
116 | // |
117 | // originating from native control | |
118 | // | |
119 | ||
120 | ||
121 | void wxMacNativeToWindow( const wxWindow* window , RgnHandle handle ) | |
122 | { | |
8b573fb8 | 123 | OffsetRgn( handle , window->MacGetLeftBorderSize() , window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
124 | } |
125 | ||
126 | void wxMacNativeToWindow( const wxWindow* window , Rect *rect ) | |
127 | { | |
8b573fb8 | 128 | OffsetRect( rect , window->MacGetLeftBorderSize() , window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
129 | } |
130 | ||
131 | // | |
132 | // directed towards native control | |
133 | // | |
134 | ||
135 | void wxMacWindowToNative( const wxWindow* window , RgnHandle handle ) | |
136 | { | |
8b573fb8 | 137 | OffsetRgn( handle , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); |
42ef83fa SC |
138 | } |
139 | ||
140 | void wxMacWindowToNative( const wxWindow* window , Rect *rect ) | |
141 | { | |
8b573fb8 | 142 | OffsetRect( rect , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ) ; |
42ef83fa SC |
143 | } |
144 | ||
145 | ||
facd6764 SC |
146 | // --------------------------------------------------------------------------- |
147 | // Carbon Events | |
148 | // --------------------------------------------------------------------------- | |
8b573fb8 | 149 | |
facd6764 SC |
150 | extern long wxMacTranslateKey(unsigned char key, unsigned char code) ; |
151 | pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) ; | |
152 | ||
f1d527c1 SC |
153 | #if TARGET_API_MAC_OSX |
154 | ||
8b573fb8 | 155 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 |
c2697b87 SC |
156 | enum { |
157 | kEventControlVisibilityChanged = 157 | |
158 | }; | |
159 | #endif | |
160 | ||
f1d527c1 SC |
161 | #endif |
162 | ||
facd6764 SC |
163 | static const EventTypeSpec eventList[] = |
164 | { | |
f1d527c1 | 165 | { kEventClassControl , kEventControlHit } , |
facd6764 | 166 | #if TARGET_API_MAC_OSX |
73fe67bd SC |
167 | { kEventClassControl , kEventControlDraw } , |
168 | { kEventClassControl , kEventControlVisibilityChanged } , | |
169 | { kEventClassControl , kEventControlEnabledStateChanged } , | |
170 | { kEventClassControl , kEventControlHiliteChanged } , | |
f1d527c1 | 171 | { kEventClassControl , kEventControlSetFocusPart } , |
8b573fb8 VZ |
172 | |
173 | { kEventClassService , kEventServiceGetTypes }, | |
174 | { kEventClassService , kEventServiceCopy }, | |
175 | { kEventClassService , kEventServicePaste }, | |
176 | ||
177 | // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only | |
facd6764 | 178 | // { kEventClassControl , kEventControlBoundsChanged } , |
facd6764 SC |
179 | #endif |
180 | } ; | |
181 | ||
182 | static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) | |
183 | { | |
184 | OSStatus result = eventNotHandledErr ; | |
185 | ||
186 | wxMacCarbonEvent cEvent( event ) ; | |
8b573fb8 | 187 | |
facd6764 SC |
188 | ControlRef controlRef ; |
189 | wxWindowMac* thisWindow = (wxWindowMac*) data ; | |
190 | ||
191 | cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; | |
192 | ||
193 | switch( GetEventKind( event ) ) | |
194 | { | |
f1d527c1 | 195 | #if TARGET_API_MAC_OSX |
facd6764 SC |
196 | case kEventControlDraw : |
197 | { | |
1e8cde71 | 198 | RgnHandle updateRgn = NULL ; |
055a486b | 199 | RgnHandle allocatedRgn = NULL ; |
1e8cde71 | 200 | wxRegion visRegion = thisWindow->MacGetVisibleRegion() ; |
8b573fb8 | 201 | if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr ) |
1e8cde71 SC |
202 | { |
203 | updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; | |
204 | } | |
055a486b SC |
205 | else |
206 | { | |
207 | if ( thisWindow->MacGetLeftBorderSize() != 0 || thisWindow->MacGetTopBorderSize() != 0 ) | |
208 | { | |
209 | allocatedRgn = NewRgn() ; | |
210 | CopyRgn( updateRgn , allocatedRgn ) ; | |
42ef83fa SC |
211 | // hide the given region by the new region that must be shifted |
212 | wxMacNativeToWindow( thisWindow , allocatedRgn ) ; | |
213 | updateRgn = allocatedRgn ; | |
055a486b SC |
214 | } |
215 | } | |
facd6764 | 216 | |
8b573fb8 | 217 | #if 0 |
125c7984 | 218 | // in case we would need a coregraphics compliant background erase first |
bcbd6987 | 219 | // now usable to track redraws |
facd6764 SC |
220 | CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ; |
221 | if ( thisWindow->MacIsUserPane() ) | |
222 | { | |
bcbd6987 SC |
223 | static float color = 0.5 ; |
224 | static channel = 0 ; | |
8b573fb8 VZ |
225 | HIRect bounds; |
226 | HIViewGetBounds( controlRef, &bounds ); | |
227 | CGContextSetRGBFillColor( cgContext, channel == 0 ? color : 0.5 , | |
228 | channel == 1 ? color : 0.5 , channel == 2 ? color : 0.5 , 1 ); | |
229 | CGContextFillRect( cgContext, bounds ); | |
230 | color += 0.1 ; | |
231 | if ( color > 0.9 ) | |
232 | { | |
233 | color = 0.5 ; | |
234 | channel++ ; | |
235 | if ( channel == 3 ) | |
236 | channel = 0 ; | |
237 | } | |
facd6764 SC |
238 | } |
239 | #endif | |
bcbd6987 | 240 | if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) |
facd6764 | 241 | result = noErr ; |
055a486b SC |
242 | if ( allocatedRgn ) |
243 | DisposeRgn( allocatedRgn ) ; | |
facd6764 SC |
244 | } |
245 | break ; | |
73fe67bd SC |
246 | case kEventControlVisibilityChanged : |
247 | thisWindow->MacVisibilityChanged() ; | |
248 | break ; | |
249 | case kEventControlEnabledStateChanged : | |
250 | thisWindow->MacEnabledStateChanged() ; | |
251 | break ; | |
252 | case kEventControlHiliteChanged : | |
253 | thisWindow->MacHiliteChanged() ; | |
254 | break ; | |
f1d527c1 SC |
255 | case kEventControlSetFocusPart : |
256 | { | |
257 | Boolean focusEverything = false ; | |
258 | ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode ); | |
259 | if ( cEvent.GetParameter<Boolean>(kEventParamControlFocusEverything , &focusEverything ) == noErr ) | |
260 | { | |
261 | } | |
262 | if ( controlPart == kControlFocusNoPart ) | |
263 | { | |
264 | #if wxUSE_CARET | |
265 | if ( thisWindow->GetCaret() ) | |
266 | { | |
267 | thisWindow->GetCaret()->OnKillFocus(); | |
268 | } | |
269 | #endif // wxUSE_CARET | |
5ca0d812 | 270 | wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); |
f1d527c1 SC |
271 | event.SetEventObject(thisWindow); |
272 | thisWindow->GetEventHandler()->ProcessEvent(event) ; | |
273 | } | |
274 | else | |
275 | { | |
276 | // panel wants to track the window which was the last to have focus in it | |
277 | wxChildFocusEvent eventFocus(thisWindow); | |
278 | thisWindow->GetEventHandler()->ProcessEvent(eventFocus); | |
8b573fb8 | 279 | |
f1d527c1 SC |
280 | #if wxUSE_CARET |
281 | if ( thisWindow->GetCaret() ) | |
282 | { | |
283 | thisWindow->GetCaret()->OnSetFocus(); | |
284 | } | |
285 | #endif // wxUSE_CARET | |
286 | ||
287 | wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); | |
288 | event.SetEventObject(thisWindow); | |
289 | thisWindow->GetEventHandler()->ProcessEvent(event) ; | |
290 | } | |
64fec3ab SC |
291 | if ( thisWindow->MacIsUserPane() ) |
292 | result = noErr ; | |
f1d527c1 SC |
293 | } |
294 | break ; | |
295 | #endif | |
296 | case kEventControlHit : | |
297 | { | |
298 | result = thisWindow->MacControlHit( handler , event ) ; | |
299 | } | |
300 | break ; | |
facd6764 SC |
301 | default : |
302 | break ; | |
303 | } | |
304 | return result ; | |
305 | } | |
306 | ||
e4727773 SC |
307 | static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
308 | { | |
309 | OSStatus result = eventNotHandledErr ; | |
310 | ||
311 | wxMacCarbonEvent cEvent( event ) ; | |
8b573fb8 | 312 | |
e4727773 SC |
313 | ControlRef controlRef ; |
314 | wxWindowMac* thisWindow = (wxWindowMac*) data ; | |
315 | wxTextCtrl* textCtrl = wxDynamicCast( thisWindow , wxTextCtrl ) ; | |
316 | cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ; | |
317 | ||
318 | switch( GetEventKind( event ) ) | |
319 | { | |
320 | case kEventServiceGetTypes : | |
321 | if( textCtrl ) | |
322 | { | |
323 | long from, to ; | |
324 | textCtrl->GetSelection( &from , &to ) ; | |
325 | ||
8b573fb8 | 326 | CFMutableArrayRef copyTypes = 0 , pasteTypes = 0; |
e4727773 SC |
327 | if( from != to ) |
328 | copyTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServiceCopyTypes , typeCFMutableArrayRef ) ; | |
329 | if ( textCtrl->IsEditable() ) | |
330 | pasteTypes = cEvent.GetParameter< CFMutableArrayRef >( kEventParamServicePasteTypes , typeCFMutableArrayRef ) ; | |
8b573fb8 VZ |
331 | |
332 | static const OSType textDataTypes[] = { kTXNTextData /* , 'utxt' , 'PICT', 'MooV', 'AIFF' */ }; | |
e4727773 SC |
333 | for ( size_t i = 0 ; i < WXSIZEOF(textDataTypes) ; ++i ) |
334 | { | |
335 | CFStringRef typestring = CreateTypeStringWithOSType(textDataTypes[i]); | |
336 | if ( typestring ) | |
337 | { | |
338 | if ( copyTypes ) | |
339 | CFArrayAppendValue (copyTypes, typestring) ; | |
340 | if ( pasteTypes ) | |
341 | CFArrayAppendValue (pasteTypes, typestring) ; | |
342 | CFRelease( typestring ) ; | |
343 | } | |
344 | } | |
345 | result = noErr ; | |
346 | } | |
347 | break ; | |
348 | case kEventServiceCopy : | |
349 | if ( textCtrl ) | |
350 | { | |
351 | long from, to ; | |
352 | textCtrl->GetSelection( &from , &to ) ; | |
353 | wxString val = textCtrl->GetValue() ; | |
354 | val = val.Mid( from , to - from ) ; | |
355 | ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ; | |
356 | verify_noerr( ClearScrap( &scrapRef ) ) ; | |
357 | verify_noerr( PutScrapFlavor( scrapRef , kTXNTextData , 0 , val.Length() , val.c_str() ) ) ; | |
358 | result = noErr ; | |
359 | } | |
360 | break ; | |
361 | case kEventServicePaste : | |
362 | if ( textCtrl ) | |
363 | { | |
364 | ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ; | |
365 | Size textSize, pastedSize ; | |
366 | verify_noerr( GetScrapFlavorSize (scrapRef, kTXNTextData, &textSize) ) ; | |
367 | textSize++ ; | |
368 | char *content = new char[textSize] ; | |
8b573fb8 | 369 | GetScrapFlavorData (scrapRef, kTXNTextData, &pastedSize, content ); |
e4727773 | 370 | content[textSize-1] = 0 ; |
8ef4d6e2 SC |
371 | #if wxUSE_UNICODE |
372 | textCtrl->WriteText( wxString( content , wxConvLocal ) ); | |
373 | #else | |
e4727773 | 374 | textCtrl->WriteText( wxString( content ) ) ; |
8ef4d6e2 | 375 | #endif |
e4727773 SC |
376 | delete[] content ; |
377 | result = noErr ; | |
378 | } | |
379 | break ; | |
380 | } | |
8b573fb8 | 381 | |
e4727773 | 382 | return result ; |
8b573fb8 | 383 | } |
e4727773 | 384 | |
facd6764 SC |
385 | pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
386 | { | |
af6b7b80 SC |
387 | EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; |
388 | EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ; | |
389 | wxTheApp->MacSetCurrentEvent( event , handler ) ; | |
facd6764 SC |
390 | OSStatus result = eventNotHandledErr ; |
391 | ||
392 | switch ( GetEventClass( event ) ) | |
393 | { | |
394 | case kEventClassControl : | |
395 | result = wxMacWindowControlEventHandler( handler, event, data ) ; | |
396 | break ; | |
e4727773 SC |
397 | case kEventClassService : |
398 | result = wxMacWindowServiceEventHandler( handler, event , data ) ; | |
facd6764 SC |
399 | default : |
400 | break ; | |
401 | } | |
af6b7b80 | 402 | wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ; |
facd6764 SC |
403 | return result ; |
404 | } | |
405 | ||
406 | DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler ) | |
407 | ||
408 | // --------------------------------------------------------------------------- | |
409 | // UserPane events for non OSX builds | |
410 | // --------------------------------------------------------------------------- | |
8b573fb8 | 411 | |
facd6764 SC |
412 | static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part) |
413 | { | |
414 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
415 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
416 | win->MacControlUserPaneDrawProc(part) ; | |
417 | } | |
418 | ||
419 | static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where) | |
420 | { | |
421 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
422 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
423 | return win->MacControlUserPaneHitTestProc(where.h , where.v) ; | |
424 | } | |
425 | ||
426 | static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc) | |
427 | { | |
428 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
429 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
430 | return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc) ; | |
431 | } | |
432 | ||
433 | static pascal void wxMacControlUserPaneIdleProc(ControlRef control) | |
434 | { | |
435 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
436 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
437 | win->MacControlUserPaneIdleProc() ; | |
438 | } | |
439 | ||
440 | static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) | |
441 | { | |
442 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
443 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
444 | return win->MacControlUserPaneKeyDownProc(keyCode,charCode,modifiers) ; | |
445 | } | |
446 | ||
447 | static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating) | |
448 | { | |
449 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
450 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
451 | win->MacControlUserPaneActivateProc(activating) ; | |
452 | } | |
453 | ||
454 | static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action) | |
455 | { | |
456 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
457 | wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ; | |
458 | return win->MacControlUserPaneFocusProc(action) ; | |
459 | } | |
460 | ||
461 | static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info) | |
462 | { | |
463 | wxWindow * win = wxFindControlFromMacControl(control) ; | |
464 | wxCHECK_RET( win , wxT("Callback from unkown control") ) ; | |
465 | win->MacControlUserPaneBackgroundProc(info) ; | |
466 | } | |
467 | ||
8b573fb8 | 468 | void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part) |
facd6764 | 469 | { |
bcbd6987 SC |
470 | RgnHandle rgn = NewRgn() ; |
471 | GetClip( rgn ) ; | |
472 | wxMacWindowStateSaver sv( this ) ; | |
473 | SectRgn( rgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , rgn ) ; | |
474 | MacDoRedraw( rgn , 0 ) ; | |
475 | DisposeRgn( rgn ) ; | |
facd6764 SC |
476 | } |
477 | ||
8b573fb8 | 478 | wxInt16 wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) |
facd6764 SC |
479 | { |
480 | return kControlNoPart ; | |
481 | } | |
482 | ||
8b573fb8 | 483 | wxInt16 wxWindowMac::MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) |
facd6764 SC |
484 | { |
485 | return kControlNoPart ; | |
486 | } | |
487 | ||
8b573fb8 | 488 | void wxWindowMac::MacControlUserPaneIdleProc() |
facd6764 SC |
489 | { |
490 | } | |
491 | ||
8b573fb8 | 492 | wxInt16 wxWindowMac::MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) |
facd6764 SC |
493 | { |
494 | return kControlNoPart ; | |
495 | } | |
496 | ||
8b573fb8 | 497 | void wxWindowMac::MacControlUserPaneActivateProc(bool activating) |
facd6764 SC |
498 | { |
499 | } | |
500 | ||
8b573fb8 | 501 | wxInt16 wxWindowMac::MacControlUserPaneFocusProc(wxInt16 action) |
facd6764 SC |
502 | { |
503 | return kControlNoPart ; | |
504 | } | |
505 | ||
8b573fb8 | 506 | void wxWindowMac::MacControlUserPaneBackgroundProc(void* info) |
facd6764 SC |
507 | { |
508 | } | |
509 | ||
510 | ControlUserPaneDrawUPP gControlUserPaneDrawUPP = NULL ; | |
511 | ControlUserPaneHitTestUPP gControlUserPaneHitTestUPP = NULL ; | |
512 | ControlUserPaneTrackingUPP gControlUserPaneTrackingUPP = NULL ; | |
513 | ControlUserPaneIdleUPP gControlUserPaneIdleUPP = NULL ; | |
514 | ControlUserPaneKeyDownUPP gControlUserPaneKeyDownUPP = NULL ; | |
515 | ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ; | |
516 | ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ; | |
517 | ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ; | |
e7549107 SC |
518 | |
519 | // =========================================================================== | |
520 | // implementation | |
521 | // =========================================================================== | |
522 | ||
71f2fb52 | 523 | #if KEY_wxList_DEPRECATED |
facd6764 SC |
524 | wxList wxWinMacControlList(wxKEY_INTEGER); |
525 | ||
526 | wxWindow *wxFindControlFromMacControl(ControlRef inControl ) | |
527 | { | |
528 | wxNode *node = wxWinMacControlList.Find((long)inControl); | |
529 | if (!node) | |
530 | return NULL; | |
531 | return (wxControl *)node->GetData(); | |
532 | } | |
533 | ||
534 | void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) | |
535 | { | |
536 | // adding NULL ControlRef is (first) surely a result of an error and | |
537 | // (secondly) breaks native event processing | |
538 | wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); | |
539 | ||
540 | if ( !wxWinMacControlList.Find((long)inControl) ) | |
541 | wxWinMacControlList.Append((long)inControl, control); | |
542 | } | |
543 | ||
544 | void wxRemoveMacControlAssociation(wxWindow *control) | |
545 | { | |
546 | wxWinMacControlList.DeleteObject(control); | |
547 | } | |
71f2fb52 RN |
548 | #else |
549 | ||
550 | WX_DECLARE_HASH_MAP(ControlRef, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap); | |
551 | ||
552 | static MacControlMap wxWinMacControlList; | |
553 | ||
554 | wxWindow *wxFindControlFromMacControl(ControlRef inControl ) | |
555 | { | |
556 | MacControlMap::iterator node = wxWinMacControlList.find(inControl); | |
557 | ||
558 | return (node == wxWinMacControlList.end()) ? NULL : node->second; | |
559 | } | |
560 | ||
561 | void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) | |
562 | { | |
563 | // adding NULL ControlRef is (first) surely a result of an error and | |
564 | // (secondly) breaks native event processing | |
565 | wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); | |
566 | ||
567 | wxWinMacControlList[inControl] = control; | |
568 | } | |
569 | ||
570 | void wxRemoveMacControlAssociation(wxWindow *control) | |
571 | { | |
572 | // iterate over all the elements in the class | |
573 | MacControlMap::iterator it; | |
574 | for ( it = wxWinMacControlList.begin(); it != wxWinMacControlList.end(); ++it ) | |
575 | { | |
576 | if ( it->second == control ) | |
577 | { | |
578 | wxWinMacControlList.erase(it); | |
579 | break; | |
580 | } | |
581 | } | |
582 | } | |
583 | #endif // deprecated wxList | |
facd6764 SC |
584 | |
585 | // UPP functions | |
586 | ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; | |
587 | ||
588 | ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ; | |
589 | ||
590 | // we have to setup the brush in the current port and return noErr | |
8b573fb8 | 591 | // or return an error code so that the control manager walks further up the |
facd6764 SC |
592 | // hierarchy to find a correct background |
593 | ||
594 | pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) | |
595 | { | |
596 | OSStatus status = paramErr ; | |
597 | switch( iMessage ) | |
598 | { | |
599 | case kControlMsgApplyTextColor : | |
600 | break ; | |
601 | case kControlMsgSetUpBackground : | |
602 | { | |
603 | wxWindow* wx = (wxWindow*) wxFindControlFromMacControl( iControl ) ; | |
604 | if ( wx != NULL ) | |
605 | { | |
db7a550b | 606 | /* |
facd6764 SC |
607 | const wxBrush &brush = wx->MacGetBackgroundBrush() ; |
608 | if ( brush.Ok() ) | |
609 | { | |
facd6764 | 610 | wxDC::MacSetupBackgroundForCurrentPort( brush ) ; |
db7a550b SC |
611 | */ |
612 | // this clipping is only needed for non HIView | |
8b573fb8 | 613 | |
facd6764 SC |
614 | RgnHandle clip = NewRgn() ; |
615 | int x = 0 , y = 0; | |
616 | ||
617 | wx->MacWindowToRootWindow( &x,&y ) ; | |
618 | CopyRgn( (RgnHandle) wx->MacGetVisibleRegion().GetWXHRGN() , clip ) ; | |
619 | OffsetRgn( clip , x , y ) ; | |
620 | SetClip( clip ) ; | |
621 | DisposeRgn( clip ) ; | |
622 | ||
623 | status = noErr ; | |
db7a550b | 624 | /* |
facd6764 SC |
625 | } |
626 | else if ( wx->MacIsUserPane() ) | |
627 | { | |
628 | // if we don't have a valid brush for such a control, we have to call the | |
629 | // setup of our parent ourselves | |
630 | status = SetUpControlBackground( (ControlRef) wx->GetParent()->GetHandle() , iDepth , iIsColor ) ; | |
631 | } | |
db7a550b | 632 | */ |
facd6764 SC |
633 | } |
634 | } | |
635 | break ; | |
636 | default : | |
637 | break ; | |
638 | } | |
639 | return status ; | |
640 | } | |
641 | ||
642 | ||
643 | pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) ; | |
644 | pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode partCode ) | |
645 | { | |
646 | if ( partCode != 0) | |
647 | { | |
648 | wxWindow* wx = wxFindControlFromMacControl( control ) ; | |
649 | if ( wx ) | |
650 | { | |
651 | wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ; | |
652 | } | |
653 | } | |
654 | } | |
e7549107 SC |
655 | |
656 | // ---------------------------------------------------------------------------- | |
facd6764 | 657 | // constructors and such |
e7549107 SC |
658 | // ---------------------------------------------------------------------------- |
659 | ||
94f9b1f0 | 660 | wxWindowMac::wxWindowMac() |
8b573fb8 VZ |
661 | { |
662 | Init(); | |
94f9b1f0 SC |
663 | } |
664 | ||
665 | wxWindowMac::wxWindowMac(wxWindowMac *parent, | |
666 | wxWindowID id, | |
667 | const wxPoint& pos , | |
668 | const wxSize& size , | |
669 | long style , | |
670 | const wxString& name ) | |
671 | { | |
672 | Init(); | |
673 | Create(parent, id, pos, size, style, name); | |
674 | } | |
675 | ||
e766c8a9 | 676 | void wxWindowMac::Init() |
519cb848 | 677 | { |
21fd5529 | 678 | m_peer = NULL ; |
79392158 | 679 | m_frozenness = 0 ; |
557d6f32 | 680 | #if WXWIN_COMPATIBILITY_2_4 |
e7549107 | 681 | m_backgroundTransparent = FALSE; |
557d6f32 | 682 | #endif |
e7549107 SC |
683 | |
684 | // as all windows are created with WS_VISIBLE style... | |
685 | m_isShown = TRUE; | |
686 | ||
6264b550 RR |
687 | m_hScrollBar = NULL ; |
688 | m_vScrollBar = NULL ; | |
facd6764 SC |
689 | m_macBackgroundBrush = wxNullBrush ; |
690 | ||
facd6764 | 691 | m_macIsUserPane = TRUE; |
8b573fb8 | 692 | |
facd6764 | 693 | // make sure all proc ptrs are available |
8b573fb8 | 694 | |
facd6764 SC |
695 | if ( gControlUserPaneDrawUPP == NULL ) |
696 | { | |
697 | gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ; | |
698 | gControlUserPaneHitTestUPP = NewControlUserPaneHitTestUPP( wxMacControlUserPaneHitTestProc ) ; | |
699 | gControlUserPaneTrackingUPP = NewControlUserPaneTrackingUPP( wxMacControlUserPaneTrackingProc ) ; | |
700 | gControlUserPaneIdleUPP = NewControlUserPaneIdleUPP( wxMacControlUserPaneIdleProc ) ; | |
701 | gControlUserPaneKeyDownUPP = NewControlUserPaneKeyDownUPP( wxMacControlUserPaneKeyDownProc ) ; | |
702 | gControlUserPaneActivateUPP = NewControlUserPaneActivateUPP( wxMacControlUserPaneActivateProc ) ; | |
703 | gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ; | |
704 | gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ; | |
705 | } | |
706 | if ( wxMacLiveScrollbarActionUPP == NULL ) | |
707 | { | |
708 | wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc ); | |
709 | } | |
710 | ||
711 | if ( wxMacSetupControlBackgroundUPP == NULL ) | |
712 | { | |
713 | wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; | |
714 | } | |
715 | ||
c6f9fb05 SC |
716 | // we need a valid font for the encodings |
717 | wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); | |
e9576ca5 SC |
718 | } |
719 | ||
720 | // Destructor | |
e766c8a9 | 721 | wxWindowMac::~wxWindowMac() |
e9576ca5 | 722 | { |
7de59551 RD |
723 | SendDestroyEvent(); |
724 | ||
140f2012 | 725 | m_isBeingDeleted = TRUE; |
6ed71b4f | 726 | |
7ebf5540 SC |
727 | if ( m_peer ) |
728 | { | |
729 | // deleting a window while it is shown invalidates the region occupied by border or | |
730 | // focus | |
731 | int outerBorder = MacGetLeftBorderSize() ; | |
732 | if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) | |
8b573fb8 | 733 | outerBorder += 4 ; |
7ebf5540 SC |
734 | |
735 | if ( IsShown() && ( outerBorder > 0 ) ) | |
736 | { | |
737 | // as the borders are drawn on the parent we have to properly invalidate all these areas | |
738 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ; | |
8b573fb8 | 739 | |
7ebf5540 SC |
740 | Rect rect ; |
741 | ||
742 | m_peer->GetRect( &rect ) ; | |
743 | RectRgn( updateInner , &rect ) ; | |
744 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
745 | RectRgn( updateOuter , &rect ) ; | |
746 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 747 | wxPoint parent(0,0); |
7ebf5540 SC |
748 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
749 | parent -= GetParent()->GetClientAreaOrigin() ; | |
750 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 | 751 | CopyRgn( updateOuter , updateTotal ) ; |
7ebf5540 SC |
752 | |
753 | GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ; | |
754 | DisposeRgn(updateOuter) ; | |
755 | DisposeRgn(updateInner) ; | |
756 | DisposeRgn(updateTotal) ; | |
757 | } | |
758 | } | |
759 | ||
d4380aaf SC |
760 | #ifndef __WXUNIVERSAL__ |
761 | // VS: make sure there's no wxFrame with last focus set to us: | |
762 | for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) | |
763 | { | |
764 | wxFrame *frame = wxDynamicCast(win, wxFrame); | |
765 | if ( frame ) | |
766 | { | |
767 | if ( frame->GetLastFocus() == this ) | |
768 | { | |
769 | frame->SetLastFocus((wxWindow*)NULL); | |
770 | } | |
771 | break; | |
772 | } | |
773 | } | |
774 | #endif // __WXUNIVERSAL__ | |
8b573fb8 VZ |
775 | |
776 | // destroy children before destroying this window itself | |
777 | DestroyChildren(); | |
778 | ||
facd6764 SC |
779 | // wxRemoveMacControlAssociation( this ) ; |
780 | // If we delete an item, we should initialize the parent panel, | |
781 | // because it could now be invalid. | |
782 | wxWindow *parent = GetParent() ; | |
783 | if ( parent ) | |
784 | { | |
785 | if (parent->GetDefaultItem() == (wxButton*) this) | |
786 | parent->SetDefaultItem(NULL); | |
787 | } | |
21fd5529 | 788 | if ( m_peer && m_peer->Ok() ) |
facd6764 SC |
789 | { |
790 | // in case the callback might be called during destruction | |
791 | wxRemoveMacControlAssociation( this) ; | |
5ca0d812 SC |
792 | // we currently are not using this hook |
793 | // ::SetControlColorProc( *m_peer , NULL ) ; | |
794 | m_peer->Dispose() ; | |
facd6764 | 795 | } |
d4380aaf | 796 | |
facd6764 | 797 | if ( g_MacLastWindow == this ) |
6264b550 | 798 | { |
facd6764 | 799 | g_MacLastWindow = NULL ; |
6264b550 | 800 | } |
7de59551 | 801 | |
fd76aa8d SC |
802 | wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; |
803 | if ( frame ) | |
804 | { | |
e40298d5 JS |
805 | if ( frame->GetLastFocus() == this ) |
806 | frame->SetLastFocus( NULL ) ; | |
fd76aa8d | 807 | } |
e7549107 | 808 | |
42683dfb SC |
809 | // delete our drop target if we've got one |
810 | #if wxUSE_DRAG_AND_DROP | |
811 | if ( m_dropTarget != NULL ) | |
812 | { | |
813 | delete m_dropTarget; | |
814 | m_dropTarget = NULL; | |
815 | } | |
816 | #endif // wxUSE_DRAG_AND_DROP | |
21fd5529 SC |
817 | delete m_peer ; |
818 | } | |
819 | ||
8b573fb8 VZ |
820 | WXWidget wxWindowMac::GetHandle() const |
821 | { | |
822 | return (WXWidget) m_peer->GetControlRef() ; | |
e9576ca5 SC |
823 | } |
824 | ||
facd6764 | 825 | |
5ca0d812 | 826 | void wxWindowMac::MacInstallEventHandler( WXWidget control ) |
facd6764 | 827 | { |
5ca0d812 SC |
828 | wxAssociateControlWithMacControl( (ControlRef) control , this ) ; |
829 | InstallControlEventHandler( (ControlRef) control , GetwxMacWindowEventHandlerUPP(), | |
8b573fb8 | 830 | GetEventTypeCount(eventList), eventList, this, |
facd6764 SC |
831 | (EventHandlerRef *)&m_macControlEventHandler); |
832 | ||
833 | } | |
834 | ||
e9576ca5 | 835 | // Constructor |
e766c8a9 | 836 | bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, |
e9576ca5 SC |
837 | const wxPoint& pos, |
838 | const wxSize& size, | |
839 | long style, | |
840 | const wxString& name) | |
841 | { | |
e766c8a9 | 842 | wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") ); |
e9576ca5 | 843 | |
e7549107 | 844 | if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) |
e9576ca5 SC |
845 | return FALSE; |
846 | ||
facd6764 | 847 | m_windowVariant = parent->GetWindowVariant() ; |
8b573fb8 | 848 | |
facd6764 SC |
849 | if ( m_macIsUserPane ) |
850 | { | |
851 | Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; | |
8b573fb8 | 852 | |
ebe86b1e | 853 | UInt32 features = 0 |
8b573fb8 VZ |
854 | | kControlSupportsEmbedding |
855 | // | kControlSupportsLiveFeedback | |
856 | // | kControlHasSpecialBackground | |
857 | // | kControlSupportsCalcBestRect | |
858 | // | kControlHandlesTracking | |
859 | | kControlSupportsFocus | |
860 | // | kControlWantsActivate | |
861 | // | kControlWantsIdle | |
862 | ; | |
ebe86b1e | 863 | |
21fd5529 | 864 | m_peer = new wxMacControl() ; |
5ca0d812 | 865 | ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() ); |
8b573fb8 | 866 | |
facd6764 SC |
867 | |
868 | MacPostControlCreate(pos,size) ; | |
bcbd6987 | 869 | #if !TARGET_API_MAC_OSX |
5ca0d812 SC |
870 | m_peer->SetData<ControlUserPaneDrawUPP>(kControlEntireControl,kControlUserPaneDrawProcTag,&gControlUserPaneDrawUPP) ; |
871 | m_peer->SetData<ControlUserPaneHitTestUPP>(kControlEntireControl,kControlUserPaneHitTestProcTag,&gControlUserPaneHitTestUPP) ; | |
872 | m_peer->SetData<ControlUserPaneTrackingUPP>(kControlEntireControl,kControlUserPaneTrackingProcTag,&gControlUserPaneTrackingUPP) ; | |
873 | m_peer->SetData<ControlUserPaneIdleUPP>(kControlEntireControl,kControlUserPaneIdleProcTag,&gControlUserPaneIdleUPP) ; | |
874 | m_peer->SetData<ControlUserPaneKeyDownUPP>(kControlEntireControl,kControlUserPaneKeyDownProcTag,&gControlUserPaneKeyDownUPP) ; | |
875 | m_peer->SetData<ControlUserPaneActivateUPP>(kControlEntireControl,kControlUserPaneActivateProcTag,&gControlUserPaneActivateUPP) ; | |
876 | m_peer->SetData<ControlUserPaneFocusUPP>(kControlEntireControl,kControlUserPaneFocusProcTag,&gControlUserPaneFocusUPP) ; | |
877 | m_peer->SetData<ControlUserPaneBackgroundUPP>(kControlEntireControl,kControlUserPaneBackgroundProcTag,&gControlUserPaneBackgroundUPP) ; | |
8b573fb8 | 878 | #endif |
facd6764 | 879 | } |
e766c8a9 | 880 | #ifndef __WXUNIVERSAL__ |
14c9cbdb RD |
881 | // Don't give scrollbars to wxControls unless they ask for them |
882 | if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) || | |
883 | (IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL))) | |
6264b550 RR |
884 | { |
885 | MacCreateScrollBars( style ) ; | |
886 | } | |
e766c8a9 | 887 | #endif |
3dfafdb9 RD |
888 | |
889 | wxWindowCreateEvent event(this); | |
7e4a196e | 890 | GetEventHandler()->AddPendingEvent(event); |
3dfafdb9 | 891 | |
e9576ca5 SC |
892 | return TRUE; |
893 | } | |
894 | ||
facd6764 SC |
895 | void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size) |
896 | { | |
21fd5529 | 897 | wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ; |
facd6764 | 898 | |
5ca0d812 | 899 | m_peer->SetReference( (long) this ) ; |
488abb22 | 900 | GetParent()->AddChild(this); |
facd6764 | 901 | |
5ca0d812 | 902 | MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ); |
facd6764 SC |
903 | |
904 | ControlRef container = (ControlRef) GetParent()->GetHandle() ; | |
905 | wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; | |
5ca0d812 | 906 | ::EmbedControl( m_peer->GetControlRef() , container ) ; |
facd6764 SC |
907 | |
908 | // adjust font, controlsize etc | |
909 | DoSetWindowVariant( m_windowVariant ) ; | |
910 | ||
911 | #if !TARGET_API_MAC_OSX | |
8b573fb8 | 912 | // eventually we can fix some clipping issues be reactivating this hook |
facd6764 | 913 | //if ( m_macIsUserPane ) |
be346c26 | 914 | // SetControlColorProc( m_peer->GetControlRef() , wxMacSetupControlBackgroundUPP ) ; |
facd6764 | 915 | #endif |
5ca0d812 | 916 | m_peer->SetTitle( wxStripMenuCodes(m_label) ) ; |
facd6764 | 917 | |
facd6764 | 918 | if (!m_macIsUserPane) |
d3b5db4b RD |
919 | { |
920 | SetInitialBestSize(size); | |
facd6764 SC |
921 | } |
922 | ||
923 | SetCursor( *wxSTANDARD_CURSOR ) ; | |
facd6764 SC |
924 | } |
925 | ||
926 | void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) | |
927 | { | |
23176131 JS |
928 | // Don't assert, in case we set the window variant before |
929 | // the window is created | |
21fd5529 | 930 | // wxASSERT( m_peer->Ok() ) ; |
facd6764 | 931 | |
23176131 JS |
932 | m_windowVariant = variant ; |
933 | ||
21fd5529 | 934 | if (m_peer == NULL || !m_peer->Ok()) |
23176131 | 935 | return; |
facd6764 | 936 | |
8b573fb8 | 937 | ControlSize size ; |
facd6764 SC |
938 | ThemeFontID themeFont = kThemeSystemFont ; |
939 | ||
940 | // we will get that from the settings later | |
8b573fb8 | 941 | // and make this NORMAL later, but first |
facd6764 | 942 | // we have a few calculations that we must fix |
8b573fb8 | 943 | |
facd6764 SC |
944 | switch ( variant ) |
945 | { | |
946 | case wxWINDOW_VARIANT_NORMAL : | |
8b573fb8 VZ |
947 | size = kControlSizeNormal; |
948 | themeFont = kThemeSystemFont ; | |
facd6764 SC |
949 | break ; |
950 | case wxWINDOW_VARIANT_SMALL : | |
8b573fb8 VZ |
951 | size = kControlSizeSmall; |
952 | themeFont = kThemeSmallSystemFont ; | |
facd6764 SC |
953 | break ; |
954 | case wxWINDOW_VARIANT_MINI : | |
955 | if (UMAGetSystemVersion() >= 0x1030 ) | |
956 | { | |
8b573fb8 VZ |
957 | // not always defined in the headers |
958 | size = 3 ; | |
959 | themeFont = 109 ; | |
facd6764 SC |
960 | } |
961 | else | |
962 | { | |
8b573fb8 VZ |
963 | size = kControlSizeSmall; |
964 | themeFont = kThemeSmallSystemFont ; | |
facd6764 SC |
965 | } |
966 | break ; | |
967 | case wxWINDOW_VARIANT_LARGE : | |
8b573fb8 VZ |
968 | size = kControlSizeLarge; |
969 | themeFont = kThemeSystemFont ; | |
facd6764 SC |
970 | break ; |
971 | default: | |
972 | wxFAIL_MSG(_T("unexpected window variant")); | |
973 | break ; | |
974 | } | |
5ca0d812 | 975 | m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag,&size ) ; |
facd6764 SC |
976 | |
977 | wxFont font ; | |
978 | font.MacCreateThemeFont( themeFont ) ; | |
979 | SetFont( font ) ; | |
980 | } | |
981 | ||
8b573fb8 | 982 | void wxWindowMac::MacUpdateControlFont() |
facd6764 | 983 | { |
ac99838a | 984 | m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ; |
8b573fb8 | 985 | Refresh() ; |
facd6764 SC |
986 | } |
987 | ||
988 | bool wxWindowMac::SetFont(const wxFont& font) | |
989 | { | |
d5ccba72 | 990 | bool retval = wxWindowBase::SetFont( font ) ; |
8b573fb8 | 991 | |
facd6764 | 992 | MacUpdateControlFont() ; |
8b573fb8 | 993 | |
facd6764 SC |
994 | return retval; |
995 | } | |
996 | ||
997 | bool wxWindowMac::SetForegroundColour(const wxColour& col ) | |
998 | { | |
999 | if ( !wxWindowBase::SetForegroundColour(col) ) | |
1000 | return false ; | |
8b573fb8 | 1001 | |
facd6764 | 1002 | MacUpdateControlFont() ; |
8b573fb8 | 1003 | |
facd6764 SC |
1004 | return true ; |
1005 | } | |
1006 | ||
1007 | bool wxWindowMac::SetBackgroundColour(const wxColour& col ) | |
1008 | { | |
1009 | if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol ) | |
1010 | return false ; | |
1011 | ||
1012 | wxBrush brush ; | |
b52acd03 RD |
1013 | wxColour newCol(GetBackgroundColour()); |
1014 | if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) | |
facd6764 SC |
1015 | { |
1016 | brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ; | |
1017 | } | |
b52acd03 | 1018 | else if ( newCol == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) ) |
facd6764 | 1019 | { |
8b573fb8 VZ |
1020 | brush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ; |
1021 | } | |
facd6764 SC |
1022 | else |
1023 | { | |
b52acd03 | 1024 | brush.SetColour( newCol ) ; |
facd6764 SC |
1025 | } |
1026 | MacSetBackgroundBrush( brush ) ; | |
8b573fb8 | 1027 | |
db7a550b | 1028 | MacUpdateControlFont() ; |
8b573fb8 | 1029 | |
facd6764 SC |
1030 | return true ; |
1031 | } | |
1032 | ||
7ea087b7 SC |
1033 | void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush ) |
1034 | { | |
1035 | m_macBackgroundBrush = brush ; | |
1036 | m_peer->SetBackground( brush ) ; | |
1037 | } | |
facd6764 SC |
1038 | |
1039 | bool wxWindowMac::MacCanFocus() const | |
1040 | { | |
f6e3849c SC |
1041 | // there is currently no way to determine whether the window is running in full keyboard |
1042 | // access mode, therefore we cannot rely on these features, yet the only other way would be | |
1043 | // to issue a SetKeyboardFocus event and verify after whether it succeeded, this would risk problems | |
1044 | // in event handlers... | |
f1d527c1 | 1045 | UInt32 features = 0 ; |
5ca0d812 | 1046 | m_peer->GetFeatures( & features ) ; |
8b573fb8 | 1047 | return features & ( kControlSupportsFocus | kControlGetsFocusOnClick ) ; |
facd6764 SC |
1048 | } |
1049 | ||
1050 | ||
e766c8a9 | 1051 | void wxWindowMac::SetFocus() |
e9576ca5 | 1052 | { |
6264b550 RR |
1053 | if ( AcceptsFocus() ) |
1054 | { | |
7d0cfe71 | 1055 | |
f1d527c1 | 1056 | wxWindow* former = FindFocus() ; |
7d0cfe71 SC |
1057 | if ( former == this ) |
1058 | return ; | |
1059 | ||
5ca0d812 | 1060 | OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ; |
f1d527c1 SC |
1061 | // as we cannot rely on the control features to find out whether we are in full keyboard mode, we can only |
1062 | // leave in case of an error | |
1063 | if ( err == errCouldntSetFocus ) | |
1064 | return ; | |
1065 | ||
1066 | #if !TARGET_API_MAC_OSX | |
1067 | // emulate carbon events when running under carbonlib where they are not natively available | |
1068 | if ( former ) | |
1069 | { | |
1070 | EventRef evRef = NULL ; | |
1071 | verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent , | |
1072 | &evRef ) ); | |
1073 | ||
1074 | wxMacCarbonEvent cEvent( evRef ) ; | |
1075 | cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) former->GetHandle() ) ; | |
1076 | cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNoPart ) ; | |
8b573fb8 | 1077 | |
f1d527c1 SC |
1078 | wxMacWindowEventHandler( NULL , evRef , former ) ; |
1079 | ReleaseEvent(evRef) ; | |
6264b550 | 1080 | } |
f1d527c1 | 1081 | // send new focus event |
6264b550 | 1082 | { |
f1d527c1 SC |
1083 | EventRef evRef = NULL ; |
1084 | verify_noerr( MacCreateEvent( NULL , kEventClassControl , kEventControlSetFocusPart , TicksToEventTime( TickCount() ) , kEventAttributeUserEvent , | |
1085 | &evRef ) ); | |
1086 | ||
1087 | wxMacCarbonEvent cEvent( evRef ) ; | |
1088 | cEvent.SetParameter<ControlRef>( kEventParamDirectObject , (ControlRef) GetHandle() ) ; | |
1089 | cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode , kControlFocusNextPart ) ; | |
8b573fb8 | 1090 | |
f1d527c1 SC |
1091 | wxMacWindowEventHandler( NULL , evRef , this ) ; |
1092 | ReleaseEvent(evRef) ; | |
6264b550 | 1093 | } |
f1d527c1 | 1094 | #endif |
6264b550 | 1095 | } |
e9576ca5 SC |
1096 | } |
1097 | ||
e9576ca5 | 1098 | |
4116c221 | 1099 | void wxWindowMac::DoCaptureMouse() |
e9576ca5 | 1100 | { |
519cb848 | 1101 | wxTheApp->s_captureWindow = this ; |
e9576ca5 SC |
1102 | } |
1103 | ||
90b959ae SC |
1104 | wxWindow* wxWindowBase::GetCapture() |
1105 | { | |
1106 | return wxTheApp->s_captureWindow ; | |
1107 | } | |
1108 | ||
4116c221 | 1109 | void wxWindowMac::DoReleaseMouse() |
e9576ca5 | 1110 | { |
519cb848 | 1111 | wxTheApp->s_captureWindow = NULL ; |
e9576ca5 SC |
1112 | } |
1113 | ||
e9576ca5 SC |
1114 | #if wxUSE_DRAG_AND_DROP |
1115 | ||
e766c8a9 | 1116 | void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) |
e9576ca5 | 1117 | { |
e40298d5 JS |
1118 | if ( m_dropTarget != 0 ) { |
1119 | delete m_dropTarget; | |
1120 | } | |
6ed71b4f | 1121 | |
e40298d5 JS |
1122 | m_dropTarget = pDropTarget; |
1123 | if ( m_dropTarget != 0 ) | |
1124 | { | |
1125 | // TODO | |
1126 | } | |
e9576ca5 SC |
1127 | } |
1128 | ||
1129 | #endif | |
1130 | ||
1131 | // Old style file-manager drag&drop | |
e766c8a9 | 1132 | void wxWindowMac::DragAcceptFiles(bool accept) |
e9576ca5 SC |
1133 | { |
1134 | // TODO | |
1135 | } | |
1136 | ||
055a486b SC |
1137 | // Returns the size of the native control. In the case of the toplevel window |
1138 | // this is the content area root control | |
1139 | ||
facd6764 | 1140 | void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y, |
8b573fb8 | 1141 | int& w, int& h) const |
e9576ca5 | 1142 | { |
facd6764 | 1143 | Rect bounds ; |
8b573fb8 | 1144 | m_peer->GetRect( &bounds ) ; |
e9576ca5 | 1145 | |
14c9cbdb | 1146 | |
facd6764 SC |
1147 | x = bounds.left ; |
1148 | y = bounds.top ; | |
1149 | w = bounds.right - bounds.left ; | |
1150 | h = bounds.bottom - bounds.top ; | |
e9576ca5 SC |
1151 | } |
1152 | ||
055a486b | 1153 | // From a wx position / size calculate the appropriate size of the native control |
8b573fb8 | 1154 | |
facd6764 SC |
1155 | bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, |
1156 | const wxSize& size, | |
1157 | int& x, int& y, | |
8b573fb8 | 1158 | int& w, int& h , bool adjustOrigin ) const |
51abe921 | 1159 | { |
5ca0d812 | 1160 | // the desired size, minus the border pixels gives the correct size of the control |
8b573fb8 | 1161 | |
facd6764 SC |
1162 | x = (int)pos.x; |
1163 | y = (int)pos.y; | |
1164 | // todo the default calls may be used as soon as PostCreateControl Is moved here | |
1165 | w = size.x ; // WidthDefault( size.x ); | |
1166 | h = size.y ; // HeightDefault( size.y ) ; | |
1167 | #if !TARGET_API_MAC_OSX | |
1168 | GetParent()->MacWindowToRootWindow( &x , &y ) ; | |
1169 | #endif | |
5ca0d812 SC |
1170 | |
1171 | x += MacGetLeftBorderSize() ; | |
1172 | y += MacGetTopBorderSize() ; | |
1173 | w -= MacGetLeftBorderSize() + MacGetRightBorderSize() ; | |
1174 | h -= MacGetTopBorderSize() + MacGetBottomBorderSize() ; | |
8b573fb8 | 1175 | |
79392158 SC |
1176 | if ( adjustOrigin ) |
1177 | AdjustForParentClientOrigin( x , y ) ; | |
7ebf5540 SC |
1178 | #if TARGET_API_MAC_OSX |
1179 | // this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border | |
1180 | if ( ! GetParent()->IsTopLevel() ) | |
1181 | { | |
1182 | x -= GetParent()->MacGetLeftBorderSize() ; | |
1183 | y -= GetParent()->MacGetTopBorderSize() ; | |
1184 | } | |
1185 | #endif | |
facd6764 SC |
1186 | return true ; |
1187 | } | |
1188 | ||
42ef83fa | 1189 | // Get window size (not client size) |
facd6764 SC |
1190 | void wxWindowMac::DoGetSize(int *x, int *y) const |
1191 | { | |
5ca0d812 | 1192 | // take the size of the control and add the borders that have to be drawn outside |
42ef83fa SC |
1193 | int x1 , y1 , w1 , h1 ; |
1194 | ||
facd6764 | 1195 | MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ; |
42ef83fa | 1196 | |
5ca0d812 SC |
1197 | w1 += MacGetLeftBorderSize() + MacGetRightBorderSize() ; |
1198 | h1 += MacGetTopBorderSize() + MacGetBottomBorderSize() ; | |
8b573fb8 | 1199 | |
5ca0d812 SC |
1200 | if(x) *x = w1 ; |
1201 | if(y) *y = h1 ; | |
facd6764 SC |
1202 | } |
1203 | ||
42ef83fa | 1204 | // get the position of the bounds of this window in client coordinates of its parent |
facd6764 SC |
1205 | void wxWindowMac::DoGetPosition(int *x, int *y) const |
1206 | { | |
facd6764 SC |
1207 | int x1 , y1 , w1 ,h1 ; |
1208 | MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ; | |
5ca0d812 SC |
1209 | x1 -= MacGetLeftBorderSize() ; |
1210 | y1 -= MacGetTopBorderSize() ; | |
42ef83fa SC |
1211 | // to non-client |
1212 | #if !TARGET_API_MAC_OSX | |
1213 | if ( !GetParent()->IsTopLevel() ) | |
1214 | { | |
1215 | Rect bounds ; | |
1216 | GetControlBounds( (ControlRef) GetParent()->GetHandle() , &bounds ) ; | |
1217 | x1 -= bounds.left ; | |
1218 | y1 -= bounds.top ; | |
1219 | } | |
1220 | #endif | |
facd6764 | 1221 | if ( !IsTopLevel() ) |
2b5f62a0 | 1222 | { |
facd6764 SC |
1223 | wxWindow *parent = GetParent(); |
1224 | if ( parent ) | |
8950f7cc | 1225 | { |
1a02aff9 SC |
1226 | // we must first adjust it to be in window coordinates of the parent, as otherwise it gets lost by the clientareaorigin fix |
1227 | x1 += parent->MacGetLeftBorderSize() ; | |
1228 | y1 += parent->MacGetTopBorderSize() ; | |
1229 | // and now to client coordinates | |
facd6764 SC |
1230 | wxPoint pt(parent->GetClientAreaOrigin()); |
1231 | x1 -= pt.x ; | |
1232 | y1 -= pt.y ; | |
6ed71b4f | 1233 | } |
2b5f62a0 | 1234 | } |
facd6764 SC |
1235 | if(x) *x = x1 ; |
1236 | if(y) *y = y1 ; | |
facd6764 | 1237 | } |
51abe921 | 1238 | |
e766c8a9 | 1239 | void wxWindowMac::DoScreenToClient(int *x, int *y) const |
e9576ca5 | 1240 | { |
facd6764 | 1241 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
8b573fb8 | 1242 | |
facd6764 | 1243 | wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ; |
8b573fb8 | 1244 | |
facd6764 SC |
1245 | { |
1246 | Point localwhere = {0,0} ; | |
519cb848 | 1247 | |
facd6764 SC |
1248 | if(x) localwhere.h = * x ; |
1249 | if(y) localwhere.v = * y ; | |
8b573fb8 | 1250 | |
a9de2608 | 1251 | QDGlobalToLocalPoint( GetWindowPort( window ) , &localwhere ) ; |
facd6764 SC |
1252 | if(x) *x = localwhere.h ; |
1253 | if(y) *y = localwhere.v ; | |
6ed71b4f | 1254 | |
facd6764 | 1255 | } |
2078220e | 1256 | MacRootWindowToWindow( x , y ) ; |
8b573fb8 | 1257 | |
facd6764 SC |
1258 | wxPoint origin = GetClientAreaOrigin() ; |
1259 | if(x) *x -= origin.x ; | |
1260 | if(y) *y -= origin.y ; | |
e9576ca5 SC |
1261 | } |
1262 | ||
e766c8a9 | 1263 | void wxWindowMac::DoClientToScreen(int *x, int *y) const |
e9576ca5 | 1264 | { |
facd6764 SC |
1265 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1266 | wxCHECK_RET( window , wxT("TopLevel Window Missing") ) ; | |
14c9cbdb | 1267 | |
facd6764 SC |
1268 | wxPoint origin = GetClientAreaOrigin() ; |
1269 | if(x) *x += origin.x ; | |
1270 | if(y) *y += origin.y ; | |
14c9cbdb | 1271 | |
2078220e | 1272 | MacWindowToRootWindow( x , y ) ; |
14c9cbdb | 1273 | |
facd6764 SC |
1274 | { |
1275 | Point localwhere = { 0,0 }; | |
1276 | if(x) localwhere.h = * x ; | |
1277 | if(y) localwhere.v = * y ; | |
a9de2608 | 1278 | QDLocalToGlobalPoint( GetWindowPort( window ) , &localwhere ) ; |
facd6764 SC |
1279 | if(x) *x = localwhere.h ; |
1280 | if(y) *y = localwhere.v ; | |
1281 | } | |
519cb848 SC |
1282 | } |
1283 | ||
e766c8a9 | 1284 | void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const |
519cb848 | 1285 | { |
1c310985 SC |
1286 | wxPoint origin = GetClientAreaOrigin() ; |
1287 | if(x) *x += origin.x ; | |
1288 | if(y) *y += origin.y ; | |
14c9cbdb | 1289 | |
1c310985 SC |
1290 | MacWindowToRootWindow( x , y ) ; |
1291 | } | |
1292 | ||
1293 | void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const | |
1294 | { | |
1c310985 | 1295 | MacRootWindowToWindow( x , y ) ; |
facd6764 SC |
1296 | |
1297 | wxPoint origin = GetClientAreaOrigin() ; | |
1c310985 SC |
1298 | if(x) *x -= origin.x ; |
1299 | if(y) *y -= origin.y ; | |
1300 | } | |
1301 | ||
1302 | void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const | |
1303 | { | |
facd6764 | 1304 | #if TARGET_API_MAC_OSX |
5ca0d812 | 1305 | wxPoint pt ; |
facd6764 SC |
1306 | if ( x ) pt.x = *x ; |
1307 | if ( y ) pt.y = *y ; | |
1308 | ||
125c7984 | 1309 | if ( !IsTopLevel() ) |
5437ff47 RD |
1310 | { |
1311 | wxTopLevelWindowMac* top = MacGetTopLevelWindow(); | |
1312 | if (top) | |
5ca0d812 SC |
1313 | { |
1314 | pt.x -= MacGetLeftBorderSize() ; | |
1315 | pt.y -= MacGetTopBorderSize() ; | |
1316 | wxMacControl::Convert( &pt , m_peer , top->m_peer ) ; | |
1317 | } | |
5437ff47 | 1318 | } |
8b573fb8 | 1319 | |
facd6764 SC |
1320 | if ( x ) *x = (int) pt.x ; |
1321 | if ( y ) *y = (int) pt.y ; | |
1322 | #else | |
1c310985 | 1323 | if ( !IsTopLevel() ) |
6264b550 | 1324 | { |
facd6764 | 1325 | Rect bounds ; |
8b573fb8 | 1326 | m_peer->GetRect( &bounds ) ; |
055a486b SC |
1327 | if(x) *x += bounds.left - MacGetLeftBorderSize() ; |
1328 | if(y) *y += bounds.top - MacGetTopBorderSize() ; | |
6264b550 | 1329 | } |
facd6764 SC |
1330 | #endif |
1331 | } | |
1332 | ||
1333 | void wxWindowMac::MacWindowToRootWindow( short *x , short *y ) const | |
1334 | { | |
1335 | int x1 , y1 ; | |
1336 | if ( x ) x1 = *x ; | |
1337 | if ( y ) y1 = *y ; | |
1338 | MacWindowToRootWindow( &x1 , &y1 ) ; | |
1339 | if ( x ) *x = x1 ; | |
1340 | if ( y ) *y = y1 ; | |
519cb848 SC |
1341 | } |
1342 | ||
1c310985 | 1343 | void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const |
519cb848 | 1344 | { |
facd6764 | 1345 | #if TARGET_API_MAC_OSX |
5ca0d812 | 1346 | wxPoint pt ; |
facd6764 SC |
1347 | if ( x ) pt.x = *x ; |
1348 | if ( y ) pt.y = *y ; | |
1349 | ||
125c7984 | 1350 | if ( !IsTopLevel() ) |
5ca0d812 SC |
1351 | { |
1352 | wxMacControl::Convert( &pt , MacGetTopLevelWindow()->m_peer , m_peer ) ; | |
1353 | pt.x += MacGetLeftBorderSize() ; | |
1354 | pt.y += MacGetTopBorderSize() ; | |
1355 | } | |
8b573fb8 | 1356 | |
facd6764 SC |
1357 | if ( x ) *x = (int) pt.x ; |
1358 | if ( y ) *y = (int) pt.y ; | |
1359 | #else | |
1c310985 | 1360 | if ( !IsTopLevel() ) |
6264b550 | 1361 | { |
facd6764 | 1362 | Rect bounds ; |
8b573fb8 | 1363 | m_peer->GetRect( &bounds ) ; |
055a486b SC |
1364 | if(x) *x -= bounds.left + MacGetLeftBorderSize() ; |
1365 | if(y) *y -= bounds.top + MacGetTopBorderSize() ; | |
6264b550 | 1366 | } |
facd6764 | 1367 | #endif |
e9576ca5 SC |
1368 | } |
1369 | ||
facd6764 | 1370 | void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const |
e9576ca5 | 1371 | { |
facd6764 SC |
1372 | int x1 , y1 ; |
1373 | if ( x ) x1 = *x ; | |
1374 | if ( y ) y1 = *y ; | |
1375 | MacRootWindowToWindow( &x1 , &y1 ) ; | |
1376 | if ( x ) *x = x1 ; | |
1377 | if ( y ) *y = y1 ; | |
1378 | } | |
6ed71b4f | 1379 | |
29281095 SC |
1380 | void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) |
1381 | { | |
1382 | RgnHandle rgn = NewRgn() ; | |
1383 | Rect content ; | |
5ca0d812 | 1384 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
29281095 SC |
1385 | { |
1386 | GetRegionBounds( rgn , &content ) ; | |
29281095 SC |
1387 | } |
1388 | else | |
1389 | { | |
5ca0d812 | 1390 | m_peer->GetRect( &content ) ; |
29281095 | 1391 | } |
7596e51d | 1392 | DisposeRgn( rgn ) ; |
29281095 | 1393 | Rect structure ; |
5ca0d812 | 1394 | m_peer->GetRect( &structure ) ; |
8b573fb8 | 1395 | #if !TARGET_API_MAC_OSX |
29281095 SC |
1396 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1397 | #endif | |
1398 | left = content.left - structure.left ; | |
1399 | top = content.top - structure.top ; | |
1400 | right = structure.right - content.right ; | |
1401 | bottom = structure.bottom - content.bottom ; | |
1402 | } | |
1403 | ||
facd6764 SC |
1404 | wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const |
1405 | { | |
1406 | wxSize sizeTotal = size; | |
1407 | ||
1408 | RgnHandle rgn = NewRgn() ; | |
1409 | ||
1410 | Rect content ; | |
8b573fb8 | 1411 | |
5ca0d812 | 1412 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
6618870d | 1413 | { |
facd6764 | 1414 | GetRegionBounds( rgn , &content ) ; |
6618870d SC |
1415 | } |
1416 | else | |
1417 | { | |
5ca0d812 | 1418 | m_peer->GetRect( &content ) ; |
e40298d5 | 1419 | } |
7596e51d | 1420 | DisposeRgn( rgn ) ; |
facd6764 | 1421 | Rect structure ; |
5ca0d812 | 1422 | m_peer->GetRect( &structure ) ; |
8b573fb8 | 1423 | #if !TARGET_API_MAC_OSX |
facd6764 SC |
1424 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1425 | #endif | |
6ed71b4f | 1426 | |
facd6764 | 1427 | sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ; |
8b573fb8 | 1428 | sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ; |
6ed71b4f | 1429 | |
facd6764 SC |
1430 | sizeTotal.x += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
1431 | sizeTotal.y += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ; | |
6ed71b4f | 1432 | |
facd6764 | 1433 | return sizeTotal; |
e9576ca5 SC |
1434 | } |
1435 | ||
1436 | ||
1437 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
e766c8a9 | 1438 | void wxWindowMac::DoGetClientSize(int *x, int *y) const |
e9576ca5 | 1439 | { |
9453cf2b | 1440 | int ww, hh; |
6ed71b4f | 1441 | |
facd6764 SC |
1442 | RgnHandle rgn = NewRgn() ; |
1443 | Rect content ; | |
5ca0d812 | 1444 | if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr ) |
facd6764 SC |
1445 | { |
1446 | GetRegionBounds( rgn , &content ) ; | |
facd6764 SC |
1447 | } |
1448 | else | |
1449 | { | |
5ca0d812 | 1450 | m_peer->GetRect( &content ) ; |
facd6764 | 1451 | } |
7596e51d | 1452 | DisposeRgn( rgn ) ; |
facd6764 SC |
1453 | #if !TARGET_API_MAC_OSX |
1454 | Rect structure ; | |
5ca0d812 | 1455 | m_peer->GetRect( &structure ) ; |
facd6764 | 1456 | OffsetRect( &content , -structure.left , -structure.top ) ; |
8b573fb8 | 1457 | #endif |
facd6764 SC |
1458 | ww = content.right - content.left ; |
1459 | hh = content.bottom - content.top ; | |
055a486b | 1460 | /* |
6264b550 RR |
1461 | ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; |
1462 | hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ); | |
055a486b | 1463 | */ |
db7a550b | 1464 | /* |
e40298d5 JS |
1465 | if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) |
1466 | { | |
1467 | int x1 = 0 ; | |
1468 | int y1 = 0 ; | |
facd6764 SC |
1469 | int w ; |
1470 | int h ; | |
1471 | GetSize( &w , &h ) ; | |
8b573fb8 | 1472 | |
e40298d5 JS |
1473 | MacClientToRootWindow( &x1 , &y1 ) ; |
1474 | MacClientToRootWindow( &w , &h ) ; | |
6ed71b4f | 1475 | |
e40298d5 | 1476 | wxWindowMac *iter = (wxWindowMac*)this ; |
6ed71b4f | 1477 | |
e40298d5 JS |
1478 | int totW = 10000 , totH = 10000; |
1479 | while( iter ) | |
6264b550 | 1480 | { |
e40298d5 JS |
1481 | if ( iter->IsTopLevel() ) |
1482 | { | |
facd6764 | 1483 | iter->GetSize( &totW , &totH ) ; |
e40298d5 JS |
1484 | break ; |
1485 | } | |
6ed71b4f | 1486 | |
e40298d5 | 1487 | iter = iter->GetParent() ; |
6264b550 | 1488 | } |
6ed71b4f | 1489 | |
e40298d5 | 1490 | if (m_hScrollBar && m_hScrollBar->IsShown() ) |
6264b550 | 1491 | { |
db7a550b | 1492 | hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ; |
e40298d5 JS |
1493 | if ( h-y1 >= totH ) |
1494 | { | |
1495 | hh += 1 ; | |
1496 | } | |
6264b550 | 1497 | } |
e40298d5 | 1498 | if (m_vScrollBar && m_vScrollBar->IsShown() ) |
6264b550 | 1499 | { |
db7a550b | 1500 | ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE; |
e40298d5 JS |
1501 | if ( w-x1 >= totW ) |
1502 | { | |
1503 | ww += 1 ; | |
1504 | } | |
6264b550 RR |
1505 | } |
1506 | } | |
db7a550b SC |
1507 | */ |
1508 | if (m_hScrollBar && m_hScrollBar->IsShown() ) | |
1509 | { | |
1510 | hh -= m_hScrollBar->GetSize().y ; // MAC_SCROLLBAR_SIZE ; | |
1511 | } | |
1512 | if (m_vScrollBar && m_vScrollBar->IsShown() ) | |
1513 | { | |
1514 | ww -= m_vScrollBar->GetSize().x ; // MAC_SCROLLBAR_SIZE; | |
1515 | } | |
e40298d5 JS |
1516 | if(x) *x = ww; |
1517 | if(y) *y = hh; | |
facd6764 SC |
1518 | |
1519 | } | |
1520 | ||
1521 | bool wxWindowMac::SetCursor(const wxCursor& cursor) | |
1522 | { | |
1523 | if (m_cursor == cursor) | |
1524 | return FALSE; | |
1525 | ||
1526 | if (wxNullCursor == cursor) | |
1527 | { | |
1528 | if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) | |
1529 | return FALSE ; | |
1530 | } | |
1531 | else | |
1532 | { | |
1533 | if ( ! wxWindowBase::SetCursor( cursor ) ) | |
1534 | return FALSE ; | |
1535 | } | |
1536 | ||
1537 | wxASSERT_MSG( m_cursor.Ok(), | |
1538 | wxT("cursor must be valid after call to the base version")); | |
8b573fb8 VZ |
1539 | |
1540 | ||
2d1760d3 | 1541 | wxWindowMac *mouseWin = 0 ; |
facd6764 | 1542 | { |
2d1760d3 SC |
1543 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1544 | CGrafPtr savePort ; | |
1545 | Boolean swapped = QDSwapPort( GetWindowPort( window ) , &savePort ) ; | |
8b573fb8 | 1546 | |
2d1760d3 SC |
1547 | // TODO If we ever get a GetCurrentEvent.. replacement for the mouse |
1548 | // position, use it... | |
8b573fb8 | 1549 | |
2d1760d3 SC |
1550 | Point pt ; |
1551 | GetMouse( &pt ) ; | |
1552 | ControlPartCode part ; | |
1553 | ControlRef control ; | |
1554 | control = wxMacFindControlUnderMouse( pt , window , &part ) ; | |
1555 | if ( control ) | |
1556 | mouseWin = wxFindControlFromMacControl( control ) ; | |
8b573fb8 | 1557 | |
2d1760d3 SC |
1558 | if ( swapped ) |
1559 | QDSwapPort( savePort , NULL ) ; | |
facd6764 | 1560 | } |
2d1760d3 SC |
1561 | |
1562 | if ( mouseWin == this && !wxIsBusy() ) | |
facd6764 SC |
1563 | { |
1564 | m_cursor.MacInstall() ; | |
1565 | } | |
1566 | ||
1567 | return TRUE ; | |
519cb848 SC |
1568 | } |
1569 | ||
facd6764 SC |
1570 | #if wxUSE_MENUS |
1571 | bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) | |
1572 | { | |
1573 | menu->SetInvokingWindow(this); | |
1574 | menu->UpdateUI(); | |
8b573fb8 | 1575 | |
971562cb VS |
1576 | if ( x == -1 && y == -1 ) |
1577 | { | |
1578 | wxPoint mouse = wxGetMousePosition(); | |
1579 | x = mouse.x; y = mouse.y; | |
1580 | } | |
1581 | else | |
1582 | { | |
1583 | ClientToScreen( &x , &y ) ; | |
1584 | } | |
facd6764 SC |
1585 | |
1586 | menu->MacBeforeDisplay( true ) ; | |
1587 | long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ; | |
1588 | if ( HiWord(menuResult) != 0 ) | |
1589 | { | |
1590 | MenuCommand id ; | |
1591 | GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ; | |
1592 | wxMenuItem* item = NULL ; | |
1593 | wxMenu* realmenu ; | |
1594 | item = menu->FindItem(id, &realmenu) ; | |
1595 | if (item->IsCheckable()) | |
1596 | { | |
1597 | item->Check( !item->IsChecked() ) ; | |
1598 | } | |
1599 | menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; | |
1600 | } | |
1601 | menu->MacAfterDisplay( true ) ; | |
1602 | ||
1603 | menu->SetInvokingWindow(NULL); | |
1604 | ||
1605 | return TRUE; | |
1606 | } | |
1607 | #endif | |
51abe921 SC |
1608 | |
1609 | // ---------------------------------------------------------------------------- | |
1610 | // tooltips | |
1611 | // ---------------------------------------------------------------------------- | |
1612 | ||
1613 | #if wxUSE_TOOLTIPS | |
1614 | ||
e766c8a9 | 1615 | void wxWindowMac::DoSetToolTip(wxToolTip *tooltip) |
51abe921 SC |
1616 | { |
1617 | wxWindowBase::DoSetToolTip(tooltip); | |
6ed71b4f | 1618 | |
6264b550 RR |
1619 | if ( m_tooltip ) |
1620 | m_tooltip->SetWindow(this); | |
51abe921 SC |
1621 | } |
1622 | ||
1623 | #endif // wxUSE_TOOLTIPS | |
1624 | ||
e766c8a9 | 1625 | void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) |
51abe921 | 1626 | { |
db7a550b | 1627 | // this is never called for a toplevel window, so we know we have a parent |
facd6764 | 1628 | int former_x , former_y , former_w, former_h ; |
db7a550b SC |
1629 | |
1630 | // Get true coordinates of former position | |
facd6764 SC |
1631 | DoGetPosition( &former_x , &former_y ) ; |
1632 | DoGetSize( &former_w , &former_h ) ; | |
db7a550b SC |
1633 | |
1634 | wxWindow *parent = GetParent(); | |
1635 | if ( parent ) | |
1636 | { | |
1637 | wxPoint pt(parent->GetClientAreaOrigin()); | |
1638 | former_x += pt.x ; | |
1639 | former_y += pt.y ; | |
1640 | } | |
6ed71b4f | 1641 | |
e40298d5 JS |
1642 | int actualWidth = width; |
1643 | int actualHeight = height; | |
1644 | int actualX = x; | |
1645 | int actualY = y; | |
6ed71b4f | 1646 | |
14c9cbdb | 1647 | if ((m_minWidth != -1) && (actualWidth < m_minWidth)) |
6264b550 | 1648 | actualWidth = m_minWidth; |
14c9cbdb | 1649 | if ((m_minHeight != -1) && (actualHeight < m_minHeight)) |
6264b550 | 1650 | actualHeight = m_minHeight; |
14c9cbdb | 1651 | if ((m_maxWidth != -1) && (actualWidth > m_maxWidth)) |
6264b550 | 1652 | actualWidth = m_maxWidth; |
14c9cbdb | 1653 | if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) |
6264b550 | 1654 | actualHeight = m_maxHeight; |
6ed71b4f | 1655 | |
6264b550 RR |
1656 | bool doMove = false ; |
1657 | bool doResize = false ; | |
6ed71b4f | 1658 | |
6264b550 RR |
1659 | if ( actualX != former_x || actualY != former_y ) |
1660 | { | |
1661 | doMove = true ; | |
1662 | } | |
1663 | if ( actualWidth != former_w || actualHeight != former_h ) | |
1664 | { | |
1665 | doResize = true ; | |
1666 | } | |
6ed71b4f | 1667 | |
6264b550 RR |
1668 | if ( doMove || doResize ) |
1669 | { | |
79392158 SC |
1670 | // we don't adjust twice for the origin |
1671 | Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ; | |
5ca0d812 | 1672 | bool vis = m_peer->IsVisible(); |
8b573fb8 | 1673 | |
d390fdcf SC |
1674 | int outerBorder = MacGetLeftBorderSize() ; |
1675 | if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) | |
8b573fb8 | 1676 | outerBorder += 4 ; |
d390fdcf SC |
1677 | |
1678 | if ( vis && ( outerBorder > 0 ) ) | |
1679 | { | |
1680 | // as the borders are drawn on the parent we have to properly invalidate all these areas | |
1681 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ; | |
8b573fb8 | 1682 | |
d390fdcf SC |
1683 | Rect rect ; |
1684 | ||
1685 | m_peer->GetRect( &rect ) ; | |
1686 | RectRgn( updateInner , &rect ) ; | |
1687 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
1688 | RectRgn( updateOuter , &rect ) ; | |
1689 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 1690 | wxPoint parent(0,0); |
d390fdcf SC |
1691 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
1692 | parent -= GetParent()->GetClientAreaOrigin() ; | |
1693 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 VZ |
1694 | CopyRgn( updateOuter , updateTotal ) ; |
1695 | ||
d390fdcf SC |
1696 | rect = r ; |
1697 | RectRgn( updateInner , &rect ) ; | |
1698 | InsetRect( &rect , -outerBorder , -outerBorder ) ; | |
1699 | RectRgn( updateOuter , &rect ) ; | |
1700 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
7ebf5540 SC |
1701 | |
1702 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
8b573fb8 | 1703 | UnionRgn( updateOuter , updateTotal , updateTotal ) ; |
d390fdcf SC |
1704 | |
1705 | GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ; | |
1706 | DisposeRgn(updateOuter) ; | |
1707 | DisposeRgn(updateInner) ; | |
1708 | DisposeRgn(updateTotal) ; | |
1709 | } | |
5ca0d812 | 1710 | |
b05bf6ee SC |
1711 | // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! |
1712 | if ( vis ) | |
5ca0d812 | 1713 | m_peer->SetVisibility( false , true ) ; |
d390fdcf | 1714 | |
8b573fb8 | 1715 | m_peer->SetRect( &r ) ; |
b05bf6ee | 1716 | if ( vis ) |
5ca0d812 SC |
1717 | m_peer->SetVisibility( true , true ) ; |
1718 | ||
6264b550 RR |
1719 | MacRepositionScrollBars() ; |
1720 | if ( doMove ) | |
1721 | { | |
facd6764 | 1722 | wxPoint point(actualX,actualY); |
6264b550 RR |
1723 | wxMoveEvent event(point, m_windowId); |
1724 | event.SetEventObject(this); | |
1725 | GetEventHandler()->ProcessEvent(event) ; | |
1726 | } | |
1727 | if ( doResize ) | |
1728 | { | |
e40298d5 | 1729 | MacRepositionScrollBars() ; |
facd6764 | 1730 | wxSize size(actualWidth, actualHeight); |
e40298d5 JS |
1731 | wxSizeEvent event(size, m_windowId); |
1732 | event.SetEventObject(this); | |
1733 | GetEventHandler()->ProcessEvent(event); | |
6264b550 RR |
1734 | } |
1735 | } | |
6ed71b4f | 1736 | |
954fc50b SC |
1737 | } |
1738 | ||
facd6764 SC |
1739 | wxSize wxWindowMac::DoGetBestSize() const |
1740 | { | |
eb69d46e SC |
1741 | if ( m_macIsUserPane || IsTopLevel() ) |
1742 | return wxWindowBase::DoGetBestSize() ; | |
8b573fb8 | 1743 | |
facd6764 | 1744 | Rect bestsize = { 0 , 0 , 0 , 0 } ; |
facd6764 | 1745 | int bestWidth, bestHeight ; |
5ca0d812 | 1746 | m_peer->GetBestRect( &bestsize ) ; |
facd6764 SC |
1747 | |
1748 | if ( EmptyRect( &bestsize ) ) | |
1749 | { | |
facd6764 SC |
1750 | bestsize.left = bestsize.top = 0 ; |
1751 | bestsize.right = 16 ; | |
1752 | bestsize.bottom = 16 ; | |
1753 | if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) | |
1754 | { | |
1755 | bestsize.bottom = 16 ; | |
1756 | } | |
e3e817d4 | 1757 | #if wxUSE_SPINBTN |
facd6764 SC |
1758 | else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) |
1759 | { | |
8b573fb8 | 1760 | bestsize.bottom = 24 ; |
facd6764 | 1761 | } |
e3e817d4 | 1762 | #endif // wxUSE_SPINBTN |
facd6764 SC |
1763 | else |
1764 | { | |
8b573fb8 | 1765 | // return wxWindowBase::DoGetBestSize() ; |
facd6764 SC |
1766 | } |
1767 | } | |
1768 | ||
1769 | bestWidth = bestsize.right - bestsize.left ; | |
1770 | bestHeight = bestsize.bottom - bestsize.top ; | |
1771 | if ( bestHeight < 10 ) | |
1772 | bestHeight = 13 ; | |
8b573fb8 | 1773 | |
facd6764 SC |
1774 | return wxSize(bestWidth, bestHeight); |
1775 | } | |
1776 | ||
1777 | ||
954fc50b SC |
1778 | // set the size of the window: if the dimensions are positive, just use them, |
1779 | // but if any of them is equal to -1, it means that we must find the value for | |
1780 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1781 | // which case -1 is a valid value for x and y) | |
1782 | // | |
1783 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1784 | // the width/height to best suit our contents, otherwise we reuse the current | |
1785 | // width/height | |
1786 | void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) | |
1787 | { | |
1788 | // get the current size and position... | |
1789 | int currentX, currentY; | |
1790 | GetPosition(¤tX, ¤tY); | |
6ed71b4f | 1791 | |
954fc50b SC |
1792 | int currentW,currentH; |
1793 | GetSize(¤tW, ¤tH); | |
6ed71b4f | 1794 | |
954fc50b SC |
1795 | // ... and don't do anything (avoiding flicker) if it's already ok |
1796 | if ( x == currentX && y == currentY && | |
769ac869 | 1797 | width == currentW && height == currentH && ( height != -1 && width != -1 ) ) |
954fc50b | 1798 | { |
facd6764 | 1799 | // TODO REMOVE |
6264b550 | 1800 | MacRepositionScrollBars() ; // we might have a real position shift |
954fc50b SC |
1801 | return; |
1802 | } | |
6ed71b4f | 1803 | |
954fc50b SC |
1804 | if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) |
1805 | x = currentX; | |
1806 | if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) | |
1807 | y = currentY; | |
6ed71b4f | 1808 | |
954fc50b | 1809 | AdjustForParentClientOrigin(x, y, sizeFlags); |
6ed71b4f | 1810 | |
954fc50b SC |
1811 | wxSize size(-1, -1); |
1812 | if ( width == -1 ) | |
1813 | { | |
1814 | if ( sizeFlags & wxSIZE_AUTO_WIDTH ) | |
1815 | { | |
1816 | size = DoGetBestSize(); | |
1817 | width = size.x; | |
1818 | } | |
1819 | else | |
1820 | { | |
1821 | // just take the current one | |
1822 | width = currentW; | |
1823 | } | |
1824 | } | |
6ed71b4f | 1825 | |
954fc50b SC |
1826 | if ( height == -1 ) |
1827 | { | |
1828 | if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) | |
1829 | { | |
1830 | if ( size.x == -1 ) | |
1831 | { | |
1832 | size = DoGetBestSize(); | |
1833 | } | |
1834 | //else: already called DoGetBestSize() above | |
6ed71b4f | 1835 | |
954fc50b SC |
1836 | height = size.y; |
1837 | } | |
1838 | else | |
1839 | { | |
1840 | // just take the current one | |
1841 | height = currentH; | |
1842 | } | |
1843 | } | |
6ed71b4f | 1844 | |
954fc50b | 1845 | DoMoveWindow(x, y, width, height); |
6ed71b4f | 1846 | |
e9576ca5 | 1847 | } |
519cb848 | 1848 | |
e766c8a9 | 1849 | wxPoint wxWindowMac::GetClientAreaOrigin() const |
e9576ca5 | 1850 | { |
facd6764 SC |
1851 | RgnHandle rgn = NewRgn() ; |
1852 | Rect content ; | |
5ca0d812 | 1853 | m_peer->GetRegion( kControlContentMetaPart , rgn ) ; |
facd6764 SC |
1854 | GetRegionBounds( rgn , &content ) ; |
1855 | DisposeRgn( rgn ) ; | |
1856 | #if !TARGET_API_MAC_OSX | |
736fac3a SC |
1857 | // if the content rgn is empty / not supported |
1858 | // don't attempt to correct the coordinates to wxWindow relative ones | |
1859 | if (!::EmptyRect( &content ) ) | |
1860 | { | |
1861 | Rect structure ; | |
5ca0d812 | 1862 | m_peer->GetRect( &structure ) ; |
736fac3a SC |
1863 | OffsetRect( &content , -structure.left , -structure.top ) ; |
1864 | } | |
8b573fb8 | 1865 | #endif |
facd6764 SC |
1866 | |
1867 | return wxPoint( content.left + MacGetLeftBorderSize( ) , content.top + MacGetTopBorderSize( ) ); | |
1868 | } | |
1869 | ||
1870 | void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) | |
1871 | { | |
1872 | if ( clientheight != -1 || clientheight != -1 ) | |
1873 | { | |
1874 | int currentclientwidth , currentclientheight ; | |
1875 | int currentwidth , currentheight ; | |
1876 | ||
1877 | GetClientSize( ¤tclientwidth , ¤tclientheight ) ; | |
1878 | GetSize( ¤twidth , ¤theight ) ; | |
1879 | ||
1880 | DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , | |
1881 | currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; | |
1882 | } | |
e9576ca5 SC |
1883 | } |
1884 | ||
d84afea9 | 1885 | void wxWindowMac::SetTitle(const wxString& title) |
e9576ca5 | 1886 | { |
facd6764 SC |
1887 | m_label = wxStripMenuCodes(title) ; |
1888 | ||
21fd5529 | 1889 | if ( m_peer && m_peer->Ok() ) |
facd6764 | 1890 | { |
5ca0d812 | 1891 | m_peer->SetTitle( m_label ) ; |
facd6764 SC |
1892 | } |
1893 | Refresh() ; | |
519cb848 SC |
1894 | } |
1895 | ||
d84afea9 | 1896 | wxString wxWindowMac::GetTitle() const |
519cb848 | 1897 | { |
ed60b502 | 1898 | return m_label ; |
519cb848 SC |
1899 | } |
1900 | ||
8ab50549 SC |
1901 | bool wxWindowMac::Show(bool show) |
1902 | { | |
1903 | if ( !wxWindowBase::Show(show) ) | |
1904 | return FALSE; | |
8b573fb8 | 1905 | |
8ab50549 | 1906 | // TODO use visibilityChanged Carbon Event for OSX |
2c899c20 SC |
1907 | if ( m_peer ) |
1908 | { | |
1909 | bool former = MacIsReallyShown() ; | |
8b573fb8 | 1910 | |
2c899c20 SC |
1911 | m_peer->SetVisibility( show , true ) ; |
1912 | if ( former != MacIsReallyShown() ) | |
1913 | MacPropagateVisibilityChanged() ; | |
1914 | } | |
8ab50549 SC |
1915 | return TRUE; |
1916 | } | |
1917 | ||
1918 | bool wxWindowMac::Enable(bool enable) | |
1919 | { | |
21fd5529 | 1920 | wxASSERT( m_peer->Ok() ) ; |
8ab50549 SC |
1921 | if ( !wxWindowBase::Enable(enable) ) |
1922 | return FALSE; | |
1923 | ||
1924 | bool former = MacIsReallyEnabled() ; | |
5ca0d812 | 1925 | m_peer->Enable( enable ) ; |
8ab50549 SC |
1926 | |
1927 | if ( former != MacIsReallyEnabled() ) | |
1928 | MacPropagateEnabledStateChanged() ; | |
1929 | return TRUE; | |
1930 | } | |
1931 | ||
8b573fb8 | 1932 | // |
8ab50549 SC |
1933 | // status change propagations (will be not necessary for OSX later ) |
1934 | // | |
1935 | ||
facd6764 SC |
1936 | void wxWindowMac::MacPropagateVisibilityChanged() |
1937 | { | |
73fe67bd | 1938 | #if !TARGET_API_MAC_OSX |
facd6764 | 1939 | MacVisibilityChanged() ; |
8b573fb8 | 1940 | |
71f2fb52 | 1941 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
facd6764 SC |
1942 | while ( node ) |
1943 | { | |
1944 | wxWindowMac *child = node->GetData(); | |
1945 | if ( child->IsShown() ) | |
1946 | child->MacPropagateVisibilityChanged( ) ; | |
1947 | node = node->GetNext(); | |
1948 | } | |
73fe67bd | 1949 | #endif |
facd6764 SC |
1950 | } |
1951 | ||
8ab50549 | 1952 | void wxWindowMac::MacPropagateEnabledStateChanged( ) |
e9576ca5 | 1953 | { |
73fe67bd | 1954 | #if !TARGET_API_MAC_OSX |
8ab50549 | 1955 | MacEnabledStateChanged() ; |
8b573fb8 | 1956 | |
71f2fb52 | 1957 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
8ab50549 SC |
1958 | while ( node ) |
1959 | { | |
1960 | wxWindowMac *child = node->GetData(); | |
1961 | if ( child->IsEnabled() ) | |
1962 | child->MacPropagateEnabledStateChanged() ; | |
1963 | node = node->GetNext(); | |
1964 | } | |
73fe67bd | 1965 | #endif |
8ab50549 SC |
1966 | } |
1967 | ||
1968 | void wxWindowMac::MacPropagateHiliteChanged( ) | |
1969 | { | |
73fe67bd | 1970 | #if !TARGET_API_MAC_OSX |
8ab50549 | 1971 | MacHiliteChanged() ; |
8b573fb8 | 1972 | |
71f2fb52 | 1973 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
8ab50549 SC |
1974 | while ( node ) |
1975 | { | |
1976 | wxWindowMac *child = node->GetData(); | |
1977 | // if ( child->IsEnabled() ) | |
1978 | child->MacPropagateHiliteChanged() ; | |
1979 | node = node->GetNext(); | |
1980 | } | |
73fe67bd | 1981 | #endif |
8ab50549 SC |
1982 | } |
1983 | ||
1984 | // | |
1985 | // status change notifications | |
8b573fb8 | 1986 | // |
8ab50549 | 1987 | |
8b573fb8 | 1988 | void wxWindowMac::MacVisibilityChanged() |
8ab50549 SC |
1989 | { |
1990 | } | |
1991 | ||
8b573fb8 | 1992 | void wxWindowMac::MacHiliteChanged() |
8ab50549 SC |
1993 | { |
1994 | } | |
1995 | ||
8b573fb8 | 1996 | void wxWindowMac::MacEnabledStateChanged() |
8ab50549 | 1997 | { |
facd6764 | 1998 | } |
e7549107 | 1999 | |
8ab50549 SC |
2000 | // |
2001 | // status queries on the inherited window's state | |
2002 | // | |
2003 | ||
8b573fb8 | 2004 | bool wxWindowMac::MacIsReallyShown() |
facd6764 SC |
2005 | { |
2006 | // only under OSX the visibility of the TLW is taken into account | |
2007 | #if TARGET_API_MAC_OSX | |
aa522e33 SC |
2008 | if ( m_peer && m_peer->Ok() ) |
2009 | return m_peer->IsVisible(); | |
2010 | #endif | |
facd6764 SC |
2011 | wxWindow* win = this ; |
2012 | while( win->IsShown() ) | |
2013 | { | |
2014 | if ( win->IsTopLevel() ) | |
2015 | return true ; | |
8b573fb8 | 2016 | |
facd6764 SC |
2017 | win = win->GetParent() ; |
2018 | if ( win == NULL ) | |
2019 | return true ; | |
8b573fb8 | 2020 | |
facd6764 SC |
2021 | } ; |
2022 | return false ; | |
facd6764 | 2023 | } |
4241baae | 2024 | |
8b573fb8 | 2025 | bool wxWindowMac::MacIsReallyEnabled() |
facd6764 | 2026 | { |
5ca0d812 | 2027 | return m_peer->IsEnabled() ; |
facd6764 SC |
2028 | } |
2029 | ||
8b573fb8 | 2030 | bool wxWindowMac::MacIsReallyHilited() |
c809f3be | 2031 | { |
5ca0d812 | 2032 | return m_peer->IsActive(); |
c809f3be SC |
2033 | } |
2034 | ||
8b573fb8 | 2035 | void wxWindowMac::MacFlashInvalidAreas() |
002c9672 SC |
2036 | { |
2037 | #if TARGET_API_MAC_OSX | |
2038 | HIViewFlashDirtyArea( (WindowRef) MacGetTopLevelWindowRef() ) ; | |
2039 | #endif | |
2040 | } | |
2041 | ||
8ab50549 SC |
2042 | // |
2043 | // | |
2044 | // | |
2045 | ||
e766c8a9 | 2046 | int wxWindowMac::GetCharHeight() const |
e9576ca5 | 2047 | { |
6264b550 RR |
2048 | wxClientDC dc ( (wxWindowMac*)this ) ; |
2049 | return dc.GetCharHeight() ; | |
e9576ca5 SC |
2050 | } |
2051 | ||
e766c8a9 | 2052 | int wxWindowMac::GetCharWidth() const |
e9576ca5 | 2053 | { |
6264b550 RR |
2054 | wxClientDC dc ( (wxWindowMac*)this ) ; |
2055 | return dc.GetCharWidth() ; | |
e9576ca5 SC |
2056 | } |
2057 | ||
e766c8a9 | 2058 | void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y, |
e7549107 | 2059 | int *descent, int *externalLeading, const wxFont *theFont ) const |
e9576ca5 | 2060 | { |
e7549107 SC |
2061 | const wxFont *fontToUse = theFont; |
2062 | if ( !fontToUse ) | |
2063 | fontToUse = &m_font; | |
14c9cbdb | 2064 | |
e766c8a9 | 2065 | wxClientDC dc( (wxWindowMac*) this ) ; |
7c74e7fe | 2066 | long lx,ly,ld,le ; |
5fde6fcc | 2067 | dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ; |
2f1ae414 | 2068 | if ( externalLeading ) |
6264b550 | 2069 | *externalLeading = le ; |
2f1ae414 | 2070 | if ( descent ) |
6264b550 | 2071 | *descent = ld ; |
2f1ae414 | 2072 | if ( x ) |
6264b550 | 2073 | *x = lx ; |
2f1ae414 | 2074 | if ( y ) |
6264b550 | 2075 | *y = ly ; |
e9576ca5 SC |
2076 | } |
2077 | ||
0a67a93b | 2078 | /* |
14c9cbdb | 2079 | * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect |
1c310985 SC |
2080 | * we always intersect with the entire window, not only with the client area |
2081 | */ | |
14c9cbdb | 2082 | |
e766c8a9 | 2083 | void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) |
e9576ca5 | 2084 | { |
065ab451 SC |
2085 | if ( m_peer == NULL ) |
2086 | return ; | |
8b573fb8 | 2087 | |
facd6764 | 2088 | #if TARGET_API_MAC_OSX |
1e8cde71 | 2089 | if ( rect == NULL ) |
8b573fb8 | 2090 | m_peer->SetNeedsDisplay( true ) ; |
1e8cde71 SC |
2091 | else |
2092 | { | |
2093 | RgnHandle update = NewRgn() ; | |
2094 | SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; | |
84f6927e SC |
2095 | SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; |
2096 | wxPoint origin = GetClientAreaOrigin() ; | |
8b573fb8 | 2097 | OffsetRgn( update, origin.x , origin.y ) ; |
db7a550b SC |
2098 | // right now this is wx' window coordinates, as our native peer does not have borders, this is |
2099 | // inset | |
2100 | OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; | |
8b573fb8 VZ |
2101 | m_peer->SetNeedsDisplay( true , update) ; |
2102 | DisposeRgn( update ) ; | |
1e8cde71 | 2103 | } |
facd6764 | 2104 | #else |
a9825a9b SC |
2105 | /* |
2106 | RgnHandle updateRgn = NewRgn() ; | |
2107 | if ( rect == NULL ) | |
2108 | { | |
2109 | CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ; | |
2110 | } | |
2111 | else | |
2112 | { | |
2113 | SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; | |
8b573fb8 | 2114 | SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ; |
a9825a9b SC |
2115 | } |
2116 | InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ; | |
2117 | DisposeRgn(updateRgn) ; | |
2118 | */ | |
5ca0d812 | 2119 | if ( m_peer->IsVisible()) |
facd6764 | 2120 | { |
5ca0d812 SC |
2121 | m_peer->SetVisibility( false , false ) ; |
2122 | m_peer->SetVisibility( true , true ) ; | |
facd6764 SC |
2123 | } |
2124 | /* | |
94abc21f | 2125 | if ( MacGetTopLevelWindow() == NULL ) |
9a456218 | 2126 | return ; |
14c9cbdb | 2127 | |
5ca0d812 | 2128 | if ( !m_peer->IsVisible()) |
8b573fb8 VZ |
2129 | return ; |
2130 | ||
c3a05e8a | 2131 | wxPoint client = GetClientAreaOrigin(); |
9a456218 RR |
2132 | int x1 = -client.x; |
2133 | int y1 = -client.y; | |
2134 | int x2 = m_width - client.x; | |
2135 | int y2 = m_height - client.y; | |
2136 | ||
2137 | if (IsKindOf( CLASSINFO(wxButton))) | |
2138 | { | |
2139 | // buttons have an "aura" | |
2140 | y1 -= 5; | |
2141 | x1 -= 5; | |
2142 | y2 += 5; | |
2143 | x2 += 5; | |
2144 | } | |
2145 | ||
2146 | Rect clientrect = { y1, x1, y2, x2 }; | |
14c9cbdb | 2147 | |
1c310985 | 2148 | if ( rect ) |
6264b550 | 2149 | { |
1c310985 | 2150 | Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; |
14c9cbdb | 2151 | SectRect( &clientrect , &r , &clientrect ) ; |
6264b550 | 2152 | } |
14c9cbdb | 2153 | |
1c310985 | 2154 | if ( !EmptyRect( &clientrect ) ) |
e9576ca5 | 2155 | { |
1c310985 | 2156 | int top = 0 , left = 0 ; |
14c9cbdb | 2157 | |
1c310985 SC |
2158 | MacClientToRootWindow( &left , &top ) ; |
2159 | OffsetRect( &clientrect , left , top ) ; | |
14c9cbdb | 2160 | |
1c310985 | 2161 | MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ; |
e9576ca5 | 2162 | } |
facd6764 SC |
2163 | */ |
2164 | #endif | |
2165 | } | |
2166 | ||
79392158 SC |
2167 | void wxWindowMac::Freeze() |
2168 | { | |
2169 | #if TARGET_API_MAC_OSX | |
2170 | if ( !m_frozenness++ ) | |
2171 | { | |
52ef5c3c RD |
2172 | if ( m_peer && m_peer->Ok() ) |
2173 | m_peer->SetDrawingEnabled( false ) ; | |
79392158 SC |
2174 | } |
2175 | #endif | |
2176 | } | |
2177 | ||
b175b96b | 2178 | |
79392158 SC |
2179 | void wxWindowMac::Thaw() |
2180 | { | |
2181 | #if TARGET_API_MAC_OSX | |
2182 | wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); | |
2183 | ||
2184 | if ( !--m_frozenness ) | |
2185 | { | |
52ef5c3c RD |
2186 | if ( m_peer && m_peer->Ok() ) |
2187 | { | |
2188 | m_peer->SetDrawingEnabled( true ) ; | |
2189 | m_peer->InvalidateWithChildren() ; | |
2190 | } | |
79392158 SC |
2191 | } |
2192 | #endif | |
2193 | } | |
2194 | ||
facd6764 SC |
2195 | void wxWindowMac::MacRedrawControl() |
2196 | { | |
2197 | /* | |
5ca0d812 | 2198 | if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible()) |
facd6764 SC |
2199 | { |
2200 | #if TARGET_API_MAC_CARBON | |
2201 | Update() ; | |
2202 | #else | |
2203 | wxClientDC dc(this) ; | |
2204 | wxMacPortSetter helper(&dc) ; | |
2205 | wxMacWindowClipper clipper(this) ; | |
2206 | wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; | |
21fd5529 | 2207 | UMADrawControl( *m_peer ) ; |
facd6764 SC |
2208 | #endif |
2209 | } | |
2210 | */ | |
2211 | } | |
8b573fb8 | 2212 | |
facd6764 SC |
2213 | /* TODO |
2214 | void wxWindowMac::OnPaint(wxPaintEvent& event) | |
2215 | { | |
2216 | // why don't we skip that here ? | |
e9576ca5 | 2217 | } |
facd6764 | 2218 | */ |
e9576ca5 | 2219 | |
e766c8a9 | 2220 | wxWindowMac *wxGetActiveWindow() |
e9576ca5 | 2221 | { |
519cb848 | 2222 | // actually this is a windows-only concept |
e9576ca5 SC |
2223 | return NULL; |
2224 | } | |
2225 | ||
e9576ca5 | 2226 | // Coordinates relative to the window |
e766c8a9 | 2227 | void wxWindowMac::WarpPointer (int x_pos, int y_pos) |
e9576ca5 | 2228 | { |
e40298d5 | 2229 | // We really don't move the mouse programmatically under Mac. |
e9576ca5 SC |
2230 | } |
2231 | ||
facd6764 | 2232 | void wxWindowMac::OnEraseBackground(wxEraseEvent& event) |
e9576ca5 | 2233 | { |
be346c26 | 2234 | #if TARGET_API_MAC_OSX |
facd6764 | 2235 | if ( m_macBackgroundBrush.Ok() == false || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT ) |
94abc21f | 2236 | { |
facd6764 | 2237 | event.Skip() ; |
94abc21f SC |
2238 | } |
2239 | else | |
be346c26 | 2240 | #endif |
7ebf5540 | 2241 | { |
8b573fb8 | 2242 | event.GetDC()->Clear() ; |
7ebf5540 | 2243 | } |
1c310985 SC |
2244 | } |
2245 | ||
2246 | void wxWindowMac::OnNcPaint( wxNcPaintEvent& event ) | |
2247 | { | |
af6b7b80 | 2248 | event.Skip() ; |
e9576ca5 SC |
2249 | } |
2250 | ||
e766c8a9 | 2251 | int wxWindowMac::GetScrollPos(int orient) const |
e9576ca5 | 2252 | { |
1c310985 SC |
2253 | if ( orient == wxHORIZONTAL ) |
2254 | { | |
2255 | if ( m_hScrollBar ) | |
2256 | return m_hScrollBar->GetThumbPosition() ; | |
2257 | } | |
2258 | else | |
2259 | { | |
2260 | if ( m_vScrollBar ) | |
2261 | return m_vScrollBar->GetThumbPosition() ; | |
2262 | } | |
e9576ca5 SC |
2263 | return 0; |
2264 | } | |
2265 | ||
2266 | // This now returns the whole range, not just the number | |
2267 | // of positions that we can scroll. | |
e766c8a9 | 2268 | int wxWindowMac::GetScrollRange(int orient) const |
e9576ca5 | 2269 | { |
1c310985 SC |
2270 | if ( orient == wxHORIZONTAL ) |
2271 | { | |
2272 | if ( m_hScrollBar ) | |
2273 | return m_hScrollBar->GetRange() ; | |
2274 | } | |
2275 | else | |
2276 | { | |
2277 | if ( m_vScrollBar ) | |
2278 | return m_vScrollBar->GetRange() ; | |
2279 | } | |
e9576ca5 SC |
2280 | return 0; |
2281 | } | |
2282 | ||
e766c8a9 | 2283 | int wxWindowMac::GetScrollThumb(int orient) const |
e9576ca5 | 2284 | { |
1c310985 SC |
2285 | if ( orient == wxHORIZONTAL ) |
2286 | { | |
2287 | if ( m_hScrollBar ) | |
2288 | return m_hScrollBar->GetThumbSize() ; | |
2289 | } | |
2290 | else | |
2291 | { | |
2292 | if ( m_vScrollBar ) | |
2293 | return m_vScrollBar->GetThumbSize() ; | |
2294 | } | |
e9576ca5 SC |
2295 | return 0; |
2296 | } | |
2297 | ||
e766c8a9 | 2298 | void wxWindowMac::SetScrollPos(int orient, int pos, bool refresh) |
e9576ca5 | 2299 | { |
1c310985 | 2300 | if ( orient == wxHORIZONTAL ) |
6264b550 | 2301 | { |
1c310985 SC |
2302 | if ( m_hScrollBar ) |
2303 | m_hScrollBar->SetThumbPosition( pos ) ; | |
6264b550 RR |
2304 | } |
2305 | else | |
2306 | { | |
1c310985 SC |
2307 | if ( m_vScrollBar ) |
2308 | m_vScrollBar->SetThumbPosition( pos ) ; | |
6264b550 | 2309 | } |
2f1ae414 SC |
2310 | } |
2311 | ||
14c9cbdb | 2312 | void wxWindowMac::MacPaintBorders( int left , int top ) |
2f1ae414 | 2313 | { |
1c310985 | 2314 | if( IsTopLevel() ) |
6264b550 | 2315 | return ; |
8b573fb8 | 2316 | |
fd926bcc | 2317 | Rect rect ; |
8b573fb8 | 2318 | m_peer->GetRect( &rect ) ; |
fd926bcc SC |
2319 | InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; |
2320 | ||
2321 | if ( !IsTopLevel() ) | |
2322 | { | |
2323 | wxTopLevelWindowMac* top = MacGetTopLevelWindow(); | |
2324 | if (top) | |
2325 | { | |
2326 | wxPoint pt(0,0) ; | |
2327 | wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ; | |
2328 | rect.left += pt.x ; | |
2329 | rect.right += pt.x ; | |
2330 | rect.top += pt.y ; | |
2331 | rect.bottom += pt.y ; | |
2332 | } | |
2333 | } | |
8b573fb8 | 2334 | |
2f1ae414 SC |
2335 | if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) |
2336 | { | |
af6b7b80 | 2337 | Rect srect = rect ; |
11d1adbf | 2338 | SInt32 border = 0 ; |
5ca0d812 | 2339 | GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ; |
af6b7b80 SC |
2340 | InsetRect( &srect , border , border ); |
2341 | DrawThemeEditTextFrame(&srect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; | |
8208e181 SC |
2342 | } |
2343 | else if (HasFlag(wxSIMPLE_BORDER)) | |
2344 | { | |
af6b7b80 | 2345 | Rect srect = rect ; |
1a02aff9 SC |
2346 | SInt32 border = 0 ; |
2347 | GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ; | |
af6b7b80 | 2348 | InsetRect( &srect , border , border ); |
8b573fb8 | 2349 | DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; |
eec462f8 | 2350 | } |
8208e181 SC |
2351 | } |
2352 | ||
abda5788 SC |
2353 | void wxWindowMac::RemoveChild( wxWindowBase *child ) |
2354 | { | |
2355 | if ( child == m_hScrollBar ) | |
2356 | m_hScrollBar = NULL ; | |
2357 | if ( child == m_vScrollBar ) | |
2358 | m_vScrollBar = NULL ; | |
14c9cbdb | 2359 | |
abda5788 SC |
2360 | wxWindowBase::RemoveChild( child ) ; |
2361 | } | |
2362 | ||
e9576ca5 | 2363 | // New function that will replace some of the above. |
e766c8a9 | 2364 | void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, |
e9576ca5 SC |
2365 | int range, bool refresh) |
2366 | { | |
e40298d5 JS |
2367 | if ( orient == wxHORIZONTAL ) |
2368 | { | |
2369 | if ( m_hScrollBar ) | |
6264b550 | 2370 | { |
e40298d5 | 2371 | if ( range == 0 || thumbVisible >= range ) |
6264b550 | 2372 | { |
e40298d5 JS |
2373 | if ( m_hScrollBar->IsShown() ) |
2374 | m_hScrollBar->Show(false) ; | |
2375 | } | |
2376 | else | |
2377 | { | |
2378 | if ( !m_hScrollBar->IsShown() ) | |
2379 | m_hScrollBar->Show(true) ; | |
2380 | m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
6264b550 RR |
2381 | } |
2382 | } | |
e40298d5 JS |
2383 | } |
2384 | else | |
2385 | { | |
2386 | if ( m_vScrollBar ) | |
6264b550 | 2387 | { |
e40298d5 | 2388 | if ( range == 0 || thumbVisible >= range ) |
6264b550 | 2389 | { |
e40298d5 JS |
2390 | if ( m_vScrollBar->IsShown() ) |
2391 | m_vScrollBar->Show(false) ; | |
2392 | } | |
2393 | else | |
2394 | { | |
2395 | if ( !m_vScrollBar->IsShown() ) | |
2396 | m_vScrollBar->Show(true) ; | |
2397 | m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; | |
6264b550 RR |
2398 | } |
2399 | } | |
e40298d5 JS |
2400 | } |
2401 | MacRepositionScrollBars() ; | |
e9576ca5 SC |
2402 | } |
2403 | ||
2404 | // Does a physical scroll | |
e766c8a9 | 2405 | void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) |
e9576ca5 | 2406 | { |
ba87f54c SC |
2407 | if( dx == 0 && dy ==0 ) |
2408 | return ; | |
8b573fb8 | 2409 | |
6ed71b4f | 2410 | |
6264b550 | 2411 | { |
adb8a71b | 2412 | |
6264b550 RR |
2413 | int width , height ; |
2414 | GetClientSize( &width , &height ) ; | |
adb8a71b | 2415 | #if TARGET_API_MAC_OSX |
002c9672 | 2416 | // note there currently is a bug in OSX which makes inefficient refreshes in case an entire control |
8b573fb8 | 2417 | // area is scrolled, this does not occur if width and height are 2 pixels less, |
002c9672 | 2418 | // TODO write optimal workaround |
42ef83fa | 2419 | wxRect scrollrect( MacGetLeftBorderSize() , MacGetTopBorderSize() , width , height ) ; |
8b573fb8 | 2420 | if ( rect ) |
adb8a71b | 2421 | { |
5ca0d812 | 2422 | scrollrect.Intersect( *rect ) ; |
adb8a71b | 2423 | } |
5ca0d812 | 2424 | if ( m_peer->GetNeedsDisplay() ) |
002c9672 SC |
2425 | { |
2426 | // becuase HIViewScrollRect does not scroll the already invalidated area we have two options | |
2427 | // either immediate redraw or full invalidate | |
2428 | #if 1 | |
2429 | // is the better overall solution, as it does not slow down scrolling | |
5ca0d812 | 2430 | m_peer->SetNeedsDisplay( true ) ; |
002c9672 | 2431 | #else |
8b573fb8 | 2432 | // this would be the preferred version for fast drawing controls |
002c9672 SC |
2433 | if( UMAGetSystemVersion() < 0x1030 ) |
2434 | Update() ; | |
2435 | else | |
42ef83fa | 2436 | HIViewRender(m_peer->GetControlRef()) ; |
002c9672 SC |
2437 | #endif |
2438 | } | |
84e5d27d SC |
2439 | // as the native control might be not a 0/0 wx window coordinates, we have to offset |
2440 | scrollrect.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; | |
5ca0d812 | 2441 | m_peer->ScrollRect( scrollrect , dx , dy ) ; |
adb8a71b | 2442 | #else |
6ed71b4f | 2443 | |
facd6764 | 2444 | wxPoint pos; |
8b573fb8 | 2445 | pos.x = pos.y = 0; |
430e1eed | 2446 | |
facd6764 | 2447 | Rect scrollrect; |
6264b550 | 2448 | RgnHandle updateRgn = NewRgn() ; |
430e1eed | 2449 | |
adb8a71b | 2450 | { |
430e1eed SC |
2451 | wxClientDC dc(this) ; |
2452 | wxMacPortSetter helper(&dc) ; | |
8b573fb8 | 2453 | |
5ca0d812 | 2454 | m_peer->GetRect( &scrollrect ) ; |
430e1eed SC |
2455 | scrollrect.top += MacGetTopBorderSize() ; |
2456 | scrollrect.left += MacGetLeftBorderSize() ; | |
2457 | scrollrect.bottom = scrollrect.top + height ; | |
2458 | scrollrect.right = scrollrect.left + width ; | |
8b573fb8 | 2459 | |
430e1eed SC |
2460 | if ( rect ) |
2461 | { | |
2462 | Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) , | |
2463 | dc.XLOG2DEVMAC(rect->x + rect->width) } ; | |
2464 | SectRect( &scrollrect , &r , &scrollrect ) ; | |
2465 | } | |
2466 | ScrollRect( &scrollrect , dx , dy , updateRgn ) ; | |
ba87f54c | 2467 | } |
430e1eed | 2468 | // ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ; |
facd6764 | 2469 | #endif |
6264b550 | 2470 | } |
6ed71b4f | 2471 | |
71f2fb52 | 2472 | for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext()) |
6264b550 | 2473 | { |
9bd1404d | 2474 | wxWindowMac *child = node->GetData(); |
6264b550 RR |
2475 | if (child == m_vScrollBar) continue; |
2476 | if (child == m_hScrollBar) continue; | |
2477 | if (child->IsTopLevel()) continue; | |
6ed71b4f | 2478 | |
6264b550 RR |
2479 | int x,y; |
2480 | child->GetPosition( &x, &y ); | |
2481 | int w,h; | |
2482 | child->GetSize( &w, &h ); | |
00f55394 SC |
2483 | if (rect) |
2484 | { | |
2485 | wxRect rc(x,y,w,h); | |
2486 | if (rect->Intersects(rc)) | |
2487 | child->SetSize( x+dx, y+dy, w, h ); | |
2488 | } | |
2489 | else | |
2490 | { | |
8b573fb8 VZ |
2491 | child->SetSize( x+dx, y+dy, w, h ); |
2492 | } | |
6264b550 | 2493 | } |
e9576ca5 SC |
2494 | } |
2495 | ||
e766c8a9 | 2496 | void wxWindowMac::MacOnScroll(wxScrollEvent &event ) |
7c74e7fe | 2497 | { |
6264b550 RR |
2498 | if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar ) |
2499 | { | |
2500 | wxScrollWinEvent wevent; | |
2501 | wevent.SetPosition(event.GetPosition()); | |
2502 | wevent.SetOrientation(event.GetOrientation()); | |
2503 | wevent.m_eventObject = this; | |
6ed71b4f VZ |
2504 | |
2505 | if (event.m_eventType == wxEVT_SCROLL_TOP) | |
6264b550 | 2506 | wevent.m_eventType = wxEVT_SCROLLWIN_TOP; |
6ed71b4f VZ |
2507 | else if (event.m_eventType == wxEVT_SCROLL_BOTTOM) |
2508 | wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; | |
2509 | else if (event.m_eventType == wxEVT_SCROLL_LINEUP) | |
2510 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; | |
2511 | else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) | |
2512 | wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; | |
2513 | else if (event.m_eventType == wxEVT_SCROLL_PAGEUP) | |
2514 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; | |
2515 | else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) | |
2516 | wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; | |
2517 | else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) | |
2518 | wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; | |
2519 | else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE) | |
2520 | wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; | |
2521 | ||
2522 | GetEventHandler()->ProcessEvent(wevent); | |
7c74e7fe SC |
2523 | } |
2524 | } | |
2525 | ||
e9576ca5 | 2526 | // Get the window with the focus |
0fe02759 | 2527 | wxWindowMac *wxWindowBase::DoFindFocus() |
e9576ca5 | 2528 | { |
f1d527c1 SC |
2529 | ControlRef control ; |
2530 | GetKeyboardFocus( GetUserFocusWindow() , &control ) ; | |
2531 | return wxFindControlFromMacControl( control ) ; | |
519cb848 SC |
2532 | } |
2533 | ||
e766c8a9 | 2534 | void wxWindowMac::OnSetFocus(wxFocusEvent& event) |
7810c95b SC |
2535 | { |
2536 | // panel wants to track the window which was the last to have focus in it, | |
2537 | // so we want to set ourselves as the window which last had focus | |
2538 | // | |
2539 | // notice that it's also important to do it upwards the tree becaus | |
2540 | // otherwise when the top level panel gets focus, it won't set it back to | |
2541 | // us, but to some other sibling | |
6ed71b4f | 2542 | |
c1fb8167 SC |
2543 | // CS:don't know if this is still needed: |
2544 | //wxChildFocusEvent eventFocus(this); | |
2545 | //(void)GetEventHandler()->ProcessEvent(eventFocus); | |
7810c95b | 2546 | |
5ca0d812 SC |
2547 | if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) |
2548 | { | |
788e118f | 2549 | wxMacWindowStateSaver sv( this ) ; |
5ca0d812 SC |
2550 | |
2551 | int w , h ; | |
788e118f SC |
2552 | int x , y ; |
2553 | x = y = 0 ; | |
2554 | MacWindowToRootWindow( &x , &y ) ; | |
5ca0d812 | 2555 | GetSize( &w , &h ) ; |
788e118f | 2556 | Rect rect = {y , x , h + y , w + x } ; |
5ca0d812 SC |
2557 | |
2558 | if ( event.GetEventType() == wxEVT_SET_FOCUS ) | |
2559 | DrawThemeFocusRect( &rect , true ) ; | |
2560 | else | |
af6b7b80 | 2561 | { |
5ca0d812 | 2562 | DrawThemeFocusRect( &rect , false ) ; |
8b573fb8 | 2563 | |
af6b7b80 | 2564 | // as this erases part of the frame we have to redraw borders |
101634b2 SC |
2565 | // and because our z-ordering is not always correct (staticboxes) |
2566 | // we have to invalidate things, we cannot simple redraw | |
2567 | RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ; | |
2568 | RectRgn( updateInner , &rect ) ; | |
2569 | InsetRect( &rect , -4 , -4 ) ; | |
2570 | RectRgn( updateOuter , &rect ) ; | |
2571 | DiffRgn( updateOuter , updateInner ,updateOuter ) ; | |
8b573fb8 | 2572 | wxPoint parent(0,0); |
101634b2 SC |
2573 | GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; |
2574 | parent -= GetParent()->GetClientAreaOrigin() ; | |
2575 | OffsetRgn( updateOuter , -parent.x , -parent.y ) ; | |
2576 | GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ; | |
2577 | DisposeRgn(updateOuter) ; | |
2578 | DisposeRgn(updateInner) ; | |
af6b7b80 | 2579 | } |
5ca0d812 SC |
2580 | } |
2581 | ||
7810c95b SC |
2582 | event.Skip(); |
2583 | } | |
2584 | ||
e39af974 | 2585 | void wxWindowMac::OnInternalIdle() |
e9576ca5 | 2586 | { |
e9576ca5 SC |
2587 | // This calls the UI-update mechanism (querying windows for |
2588 | // menu/toolbar/control state information) | |
e39af974 JS |
2589 | if (wxUpdateUIEvent::CanUpdate(this)) |
2590 | UpdateWindowUI(wxUPDATE_UI_FROMIDLE); | |
e9576ca5 SC |
2591 | } |
2592 | ||
2593 | // Raise the window to the top of the Z order | |
e766c8a9 | 2594 | void wxWindowMac::Raise() |
e9576ca5 | 2595 | { |
5ca0d812 | 2596 | m_peer->SetZOrder( true , NULL ) ; |
e9576ca5 SC |
2597 | } |
2598 | ||
2599 | // Lower the window to the bottom of the Z order | |
e766c8a9 | 2600 | void wxWindowMac::Lower() |
e9576ca5 | 2601 | { |
5ca0d812 | 2602 | m_peer->SetZOrder( false , NULL ) ; |
e9576ca5 SC |
2603 | } |
2604 | ||
6ed71b4f | 2605 | |
facd6764 | 2606 | // static wxWindow *gs_lastWhich = NULL; |
519cb848 | 2607 | |
7de59551 | 2608 | bool wxWindowMac::MacSetupCursor( const wxPoint& pt) |
467e3168 SC |
2609 | { |
2610 | // first trigger a set cursor event | |
6ed71b4f | 2611 | |
467e3168 SC |
2612 | wxPoint clientorigin = GetClientAreaOrigin() ; |
2613 | wxSize clientsize = GetClientSize() ; | |
2614 | wxCursor cursor ; | |
2615 | if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) | |
7de59551 | 2616 | { |
467e3168 | 2617 | wxSetCursorEvent event( pt.x , pt.y ); |
6ed71b4f | 2618 | |
467e3168 SC |
2619 | bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); |
2620 | if ( processedEvtSetCursor && event.HasCursor() ) | |
2621 | { | |
e40298d5 | 2622 | cursor = event.GetCursor() ; |
467e3168 SC |
2623 | } |
2624 | else | |
2625 | { | |
6ed71b4f | 2626 | |
467e3168 SC |
2627 | // the test for processedEvtSetCursor is here to prevent using m_cursor |
2628 | // if the user code caught EVT_SET_CURSOR() and returned nothing from | |
2629 | // it - this is a way to say that our cursor shouldn't be used for this | |
2630 | // point | |
2631 | if ( !processedEvtSetCursor && m_cursor.Ok() ) | |
2632 | { | |
2633 | cursor = m_cursor ; | |
2634 | } | |
2635 | if ( wxIsBusy() ) | |
2636 | { | |
2637 | } | |
2638 | else | |
2639 | { | |
2640 | if ( !GetParent() ) | |
2641 | cursor = *wxSTANDARD_CURSOR ; | |
2642 | } | |
2643 | } | |
2644 | if ( cursor.Ok() ) | |
2645 | cursor.MacInstall() ; | |
2646 | } | |
2647 | return cursor.Ok() ; | |
2648 | } | |
2649 | ||
e766c8a9 | 2650 | wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) |
2f1ae414 | 2651 | { |
6264b550 RR |
2652 | if ( m_tooltip ) |
2653 | { | |
2654 | return m_tooltip->GetTip() ; | |
2655 | } | |
427ff662 | 2656 | return wxEmptyString ; |
2f1ae414 | 2657 | } |
6264b550 | 2658 | |
1c310985 | 2659 | void wxWindowMac::Update() |
519cb848 | 2660 | { |
facd6764 | 2661 | #if TARGET_API_MAC_OSX |
957f865c | 2662 | |
430e1eed | 2663 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 |
957f865c RN |
2664 | WindowRef window = (WindowRef)MacGetTopLevelWindowRef() ; |
2665 | ||
430e1eed SC |
2666 | // for composited windows this also triggers a redraw of all |
2667 | // invalid views in the window | |
2668 | if( UMAGetSystemVersion() >= 0x1030 ) | |
8b573fb8 VZ |
2669 | HIWindowFlush(window) ; |
2670 | else | |
430e1eed SC |
2671 | #endif |
2672 | { | |
2673 | // the only way to trigger the redrawing on earlier systems is to call | |
2674 | // ReceiveNextEvent | |
2675 | ||
2676 | EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; | |
2677 | UInt32 currentEventClass = 0 ; | |
2678 | UInt32 currentEventKind = 0 ; | |
2679 | if ( currentEvent != NULL ) | |
2680 | { | |
2681 | currentEventClass = ::GetEventClass( currentEvent ) ; | |
2682 | currentEventKind = ::GetEventKind( currentEvent ) ; | |
8b573fb8 | 2683 | } |
430e1eed SC |
2684 | if ( currentEventClass != kEventClassMenu ) |
2685 | { | |
2686 | // when tracking a menu, strange redraw errors occur if we flush now, so leave.. | |
2687 | ||
2688 | EventRef theEvent; | |
2689 | OSStatus status = noErr ; | |
2690 | status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ; | |
2691 | } | |
3e444781 | 2692 | else |
5ca0d812 | 2693 | m_peer->SetNeedsDisplay( true ) ; |
430e1eed | 2694 | } |
facd6764 | 2695 | #else |
5ca0d812 | 2696 | ::Draw1Control( m_peer->GetControlRef() ) ; |
bec721ec | 2697 | #endif |
519cb848 SC |
2698 | } |
2699 | ||
14c9cbdb | 2700 | wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const |
519cb848 | 2701 | { |
1c310985 | 2702 | wxTopLevelWindowMac* win = NULL ; |
facd6764 | 2703 | WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; |
1c310985 | 2704 | if ( window ) |
6264b550 | 2705 | { |
1c310985 | 2706 | win = wxFindWinFromMacWindow( window ) ; |
14c9cbdb | 2707 | } |
1c310985 | 2708 | return win ; |
519cb848 | 2709 | } |
facd6764 | 2710 | wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) |
94abc21f | 2711 | { |
0fa8508d SC |
2712 | // includeOuterStructures is true if we try to draw somthing like a focus ring etc. |
2713 | // also a window dc uses this, in this case we only clip in the hierarchy for hard | |
2714 | // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having | |
2715 | // to add focus borders everywhere | |
8b573fb8 | 2716 | |
facd6764 | 2717 | Rect r ; |
e40298d5 JS |
2718 | RgnHandle visRgn = NewRgn() ; |
2719 | RgnHandle tempRgn = NewRgn() ; | |
5ca0d812 | 2720 | if ( m_peer->IsVisible()) |
e40298d5 | 2721 | { |
5ca0d812 SC |
2722 | m_peer->GetRect( &r ) ; |
2723 | r.left -= MacGetLeftBorderSize() ; | |
2724 | r.top -= MacGetTopBorderSize() ; | |
2725 | r.bottom += MacGetBottomBorderSize() ; | |
2726 | r.right += MacGetRightBorderSize() ; | |
8b573fb8 | 2727 | |
facd6764 | 2728 | if (! MacGetTopLevelWindow()->MacUsesCompositing() ) |
21f9e953 | 2729 | { |
facd6764 SC |
2730 | MacRootWindowToWindow( &r.left , & r.top ) ; |
2731 | MacRootWindowToWindow( &r.right , & r.bottom ) ; | |
21f9e953 | 2732 | } |
facd6764 SC |
2733 | else |
2734 | { | |
2735 | r.right -= r.left ; | |
2736 | r.bottom -= r.top ; | |
2737 | r.left = 0 ; | |
2738 | r.top = 0 ; | |
2739 | } | |
2740 | if ( includeOuterStructures ) | |
af6b7b80 | 2741 | InsetRect( &r , -4 , -4 ) ; |
facd6764 | 2742 | RectRgn( visRgn , &r ) ; |
db7a550b | 2743 | |
21f9e953 | 2744 | if ( !IsTopLevel() ) |
94abc21f | 2745 | { |
facd6764 SC |
2746 | wxWindow* child = this ; |
2747 | wxWindow* parent = child->GetParent() ; | |
21f9e953 SC |
2748 | while( parent ) |
2749 | { | |
21f9e953 | 2750 | int x , y ; |
facd6764 | 2751 | wxSize size ; |
d3e780ec SC |
2752 | // we have to find a better clipping algorithm here, in order not to clip things |
2753 | // positioned like status and toolbar | |
2754 | if ( 1 /* parent->IsTopLevel() && child->IsKindOf( CLASSINFO( wxToolBar ) ) */ ) | |
facd6764 SC |
2755 | { |
2756 | size = parent->GetSize() ; | |
2757 | x = y = 0 ; | |
2758 | } | |
2759 | else | |
2760 | { | |
2761 | size = parent->GetClientSize() ; | |
2762 | wxPoint origin = parent->GetClientAreaOrigin() ; | |
2763 | x = origin.x ; | |
2764 | y = origin.y ; | |
2765 | } | |
21f9e953 SC |
2766 | parent->MacWindowToRootWindow( &x, &y ) ; |
2767 | MacRootWindowToWindow( &x , &y ) ; | |
2768 | ||
0fa8508d | 2769 | if ( !includeOuterStructures || ( |
7f17ac74 SC |
2770 | parent->MacClipChildren() || |
2771 | ( parent->GetParent() && parent->GetParent()->MacClipGrandChildren() ) | |
0fa8508d SC |
2772 | ) ) |
2773 | { | |
2774 | SetRectRgn( tempRgn , | |
2775 | x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , | |
2776 | x + size.x - parent->MacGetRightBorderSize(), | |
2777 | y + size.y - parent->MacGetBottomBorderSize()) ; | |
21f9e953 | 2778 | |
0fa8508d SC |
2779 | SectRgn( visRgn , tempRgn , visRgn ) ; |
2780 | } | |
21f9e953 SC |
2781 | if ( parent->IsTopLevel() ) |
2782 | break ; | |
facd6764 SC |
2783 | child = parent ; |
2784 | parent = child->GetParent() ; | |
7372fd0a | 2785 | } |
94abc21f | 2786 | } |
e40298d5 | 2787 | } |
facd6764 SC |
2788 | |
2789 | wxRegion vis = visRgn ; | |
e40298d5 JS |
2790 | DisposeRgn( visRgn ) ; |
2791 | DisposeRgn( tempRgn ) ; | |
facd6764 | 2792 | return vis ; |
94abc21f SC |
2793 | } |
2794 | ||
facd6764 SC |
2795 | /* |
2796 | This function must not change the updatergn ! | |
2797 | */ | |
8b573fb8 | 2798 | bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) |
519cb848 | 2799 | { |
76a5e5d2 | 2800 | RgnHandle updatergn = (RgnHandle) updatergnr ; |
facd6764 | 2801 | bool handled = false ; |
42ef83fa SC |
2802 | Rect updatebounds ; |
2803 | GetRegionBounds( updatergn , &updatebounds ) ; | |
eec462f8 | 2804 | // wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ; |
42ef83fa | 2805 | if ( !EmptyRgn(updatergn) ) |
6264b550 | 2806 | { |
1c310985 SC |
2807 | RgnHandle newupdate = NewRgn() ; |
2808 | wxSize point = GetClientSize() ; | |
2809 | wxPoint origin = GetClientAreaOrigin() ; | |
1c310985 | 2810 | SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ; |
facd6764 | 2811 | SectRgn( newupdate , updatergn , newupdate ) ; |
8b573fb8 | 2812 | |
eec462f8 SC |
2813 | // first send an erase event to the entire update area |
2814 | { | |
42ef83fa | 2815 | wxWindowDC dc(this); |
1a02aff9 | 2816 | dc.SetClippingRegion(wxRegion(updatergn)); |
42ef83fa SC |
2817 | wxEraseEvent eevent( GetId(), &dc ); |
2818 | eevent.SetEventObject( this ); | |
2819 | GetEventHandler()->ProcessEvent( eevent ); | |
eec462f8 | 2820 | } |
8b573fb8 | 2821 | |
42ef83fa | 2822 | // calculate a client-origin version of the update rgn and set m_updateRegion to that |
1c310985 SC |
2823 | OffsetRgn( newupdate , -origin.x , -origin.y ) ; |
2824 | m_updateRegion = newupdate ; | |
8b573fb8 | 2825 | DisposeRgn( newupdate ) ; |
6ed71b4f | 2826 | |
1c310985 | 2827 | if ( !m_updateRegion.Empty() ) |
6264b550 | 2828 | { |
facd6764 | 2829 | // paint the window itself |
e40298d5 JS |
2830 | wxPaintEvent event; |
2831 | event.m_timeStamp = time ; | |
2832 | event.SetEventObject(this); | |
8b573fb8 | 2833 | handled = GetEventHandler()->ProcessEvent(event); |
af6b7b80 SC |
2834 | |
2835 | // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards | |
2836 | if ( !handled ) | |
2837 | { | |
2838 | if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) | |
2839 | { | |
2840 | CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; | |
2841 | handled = true ; | |
2842 | } | |
2843 | } | |
2844 | ||
eec462f8 | 2845 | } |
8b573fb8 | 2846 | |
eec462f8 SC |
2847 | // now we cannot rely on having its borders drawn by a window itself, as it does not |
2848 | // get the updateRgn wide enough to always do so, so we do it from the parent | |
2849 | // this would also be the place to draw any custom backgrounds for native controls | |
2850 | // in Composited windowing | |
36d7f54e | 2851 | wxPoint clientOrigin = GetClientAreaOrigin() ; |
8b573fb8 | 2852 | |
71f2fb52 | 2853 | for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext()) |
eec462f8 SC |
2854 | { |
2855 | wxWindowMac *child = node->GetData(); | |
2856 | if (child == m_vScrollBar) continue; | |
2857 | if (child == m_hScrollBar) continue; | |
2858 | if (child->IsTopLevel()) continue; | |
2859 | if (!child->IsShown()) continue; | |
fe779e40 | 2860 | |
af6b7b80 SC |
2861 | int x,y; |
2862 | child->GetPosition( &x, &y ); | |
2863 | int w,h; | |
2864 | child->GetSize( &w, &h ); | |
2865 | Rect childRect = { y , x , y + h , x + w } ; | |
36d7f54e | 2866 | OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ; |
eec462f8 SC |
2867 | if ( child->MacGetTopBorderSize() ) |
2868 | { | |
eec462f8 SC |
2869 | if ( RectInRgn( &childRect , updatergn ) ) |
2870 | { | |
2871 | // paint custom borders | |
2872 | wxNcPaintEvent eventNc( child->GetId() ); | |
2873 | eventNc.SetEventObject( child ); | |
af6b7b80 SC |
2874 | if ( !child->GetEventHandler()->ProcessEvent( eventNc ) ) |
2875 | { | |
2876 | wxWindowDC dc(this) ; | |
2877 | dc.SetClippingRegion(wxRegion(updatergn)); | |
2878 | wxMacPortSetter helper(&dc) ; | |
36d7f54e | 2879 | child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ; |
af6b7b80 | 2880 | } |
eec462f8 | 2881 | } |
8b573fb8 | 2882 | } |
af6b7b80 SC |
2883 | if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() ) |
2884 | { | |
2885 | wxWindowDC dc(this) ; | |
2886 | dc.SetClippingRegion(wxRegion(updatergn)); | |
2887 | wxMacPortSetter helper(&dc) ; | |
7ebf5540 SC |
2888 | Rect r = childRect ; |
2889 | OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ; | |
2890 | DrawThemeFocusRect( &r , true ) ; | |
af6b7b80 | 2891 | } |
14c9cbdb | 2892 | } |
6264b550 | 2893 | } |
facd6764 SC |
2894 | return handled ; |
2895 | } | |
6ed71b4f | 2896 | |
facd6764 SC |
2897 | void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) |
2898 | { | |
2899 | RgnHandle updatergn = (RgnHandle) updatergnr ; | |
2900 | // updatergn is always already clipped to our boundaries | |
2901 | // if we are in compositing mode then it is in relative to the upper left of the control | |
2902 | // if we are in non-compositing, then it is relatvie to the uppder left of the content area | |
2903 | // of the toplevel window | |
2904 | // it is in window coordinates, not in client coordinates | |
6ed71b4f | 2905 | |
facd6764 SC |
2906 | // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates |
2907 | RgnHandle ownUpdateRgn = NewRgn() ; | |
2908 | CopyRgn( updatergn , ownUpdateRgn ) ; | |
2909 | ||
2910 | if ( MacGetTopLevelWindow()->MacUsesCompositing() == false ) | |
8b573fb8 | 2911 | { |
facd6764 | 2912 | Rect bounds; |
5ca0d812 | 2913 | m_peer->GetRectInWindowCoords( &bounds ); |
facd6764 SC |
2914 | RgnHandle controlRgn = NewRgn(); |
2915 | RectRgn( controlRgn, &bounds ); | |
2916 | //KO: This sets the ownUpdateRgn to the area of this control that is inside | |
2917 | // the window update region | |
8b573fb8 | 2918 | SectRgn( ownUpdateRgn, controlRgn, ownUpdateRgn ); |
facd6764 | 2919 | DisposeRgn( controlRgn ); |
8b573fb8 | 2920 | |
facd6764 | 2921 | //KO: convert ownUpdateRgn to local coordinates |
8b573fb8 | 2922 | OffsetRgn( ownUpdateRgn, -bounds.left, -bounds.top ); |
6264b550 | 2923 | } |
8b573fb8 | 2924 | |
facd6764 SC |
2925 | MacDoRedraw( ownUpdateRgn , time ) ; |
2926 | DisposeRgn( ownUpdateRgn ) ; | |
6ed71b4f | 2927 | |
519cb848 SC |
2928 | } |
2929 | ||
facd6764 | 2930 | WXWindow wxWindowMac::MacGetTopLevelWindowRef() const |
519cb848 | 2931 | { |
6264b550 | 2932 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 2933 | |
6264b550 RR |
2934 | while( iter ) |
2935 | { | |
1c310985 SC |
2936 | if ( iter->IsTopLevel() ) |
2937 | return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ; | |
519cb848 | 2938 | |
6264b550 | 2939 | iter = iter->GetParent() ; |
14c9cbdb | 2940 | } |
427ff662 | 2941 | wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; |
6264b550 | 2942 | return NULL ; |
519cb848 SC |
2943 | } |
2944 | ||
14c9cbdb | 2945 | void wxWindowMac::MacCreateScrollBars( long style ) |
519cb848 | 2946 | { |
427ff662 | 2947 | wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; |
14c9cbdb | 2948 | |
aa99e0cd SC |
2949 | if ( style & ( wxVSCROLL | wxHSCROLL ) ) |
2950 | { | |
2951 | bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; | |
db7a550b | 2952 | int scrlsize = MAC_SCROLLBAR_SIZE ; |
8b573fb8 VZ |
2953 | wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL ; |
2954 | if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL || GetWindowVariant() == wxWINDOW_VARIANT_MINI ) | |
2955 | { | |
2956 | scrlsize = MAC_SMALL_SCROLLBAR_SIZE ; | |
2957 | variant = wxWINDOW_VARIANT_SMALL ; | |
2958 | } | |
db7a550b SC |
2959 | |
2960 | int adjust = hasBoth ? scrlsize - 1: 0 ; | |
aa99e0cd SC |
2961 | int width, height ; |
2962 | GetClientSize( &width , &height ) ; | |
2963 | ||
db7a550b SC |
2964 | wxPoint vPoint(width-scrlsize, 0) ; |
2965 | wxSize vSize(scrlsize, height - adjust) ; | |
2966 | wxPoint hPoint(0 , height-scrlsize ) ; | |
2967 | wxSize hSize( width - adjust, scrlsize) ; | |
aa99e0cd SC |
2968 | |
2969 | ||
2970 | if ( style & wxVSCROLL ) | |
2971 | { | |
375bb200 | 2972 | m_vScrollBar = new wxScrollBar(this, wxID_ANY, vPoint, |
aa99e0cd SC |
2973 | vSize , wxVERTICAL); |
2974 | } | |
2975 | ||
2976 | if ( style & wxHSCROLL ) | |
2977 | { | |
375bb200 | 2978 | m_hScrollBar = new wxScrollBar(this, wxID_ANY, hPoint, |
aa99e0cd SC |
2979 | hSize , wxHORIZONTAL); |
2980 | } | |
2981 | } | |
aa99e0cd | 2982 | |
14c9cbdb | 2983 | |
6264b550 RR |
2984 | // because the create does not take into account the client area origin |
2985 | MacRepositionScrollBars() ; // we might have a real position shift | |
519cb848 SC |
2986 | } |
2987 | ||
e766c8a9 | 2988 | void wxWindowMac::MacRepositionScrollBars() |
519cb848 | 2989 | { |
aa99e0cd SC |
2990 | if ( !m_hScrollBar && !m_vScrollBar ) |
2991 | return ; | |
8b573fb8 | 2992 | |
6264b550 | 2993 | bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ; |
db7a550b SC |
2994 | int scrlsize = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ; |
2995 | int adjust = hasBoth ? scrlsize - 1 : 0 ; | |
14c9cbdb | 2996 | |
6264b550 | 2997 | // get real client area |
14c9cbdb | 2998 | |
facd6764 SC |
2999 | int width ; |
3000 | int height ; | |
3001 | GetSize( &width , &height ) ; | |
6264b550 RR |
3002 | |
3003 | width -= MacGetLeftBorderSize() + MacGetRightBorderSize(); | |
3004 | height -= MacGetTopBorderSize() + MacGetBottomBorderSize(); | |
14c9cbdb | 3005 | |
6264b550 RR |
3006 | wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ; |
3007 | wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ; | |
3008 | wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ; | |
3009 | wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ; | |
db7a550b | 3010 | /* |
14c9cbdb | 3011 | int x = 0 ; |
6264b550 | 3012 | int y = 0 ; |
facd6764 SC |
3013 | int w ; |
3014 | int h ; | |
3015 | GetSize( &w , &h ) ; | |
14c9cbdb | 3016 | |
6264b550 RR |
3017 | MacClientToRootWindow( &x , &y ) ; |
3018 | MacClientToRootWindow( &w , &h ) ; | |
14c9cbdb | 3019 | |
6264b550 | 3020 | wxWindowMac *iter = (wxWindowMac*)this ; |
14c9cbdb | 3021 | |
6264b550 RR |
3022 | int totW = 10000 , totH = 10000; |
3023 | while( iter ) | |
3024 | { | |
1c310985 | 3025 | if ( iter->IsTopLevel() ) |
6264b550 | 3026 | { |
facd6764 | 3027 | iter->GetSize( &totW , &totH ) ; |
6264b550 RR |
3028 | break ; |
3029 | } | |
3030 | ||
3031 | iter = iter->GetParent() ; | |
14c9cbdb RD |
3032 | } |
3033 | ||
6264b550 RR |
3034 | if ( x == 0 ) |
3035 | { | |
3036 | hPoint.x = -1 ; | |
3037 | hSize.x += 1 ; | |
3038 | } | |
3039 | if ( y == 0 ) | |
3040 | { | |
3041 | vPoint.y = -1 ; | |
3042 | vSize.y += 1 ; | |
3043 | } | |
14c9cbdb | 3044 | |
6264b550 RR |
3045 | if ( w-x >= totW ) |
3046 | { | |
3047 | hSize.x += 1 ; | |
3048 | vPoint.x += 1 ; | |
3049 | } | |
14c9cbdb | 3050 | |
6264b550 RR |
3051 | if ( h-y >= totH ) |
3052 | { | |
3053 | vSize.y += 1 ; | |
3054 | hPoint.y += 1 ; | |
3055 | } | |
db7a550b | 3056 | */ |
6264b550 RR |
3057 | if ( m_vScrollBar ) |
3058 | { | |
3059 | m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE); | |
3060 | } | |
3061 | if ( m_hScrollBar ) | |
3062 | { | |
3063 | m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE); | |
3064 | } | |
519cb848 SC |
3065 | } |
3066 | ||
e766c8a9 | 3067 | bool wxWindowMac::AcceptsFocus() const |
7c551d95 SC |
3068 | { |
3069 | return MacCanFocus() && wxWindowBase::AcceptsFocus(); | |
3070 | } | |
519cb848 | 3071 | |
14c9cbdb | 3072 | void wxWindowMac::MacSuperChangedPosition() |
519cb848 | 3073 | { |
6264b550 | 3074 | // only window-absolute structures have to be moved i.e. controls |
519cb848 | 3075 | |
71f2fb52 | 3076 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
6264b550 RR |
3077 | while ( node ) |
3078 | { | |
9bd1404d | 3079 | wxWindowMac *child = node->GetData(); |
6264b550 | 3080 | child->MacSuperChangedPosition() ; |
eb22f2a6 | 3081 | node = node->GetNext(); |
6264b550 | 3082 | } |
519cb848 | 3083 | } |
519cb848 | 3084 | |
14c9cbdb | 3085 | void wxWindowMac::MacTopLevelWindowChangedPosition() |
a3bf4a62 | 3086 | { |
6264b550 | 3087 | // only screen-absolute structures have to be moved i.e. glcanvas |
a3bf4a62 | 3088 | |
71f2fb52 | 3089 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
6264b550 RR |
3090 | while ( node ) |
3091 | { | |
9bd1404d | 3092 | wxWindowMac *child = node->GetData(); |
6264b550 | 3093 | child->MacTopLevelWindowChangedPosition() ; |
eb22f2a6 | 3094 | node = node->GetNext(); |
6264b550 | 3095 | } |
a3bf4a62 | 3096 | } |
facd6764 | 3097 | |
e766c8a9 | 3098 | long wxWindowMac::MacGetLeftBorderSize( ) const |
2f1ae414 | 3099 | { |
1c310985 | 3100 | if( IsTopLevel() ) |
6264b550 | 3101 | return 0 ; |
2f1ae414 SC |
3102 | |
3103 | if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER ) | |
3104 | { | |
ed60b502 | 3105 | SInt32 border = 3 ; |
ed60b502 | 3106 | return border ; |
2f1ae414 SC |
3107 | } |
3108 | else if ( m_windowStyle &wxDOUBLE_BORDER) | |
3109 | { | |
ed60b502 | 3110 | SInt32 border = 3 ; |
ed60b502 | 3111 | return border ; |
2f1ae414 SC |
3112 | } |
3113 | else if (m_windowStyle &wxSIMPLE_BORDER) | |
3114 | { | |
6264b550 | 3115 | return 1 ; |
2f1ae414 | 3116 | } |
6264b550 | 3117 | return 0 ; |
2f1ae414 SC |
3118 | } |
3119 | ||
e766c8a9 | 3120 | long wxWindowMac::MacGetRightBorderSize( ) const |
5b781a67 | 3121 | { |
1c310985 SC |
3122 | // they are all symmetric in mac themes |
3123 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3124 | } |
3125 | ||
e766c8a9 | 3126 | long wxWindowMac::MacGetTopBorderSize( ) const |
5b781a67 | 3127 | { |
1c310985 SC |
3128 | // they are all symmetric in mac themes |
3129 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3130 | } |
3131 | ||
e766c8a9 | 3132 | long wxWindowMac::MacGetBottomBorderSize( ) const |
5b781a67 | 3133 | { |
1c310985 SC |
3134 | // they are all symmetric in mac themes |
3135 | return MacGetLeftBorderSize() ; | |
5b781a67 SC |
3136 | } |
3137 | ||
14c9cbdb | 3138 | long wxWindowMac::MacRemoveBordersFromStyle( long style ) |
2f1ae414 | 3139 | { |
055a486b | 3140 | return style & ~wxBORDER_MASK ; |
2f1ae414 | 3141 | } |
0a67a93b | 3142 | |
e766c8a9 | 3143 | // Find the wxWindowMac at the current mouse position, returning the mouse |
3723b7b1 | 3144 | // position. |
e766c8a9 | 3145 | wxWindowMac* wxFindWindowAtPointer(wxPoint& pt) |
3723b7b1 | 3146 | { |
59a12e90 | 3147 | pt = wxGetMousePosition(); |
e766c8a9 | 3148 | wxWindowMac* found = wxFindWindowAtPoint(pt); |
59a12e90 | 3149 | return found; |
3723b7b1 JS |
3150 | } |
3151 | ||
3152 | // Get the current mouse position. | |
3153 | wxPoint wxGetMousePosition() | |
3154 | { | |
57591e0e JS |
3155 | int x, y; |
3156 | wxGetMousePosition(& x, & y); | |
3157 | return wxPoint(x, y); | |
3723b7b1 JS |
3158 | } |
3159 | ||
6ed71b4f | 3160 | void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) |
8950f7cc | 3161 | { |
8b573fb8 VZ |
3162 | if ( event.GetEventType() == wxEVT_RIGHT_DOWN ) |
3163 | { | |
3164 | // copied from wxGTK : CS | |
249aad30 | 3165 | // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN |
8950f7cc SC |
3166 | // except that: |
3167 | // | |
3168 | // (a) it's a command event and so is propagated to the parent | |
3169 | // (b) under MSW it can be generated from kbd too | |
3170 | // (c) it uses screen coords (because of (a)) | |
3171 | wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, | |
3172 | this->GetId(), | |
3173 | this->ClientToScreen(event.GetPosition())); | |
249aad30 SC |
3174 | if ( ! GetEventHandler()->ProcessEvent(evtCtx) ) |
3175 | event.Skip() ; | |
8b573fb8 | 3176 | } |
facd6764 SC |
3177 | else |
3178 | { | |
8b573fb8 | 3179 | event.Skip() ; |
facd6764 | 3180 | } |
8950f7cc SC |
3181 | } |
3182 | ||
8b573fb8 | 3183 | void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) |
facd6764 | 3184 | { |
facd6764 SC |
3185 | } |
3186 | ||
8b573fb8 | 3187 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin ) |
3083eb85 SC |
3188 | { |
3189 | int x ,y , w ,h ; | |
8b573fb8 | 3190 | |
79392158 | 3191 | window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin) ; |
3083eb85 SC |
3192 | Rect bounds = { y , x , y+h , x+w }; |
3193 | return bounds ; | |
3194 | } | |
3195 | ||
8b573fb8 | 3196 | wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) |
f1d527c1 SC |
3197 | { |
3198 | return eventNotHandledErr ; | |
3199 | } | |
3200 | ||
facd6764 | 3201 |