minot changes

This commit is contained in:
charras 2009-05-29 07:29:55 +00:00
parent 866d5c3ab1
commit d3dc65b656
4 changed files with 14 additions and 15 deletions

View File

@ -193,7 +193,7 @@ EDA_TextStruct::~EDA_TextStruct()
*/ */
int EDA_TextStruct::LenSize( const wxString& aLine ) const int EDA_TextStruct::LenSize( const wxString& aLine ) const
{ {
return TextWidth(aLine, m_Size.x, m_Italic, m_Bold ) + m_Width; return ReturnGraphicTextWidth(aLine, m_Size.x, m_Italic, m_Bold ) + m_Width;
} }

View File

@ -20,7 +20,7 @@
#define EDA_DRAWBASE #define EDA_DRAWBASE
#include "hershey_fonts.h" #include "hershey_fonts.h"
#define HERSHEY_SIZE 32.0 #define HERSHEY_SIZE 32.0 // size factor used to calculate actual size of shapes from hershey fonts
/* Functions to draw / plot a string. /* Functions to draw / plot a string.
* texts have only one line. * texts have only one line.
@ -67,7 +67,7 @@ static const char* get_hershey_recipe( int AsciiCode, bool bold )
} }
int TextWidth( const wxString& aText, int size_h, bool italic, bool bold ) int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool bold )
{ {
int tally = 0; int tally = 0;
int char_count = aText.length(); int char_count = aText.length();
@ -85,13 +85,13 @@ int TextWidth( const wxString& aText, int size_h, bool italic, bool bold )
/* Get metrics */ /* Get metrics */
int xsta = *ptcar++ - 'R'; int xsta = *ptcar++ - 'R';
int xsto = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R';
tally += wxRound( size_h * (xsto - xsta) / HERSHEY_SIZE ); tally += wxRound( aXSize * (xsto - xsta) / HERSHEY_SIZE );
} }
/* Italic correction, 1/8em */ /* Italic correction, 1/8em */
if( italic ) if( italic )
{ {
tally += wxRound( size_h * 0.125 ); tally += wxRound( aXSize * 0.125 );
} }
return tally; return tally;
} }
@ -130,7 +130,7 @@ static void DrawGraphicTextPline(
static int overbar_position( int size_v, int thickness ) static int overbar_position( int size_v, int thickness )
{ {
return wxRound( (double) size_v * 30.0 / HERSHEY_SIZE + (double) thickness ); return wxRound( ((double) size_v * 26/HERSHEY_SIZE ) + ((double) thickness * 1.5) );
} }
@ -228,7 +228,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
current_char_pos = aPos; current_char_pos = aPos;
dx = TextWidth( aText, size_h, aItalic, aBold ); dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aBold );
dy = size_v; dy = size_v;
/* Do not draw the text if out of draw area! */ /* Do not draw the text if out of draw area! */

View File

@ -456,7 +456,6 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
int x, y, x1, y1; int x, y, x1, y1;
wxString StringPinNum; wxString StringPinNum;
EDA_Colors NameColor, NumColor; EDA_Colors NameColor, NumColor;
int PinTxtLen;
wxSize PinNameSize( m_PinNameSize, m_PinNameSize ); wxSize PinNameSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize( m_PinNumSize, m_PinNumSize ); wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
@ -491,9 +490,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
x1 += m_PinLen; break; x1 += m_PinLen; break;
} }
PinTxtLen = TextWidth( m_PinName, PinNameSize.x, false, false) + LineWidth; if( m_PinName.IsEmpty() )
if( PinTxtLen == 0 )
DrawPinName = FALSE; DrawPinName = FALSE;
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
@ -658,7 +655,6 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
int x, y, x1, y1; int x, y, x1, y1;
wxString StringPinNum; wxString StringPinNum;
EDA_Colors NameColor, NumColor; EDA_Colors NameColor, NumColor;
int PinTxtLen = 0;
wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize ); wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize ); wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize );
bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST)
@ -687,8 +683,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
x1 += m_PinLen; break; x1 += m_PinLen; break;
} }
PinTxtLen = TextWidth( m_PinName, PinNameSize.x, false, false) + aWidth; if( m_PinName.IsEmpty() )
if( PinTxtLen == 0 )
DrawPinName = FALSE; DrawPinName = FALSE;
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */ if( TextInside ) /* Draw the text inside, but the pin numbers outside. */

View File

@ -9,7 +9,11 @@
class WinEDA_DrawPanel; class WinEDA_DrawPanel;
int TextWidth(const wxString& aText, int size_h, bool italic, bool bold ); /** Function ReturnGraphicTextWidth
* @return the X size of the graphic text
* the full X size is ReturnGraphicTextWidth + the thickness of graphic lines
*/
int ReturnGraphicTextWidth(const wxString& aText, int size_h, bool italic, bool bold );
/** Function NegableTextLength /** Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */ * Return the text length of a negable string, excluding the ~ markers */