Commit 348cfa79 authored by charras's avatar charras

More about italic and bold texts options in fields and graphic texts + code cleanup

parent f08585f9
......@@ -6,6 +6,12 @@ Please add newer entries at the top, list the date and your name with
email address.
2008-Dec-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++Eeschema:
More about italic and bold texts options in fields and graphic texts
2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++Pcbnew:
......
......@@ -32,6 +32,7 @@ set(EESCHEMA_SRCS
delete.cpp
delsheet.cpp
# dialog_backanno.cpp
dialog_bodygraphictext_properties_base.cpp
dialog_build_BOM.cpp
# dialog_cmp_graphic_properties.cpp
dialog_create_component.cpp
......@@ -94,7 +95,7 @@ set(EESCHEMA_SRCS
sheetlab.cpp
symbdraw.cpp
symbedit.cpp
symbtext.cpp
edit_graphic_bodyitem_text.cpp
tool_lib.cpp
tool_sch.cpp
tool_viewlib.cpp
......
......@@ -126,6 +126,7 @@ void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame )
*/
{
wxString msg;
int thickness = 0;
frame->MsgPanel->EraseMsgBox();
......@@ -135,21 +136,27 @@ void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame )
switch( Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
thickness = ( (LibDrawArc*) this )->m_Width;
msg = wxT( "Arc" ); break;
case COMPONENT_CIRCLE_DRAW_TYPE:
thickness = ( (LibDrawCircle*) this )->m_Width;
msg = wxT( "Circle" ); break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
thickness = ( (LibDrawText*) this )->m_Width;
msg = wxT( "Text" ); break;
case COMPONENT_RECT_DRAW_TYPE:
thickness = ( (LibDrawSquare*) this )->m_Width;
msg = wxT( "Rect" ); break;
case COMPONENT_POLYLINE_DRAW_TYPE:
thickness = ( (LibDrawPolyline*) this )->m_Width;
msg = wxT( "PolyLine" ); break;
case COMPONENT_LINE_DRAW_TYPE:
thickness = ( (LibDrawSegment*) this )->m_Width;
msg = wxT( "Segment" ); break;
case COMPONENT_PIN_DRAW_TYPE:
......@@ -181,9 +188,9 @@ void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame )
msg = wxT( "?" );
Affiche_1_Parametre( frame, 14, _( "Convert" ), msg, BROWN );
if( m_Width )
msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true );
if( thickness )
msg = ReturnStringFromValue( g_UnitMetric, thickness, EESCHEMA_INTERNAL_UNIT, true );
else
msg = _( "default" );
Affiche_1_Parametre( frame, 20, _( "Width" ), msg, BLUE );
Affiche_1_Parametre( frame, 20, _( "Thickness" ), msg, BLUE );
}
......@@ -12,11 +12,6 @@
#include "protos.h"
/*******************************************************/
/* Methodes relatives a la manipulation des librairies */
/*******************************************************/
/***************************************************************************************/
LibraryStruct::LibraryStruct( int type, const wxString& name, const wxString& fullname )
/***************************************************************************************/
......@@ -396,11 +391,6 @@ LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_D
if( m_FieldId >= NUMBER_OF_FIELDS )
m_FieldId = NUMBER_OF_FIELDS - 1;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
m_Orient = 0; /* Orientation */
m_Attributs = 0; /* Attributs = unvisible ... */
m_Width = 0;
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Horizontal and vertical text justification */
}
......@@ -432,6 +422,7 @@ void LibDrawField::Copy( LibDrawField* Target )
Target->m_Name = m_Name;
Target->m_HJustify = m_HJustify;
Target->m_VJustify = m_VJustify;
Target->m_Italic = m_Italic;
}
......@@ -494,13 +485,11 @@ LibDrawCircle* LibDrawCircle::GenCopy()
/*****************************************************************/
LibDrawText::LibDrawText() : LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
LibDrawText::LibDrawText() : LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ),
EDA_TextStruct()
/*****************************************************************/
{
m_Horiz = TEXT_ORIENT_HORIZ;
m_Size = wxSize( 50, 50 );
m_Type = 0;
m_Width = 0;
}
......@@ -511,14 +500,17 @@ LibDrawText* LibDrawText::GenCopy()
LibDrawText* newitem = new LibDrawText();
newitem->m_Pos = m_Pos;
newitem->m_Horiz = m_Horiz;
newitem->m_Orient = m_Orient;
newitem->m_Size = m_Size;
newitem->m_Type = m_Type;
newitem->m_Attributs = m_Attributs;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Text = m_Text;
newitem->m_Width = m_Width;
newitem->m_Italic = m_Italic;
newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify;
return newitem;
}
......@@ -589,7 +581,6 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
newitem->m_PolyList = (int*) MyMalloc( size );
memcpy( newitem->m_PolyList, m_PolyList, size );
}
newitem->m_Pos = m_Pos;
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
......
......@@ -198,14 +198,16 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T';
if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c",
if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c%c%c",
m_FieldId,
CONV_TO_UTF8( m_Text ),
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
m_Pos.x, m_Pos.y,
m_Size.x,
m_Attributs,
hjustify, vjustify ) == EOF )
hjustify, vjustify,
m_Italic ? 'I' : 'N',
m_Width > 1 ? 'B' : 'N' ) == EOF )
{
return false;
}
......
......@@ -23,9 +23,7 @@ LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type ) :
* 0 if the item is common to all units */
m_Convert = 0; /* Shape identification (for parts which have a convert shape)
* 0 if the item is common to all shapes */
m_Width = 0; /* Default value to draw lines or arc ... */
m_Fill = NO_FILL; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR.
* has meaning only for some items */
m_Fill = NO_FILL;
}
......@@ -159,12 +157,12 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOff
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
int t1 = (aTransformMatrix[0][0] != 0) ^ (m_Horiz != 0);
int t1 = (aTransformMatrix[0][0] != 0) ^ (m_Orient != 0);
DrawGraphicText( aPanel, aDC, pos1, (EDA_Colors) color, m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, linewidth );
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, linewidth, m_Italic );
}
......@@ -299,7 +297,7 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOf
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
/* if aData not NULL, adat must point a wxString which is used instead of the m_Text
/* if aData not NULL, aData must point a wxString which is used instead of the m_Text
*/
{
wxPoint text_pos;
......@@ -340,7 +338,7 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOf
(EDA_Colors) color, text->GetData(),
m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
m_HJustify, m_VJustify, linewidth );
m_HJustify, m_VJustify, linewidth, m_Italic );
}
......
......@@ -130,8 +130,6 @@ public:
* 0 if the item is common to all units */
int m_Convert; /* Shape identification (for parts which have a convert shape)
* 0 if the item is common to all shapes */
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR. has meaning only for some items */
public:
......@@ -189,6 +187,8 @@ public:
int m_PinNumSize, m_PinNameSize; /* Pin num and Pin name sizes */
// int m_PinNumWidth, m_PinNameWidth; /* (Currently Unused) Pin num and Pin name text width */
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibDrawPin();
......@@ -246,6 +246,8 @@ public:
int m_Rayon;
int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */
wxPoint m_ArcStart, m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibDrawArc();
......@@ -278,6 +280,8 @@ class LibDrawCircle : public LibEDA_BaseStruct
{
public:
int m_Rayon;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibDrawCircle();
......@@ -311,12 +315,8 @@ public:
/* they are a separate class */
/*********************************************/
class LibDrawText : public LibEDA_BaseStruct
, public EDA_TextStruct
{
public:
int m_Horiz;
wxSize m_Size;
int m_Type;
wxString m_Text;
public:
LibDrawText();
......@@ -350,6 +350,8 @@ class LibDrawSquare : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibDrawSquare();
......@@ -382,6 +384,8 @@ class LibDrawSegment : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibDrawSegment();
......@@ -415,6 +419,7 @@ class LibDrawPolyline : public LibEDA_BaseStruct
public:
int m_CornersCount;
int* m_PolyList;
int m_Width; /* Tickness */
public:
LibDrawPolyline();
......@@ -458,6 +463,7 @@ public:
* Name (74LS00..) used to find the component in libraries, and give the default value in schematic
*/
class LibDrawField : public LibEDA_BaseStruct
, public EDA_TextStruct
{
public:
int m_FieldId; /* 0 a 11
......@@ -465,13 +471,7 @@ public:
* 2 = Default footprint, 3 = subsheet (not used, reserved)
* .. 11 other fields
*/
wxSize m_Size;
int m_Orient; /* Orientation */
int m_Attributs; /* Attributes (Non visible ...) */
enum GRTextHorizJustifyType m_HJustify; /* Horizontal Text Justify */
enum GRTextVertJustifyType m_VJustify; /* Vertical Text Justify */
wxString m_Text; /* Field Data */
wxString m_Name; /* Field Name */
wxString m_Name; /* Field Name (not the fielsd text itself, that is .m_Text) */
public:
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_bodygraphictext_properties_base.h"
///////////////////////////////////////////////////////////////////////////
Dialog_BodyGraphicText_Properties_base::Dialog_BodyGraphicText_Properties_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bLeftSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TextValue->SetMinSize( wxSize( 200,-1 ) );
bLeftSizer->Add( m_TextValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxStaticBoxSizer* sOptionsSizer;
sOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _(" Text Options : ") ), wxVERTICAL );
m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to Units"), wxDefaultPosition, wxDefaultSize, 0 );
sOptionsSizer->Add( m_CommonUnit, 0, wxALL, 5 );
m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to convert"), wxDefaultPosition, wxDefaultSize, 0 );
sOptionsSizer->Add( m_CommonConvert, 0, wxALL, 5 );
m_Orient = new wxCheckBox( this, wxID_ANY, _("Vertical"), wxDefaultPosition, wxDefaultSize, 0 );
sOptionsSizer->Add( m_Orient, 0, wxALL, 5 );
bLeftSizer->Add( sOptionsSizer, 0, 0, 5 );
bMainSizer->Add( bLeftSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
m_TextSizeText = new wxStaticText( this, wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextSizeText->Wrap( -1 );
bRightSizer->Add( m_TextSizeText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_TextShapeOptNChoices = sizeof( m_TextShapeOptChoices ) / sizeof( wxString );
m_TextShapeOpt = new wxRadioBox( this, wxID_ANY, _("Text Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeOptNChoices, m_TextShapeOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextShapeOpt->SetSelection( 3 );
bRightSizer->Add( m_TextShapeOpt, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( bRightSizer, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_buttonOK, 0, wxALL, 5 );
m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_buttonCANCEL, 0, wxALL, 5 );
bMainSizer->Add( bSizer4, 0, wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( bMainSizer );
this->Layout();
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( Dialog_BodyGraphicText_Properties_base::OnInitDialog ) );
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnOkClick ), NULL, this );
m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnCancelClick ), NULL, this );
}
Dialog_BodyGraphicText_Properties_base::~Dialog_BodyGraphicText_Properties_base()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( Dialog_BodyGraphicText_Properties_base::OnInitDialog ) );
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnOkClick ), NULL, this );
m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Dialog_BodyGraphicText_Properties_base::OnCancelClick ), NULL, this );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_bodygraphictext_properties_base__
#define __dialog_bodygraphictext_properties_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class Dialog_BodyGraphicText_Properties_base
///////////////////////////////////////////////////////////////////////////////
class Dialog_BodyGraphicText_Properties_base : public wxDialog
{
private:
protected:
wxStaticText* m_staticText1;
wxTextCtrl* m_TextValue;
wxCheckBox* m_CommonUnit;
wxCheckBox* m_CommonConvert;
wxCheckBox* m_Orient;
wxStaticText* m_TextSizeText;
wxTextCtrl* m_TextSize;
wxRadioBox* m_TextShapeOpt;
wxButton* m_buttonOK;
wxButton* m_buttonCANCEL;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
public:
Dialog_BodyGraphicText_Properties_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Graphic text properties:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 360,180 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~Dialog_BodyGraphicText_Properties_base();
};
#endif //__dialog_bodygraphictext_properties_base__
......@@ -435,6 +435,13 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
int style = 0;
if ( field.m_Italic )
style = 1;
if ( field.m_Width > 1 )
style |= 2;
m_StyleRadioBox->SetSelection(style);
fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing
......@@ -499,6 +506,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
field.m_Name = fieldNameTextCtrl->GetValue();
field.m_Text = fieldValueTextCtrl->GetValue();
......@@ -507,6 +515,17 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize( textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UnitMetric );
field.m_Size.y = field.m_Size.x;
int style = m_StyleRadioBox->GetSelection( );
if ( (style & 1 ) != 0 )
field.m_Italic = true;
else
field.m_Italic = false;
if ( (style & 2 ) != 0 )
field.m_Width = field.m_Size.x / 4;
else
field.m_Width = 0;
double value;
posXTextCtrl->GetValue().ToDouble( &value );
......
......@@ -114,19 +114,30 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
wxStaticBoxSizer* visibilitySizer;
visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL );
wxBoxSizer* bShowRotateSizer;
bShowRotateSizer = new wxBoxSizer( wxVERTICAL );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
showCheckBox->SetToolTip( _("Check if you want this field visible") );
visibilitySizer->Add( showCheckBox, 1, wxALL, 5 );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
visibilitySizer->Add( rotateCheckBox, 1, wxALL, 5 );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 );
visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 );
wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
m_StyleRadioBox->SetSelection( 0 );
visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxALL|wxEXPAND, 5 );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 );
wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
......
......@@ -49,6 +49,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
wxButton* moveUpButton;
wxCheckBox* showCheckBox;
wxCheckBox* rotateCheckBox;
wxRadioBox* m_StyleRadioBox;
wxStaticText* fieldNameLabel;
wxTextCtrl* fieldNameTextCtrl;
wxStaticText* fieldValueLabel;
......
/**********************************************/
/* EESchema - symbtext.cpp for Library Editor */
/**********************************************/
/* Menu et routines de creation, modification, suppression de textes
du type symbole
(textes autres que Fields)
*/
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "dialog_bodygraphictext_properties_base.h"
#include "protos.h"
class Dialog_BodyGraphicText_Properties : public Dialog_BodyGraphicText_Properties_base
{
private:
WinEDA_LibeditFrame * m_Parent;
LibDrawText * m_GraphicText;
public:
Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent, LibDrawText * aGraphicText);
~Dialog_BodyGraphicText_Properties() {};
private:
void OnInitDialog( wxInitDialogEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
};
Dialog_BodyGraphicText_Properties::Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent, LibDrawText * aGraphicText) :
Dialog_BodyGraphicText_Properties_base(aParent)
{
m_Parent = aParent;
m_GraphicText = aGraphicText;
}
/********************************************************************************/
void Dialog_BodyGraphicText_Properties::OnInitDialog( wxInitDialogEvent& event )
/********************************************************************************/
{
wxString msg;
SetFocus();
if ( m_GraphicText )
{
msg = ReturnStringFromValue(g_UnitMetric, m_GraphicText->m_Size.x, m_Parent->m_InternalUnits);
m_TextSize->SetValue(msg);
m_TextValue->SetValue(m_GraphicText->m_Text);
if ( m_GraphicText->m_Unit == 0 ) m_CommonUnit->SetValue(TRUE);
if ( m_GraphicText->m_Convert == 0 ) m_CommonConvert->SetValue(TRUE);
if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT ) m_Orient->SetValue(TRUE);
int shape = 0;
if ( m_GraphicText->m_Italic)
shape = 1;
if ( m_GraphicText->m_Width > 1)
shape |= 2;
m_TextShapeOpt->SetSelection(shape);
}
else
{
msg = ReturnStringFromValue(g_UnitMetric, g_LastTextSize, m_Parent->m_InternalUnits);
m_TextSize->SetValue(msg);
if ( ! g_FlDrawSpecificUnit ) m_CommonUnit->SetValue(TRUE);
if ( ! g_FlDrawSpecificConvert ) m_CommonConvert->SetValue(TRUE);
if ( g_LastTextOrient == TEXT_ORIENT_VERT ) m_Orient->SetValue(TRUE);
}
msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol();
m_TextSizeText->SetLabel(msg);
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
}
void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event )
{
event.Skip();
}
/***************************************************************************/
void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
/***************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'edition
*/
{
wxString Line;
Line = m_TextValue->GetValue();
g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
g_LastTextSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits);
g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE;
g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE;
if ( m_GraphicText )
{
if ( ! Line.IsEmpty() ) m_GraphicText->m_Text = Line;
else m_GraphicText->m_Text = wxT("[null]");
m_GraphicText->m_Size.x = m_GraphicText->m_Size.y = g_LastTextSize;
m_GraphicText->m_Orient = g_LastTextOrient;
if( g_FlDrawSpecificUnit ) m_GraphicText->m_Unit = CurrentUnit;
else m_GraphicText->m_Unit = 0;
if( g_FlDrawSpecificConvert ) m_GraphicText->m_Convert = CurrentConvert;
else m_GraphicText->m_Convert = 0;
if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 )
m_GraphicText->m_Italic = true;
else
m_GraphicText->m_Italic = false;
if ( (m_TextShapeOpt->GetSelection() & 2 ) != 0 )
m_GraphicText->m_Width = m_GraphicText->m_Size.x / 4;
else
m_GraphicText->m_Width = 0;
}
Close();
if ( CurrentDrawItem )
CurrentDrawItem->Display_Infos_DrawEntry(m_Parent);
Close();
}
/*******************************************************/
void WinEDA_LibeditFrame::EditSymbolText(wxDC * DC,
LibEDA_BaseStruct * DrawItem)
/*******************************************************/
{
int DrawMode = g_XorMode;
if ( DrawItem == NULL ) return;
if ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) return;
/* Effacement ancien texte */
if( ((LibDrawText*)DrawItem)->m_Text && DC)
DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawItem, DrawMode);
Dialog_BodyGraphicText_Properties * frame =
new Dialog_BodyGraphicText_Properties(this, (LibDrawText *) DrawItem);
frame->ShowModal(); frame->Destroy();
GetScreen()->SetModify();
/* Affichage nouveau texte */
if( ((LibDrawText*)DrawItem)->m_Text && DC)
{
if ( (DrawItem->m_Flags & IS_MOVED) == 0 )
DrawMode = GR_DEFAULT_DRAWMODE;
DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawItem, DrawMode);
}
}
/****************************************************/
void WinEDA_LibeditFrame::RotateSymbolText(wxDC * DC)
/****************************************************/
/*
90 deg Graphic text Rotation .
*/
{
LibDrawText * DrawItem = (LibDrawText *) CurrentDrawItem;
if(DrawItem == NULL) return;
/* Erase drawing (can be within a move command) */
if ( DrawPanel->ManageCurseur == NULL)
DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawItem, g_XorMode);
else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE);
if( DrawItem->m_Orient == TEXT_ORIENT_HORIZ)
DrawItem->m_Orient = TEXT_ORIENT_VERT;
else DrawItem->m_Orient = TEXT_ORIENT_HORIZ;
GetScreen()->SetModify();
/* Redraw item with new orient */
if ( DrawPanel->ManageCurseur == NULL)
DrawLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawItem, GR_DEFAULT_DRAWMODE);
else DrawPanel->ManageCurseur(DrawPanel, DC, FALSE);
}
......@@ -59,7 +59,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
m_CurrentText->m_Italic = 0;
if ( ( style & 2 ) )
m_CurrentText->m_Width = m_CurrentText->m_Size.x / 5;
m_CurrentText->m_Width = m_CurrentText->m_Size.x / 4;
else
m_CurrentText->m_Width = 0;
......
......@@ -350,7 +350,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
DrawGraphicText( panel, DC, pos, color, m_Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
hjustify, vjustify, LineWidth, m_Italic );
}
else // For more than one part per package, we must add the part selection to the reference )
{
......@@ -366,7 +366,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel,
DrawGraphicText( panel, DC, pos, color, fulltext,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
hjustify, vjustify, LineWidth, m_Italic );
}
}
......
......@@ -610,14 +610,21 @@ LibEDA_BaseStruct* GetDrawEntry (WinEDA_DrawFrame* frame,
New = Text;
Buffer[0] = 0;
Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s",
&Text->m_Horiz,
chartmp[0] = 0; // For italic option, Not in old versions
int thickness = 0; // Not in old versions
Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s %s %d",
&Text->m_Orient,
&Text->m_Pos.x, &Text->m_Pos.y,
&Text->m_Size.x, &Text->m_Type,
&Unit, &Convert, Buffer ) != 8;
&Text->m_Size.x, &Text->m_Attributs,
&Unit, &Convert, Buffer, chartmp, &thickness ) < 8;
Text->m_Unit = Unit; Text->m_Convert = Convert;
Text->m_Size.y = Text->m_Size.x;
if ( strnicmp(chartmp, "Italic", 6) == 0 )
Text->m_Italic = true;
Text->m_Width = thickness;
if( !Error )
{ /* Convert '~' to spaces. */
Text->m_Text = CONV_FROM_UTF8( Buffer );
......@@ -909,8 +916,8 @@ GetLibEntryField (EDA_LibComponentStruct* LibEntry,
line++;
FieldUserName[0] = 0;
nbparam = sscanf( line, " %d %d %d %c %c %c %c",
memset( Char4, 0, sizeof(Char4));
nbparam = sscanf( line, " %d %d %d %c %c %c %s",
&posx, &posy, &size, Char1, Char2, Char3, Char4 );
orient = TEXT_ORIENT_HORIZ;
......@@ -928,10 +935,15 @@ GetLibEntryField (EDA_LibComponentStruct* LibEntry,
hjustify = GR_TEXT_HJUSTIFY_LEFT;
else if( *Char3 == 'R' )
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
if( *Char4 == 'B' )
if( Char4[0] == 'B' )
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
else if( *Char4 == 'T' )
else if( Char4[0] == 'T' )
vjustify = GR_TEXT_VJUSTIFY_TOP;
if ( Char4[1] == 'I' ) // Italic
Field->m_Italic = true;
if ( Char4[2] == 'B' ) // Bold
Field->m_Width = size / 4;
}
switch( NumOfField )
......
......@@ -913,7 +913,7 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
ii = 2;
dx = (Text->m_Size.x * ii) / 2;
dy = Text->m_Size.y / 2;
if( Text->m_Horiz == TEXT_ORIENT_VERT )
if( Text->m_Orient == TEXT_ORIENT_VERT )
{
EXCHG( dx, dy );
}
......
......@@ -56,6 +56,7 @@ OBJECTS = eeschema.o\
edit_component_in_schematic.o\
dialog_edit_component_in_schematic_fbp.o \
dialog_edit_component_in_schematic.o \
dialog_bodygraphictext_properties_base.o\
locate.o \
save_schemas.o sheet.o \
read_from_file_schematic_items_descriptions.o\
......@@ -67,7 +68,8 @@ OBJECTS = eeschema.o\
libfield.o \
edit_component_in_lib.o \
menubar.o \
savelib.o symbtext.o \
savelib.o\
edit_graphic_bodyitem_text.o \
symbdraw.o \
hierarch.o files-io.o \
annotate.o\
......
......@@ -249,7 +249,7 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0);
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
SetCurrentLineWidth( -1 );
int thickness = Text->m_Width;
......
......@@ -695,8 +695,8 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
{
int newNdx = component->GetFieldCount();
SCH_CMP_FIELD f( wxPoint( 0, 0 ), newNdx, component, fieldName );
component->AddField( f );
SCH_CMP_FIELD field( wxPoint( 0, 0 ), newNdx, component, fieldName );
component->AddField( field );
}
}
else
......@@ -705,7 +705,7 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
}
component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 );
memset(Char3, 0, sizeof(Char3) );
if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1,
&component->GetField( fieldNdx )->m_Pos.x,
&component->GetField( fieldNdx )->m_Pos.y,
......@@ -735,10 +735,18 @@ int ReadPartDescr( wxWindow* frame, char* Line, FILE* f,
hjustify = GR_TEXT_HJUSTIFY_LEFT;
else if( *Char2 == 'R' )
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
if( *Char3 == 'B' )
if( Char3[0] == 'B' )
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
else if( *Char3 == 'T' )
else if( Char3[0] == 'T' )
vjustify = GR_TEXT_VJUSTIFY_TOP;
if( Char3[1] == 'I' )
component->GetField( fieldNdx )->m_Italic = true;
else
component->GetField( fieldNdx )->m_Italic = false;
if( Char3[2] == 'B' )
component->GetField( fieldNdx )->m_Width = component->GetField( fieldNdx )->m_Size.x / 4;
else
component->GetField( fieldNdx )->m_Width = 0;
component->GetField( fieldNdx )->m_HJustify = hjustify;
component->GetField( fieldNdx )->m_VJustify = vjustify;
......
......@@ -68,15 +68,19 @@ bool LibDrawText::Save( FILE* ExportFile ) const
/************************************************/
{
wxString text = m_Text;
// Spaces are not allowed in text because it is not double quoted: changed to '~'
text.Replace( wxT( " " ), wxT( "~" ) );
text.Replace( wxT( " " ), wxT( "~" ) ); // Spaces are not allowed: changed to '~'
fprintf( ExportFile, "T %d %d %d %d %d %d %d %s\n",
m_Horiz,
fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ",
m_Orient,
m_Pos.x, m_Pos.y,
m_Size.x, m_Type,
m_Size.x, m_Attributs,
m_Unit, m_Convert,
CONV_TO_UTF8( text ) );
CONV_TO_UTF8( text ));
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", m_Width );
fprintf( ExportFile, "\n");
return true;
}
......@@ -200,13 +204,15 @@ bool LibDrawField::Save( FILE* ExportFile ) const
vjustify = 'T';
if( text.IsEmpty() )
text = wxT( "~" );
fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c",
fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c",
m_FieldId, CONV_TO_UTF8( text ),
m_Pos.x, m_Pos.y,
m_Size.x,
m_Orient == 0 ? 'H' : 'V',
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
hjustify, vjustify );
hjustify, vjustify,
m_Italic ? 'I' : 'N',
m_Width > 1 ? 'B' : 'N');
// Save field name, if necessary
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
......@@ -222,7 +228,8 @@ LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame,
LibEDA_BaseStruct* DrawItem )
/**********************************************************/
/* Duplicate a DrawLibItem
/** Function CopyDrawEntryStruct
* Duplicate a DrawLibItem
* the new item is only created, it is not put in the current component linked list
* @param DrawEntry = DrawLibItem * item to duplicate
* @return a pointer to the new item
......
......@@ -304,7 +304,7 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
CurrentDrawItem = Text;
Text->m_Size.x = Text->m_Size.y = g_LastTextSize;
Text->m_Horiz = g_LastTextOrient;
Text->m_Orient = g_LastTextOrient;
Text->m_Pos.x = GetScreen()->m_Curseur.x;
Text->m_Pos.y = -( GetScreen()->m_Curseur.y );
EditSymbolText( NULL, Text );
......
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
// Name: symbtext.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 12/02/2006 14:04:59
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 12/02/2006 14:04:59
#ifndef _SYMBTEXT_H_
#define _SYMBTEXT_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "symbtext.h"
#endif
/*!
* Includes
*/
////@begin includes
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define ID_TEXTCTRL 10001
#define ID_TEXTCTRL1 10002
#define ID_CHECKBOX 10003
#define ID_CHECKBOX1 10004
#define ID_CHECKBOX2 10005
#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE _("Graphic text properties")
#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION wxDefaultPosition
////@end control identifiers
/*!
* Compatibility
*/
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
/*!
* WinEDA_bodytext_PropertiesFrame class declaration
*/
class WinEDA_bodytext_PropertiesFrame: public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_bodytext_PropertiesFrame )
DECLARE_EVENT_TABLE()
public:
/// Constructors
WinEDA_bodytext_PropertiesFrame( );
WinEDA_bodytext_PropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_BODYTEXT_PROPERTIESFRAME_STYLE );
/// Creates the controls and sizers
void CreateControls();
////@begin WinEDA_bodytext_PropertiesFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
////@end WinEDA_bodytext_PropertiesFrame event handler declarations
////@begin WinEDA_bodytext_PropertiesFrame member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_bodytext_PropertiesFrame member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
void bodytext_PropertiesAccept(wxCommandEvent& event);
////@begin WinEDA_bodytext_PropertiesFrame member variables
wxTextCtrl* m_NewText;
wxStaticText* m_SizeText;
wxTextCtrl* m_Size;
wxCheckBox* m_CommonUnit;
wxCheckBox* m_CommonConvert;
wxCheckBox* m_Orient;
wxButton* m_btClose;
////@end WinEDA_bodytext_PropertiesFrame member variables
WinEDA_LibeditFrame * m_Parent;
};
#endif
// _SYMBTEXT_H_
This diff is collapsed.
#include "wx/msw/wx.rc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment