Beispiel #1
0
void TextBox::setCaretLocation(int x, int y)
{
    // Get index into string and cursor location from the latest touch location.
    _prevCaretLocation.set(_caretLocation);
    _caretLocation.set(x + _absoluteBounds.x,
                       y + _absoluteBounds.y);

    Font* font = getFont(_state);
    unsigned int fontSize = getFontSize(_state);
    Font::Justify textAlignment = getTextAlignment(_state);
    bool rightToLeft = getTextRightToLeft(_state);

    int index = font->getIndexAtLocation(_text.c_str(), _textBounds, fontSize, _caretLocation, &_caretLocation,
            textAlignment, true, rightToLeft);

    if (index == -1)
    {
        // Attempt to find the nearest valid caret location.
        Rectangle textBounds;
        font->measureText(_text.c_str(), _textBounds, fontSize, &textBounds, textAlignment, true, true);

        if (_caretLocation.x > textBounds.x + textBounds.width &&
            _caretLocation.y > textBounds.y + textBounds.height)
        {
            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, (unsigned int)_text.length(),
                textAlignment, true, rightToLeft);
            return;
        }

        if (_caretLocation.x < textBounds.x)
        {
            _caretLocation.x = textBounds.x;
        }
        else if (_caretLocation.x > textBounds.x + textBounds.width)
        {
            _caretLocation.x = textBounds.x + textBounds.width;
        }

        if (_caretLocation.y < textBounds.y)
        {
            _caretLocation.y = textBounds.y;
        }
        else if (_caretLocation.y > textBounds.y + textBounds.height)
        {
            Font* font = getFont(_state);
            GP_ASSERT(font);
            unsigned int fontSize = getFontSize(_state);
            _caretLocation.y = textBounds.y + textBounds.height - fontSize;
        }

        index = font->getIndexAtLocation(_text.c_str(), _textBounds, fontSize, _caretLocation, &_caretLocation,
            textAlignment, true, rightToLeft);

        if (index == -1)
        {
            // We failed to find a valid location; just put the caret back to where it was.
            _caretLocation.set(_prevCaretLocation);
        }
    }
}
Beispiel #2
0
void TextBox::setCaretLocation(int x, int y)
{
    Control::State state = getState();

    Vector2 point(x + _absoluteBounds.x, y + _absoluteBounds.y);

    // Get index into string and cursor location from the latest touch location.
    Font* font = getFont(state);
    unsigned int fontSize = getFontSize(state);
    Font::Justify textAlignment = getTextAlignment(state);
    bool rightToLeft = getTextRightToLeft(state);
    const std::string displayedText = getDisplayedText();

    int index = font->getIndexAtLocation(displayedText.c_str(), _textBounds, fontSize, point, &point,
            textAlignment, true, rightToLeft);

    if (index == -1)
    {
        // Attempt to find the nearest valid caret location.
        Rectangle textBounds;
        font->measureText(displayedText.c_str(), _textBounds, fontSize, &textBounds, textAlignment, true, true);

        if (point.x > textBounds.x + textBounds.width &&
            point.y > textBounds.y + textBounds.height)
        {
            font->getLocationAtIndex(displayedText.c_str(), _textBounds, fontSize, &point, (unsigned int)_text.length(),
                textAlignment, true, rightToLeft);
            return;
        }

        if (point.x < textBounds.x)
        {
            point.x = textBounds.x;
        }
        else if (point.x > textBounds.x + textBounds.width)
        {
            point.x = textBounds.x + textBounds.width;
        }

        if (point.y < textBounds.y)
        {
            point.y = textBounds.y;
        }
        else if (point.y > textBounds.y + textBounds.height)
        {
            Font* font = getFont(state);
            GP_ASSERT(font);
            unsigned int fontSize = getFontSize(state);
            point.y = textBounds.y + textBounds.height - fontSize;
        }

        index = font->getIndexAtLocation(displayedText.c_str(), _textBounds, fontSize, point, &point,
            textAlignment, true, rightToLeft);
    }

    if (index != -1)
        _caretLocation = index;
}
Beispiel #3
0
void CBitmapFont::makeFont(){
	//gcon.printf("makeFont() : making font %s_%f\n", name.c_str(), getFontSize());
	file = CFTLibrary::getSingleton()->loadFontFace(name, &mFace);
	//size = 17;
	if(FT_Set_Char_Size(
              mFace,    /* handle to face object           */
              0,       /* char_width in 1/64th of points  */
              (S32)getFontSize()*64,   /* char_height in 1/64th of points */
              0,     /* horizontal device resolution    */
			  0 ))   /* vertical device resolution      */ {

		throw CException("Failed to set char size.");
	}

	if(FT_Select_Charmap( mFace, ft_encoding_unicode ))
		throw CException("Non unicode font");

	mGlyphs.resize(mFace->num_glyphs, 0);

	mTextureSize = 256;

	pen.x = pen.y = 0;

	curTex = newTexture();

	for(S32 i = 0 ; i < 130 ; ++i){
		generateGlyph(i);	
	}

	//CFTLibrary::getSingleton()->doneFontFace(&mFace);
}
Beispiel #4
0
void CBitmapFont::stringSize(const std::string &str, F32 *w, F32 *h){
	if(!mTextures.size())
		makeFont();
	*w = *h = 0.0;
    F32 maxw = 0.0;
    S32 lines = 1;
	for(S32 i = 0 ; i < str.size() ; i++){
		FT_UInt glyph_index;

        if(str[i] == '\n'){
            *w = 0.0;
            ++lines;
            continue;
        }
		glyph_index = FT_Get_Char_Index( mFace, (FT_ULong)str[i] );

		CBitmapGlyph *g = mGlyphs[glyph_index];

		if(!g)
			continue;

		*w += g->mAdvance.x;
        if(*w > maxw)maxw = *w;
	}
    *w = maxw;
	*h = lines * getFontSize() * 64.0 * 1.2 / dpi; //convert points to pixels
}
Beispiel #5
0
void TextBox::getCaretLocation(Vector2* p)
{
    GP_ASSERT(p);

    State state = getState();
    getFont(state)->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, getFontSize(state), p, _caretLocation, getTextAlignment(state), true, getTextRightToLeft(state));
}
void ArduRCT_GraphicsUITab::draw(ArduRCT_Graphics *graphics, int16_t uiX, int16_t uiY, uint16_t uiWidth) {
    uint16_t bgColor = graphics->getBackgroundColor();
    uint16_t color = GRAPHICS_UI_COLOR_RELEASED;
    if (_value == GRAPHICS_UI_PRESSED) color = GRAPHICS_UI_COLOR_BACKGROUND;
    if (_state == GRAPHICS_UI_PRESSED) color = GRAPHICS_UI_COLOR_PRESSED;
    graphics->setBackgroundColor(color);
    int16_t xStart = 0;
    if ((getPrevious() == 0) || (getPrevious()->getGroup() != _group)) xStart = GRAPHICS_UI_TAB_LEFT_MARGIN;
    graphics->fillRectangle(xStart+uiX+x, uiY+y+1, width-xStart, height-1, color);
    uint16_t bColor = BLACK;
    if (_state == GRAPHICS_UI_SELECTED || _state == GRAPHICS_UI_RELEASED) bColor = GRAPHICS_UI_COLOR_HIGHLIGHTED;
    graphics->drawRectangle(xStart+uiX+x, uiY+y+1, width-xStart, height-1, bColor, 1);	
    int16_t lineY = uiY+y+height-1;
    if (xStart != 0) graphics->drawLine(uiX+x, lineY, uiX+x+xStart, lineY, BLACK, 1);
    // for the last tab, go to the end of the ui
    if ((getNext() == 0) || (getNext()->getGroup() != _group)) 
        graphics->drawLine(uiX+x+width, lineY, uiX+x+width+uiWidth, lineY, BLACK, 1);
    if (_value == GRAPHICS_UI_PRESSED) 
        graphics->drawLine(uiX+x+xStart+1, lineY, uiX+x+width-2, lineY, WHITE, 1);
    if (_text) {
        uint8_t fontSize = getFontSize(_text);
        graphics->drawString(_text, uiX+x+_textX+xStart/2, uiY+y+_textY+1, BLACK, fontSize, GRAPHICS_UI_ELEMENT_FONT_IS_BOLD, false);
    } else if (_drawHandler) {
        (*_drawHandler)(_id, _state, _value, x+uiX, y+uiY, width, height);
    }
    graphics->setBackgroundColor(bgColor);
}
void ArduRCT_GraphicsUITab::autoSize(ArduRCT_Graphics *graphics) {
    if (_text == 0) return; 
    uint8_t fontSize = getFontSize(_text);
    height = graphics->getFontHeight(fontSize) + GRAPHICS_UI_TAB_TOP_MARGIN * 2;
    width =  graphics->getStringWidth(_text, fontSize) + GRAPHICS_UI_TAB_LEFT_MARGIN * 2;
    if ((getPrevious() == 0) || (getPrevious()->getGroup() != _group)) width += GRAPHICS_UI_TAB_LEFT_MARGIN;
}
Beispiel #8
0
void GRSingleRest::updateBoundingBox()
{
    traceMethod("updateBoundingBox");
    const float extent = GetSymbolExtent(mType);
    const int theSize = getFontSize();
    const NVPoint & offset = getOffset();
    float scale = getSize();

    mBoundingBox.left = -extent/2 * scale;
    mBoundingBox.right = mBoundingBox.left + (extent * scale);

    switch (mType) {
    case P1:
        mBoundingBox.top = (LSPACE - mPosition.y) * scale;
        mBoundingBox.bottom = (theSize - LSPACE) * scale;
        break;
    case P2:
        mBoundingBox.top = (LSPACE * 1.5f - mPosition.y) * scale;
        mBoundingBox.bottom = (theSize - LSPACE * 1.5f) * scale;
        break;
    case P8:
    case P16:
        mBoundingBox.top = (LSPACE - mPosition.y) * scale;
        mBoundingBox.bottom = theSize * scale;
        break;
    default:
        mBoundingBox.top = -mPosition.y * scale;
        mBoundingBox.bottom = theSize * scale;
        break;
    }
    mMapping = mBoundingBox;
    mMapping += mPosition + offset;
}
void PointerCoordinates::draw(StelCore *core)
{
	if (!isEnabled())
		return;

	const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto);
	StelPainter sPainter(prj);
	sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f);
	font.setPixelSize(getFontSize());
	sPainter.setFont(font);

	QPoint p = QCursor::pos(); // get screen coordinates of mouse cursor
	Vec3d mousePosition;
	float wh = prj->getViewportWidth()/2; // get half of width of the screen
	float hh = prj->getViewportHeight()/2; // get half of height of the screen
	float mx = p.x()-wh; // point 0 in center of the screen, axis X directed to right
	float my = p.y()-hh; // point 0 in center of the screen, axis Y directed to bottom
	// calculate position of mouse cursor via position of center of the screen (and invert axis Y)
	prj->unProject(prj->getViewportPosX()+wh+mx, prj->getViewportPosY()+hh+1-my, mousePosition);

	double dec_j2000, ra_j2000;
	StelUtils::rectToSphe(&ra_j2000,&dec_j2000,mousePosition); // Calculate RA/DE (J2000.0) and show it...
	QString coordsText = QString("%1/%2").arg(StelUtils::radToHmsStr(ra_j2000, true)).arg(StelUtils::radToDmsStr(dec_j2000, true));

	sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordinatesPlace(coordsText).second, coordsText);
}
Beispiel #10
0
void RAPHAEL_SetFontSpec(pDevDesc dev, R_GE_gcontext *gc, int idx) {
	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	char *saved_locale;
	saved_locale = setlocale(LC_NUMERIC, "C");

	float alpha =  R_ALPHA(gc->col)/255.0;
	double fontsize = getFontSize(gc->cex, gc->ps, gc->lineheight);


	if ( gc->cex > 0.0 && alpha > 0 ) {
		fprintf(pd->dmlFilePointer, "elt_%d.attr({", idx);
		fprintf(pd->dmlFilePointer, "'fill': \"#%s\"", RGBHexValue(gc->col) );
		fprintf(pd->dmlFilePointer, ", 'fill-opacity': \"%.3f\"", alpha );
		fprintf(pd->dmlFilePointer, ", 'font-family': \"%s\"", pd->fi->fontname );
		fprintf(pd->dmlFilePointer, ", 'font-size': \"%.0f\"", fontsize );
		if (gc->fontface == 2) {
			fputs(", 'font-weight': \"bold\"", pd->dmlFilePointer );
		} else if (gc->fontface == 3) {
			fputs(", 'font-style':\"italic\"", pd->dmlFilePointer );
		} else if (gc->fontface == 4) {
			fputs(", 'font-weight': \"bold\", 'font-style':\"italic\"", pd->dmlFilePointer );
		}
		fputs("});\n", pd->dmlFilePointer );


	}

	setlocale(LC_NUMERIC, saved_locale);

}
Beispiel #11
0
unsigned int TextBox::drawImages(Form* form, const Rectangle& clip)
{
    Control::State state = getState();

    if (_caretImage && (state == ACTIVE || hasFocus()))
    {
        // Draw the cursor at its current location.
        const Rectangle& region = _caretImage->getRegion();
        if (!region.isEmpty())
        {
            const Theme::UVs& uvs = _caretImage->getUVs();
            Vector4 color = _caretImage->getColor();
            color.w *= _opacity;

            float caretWidth = region.width * _fontSize / region.height;

            Font* font = getFont(state);
            unsigned int fontSize = getFontSize(state);
            Vector2 point;
            font->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, fontSize, &point, _caretLocation, 
                 getTextAlignment(state), true, getTextRightToLeft(state));

            SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
            startBatch(form, batch);
            batch->draw(point.x - caretWidth * 0.5f, point.y, caretWidth, fontSize, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
            finishBatch(form, batch);

            return 1;
        }
    }

    return 0;
}
Beispiel #12
0
/*!
 * \brief TextAnnotation::duplicate
 * Creates a duplicate of this object.
 */
