Commit e875e075 authored by charras's avatar charras
Browse files

minor enhancements and fixes

parent 9e07e246
Loading
Loading
Loading
Loading
+73 −17
Original line number Original line Diff line number Diff line
@@ -14,22 +14,24 @@
#include "class_drawpanel.h"
#include "class_drawpanel.h"
#include "program.h"
#include "program.h"
#include "general.h"
#include "general.h"
#include "drawtxt.h"
#include "confirm.h"
#include "dialog_edit_label.h"
#include "dialog_edit_label.h"




int DialogLabelEditor::ShowModally(  WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
/*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct )
{
{
    int ret;
/*************************************************************************/

/* Edit the properties of the text (Label, Global label, graphic text).. )
    DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText );
 *  pointed by "TextStruct"
 */
    if( TextStruct == NULL )
        return;


    // doing any post construction resizing is better done here than in
    DialogLabelEditor dialog( this, TextStruct );
    // OnInitDialog() since it tends to flash/redraw the dialog less.
    dialog.ShowModal();
    dialog->init();


    ret = dialog->ShowModal();
    dialog->Destroy();
    return ret;
}
}




@@ -39,11 +41,14 @@ DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* C
{
{
    m_Parent = parent;
    m_Parent = parent;
    m_CurrentText = CurrentText;
    m_CurrentText = CurrentText;
    init();
    InitDialog();

    GetSizer()->SetSizeHints(this);
    Centre();
}
}




void DialogLabelEditor::init()
void DialogLabelEditor::InitDialog()
{
{
    wxString msg;
    wxString msg;
    bool multine = false;
    bool multine = false;
@@ -143,11 +148,6 @@ void DialogLabelEditor::init()
    {
    {
        m_TextShape->Show( false );
        m_TextShape->Show( false );
    }
    }

    if( GetSizer() )
    {
        GetSizer()->SetSizeHints( this );
    }
}
}


