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

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

parents 2a14f2d5 f839ba95
......@@ -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 )
......
......@@ -26,8 +26,8 @@
#include "xnode.h"
#include "macros.h"
typedef wxXmlProperty XATTR;
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
......@@ -629,7 +629,7 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE
XNODE* EXPORT_HELP::makeGenericDesignHeader()
{
XNODE* xdesign = node( wxT("design") );
char date[128];
char date[128];
DateAndTime( date );
......
......@@ -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>
......
......@@ -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>-----------------------------------------
};
......
......@@ -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 );
......
This diff is collapsed.
......@@ -13,8 +13,8 @@
enum hotkey_id_commnand {
HK_DELETE = HK_COMMON_END,
HK_BACK_SPACE,
HK_ROTATE_FOOTPRINT,
HK_MOVE_FOOTPRINT_OR_TRACK,
HK_ROTATE_ITEM,
HK_MOVE_ITEM,
HK_DRAG_FOOTPRINT_OR_TRACK,
HK_FLIP_FOOTPRINT,
HK_GET_AND_MOVE_FOOTPRINT,
......@@ -48,7 +48,6 @@ enum hotkey_id_commnand {
HK_SWITCH_LAYER_TO_INNER13,
HK_SWITCH_LAYER_TO_INNER14,
HK_ADD_MODULE,
HK_MOVE_TRACK,
HK_SLIDE_TRACK
};
......
......@@ -169,8 +169,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
}
if( !flags )
{
msg = AddHotkeyName( _( "Move Drawing" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
_( "Move Drawing" ), move_xpm );
msg, move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _(
"Delete Drawing" ), delete_xpm );
......@@ -225,8 +226,8 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
case TYPE_MIRE:
if( !flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST,
_( "Move Target" ), move_xpm );
msg = AddHotkeyName( _( "Move Target" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, msg, move_xpm );
msg = AddHotkeyName( _( "Edit Target" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE,
msg, edit_xpm );
......@@ -601,8 +602,9 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
_( "Remove Filled Areas in Zone" ), fill_zone_xpm );
}
msg = AddHotkeyName( _( "Move Zone" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
_( "Move Zone" ), move_xpm );
msg, move_xpm );
msg = AddHotkeyName( _( "Edit Zone Params" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
......@@ -636,14 +638,14 @@ void WinEDA_PcbFrame::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* men
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_footprint, -1, msg, module_xpm );
if( !flags )
{
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_FOOTPRINT_OR_TRACK );
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_MOVE_MODULE_REQUEST,
msg, move_module_xpm );
msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_FOOTPRINT_OR_TRACK );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_DRAG_MODULE_REQUEST,
msg, drag_module_xpm );
}
msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_FOOTPRINT );
msg = AddHotkeyName( _( "Rotate +" ), s_Board_Editor_Hokeys_Descr, HK_ROTATE_ITEM );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE,
msg, rotate_module_pos_xpm );
ADD_MENUITEM( sub_menu_footprint, ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE,
......@@ -681,8 +683,11 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Fp_text, -1, msg, footprint_text_xpm );
if( !flags )
{
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST,
_( "Move" ), move_field_xpm );
msg, move_field_xpm );
}
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE,
_( "Rotate" ), rotate_field_xpm );
......@@ -734,8 +739,9 @@ void WinEDA_PcbFrame::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
sub_menu_Pad = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm );
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST,
_( "Move" ), move_pad_xpm );
msg, move_pad_xpm );
ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST,
_( "Drag" ), drag_pad_xpm );
......@@ -791,8 +797,9 @@ void WinEDA_PcbFrame::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
if( !flags )
{
msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM );
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST,
_( "Move" ), move_text_xpm );
msg, move_text_xpm );
}
ADD_MENUITEM( sub_menu_Text, ID_POPUP_PCB_ROTATE_TEXTEPCB,
_( "Rotate" ), rotate_pos_xpm );
......
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