Commit 9d400e4c authored by charras's avatar charras

fixed some (minors) problems about hotkeys.

Code cleaning.
Patch for 3D problem with macOSX
parent 5a0aca0e
/////////////////////////////////////////////////////////////////////////////
// Name: 3d_canvas.cpp
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
......@@ -12,6 +13,7 @@
#include "wx/dataobj.h"
#include "wx/clipbrd.h"
#include <wx/wupdlock.h>
#include "gestfich.h"
......@@ -27,17 +29,20 @@
*/
BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )
// key event:
EVT_CHAR( Pcb3D_GLCanvas::OnChar )
// mouse events
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
// other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
Pcb3D_GLCanvas::OnPopUpMenu )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )
// key event:
EVT_CHAR( Pcb3D_GLCanvas::OnChar )
// mouse events
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
// other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
Pcb3D_GLCanvas::OnPopUpMenu )
END_EVENT_TABLE()
Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent ) :
......@@ -203,6 +208,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode )
Refresh( FALSE );
}
void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event )
{
wxSize size( GetClientSize() );
......@@ -302,67 +308,67 @@ void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event )
pos.x = event.GetX(); pos.y = event.GetY();
wxMenuItem* item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMIN,
_( "Zoom +" ) );
_( "Zoom +" ) );
item->SetBitmap( zoom_in_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMOUT,
_( "Zoom -" ) );
_( "Zoom -" ) );
item->SetBitmap( zoom_out_xpm );
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZPOS,
_( "Top View" ) );
_( "Top View" ) );
item->SetBitmap( axis3d_top_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZNEG,
_( "Bottom View" ) );
_( "Bottom View" ) );
item->SetBitmap( axis3d_bottom_xpm );
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XPOS,
_( "Right View" ) );
_( "Right View" ) );
item->SetBitmap( axis3d_right_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XNEG,
_( "Left View" ) );
_( "Left View" ) );
item->SetBitmap( axis3d_left_xpm );
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YPOS,
_( "Front View" ) );
_( "Front View" ) );
item->SetBitmap( axis3d_front_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YNEG,
_( "Back View" ) );
_( "Back View" ) );
item->SetBitmap( axis3d_back_xpm );
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_LEFT,
_( "Move left <-" ) );
_( "Move left <-" ) );
item->SetBitmap( left_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_RIGHT,
_( "Move right ->" ) );
_( "Move right ->" ) );
item->SetBitmap( right_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_UP,
_( "Move Up ^" ) );
_( "Move Up ^" ) );
item->SetBitmap( up_xpm );
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN,
_( "Move Down" ) );
_( "Move Down" ) );
item->SetBitmap( down_xpm );
PopUpMenu.Append( item );
......@@ -579,12 +585,52 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
Redraw( true );
wxSize image_size = GetClientSize();
#ifndef __WXMAC__
wxClientDC dc( this );
wxBitmap bitmap( image_size.x, image_size.y );
wxMemoryDC memdc;
memdc.SelectObject( bitmap );
memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
memdc.SelectObject( wxNullBitmap );
#else
struct vieport_params
{
GLint originx;
GLint originy;
GLint x;
GLint y;
} viewport;
wxWindowUpdateLocker noUpdates( this );
glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );
unsigned char* pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 );
unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y );
wxImage image( viewport.x, viewport.y );
glPixelStorei( GL_PACK_ALIGNMEN T, 1 );
glReadBuffer( GL_BACK_LEFT );
glReadPixels( viewport.originx,
viewport.originy,
viewport.x,
viewport.y,
GL_RGB,
GL_UNSIGNED_ BYTE,
pixelbuffer );
glReadPixels( viewport.originx,
viewport.originy,
viewport.x,
viewport.y,
GL_ALPHA,
GL_UNSIGNED_ BYTE,
alphabuffer );
image.SetData( pixelbuffer );
image.SetAlpha( alphabuffer );
image = image.Mirror( false );
wxBitmap bitmap( image );
#endif
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
......
......@@ -162,7 +162,7 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
};
/*
/** function ReturnKeyNameFromKeyCode
* return the key name from the key code
* Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] )
......@@ -201,7 +201,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
}
/*
/** function AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value
......@@ -219,7 +219,7 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List,
}
/*
/** function AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of
* commands
......@@ -249,7 +249,7 @@ wxString AddHotkeyName( const wxString& text,
}
/*
/** function ReturnKeyNameFromCommandId
* return the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value
......@@ -273,7 +273,7 @@ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId )
}
/*
/** function ReturnKeyCodeFromKeyName
* return the key code from its key name
* Only some wxWidgets key values are handled for function key
* @param keyname = wxString key name to find in s_Hotkey_Name_List[],
......@@ -300,7 +300,7 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
}
/*
/** function DisplayHotkeyList
* Displays the current hotkey list
* @param frame = current active frame
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list
......@@ -331,7 +331,7 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame,
}
/*
/** function GetDescriptorFromHotkey
* Return a Ki_HotkeyInfo * pointer fron a key code for OnHotKey() function
* @param key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands
......
......@@ -14,10 +14,8 @@
enum id_eeschema_frm
{
/* Schecmatic editor horizontal toolbar IDs */
ID_SCHEMATIC_UNDO = ID_END_LIST,
ID_SCHEMATIC_REDO,
ID_HIERARCHY,
/* Schematic editor horizontal toolbar IDs */
ID_HIERARCHY = ID_END_LIST,
ID_TO_LIBVIEW,
ID_GET_ANNOTATE,
ID_GET_ERC,
......@@ -138,8 +136,6 @@ enum id_eeschema_frm
ID_LIBEDIT_GET_FRAME_EDIT_PART,
ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
ID_LIBEDIT_DELETE_PART,
ID_LIBEDIT_UNDO,
ID_LIBEDIT_REDO,
ID_DE_MORGAN_NORMAL_BUTT,
ID_DE_MORGAN_CONVERT_BUTT,
ID_LIBEDIT_EDIT_PIN_BY_PIN,
......
......@@ -80,12 +80,12 @@ static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),
/* Undo */
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
(int) ID_SCHEMATIC_UNDO );
(int) wxID_UNDO );
/* Redo */
#if !defined( __WXMAC__ )
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
(int) ID_SCHEMATIC_REDO );
(int) wxID_REDO );
#else
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO,
GR_KB_SHIFT + GR_KB_CTRL + 'Z',
......@@ -699,7 +699,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_UNDO:
if( !ItemInEdit )
{
toolCmd.SetId( ID_LIBEDIT_UNDO );
toolCmd.SetId( wxID_UNDO );
GetEventHandler()->ProcessEvent( toolCmd );
}
break;
......@@ -707,7 +707,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_REDO:
if( !ItemInEdit )
{
toolCmd.SetId( ID_LIBEDIT_REDO );
toolCmd.SetId( wxID_REDO );
GetEventHandler()->ProcessEvent( toolCmd );
}
break;
......
......@@ -79,9 +79,9 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
WinEDA_LibeditFrame::LoadOneLibraryPart )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_UNDO,
EVT_TOOL( wxID_UNDO,
WinEDA_LibeditFrame::GetComponentFromUndoList )
EVT_TOOL( ID_LIBEDIT_REDO,
EVT_TOOL( wxID_REDO,
WinEDA_LibeditFrame::GetComponentFromRedoList )
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART,
WinEDA_LibeditFrame::OnEditComponentProperties )
......@@ -134,8 +134,8 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
WinEDA_LibeditFrame::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART,
WinEDA_LibeditFrame::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
EVT_UPDATE_UI( ID_LIBEDIT_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
EVT_UPDATE_UI( wxID_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB,
WinEDA_LibeditFrame::OnUpdateSaveCurrentLib )
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, WinEDA_LibeditFrame::OnUpdateViewDoc )
......
......@@ -63,26 +63,26 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
/* Separator */
filesMenu->AppendSeparator();
/* Save */
item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET, _( "&Save\tCtrl+S" ),
/* Save Project */
item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save Whole Schematic Project\tCtrl+S" ),
_( "Save all sheets in the schematic project" ) );
item->SetBitmap( save_project_xpm );
filesMenu->Append( item );
item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET, _( "&Save Current Sheet Only" ),
_( "Save only current schematic sheet" ) );
item->SetBitmap( save_xpm );
filesMenu->Append( item );
/* Save as... */
item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET_AS,
_( "Save &as...\tShift+Ctrl+S" ),
_( "Save Current Sheet &as\tShift+Ctrl+S" ),
_( "Save current schematic sheet as..." ) );
item->SetBitmap( save_as_xpm );
filesMenu->Append( item );
/* Save Project */
item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save Project" ),
_( "Save all sheets in the schematic project" ) );
item->SetBitmap( save_project_xpm );
filesMenu->Append( item );
/* Separator */
filesMenu->AppendSeparator();
......@@ -157,7 +157,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
text = _( "Undo\tCtrl+Z" );
#endif
item = new wxMenuItem( editMenu, ID_SCHEMATIC_UNDO, text,
item = new wxMenuItem( editMenu, wxID_UNDO, text,
_( "Undo last edition" ), wxITEM_NORMAL );
item->SetBitmap( undo_xpm );
editMenu->Append( item );
......@@ -169,7 +169,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
text = _( "Redo\tShift+Ctrl+Z" );
#endif
item = new wxMenuItem( editMenu, ID_SCHEMATIC_REDO, text,
item = new wxMenuItem( editMenu, wxID_REDO, text,
_( "Redo the last undo command" ), wxITEM_NORMAL );
item->SetBitmap( redo_xpm );
editMenu->Append( item );
......
......@@ -82,9 +82,9 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_SCHEMATIC_UNDO,
EVT_TOOL( wxID_UNDO,
WinEDA_SchematicFrame::GetSchematicFromUndoList )
EVT_TOOL( ID_SCHEMATIC_REDO,
EVT_TOOL( wxID_REDO,
WinEDA_SchematicFrame::GetSchematicFromRedoList )
EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
......@@ -120,9 +120,9 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_UPDATE_UI( wxID_CUT, WinEDA_SchematicFrame::OnUpdateBlockSelected )
EVT_UPDATE_UI( wxID_COPY, WinEDA_SchematicFrame::OnUpdateBlockSelected )
EVT_UPDATE_UI( wxID_PASTE, WinEDA_SchematicFrame::OnUpdatePaste )
EVT_UPDATE_UI( ID_SCHEMATIC_UNDO,
EVT_UPDATE_UI( wxID_UNDO,
WinEDA_SchematicFrame::OnUpdateSchematicUndo )
EVT_UPDATE_UI( ID_SCHEMATIC_REDO,
EVT_UPDATE_UI( wxID_REDO,
WinEDA_SchematicFrame::OnUpdateSchematicRedo )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID,
WinEDA_SchematicFrame::OnUpdateGrid )
......
......@@ -136,11 +136,11 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Undo last command" ), s_Schematic_Hokeys_Descr,
HK_UNDO );
m_HToolBar->AddTool( ID_LIBEDIT_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
msg );
msg = AddHotkeyName( _( "Redo the last command" ), s_Schematic_Hokeys_Descr,
HK_REDO );
m_HToolBar->AddTool( ID_LIBEDIT_REDO, wxEmptyString, wxBitmap( redo_xpm ),
m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ),
msg );
m_HToolBar->AddSeparator();
......
......@@ -71,12 +71,12 @@ void WinEDA_SchematicFrame::ReCreateHToolbar()
m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Undo last edition" ), s_Schematic_Hokeys_Descr,
HK_UNDO );
m_HToolBar->AddTool( ID_SCHEMATIC_UNDO, wxEmptyString,
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString,
wxBitmap( undo_xpm ), msg );
msg = AddHotkeyName( _( "Redo the last undo command" ),
s_Schematic_Hokeys_Descr, HK_REDO );
m_HToolBar->AddTool( ID_SCHEMATIC_REDO, wxEmptyString,
m_HToolBar->AddTool( wxID_REDO, wxEmptyString,
wxBitmap( redo_xpm ), msg );
m_HToolBar->AddSeparator();
......
......@@ -84,7 +84,7 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GEN_PRINT, WinEDA_GerberFrame::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_DRC_CONTROL, WinEDA_GerberFrame::Process_Special_Functions )
......
......@@ -195,7 +195,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
_( "Paste" ) );
#endif
m_HToolBar->AddTool( ID_UNDO_BUTT, wxEmptyString,
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString,
wxBitmap( undelete_xpm ),
_( "Undelete" ) );
......
......@@ -56,10 +56,6 @@ enum main_id
ID_GEN_COPY_SHEET_TO_CLIPBOARD,
ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
ID_GEN_UNUSED0,
ID_GEN_UNUSED1,
ID_GEN_UNUSED2,
ID_GEN_UNUSED3,
ID_GEN_UNUSED4,
ID_GEN_EXPORT_FILE,
ID_GEN_EXPORT_SPECCTRA,
......@@ -92,8 +88,6 @@ enum main_id
ID_COLORS_SETUP,
ID_REPEAT_BUTT,
ID_UNDO_BUTT,
ID_REDO_BUTT,
ID_LANGUAGE_CHOICE,
ID_LANGUAGE_DEFAULT,
......
No preview for this file type
This diff is collapsed.
......@@ -86,12 +86,43 @@ static Ki_HotkeyInfo HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE,
WXK_DELETE );
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),
HK_RESET_LOCAL_COORD, ' ' );
static Ki_HotkeyInfo HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
/* Zoom In */
#if !defined( __WXMAC__ )
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
#else
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+' );
#endif
/* Zoom Out */
#if !defined( __WXMAC__ )
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
#else
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-' );
#endif
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
/* Undo */
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
(int) wxID_UNDO );
/* Redo */
#if !defined( __WXMAC__ )
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
(int) wxID_REDO );
#else
static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO,
GR_KB_SHIFT + GR_KB_CTRL + 'Z',
(int) wxID_REDO );
#endif
static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U'
+ GR_KB_CTRL );
static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ),
......@@ -99,12 +130,13 @@ static Ki_HotkeyInfo HkTrackDisplayMode( wxT( "Track Display Mode" ),
static Ki_HotkeyInfo HkAddModule( wxT( "Add Module" ), HK_ADD_MODULE, 'O' );
// List of common hotkey descriptors
Ki_HotkeyInfo
* s_Common_Hotkey_List[] =
Ki_HotkeyInfo* s_Common_Hotkey_List[] =
{
&HkHelp, &HkZoomIn, &HkZoomOut,
&HkZoomRedraw, &HkZoomCenter, &HkZoomAuto,
&HkSwitchUnits, &HkResetLocalCoord, NULL
&HkSwitchUnits, &HkResetLocalCoord,
&HkUndo, &HkRedo,
NULL
};
// List of hotkey descriptors for pcbnew
......@@ -143,8 +175,7 @@ struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] =
// list of sections and corresponding hotkey list for the board editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[] =
{ {
&g_CommonSectionTag,
s_Common_Hotkey_List,
&g_CommonSectionTag, s_Common_Hotkey_List,
NULL
},{
&g_BoardEditorSectionTag, s_board_edit_Hotkey_List, NULL
......@@ -153,8 +184,7 @@ struct Ki_HotkeyInfoSectionDescriptor s_Board_Editor_Hokeys_Descr[] =
} };
// list of sections and corresponding hotkey list for the footprint editor (used to list current hotkeys)
struct Ki_HotkeyInfoSectionDescriptor
s_Module_Editor_Hokeys_Descr[] =
struct Ki_HotkeyInfoSectionDescriptor s_Module_Editor_Hokeys_Descr[] =
{ {
&g_CommonSectionTag, s_Common_Hotkey_List, NULL
},{
......@@ -192,12 +222,13 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
/* Convert lower to upper case
* (the usual toupper function has problem with non ascii codes like function keys
*/
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey,
s_Common_Hotkey_List );
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List );
if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, s_board_edit_Hotkey_List );
......@@ -308,6 +339,16 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_UNDO:
case HK_REDO:
if( ItemFree )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event );
}
break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
......@@ -631,17 +672,23 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
if( hotkey == 0 )
return;
bool ItemFree = (GetCurItem() == 0 || GetCurItem()->m_Flags == 0);
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (just easier to handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
hotkey += 'A' - 1;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey,
s_Common_Hotkey_List );
Ki_HotkeyInfo* HK_Descr = GetDescriptorFromHotkey( hotkey, s_Common_Hotkey_List );
if( HK_Descr == NULL )
HK_Descr = GetDescriptorFromHotkey( hotkey, s_module_edit_Hotkey_List );
if( HK_Descr == NULL )
return;
......@@ -684,6 +731,16 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_UNDO:
case HK_REDO:
if( ItemFree )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event );
}
break;
case HK_ZOOM_AUTO:
cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd );
......
......@@ -16,6 +16,8 @@ enum hotkey_id_commnand {
HK_ZOOM_REDRAW,
HK_ZOOM_CENTER,
HK_ZOOM_AUTO,
HK_UNDO,
HK_REDO,
HK_DELETE,
HK_BACK_SPACE,
HK_ROTATE_FOOTPRINT,
......
......@@ -245,8 +245,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
#else
text = _( "Undo\tCtrl+Z" );
#endif
item = new wxMenuItem( editMenu, ID_UNDO_BUTT, text,
item = new wxMenuItem( editMenu, wxID_UNDO, text,
_( "Undo last edition" ), wxITEM_NORMAL );
item->SetBitmap( undo_xpm );
editMenu->Append( item );
......@@ -257,8 +256,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
#else
text = _( "Redo\tShift+Ctrl+Z" );
#endif
item = new wxMenuItem( editMenu, ID_REDO_BUTT, text,
item = new wxMenuItem( editMenu, wxID_REDO, text,
_( "Redo the last undo command" ), wxITEM_NORMAL );
item->SetBitmap( redo_xpm );
editMenu->Append( item );
......@@ -376,10 +374,11 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
/* 3D Display */
item = new wxMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME,
_( "3D Display" ), _( "Show board in the 3D viewer" ) );
wxMenu* Display3DMenu = new wxMenu;
item = new wxMenuItem( Display3DMenu, ID_MENU_PCB_SHOW_3D_FRAME,
_( "3D Display" ), _( "Show board in 3D viewer" ) );
item->SetBitmap( show_3d_xpm );
viewMenu->Append( item );
Display3DMenu->Append( item );
/**
......@@ -525,6 +524,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( configmenu, _( "&Preferences" ) );
menuBar->Append( designRulesMenu, _( "&Design Rules" ) );
menuBar->Append( Display3DMenu, _( "&3D Display" ) );
menuBar->Append( helpMenu, _( "&Help" ) );
/* Associate the menu bar with the frame */
......
......@@ -74,9 +74,9 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame )
WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES,
WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_UNDO,
EVT_TOOL( wxID_UNDO,
WinEDA_ModuleEditFrame::GetComponentFromUndoList )
EVT_TOOL( ID_MODEDIT_REDO,
EVT_TOOL( wxID_REDO,
WinEDA_ModuleEditFrame::GetComponentFromRedoList )
// Vertical toolbar (left click):
......@@ -316,9 +316,9 @@ void WinEDA_ModuleEditFrame::SetToolbars()
if( GetScreen() )
{
m_HToolBar->EnableTool( ID_MODEDIT_UNDO,
m_HToolBar->EnableTool( wxID_UNDO,
GetScreen()->GetUndoCommandCount()>0 && active );
m_HToolBar->EnableTool( ID_MODEDIT_REDO,
m_HToolBar->EnableTool( wxID_REDO,
GetScreen()->GetRedoCommandCount()>0 && active );
}
......
......@@ -127,8 +127,8 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
EVT_TOOL( wxID_CUT, WinEDA_PcbFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_PcbFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_PcbFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_PcbFrame::GetBoardFromUndoList )
EVT_TOOL( ID_REDO_BUTT, WinEDA_PcbFrame::GetBoardFromRedoList )
EVT_TOOL( wxID_UNDO, WinEDA_PcbFrame::GetBoardFromUndoList )
EVT_TOOL( wxID_REDO, WinEDA_PcbFrame::GetBoardFromRedoList )
EVT_TOOL( ID_GEN_PRINT, WinEDA_PcbFrame::ToPrinter )
EVT_TOOL( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
EVT_TOOL( ID_GEN_PLOT, WinEDA_PcbFrame::Process_Special_Functions )
......
......@@ -249,8 +249,6 @@ enum pcbnew_ids
ID_MODEDIT_TRANSFORM_MODULE,
ID_MODEDIT_MODULE_ROTATE,
ID_MODEDIT_MODULE_MIRROR,
ID_MODEDIT_UNDO,
ID_MODEDIT_REDO,
ID_MODEDIT_IMPORT_PART,
ID_MODEDIT_EXPORT_PART,
ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
......
......@@ -87,9 +87,9 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar()
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_MODEDIT_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
_( "Undo last edition" ) );
m_HToolBar->AddTool( ID_MODEDIT_REDO, wxEmptyString, wxBitmap( redo_xpm ),
m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ),
_( "Redo the last undo command" ) );
m_HToolBar->AddSeparator();
......
......@@ -224,9 +224,9 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
#endif
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_UNDO_BUTT, wxEmptyString, wxBitmap( undo_xpm ),
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
_( "Undo last edition" ) );
m_HToolBar->AddTool( ID_REDO_BUTT, wxEmptyString, wxBitmap( redo_xpm ),
m_HToolBar->AddTool( wxID_REDO, wxEmptyString, wxBitmap( redo_xpm ),
_( "Redo the last undo command" ) );
m_HToolBar->AddSeparator();
......
......@@ -177,10 +177,10 @@ void WinEDA_PcbFrame::SetToolbars()
m_HToolBar->EnableTool( wxID_PASTE, false );
state = GetScreen()->GetUndoCommandCount() > 0;
m_HToolBar->EnableTool( ID_UNDO_BUTT, state );
m_HToolBar->EnableTool( wxID_UNDO, state );
state = GetScreen()->GetRedoCommandCount() > 0;
m_HToolBar->EnableTool( ID_REDO_BUTT, state );
m_HToolBar->EnableTool( wxID_REDO, state );
if( m_OptionsToolBar )
{
......
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