Example #1
0
void    FCPushConst( void ) {
//=====================

// Process PUSH_CONST F-Code.

    sym_id      sym;
    char        fmt_buff[CONVERSION_BUFFER+1];

    sym = GetPtr();
    switch( sym->cn.typ ) {
    case FT_INTEGER_1 :
    case FT_INTEGER_2 :
    case FT_INTEGER :
        XPush( IntegerConstant( &sym->cn.value, sym->cn.size ) );
        break;
    case FT_LOGICAL_1 :
    case FT_LOGICAL :
        XPush( CGInteger( sym->cn.value.logstar4, TY_UINT_1 ) );
        break;
    case FT_REAL :
        CnvS2S( &sym->cn.value.single, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_SINGLE ) );
        break;
    case FT_DOUBLE :
        CnvD2S( &sym->cn.value.dble, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_DOUBLE ) );
        break;
    case FT_TRUE_EXTENDED :
        CnvX2S( &sym->cn.value.extended, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_LONGDOUBLE ) );
        break;
    case FT_COMPLEX :
        PushCmplxConst( sym );
        break;
    case FT_DCOMPLEX :
        PushCmplxConst( sym );
        break;
    case FT_TRUE_XCOMPLEX :
        PushCmplxConst( sym );
        break;
    }
}
Example #2
0
void            PushCmplxConst( sym_id sym ) {
//============================================

// Push a complex constant.

    char        fmt_buff[80];

    if( sym->u.cn.typ == FT_COMPLEX ) {
        CnvS2S( &sym->u.cn.value.scomplex.imagpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_SINGLE ) );
        CnvS2S( &sym->u.cn.value.scomplex.realpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_SINGLE ) );
    } else if( sym->u.cn.typ == FT_DCOMPLEX ) {
        CnvD2S( &sym->u.cn.value.dcomplex.imagpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_DOUBLE ) );
        CnvD2S( &sym->u.cn.value.dcomplex.realpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_DOUBLE ) );
    } else {
        CnvX2S( &sym->u.cn.value.xcomplex.imagpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_LONGDOUBLE ) );
        CnvX2S( &sym->u.cn.value.xcomplex.realpart, fmt_buff );
        XPush( CGFloat( fmt_buff, TY_LONGDOUBLE ) );
    }
}
Example #3
0
static inline CGFloat toCGFloat(FIXED f)
{
    return f.value + f.fract / CGFloat(65536.0);
}
Example #4
0
CGSize CGLayerGetSize(CGLayerRef layer)
{
	QRect rect = layer->picture->boundingRect();
	return CGSize { CGFloat(rect.width()), CGFloat(rect.height()) };
}
bool	AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event)
{	
#if !__LP64__
	UInt32 eclass = GetEventClass(event);
	UInt32 ekind = GetEventKind(event);
	ControlRef control;
	
	switch (eclass) {
		case kEventClassControl:
		{
			switch (ekind) {
			case kEventControlClick:
				GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control);
				if (control == mCarbonPane) {
					ClearKeyboardFocus(mCarbonWindow);
					return true;
				}
			}
		}
		break;
		
		case kEventClassScrollable:
		{
			switch (ekind) {
			case kEventScrollableGetInfo:
				{
					// [1/4]
					/*	<--	kEventParamImageSize (out, typeHISize)
					 *		On exit, contains the size of the entire scrollable view.
					 */
					// by sam: fixed the line: HISize originalSize = { mBottomRight.h, mBottomRight.v };
					HISize originalSize = { CGFloat(mBottomRight.h), CGFloat(mBottomRight.v) };
					verify_noerr(SetEventParameter(event, kEventParamImageSize, typeHISize, sizeof(HISize), &originalSize));
					
					// [2/4]
					/*	<--	kEventParamViewSize (out, typeHISize)
					 *		On exit, contains the amount of the scrollable view that is
					 *		visible.
					 */
					HIViewRef parentView = HIViewGetSuperview(mCarbonPane);
					HIRect parentBounds;
					verify_noerr(HIViewGetBounds(parentView, &parentBounds));
					//HISize windowSize = {	float(windowBounds.right - windowBounds.left),
					//						float(windowBounds.bottom - windowBounds.top) };
					verify_noerr(SetEventParameter(event, kEventParamViewSize, typeHISize, sizeof(HISize), &(parentBounds.size)));
					
					// [3/4]
					/*	<--	kEventParamLineSize (out, typeHISize)
					 *		On exit, contains the amount that should be scrolled in
					 *		response to a single click on a scrollbar arrow.
					 */
					 HISize scrollIncrementSize = { 16.0f, float(20) };
					 verify_noerr(SetEventParameter(event, kEventParamLineSize, typeHISize, sizeof(HISize), &scrollIncrementSize));
					 
					// [4/4]
					/*	<-- kEventParamOrigin (out, typeHIPoint)
					 *		On exit, contains the scrollable viewÕs current origin (the
					 *		view-relative coordinate that is drawn at the top left
					 *		corner of its frame). These coordinates should always be
					 *		greater than or equal to zero. They should be less than or
					 *		equal to the viewÕs image size minus its view size.
					 */
					 verify_noerr(SetEventParameter(event, kEventParamOrigin, typeHIPoint, sizeof(HIPoint), &mCurrentScrollPoint));
				}
				return true;
				
			case kEventScrollableScrollTo:
				{
					/*
					 *  kEventClassScrollable / kEventScrollableScrollTo
					 *  
					 *  Summary:
					 *    Requests that an HIScrollViewÕs scrollable view should scroll to
					 *    a particular origin.
					 */
					
					/*	-->	kEventParamOrigin (in, typeHIPoint)
					 *		The new origin for the scrollable view. The origin
					 *		coordinates will vary from (0,0) to scrollable viewÕs image
					 *		size minus its view size.
					 */
					HIPoint pointToScrollTo;
					verify_noerr(GetEventParameter(event, kEventParamOrigin, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pointToScrollTo));
					
					float xDelta = mCurrentScrollPoint.x - pointToScrollTo.x;
					float yDelta = mCurrentScrollPoint.y - pointToScrollTo.y;
					// move visible portion the appropriate amount
					verify_noerr(HIViewScrollRect(mCarbonPane, NULL, xDelta, yDelta));
					// set new content to be drawn
					verify_noerr(HIViewSetBoundsOrigin(mCarbonPane, pointToScrollTo.x, pointToScrollTo.y));
					
					mCurrentScrollPoint = pointToScrollTo;
				}
				return true;
				
			default:
				break;
			}
		}
		break;
		
		default:
			break;
	}
