void SCH_TEXT::Plot( PLOTTER* aPlotter ) { static std::vector <wxPoint> Poly; COLOR4D color = GetLayerColor( GetLayer() ); int tmp = GetThickness(); int thickness = GetPenSize(); // Two thicknesses are set here: // The first is for EDA_TEXT, which controls the interline spacing based on text thickness // The second is for the output that sets the actual stroke size SetThickness( thickness ); aPlotter->SetCurrentLineWidth( thickness ); if( IsMultilineAllowed() ) { std::vector<wxPoint> positions; wxArrayString strings_list; wxStringSplit( GetShownText(), strings_list, '\n' ); positions.reserve( strings_list.Count() ); GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() ); for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxPoint textpos = positions[ii] + GetSchematicTextOffset(); wxString& txt = strings_list.Item( ii ); aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); } } else { wxPoint textpos = GetTextPos() + GetSchematicTextOffset(); aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); } // Draw graphic symbol for global or hierarchical labels CreateGraphicShape( Poly, GetTextPos() ); aPlotter->SetCurrentLineWidth( GetPenSize() ); if( Poly.size() ) aPlotter->PlotPoly( Poly, NO_FILL ); SetThickness( tmp ); }
void CXTPPopupItem::CalculateHeight() { if (m_pRichRender) { return; } if (m_pUIElement) { XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL); CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width()); m_rcItem.right = m_rcItem.left + sz.cx; m_rcItem.bottom = m_rcItem.top + sz.cy; return; } CXTPImageManagerIcon* pIcon = GetImage(); if (pIcon) { m_rcItem.bottom = m_rcItem.top + pIcon->GetHeight(); return; } CWindowDC dc(NULL); CRect rcText(0, 0, m_rcItem.Width(), 0); CFont fntUnderline; CFont* pFont = GetTextFont(); if (IsHyperLink() && IsUnderline() || IsBold()) { LOGFONT lpLogFont; pFont->GetLogFont(&lpLogFont); lpLogFont.lfUnderline = (IsHyperLink() && IsUnderline()); lpLogFont.lfWeight = IsBold() ? FW_BOLD : FW_NORMAL; VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont)); pFont = &fntUnderline; } CXTPFontDC font(&dc, pFont); dc.DrawText(m_strCaption, rcText, m_nAlign | DT_CALCRECT); m_rcItem.bottom = m_rcItem.top + rcText.Height(); }
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = (int) GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 deg. { if( orient == TEXT_ANGLE_HORIZ ) orient = TEXT_ANGLE_VERT; else orient = TEXT_ANGLE_HORIZ; } EDA_RECT BoundaryBox = GetBoundingBox(); BoundaryBox.RevertYAxis(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset; aPlotter->Text( textpos, GetDefaultColor(), GetShownText(), orient, GetTextSize(), hjustify, vjustify, GetPenSize(), IsItalic(), IsBold() ); }
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const { if(charvalid & BOLD) fmt.Bold(IsBold()); if(charvalid & ITALIC) fmt.Italic(IsItalic()); if(charvalid & UNDERLINE) fmt.Underline(IsUnderline()); if(charvalid & STRIKEOUT) fmt.Strikeout(IsStrikeout()); if(charvalid & NOAA) fmt.NonAntiAliased(IsNonAntiAliased()); if(charvalid & CAPITALS) fmt.capitals = capitals; if(charvalid & DASHED) fmt.dashed = dashed; if(charvalid & SSCRIPT) fmt.sscript = sscript; if(charvalid & FACE) fmt.Face(GetFace()); if(charvalid & HEIGHT) fmt.Height(GetHeight()); if(charvalid & LANGUAGE) fmt.language = language; if(charvalid & INK) fmt.ink = ink; if(charvalid & PAPER) fmt.paper = paper; if(charvalid & LANG) fmt.language = language; if(charvalid & LINK) fmt.link = link; if(charvalid & INDEXENTRY) fmt.indexentry = indexentry; }
// This takes a string and uses it to set the expanded or // collapsed state of the tree items. int CStatisticsTree::ApplyExpandedMask(CString theMask, HTREEITEM theItem, int theStringIndex) { HTREEITEM hCurrent; if (theItem == NULL) { hCurrent = GetRootItem(); SetRedraw(false); ExpandAll(true); m_bExpandingAll = true; } else hCurrent = theItem; while (hCurrent != NULL && theStringIndex < theMask.GetLength()) { if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) { if (theMask.GetAt(theStringIndex) == '0') Expand(hCurrent, TVE_COLLAPSE); theStringIndex++; theStringIndex = ApplyExpandedMask(theMask, GetChildItem(hCurrent), theStringIndex); } hCurrent = GetNextItem(hCurrent, TVGN_NEXT); } if (theItem == NULL) { SetRedraw(true); m_bExpandingAll = true; } return theStringIndex; }
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) { wxASSERT( plotter != NULL ); EDA_RECT bBox = GetBoundingBox(); // convert coordinates from draw Y axis to libedit Y axis bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. */ int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; // Get color COLOR4D color; if( plotter->GetColorMode() ) // Used normal color or selected color color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor(); else color = COLOR4D::BLACK; plotter->Text( pos, color, GetShownText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); }
const EDA_RECT SCH_TEXT::GetBoundingBox() const { // We must pass the effective text thickness to GetTextBox // when calculating the bounding box int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); EDA_RECT rect = GetTextBox( -1, linewidth ); if( GetTextAngle() != 0 ) // Rotate rect { wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); RotatePoint( &pos, GetTextPos(), GetTextAngle() ); RotatePoint( &end, GetTextPos(), GetTextAngle() ); rect.SetOrigin( pos ); rect.SetEnd( end ); } rect.Normalize(); return rect; }
// This returns a string of 1's and 0's indicating // which parent items are expanded. Only saves the // bold items. CString CStatisticsTree::GetExpandedMask(HTREEITEM theItem) { HTREEITEM hCurrent; CString tempMask; tempMask.Empty(); if (theItem == NULL) hCurrent = GetRootItem(); else hCurrent = theItem; while (hCurrent != NULL) { if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) { if (IsExpanded(hCurrent)) tempMask += "1"; if (!IsExpanded(hCurrent)) tempMask += "0"; tempMask += GetExpandedMask(GetChildItem(hCurrent)); } hCurrent = GetNextItem(hCurrent, TVGN_NEXT); } return tempMask; }
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; }
//////////////////////////////////////////////////////////////////// // Public functions // void CDrawField::Draw( int page, CDC* dc ) /* ============================================================ Function : CDrawField::Draw Description : Draws this object. Access : Public Return : void Parameters : int page - Current page CDC* dc - CDC to draw to Usage : Called by the generator to draw the object. ============================================================*/ { CString title = GetTitle(); CDoubleRect rect = GetPosition(); CUnitConversion::InchesToPixels( rect ); CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) ); CUnitConversion::AdjustPixelsToPaper( dc, r ); LOGFONT lf; ZeroMemory( &lf, sizeof( lf ) ); lstrcpy( lf.lfFaceName, GetFontName() ); lf.lfHeight = CUnitConversion::PointsToPixels( static_cast< double >( GetFontSize() ) / 10.0 ); lf.lfItalic = static_cast< BYTE >( GetFontItalic() ); lf.lfUnderline = static_cast< BYTE >( GetFontUnderline() ); lf.lfStrikeOut = static_cast< BYTE >( GetFontStrikeout() ); lf.lfCharSet = static_cast< BYTE >( GetFontCharset() ); if( GetFontBold() ) lf.lfWeight = FW_BOLD; else lf.lfWeight = FW_NORMAL; if( IsBold( title ) ) lf.lfWeight = FW_BOLD; if( IsItalic( title ) ) lf.lfItalic = TRUE; CFont font; font.CreateFontIndirect( &lf ); dc->SelectObject( &font ); int color = dc->SetTextColor( GetFontColor() ); int mode = dc->SetBkMode( TRANSPARENT ); int justification = GetJustification(); ReplaceFields( page, title ); dc->DrawText( title, r, DT_NOPREFIX | DT_WORDBREAK | justification ); dc->SetBkMode( mode ); dc->SetTextColor( color ); dc->SelectStockObject( ANSI_VAR_FONT ); }
void RichTxt::FormatInfo::Combine(const RichPara::CharFormat& fmt) { if(IsBold() != fmt.IsBold()) { charvalid &= ~BOLD; NoBold(); } if(IsItalic() != fmt.IsItalic()) { charvalid &= ~ITALIC; NoItalic(); } if(IsUnderline() != fmt.IsUnderline()) { charvalid &= ~UNDERLINE; NoUnderline(); } if(IsStrikeout() != fmt.IsStrikeout()) { charvalid &= ~STRIKEOUT; NoStrikeout(); } if(IsNonAntiAliased() != fmt.IsNonAntiAliased()) { charvalid &= ~NOAA; NoNonAntiAliased(); } if(capitals != fmt.capitals) { charvalid &= ~CAPITALS; capitals = false; } if(dashed != fmt.dashed) { charvalid &= ~DASHED; dashed = false; } if(sscript != fmt.sscript) { charvalid &= ~SSCRIPT; sscript = 0; } if(GetFace() != fmt.GetFace()) charvalid &= ~FACE; if(GetHeight() != fmt.GetHeight()) charvalid &= ~HEIGHT; if(ink != fmt.ink) { charvalid &= ~INK; ink = Null; } if(paper != fmt.paper) { charvalid &= ~PAPER; paper = Null; } if(language != fmt.language) { charvalid &= ~LANG; language = 0; } if(link != fmt.link) { charvalid &= ~LINK; link = Null; } if(indexentry != fmt.indexentry) { charvalid &= ~INDEXENTRY; indexentry = Null; } }
void ExtTreeRow::GetDisplayText(int column, CString& rstrBuffer, bool& bold_font) const { bold_font = false; GetColumn(column, rstrBuffer); if (IsBold()) bold_font = true; }
void SCH_FIELD::Plot( PLOTTER* aPlotter ) { SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent(); wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T, wxT( "Cannot plot field with invalid parent." ) ); COLOR4D color = GetLayerColor( GetLayer() ); if( !IsVisible() ) return; if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = GetTextAngle(); if( parent->GetTransform().y1 ) // Rotate component 90 deg. { if( orient == TEXT_ANGLE_HORIZ ) orient = TEXT_ANGLE_VERT; else orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component * orientation/mirror * this is a bit complicated due to cumulative calculations: * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H justifications * according to the text orientation. * - When a component is mirrored, the text is not mirrored and * justifications are complicated to calculate * so the more easily way is to use no justifications ( Centered text ) * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT BoundaryBox = GetBoundingBox(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = BoundaryBox.Centre(); int thickness = GetPenSize(); aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), hjustify, vjustify, thickness, IsItalic(), IsBold() ); }
// This is the primary function for generating HTML output of the statistics tree. // It is recursive. CString CStatisticsTree::GetHTML(bool onlyVisible, HTREEITEM theItem, int theItemLevel, bool firstItem) { HTREEITEM hCurrent; if (theItem == NULL) { if (!onlyVisible) theApp.emuledlg->statisticswnd->ShowStatistics(true); hCurrent = GetRootItem(); // Copy All Vis or Copy All } else hCurrent = theItem; CString strBuffer; if (firstItem) //Xman // Maella -Support for tag ET_MOD_VERSION 0x55 /* strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick()); */ // ==> ModID [itsonlyme/SiRoB] - Stulle /* strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong + _T(" ") + MOD_VERSION, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick()); */ strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s [%s] %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong, theApp.m_strModLongVersion, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick()); // <== ModID [itsonlyme/SiRoB] - Stulle //Xman end while (hCurrent != NULL) { CString strItem; if (IsBold(hCurrent)) strItem = _T("<b>") + GetItemText(hCurrent) + _T("</b>"); else strItem = GetItemText(hCurrent); for (int i = 0; i < theItemLevel; i++) strBuffer += _T(" "); if (theItemLevel == 0) strBuffer.Append(_T("\n")); strBuffer += strItem + _T("<br />"); if (ItemHasChildren(hCurrent) && (!onlyVisible || IsExpanded(hCurrent))) strBuffer += GetHTML(onlyVisible, GetChildItem(hCurrent), theItemLevel+1, false); hCurrent = GetNextItem(hCurrent, TVGN_NEXT); if (firstItem && theItem != NULL) break; // Copy Selected Branch was used, so we don't want to copy all branches at this level. Only the one that was selected. } if (firstItem) strBuffer += _T("</font>"); return strBuffer; }
void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) { COLOR4D color = GetLayerColor( m_Layer ); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); int savedWidth = GetThickness(); SetThickness( linewidth ); // Set the minimum width EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); SetThickness( savedWidth ); }
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; }
const EDA_RECT SCH_FIELD::GetBoundingBox() const { SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); // We must pass the effective text thickness to GetTextBox // when calculating the bounding box linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); // Calculate the text bounding box: EDA_RECT rect; if( m_id == REFERENCE ) // multi units have one letter or more added to reference { SCH_FIELD text( *this ); // Make a local copy to change text // because GetBoundingBox() is const text.SetText( GetFullyQualifiedText() ); rect = text.GetTextBox( -1, linewidth ); } else rect = GetTextBox( -1, linewidth ); // Calculate the bounding box position relative to the component: wxPoint origin = parentComponent->GetPosition(); wxPoint pos = GetTextPos() - origin; wxPoint begin = rect.GetOrigin() - origin; wxPoint end = rect.GetEnd() - origin; RotatePoint( &begin, pos, GetTextAngle() ); RotatePoint( &end, pos, GetTextAngle() ); // Due to the Y axis direction, we must mirror the bounding box, // relative to the text position: MIRROR( begin.y, pos.y ); MIRROR( end.y, pos.y ); // Now, apply the component transform (mirror/rot) begin = parentComponent->GetTransform().TransformCoordinate( begin ); end = parentComponent->GetTransform().TransformCoordinate( end ); rect.SetOrigin( begin); rect.SetEnd( end); rect.Move( origin ); rect.Normalize(); return rect; }
int CRedlineObject::DrawObject(HDC hDC, LPRECT lpRect, bool bSelected) { int iSavedDC = ::SaveDC(hDC); long lOldColor = ::GetTextColor(hDC); long lOldBkColor = ::GetBkColor(hDC); long lNewColor = SetNewTextColor(hDC, bSelected); HFONT hSelectedFont = MakeFontBold(m_pFont->GetFontHandle(), IsBold()); HFONT hOldFont = (HFONT)::SelectObject(hDC, hSelectedFont); long lTextWidth = GetTextRectWidth(hDC, m_sText); int nOldBKMode = TRANSPARENT; if (m_pFont->GetTextBackColor() != -1) { nOldBKMode = ::GetBkMode(hDC); ::SetBkMode(hDC, OPAQUE); } ::DrawText(hDC, m_sText, (x64_int_cast)m_sText.length(), lpRect, DT_NOPREFIX | DT_LEFT | DT_VCENTER); if (m_pFont->GetTextBackColor() != -1) { ::SetBkMode(hDC, nOldBKMode); } DrawUnderline(hDC, lpRect, lTextWidth, lNewColor, m_pFont->IsDoubleUnderline(), bSelected); ::SelectObject(hDC, hOldFont); ::SetTextColor(hDC, lOldColor); ::SetBkColor(hDC, lOldBkColor); if(hSelectedFont) ::DeleteObject(hSelectedFont); ::RestoreDC(hDC, iSavedDC); return lTextWidth; }
void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) { static std::vector <wxPoint> Poly; COLOR4D color = GetLayerColor( m_Layer ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); int save_width = GetThickness(); SetThickness( linewidth ); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); SetThickness( save_width ); // restore initial value CreateGraphicShape( Poly, GetTextPos() + aOffset ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); }
void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { wxPoint text_pos; COLOR4D color = IsVisible() ? GetDefaultColor() : GetInvisibleItemColor(); int linewidth = GetPenSize(); text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset; wxString text; if( aData ) text = *(wxString*)aData; else text = m_Text; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; DrawGraphicText( clipbox, aDC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(), GetVertJustify(), linewidth, IsItalic(), IsBold() ); }
void CFontDialog::GetCharFormat(CHARFORMAT& cf) const { USES_CONVERSION; cf.dwEffects = 0; cf.dwMask = 0; if ((m_cf.Flags & CF_NOSTYLESEL) == 0) { cf.dwMask |= CFM_BOLD | CFM_ITALIC; cf.dwEffects |= (IsBold()) ? CFE_BOLD : 0; cf.dwEffects |= (IsItalic()) ? CFE_ITALIC : 0; } if ((m_cf.Flags & CF_NOSIZESEL) == 0) { cf.dwMask |= CFM_SIZE; //GetSize() returns in tenths of points so mulitply by 2 to get twips cf.yHeight = GetSize()*2; } if ((m_cf.Flags & CF_NOFACESEL) == 0) { cf.dwMask |= CFM_FACE; cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily; lstrcpyA(cf.szFaceName, T2A((LPTSTR)(LPCTSTR)GetFaceName())); } if (m_cf.Flags & CF_EFFECTS) { cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR; cf.dwEffects |= (IsUnderline()) ? CFE_UNDERLINE : 0; cf.dwEffects |= (IsStrikeOut()) ? CFE_STRIKEOUT : 0; cf.crTextColor = GetColor(); } if ((m_cf.Flags & CF_NOSCRIPTSEL) == 0) { cf.bCharSet = m_cf.lpLogFont->lfCharSet; cf.dwMask |= CFM_CHARSET; } cf.yOffset = 0; }
void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize() { m_ConstrainedTextSize = m_TextSize; if( m_ConstrainedTextSize.x == 0 ) m_ConstrainedTextSize.x = m_DefaultTextSize.x; if( m_ConstrainedTextSize.y == 0 ) m_ConstrainedTextSize.y = m_DefaultTextSize.y; if( m_BoundingBoxSize.x || m_BoundingBoxSize.y ) { int linewidth = 0; // to know the X and Y size of the line, we should use // EDA_TEXT::GetTextBox() // but this function uses integers // So, to avoid truncations with our unit in mm, use microns. wxSize size_micron; size_micron.x = KiROUND( m_ConstrainedTextSize.x * 1000.0 ); size_micron.y = KiROUND( m_ConstrainedTextSize.y * 1000.0 ); WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText, wxPoint(0,0), size_micron, linewidth, BLACK, IsItalic(), IsBold() ) ); dummy.SetMultilineAllowed( true ); TransfertSetupToGraphicText( &dummy ); EDA_RECT rect = dummy.GetTextBox(); DSIZE size; size.x = rect.GetWidth() / 1000.0; size.y = rect.GetHeight() / 1000.0; if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x ) m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x; if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y ) m_ConstrainedTextSize.y *= m_BoundingBoxSize.y / size.y; } }
// Expand all the tree sections. Recursive. // Can also expand only bold items (Main Sections) void CStatisticsTree::ExpandAll(bool onlyBold, HTREEITEM theItem) { HTREEITEM hCurrent; if (theItem == NULL) { if (onlyBold) CollapseAll(); hCurrent = GetRootItem(); m_bExpandingAll = true; } else hCurrent = theItem; while (hCurrent != NULL) { if (ItemHasChildren(hCurrent) && (!onlyBold || IsBold(hCurrent))) { Expand(hCurrent, TVE_EXPAND); ExpandAll(onlyBold, GetChildItem(hCurrent)); } hCurrent = GetNextItem(hCurrent, TVGN_NEXT); } if (theItem == NULL) m_bExpandingAll = false; }
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const { wxPoint text_offset; int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() ); int halfSize = GetTextWidth() / 2; int offset = width; switch( m_shape ) { case NET_INPUT: case NET_BIDI: case NET_TRISTATE: offset += halfSize; break; case NET_OUTPUT: case NET_UNSPECIFIED: offset += TXT_MARGIN; break; default: break; } switch( GetLabelSpinStyle() ) { default: case 0: text_offset.x -= offset; break; // Orientation horiz normal case 1: text_offset.y -= offset; break; // Orientation vert UP case 2: text_offset.x += offset; break; // Orientation horiz inverse case 3: text_offset.y += offset; break; // Orientation vert BOTTOM } return text_offset; }
//---------------------------------------------------------------------------------------- void PgmCtrl::OnSelChanged(wxMouseEvent& WXUNUSED(event)) { int i; Temp0.Empty(); Temp1.Empty(); #if wxUSE_STATUSBAR pDoc->p_MainFrame->SetStatusText(Temp0,0); #endif // wxUSE_STATUSBAR // Get the Information that we need wxTreeItemId itemId = GetSelection(); TreeData *item = (TreeData *)GetItemData(itemId); if (item != NULL ) { int Treffer = 0; Temp1.Printf(_T("%s"),item->m_desc.c_str()); //-------------------------------------------------------------------------------------- if (Temp1 == _T("Language English")) { Temp0 = _T("std"); p_ProgramCfg->Write(_T("/Local/langid"),Temp0); Temp0 = _("-I-> After a programm restart, the language will be changed to English."); wxMessageBox(Temp0); } if (Temp1 == _T("Language German")) { Temp0 = _T("de"); p_ProgramCfg->Write(_T("/Local/langid"),Temp0); Temp0 = _("-I-> After a programm restart, the language will be changed to German."); wxMessageBox(Temp0); } //-------------------------------------------------------------------------------------- if (Temp1 == _T("wxConfigBase Delete")) { if (p_ProgramCfg->DeleteAll()) // Default Diretory for wxFileSelector Temp0 = _("-I-> wxConfigBase.p_ProgramCfg->DeleteAll() was successful."); else Temp0 = _("-E-> wxConfigBase.p_ProgramCfg->DeleteAll() was not successful !"); wxBell(); // Ding_a_Ling Treffer++; } //-------------------------------------------------------------------------------------- if (Temp1.Contains(_T("ODBC-"))) { Temp1 = Temp1.Mid(5,wxSTRING_MAXLEN); for (i=0;i<pDoc->i_DSN;i++) { if (Temp1 == (pDoc->p_DSN+i)->Dsn) { pDoc->OnChosenDSN(i); } } Treffer++; } //-------------------------------------------------------------------------------------- if (Treffer == 0) { //------------------------------------------------------------------------------------- Temp0.Printf(_("Item '%s': %sselected, %sexpanded, %sbold, %u children (%u immediately under this item)."), item->m_desc.c_str(), bool2String(IsSelected(itemId)), bool2String(IsExpanded(itemId)), bool2String(IsBold(itemId)), GetChildrenCount(itemId), GetChildrenCount(itemId)); LogBuf.Printf(_T("-I-> PgmCtrl::OnSelChanged - %s"),Temp0.c_str()); wxLogMessage( _T("%s"), LogBuf.c_str() ); //------------------------------------------------------------------------------------- } } }
void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { COLOR4D color = GetDefaultColor(); if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } GRSetDrawMode( aDC, aDrawMode ); /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ int orient = GetTextAngle(); if( aTransform.y1 ) // Rotate component 90 degrees. { if( orient == TEXT_ANGLE_HORIZ ) orient = TEXT_ANGLE_VERT; else orient = TEXT_ANGLE_HORIZ; } /* Calculate the text justification, according to the component * orientation/mirror this is a bit complicated due to cumulative * calculations: * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H justifications * according to the text orientation. * - When a component is mirrored, the text is not mirrored and * justifications are complicated to calculate * so the more easily way is to use no justifications ( Centered text ) * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT bBox = GetBoundingBox(); // convert coordinates from draw Y axis to libedit Y axis: bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); // Calculate pos according to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ #if 0 // bBox already uses libedit Y axis. bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; switch( Type() ) { case SCH_TEXT_T: msg = _( "Graphic Text" ); break; case SCH_LABEL_T: msg = _( "Label" ); break; case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" ); break; case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; default: return; } aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) ); switch( GetLabelSpinStyle() ) { case 0: msg = _( "Horizontal" ); break; case 1: msg = _( "Vertical up" ); break; case 2: msg = _( "Horizontal invert" ); break; case 3: msg = _( "Vertical down" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) ); wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = 0; if( IsItalic() ) style = 1; if( IsBold() ) style += 2; aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); // Display electricat type if it is relevant if( (Type() == SCH_GLOBAL_LABEL_T) || (Type() == SCH_HIERARCHICAL_LABEL_T ) || (Type() == SCH_SHEET_PIN_T ) ) { switch( GetShape() ) { case NET_INPUT: msg = _( "Input" ); break; case NET_OUTPUT: msg = _( "Output" ); break; case NET_BIDI: msg = _( "Bidirectional" ); break; case NET_TRISTATE: msg = _( "Tri-State" ); break; case NET_UNSPECIFIED: msg = _( "Passive" ); break; default: msg = wxT( "???" ); break; } aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) ); } // Display text size (X or Y value, with are the same value in Eeschema) msg = MessageTextFromValue( aUnits, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); #if defined(DEBUG) if( auto conn = Connection( *g_CurrentSheet ) ) { conn->AppendDebugInfoToMsgPanel( aList ); } msg.Printf( "%p", this ); aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) ); #endif }
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { if( aPanel == NULL ) return; /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); BOARD* brd = GetBoard( ); auto frame = static_cast<PCB_BASE_FRAME*> ( aPanel->GetParent() ); auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); PCB_LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) ) || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) ) return; if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "%R" ) ) return; if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "%V" ) ) return; // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) if( !IsVisible() ) { if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) ) return; color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); } auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() ); // shade text if high contrast mode is active if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; if( !IsOnLayer( curr_layer ) ) color = COLOR4D( DARKDARKGRAY ); } // Draw mode compensation for the width int width = GetThickness(); if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = GetTextPos() - aOffset; // Draw the text anchor point if( brd->IsElementVisible( LAYER_ANCHOR ) ) { COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ); GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } // Draw the text proper, with the right attributes wxSize size = GetTextSize(); double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) if( IsMirrored() ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, size, GetHorizJustify(), GetVertJustify(), width, IsItalic(), IsBold() ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); } #endif }
void wxSTEditorTreeCtrl::UpdateFromNotebook() { wxSTERecursionGuard guard(m_rGuard_UpdateFromNotebook); if (guard.IsInside()) return; wxSTEditorNotebook *noteBook = GetSTEditorNotebook(); if (!noteBook) return; int n; int page_count = noteBook->GetPageCount(); int note_sel = noteBook->GetSelection(); wxTreeItemId id, selId; // Check for and add a root item to the treectrl, it's hidden wxTreeItemId rootId = GetRootItem(); if (!rootId) rootId = AddRoot(_("Root"), -1, -1, NULL); // Check for and add a "Opened files" item to the treectrl wxArrayString openedfilesPath; openedfilesPath.Add(_("Opened files")); wxTreeItemId openedId = FindOrInsertItem(openedfilesPath, STE_TREECTRL_FIND_OR_INSERT); wxLongToLongHashMap windowToSTETreeItemDataMap = m_windowToSTETreeItemDataMap; Freeze(); for (n = 0; n < page_count; n++) { id = wxTreeItemId(); // start fresh wxSTEditor* editor = noteBook->GetEditor(n); wxWindow* notePage = noteBook->GetPage(n); wxSTETreeItemData* steTreeItemData = NULL; // If this editor was already added to the tree, check if it's still correct if (editor && editor->GetTreeItemData()) { // get and check the old tree item id, the filename/path could have changed steTreeItemData = editor->GetTreeItemData(); if (steTreeItemData) id = steTreeItemData->m_id; if (steTreeItemData) { if ((steTreeItemData->m_notePage == notePage) && (steTreeItemData->m_fileName == editor->GetFileName())) { // the page didn't change name, but do resync page number steTreeItemData->m_page_num = n; windowToSTETreeItemDataMap.erase((long)notePage); } else steTreeItemData = NULL; } // Something changed, redo it if (id && !steTreeItemData) { // Erase refs to this page, we will recreate it m_windowToSTETreeItemDataMap.erase((long)notePage); windowToSTETreeItemDataMap.erase((long)notePage); DeleteItem(id, true, -1, openedId); // null it and add it correctly later id = wxTreeItemId(); editor->SetTreeItemData(NULL); } } bool modified = editor->IsModified(); if (!id) { // Create new data to add to the wxTreeItem steTreeItemData = new wxSTETreeItemData(n, notePage); // Only connect the destroy handler once if (m_windowDestroyMap.find((long)notePage) == m_windowDestroyMap.end()) { m_windowDestroyMap[(long)notePage] = 1; notePage->Connect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); } if (editor) { modified = editor->IsModified(); steTreeItemData->m_root = _("Opened files"); steTreeItemData->m_fileName = editor->GetFileName(); wxFileName fn(steTreeItemData->m_fileName); // Don't need to Normalize() since it is done in wxSTEditor::SetFilename() //if (fn.FileExists()) fn.Normalize(); switch (m_display_type) { case SHOW_FILENAME_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_FILEPATH_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullPath()); break; } case SHOW_PATH_THEN_FILENAME : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetPath()); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_ALL_PATHS : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); wxArrayString dirs = fn.GetDirs(); for (size_t i = 0; i < dirs.GetCount(); ++i) steTreeItemData->m_treePath.Add(dirs[i]); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } } } else { steTreeItemData->m_root = _("Others"); steTreeItemData->m_fileName = noteBook->GetPageText(n); steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(steTreeItemData->m_fileName.GetFullPath()); } // Always insert a new editor since if we already did, it'd have a treeitem id. // For other windows, who knows, you can only have one tree node per notebook page name if (editor) { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_EDITOR); editor->SetTreeItemData(steTreeItemData); steTreeItemData->m_steRefData = editor->GetSTERefData(); } else { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_FIND_OR_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_OTHER); } // must set new data before deleting old in MSW since it checks old before setting new wxTreeItemData* oldData = GetItemData(id); steTreeItemData->m_id = id; SetItemData(id, steTreeItemData); if (oldData) delete oldData; m_windowToSTETreeItemDataMap[(long)notePage] = (long)steTreeItemData; } // we should have valid id at this point if (n == note_sel) selId = id; else if (IsBold(id)) SetItemBold(id, false); SetItemTextColour(id, modified ? *wxRED : *wxBLACK); } wxLongToLongHashMap::iterator it; for( it = windowToSTETreeItemDataMap.begin(); it != windowToSTETreeItemDataMap.end(); ++it ) { wxSTETreeItemData* oldData = (wxSTETreeItemData*)it->second; DeleteItem(oldData->m_id, true, -1, openedId); m_windowToSTETreeItemDataMap.erase(it->first); } if (selId) { SetItemBold(selId); SelectItem(selId); } SortAllChildren(GetRootItem()); Thaw(); }
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos ) { int halfSize = GetTextHeight() / 2; int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); aPoints.clear(); int symb_len = LenSize( GetShownText(), linewidth ) + ( TXT_MARGIN * 2 ); // Create outline shape : 6 points int x = symb_len + linewidth + 3; // Use negation bar Y position to calculate full vertical size // Search for overbar symbol bool hasOverBar = false; for( unsigned ii = 1; ii < m_Text.size(); ii++ ) { if( m_Text[ii-1] == '~' && m_Text[ii] != '~' ) { hasOverBar = true; break; } } #define Y_CORRECTION 1.40 // Note: this factor is due to the fact the Y size of a few letters like [ // are bigger than the y size value, and we need a margin for the graphic symbol. int y = KiROUND( halfSize * Y_CORRECTION ); // Note: this factor is due to the fact we need a margin for the graphic symbol. #define Y_OVERBAR_CORRECTION 1.2 if( hasOverBar ) y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth ) * Y_OVERBAR_CORRECTION ); // Gives room for line thickess and margin y += linewidth // for line thickess + linewidth/2; // for margin // Starting point(anchor) aPoints.push_back( wxPoint( 0, 0 ) ); aPoints.push_back( wxPoint( 0, -y ) ); // Up aPoints.push_back( wxPoint( -x, -y ) ); // left aPoints.push_back( wxPoint( -x, 0 ) ); // Up left aPoints.push_back( wxPoint( -x, y ) ); // left down aPoints.push_back( wxPoint( 0, y ) ); // down int x_offset = 0; switch( m_shape ) { case NET_INPUT: x_offset = -halfSize; aPoints[0].x += halfSize; break; case NET_OUTPUT: aPoints[3].x -= halfSize; break; case NET_BIDI: case NET_TRISTATE: x_offset = -halfSize; aPoints[0].x += halfSize; aPoints[3].x -= halfSize; break; case NET_UNSPECIFIED: default: break; } int angle = 0; switch( GetLabelSpinStyle() ) { default: case 0: break; // Orientation horiz normal case 1: angle = -900; break; // Orientation vert UP case 2: angle = 1800; break; // Orientation horiz inverse case 3: angle = 900; break; // Orientation vert BOTTOM } // Rotate outlines and move corners in real position for( wxPoint& aPoint : aPoints ) { aPoint.x += x_offset; if( angle ) RotatePoint( &aPoint, angle ); aPoint += Pos; } aPoints.push_back( aPoints[0] ); // closing }