/*!
/*!
@@ -180,3 +180,59 @@ void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event )
    EndModal( wxID_CANCEL );
    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 );
}

+2 −12
Original line number Original line Diff line number Diff line
@@ -17,25 +17,15 @@ private:
    SCH_TEXT * m_CurrentText;
    SCH_TEXT * m_CurrentText;
    wxTextCtrl* m_TextLabel;
    wxTextCtrl* m_TextLabel;


protected:
public:
    // these are protected so that the static ShowModally() gets used.
    DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText);
    DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText);
    ~DialogLabelEditor(){};
    ~DialogLabelEditor(){};




public:
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:
private:
    void init( );
    void InitDialog( );
  	void onEnterKey( wxCommandEvent& event );
  	void onEnterKey( wxCommandEvent& event );
    void OnButtonOKClick( wxCommandEvent& event );
    void OnButtonOKClick( wxCommandEvent& event );
    void OnButtonCANCEL_Click( wxCommandEvent& event );
    void OnButtonCANCEL_Click( wxCommandEvent& event );
+1 −81
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
#include "general.h"
#include "general.h"
#include "protos.h"
#include "protos.h"


#include "dialog_edit_label.h"


static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );


@@ -29,59 +26,6 @@ static int s_DefaultShapeGLabel = (int) NET_INPUT;
static int     s_DefaultOrientGLabel = 0;
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 )
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 )
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;
    NewText->m_Flags  = IS_NEW | IS_MOVED;


    RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode );
    RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode );
    EditSchematicText( NewText, DC );
    EditSchematicText( NewText );


    if( NewText->m_Text.IsEmpty() )
    if( NewText->m_Text.IsEmpty() )
    {
    {
+10 −10
Original line number Original line Diff line number Diff line
@@ -74,17 +74,17 @@ static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ),
                                         HK_MIRROR_X_COMPONENT, 'X' );
                                         HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
                                              HK_ORIENT_NORMAL_COMPONENT, 'N' );
                                              HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component" ),
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component or Label" ),
                                        HK_ROTATE_COMPONENT, 'R' );
                                        HK_ROTATE_COMPONENT_OR_LABEL, 'R' );
static Ki_HotkeyInfo HkEditComponent( wxT( "Edit Component" ),
static Ki_HotkeyInfo HkEditComponent( wxT( "Edit Component or Label" ),
                                           HK_EDIT_COMPONENT, 'E' );
                                           HK_EDIT_COMPONENT_OR_LABEL, 'E' );
static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
                                           HK_EDIT_COMPONENT_VALUE, 'V' );
                                           HK_EDIT_COMPONENT_VALUE, 'V' );
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
                                               HK_EDIT_COMPONENT_FOOTPRINT,
                                               HK_EDIT_COMPONENT_FOOTPRINT,
                                               'F' );
                                               'F' );
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component" ),
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component or Label" ),
                                      HK_MOVE_COMPONENT, 'M',
                                      HK_MOVE_COMPONENT_OR_LABEL, 'M',
                                      ID_POPUP_SCH_MOVE_CMP_REQUEST );
                                      ID_POPUP_SCH_MOVE_CMP_REQUEST );
static Ki_HotkeyInfo HkDragComponent( wxT( "Drag Component" ),
static Ki_HotkeyInfo HkDragComponent( wxT( "Drag Component" ),
                                      HK_DRAG_COMPONENT, 'G',
                                      HK_DRAG_COMPONENT, 'G',
@@ -327,7 +327,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        }
        }
        break;
        break;


    case HK_ROTATE_COMPONENT:       // Component Rotation
    case HK_ROTATE_COMPONENT_OR_LABEL:       // Component Rotation
        if( DrawStruct == NULL )
        if( DrawStruct == NULL )
        {
        {
            DrawStruct = PickStruct( GetScreen()->m_Curseur,
            DrawStruct = PickStruct( GetScreen()->m_Curseur,
@@ -416,7 +416,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        break;
        break;


    case HK_DRAG_COMPONENT:         // Start drag Component
    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 )
        if( ItemInEdit )
            break;
            break;


@@ -463,7 +463,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        }
        }
        break;
        break;


    case HK_EDIT_COMPONENT:
    case HK_EDIT_COMPONENT_OR_LABEL:


        if( ItemInEdit )
        if( ItemInEdit )
            break;
            break;
@@ -490,7 +490,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        case TYPE_SCH_LABEL:
        case TYPE_SCH_LABEL:
        case TYPE_SCH_GLOBALLABEL:
        case TYPE_SCH_GLOBALLABEL:
        case TYPE_SCH_HIERLABEL:
        case TYPE_SCH_HIERLABEL:
            EditSchematicText( (SCH_TEXT*) DrawStruct, DC );
            EditSchematicText( (SCH_TEXT*) DrawStruct );
            break;
            break;


        default:
        default:
+3 −3
Original line number Original line Diff line number Diff line
@@ -24,14 +24,14 @@ enum hotkey_id_commnand {
	HK_UNDO,
	HK_UNDO,
	HK_REDO,
	HK_REDO,
    HK_MOVEBLOCK_TO_DRAGBLOCK,
    HK_MOVEBLOCK_TO_DRAGBLOCK,
    HK_ROTATE_COMPONENT,
    HK_ROTATE_COMPONENT_OR_LABEL,
	HK_EDIT_COMPONENT,
	HK_EDIT_COMPONENT_OR_LABEL,
	HK_EDIT_COMPONENT_VALUE,
	HK_EDIT_COMPONENT_VALUE,
	HK_EDIT_COMPONENT_FOOTPRINT,
	HK_EDIT_COMPONENT_FOOTPRINT,
    HK_MIRROR_X_COMPONENT,
    HK_MIRROR_X_COMPONENT,
    HK_MIRROR_Y_COMPONENT,
    HK_MIRROR_Y_COMPONENT,
    HK_ORIENT_NORMAL_COMPONENT,
    HK_ORIENT_NORMAL_COMPONENT,
    HK_MOVE_COMPONENT,
    HK_MOVE_COMPONENT_OR_LABEL,
    HK_DRAG_COMPONENT,
    HK_DRAG_COMPONENT,
    HK_ADD_NEW_COMPONENT,
    HK_ADD_NEW_COMPONENT,
    HK_BEGIN_WIRE
    HK_BEGIN_WIRE
Loading