#endif
	return false;
}
Example #6
0
BOOL MacWidgetPainter::DrawScrollbar(const OpRect &drawrect)
{
	HIThemeTrackDrawInfo 	drawInfo;
	ThemeTrackPressState 	pressState = 0;
	OpScrollbar 			*scroll = (OpScrollbar*)widget;
	HIShapeRef				thumbRgn;
	OpRect					opBounds = scroll->GetBounds();
		
	CGRect bounds = {{-drawrect.x, -drawrect.y}, {opBounds.width, opBounds.height}};
	
	pressState = (ThemeTrackPressState)scroll->GetHitPart();
	
	// hack to draw correctly, for some reason DrawThemeTrack needs this.
	if(pressState == kThemeTopInsideArrowPressed)
		pressState = kThemeBottomInsideArrowPressed;
	else if(pressState == kThemeBottomInsideArrowPressed)
		pressState = kThemeTopInsideArrowPressed;

	if(scroll->horizontal)
	{
		bounds.size.width++;
	}
	else
	{
		bounds.size.height++;
	}

	OpWindow *rootWindow;
	BOOL inActiveWindow = FALSE;
	if (vd->GetView())
	{
		rootWindow = vd->GetView()->GetContainer()->GetOpView()->GetRootWindow();
		inActiveWindow = rootWindow->IsActiveTopmostWindow() || rootWindow->GetStyle() == OpWindow::STYLE_POPUP;
	}

	drawInfo.version = 0;
	drawInfo.kind = kThemeMediumScrollBar;
	drawInfo.enableState = (scroll->IsEnabled() && inActiveWindow) ? kThemeTrackActive : kThemeTrackInactive;
	drawInfo.attributes = kThemeTrackShowThumb | (scroll->horizontal ? kThemeTrackHorizontal : 0);
	drawInfo.bounds = bounds;
	drawInfo.min = scroll->limit_min;
	drawInfo.max = scroll->limit_max;
	drawInfo.value = scroll->value;
	drawInfo.trackInfo.scrollbar.viewsize = scroll->limit_visible;
	drawInfo.trackInfo.scrollbar.pressState = pressState;
	
	int minSize = g_op_ui_info->GetHorizontalScrollbarHeight();
	if (GetOSVersion() >= 0x1070)
	{
		minSize = 0;
	}
	else if (GetInfo()->GetScrollbarArrowStyle() == ARROWS_AT_BOTTOM_AND_TOP)
	{
		minSize *= 6;
		minSize -= 4;
	}
	else
	{
		minSize *= 4;
	}
	
	// Bail out if smaller than minSize
	if(scroll->horizontal)
	{
		if((bounds.size.width) < minSize)
		{
			return FALSE;
		}
	}
	else
	{
		if((bounds.size.height) < minSize)
		{
			return FALSE;
		}
	}
	
	// Ok, the thumb(knob) could have been changed, let's update
	if(noErr == HIThemeGetTrackThumbShape(&drawInfo, &thumbRgn))
	{
		HIRect thumbRect;
		OpRect thumbOpRect;
		HIShapeGetBounds(thumbRgn, &thumbRect);
		CFRelease(thumbRgn);
		
		thumbOpRect.x = thumbRect.origin.x - bounds.origin.x;
		thumbOpRect.y = thumbRect.origin.y - bounds.origin.y;
		thumbOpRect.width = thumbRect.size.width;
		thumbOpRect.height = thumbRect.size.height;
		
		scroll->SetKnobRect(thumbOpRect);
	}
	
	if (OpStatus::IsError(MacCachedObjectFactory<MacWidgetBitmap, MacWidgetBitmapTraits>::Init()))
		return FALSE;

	int bmpwidth = drawrect.width;
	int bmpheight = drawrect.height;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
	const PixelScaler& scaler = vd->GetVPScale();
	bmpwidth = TO_DEVICE_PIXEL(scaler, bmpwidth);
	bmpheight = TO_DEVICE_PIXEL(scaler, bmpheight);
#endif // PIXEL_SCALE_RENDERING_SUPPORT

	MacWidgetBitmap* bitmap = MacCachedObjectFactory<MacWidgetBitmap, MacWidgetBitmapTraits>::CreateObject(MacWidgetBitmapTraits::CreateParam(bmpwidth, bmpheight));

	if (!bitmap)
		return FALSE;

	// Set clip and draw
	widget->SetClipRect(drawrect);
	OpBitmap* bmp = bitmap->GetOpBitmap();
	void* image_data = bmp->GetPointer(OpBitmap::ACCESS_WRITEONLY);
	if (!image_data)
	{
		bitmap->DecRef();
		widget->RemoveClipRect();
		return FALSE;
	}
	bitmap->Lock();
	const int bpl = bmp->GetBytesPerLine();
	memset(image_data, 0, bpl * bmp->Height());

	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
	CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal;
	// create the context at size of drawrect instead of bitmap itself.
	// we cache the bitmap to prevent create-destroy cycle and reallocation.
	// since we need the bitmap's memory only, we can create a much smaller context within that buffer.
	CGContextRef context = CGBitmapContextCreate(image_data, bmpwidth, bmpheight, 8, bpl, colorSpace, alpha);
	CGColorSpaceRelease(colorSpace);
	if (!context)
	{
		bitmap->DecRef();
		bmp->ReleasePointer(FALSE);
		widget->RemoveClipRect();
		bitmap->Unlock();
		return FALSE;
	}

	const int win_height = drawrect.height;

	CGFloat scale = 1.0f;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
	scale = CGFloat(scaler.GetScale()) / 100.0f;
#endif // PIXEL_SCALE_RENDERING_SUPPORT
	CGContextScaleCTM(context, scale, -scale);
	CGContextTranslateCTM(context, 0.0f, -win_height);
	
	HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal);

	bmp->ReleasePointer();
	vd->BitmapOut(bmp, OpRect(0, 0, bmp->Width(), bmp->Height()), drawrect);
	CGContextRelease(context);

	widget->RemoveClipRect();
	bitmap->Unlock();
	bitmap->DecRef();

	return TRUE;
}