]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/control.cpp
fixed FindOrCreatePen/Brush() for the case when the object couldn't be created succes...
[wxWidgets.git] / src / mac / control.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: control.cpp
3// Purpose: wxControl class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "control.h"
14#endif
15
16#include "wx/control.h"
17#include "wx/panel.h"
18#include "wx/app.h"
19#include "wx/notebook.h"
20#include "wx/tabctrl.h"
21#include "wx/radiobox.h"
22#include "wx/spinbutt.h"
23#include "wx/scrolbar.h"
24#include "wx/button.h"
25#include "wx/dialog.h"
26#include "wx/statbox.h"
27#include "wx/sizer.h"
28#include "wx/stattext.h"
29
30#if !USE_SHARED_LIBRARY
31IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
32
33BEGIN_EVENT_TABLE(wxControl, wxWindow)
34 EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
35 EVT_CHAR( wxControl::OnKeyDown )
36 EVT_PAINT( wxControl::OnPaint )
37END_EVENT_TABLE()
38#endif
39
40#include <wx/mac/uma.h>
41
42// Item members
43
44ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
45
46pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
47pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
48{
49 if ( partCode != 0)
50 {
51 wxControl* wx = (wxControl*) GetControlReference( control ) ;
52 if ( wx )
53 {
54 wx->MacHandleControlClick( control , partCode ) ;
55 }
56 }
57}
58
59wxControl::wxControl()
60{
61 m_macControl = NULL ;
62 m_macHorizontalBorder = 0 ; // additional pixels around the real control
63 m_macVerticalBorder = 0 ;
64 m_backgroundColour = *wxWHITE;
65 m_foregroundColour = *wxBLACK;
66#if WXWIN_COMPATIBILITY
67 m_callback = 0;
68#endif // WXWIN_COMPATIBILITY
69
70 if ( wxMacLiveScrollbarActionUPP == NULL )
71 {
72#ifdef __UNIX__
73 wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
74#else
75 wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
76#endif
77 }
78}
79
80bool wxControl::Create(wxWindow *parent, wxWindowID id,
81 const wxPoint& pos,
82 const wxSize& size, long style,
83 const wxValidator& validator,
84 const wxString& name)
85{
86 m_macControl = NULL ;
87 m_macHorizontalBorder = 0 ; // additional pixels around the real control
88 m_macVerticalBorder = 0 ;
89 bool rval = wxWindow::Create(parent, id, pos, size, style, name);
90 if (rval) {
91#if wxUSE_VALIDATORS
92 SetValidator(validator);
93#endif
94 }
95 return rval;
96}
97
98wxControl::~wxControl()
99{
100 m_isBeingDeleted = TRUE;
101 // If we delete an item, we should initialize the parent panel,
102 // because it could now be invalid.
103 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
104 if ( panel )
105 {
106 if (panel->GetDefaultItem() == (wxButton*) this)
107 panel->SetDefaultItem(NULL);
108 }
109 if ( m_macControl )
110 {
111 UMADisposeControl( m_macControl ) ;
112 m_macControl = NULL ;
113 }
114}
115
116void wxControl::SetLabel(const wxString& title)
117{
118 m_label = title ;
119
120 if ( m_macControl )
121 {
122 Str255 maclabel ;
123 wxString label ;
124
125 if( wxApp::s_macDefaultEncodingIsPC )
126 label = wxMacMakeMacStringFromPC( title ) ;
127 else
128 label = title ;
129
130#if TARGET_CARBON
131 c2pstrcpy( (StringPtr) maclabel , label ) ;
132#else
133 strcpy( (char *) maclabel , label ) ;
134 c2pstr( (char *) maclabel ) ;
135#endif
136 ::SetControlTitle( m_macControl , maclabel ) ;
137 }
138}
139
140wxSize wxControl::DoGetBestSize() const
141{
142 return wxSize(20, 20);
143}
144
145bool wxControl::ProcessCommand (wxCommandEvent & event)
146{
147 // Tries:
148 // 1) A callback function (to become obsolete)
149 // 2) OnCommand, starting at this window and working up parent hierarchy
150 // 3) OnCommand then calls ProcessEvent to search the event tables.
151#if WXWIN_COMPATIBILITY
152 if ( m_callback )
153 {
154 (void)(*m_callback)(this, event);
155
156 return TRUE;
157 }
158 else
159#endif // WXWIN_COMPATIBILITY
160 {
161 return GetEventHandler()->ProcessEvent(event);
162 }
163}
164
165// ------------------------
166wxList *wxWinMacControlList = NULL;
167wxControl *wxFindControlFromMacControl(ControlHandle inControl )
168{
169 wxNode *node = wxWinMacControlList->Find((long)inControl);
170 if (!node)
171 return NULL;
172 return (wxControl *)node->Data();
173}
174
175void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control)
176{
177 // adding NULL WindowRef is (first) surely a result of an error and
178 // (secondly) breaks menu command processing
179 wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" );
180
181 if ( !wxWinMacControlList->Find((long)inControl) )
182 wxWinMacControlList->Append((long)inControl, control);
183}
184
185void wxRemoveMacControlAssociation(wxControl *control)
186{
187 wxWinMacControlList->DeleteObject(control);
188}
189
190void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
191 const wxPoint& pos,
192 const wxSize& size, long style,
193 const wxValidator& validator,
194 const wxString& name , Rect *outBounds , StringPtr maclabel )
195{
196 m_label = label ;
197 SetName(name);
198 if ( &validator )
199 SetValidator(validator);
200
201 m_windowStyle = style;
202 parent->AddChild((wxButton *)this);
203
204 m_backgroundColour = parent->GetBackgroundColour() ;
205 m_foregroundColour = parent->GetForegroundColour() ;
206
207 if (id == -1)
208 m_windowId = NewControlId();
209 else
210 m_windowId = id;
211
212 m_width = size.x ;
213 m_height = size.y ;
214 int x = pos.x ;
215 int y = pos.y ;
216 AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
217 m_x = x ;
218 m_y = y ;
219
220
221 parent->MacClientToRootWindow( &x , &y ) ;
222 outBounds->top = y + m_macVerticalBorder ;
223 outBounds->left = x + m_macHorizontalBorder ;
224 outBounds->bottom = outBounds->top + m_height - 2 * m_macVerticalBorder;
225 outBounds->right = outBounds->left + m_width - 2 * m_macHorizontalBorder ;
226
227 char c_text[255];
228 strcpy( c_text , label ) ;
229 if( wxApp::s_macDefaultEncodingIsPC )
230 {
231 wxMacConvertFromPCForControls( c_text ) ;
232 }
233
234#if TARGET_CARBON
235 c2pstrcpy( (StringPtr) maclabel , c_text ) ;
236#else
237 strcpy( (char *) maclabel , c_text ) ;
238 c2pstr( (char *) maclabel ) ;
239#endif
240}
241
242void wxControl::MacPostControlCreate()
243{
244 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
245
246 if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
247 {
248 // no font
249 }
250 else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) )
251 {
252 ControlFontStyleRec controlstyle ;
253 controlstyle.flags = kControlUseFontMask ;
254 controlstyle.font = kControlFontSmallBoldSystemFont ;
255
256 ::UMASetControlFontStyle( m_macControl , &controlstyle ) ;
257 }
258 else
259 {
260 ControlFontStyleRec controlstyle ;
261 controlstyle.flags = kControlUseFontMask ;
262 controlstyle.font = kControlFontSmallSystemFont ;
263
264 ::UMASetControlFontStyle( m_macControl , &controlstyle ) ;
265 }
266 ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
267 wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
268 ::UMAEmbedControl( m_macControl , container ) ;
269 m_macControlIsShown = true ;
270 MacAdjustControlRect() ;
271 wxAssociateControlWithMacControl( m_macControl , this ) ;
272}
273
274void wxControl::MacAdjustControlRect()
275{
276 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
277 if ( m_width == -1 || m_height == -1 )
278 {
279 Rect bestsize = { 0 , 0 , 0 , 0 } ;
280 short baselineoffset ;
281
282 UMAGetBestControlRect( m_macControl , &bestsize , &baselineoffset ) ;
283
284 if ( EmptyRect( &bestsize ) )
285 {
286 baselineoffset = 0;
287 bestsize.left = bestsize.top = 0 ;
288 bestsize.right = 16 ;
289 bestsize.bottom = 16 ;
290 if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
291 {
292 bestsize.bottom = 16 ;
293 }
294 else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
295 {
296 bestsize.bottom = 24 ;
297 }
298 }
299
300 if ( m_width == -1 )
301 {
302 if ( IsKindOf( CLASSINFO( wxButton ) ) )
303 {
304 m_width = m_label.Length() * 8 + 12 ;
305 }
306 else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
307 {
308 m_width = m_label.Length() * 8 ;
309 }
310 else
311 m_width = bestsize.right - bestsize.left ;
312
313 m_width += 2 * m_macHorizontalBorder ;
314 }
315 if ( m_height == -1 )
316 {
317 m_height = bestsize.bottom - bestsize.top ;
318 if ( m_height < 10 )
319 m_height = 13 ;
320
321 m_height += 2 * m_macVerticalBorder;
322 }
323
324 wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ;
325 if ( helper.Ok() )
326 {
327 UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
328 }
329 }
330}
331ControlHandle wxControl::MacGetContainerForEmbedding()
332{
333 if ( m_macControl )
334 return m_macControl ;
335
336 return wxWindow::MacGetContainerForEmbedding() ;
337}
338
339void wxControl::MacSuperChangedPosition()
340{
341 if ( m_macControl )
342 {
343 Rect contrlRect ;
344 GetControlBounds( m_macControl , &contrlRect ) ;
345 int former_mac_x = contrlRect.left ;
346 int former_mac_y = contrlRect.top ;
347 int mac_x = m_x ;
348 int mac_y = m_y ;
349 GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
350
351 WindowRef rootwindow = GetMacRootWindow() ;
352 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
353 UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
354 wxMacDrawingHelper focus( wxrootwindow ) ;
355
356 if ( mac_x != former_mac_x || mac_y != former_mac_y )
357 {
358 {
359 Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
360 InvalWindowRect( rootwindow , &inval ) ;
361 }
362 UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
363 {
364 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
365 InvalWindowRect( rootwindow , &inval ) ;
366 }
367 }
368 if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
369 {
370 }
371 else
372 {
373 UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
374 }
375 }
376
377 wxWindow::MacSuperChangedPosition() ;
378}
379
380void wxControl::MacSuperEnabled( bool enabled )
381{
382/*
383 if ( m_macControl )
384 {
385 if ( UMAHasAppearance() )
386 {
387 if ( !enabled )
388 {
389 ::DeactivateControl( m_macControl ) ;
390 }
391 else
392 {
393 if ( m_macEnabled )
394 ::ActivateControl( m_macControl ) ;
395 }
396 }
397 else
398 {
399 if ( !enabled )
400 {
401 ::HiliteControl( m_macControl , 255 ) ;
402 }
403 else
404 {
405 if ( m_macEnabled )
406 ::HiliteControl( m_macControl , 0 ) ;
407 }
408 }
409 }
410 wxWindow::MacSuperEnabled( enabled ) ;
411*/
412}
413
414void wxControl::MacSuperShown( bool show )
415{
416 if ( m_macControl )
417 {
418 if ( !show )
419 {
420 if ( m_macControlIsShown )
421 {
422 ::UMAHideControl( m_macControl ) ;
423 m_macControlIsShown = false ;
424 }
425 }
426 else
427 {
428 if ( MacIsReallyShown() && !m_macControlIsShown )
429 {
430 ::UMAShowControl( m_macControl ) ;
431 m_macControlIsShown = true ;
432 }
433 }
434 }
435
436 wxWindow::MacSuperShown( show ) ;
437}
438
439void wxControl::DoSetSize(int x, int y,
440 int width, int height,
441 int sizeFlags )
442{
443 if ( m_macControl == NULL )
444 {
445 wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
446 return ;
447 }
448
449 WindowRef rootwindow = GetMacRootWindow() ;
450 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
451 UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ;
452
453 int former_x = m_x ;
454 int former_y = m_y ;
455 int former_w = m_width ;
456 int former_h = m_height ;
457
458 Rect contrlRect ;
459 GetControlBounds( m_macControl , &contrlRect ) ;
460 int former_mac_x = contrlRect.left ;
461 int former_mac_y = contrlRect.top ;
462
463 int currentX, currentY;
464 GetPosition(&currentX, &currentY);
465 int currentW,currentH;
466 GetSize(&currentW, &currentH);
467
468 int actualWidth = width;
469 int actualHeight = height;
470 int actualX = x;
471 int actualY = y;
472 if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
473 actualX = currentX;
474 if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
475 actualY = currentY;
476 if (width == -1)
477 actualWidth = currentW ;
478 if (height == -1)
479 actualHeight = currentH ;
480
481 if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH)
482 return ;
483
484 AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
485 WindowRef macrootwindow = GetMacRootWindow() ;
486 wxMacDrawingHelper focus( wxFindWinFromMacWindow( macrootwindow ) ) ;
487
488 int mac_x = actualX ;
489 int mac_y = actualY ;
490 GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ;
491
492 if ( mac_x != former_mac_x || mac_y != former_mac_y )
493 {
494 {
495 Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
496 InvalWindowRect( macrootwindow, &inval ) ;
497 }
498 UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
499 {
500 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
501 InvalWindowRect(macrootwindow, &inval ) ;
502 }
503 }
504
505 if ( actualX != former_x || actualY != former_y )
506 {
507 m_x = actualX ;
508 m_y = actualY ;
509
510 MacRepositionScrollBars() ;
511 // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..)
512 wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
513 event.SetEventObject(this);
514 GetEventHandler()->ProcessEvent(event);
515 }
516 if ( actualWidth != former_w || actualHeight != former_h )
517 {
518 {
519 Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ;
520 InvalWindowRect( macrootwindow, &inval ) ;
521 }
522 m_width = actualWidth ;
523 m_height = actualHeight ;
524
525 UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
526 {
527 Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
528 InvalWindowRect( macrootwindow , &inval ) ;
529 }
530
531 MacRepositionScrollBars() ;
532 wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
533 event.SetEventObject(this);
534 GetEventHandler()->ProcessEvent(event);
535 }
536 if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
537 {
538 }
539 else
540 {
541 UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ;
542 }
543}
544
545bool wxControl::Show(bool show)
546{
547 if ( !wxWindow::Show( show ) )
548 return FALSE ;
549
550 if ( m_macControl )
551 {
552 if ( !show )
553 {
554 if ( m_macControlIsShown )
555 {
556 ::UMAHideControl( m_macControl ) ;
557 m_macControlIsShown = false ;
558 }
559 }
560 else
561 {
562 if ( MacIsReallyShown() && !m_macControlIsShown )
563 {
564 ::UMAShowControl( m_macControl ) ;
565 m_macControlIsShown = true ;
566 }
567 }
568 }
569 return TRUE ;
570}
571
572bool wxControl::Enable(bool enable)
573{
574 if ( !wxWindow::Enable(enable) )
575 return FALSE;
576
577 if ( m_macControl )
578 {
579
580 if ( UMAHasAppearance() )
581 {
582 if ( enable )
583 ::ActivateControl( m_macControl ) ;
584 else
585 ::DeactivateControl( m_macControl ) ;
586 }
587 else
588 {
589 if ( enable )
590 ::HiliteControl( m_macControl , 0 ) ;
591 else
592 ::HiliteControl( m_macControl , 255 ) ;
593 }
594 }
595 return TRUE ;
596}
597
598void wxControl::Refresh(bool eraseBack, const wxRect *rect)
599{
600 if ( m_macControl )
601 {
602 wxWindow::Refresh( eraseBack , rect ) ;
603 }
604 else
605 {
606 wxWindow::Refresh( eraseBack , rect ) ;
607 }
608}
609
610void wxControl::MacRedrawControl()
611{
612 if ( m_macControl )
613 {
614 WindowRef window = GetMacRootWindow() ;
615 if ( window )
616 {
617 wxWindow* win = wxFindWinFromMacWindow( window ) ;
618 if ( win )
619 {
620 wxMacDrawingHelper help( win ) ;
621 // the mac control manager always assumes to have the origin at 0,0
622 SetOrigin( 0 , 0 ) ;
623
624 bool hasTabBehind = false ;
625 wxWindow* parent = GetParent() ;
626 while ( parent )
627 {
628 if( parent->MacGetWindowData() )
629 {
630 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
631 break ;
632 }
633
634 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
635 {
636 if ( ((wxControl*)parent)->m_macControl )
637 SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
638 break ;
639 }
640
641 parent = parent->GetParent() ;
642 }
643
644 UMADrawControl( m_macControl ) ;
645 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
646 wxDC::MacInvalidateSetup() ;
647 }
648 }
649 }
650}
651
652void wxControl::OnPaint(wxPaintEvent& event)
653{
654 if ( m_macControl )
655 {
656 WindowRef window = GetMacRootWindow() ;
657 if ( window )
658 {
659 wxWindow* win = wxFindWinFromMacWindow( window ) ;
660 if ( win )
661 {
662 wxMacDrawingHelper help( win ) ;
663 // the mac control manager always assumes to have the origin at 0,0
664 SetOrigin( 0 , 0 ) ;
665
666 bool hasTabBehind = false ;
667 wxWindow* parent = GetParent() ;
668 while ( parent )
669 {
670 if( parent->MacGetWindowData() )
671 {
672 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
673 break ;
674 }
675
676 if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
677 {
678 if ( ((wxControl*)parent)->m_macControl )
679 SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ;
680 break ;
681 }
682
683 parent = parent->GetParent() ;
684 }
685
686 UMADrawControl( m_macControl ) ;
687 UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
688 wxDC::MacInvalidateSetup() ;
689 }
690 }
691 }
692 else
693 {
694 // wxWindow::OnPaint( event ) ;
695 }
696}
697void wxControl::OnEraseBackground(wxEraseEvent& event)
698{
699 // In general, you don't want to erase the background of a control,
700 // or you'll get a flicker.
701 // TODO: move this 'null' function into each control that
702 // might flicker.
703}
704
705
706void wxControl::OnKeyDown( wxKeyEvent &event )
707{
708 if ( m_macControl == NULL )
709 return ;
710
711 EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
712 short keycode ;
713 short keychar ;
714 keychar = short(ev->message & charCodeMask);
715 keycode = short(ev->message & keyCodeMask) >> 8 ;
716
717 UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
718}
719
720void wxControl::OnMouseEvent( wxMouseEvent &event )
721{
722 if ( m_macControl == NULL )
723 {
724 event.Skip() ;
725 return ;
726 }
727
728 if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
729 {
730
731 int x = event.m_x ;
732 int y = event.m_y ;
733
734 MacClientToRootWindow( &x , &y ) ;
735
736 ControlHandle control ;
737 Point localwhere ;
738 GrafPtr port ;
739 SInt16 controlpart ;
740 WindowRef window = GetMacRootWindow() ;
741
742 localwhere.h = x ;
743 localwhere.v = y ;
744
745 short modifiers = 0;
746
747 if ( !event.m_leftDown && !event.m_rightDown )
748 modifiers |= btnState ;
749
750 if ( event.m_shiftDown )
751 modifiers |= shiftKey ;
752
753 if ( event.m_controlDown )
754 modifiers |= controlKey ;
755
756 if ( event.m_altDown )
757 modifiers |= optionKey ;
758
759 if ( event.m_metaDown )
760 modifiers |= cmdKey ;
761
762 controlpart = FindControl( localwhere , window , &control ) ;
763 {
764 /*
765 if ( AcceptsFocus() && FindFocus() != this )
766 {
767 SetFocus() ;
768 }
769 */
770 if ( control && UMAIsControlActive( control ) )
771 {
772 {
773 if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() )
774 controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ;
775 else
776 controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
777 wxTheApp->s_lastMouseDown = 0 ;
778 if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) )
779 && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice
780 {
781 MacHandleControlClick( control , controlpart ) ;
782 }
783 }
784 }
785 }
786 }
787}
788
789bool wxControl::MacCanFocus() const
790{
791 { if ( m_macControl == NULL )
792 return true ;
793 else
794 return false ;
795 }
796}
797
798void wxControl::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
799{
800 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
801}
802