Commit 9d400e4c authored by charras's avatar charras
Browse files

fixed some (minors) problems about hotkeys.

Code cleaning.
Patch for 3D problem with macOSX
parent 5a0aca0e
Loading
Loading
Loading
Loading
+69 −23
Original line number Original line Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

// Name:        3d_canvas.cpp
// Name:        3d_canvas.cpp
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
#include "fctsys.h"
@@ -12,6 +13,7 @@


#include "wx/dataobj.h"
#include "wx/dataobj.h"
#include "wx/clipbrd.h"
#include "wx/clipbrd.h"
#include <wx/wupdlock.h>


#include "gestfich.h"
#include "gestfich.h"


@@ -28,12 +30,15 @@


BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas )
BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )

// key event:
// key event:
EVT_CHAR( Pcb3D_GLCanvas::OnChar )
EVT_CHAR( Pcb3D_GLCanvas::OnChar )

// mouse events
// mouse events
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )

// other events
// other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
@@ -203,6 +208,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode )
    Refresh( FALSE );
    Refresh( FALSE );
}
}



void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event )
void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event )
{
{
    wxSize size( GetClientSize() );
    wxSize size( GetClientSize() );
@@ -579,12 +585,52 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
    Redraw( true );
    Redraw( true );


    wxSize     image_size = GetClientSize();
    wxSize     image_size = GetClientSize();
 #ifndef __WXMAC__
    wxClientDC dc( this );
    wxClientDC dc( this );
    wxBitmap   bitmap( image_size.x, image_size.y );
    wxBitmap   bitmap( image_size.x, image_size.y );
    wxMemoryDC memdc;
    wxMemoryDC memdc;
    memdc.SelectObject( bitmap );
    memdc.SelectObject( bitmap );
    memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
    memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
    memdc.SelectObject( wxNullBitmap );
    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 )
    if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
    {
+7 −7
Original line number Original line Diff line number Diff line
@@ -162,7 +162,7 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
};
};




/*
/** function ReturnKeyNameFromKeyCode
 * return the key name from the key code
 * return the key name from the key code
 * Only some wxWidgets key values are handled for function key ( see
 * Only some wxWidgets key values are handled for function key ( see
 * s_Hotkey_Name_List[] )
 * 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)
 * Add the key name from the Command id value ( m_Idcommand member value)
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param CommandId = Command Id value
 * @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)
 * Add the key name from the Command id value ( m_Idcommand member value)
 * @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of
 * @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of
 * commands
 * 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)
 * return the key name from the Command id value ( m_Idcommand member value)
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param CommandId = Command Id value
 * @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
 * return the key code from its key name
 * Only some wxWidgets key values are handled for function key
 * Only some wxWidgets key values are handled for function key
 * @param keyname = wxString key name to find in s_Hotkey_Name_List[],
 * @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
 * Displays the current hotkey list
 * @param frame = current active frame
 * @param frame = current active frame
 * @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list
 * @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
 * 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 key = key code (ascii value, or wxWidgets value for function keys
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param List = pointer to a Ki_HotkeyInfo list of commands
+2 −6
Original line number Original line Diff line number Diff line
@@ -14,10 +14,8 @@


enum id_eeschema_frm
enum id_eeschema_frm
{
{
    /* Schecmatic editor horizontal toolbar IDs */
    /* Schematic editor horizontal toolbar IDs */
    ID_SCHEMATIC_UNDO = ID_END_LIST,
    ID_HIERARCHY = ID_END_LIST,
    ID_SCHEMATIC_REDO,
    ID_HIERARCHY,
    ID_TO_LIBVIEW,
    ID_TO_LIBVIEW,
    ID_GET_ANNOTATE,
    ID_GET_ANNOTATE,
    ID_GET_ERC,
    ID_GET_ERC,
