--- salnativewidgets.cxx 2006-09-10 01:56:25.000000000 +0200 +++ salnativewidgets_new.cxx 2006-09-10 02:00:58.000000000 +0200 @@ -41,6 +41,8 @@ #include #endif +#include + using ::rtl::OUString; BOOL AquaSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) @@ -50,12 +52,12 @@ // Enable/disable experimental native controls code? // // To enable, set the environment variable AQUA_NATIVE_CONTROLS to TRUE - +/* static const char *pExperimental = getenv ("AQUA_NATIVE_CONTROLS"); if ( !pExperimental || strcasecmp(pExperimental, "TRUE") ) return FALSE; - +*/ // End of experimental code enable/disable part switch( nType ) @@ -67,12 +69,10 @@ return TRUE; break; case CTRL_SCROLLBAR: -/* - if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT ) - return FALSE; // no background painting needed - if( nPart == PART_ENTIRE_CONTROL ) - hTheme = getThemeHandle( mhWnd, L"Scrollbar"); -*/ + + if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT || nPart == PART_ENTIRE_CONTROL ) + return TRUE; +// hTheme = getThemeHandle( mhWnd, L"Scrollbar"); break; case CTRL_COMBOBOX: /* @@ -93,6 +93,7 @@ nPart == PART_BUTTON_LEFT|| nPart == PART_BUTTON_RIGHT ) hTheme = getThemeHandle( mhWnd, L"Spin"); */ + break; case CTRL_SPINBUTTONS: if( nPart == PART_ENTIRE_CONTROL || nPart == PART_ALL_BUTTONS ) @@ -202,7 +203,6 @@ if( (nState & CTRL_STATE_PRESSED) != 0 ) return kThemeStatePressed; - if( (nState & CTRL_STATE_ROLLOVER) != 0 ) return kThemeStateRollover; @@ -223,34 +223,34 @@ ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, const rtl::OUString& aCaption ) { - SetPortWindowPort (mrWindow); BOOL bOk = FALSE; - + BOOL isHoriz; + Rectangle buttonRect = rControlRegion.GetBoundRect(); - Rect rc; - rc.left = buttonRect.Left(); - rc.right = buttonRect.Right()+1; - rc.top = buttonRect.Top(); - rc.bottom = buttonRect.Bottom()+1; - switch( nType ) + HIRect hirc; + hirc.origin.x = buttonRect.Left(); + hirc.origin.y = buttonRect.Top(); + hirc.size.width = buttonRect.Right()+1 - buttonRect.Left(); + hirc.size.height = buttonRect.Bottom()+1 - buttonRect.Top(); + + switch( nType ) { case CTRL_PUSHBUTTON: case CTRL_RADIOBUTTON: case CTRL_CHECKBOX: { - ThemeButtonKind aKind; + HIThemeButtonDrawInfo aInfo; switch( nType ) { - case CTRL_RADIOBUTTON: aKind = kThemeRadioButton; break; - case CTRL_CHECKBOX: aKind = kThemeCheckBox; break; + case CTRL_RADIOBUTTON: aInfo.kind = kThemeRadioButton; break; + case CTRL_CHECKBOX: aInfo.kind = kThemeCheckBox; break; case CTRL_PUSHBUTTON: - default: aKind = kThemePushButton; break; + default: aInfo.kind = kThemePushButton; break; } - ThemeButtonDrawInfo aInfo; aInfo.state = getState( nState ); switch( aValue.getTristateVal() ) { @@ -263,12 +263,66 @@ aInfo.adornment = ((nState & CTRL_STATE_DEFAULT) != 0) ? kThemeAdornmentDefault : kThemeAdornmentNone; if( (nState & CTRL_STATE_FOCUSED) != 0 ) aInfo.adornment |= kThemeAdornmentFocus; - - return noErr == DrawThemeButton ( &rc, aKind, &aInfo, 0, 0, 0, 0 ); + if (BeginGraphics() ) + { + HIThemeDrawButton ( &hirc, &aInfo, mrContext, kHIThemeOrientationNormal, NULL ); + EndGraphics(); + return true; + } + else + { + return false; + } } case CTRL_SCROLLBAR: + + // default is vertical scrollbar + if ( nPart == PART_DRAW_BACKGROUND_VERT) + { + isHoriz = false; + } + else + isHoriz = true; + + // structure to define Track infos + HIScrollBarTrackInfo aScrollInfo; + aScrollInfo.version = 0; + aScrollInfo.enableState = getState( nState ); + + fprintf( stderr, " Valeur de nState : %f\n", nState); + + // this cast is mandatory + aScrollInfo.viewsize = hirc.size.height; + + // structure to define the used Theme (system theme by defaut) + HIThemeTrackDrawInfo aTrackTheme; + + // this parameter is mandatory, else nothing is drawn + aTrackTheme.kind = kThemeScrollBarThumbNormal; //other tested and working possibilities : kThemeMediumScrollBar, kThemeScrollBarThumbProportional + + // this parameter is mandatory, else nothing is drawn + aTrackTheme.bounds = hirc; + + // the minimum is on bottom, where y is max, respecting Quartz origin + aTrackTheme.min = static_cast(hirc.origin.y); + + // the maximum is on top, where y is minimal,in Quartz coordinates + aTrackTheme.max = static_cast( hirc.origin.x) ; + + if ( BeginGraphics() ) + { + // No change on Oy axis + HIThemeDrawTrack(&aTrackTheme, NULL, mrContext,isHoriz); // kHIThemeOrientationInverted instead ?// + + EndGraphics(); + + return true; + } + else + return false; + // hTheme = getThemeHandle( mhWnd, L"Scrollbar"); - break; + break; case CTRL_COMBOBOX: /* if( nPart == PART_ENTIRE_CONTROL ) @@ -292,7 +346,8 @@ aInfo.state = getState( pValue->mnUpperState ); aInfo.adornment = ((nState & CTRL_STATE_FOCUSED) != 0) ? kThemeAdornmentFocus : kThemeAdornmentNone; aInfo.value = kThemeButtonOn; - return noErr == DrawThemeButton ( &rc, kThemeIncDecButton, &aInfo, 0, 0, 0, 0 ); + // return noErr == DrawThemeButton ( &rc, kThemeIncDecButton, &aInfo, 0, 0, 0, 0 ); + break; case CTRL_EDITBOX: case CTRL_MULTILINE_EDITBOX: // hTheme = getThemeHandle( mhWnd, L"Edit"); @@ -391,52 +446,5 @@ Region &rNativeBoundingRegion, Region &rNativeContentRegion ) { - /* - BOOL bRet = FALSE; - - HDC hDC = GetDC( mhWnd ); - if( nType == CTRL_TOOLBAR ) - { - if( nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT ) - { - / * - // the vertical gripper is not supported in most themes and it makes no - // sense to only support horizontal gripper - - HTHEME hTheme = getThemeHandle( mhWnd, L"Rebar"); - if( hTheme ) - { - Rectangle aRect( ImplGetThemeRect( hTheme, hDC, nPart == PART_THUMB_HORZ ? RP_GRIPPERVERT : RP_GRIPPER, - 0, rControlRegion.GetBoundRect() ) ); - if( nPart == PART_THUMB_HORZ && !aRect.IsEmpty() ) - { - Rectangle aVertRect( 0, 0, aRect.getHeight(), aRect.getWidth() ); - rNativeContentRegion = aVertRect; - } - else - rNativeContentRegion = aRect; - rNativeBoundingRegion = rNativeContentRegion; - if( !rNativeContentRegion.IsEmpty() ) - bRet = TRUE; - } - * / - } - if( nPart == PART_BUTTON ) - { - HTHEME hTheme = getThemeHandle( mhWnd, L"Toolbar"); - if( hTheme ) - { - Rectangle aRect( ImplGetThemeRect( hTheme, hDC, TP_SPLITBUTTONDROPDOWN, - TS_HOT, rControlRegion.GetBoundRect() ) ); - rNativeContentRegion = aRect; - rNativeBoundingRegion = rNativeContentRegion; - if( !rNativeContentRegion.IsEmpty() ) - bRet = TRUE; - } - } - } - ReleaseDC( mhWnd, hDC ); - return( bRet ); - */ return FALSE; }