eeschema: Fix cutoff text in pinmap
Ensure the proper bounding box is used when computing the amount of space taken by angled text in the control. Fixes https://gitlab.com/kicad/code/kicad/issues/4761
This commit is contained in:
parent
f481be3358
commit
c6eb072726
|
@ -35,8 +35,12 @@ WX_ANGLE_TEXT::WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString&
|
||||||
font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller
|
font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller
|
||||||
SetFont( font );
|
SetFont( font );
|
||||||
|
|
||||||
wxPoint pos = GetPosition();
|
// Measure the size of the text
|
||||||
wxSize size = GetTextExtent( m_label );
|
wxClientDC dc( this );
|
||||||
|
dc.SetFont( font );
|
||||||
|
|
||||||
|
wxSize size = dc.GetTextExtent( m_label );
|
||||||
|
wxPoint pos = GetPosition();
|
||||||
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||||
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
||||||
|
|
||||||
|
@ -66,7 +70,7 @@ void WX_ANGLE_TEXT::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
|
dc.SetTextForeground( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
|
||||||
dc.SetTextBackground( wxTransparentColor );
|
dc.SetTextBackground( wxTransparentColor );
|
||||||
|
|
||||||
wxSize size = GetTextExtent( m_label );
|
wxSize size = dc.GetTextExtent( m_label );
|
||||||
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||||
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
||||||
wxPoint pos( 0, -bbox.GetTop() );
|
wxPoint pos( 0, -bbox.GetTop() );
|
||||||
|
@ -75,3 +79,18 @@ void WX_ANGLE_TEXT::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EDA_RECT WX_ANGLE_TEXT::GetBoundingBox( wxWindow* aWindow, const wxString& aLabel, double aAngle )
|
||||||
|
{
|
||||||
|
// Create the font used for the text
|
||||||
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||||
|
font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller
|
||||||
|
|
||||||
|
// Measure the size of the text
|
||||||
|
wxClientDC dc( aWindow );
|
||||||
|
dc.SetFont( font );
|
||||||
|
|
||||||
|
wxSize size = dc.GetTextExtent( aLabel );
|
||||||
|
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||||
|
|
||||||
|
return rect.GetBoundingBoxRotated( rect.GetPosition(), aAngle );
|
||||||
|
}
|
||||||
|
|
|
@ -24,15 +24,26 @@
|
||||||
#ifndef _WX_ANGLE_TEXT_
|
#ifndef _WX_ANGLE_TEXT_
|
||||||
#define _WX_ANGLE_TEXT_
|
#define _WX_ANGLE_TEXT_
|
||||||
|
|
||||||
|
#include <eda_rect.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WX_ANGLE_TEXT : public wxPanel
|
class WX_ANGLE_TEXT : public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
|
WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
|
||||||
const wxPoint& aPos, double aAngle );
|
const wxPoint& aPos, double aAngle );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bounding box that this angled text will take up on a certain window.
|
||||||
|
*
|
||||||
|
* @param aWindow is the wxWindow the text will go on
|
||||||
|
* @param aLabel is the text string
|
||||||
|
* @param aAngle is the angle of the text
|
||||||
|
*/
|
||||||
|
static EDA_RECT GetBoundingBox( wxWindow* aWindow, const wxString& aLabel, double aAngle );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnEraseBackground( wxEraseEvent& WXUNUSED( aEvent ) );
|
void OnEraseBackground( wxEraseEvent& WXUNUSED( aEvent ) );
|
||||||
void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||||
|
|
|
@ -83,14 +83,15 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
// Get the current text size using a dummy text.
|
// Get the current text size using a dummy text.
|
||||||
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[0], pos );
|
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[0], pos );
|
||||||
int text_width = text->GetRect().GetWidth();
|
EDA_RECT bbox = WX_ANGLE_TEXT::GetBoundingBox( m_matrixPanel, CommentERC_V[0], 450 );
|
||||||
|
|
||||||
int text_height = text->GetRect().GetHeight();
|
int text_height = text->GetRect().GetHeight();
|
||||||
|
|
||||||
bitmap_size.y = std::max( bitmap_size.y, text_height );
|
bitmap_size.y = std::max( bitmap_size.y, text_height );
|
||||||
delete text;
|
delete text;
|
||||||
|
|
||||||
// compute the Y pos interval:
|
// compute the Y pos interval:
|
||||||
pos.y = text_height + ( text_width / 2 );
|
pos.y = bbox.GetHeight();
|
||||||
|
|
||||||
if( !m_initialized )
|
if( !m_initialized )
|
||||||
{
|
{
|
||||||
|
@ -101,7 +102,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
||||||
{
|
{
|
||||||
int y = pos.y + (ii * bitmap_size.y);
|
int y = pos.y + (ii * bitmap_size.y);
|
||||||
text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
|
text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
|
||||||
wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) );
|
wxPoint( 5, y + ( bitmap_size.y / 2 ) - ( text_height / 2 ) ) );
|
||||||
labels.push_back( text );
|
labels.push_back( text );
|
||||||
|
|
||||||
int x = text->GetRect().GetRight();
|
int x = text->GetRect().GetRight();
|
||||||
|
|
Loading…
Reference in New Issue