- SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
-
- // Adjust the controls size and position
- wxPoint pos(m_x, m_y);
- wxSize best_size( DoGetBestSize() );
- wxSize new_size( m_width, m_height );
-
- m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
-
- if (new_size.x == -1) {
- new_size.x = best_size.x;
- }
- if (new_size.y == -1) {
- new_size.y = best_size.y;
- }
-
- SetSize(pos.x, pos.y, new_size.x, new_size.y);
-
- UMAShowControl( (ControlHandle) m_macControl ) ;
-
- SetCursor( *wxSTANDARD_CURSOR ) ;
-
- Refresh() ;
-}
-
-void wxControl::MacAdjustControlRect()
-{
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
- if ( m_width == -1 || m_height == -1 )
- {
- Rect bestsize = { 0 , 0 , 0 , 0 } ;
- short baselineoffset ;
-
- ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
-
- if ( EmptyRect( &bestsize ) )
- {
- baselineoffset = 0;
- bestsize.left = bestsize.top = 0 ;
- bestsize.right = 16 ;
- bestsize.bottom = 16 ;
- if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
- {
- bestsize.bottom = 16 ;
- }
- else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
- {
- bestsize.bottom = 24 ;
- }
- }
-
- if ( m_width == -1 )
- {
- if ( IsKindOf( CLASSINFO( wxButton ) ) )
- {
- m_width = m_label.Length() * 8 + 12 ;
- if ( m_width < 70 )
- m_width = 70 ;
- }
- else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
- {
- m_width = m_label.Length() * 8 ;
- }
- else
- m_width = bestsize.right - bestsize.left ;
-
- m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
- }
- if ( m_height == -1 )
- {
- m_height = bestsize.bottom - bestsize.top ;
- if ( m_height < 10 )
- m_height = 13 ;
-
- m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
- }
- MacUpdateDimensions() ;
-// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ;
- }
-}
-
-WXWidget wxControl::MacGetContainerForEmbedding()
-{
- if ( m_macControl )
- return m_macControl ;
-
- return wxWindow::MacGetContainerForEmbedding() ;
-}
-
-void wxControl::MacUpdateDimensions()
-{
- // actually in the current systems this should never be possible, but later reparenting
- // may become a reality
-
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
- if ( GetParent() == NULL )
- return ;
-
- WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
- if ( rootwindow == NULL )
- return ;
-
- Rect oldBounds ;
- GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
-
- int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
- int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
- int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
- int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
-
- GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
- bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
- bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
- if ( doMove || doResize )
- {
- InvalWindowRect( rootwindow, &oldBounds ) ;
- if ( doMove )
- {
- UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
- }
- if ( doResize )
- {
- UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
- }
- }
-}
-
-void wxControl::MacSuperChangedPosition()
-{
- MacUpdateDimensions() ;
- wxWindow::MacSuperChangedPosition() ;
-}
-
-void wxControl::MacSuperEnabled( bool enabled )
-{
- Refresh(FALSE) ;
- wxWindow::MacSuperEnabled( enabled ) ;
-}
-
-void wxControl::MacSuperShown( bool show )
-{
- if ( (ControlHandle) m_macControl )
- {
- if ( !show )
- {
- if ( m_macControlIsShown )
- {
- ::UMAHideControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = false ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macControlIsShown )
- {
- ::UMAShowControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = true ;
- }
- }
- }
-
- wxWindow::MacSuperShown( show ) ;
-}
-
-void wxControl::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags )
-{
- wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
- return ;
-/*
-
- if ( (ControlHandle) m_macControl == NULL )
- {
- wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
- return ;
- }
-
- Rect oldbounds;
- int new_x, new_y, new_width, new_height;
- int mac_x, mac_y;
-
- new_x = m_x;
- new_y = m_y;
- new_width = m_width;
- new_height = m_height;
-
- if (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)
- {
- new_x = x;
- new_y = y;
- new_width = width;
- new_height = height;
- }
- else
- {
- if (x != -1) new_x = x;
- if (y != -1) new_y = y;
- if (width != -1) new_width = width;
- if (height != -1) new_height = height;
- }
-
- if(sizeFlags & wxSIZE_AUTO)
- {
- wxSize size = GetBestSize();
- if (sizeFlags & wxSIZE_AUTO_WIDTH)
- {
- if (width == -1) new_width = size.x;
- }
- if (sizeFlags & wxSIZE_AUTO_HEIGHT)
- {
- if (height == -1) new_height = size.y;
- }
- }
- AdjustForParentClientOrigin(new_x, new_y, sizeFlags);
-
- mac_x = new_x;
- mac_y = new_y;
- if(GetParent()) {
- GetParent()->MacWindowToRootWindow(&mac_x, &mac_y);
- }
- GetControlBounds( (ControlHandle) m_macControl, &oldbounds);
- oldbounds.right = oldbounds.left + m_width;
- oldbounds.bottom = oldbounds.top + m_height;
-
- bool doMove = false;
- bool doResize = false;
-
- if ( mac_x != (oldbounds.left - m_macHorizontalBorder) ||
- mac_y != (oldbounds.top - m_macVerticalBorder) )
- {
- doMove = true ;
- }
- if ( new_width != oldbounds.right - oldbounds.left - 2 * m_macHorizontalBorder ||
- new_height != oldbounds.bottom - oldbounds.top - 2 * m_macVerticalBorder)
- {
- doResize = true ;
- }
-
- if ( doMove || doResize )
- {
- Refresh() ;
-
- // Ensure resize is within constraints
- if ((m_minWidth != -1) && (new_width < m_minWidth)) {
- new_width = m_minWidth;
- }
- if ((m_minHeight != -1) && (new_height < m_minHeight)) {
- new_height = m_minHeight;
- }
- if ((m_maxWidth != -1) && (new_width > m_maxWidth)) {
- new_width = m_maxWidth;
- }
- if ((m_maxHeight != -1) && (new_height > m_maxHeight)) {
- new_height = m_maxHeight;
- }
-
- if ( doMove )
- {
- m_x = new_x;
- m_y = new_y;
-
- UMAMoveControl( (ControlHandle) m_macControl,
- mac_x + m_macHorizontalBorder, mac_y + m_macVerticalBorder);
-
- wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event) ;
- }
- if ( doResize )
- {
- m_width = new_width;
- m_height = new_height;
-
- UMASizeControl( (ControlHandle) m_macControl,
- m_width - 2 * m_macHorizontalBorder,
- m_height - 2 * m_macVerticalBorder ) ;
-
-
- wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
-
- Refresh() ;
- }
-*/
-}
-
-bool wxControl::Show(bool show)
-{
- if ( !wxWindow::Show( show ) )
- return FALSE ;
-
- if ( (ControlHandle) m_macControl )
- {
- if ( !show )
- {
- if ( m_macControlIsShown )
- {
- ::UMAHideControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = false ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macControlIsShown )
- {
- ::UMAShowControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = true ;
- }
- }
- }
- return TRUE ;
-}