void TextAnnotation::duplicate()
{
  TextAnnotation *pTextAnnotation = new TextAnnotation("", false, mpGraphicsView);
  QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
                   mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
  pTextAnnotation->setOrigin(mOrigin + gridStep);
  pTextAnnotation->setRotationAngle(mRotation);
  pTextAnnotation->initializeTransformation();
  pTextAnnotation->setLineColor(getLineColor());
  pTextAnnotation->setFillColor(getFillColor());
  pTextAnnotation->setLinePattern(getLinePattern());
  pTextAnnotation->setFillPattern(getFillPattern());
  pTextAnnotation->setLineThickness(getLineThickness());
  pTextAnnotation->setExtents(getExtents());
  pTextAnnotation->setTextString(getTextString());
  pTextAnnotation->setFontSize(getFontSize());
  pTextAnnotation->setFontName(getFontName());
  pTextAnnotation->setTextStyles(getTextStyles());
  pTextAnnotation->setTextHorizontalAlignment(getTextHorizontalAlignment());
  pTextAnnotation->drawCornerItems();
  pTextAnnotation->setCornerItemsPassive();
  pTextAnnotation->update();
  mpGraphicsView->addClassAnnotation();
  mpGraphicsView->setCanAddClassAnnotation(true);
}
Beispiel #13
0
void TextBox::updateState(State state)
{
    Label::updateState(state);

    _fontSize = getFontSize(state);
    _caretImage = getImage("textCaret", state);
}
void KIGPDialog::writeConfig()
{
 KConfigGroup group = m_config->group("Look");
 group.writeEntry("ImagesPerRow", getImagesPerRow());
 group.writeEntry("ImageName", printImageName());
 group.writeEntry("ImageSize", printImageSize());
 group.writeEntry("ImageProperty", printImageProperty());
 group.writeEntry("FontName", getFontName());
 group.writeEntry("FontSize", getFontSize());
 group.writeEntry("ForegroundColor", getForegroundColor().name() );
 group.writeEntry("BackgroundColor", getBackgroundColor().name());

 group =m_config->group("Directory");
 group.writeEntry("RecurseSubDirectories", recurseSubDirectories());
 group.writeEntry("RecursionLevel", recursionLevel());
 group.writeEntry("CopyOriginalFiles", copyOriginalFiles());
 group.writeEntry("UseCommentFile", useCommentFile());

 group = m_config->group("Thumbnails");
 group.writeEntry("ThumbnailSize", getThumbnailSize());
 group.writeEntry("ColorDepth", getColorDepth());
 group.writeEntry("ColorDepthSet", colorDepthSet());
 group.writeEntry("ImageFormat", getImageFormat());
 group.sync();
}
Beispiel #15
0
void Settings::setFontSize(int value)
{
    if (getFontSize() != value) {
        settings.setValue("fontsize", value);
        emit fontSizeChanged();
    }
}
Beispiel #16
0
void TextBox::update(const Control* container, const Vector2& offset)
{
    Label::update(container, offset);

    _fontSize = getFontSize(_state);
    _caretImage = getImage("textCaret", _state);
}
Beispiel #17
0
void CBitmapFont::generateGlyph(U32 ch){
	S32 pad = 3;
	FT_GlyphSlot  slot = mFace->glyph;
	FT_Glyph glyph;
    FT_UInt glyph_index;

	glyph_index = FT_Get_Char_Index( mFace, (FT_ULong)ch );

	FT_Load_Glyph( mFace, glyph_index, FT_LOAD_DEFAULT);
	FT_Get_Glyph( slot, &glyph);

	FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0 ,1);

	FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
	FT_Bitmap* source = &bitmap->bitmap;


	S32 srcWidth = source->width;
	S32 srcHeight = source->rows;
	S32 srcPitch = source->pitch;

	S32 dstWidth = srcWidth;
	S32 dstHeight = srcHeight;
	S32 dstPitch = srcPitch;

	FT_BBox bbox;
	FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_pixels, &bbox);

	unsigned char *src = source->buffer;

	if(pen.x + srcWidth >= mTextureSize){
		pen.x = 0;
		pen.y += (getFontSize() * 64.0f / dpi) + pad;
	}

	glBindTexture(GL_TEXTURE_2D, curTex);checkGLError();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);checkGLError();
	glTexSubImage2D(GL_TEXTURE_2D, 0, 
		pen.x, pen.y,
		srcWidth, srcHeight,
		GL_ALPHA, GL_UNSIGNED_BYTE, src); checkGLError();

	CTexCoord start(pen);
	start /= mTextureSize;
	CTexCoord end(pen.x + srcWidth, pen.y + srcHeight);
	end /= mTextureSize;
	//CVector2 pos(slot->bitmap_left, slot->bitmap_top);
	CVector2 pos(bitmap->left, srcHeight - bitmap->top);
	CVector2 size(srcWidth, srcHeight);
	CVector2 advance(slot->advance.x >> 6, slot->advance.y >> 6);
	
	mGlyphs[glyph_index] = new CBitmapGlyph(curTex, start, end, pos, size, advance);

	pen.x += srcWidth + pad;

	FT_Done_Glyph(glyph);
}
Beispiel #18
0
TextSymbol* OgrFileImport::getSymbolForLabel(OGRStyleToolH tool, const QByteArray&)
{
	Q_ASSERT(OGR_ST_GetType(tool) == OGRSTCLabel);
	
	int is_null;
	auto label_string = OGR_ST_GetParamStr(tool, OGRSTLabelTextString, &is_null);
	if (is_null)
		return nullptr;
	
	auto color_string = OGR_ST_GetParamStr(tool, OGRSTLabelFColor, &is_null);
	auto font_size_string = OGR_ST_GetParamStr(tool, OGRSTLabelSize, &is_null);
	
	// Don't use the style string as a key: The style contains the label.
	QByteArray key;
	key.reserve(qstrlen(color_string) + qstrlen(font_size_string) + 1);
	key.append(color_string);
	key.append(font_size_string);
	auto text_symbol = static_cast<TextSymbol*>(text_symbols.value(key));
	if (!text_symbol)
	{
		text_symbol = static_cast<TextSymbol*>(default_text_symbol->duplicate());
		
		auto color = makeColor(tool, color_string);
		if (color)
			text_symbol->setColor(color);
		else
			text_symbol->setHidden(true);
		
		auto font_size = OGR_ST_GetParamDbl(tool, OGRSTLabelSize, &is_null);
		if (!is_null && font_size > 0.0)
			text_symbol->scale(font_size / text_symbol->getFontSize());
		
		key.detach();
		text_symbols.insert(key, text_symbol);
		
		map->addSymbol(text_symbol, map->getNumSymbols());
	}
	
	auto anchor = qBound(1, OGR_ST_GetParamNum(tool, OGRSTLabelAnchor, &is_null), 12);
	if (is_null)
		anchor = 1;
	
	auto angle = OGR_ST_GetParamDbl(tool, OGRSTLabelAngle, &is_null);
	if (is_null)
		angle = 0.0;
	
	QString description;
	description.reserve(qstrlen(label_string) + 100);
	description.append(QString::number(100 + anchor));
	description.append(QString::number(angle, 'g', 1));
	description.append(QLatin1Char(' '));
	description.append(label_string);
	text_symbol->setDescription(description);
	
	return text_symbol;
}
Beispiel #19
0
void Slider::drawText(const Rectangle& clip)
{
    Label::drawText(clip);

    if (_valueTextVisible && _font)
    {
        _font->start();
        _font->drawText(_valueText.c_str(), _textBounds, _textColor, getFontSize(_state), _valueTextAlignment, true, getTextRightToLeft(_state), &_viewportClipBounds);
        _font->finish();
    }
}
void PointerCoordinates::saveConfiguration(void)
{
	conf->beginGroup("PointerCoordinates");

	conf->setValue("enable_at_startup", getFlagEnableAtStartup());
	conf->setValue("flag_show_button", getFlagShowCoordinatesButton());
	conf->setValue("current_displaying_place", getCurrentCoordinatesPlaceKey());
	//conf->setValue("text_color", "1,0.5,0");
	conf->setValue("font_size", getFontSize());

	conf->endGroup();
}
Beispiel #21
0
void CFrame::render()
{
   int iParentPosX = getLeft();
   int iParentPosY = getTop();
   int iThisPosX = (int)getDescriptionXPos();
   int iThisPosY = (int)getDescriptionYPos();

   CGLFont *poFont;
   poFont = g_oFontManager.getFont(m_iFontID);
   C2DObject::renderQuad();
   poFont->print(this->getDescription(), NSDMath::CVector2(iParentPosX + iThisPosX,
										 iParentPosY + iThisPosY),
										 getFontSize(), getFontColour());
}
Beispiel #22
0
Text::Text( Canvas &canvas, Text &ao )
{
  Dout( dc::notice, *this << " Text::Text copy constructor" );
  o = evas_object_text_add( canvas.obj() );
  init();

  setGeometry( ao.getGeometry() );
  setLayer( ao.getLayer() );
  setText( ao.getText() );
  setClip( ao.getClip() );
  setFont( ao.getFontName(), getFontSize () );
  setColor( ao.getColor() );
  setVisible( ao.isVisible() );
}
Beispiel #23
0
void Label::updateBounds()
{
    if (_autoSize != AUTO_SIZE_NONE && _font)
    {
        // Measure bounds based only on normal state so that bounds updates are not always required on state changes.
        // This is a trade-off for functionality vs performance, but changing the size of UI controls on hover/focus/etc
        // is a pretty bad practice so we'll prioritize performance here.
        if (_autoSize & AUTO_SIZE_WIDTH)
        {
            float w, h;
            _font->measureText(_text.c_str(), getFontSize(NORMAL), getTextDrawingFlags(NORMAL), &w, &h, getCharacterSpacing(NORMAL), getLineSpacing(NORMAL));
            setWidthInternal(ceilf(w + getBorder(NORMAL).left + getBorder(NORMAL).right + getPadding().left + getPadding().right));
            if (_autoSize & AUTO_SIZE_HEIGHT)
                setHeightInternal(ceilf(h + getBorder(NORMAL).top + getBorder(NORMAL).bottom + getPadding().top + getPadding().bottom));
        }
        else // _autoSize & AUTO_SIZE_HEIGHT
        {
            GP_ASSERT(_autoSize & AUTO_SIZE_HEIGHT);

            // recalculate height due to word wrapping
            float h = getFontSize(NORMAL);
            if (_textBounds.width > 0.0f)
            {
                gameplay::Rectangle clipBounds(_textBounds.width, FLT_MAX);
                gameplay::Rectangle out;
                _font->measureText(_text.c_str(), clipBounds, getFontSize(NORMAL), getTextDrawingFlags(NORMAL), &out, getTextAlignment(NORMAL), 
                    true, true, getCharacterSpacing(NORMAL), getLineSpacing(NORMAL));

                h = out.height;
            }

            setHeightInternal(ceilf(h + getBorder(NORMAL).top + getBorder(NORMAL).bottom + getPadding().top + getPadding().bottom));
        }
    }

    Control::updateBounds();
}
void PointerCoordinates::saveConfiguration(void)
{
	conf->beginGroup("PointerCoordinates");

	conf->setValue("enable_at_startup", getFlagEnableAtStartup());
	conf->setValue("flag_show_button", getFlagShowCoordinatesButton());
	conf->setValue("current_displaying_place", getCurrentCoordinatesPlaceKey());
	conf->setValue("current_coordinate_system", getCurrentCoordinateSystemKey());
	QPair<int, int> cc = getCustomCoordinatesPlace();
	conf->setValue("custom_coordinates", QString("%1,%2").arg(cc.first).arg(cc.second));
	//conf->setValue("text_color", "1,0.5,0");
	conf->setValue("font_size", getFontSize());

	conf->endGroup();
}
void IntervalProgressDisplay::paintEvent(QPaintEvent *e)
{
    Q_UNUSED(e);

    if (paintStrategy) {
        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing, true);
        qreal elementsSize = getElementsSize(paintMode);
        qreal fontSize = getFontSize(paintMode);
        PaintContext paintContext(width(), height(), beatsPerInterval, currentBeat, isShowingAccents(), beatsPerAccent, elementsSize, fontSize);
        QColor currentBeatColor = usingLowContrastColors ? Qt::lightGray : Qt::white;
        QBrush textBrush = palette().text(); //using the color define in loaded stylesheet theme
        PaintColors paintColors(currentBeatColor, SECONDARY_BEATS_COLOR, ACCENT_COLOR, CURRENT_ACCENT_COLOR, DISABLED_BEATS_COLOR, textBrush);
        paintStrategy->paint(p, paintContext, paintColors);
    }
}
void getFontSettings( const GfxFeature* feature, 
                      const MapSetting* settings,
                      const char*& fontName,
                      int32& fontSize,
                      GDUtils::Color::CoolColor& color,
                      int32 scaleLeve,
                      bool smallImage ) {
   if ( settings ) {      
      fontName = settings->m_fontName;
      color = settings->m_fontColor;
   } else {
      getFontNameAndColor( feature, fontName, color );
   }

   fontSize = getFontSize( feature, scaleLeve, smallImage );
}
void RogueScene::logMessage(const char * pszFormat, ...)
{
    char szBuf[kMaxLogLen+1] = {0};
    va_list ap;
    va_start(ap, pszFormat);
    vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
    va_end(ap);
    
    CCLOG("logMessage: %s", szBuf);
    
    auto pGameLogNode = getChildByTag(RogueScene::kGameLogTag);
    // とりあえず子要素がないなら無理
    if (!pGameLogNode || pGameLogNode->getChildrenCount() <= 0)
    {
        return;
    }
    
    auto pGameLogText = static_cast<LabelTTF*>(pGameLogNode->getChildren().at(0)); // TODO: 1子しかaddしてないから動く。ちゃんとしないと・・・
    if (pGameLogText)
    {
        // TODO: 別クラスにしてログをlistで保持する。デフォルトの表示は1件だけで、center寄せ表示でいいかと
        auto pMessage = String::create(szBuf);
        
        pMessage->append("\n");

        std::string nowString = pGameLogText->getString();
        
        int count = f_r(nowString, '\n');
        
        // 3行まで表示
        if (count >= 3)
        {
            int size = nowString.size();
            unsigned int loc = nowString.find_last_of('\n', size);
            CCLOG("logMessage: loc = %d size = %d", loc, size);
            if (loc != std::string::npos)
            {
                nowString.erase(loc, nowString.size() - loc);
            }
        }
        pMessage->append(nowString);
        pGameLogText->setString(pMessage->getCString());
        pGameLogText->setVerticalAlignment(cocos2d::TextVAlignment::TOP);
        pGameLogText->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
        pGameLogText->setPosition(Point(pGameLogText->getFontSize() / 4 + pGameLogText->getContentSize().width / 2, pGameLogNode->getContentSize().height - pGameLogText->getContentSize().height / 2 - pGameLogText->getFontSize() / 4));
    }
}
Beispiel #28
0
static void RAPHAEL_Text(double x, double y, const char *str, double rot,
		double hadj, const pGEcontext gc, pDevDesc dev) {

	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_and_increment_idx(dev);
	register_element( dev);
	double w = RAPHAEL_StrWidth(str, gc, dev);
	double fontsize = getFontSize(gc->cex, gc->ps, gc->lineheight);
	double h = fontsize;
	if( h < 1.0 ) return;
	double pi = 3.141592653589793115997963468544185161590576171875;

	double alpha = -rot * pi / 180;
	double height = h;
	double Qx = x;
	double Qy = y ;
	double Px = x + (0.5-hadj) * w;
	double Py = y - 0.5 * height;
	double _cos = cos( alpha );
	double _sin = sin( alpha );

	double Ppx = Qx + (Px-Qx) * _cos - (Py-Qy) * _sin ;
	double Ppy = Qy + (Px-Qx) * _sin + (Py-Qy) * _cos;

	double corrected_offx = Ppx ;//- 0.5 * w;
	double corrected_offy = Ppy ;//- 0.1 * h;


	fprintf(pd->dmlFilePointer, "var elt_%d = %s.text(", idx, pd->objectname );
	fprintf(pd->dmlFilePointer, "%.0f,%.0f", corrected_offx, corrected_offy);
	fputs(",\"", pd->dmlFilePointer );
	raphael_text(str, pd);
	fputs("\"", pd->dmlFilePointer );
	fputs(");\n", pd->dmlFilePointer );

	RAPHAEL_SetFontSpec(dev, gc, idx);
	if( rot > 0 ) {
		fprintf(pd->dmlFilePointer, "elt_%d.transform(\"", idx);
		fprintf(pd->dmlFilePointer, "R-%.0f", rot);
		fputs("\");\n", pd->dmlFilePointer );
	}

	fflush(pd->dmlFilePointer);

}
Beispiel #29
0
void Slider::updateBounds()
{
    Label::updateBounds();

    // Compute height of track (max of track, min/max and marker
    _trackHeight = _minImage->getRegion().height;
    _trackHeight = std::max(_trackHeight, _maxImage->getRegion().height);
    _trackHeight = std::max(_trackHeight, _markerImage->getRegion().height);
    _trackHeight = std::max(_trackHeight, _trackImage->getRegion().height);

    if (_autoSize & AUTO_SIZE_HEIGHT)
    {
        float height = _bounds.height + _trackHeight;
        if (_valueTextVisible)
            height += getFontSize(NORMAL);
        setHeightInternal(height);
    }
}
Beispiel #30
0
unsigned int Slider::drawText(Form* form, const Rectangle& clip)
{
    unsigned int drawCalls = Label::drawText(form, clip);

    if (_valueTextVisible && _font)
    {
        Control::State state = getState();
        unsigned int fontSize = getFontSize(state);

        SpriteBatch* batch = _font->getSpriteBatch(fontSize);
        startBatch(form, batch);
        _font->drawText(_valueText.c_str(), _textBounds, _textColor, fontSize, _valueTextAlignment, true, getTextRightToLeft(state), _viewportClipBounds);
        finishBatch(form, batch);

        ++drawCalls;
    }

    return drawCalls;
}