2008-12-22 21:06:44 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialog_edit_module_text.cpp
|
|
|
|
// Author: jean-pierre Charras
|
|
|
|
// Licence: GPL
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2008-12-22 21:06:44 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "dialog_edit_module_text_base.h"
|
|
|
|
|
|
|
|
extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp
|
|
|
|
|
|
|
|
/*************** **************/
|
|
|
|
/* class DialogEditModuleText */
|
|
|
|
/*************** **************/
|
|
|
|
class DialogEditModuleText : public DialogEditModuleText_base
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
WinEDA_BasePcbFrame* m_Parent;
|
|
|
|
wxDC* m_DC;
|
|
|
|
MODULE* m_Module;
|
|
|
|
TEXTE_MODULE* m_CurrentTextMod;
|
|
|
|
|
|
|
|
public:
|
2009-01-05 05:21:35 +00:00
|
|
|
DialogEditModuleText( WinEDA_BasePcbFrame* parent, TEXTE_MODULE* TextMod, wxDC* DC );
|
|
|
|
~DialogEditModuleText() {};
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
private:
|
2009-01-05 05:21:35 +00:00
|
|
|
void OnInitDialog( wxInitDialogEvent& event );
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2008-12-22 21:06:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
void WinEDA_BasePcbFrame::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod,
|
|
|
|
wxDC* DC, const wxPoint& pos )
|
|
|
|
/***************************************************************************/
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
DialogEditModuleText* frame = new DialogEditModuleText( this,
|
|
|
|
TextMod, DC );
|
|
|
|
frame->ShowModal(); frame->Destroy();
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DialogEditModuleText::DialogEditModuleText( WinEDA_BasePcbFrame* parent,
|
|
|
|
TEXTE_MODULE* TextMod,
|
|
|
|
wxDC* DC ) :
|
2009-01-05 05:21:35 +00:00
|
|
|
DialogEditModuleText_base(parent)
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
m_Parent = parent;
|
|
|
|
m_DC = DC;
|
|
|
|
m_Module = NULL;
|
|
|
|
m_CurrentTextMod = TextMod;
|
|
|
|
if( m_CurrentTextMod )
|
|
|
|
{
|
|
|
|
m_Module = (MODULE*) m_CurrentTextMod->GetParent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DialogEditModuleText::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
|
|
|
void DialogEditModuleText::OnInitDialog( wxInitDialogEvent& event )
|
|
|
|
/********************************************************/
|
|
|
|
{
|
|
|
|
SetFont( *g_DialogFont );
|
2009-01-05 05:21:35 +00:00
|
|
|
SetFocus();
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( m_Module )
|
|
|
|
{
|
|
|
|
wxString format = m_ModuleInfoText->GetLabel();
|
|
|
|
msg.Printf( format,
|
|
|
|
m_Module->m_Reference->m_Text.GetData(),
|
|
|
|
m_Module->m_Value->m_Text.GetData(),
|
|
|
|
(float) (m_Module->m_Orient / 10) );
|
|
|
|
m_ModuleInfoText->SetLabel( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CurrentTextMod->m_Type == TEXT_is_VALUE )
|
|
|
|
m_TextDataTitle->SetLabel( _( "Value:" ) );
|
|
|
|
else if( m_CurrentTextMod->m_Type == TEXT_is_DIVERS )
|
|
|
|
m_TextDataTitle->SetLabel( _( "Text:" ) );
|
|
|
|
else if( m_CurrentTextMod->m_Type != TEXT_is_REFERENCE )
|
|
|
|
m_TextDataTitle->SetLabel( wxT( "???" ) );
|
|
|
|
|
|
|
|
m_Name->SetValue( m_CurrentTextMod->m_Text );
|
|
|
|
|
|
|
|
m_Style->SetSelection( m_CurrentTextMod->m_Italic ? 1 : 0 );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_SizeXTitle );
|
|
|
|
PutValueInLocalUnits( *m_TxtSizeCtrlX, m_CurrentTextMod->m_Size.x,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_SizeYTitle );
|
|
|
|
PutValueInLocalUnits( *m_TxtSizeCtrlY, m_CurrentTextMod->m_Size.y,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_PosXTitle );
|
|
|
|
PutValueInLocalUnits( *m_TxtPosCtrlX, m_CurrentTextMod->m_Pos0.x,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_PosYTitle );
|
|
|
|
PutValueInLocalUnits( *m_TxtPosCtrlY, m_CurrentTextMod->m_Pos0.y,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_WidthTitle );
|
|
|
|
PutValueInLocalUnits( *m_TxtWidthCtlr, m_CurrentTextMod->m_Width,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int text_orient = m_CurrentTextMod->m_Orient;
|
|
|
|
NORMALIZE_ANGLE_90(text_orient)
|
2008-12-22 21:06:44 +00:00
|
|
|
if( (text_orient != 0) )
|
|
|
|
m_Orient->SetSelection( 1 );
|
|
|
|
|
|
|
|
if( m_CurrentTextMod->m_NoShow )
|
|
|
|
m_Show->SetSelection( 1 );;
|
|
|
|
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
|
|
|
void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
|
|
|
|
/*********************************************************************************/
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
m_Parent->SaveCopyInUndoList( m_Parent->GetBoard()->m_Modules );
|
2008-12-22 21:06:44 +00:00
|
|
|
if( m_DC ) //Erase old text on screen
|
|
|
|
{
|
|
|
|
m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR,
|
|
|
|
(m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) );
|
|
|
|
}
|
|
|
|
m_CurrentTextMod->m_Text = m_Name->GetValue();
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
m_CurrentTextMod->m_Italic = m_Style->GetSelection() == 1 ? true : false;
|
2008-12-22 21:06:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
msg = m_TxtPosCtrlX->GetValue();
|
|
|
|
m_CurrentTextMod->m_Pos0.x = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
msg = m_TxtPosCtrlY->GetValue();
|
|
|
|
m_CurrentTextMod->m_Pos0.y = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
msg = m_TxtSizeCtrlX->GetValue();
|
|
|
|
m_CurrentTextMod->m_Size.x = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
msg = m_TxtSizeCtrlY->GetValue();
|
|
|
|
m_CurrentTextMod->m_Size.y = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
// Test for a reasonnable size:
|
|
|
|
if( m_CurrentTextMod->m_Size.x< TEXTS_MIN_SIZE )
|
|
|
|
m_CurrentTextMod->m_Size.x = TEXTS_MIN_SIZE;
|
|
|
|
if( m_CurrentTextMod->m_Size.y< TEXTS_MIN_SIZE )
|
|
|
|
m_CurrentTextMod->m_Size.y = TEXTS_MIN_SIZE;
|
|
|
|
|
|
|
|
msg = m_TxtWidthCtlr->GetValue();
|
|
|
|
int width = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
// Test for a reasonnable width:
|
|
|
|
if( width <= 1 )
|
|
|
|
width = 1;
|
2009-01-05 05:21:35 +00:00
|
|
|
int minthickness = min(m_CurrentTextMod->m_Size.x, m_CurrentTextMod->m_Size.y) / 4;
|
2008-12-22 21:06:44 +00:00
|
|
|
if( width > minthickness )
|
|
|
|
width = minthickness;
|
|
|
|
m_CurrentTextMod->SetWidth( width );
|
|
|
|
|
|
|
|
m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1;
|
2009-01-05 05:21:35 +00:00
|
|
|
int text_orient = (m_Orient->GetSelection() == 0) ? 0 : 900;
|
2008-12-22 21:06:44 +00:00
|
|
|
m_CurrentTextMod->m_Orient = text_orient;
|
|
|
|
|
|
|
|
m_CurrentTextMod->SetDrawCoord();
|
|
|
|
if( m_DC ) // Display new text
|
|
|
|
{
|
|
|
|
m_CurrentTextMod->Draw( m_Parent->DrawPanel, m_DC, GR_XOR,
|
|
|
|
(m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) );
|
|
|
|
}
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
( (MODULE*) m_CurrentTextMod->GetParent() )->m_LastEdit_Time = time( NULL );
|
|
|
|
|
|
|
|
Close( TRUE );
|
|
|
|
}
|