コード例 #1
0
ファイル: RenderThemeGtk.cpp プロジェクト: Wrichik1999/webkit
void RenderThemeGtk::systemFont(CSSValueID, FontDescription& fontDescription) const
{
    GtkSettings* settings = gtk_settings_get_default();
    if (!settings)
        return;

    // This will be a font selection string like "Sans 10" so we cannot use it as the family name.
    GUniqueOutPtr<gchar> fontName;
    g_object_get(settings, "gtk-font-name", &fontName.outPtr(), NULL);

    PangoFontDescription* pangoDescription = pango_font_description_from_string(fontName.get());
    if (!pangoDescription)
        return;

    fontDescription.setOneFamily(pango_font_description_get_family(pangoDescription));

    int size = pango_font_description_get_size(pangoDescription) / PANGO_SCALE;
    // If the size of the font is in points, we need to convert it to pixels.
    if (!pango_font_description_get_size_is_absolute(pangoDescription))
        size = size * (getScreenDPI() / 72.0);

    fontDescription.setSpecifiedSize(size);
    fontDescription.setIsAbsoluteSize(true);
    fontDescription.setGenericFamily(FontDescription::NoFamily);
    fontDescription.setWeight(FontWeightNormal);
    fontDescription.setItalic(false);
    pango_font_description_free(pangoDescription);
}
コード例 #2
0
ファイル: viewHelper.cpp プロジェクト: nbolton/vimrid
///////////////////////////////////////////////////////////
//
// Zoom to the selected image's area. The rectangle measure
//  units are in image's pixels
//
///////////////////////////////////////////////////////////
void view::setZoomRect(imbxInt32 left, imbxInt32 top, imbxInt32 right, imbxInt32 bottom)
{
	if(m_originalImage == 0)
	{
		return;
	}

	if(left > right)
	{
		imbxInt32 temp = left;
		left = right;
		right = temp;
	}

	if(top > bottom)
	{
		imbxInt32 temp = top;
		top = bottom;
		bottom = temp;

	}
	imbxInt32 centerPointX = (right - left)/2 + left;
	imbxInt32 centerPointY = (bottom - top)/2 + top;

	imbxUint32 sizeX, sizeY;
	getWindowSize(&sizeX, &sizeY);

	double imageSizeMmX, imageSizeMmY;
	m_originalImage->getSizeMm(&imageSizeMmX, &imageSizeMmY);

	imbxUint32 imageSizeX, imageSizeY;
	m_originalImage->getSize(&imageSizeX, &imageSizeY);

	imbxUint32 horzDPI, vertDPI;
	getScreenDPI(&horzDPI, &vertDPI);

	if(imageSizeMmX == 0)
	{
		imageSizeMmX = (double)imageSizeX * 25.4 / (double)horzDPI;
	}
	if(imageSizeMmY == 0)
	{
		imageSizeMmY = (double)imageSizeY * 25.4 / (double)vertDPI;
	}

	double displaySizeMmX = imageSizeMmX * ((double)(right - left) / (double)imageSizeX);
	double displaySizeMmY = imageSizeMmY * ((double)(bottom - top) / (double)imageSizeY);
	double horzZoom = 0.95*(sizeX*25.4)/(displaySizeMmX*(double)horzDPI);
	double vertZoom = 0.95*(sizeY*25.4)/(displaySizeMmY*(double)vertDPI);

	m_zoom = (horzZoom < vertZoom) ? horzZoom : vertZoom;

	updateImageRect(centerPointX, centerPointY);

}
コード例 #3
0
ファイル: viewHelper.cpp プロジェクト: nbolton/vimrid
///////////////////////////////////////////////////////////
//
// Calculate the rectancle to use to draw the image
//
///////////////////////////////////////////////////////////
void view::updateImageRect(imbxInt32 centerPointX, imbxInt32 centerPointY)
{
	imbxInt32 tempCenterPointX = 0;
	imbxInt32 tempCenterPointY = 0;
	getCenterPoint(&tempCenterPointX, &tempCenterPointY);

	if(centerPointX < 0) centerPointX = tempCenterPointX;
	if(centerPointY < 0) centerPointY = tempCenterPointY;

	imbxInt32 leftPosition, topPosition, rightPosition, bottomPosition;
	leftPosition=
		topPosition=
		rightPosition=
		bottomPosition = 0;

	// Get the window's size
	///////////////////////////////////////////////////////////
	imbxUint32 windowSizeX = 0;
	imbxUint32 windowSizeY = 0;
	getWindowSize(&windowSizeX, &windowSizeY);

	// Get the scroll size
	///////////////////////////////////////////////////////////
	imbxUint32 scrollSizeX = 0;
	imbxUint32 scrollSizeY = 0;
	getScrollSize(&scrollSizeX, &scrollSizeY);

	// Get the scroll position
	///////////////////////////////////////////////////////////
	imbxInt32 scrollPosX = 0;
	imbxInt32 scrollPosY = 0;
	getScrollPosition(&scrollPosX, &scrollPosY);

	// For now, the new scroll size and position are the same
	//  as the old ones
	///////////////////////////////////////////////////////////
	imbxUint32 newScrollSizeX=scrollSizeX;
	imbxUint32 newScrollSizeY=scrollSizeY;

	if(m_originalImage != 0)
	{
		imbxUint32 imageSizeX(0), imageSizeY(0);
		m_originalImage->getSize(&imageSizeX, &imageSizeY);

		// Retrieve the screen's resolution
		///////////////////////////////////////////////////////////
		imbxUint32 screenHorzDPI, screenVertDPI;
		screenHorzDPI=screenVertDPI=75;
		getScreenDPI(&screenHorzDPI, &screenVertDPI);

		// Get the image's size (in mms and pixels)
		///////////////////////////////////////////////////////////
		double imageSizeMmX = 0;
		double imageSizeMmY = 0;
		m_originalImage->getSizeMm(&imageSizeMmX, &imageSizeMmY);

		if(imageSizeMmX == 0)
		{
			imageSizeMmX = (double)imageSizeX * 25.4 / (double)screenHorzDPI;
		}
		if(imageSizeMmY == 0)
		{
			imageSizeMmY = (double)imageSizeY * 25.4 / (double)screenVertDPI;
		}


		// Calculate the area occupied by the image, in screen's
		//  pixels
		///////////////////////////////////////////////////////////
		imbxUint32 displayAreaWidth=(imbxUint32)((double)imageSizeMmX*m_zoom*(double)screenHorzDPI/25.4+0.5);
		imbxUint32 displayAreaHeight=(imbxUint32)((double)imageSizeMmY*m_zoom*(double)screenVertDPI/25.4+0.5);

		if(displayAreaWidth>windowSizeX)
		{
			rightPosition = displayAreaWidth;
		}
		else
		{
			leftPosition = (windowSizeX-displayAreaWidth)>>1;
			rightPosition = leftPosition+displayAreaWidth;
		}

		if(displayAreaHeight>windowSizeY)
		{
			bottomPosition = displayAreaHeight;
		}
		else
		{
			topPosition = (windowSizeY-displayAreaHeight)>>1;
			bottomPosition = topPosition+displayAreaHeight;
		}
		newScrollSizeX = displayAreaWidth;
		newScrollSizeY = displayAreaHeight;
	}