@@ -138,8 +136,6 @@ enum id_eeschema_frm
	ID_LIBEDIT_GET_FRAME_EDIT_PART,
	ID_LIBEDIT_GET_FRAME_EDIT_PART,
	ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
	ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
	ID_LIBEDIT_DELETE_PART,
	ID_LIBEDIT_DELETE_PART,
	ID_LIBEDIT_UNDO,
	ID_LIBEDIT_REDO,
	ID_DE_MORGAN_NORMAL_BUTT,
	ID_DE_MORGAN_NORMAL_BUTT,
	ID_DE_MORGAN_CONVERT_BUTT,
	ID_DE_MORGAN_CONVERT_BUTT,
	ID_LIBEDIT_EDIT_PIN_BY_PIN,
	ID_LIBEDIT_EDIT_PIN_BY_PIN,
+4 −4
Original line number Original line Diff line number Diff line
@@ -80,12 +80,12 @@ static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ),


/* Undo */
/* Undo */
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
static Ki_HotkeyInfo HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z',
                             (int) ID_SCHEMATIC_UNDO );
                             (int) wxID_UNDO );


/* Redo */
/* Redo */
#if !defined( __WXMAC__ )
#if !defined( __WXMAC__ )
    static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
    static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y',
                             (int) ID_SCHEMATIC_REDO );
                             (int) wxID_REDO );
#else
#else
    static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO,
    static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO,
                                 GR_KB_SHIFT + GR_KB_CTRL + 'Z',
                                 GR_KB_SHIFT + GR_KB_CTRL + 'Z',
@@ -699,7 +699,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
    case HK_UNDO:
    case HK_UNDO:
        if( !ItemInEdit )
        if( !ItemInEdit )
        {
        {
            toolCmd.SetId( ID_LIBEDIT_UNDO );
            toolCmd.SetId( wxID_UNDO );
            GetEventHandler()->ProcessEvent( toolCmd );
            GetEventHandler()->ProcessEvent( toolCmd );
        }
        }
        break;
        break;
@@ -707,7 +707,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
    case HK_REDO:
    case HK_REDO:
        if( !ItemInEdit )
        if( !ItemInEdit )
        {
        {
            toolCmd.SetId( ID_LIBEDIT_REDO );
            toolCmd.SetId( wxID_REDO );
            GetEventHandler()->ProcessEvent( toolCmd );
            GetEventHandler()->ProcessEvent( toolCmd );
        }
        }
        break;
        break;
+4 −4
Original line number Original line Diff line number Diff line
@@ -79,9 +79,9 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
              WinEDA_LibeditFrame::LoadOneLibraryPart )
              WinEDA_LibeditFrame::LoadOneLibraryPart )
    EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
    EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
              WinEDA_LibeditFrame::Process_Special_Functions )
              WinEDA_LibeditFrame::Process_Special_Functions )
    EVT_TOOL( ID_LIBEDIT_UNDO,
    EVT_TOOL( wxID_UNDO,
              WinEDA_LibeditFrame::GetComponentFromUndoList )
              WinEDA_LibeditFrame::GetComponentFromUndoList )
    EVT_TOOL( ID_LIBEDIT_REDO,
    EVT_TOOL( wxID_REDO,
              WinEDA_LibeditFrame::GetComponentFromRedoList )
              WinEDA_LibeditFrame::GetComponentFromRedoList )
    EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART,
    EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART,
              WinEDA_LibeditFrame::OnEditComponentProperties )
              WinEDA_LibeditFrame::OnEditComponentProperties )
@@ -134,8 +134,8 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
                   WinEDA_LibeditFrame::OnUpdateEditingPart )
                   WinEDA_LibeditFrame::OnUpdateEditingPart )
    EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART,
    EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART,
                   WinEDA_LibeditFrame::OnUpdateEditingPart )
                   WinEDA_LibeditFrame::OnUpdateEditingPart )
    EVT_UPDATE_UI( ID_LIBEDIT_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
    EVT_UPDATE_UI( wxID_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
    EVT_UPDATE_UI( ID_LIBEDIT_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
    EVT_UPDATE_UI( wxID_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
    EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB,
    EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB,
                   WinEDA_LibeditFrame::OnUpdateSaveCurrentLib )
                   WinEDA_LibeditFrame::OnUpdateSaveCurrentLib )
    EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, WinEDA_LibeditFrame::OnUpdateViewDoc )
    EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, WinEDA_LibeditFrame::OnUpdateViewDoc )
Loading