From fdaf613add176525ed8b6cafaf278dfd80f85074 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 30 May 2001 20:46:00 +0000 Subject: [PATCH] rewrite to avoid unnecessary redraws git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/uma.h | 8 +- include/wx/mac/window.h | 1 + src/mac/bmpbuttn.cpp | 2 +- src/mac/button.cpp | 2 +- src/mac/carbon/bmpbuttn.cpp | 2 +- src/mac/carbon/button.cpp | 2 +- src/mac/carbon/checkbox.cpp | 2 +- src/mac/carbon/choice.cpp | 2 +- src/mac/carbon/combobox.cpp | 2 +- src/mac/carbon/control.cpp | 35 +------ src/mac/carbon/gauge.cpp | 2 +- src/mac/carbon/listbox.cpp | 2 +- src/mac/carbon/notebmac.cpp | 2 +- src/mac/carbon/radiobox.cpp | 2 +- src/mac/carbon/radiobut.cpp | 10 +- src/mac/carbon/scrolbar.cpp | 2 +- src/mac/carbon/slider.cpp | 2 +- src/mac/carbon/spinbutt.cpp | 2 +- src/mac/carbon/statbox.cpp | 2 +- src/mac/carbon/statlmac.cpp | 2 +- src/mac/carbon/tabctrl.cpp | 2 +- src/mac/carbon/textctrl.cpp | 2 +- src/mac/carbon/toolbar.cpp | 5 +- src/mac/carbon/uma.cpp | 194 ++++++++++-------------------------- src/mac/carbon/window.cpp | 41 ++++++-- src/mac/checkbox.cpp | 2 +- src/mac/choice.cpp | 2 +- src/mac/combobox.cpp | 2 +- src/mac/control.cpp | 35 +------ src/mac/gauge.cpp | 2 +- src/mac/listbox.cpp | 2 +- src/mac/notebmac.cpp | 2 +- src/mac/radiobox.cpp | 2 +- src/mac/radiobut.cpp | 10 +- src/mac/scrolbar.cpp | 2 +- src/mac/slider.cpp | 2 +- src/mac/spinbutt.cpp | 2 +- src/mac/statbox.cpp | 2 +- src/mac/statlmac.cpp | 2 +- src/mac/tabctrl.cpp | 2 +- src/mac/textctrl.cpp | 2 +- src/mac/toolbar.cpp | 5 +- src/mac/uma.cpp | 194 ++++++++++-------------------------- src/mac/window.cpp | 41 ++++++-- 44 files changed, 234 insertions(+), 409 deletions(-) diff --git a/include/wx/mac/uma.h b/include/wx/mac/uma.h index 0898dc057a..937ef9d0f7 100644 --- a/include/wx/mac/uma.h +++ b/include/wx/mac/uma.h @@ -28,10 +28,14 @@ #include #endif #else - #define UMA_USE_APPEARANCE 0 + #define UMA_USE_APPEARANCE 1 #define UMA_USE_WINDOWMGR 0 #endif +#if UMA_USE_APPEARANCE == 0 + #pragma error "wxMac needs appearance" +#endif + #if !UMA_USE_8_6 && UMA_USE_WINDOWMGR #undef UMA_USE_WINDOWMGR #define UMA_USE_WINDOWMGR 0 @@ -101,6 +105,8 @@ void UMACloseWindow(WindowRef inWindowRef) ; void UMADrawControl( ControlHandle inControl ) ; +void UMAEnableControl( ControlHandle inControl ) ; +void UMADisableControl( ControlHandle inControl ) ; void UMAActivateControl( ControlHandle inControl ) ; void UMADeactivateControl( ControlHandle inControl ) ; void UMAApplyThemeBackground (ThemeBackgroundKind inKind, diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index e8efb280d1..df3b0b102d 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -48,6 +48,7 @@ public: WindowRef m_macWindow ; ControlHandle m_macRootControl ; wxWindow* m_macFocus ; + bool m_macHasReceivedFirstActivate ; } MacWindowData ; diff --git a/src/mac/bmpbuttn.cpp b/src/mac/bmpbuttn.cpp index 95dfb80ad4..dbbfc52d7a 100644 --- a/src/mac/bmpbuttn.cpp +++ b/src/mac/bmpbuttn.cpp @@ -57,7 +57,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , kControlBehaviorOffsetContents + ( bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0, (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; diff --git a/src/mac/button.cpp b/src/mac/button.cpp index c67c470acf..53c0861dbe 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -35,7 +35,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlPushButtonProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index 95dfb80ad4..dbbfc52d7a 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -57,7 +57,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , kControlBehaviorOffsetContents + ( bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0, (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index c67c470acf..53c0861dbe 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -35,7 +35,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlPushButtonProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index c3d4ce9709..f3eb8eca63 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -34,7 +34,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlCheckBoxProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 9363a6cdda..e9a8357ea5 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -44,7 +44,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 , + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , -12345 , 0 , kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index d765346c5c..36e92ad7a3 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -40,7 +40,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , -12345 , 0, kControlPopupButtonProc , (long) this ) ; m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 8268b03c8b..4ffb21ccac 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -136,6 +136,7 @@ void wxControl::SetLabel(const wxString& title) #endif ::SetControlTitle( m_macControl , maclabel ) ; } + Refresh() ; } wxSize wxControl::DoGetBestSize() const @@ -270,6 +271,7 @@ void wxControl::MacPostControlCreate() m_macControlIsShown = true ; MacAdjustControlRect() ; wxAssociateControlWithMacControl( m_macControl , this ) ; + UMAShowControl( m_macControl ) ; } void wxControl::MacAdjustControlRect() @@ -358,15 +360,7 @@ void wxControl::MacSuperChangedPosition() if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; - InvalWindowRect( rootwindow , &inval ) ; - } UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; - { - Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; - InvalWindowRect( rootwindow , &inval ) ; - } } if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) { @@ -494,15 +488,7 @@ void wxControl::DoSetSize(int x, int y, if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; - InvalWindowRect( macrootwindow, &inval ) ; - } UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; - { - Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; - InvalWindowRect(macrootwindow, &inval ) ; - } } if ( actualX != former_x || actualY != former_y ) @@ -579,21 +565,10 @@ bool wxControl::Enable(bool enable) if ( m_macControl ) { - - if ( UMAHasAppearance() ) - { - if ( enable ) - ::ActivateControl( m_macControl ) ; - else - ::DeactivateControl( m_macControl ) ; - } + if ( enable ) + UMAActivateControl( m_macControl ) ; else - { - if ( enable ) - ::HiliteControl( m_macControl , 0 ) ; - else - ::HiliteControl( m_macControl , 255 ) ; - } + UMADeactivateControl( m_macControl ) ; } return TRUE ; } diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index 67d5dd9c84..fe19204a45 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -41,7 +41,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , range, kControlProgressBarProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 1ed703e186..05cc0e249a 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -67,7 +67,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , kwxMacListWithVerticalScrollbar , 0 , 0, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; long result ; diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index 88b1ef2ce5..686a969462 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -116,7 +116,7 @@ bool wxNotebook::Create(wxWindow *parent, MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index b18f098d3c..3c4c07e73e 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -111,7 +111,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, val , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 84f2a739cb..8ce7963ab1 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -32,7 +32,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlRadioButtonProc , (long) this ) ; MacPostControlCreate() ; @@ -67,9 +67,11 @@ void wxRadioButton::SetValue(bool val) { int i; wxRadioButton *cycle; - + if ( GetControlValue( m_macControl ) == val ) + return ; + ::SetControlValue( m_macControl , val ) ; - + Refresh() ; if (val) { cycle=this->NextInCycle(); @@ -95,7 +97,7 @@ void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) { - SetValue(true) ; + SetValue(true) ; wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId ); event.SetEventObject(this); event.SetInt( GetValue() ); diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index fb7a5311ca..0c1a130c78 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -41,7 +41,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 100, kControlScrollBarLiveProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index ffb6631aca..bce30a4bd1 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -133,7 +133,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, } m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , - title , true , value , minValue , maxValue, + title , false , value , minValue , maxValue, kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 4003a1a388..c2b0a7bbc2 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -49,7 +49,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/carbon/statbox.cpp b/src/mac/carbon/statbox.cpp index e0d8257d0f..c50c7d8a28 100644 --- a/src/mac/carbon/statbox.cpp +++ b/src/mac/carbon/statbox.cpp @@ -41,7 +41,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/statlmac.cpp b/src/mac/carbon/statlmac.cpp index 93644da485..f5802a2095 100644 --- a/src/mac/carbon/statlmac.cpp +++ b/src/mac/carbon/statlmac.cpp @@ -54,7 +54,7 @@ bool wxStaticLine::Create( wxWindow *parent, MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlSeparatorLineProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index 5482141268..9d840214d0 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -39,7 +39,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 9ff3b81637..9a2c72ef33 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -107,7 +107,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , false , 0 , 0 , 1, ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 8e1d455afd..df820b8cb9 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -310,7 +310,7 @@ bool wxToolBar::Realize() if ( icon ) { - m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , false , 0 , behaviour + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; ControlButtonContentInfo info ; @@ -321,9 +321,10 @@ bool wxToolBar::Realize() } else { - m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , false , 0 , behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; } + UMAShowControl( m_macToolHandle ) ; m_macToolHandles.Add( m_macToolHandle ) ; tool->m_index = m_macToolHandles.Count() -1 ; if ( !tool->IsEnabled() ) diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 4cfea08505..c96a8f93de 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -425,6 +425,7 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) void UMAShowWindow( WindowRef inWindowRef ) { ShowWindow( inWindowRef ) ; + } void UMAHideWindow( WindowRef inWindowRef ) @@ -459,20 +460,20 @@ void UMACloseWindow(WindowRef inWindowRef) void UMAActivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; #if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) - { + { + if ( !UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::ActivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } + } } else #endif @@ -484,15 +485,6 @@ void UMAActivateControl( ControlHandle inControl ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - -DisposeRgn( updateRgn ) ; - } void UMADrawControl( ControlHandle inControl ) @@ -533,111 +525,54 @@ void UMADrawControl( ControlHandle inControl ) void UMAMoveControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } ::MoveControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGAMoveControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASizeControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } ::SizeControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGASizeControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - - } void UMADeactivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + if ( UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::DeactivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } + } } - else -#endif -#if !TARGET_CARBON - { - AGADeactivateControl( inControl ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASetThemeWindowBackground (WindowRef inWindow, @@ -733,16 +668,6 @@ void UMADisposeControl (ControlHandle theControl) void UMAHiliteControl (ControlHandle inControl, ControlPartCode hiliteState) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { ::HiliteControl( inControl , hiliteState ) ; @@ -751,45 +676,23 @@ void UMAHiliteControl (ControlHandle inControl, { ::HiliteControl( inControl , hiliteState ) ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } +// shows the control and adds the region to the update region void UMAShowControl (ControlHandle inControl) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { - ::ShowControl( inControl ) ; + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; } else { - ::ShowControl( inControl ) ; + (**inControl).contrlVis = 255 ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } - +// Hides the control and adds the region to the update region void UMAHideControl (ControlHandle inControl) { if ( UMAHasAppearance() ) @@ -841,7 +744,13 @@ bool UMAIsControlVisible (ControlHandle inControl) { return IsControlVisible( inControl ) ; } + else #endif + { +#if !TARGET_CARBON + return (**inControl).contrlVis == 255 ; +#endif + } return true ; } @@ -1538,5 +1447,6 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { } #endif + return noErr ; } diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 7252027515..3a5cfcd895 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -152,6 +152,20 @@ void wxWindow::Init() // Destructor wxWindow::~wxWindow() { + // deleting a window while it is shown invalidates the region + if ( IsShown() ) { + wxWindow* iter = this ; + while( iter ) { + if ( iter->m_macWindowData ) + { + Refresh() ; + break ; + } + iter = iter->GetParent() ; + + } + } + m_isBeingDeleted = TRUE; if ( s_lastMouseWindow == this ) @@ -754,11 +768,7 @@ bool wxWindow::Show(bool show) } MacSuperShown( show ) ; Refresh() ; - /* - // this will be done by the activate event - if(m_macWindowData) - MacUpdateImmediately() ; - */ + return TRUE; } @@ -899,6 +909,9 @@ void wxWindow::MacEraseBackground( Rect *rect ) void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { +// if ( !IsShown() ) +// return ; + wxMacDrawingHelper focus( this ) ; if ( focus.Ok() ) { @@ -1143,6 +1156,7 @@ void wxWindow::MacCreateRealWindow( const wxString& title, UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; m_macWindowData->m_macFocus = NULL ; + m_macWindowData->m_macHasReceivedFirstActivate = true ; } void wxWindow::MacPaint( wxPaintEvent &event ) @@ -1694,8 +1708,12 @@ void wxWindow::MacFireMouseEvent( EventRecord *ev ) else event.SetEventType(wxEVT_LEFT_DCLICK ) ; } + lastWhen = 0 ; + } + else + { + lastWhen = ev->when ; } - lastWhen = ev->when ; lastWhere = localwhere ; } @@ -1768,15 +1786,18 @@ void wxWindow::MacMouseMoved( EventRecord *ev , short part) } void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating ) { + if ( !m_macWindowData->m_macHasReceivedFirstActivate ) + m_macWindowData->m_macHasReceivedFirstActivate = true ; + wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId); event.m_timeStamp = ev->when ; event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); + Refresh() ; UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ; - Refresh() ; - MacUpdateImmediately() ; +// MacUpdateImmediately() ; } void wxWindow::MacRedraw( RgnHandle updatergn , long time) @@ -1942,7 +1963,7 @@ void wxWindow::MacUpdateImmediately() GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ; } @@ -1973,7 +1994,7 @@ void wxWindow::MacUpdate( EventRecord *ev ) GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { MacRedraw( region , ev->when ) ; } diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index c3d4ce9709..f3eb8eca63 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -34,7 +34,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlCheckBoxProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 9363a6cdda..e9a8357ea5 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -44,7 +44,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 , + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , -12345 , 0 , kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index d765346c5c..36e92ad7a3 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -40,7 +40,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , -12345 , 0, kControlPopupButtonProc , (long) this ) ; m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 8268b03c8b..4ffb21ccac 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -136,6 +136,7 @@ void wxControl::SetLabel(const wxString& title) #endif ::SetControlTitle( m_macControl , maclabel ) ; } + Refresh() ; } wxSize wxControl::DoGetBestSize() const @@ -270,6 +271,7 @@ void wxControl::MacPostControlCreate() m_macControlIsShown = true ; MacAdjustControlRect() ; wxAssociateControlWithMacControl( m_macControl , this ) ; + UMAShowControl( m_macControl ) ; } void wxControl::MacAdjustControlRect() @@ -358,15 +360,7 @@ void wxControl::MacSuperChangedPosition() if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; - InvalWindowRect( rootwindow , &inval ) ; - } UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; - { - Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; - InvalWindowRect( rootwindow , &inval ) ; - } } if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) { @@ -494,15 +488,7 @@ void wxControl::DoSetSize(int x, int y, if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; - InvalWindowRect( macrootwindow, &inval ) ; - } UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; - { - Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; - InvalWindowRect(macrootwindow, &inval ) ; - } } if ( actualX != former_x || actualY != former_y ) @@ -579,21 +565,10 @@ bool wxControl::Enable(bool enable) if ( m_macControl ) { - - if ( UMAHasAppearance() ) - { - if ( enable ) - ::ActivateControl( m_macControl ) ; - else - ::DeactivateControl( m_macControl ) ; - } + if ( enable ) + UMAActivateControl( m_macControl ) ; else - { - if ( enable ) - ::HiliteControl( m_macControl , 0 ) ; - else - ::HiliteControl( m_macControl , 255 ) ; - } + UMADeactivateControl( m_macControl ) ; } return TRUE ; } diff --git a/src/mac/gauge.cpp b/src/mac/gauge.cpp index 67d5dd9c84..fe19204a45 100644 --- a/src/mac/gauge.cpp +++ b/src/mac/gauge.cpp @@ -41,7 +41,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , range, kControlProgressBarProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 1ed703e186..05cc0e249a 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -67,7 +67,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , kwxMacListWithVerticalScrollbar , 0 , 0, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; long result ; diff --git a/src/mac/notebmac.cpp b/src/mac/notebmac.cpp index 88b1ef2ce5..686a969462 100644 --- a/src/mac/notebmac.cpp +++ b/src/mac/notebmac.cpp @@ -116,7 +116,7 @@ bool wxNotebook::Create(wxWindow *parent, MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index b18f098d3c..3c4c07e73e 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -111,7 +111,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, MacPreControlCreate( parent , id , label , pos , size ,style, val , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index 84f2a739cb..8ce7963ab1 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -32,7 +32,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlRadioButtonProc , (long) this ) ; MacPostControlCreate() ; @@ -67,9 +67,11 @@ void wxRadioButton::SetValue(bool val) { int i; wxRadioButton *cycle; - + if ( GetControlValue( m_macControl ) == val ) + return ; + ::SetControlValue( m_macControl , val ) ; - + Refresh() ; if (val) { cycle=this->NextInCycle(); @@ -95,7 +97,7 @@ void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) { - SetValue(true) ; + SetValue(true) ; wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId ); event.SetEventObject(this); event.SetInt( GetValue() ); diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index fb7a5311ca..0c1a130c78 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -41,7 +41,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 100, kControlScrollBarLiveProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index ffb6631aca..bce30a4bd1 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -133,7 +133,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, } m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , - title , true , value , minValue , maxValue, + title , false , value , minValue , maxValue, kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index 4003a1a388..c2b0a7bbc2 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -49,7 +49,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; diff --git a/src/mac/statbox.cpp b/src/mac/statbox.cpp index e0d8257d0f..c50c7d8a28 100644 --- a/src/mac/statbox.cpp +++ b/src/mac/statbox.cpp @@ -41,7 +41,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/statlmac.cpp b/src/mac/statlmac.cpp index 93644da485..f5802a2095 100644 --- a/src/mac/statlmac.cpp +++ b/src/mac/statlmac.cpp @@ -54,7 +54,7 @@ bool wxStaticLine::Create( wxWindow *parent, MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlSeparatorLineProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/tabctrl.cpp b/src/mac/tabctrl.cpp index 5482141268..9d840214d0 100644 --- a/src/mac/tabctrl.cpp +++ b/src/mac/tabctrl.cpp @@ -39,7 +39,7 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlTabSmallProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 9ff3b81637..9a2c72ef33 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -107,7 +107,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , false , 0 , 0 , 1, ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ; MacPostControlCreate() ; diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 8e1d455afd..df820b8cb9 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -310,7 +310,7 @@ bool wxToolBar::Realize() if ( icon ) { - m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , false , 0 , behaviour + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; ControlButtonContentInfo info ; @@ -321,9 +321,10 @@ bool wxToolBar::Realize() } else { - m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , false , 0 , behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; } + UMAShowControl( m_macToolHandle ) ; m_macToolHandles.Add( m_macToolHandle ) ; tool->m_index = m_macToolHandles.Count() -1 ; if ( !tool->IsEnabled() ) diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 4cfea08505..c96a8f93de 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -425,6 +425,7 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) void UMAShowWindow( WindowRef inWindowRef ) { ShowWindow( inWindowRef ) ; + } void UMAHideWindow( WindowRef inWindowRef ) @@ -459,20 +460,20 @@ void UMACloseWindow(WindowRef inWindowRef) void UMAActivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; #if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) - { + { + if ( !UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::ActivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } + } } else #endif @@ -484,15 +485,6 @@ void UMAActivateControl( ControlHandle inControl ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - -DisposeRgn( updateRgn ) ; - } void UMADrawControl( ControlHandle inControl ) @@ -533,111 +525,54 @@ void UMADrawControl( ControlHandle inControl ) void UMAMoveControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } ::MoveControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGAMoveControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASizeControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } ::SizeControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGASizeControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - - } void UMADeactivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + if ( UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::DeactivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; + } + } } - else -#endif -#if !TARGET_CARBON - { - AGADeactivateControl( inControl ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASetThemeWindowBackground (WindowRef inWindow, @@ -733,16 +668,6 @@ void UMADisposeControl (ControlHandle theControl) void UMAHiliteControl (ControlHandle inControl, ControlPartCode hiliteState) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { ::HiliteControl( inControl , hiliteState ) ; @@ -751,45 +676,23 @@ void UMAHiliteControl (ControlHandle inControl, { ::HiliteControl( inControl , hiliteState ) ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } +// shows the control and adds the region to the update region void UMAShowControl (ControlHandle inControl) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { - ::ShowControl( inControl ) ; + SetControlVisibility( inControl , true , false ) ; + InvalWindowRect(GetControlOwner(inControl),&(**inControl).contrlRect ) ; } else { - ::ShowControl( inControl ) ; + (**inControl).contrlVis = 255 ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } - +// Hides the control and adds the region to the update region void UMAHideControl (ControlHandle inControl) { if ( UMAHasAppearance() ) @@ -841,7 +744,13 @@ bool UMAIsControlVisible (ControlHandle inControl) { return IsControlVisible( inControl ) ; } + else #endif + { +#if !TARGET_CARBON + return (**inControl).contrlVis == 255 ; +#endif + } return true ; } @@ -1538,5 +1447,6 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { } #endif + return noErr ; } diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 7252027515..3a5cfcd895 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -152,6 +152,20 @@ void wxWindow::Init() // Destructor wxWindow::~wxWindow() { + // deleting a window while it is shown invalidates the region + if ( IsShown() ) { + wxWindow* iter = this ; + while( iter ) { + if ( iter->m_macWindowData ) + { + Refresh() ; + break ; + } + iter = iter->GetParent() ; + + } + } + m_isBeingDeleted = TRUE; if ( s_lastMouseWindow == this ) @@ -754,11 +768,7 @@ bool wxWindow::Show(bool show) } MacSuperShown( show ) ; Refresh() ; - /* - // this will be done by the activate event - if(m_macWindowData) - MacUpdateImmediately() ; - */ + return TRUE; } @@ -899,6 +909,9 @@ void wxWindow::MacEraseBackground( Rect *rect ) void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { +// if ( !IsShown() ) +// return ; + wxMacDrawingHelper focus( this ) ; if ( focus.Ok() ) { @@ -1143,6 +1156,7 @@ void wxWindow::MacCreateRealWindow( const wxString& title, UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; m_macWindowData->m_macFocus = NULL ; + m_macWindowData->m_macHasReceivedFirstActivate = true ; } void wxWindow::MacPaint( wxPaintEvent &event ) @@ -1694,8 +1708,12 @@ void wxWindow::MacFireMouseEvent( EventRecord *ev ) else event.SetEventType(wxEVT_LEFT_DCLICK ) ; } + lastWhen = 0 ; + } + else + { + lastWhen = ev->when ; } - lastWhen = ev->when ; lastWhere = localwhere ; } @@ -1768,15 +1786,18 @@ void wxWindow::MacMouseMoved( EventRecord *ev , short part) } void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating ) { + if ( !m_macWindowData->m_macHasReceivedFirstActivate ) + m_macWindowData->m_macHasReceivedFirstActivate = true ; + wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId); event.m_timeStamp = ev->when ; event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); + Refresh() ; UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ; - Refresh() ; - MacUpdateImmediately() ; +// MacUpdateImmediately() ; } void wxWindow::MacRedraw( RgnHandle updatergn , long time) @@ -1942,7 +1963,7 @@ void wxWindow::MacUpdateImmediately() GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { win->MacRedraw( region , wxTheApp->sm_lastMessageTime ) ; } @@ -1973,7 +1994,7 @@ void wxWindow::MacUpdate( EventRecord *ev ) GetPortVisibleRegion( GetWindowPort( window ), region ); // if windowshade gives incompatibility , take the follwing out - if ( !EmptyRgn( region ) ) + if ( !EmptyRgn( region ) && win->m_macWindowData->m_macHasReceivedFirstActivate ) { MacRedraw( region , ev->when ) ; } -- 2.45.2