//---------------------------------------------------------------------------- void Write(Real x, Real y, Real z, unsigned int color, const char *text, int count, FONT_ALIGN mode) { if (!mInitialized) return; auto& renderer = Renderer::GetInstance(); if (renderer.GetRendererOptions()->r_noText) return; // if (count < 0) count = GetTextLength(text); if (mode == FONT_ALIGN_CENTER) { Real w = GetTextWidth(text, count); x -= w / 2; } else if (mode == FONT_ALIGN_RIGHT) { Real w = GetTextWidth(text, count); x -= w; } mColor = color; renderer.UpdateObjectConstantsBuffer(&mObjectConstants); InternalWrite(Round(x), Round(y), z, text, count); }
/***************************************************************************** * void LoadFontScreen(void) *****************************************************************************/ void LoadForeignFontScreen(void) { SHORT width, height; height = 50; SetColor(GRAY002); SetFont((void *) &fireflysung_22); width = GetTextWidth((XCHAR *)ChineseStr, (void *) &fireflysung_22); OutTextXY((GetMaxX() - width) >> 1, height, (XCHAR *)ChineseStr); height += GetTextHeight((void *) &fireflysung_22) + 5; width = GetTextWidth((XCHAR *)JapaneseStr, (void *) &fireflysung_22); OutTextXY((GetMaxX() - width) >> 1, height, (XCHAR *)JapaneseStr); height += GetTextHeight((void *) &fireflysung_22) + 5; SetFont((void *) &UnBatang_0613_22); width = GetTextWidth((XCHAR *)KoreanStr, (void *) &UnBatang_0613_22); OutTextXY((GetMaxX() - width) >> 1, height, (XCHAR *)KoreanStr); height += GetTextHeight((void *) &UnBatang_0613_22) + 5; width = GetTextWidth((XCHAR *)RussianStr, (void *) &UnBatang_0613_22); OutTextXY((GetMaxX() - width) >> 1, height, (XCHAR *)RussianStr); height += GetTextHeight((void *) &UnBatang_0613_22) + 5; SetFont((void *) &DroidSans_24); width = GetTextWidth("Hello World!", (void *) &DroidSans_24); OutTextXY((GetMaxX() - width) >> 1, height, "Hello World!"); }
int LIB_TEXT::compare( const LIB_ITEM& other ) const { wxASSERT( other.Type() == LIB_TEXT_T ); const LIB_TEXT* tmp = ( LIB_TEXT* ) &other; int result = m_Text.CmpNoCase( tmp->m_Text ); if( result != 0 ) return result; if( GetTextPos().x != tmp->GetTextPos().x ) return GetTextPos().x - tmp->GetTextPos().x; if( GetTextPos().y != tmp->GetTextPos().y ) return GetTextPos().y - tmp->GetTextPos().y; if( GetTextWidth() != tmp->GetTextWidth() ) return GetTextWidth() - tmp->GetTextWidth(); if( GetTextHeight() != tmp->GetTextHeight() ) return GetTextHeight() - tmp->GetTextHeight(); return 0; }
void cFont::RenderFontShadow(WORD wFontIdx, int nShadowDistance, char* text, int size, RECT* pRect, DWORD dwColor) { if(FALSE == IsCreateFont(wFontIdx)) { return; } if( wFontIdx == 5 ) { pRect->right = pRect->left + GetTextExtentWidth( wFontIdx, text, size ) + GetTextWidth( wFontIdx ) ; } else { pRect->right = pRect->left + GetTextExtent( wFontIdx, text, size ) + GetTextWidth( wFontIdx ); } pRect->bottom = pRect->top + GetTextHeight( wFontIdx ) + 5; if(*text) { // render shadow text. DWORD dwShadowColor = 0xff000000 | RGB(10, 10, 10) ; RECT shadowRect = { pRect->left + nShadowDistance, pRect->top + nShadowDistance, pRect->right, pRect->bottom } ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,&shadowRect,dwShadowColor,CHAR_CODE_TYPE_ASCII,0,0); // render front text. DWORD dwFrontColor = 0xff000000 | dwColor ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,dwFrontColor,CHAR_CODE_TYPE_ASCII,0,0); } }
void cFont::RenderFont(WORD wFontIdx, char * text, int size, RECT * pRect, DWORD color) { if(FALSE == IsCreateFont(wFontIdx)) { return; } //KES가 수정했음 040722 if( wFontIdx == 5 ) { pRect->right = pRect->left + GetTextExtentWidth( wFontIdx, text, size ) + GetTextWidth( wFontIdx ) ; } else { pRect->right = pRect->left + GetTextExtent( wFontIdx, text, size ) + GetTextWidth( wFontIdx ); } pRect->bottom = pRect->top + GetTextHeight( wFontIdx ) + 5; //+1안하면 밑줄이 안나온다. if(*text) { DWORD dwColor = 0xff000000 | color; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,dwColor,CHAR_CODE_TYPE_ASCII,0,0); } }
void CategoryDlg::InitializeLists() { CListBox inBox(GetDlgItem(IDC_INCLUDE_LIST)); CListBox exBox(GetDlgItem(IDC_EXCLUDE_LIST)); ClearListBox(inBox); ClearListBox(exBox); int inWidth = 0; int exWidth = 0; ScopedGdiObjectSelection hIn(inBox.GetDC(), inBox.GetFont()); ScopedGdiObjectSelection hEx(exBox.GetDC(), exBox.GetFont()); for (auto it = m_categories.begin(); it != m_categories.end(); ++it) { if (it->second) { inBox.AddString(WStr(it->first)); inWidth = std::max(inWidth, GetTextWidth(inBox.GetDC(), it->first)); } else { exBox.AddString(WStr(it->first)); exWidth = std::max(exWidth, GetTextWidth(exBox.GetDC(), it->first)); } } inBox.SetHorizontalExtent(inWidth + 3*GetSystemMetrics(SM_CXBORDER)); exBox.SetHorizontalExtent(exWidth + 3*GetSystemMetrics(SM_CXBORDER)); UpdateUiState(); }
void RClickMenu::Reset(int x,int y,std::string name,RClickable* target, GamePanel* panel){ Clear(); SetOrgin(TopLeft); isOpen = true; currentPanel = panel; currentTarget = target; GetTextWidth(name); labels.push_back(new Label(x,y,width,"menubackground.png",Label::Fonts::Game, name)); labels[0]->SetTextOffset((width - GetTextWidth(name)) / 2,2); labels[0]->SetTextColor(sf::Color(255,0,0,255)); };
void CGUIFont::DrawScrollingText(float x, float y, const vecColors &colors, color_t shadowColor, const vecText &text, uint32_t alignment, float maxWidth, const CScrollInfo &scrollInfo) { if (!m_font) return; if (!shadowColor) shadowColor = m_shadowColor; if (!text.size() || ClippedRegionIsEmpty(x, y, maxWidth, alignment)) return; // nothing to render if (!scrollInfo.m_widthValid) { /* Calculate the pixel width of the complete string */ scrollInfo.m_textWidth = GetTextWidth(text); scrollInfo.m_totalWidth = scrollInfo.m_textWidth + GetTextWidth(scrollInfo.suffix); scrollInfo.m_widthValid = true; } assert(scrollInfo.m_totalWidth != 0); float textPixelWidth = ROUND(scrollInfo.m_textWidth / g_graphicsContext.GetGUIScaleX()); float suffixPixelWidth = ROUND((scrollInfo.m_totalWidth - scrollInfo.m_textWidth) / g_graphicsContext.GetGUIScaleX()); float offset; if(scrollInfo.pixelSpeed >= 0) offset = scrollInfo.pixelPos; else offset = scrollInfo.m_totalWidth - scrollInfo.pixelPos; vecColors renderColors; for (unsigned int i = 0; i < colors.size(); i++) renderColors.push_back(g_graphicsContext.MergeAlpha(colors[i] ? colors[i] : m_textColor)); bool scroll = !scrollInfo.waitTime && scrollInfo.pixelSpeed; if (shadowColor) { shadowColor = g_graphicsContext.MergeAlpha(shadowColor); vecColors shadowColors; for (unsigned int i = 0; i < renderColors.size(); i++) shadowColors.push_back((renderColors[i] & 0xff000000) != 0 ? shadowColor : 0); for (float dx = -offset; dx < maxWidth; dx += scrollInfo.m_totalWidth) { m_font->DrawTextInternal(x + dx + 1, y + 1, shadowColors, text, alignment, textPixelWidth, scroll); m_font->DrawTextInternal(x + dx + scrollInfo.m_textWidth + 1, y + 1, shadowColors, scrollInfo.suffix, alignment, suffixPixelWidth, scroll); } } for (float dx = -offset; dx < maxWidth; dx += scrollInfo.m_totalWidth) { m_font->DrawTextInternal(x + dx, y, renderColors, text, alignment, textPixelWidth, scroll); m_font->DrawTextInternal(x + dx + scrollInfo.m_textWidth, y, renderColors, scrollInfo.suffix, alignment, suffixPixelWidth, scroll); } g_graphicsContext.RestoreClipRegion(); }
void OpLabel::GetPreferedSize(INT32* w, INT32* h, INT32 cols, INT32 rows) { m_edit->UpdateSkinPadding(); //julienp: Otherwise, we mightg have the wrong padding here // if this is called before a relayout *w = GetTextWidth(); *h = GetTextHeight(); }
void RClickMenu::OnStart(){ std::string optionNames[] = {"Drop","Equip","Unequip","Deposit","Withdraw","Barter","Craft"}; GetTextWidth("Withdraw "); for(int x = 0; x < 7; x++){ OptionButtons.push_back(new Label(0,0,width,"menubackground.png",Label::Fonts::Game,optionNames[x])); } };
void DrawMenu(char items[][30], int maxitems, int select) { int i,w,p,h; ClearScreen(); /*** Draw Title Centred ***/ p = (480 - (maxitems * font_height)) / 2 + 10; for( i = 0; i < maxitems; i++ ) { w = CentreTextPosition(items[i]); h = GetTextWidth(items[i]); /* if ( i == select ) writex( w, p, h, font_height, items[i], blit_lookup_inv ); else writex( w, p, h, font_height, items[i], blit_lookup );*/ writex( w, p, h, font_height, items[i], i == select ); p += font_height; } SetScreen(); }
void TEXTE_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; wxCHECK_RET( m_Parent != NULL, wxT( "TEXTE_PCB::GetMsgPanelInfo() m_Parent is NULL." ) ); if( m_Parent->Type() == PCB_DIMENSION_T ) aList.push_back( MSG_PANEL_ITEM( _( "Dimension" ), GetShownText(), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "PCB Text" ), GetShownText(), DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BLUE ) ); if( !IsMirrored() ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "No" ), DARKGREEN ) ); else aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = MessageTextFromValue( aUnits, GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); msg = MessageTextFromValue( aUnits, GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = MessageTextFromValue( aUnits, GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); }
void cFont::RenderNoticeMsg(WORD wFontIdx, char * text, int size, RECT * pRect, DWORD frontColor, DWORD backColor) { if( FALSE == IsCreateFont(wFontIdx) ) { return; } pRect->right = pRect->left + GetTextExtent( wFontIdx, text, size ) + GetTextWidth( wFontIdx ); pRect->bottom = pRect->top + GetTextHeight( wFontIdx ) + 5; if(*text) { pRect->left -= 1 ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,backColor,CHAR_CODE_TYPE_ASCII,0,0); pRect->left += 2 ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,backColor,CHAR_CODE_TYPE_ASCII,0,0); pRect->left -= 1 ; pRect->top -= 1 ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,backColor,CHAR_CODE_TYPE_ASCII,0,0); pRect->top += 2 ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,backColor,CHAR_CODE_TYPE_ASCII,0,0); pRect->top -= 1 ; g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,frontColor,CHAR_CODE_TYPE_ASCII,0,0); } }
/********************************************************************* * Function: void TouchGetCalPoints(WORD* ax, WORD* ay) * * PreCondition: InitGraph() must be called before * * Input: ax - pointer to array receiving 3 X touch positions * ay - pointer to array receiving 3 Y touch positions * * Output: none * * Side Effects: none * * Overview: gets values for 3 touches * * Note: none * ********************************************************************/ void TouchGetCalPoints(WORD* ax, WORD* ay){ static const XCHAR calStr[] = {'C','A','L','I','B','R','A','T','I','O','N',0}; XCHAR calTouchLeft[] = {'3',' ','t','o','u','c','h','e','s',' ','l','e','f','t',0}; SHORT counter; SHORT x,y; SetFont((void*)&GOLFontDefault); SetColor(BRIGHTRED); OutTextXY((GetMaxX()-GetTextWidth((XCHAR*)calStr,(void*)&GOLFontDefault))>>1, (GetMaxY()-GetTextHeight((void*)&GOLFontDefault))>>1, (XCHAR*)calStr); for(counter=0; counter<3; counter++){ SetColor(BRIGHTRED); calTouchLeft[0] = '3' - counter; OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); // Wait for press do{ x=ADCGetX(); y=ADCGetY(); }while((y==-1)||(x==-1)); Beep(); *(ax+counter) = x; *(ay+counter) = y; // Wait for release do{ x=ADCGetX(); y=ADCGetY(); }while((y!=-1)&&(x!=-1)); SetColor(WHITE); OutTextXY((GetMaxX()-GetTextWidth(calTouchLeft,(void*)&GOLFontDefault))>>1, (GetMaxY()+GetTextHeight((void*)&GOLFontDefault))>>1, calTouchLeft); DelayMs(500); } }
ASSISTANT::Text::Text(double _x, double _y, double _width, double _height, int _zPosition, LPCTSTR _color, LPCTSTR _textString, LPCTSTR _family, LPCTSTR _size, LPCTSTR _weight, LPCTSTR _slant, LPCTSTR _position, int _textStyle, UINT _id, LPCTSTR _hyperlink, LPCTSTR _currentDirectory, LPCTSTR _linkedObjects, LPCTSTR linkColor) : ColoredObject(_x, _y, _width, _height, _zPosition, _color, _T("none"), 0, _T("none"), _id, _hyperlink, _currentDirectory, _linkedObjects) { fontFamily = _family; fontSize = _size; fontWeight = _weight; fontSlant = _slant; textPosition = _position; textStyle = _textStyle; offY = 0; drawSize = _ttoi(_size); text.Empty(); if (_textString) { text = _textString; } actPos = EndPos(); if (text.IsEmpty()) firstPos = true; else firstPos = false; m_bHasSupportedFont = true; m_bTextWidthIsStatic = true; // Compute dimension FillLogFont(m_logFont, fontFamily, drawSize, fontWeight, fontSlant); fAscent = GetTextAscent(&m_logFont); fDescent = GetTextDescent(&m_logFont); if (m_dWidth == 0) { m_bTextWidthIsStatic = false; if (text.GetLength() > 0) m_dWidth = GetTextWidth(text, text.GetLength(), &m_logFont); } m_dHeight = fAscent + fDescent; if (_hyperlink) hyperlink_ = _hyperlink; else hyperlink_.Empty(); if (linkColor) activatedLinkColor = linkColor; else activatedLinkColor.Empty(); linkWasActivated = false; m_bHasReturnAtEnd = false; }
bool CGUIFont::UpdateScrollInfo(const vecText &text, CScrollInfo &scrollInfo) { // draw at our scroll position // we handle the scrolling as follows: // We scroll on a per-pixel basis (eschewing the use of character indices // which were also in use previously). The complete string, including suffix, // is plotted to achieve the desired effect - normally just the one time, but // if there is a wrap point within the viewport then it will be plotted twice. // If the string is smaller than the viewport, then it may be plotted even // more times than that. // if (g_application.ScreenSaverDisablesAutoScrolling()) return false; if (scrollInfo.waitTime) { scrollInfo.waitTime--; return false; } if (text.empty()) return false; CScrollInfo old(scrollInfo); // move along by the appropriate scroll amount float scrollAmount = fabs(scrollInfo.GetPixelsPerFrame() * g_graphicsContext.GetGUIScaleX()); if (!scrollInfo.m_widthValid) { /* Calculate the pixel width of the complete string */ scrollInfo.m_textWidth = GetTextWidth(text); scrollInfo.m_totalWidth = scrollInfo.m_textWidth + GetTextWidth(scrollInfo.suffix); scrollInfo.m_widthValid = true; } scrollInfo.pixelPos += scrollAmount; assert(scrollInfo.m_totalWidth != 0); while (scrollInfo.pixelPos >= scrollInfo.m_totalWidth) scrollInfo.pixelPos -= scrollInfo.m_totalWidth; if (scrollInfo.pixelPos != old.pixelPos) return true; else return false; }
void CButton::updateText() { QFontMetrics qfm(m_TextLabel.font()); QString strTemp(qfm.elidedText(m_Text,Qt::ElideRight,GetTextWidth())); m_TextLabel.setText(strTemp); m_TextLabel.setAlignment(Qt::AlignCenter); //m_TextLabel.setGeometry((this->width() - m_TextLabel.width()) / 2, (this->height() - m_TextLabel.height()) / 2, m_TextLabel.width(), m_TextLabel.height()); m_TextLabel.setAttribute(Qt::WA_TranslucentBackground, true); }
void ASSISTANT::Text::GetBBox(int *minX, int *minY, int *maxX, int *maxY) { int textWidth = (int)m_dWidth; if (textWidth == 0 && text.GetLength() > 0) textWidth = (int)GetTextWidth(text, text.GetLength(), &m_logFont); *minX = (int)(m_dX - 3); *minY = (int)(m_dY - fAscent - 3); *maxX = (int)(m_dX + textWidth + 3); *maxY = (int)(m_dY + fDescent + 3); }
void ASSISTANT::Text::ChangeString(LPCTSTR _textString) { text.Empty(); text = _textString; m_bTextWidthIsStatic = false; if (text.GetLength() > 0) m_dWidth = GetTextWidth(text, text.GetLength(), &m_logFont); else m_dWidth = 0; }
/************************************************************************ Function: void DisplayErrorInfo(void) Overview: Display the error information when decoding an unsupported image or thumb drive was removed when decoding. Input: none Output: none ************************************************************************/ void DisplayErrorInfo(void) { WORD TextX, TextY, TextHeight; SetFont((void *) &GOLFontDefault); TextHeight = GetTextHeight((void *) &GOLFontDefault); SetColor(WHITE); ClearDevice(); SetColor(BRIGHTRED); TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGUnsupportedStr, (void *) &GOLFontDefault)) / 2; TextY = (IMG_SCREEN_HEIGHT - 3 * TextHeight) / 2; WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY, (XCHAR *)JPEGUnsupportedStr)); TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGImageStr, (void *) &GOLFontDefault)) / 2; WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY + TextHeight, (XCHAR *)JPEGImageStr)); TextX = (IMG_SCREEN_WIDTH - GetTextWidth((XCHAR *)JPEGFormatStr, (void *) &GOLFontDefault)) / 2; WAIT_UNTIL_FINISH(OutTextXY(TextX, TextY + 2 * TextHeight, (XCHAR *)JPEGFormatStr)); DelayMs(800); }
hsMatrix44 plTextGenerator::GetLayerTransform( void ) { hsMatrix44 xform; hsVector3 scale; scale.Set( (float)GetWidth() / (float)GetTextWidth(), (float)GetHeight() / (float)GetTextHeight(), 1.f ); xform.MakeScaleMat( &scale ); return xform; }
// see class_text_mod.h void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { MODULE* module = (MODULE*) m_Parent; if( module == NULL ) // Happens in modedit, and for new texts return; wxString msg, Line; static const wxString text_type_msg[3] = { _( "Ref." ), _( "Value" ), _( "Text" ) }; Line = module->GetReference(); aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), Line, DARKCYAN ) ); Line = GetShownText(); aList.push_back( MSG_PANEL_ITEM( _( "Text" ), Line, BROWN ) ); wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) ); if( !IsVisible() ) msg = _( "No" ); else msg = _( "Yes" ); aList.push_back( MSG_PANEL_ITEM( _( "Display" ), msg, DARKGREEN ) ); // Display text layer aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) ); if( IsMirrored() ) msg = _( "Yes" ); else msg = _( "No" ); aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = ::CoordinateToString( GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); }
void ASSISTANT::Text::GetBoundingBox(CRect &rcObject) { int textWidth = (int)m_dWidth; if (textWidth == 0 && text.GetLength() > 0) textWidth = (int)GetTextWidth(text, text.GetLength(), &m_logFont); rcObject.left = (int)m_dX; rcObject.right = (int)(m_dX + textWidth); rcObject.top = (int)(m_dY - fAscent); rcObject.bottom = (int)(m_dY + fDescent); rcObject.NormalizeRect(); }
void ASSISTANT::Text::SetFontUnsupported() { m_bHasSupportedFont = false; // Arial is default font FillLogFont(m_logFont, _T("Arial"), drawSize, fontWeight, fontSlant); fAscent = GetTextAscent(&m_logFont); fDescent = GetTextDescent(&m_logFont); if (!m_bTextWidthIsStatic) if (text.GetLength() > 0) m_dWidth = GetTextWidth(text, text.GetLength(), &m_logFont); else m_dWidth = 0; m_dHeight = fAscent+fDescent; }
void cFont::RenderFontAlpha(WORD wFontIdx, char * text, int size, RECT * pRect, DWORD color) { if(FALSE == IsCreateFont(wFontIdx)) { return; } pRect->right = pRect->left + GetTextExtent( wFontIdx, text, size ) + GetTextWidth( wFontIdx ) / 4; pRect->bottom = pRect->top + GetTextHeight( wFontIdx ) + 1; //+1안하면 밑줄이 안나온다. if(*text) { g_pExecutive->GetGeometry()->RenderFont(m_pFont[wFontIdx],text,size,pRect,color,CHAR_CODE_TYPE_ASCII,0,0); } }
int LIB_TEXT::GetPenSize() const { int pensize = GetThickness(); if( pensize == 0 ) // Use default values for pen size { if( IsBold() ) pensize = GetPenSizeForBold( GetTextWidth() ); else pensize = GetDefaultLineThickness(); } // Clip pen size for small texts: pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() ); return pensize; }
bool SCH_FIELD::Save( FILE* aFile ) const { char hjustify = 'C'; if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) hjustify = 'L'; else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) hjustify = 'R'; char vjustify = 'C'; if( GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) vjustify = 'B'; else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) vjustify = 'T'; if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c", m_id, EscapedUTF8( m_Text ).c_str(), // wraps in quotes too GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', GetTextPos().x, GetTextPos().y, GetTextWidth(), !IsVisible(), hjustify, vjustify, IsItalic() ? 'I' : 'N', IsBold() ? 'B' : 'N' ) == EOF ) { return false; } // Save field name, if the name is user definable if( m_id >= FIELD1 ) { if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF ) { return false; } } if( fprintf( aFile, "\n" ) == EOF ) { return false; } return true; }
wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const { wxPoint text_offset; int width = std::max( GetThickness(), GetDefaultLineThickness() ); int ii = GetTextWidth() + TXT_MARGIN + width; switch( GetLabelSpinStyle() ) { default: case 0: text_offset.x = -ii; break; // Orientation horiz normale case 1: text_offset.y = -ii; break; // Orientation vert UP case 2: text_offset.x = ii; break; // Orientation horiz inverse case 3: text_offset.y = ii; break; // Orientation vert BOTTOM } return text_offset; }
int DrawGLUtils::GetTextWidth(double size, const wxString &text, double factor) { int tsize = size * factor; void *font = nullptr; switch (tsize) { case 10: font = GLUT_BITMAP_HELVETICA_10; break; case 12: font = GLUT_BITMAP_HELVETICA_12; break; case 18: font = GLUT_BITMAP_HELVETICA_18; break; } if (font) { return GetTextWidth(font, text); } return GetStrokedTextWidth(size, text); }
/********************************************************************* * Function: BUTTON *BtnCreate(WORD ID, SHORT left, SHORT top, SHORT right, * SHORT bottom, SHORT radius, void *pBitmap, XCHAR *pText, * GOL_SCHEME *pScheme) * * * Notes: Creates a BUTTON object and adds it to the current active list. * If the creation is successful, the pointer to the created Object * is returned. If not successful, NULL is returned. * ********************************************************************/ BUTTON *BtnCreate( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, SHORT radius, WORD state, void *pBitmap, XCHAR *pText, GOL_SCHEME *pScheme) { BUTTON *pB = NULL; pB = malloc(sizeof(BUTTON)); if (pB == NULL) return NULL; pB->hdr.ID = ID; // unique id assigned for referencing pB->hdr.pNxtObj = NULL; // initialize pointer to NULL pB->hdr.type = OBJ_BUTTON; // set object type pB->hdr.left = left; // left position pB->hdr.top = top; // top position pB->hdr.right = right; // right position pB->hdr.bottom = bottom; // bottom position pB->radius = radius; // radius pB->pBitmap = pBitmap; // location of bitmap pB->pText = pText; // location of the text pB->hdr.state = state; // state // Set the color scheme to be used if (pScheme == NULL) pB->hdr.pGolScheme = _pDefaultGolScheme; else pB->hdr.pGolScheme = (GOL_SCHEME *)pScheme; pB->textWidth = 0; pB->textHeight = 0; if (pB->pText != NULL) { // Calculate the text width & height pB->textWidth = GetTextWidth(pText, pB->hdr.pGolScheme->pFont); pB->textHeight = GetTextHeight(pB->hdr.pGolScheme->pFont); } GOLAddObject((OBJ_HEADER*) pB); #ifdef USE_FOCUS if(GetState(pB,BTN_FOCUSED)) GOLSetFocus((OBJ_HEADER*)pB); #endif return pB; }