Commit e875e075 authored by charras's avatar charras

minor enhancements and fixes

parent 9e07e246
......@@ -14,22 +14,24 @@
#include "class_drawpanel.h"
#include "program.h"
#include "general.h"
#include "drawtxt.h"
#include "confirm.h"
#include "dialog_edit_label.h"
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
/*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct )
{
int ret;
DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText );
/*************************************************************************/
/* Edit the properties of the text (Label, Global label, graphic text).. )
* pointed by "TextStruct"
*/
if( TextStruct == NULL )
return;
// doing any post construction resizing is better done here than in
// OnInitDialog() since it tends to flash/redraw the dialog less.
dialog->init();
DialogLabelEditor dialog( this, TextStruct );
dialog.ShowModal();
ret = dialog->ShowModal();
dialog->Destroy();
return ret;
}
......@@ -39,11 +41,14 @@ DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* C
{
m_Parent = parent;
m_CurrentText = CurrentText;
init();
InitDialog();
GetSizer()->SetSizeHints(this);
Centre();
}
void DialogLabelEditor::init()
void DialogLabelEditor::InitDialog()
{
wxString msg;
bool multine = false;
......@@ -143,11 +148,6 @@ void DialogLabelEditor::init()
{
m_TextShape->Show( false );
}
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
}
/*!
......@@ -180,3 +180,59 @@ void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event )
EndModal( wxID_CANCEL );
}
/****************************************************************************/
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
{
/****************************************************************************/
wxString text;
int value;
/* save old text in undo list if not already in edit */
if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
m_Parent->DrawPanel->PostDirtyRect( m_CurrentText->GetBoundingBox() );
text = m_TextLabel->GetValue();
if( !text.IsEmpty() )
m_CurrentText->m_Text = text;
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text,
m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection();
int style = m_TextStyle->GetSelection();
if( ( style & 1 ) )
m_CurrentText->m_Italic = 1;
else
m_CurrentText->m_Italic = 0;
if( ( style & 2 ) )
{
m_CurrentText->m_Bold = true;
m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x );
}
else
{
m_CurrentText->m_Bold = false;
m_CurrentText->m_Width = 0;
}
m_Parent->GetScreen()->SetModify();
/* Make the text size as new default size if it is a new text */
if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
m_Parent->DrawPanel->PostDirtyRect( m_CurrentText->GetBoundingBox() );
m_Parent->DrawPanel->MouseToCursorSchema();
EndModal( 0 );
}
......@@ -17,25 +17,15 @@ private:
SCH_TEXT * m_CurrentText;
wxTextCtrl* m_TextLabel;
protected:
// these are protected so that the static ShowModally() gets used.
public:
DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText);
~DialogLabelEditor(){};
public:
/**
* Function ShowModally
* is a static function that constructs and then displays one of these dialogs.
* @param parent
* @param CurrentText is one of several classes derived from SCH_TEXT
* @return int - the result Dialog::ShowModal()
*/
static int ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText );
private:
void init( );
void InitDialog( );
void onEnterKey( wxCommandEvent& event );
void OnButtonOKClick( wxCommandEvent& event );
void OnButtonCANCEL_Click( wxCommandEvent& event );
......
......@@ -15,9 +15,6 @@
#include "general.h"
#include "protos.h"
#include "dialog_edit_label.h"
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
......@@ -29,59 +26,6 @@ static int s_DefaultShapeGLabel = (int) NET_INPUT;
static int s_DefaultOrientGLabel = 0;
/****************************************************************************/
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
{
/****************************************************************************/
wxString text;
int value;
/* save old text in undo list if not already in edit */
if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
text = m_TextLabel->GetValue();
if( !text.IsEmpty() )
m_CurrentText->m_Text = text;
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text,
m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection();
int style = m_TextStyle->GetSelection();
if( ( style & 1 ) )
m_CurrentText->m_Italic = 1;
else
m_CurrentText->m_Italic = 0;
if( ( style & 2 ) )
{
m_CurrentText->m_Bold = true;
m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x );
}
else
{
m_CurrentText->m_Bold = false;
m_CurrentText->m_Width = 0;
}
m_Parent->GetScreen()->SetModify();
/* Make the text size as new default size if it is a new text */
if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
m_Parent->DrawPanel->MouseToCursorSchema();
EndModal( 0 );
}
/*****************************************************************************/
void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
{
......@@ -128,30 +72,6 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
}
/*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
wxDC* DC )
{
/*************************************************************************/
/* Edit the properties of the text (Label, Global label, graphic text).. )
* pointed by "TextStruct"
*/
if( TextStruct == NULL )
return;
// Erase old text on screen
DrawPanel->CursorOff( DC );
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
DialogLabelEditor::ShowModally( this, TextStruct );
// Redraw nex text, if exists
if( ! TextStruct->m_Text.IsEmpty() )
RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC );
}
/*****************************************************************************/
void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
{
......@@ -235,7 +155,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
NewText->m_Flags = IS_NEW | IS_MOVED;
RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode );
EditSchematicText( NewText, DC );
EditSchematicText( NewText );
if( NewText->m_Text.IsEmpty() )
{
......
......@@ -74,17 +74,17 @@ static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ),
HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component" ),
HK_ROTATE_COMPONENT, 'R' );
static Ki_HotkeyInfo HkEditComponent( wxT( "Edit Component" ),
HK_EDIT_COMPONENT, 'E' );
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component or Label" ),
HK_ROTATE_COMPONENT_OR_LABEL, 'R' );
static Ki_HotkeyInfo HkEditComponent( wxT( "Edit Component or Label" ),
HK_EDIT_COMPONENT_OR_LABEL, 'E' );
static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
HK_EDIT_COMPONENT_VALUE, 'V' );
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
HK_EDIT_COMPONENT_FOOTPRINT,
'F' );
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component" ),
HK_MOVE_COMPONENT, 'M',
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component or Label" ),
HK_MOVE_COMPONENT_OR_LABEL, 'M',
ID_POPUP_SCH_MOVE_CMP_REQUEST );
static Ki_HotkeyInfo HkDragComponent( wxT( "Drag Component" ),
HK_DRAG_COMPONENT, 'G',
......@@ -327,7 +327,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
}
break;
case HK_ROTATE_COMPONENT: // Component Rotation
case HK_ROTATE_COMPONENT_OR_LABEL: // Component Rotation
if( DrawStruct == NULL )
{
DrawStruct = PickStruct( GetScreen()->m_Curseur,
......@@ -416,7 +416,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break;
case HK_DRAG_COMPONENT: // Start drag Component
case HK_MOVE_COMPONENT: // Start move Component
case HK_MOVE_COMPONENT_OR_LABEL: // Start move Component
if( ItemInEdit )
break;
......@@ -463,7 +463,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
}
break;
case HK_EDIT_COMPONENT:
case HK_EDIT_COMPONENT_OR_LABEL:
if( ItemInEdit )
break;
......@@ -490,7 +490,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
EditSchematicText( (SCH_TEXT*) DrawStruct, DC );
EditSchematicText( (SCH_TEXT*) DrawStruct );
break;
default:
......
......@@ -24,14 +24,14 @@ enum hotkey_id_commnand {
HK_UNDO,
HK_REDO,
HK_MOVEBLOCK_TO_DRAGBLOCK,
HK_ROTATE_COMPONENT,
HK_EDIT_COMPONENT,
HK_ROTATE_COMPONENT_OR_LABEL,
HK_EDIT_COMPONENT_OR_LABEL,
HK_EDIT_COMPONENT_VALUE,
HK_EDIT_COMPONENT_FOOTPRINT,
HK_MIRROR_X_COMPONENT,
HK_MIRROR_Y_COMPONENT,
HK_ORIENT_NORMAL_COMPONENT,
HK_MOVE_COMPONENT,
HK_MOVE_COMPONENT_OR_LABEL,
HK_DRAG_COMPONENT,
HK_ADD_NEW_COMPONENT,
HK_BEGIN_WIRE
......
......@@ -343,7 +343,7 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
EditSchematicText( (SCH_TEXT*) DrawStruct, DC );
EditSchematicText( (SCH_TEXT*) DrawStruct );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
......
......@@ -265,7 +265,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
{
msg = _( "Move Component" );
msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT );
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
msg, move_xpm );
msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr,
......@@ -276,7 +276,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
wxMenu* orientmenu = new wxMenu;
msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT );
HK_ROTATE_COMPONENT_OR_LABEL );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
msg, rotate_pos_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE,
......@@ -296,7 +296,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
wxMenu* editmenu = new wxMenu;
msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT );
HK_EDIT_COMPONENT_OR_LABEL );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, msg,
edit_component_xpm );
......@@ -362,14 +362,18 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
if( !GLabel->m_Flags )
{
msg = AddHotkeyName( _( "Move Global Label" ),
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT );
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
_( "Rotate Global Label" ), rotate_glabel_xpm );
msg, rotate_glabel_xpm );
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Global Label" ), edit_text_xpm );
msg, edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Global Label" ), delete_text_xpm );
......@@ -395,12 +399,16 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
{
msg = AddHotkeyName( _( "Move Hierarchical Label" ),
s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT );
HK_MOVE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
_( "Rotate Hierarchical Label" ), rotate_glabel_xpm );
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Hierarchical Label" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
......@@ -427,14 +435,18 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
if( !Label->m_Flags )
{
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT );
HK_MOVE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
_( "Rotate Label" ), rotate_pos_xpm );
msg, rotate_pos_xpm );
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Label" ), edit_text_xpm );
msg, edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Label" ), delete_text_xpm );
......@@ -453,14 +465,24 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{
wxString msg;
wxMenu* menu_change_type = new wxMenu;
if( !Text->m_Flags )
{
msg = AddHotkeyName( _( "Move Text" ),
s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
_( "Move Text" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Text" ),
msg, move_text_xpm );
}
msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg,
rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Text" ),
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg,
edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ),
delete_text_xpm );
......
......@@ -262,7 +262,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_TEXT:
EditSchematicText( (SCH_TEXT*) screen->GetCurItem(), &dc );
EditSchematicText( (SCH_TEXT*) screen->GetCurItem() );
break;
case ID_POPUP_SCH_ROTATE_TEXT:
......
......@@ -296,7 +296,7 @@ private:
// Text ,label, glabel
SCH_TEXT* CreateNewText( wxDC* DC, int type );
void EditSchematicText( SCH_TEXT* TextStruct, wxDC* DC );
void EditSchematicText( SCH_TEXT* TextStruct );
void ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC );
void StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC );
void ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype );
......
......@@ -173,7 +173,7 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
/* Redraw the current moved track segments */
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, draw_mode );
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
......
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