Commit 0e7fa222 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

merge trunk. Prepare hotkeys move and rotate items in board editor

parents 2a14f2d5 f839ba95
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -204,6 +204,46 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError
}


const char* OUTPUTFORMATTER::Quoted( std::string* aWrapee ) throw( IOError )
{
    // derived class's notion of what a quote character is
    char quote          = *GetQuoteChar( "(" );

    // Will the string be wrapped based on its interior content?
    const char* squote  = GetQuoteChar( aWrapee->c_str() );

    // Search the interior of the string for 'quote' chars
    // and replace them as found with duplicated quotes.
    // Note that necessarily any string which has internal quotes will
    // also be wrapped in quotes later in this function.
    for( unsigned i=0;  i<aWrapee->size();  ++i )
    {
        if( (*aWrapee)[i] == quote )
        {
            aWrapee->insert( aWrapee->begin()+i, quote );
            ++i;
        }
        else if( (*aWrapee)[0]=='\r' || (*aWrapee)[0]=='\n' )
        {
            // In a desire to maintain accurate line number reporting within DSNLEXER
            // a decision was made to make all S-expression strings be on a single
            // line.  You can embedd \n (human readable) in the text but not
            // '\n' which is 0x0a.
            throw IOError( _( "S-expression string has newline" ) );
        }
    }

    if( *squote )
    {
        // wrap the beginning and end of the string in a quote.
        aWrapee->insert( aWrapee->begin(), quote );
        aWrapee->insert( aWrapee->end(), quote );
    }

    return aWrapee->c_str();
}


//-----<STRING_FORMATTER>----------------------------------------------------

void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IOError )
+6 −10
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@
#include "xnode.h"
#include "macros.h"


typedef wxXmlProperty   XATTR;
#define GetAttribs      GetProperties

void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
@@ -51,18 +51,16 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
    std::string utf8;
    const char* quote;

    // output attributes first if they exist
    for( XATTR* attr = (XATTR*) GetAttributes();  attr;  attr = (XATTR*) attr->GetNext() )
    for( XATTR* attr = (XATTR*) GetAttribs();  attr;  attr = (XATTR*) attr->GetNext() )
    {
        utf8  = CONV_TO_UTF8( attr->GetValue() );   // capture the content
        quote = out->GetQuoteChar( utf8.c_str() );

        out->Print( 0, " (%s %s%s%s)",
        out->Print( 0, " (%s %s)",
            // attr names should never need quoting, no spaces, we designed the file.
            CONV_TO_UTF8( attr->GetName() ),
            quote, utf8.c_str(), quote );
            out->Quoted( &utf8 ) );
    }

    // we only expect to have used one of two types here:
@@ -88,8 +86,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError

    case wxXML_TEXT_NODE:
        utf8  = CONV_TO_UTF8( GetContent() );
        quote = out->GetQuoteChar( utf8.c_str() );
        out->Print( 0, " %s%s%s", quote, utf8.c_str(), quote );
        out->Print( 0, " %s", out->Quoted( &utf8 ) );
        break;

    default:
@@ -97,5 +94,4 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError
    }
}


// EOF
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>

<xsl:template match="export">
<xsl:template match="/export">
    <xsl:text>*PADS-PCB*&nl;*PART*&nl;</xsl:text>
    <xsl:apply-templates select="components/comp"/>
    <xsl:text>&nl;*NET*&nl;</xsl:text>
+5 −3
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ public:

    /**
     * Function Quoted
     * checks \a aWrappee input string for a need to be quoted
     * checks \a aWrapee input string for a need to be quoted
     * (e.g. contains a ')' character or a space), and for \" double quotes
     * within the string that need to be doubled up such that the DSNLEXER
     * will correctly parse the string from a file later.
@@ -312,9 +312,11 @@ public:
     *
     * @return const char* - useful for passing to printf() style functions that
     *  must output utf8 streams.
    virtual const char* Quoted( std::string* aWrapee );
        thinking about using wxCharBuffer* instead.
     * @throw IOError, if aWrapee has any \r or \n bytes in it which is
     *        illegal according to the DSNLEXER who does not ever want them
     *        within a string.
     */
    virtual const char* Quoted( std::string* aWrapee )  throw( IOError );

    //-----</interface functions>-----------------------------------------
};
+40 −4
Original line number Diff line number Diff line
@@ -253,10 +253,46 @@ public:
     */
    void             SetLastNetListRead( const wxString& aNetListFile );

    void             OnHotKey( wxDC*           DC,
                               int             hotkey,
                               EDA_BaseStruct* DrawStruct );
    bool             OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct );
    /** Function OnHotKey.
     *  ** Commands are case insensitive **
     *  Some commands are relatives to the item under the mouse cursor
     *  @param aDC = current device context
     *  @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
     *  @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
     */
    void             OnHotKey( wxDC*           aDC,
                               int             aHotkeyCode,
                               EDA_BaseStruct* aItem );

    /** Function OnHotkeyDeleteItem
     * Delete the item found under the mouse cursor
     *  Depending on the current active tool::
     *      Tool track
     *          if a track is in progress: Delete the last segment
     *			else delete the entire track
     *      Tool module (footprint):
     *          Delete the module.
     * @param aDC = current device context
     * @return true if an item was deleted
     */
    bool             OnHotkeyDeleteItem( wxDC* aDC );

    /** Function OnHotkeyMoveItem
     * Moves or drag the item (footprint, track, text .. ) found under the mouse cursor
     * Only a footprint or a track can be dragged
     * @param aIdCommand = the hotkey command id
     * @param aDC = current device context
     * @return true if an item was moved
     */
    bool             OnHotkeyMoveItem( int aIdCommand, wxDC* aDC );

    /** Function OnHotkeyRotateItem
     * Rotate the item (text or footprint) found under the mouse cursor
     * @param aIdCommand = the hotkey command id
     * @param aDC = current device context
     * @return true if an item was moved
     */
    bool             OnHotkeyRotateItem( int aIdCommand, wxDC* aDC );

    void             OnCloseWindow( wxCloseEvent& Event );
    void             Process_Special_Functions( wxCommandEvent& event );
Loading