Commit 445843e3 authored by charras's avatar charras
Browse files

Eeschema added resizable lib and cmp lists in viewlib when using AUI option.

Added patch for macOSX
turn on fast algo for draw grid (should work now)
parent 7b78dc1a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -769,7 +769,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
        // Under linux, to be tested (could be depend on linux versions
        // Under linux, to be tested (could be depend on linux versions
        // so perhaps could be necessary to set this option at run time.
        // so perhaps could be necessary to set this option at run time.


#if 1
#if 0
        // Use a pixel based draw to display grid
        // Use a pixel based draw to display grid
        // There is a lot of calls, so the cost is hight
        // There is a lot of calls, so the cost is hight
        // and grid is slowly drawn on some platforms
        // and grid is slowly drawn on some platforms
+34 −1
Original line number Original line Diff line number Diff line
@@ -32,10 +32,43 @@ const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files (*.eq
const wxString titleLibLoadError( _( "Library Load Error" ) );
const wxString titleLibLoadError( _( "Library Load Error" ) );




/* MacOSX: Needed for file association 
 * http://wiki.wxwidgets.org/WxMac-specific_topics
 */
void WinEDA_App::MacOpenFile(const wxString &fileName) {
    wxFileName    fn = fileName;
    wxString      oldPath;
    WinEDA_CvpcbFrame * frame = ((WinEDA_CvpcbFrame*)GetTopWindow());

    if( frame->m_NetlistFileName.DirExists() )
        oldPath = frame->m_NetlistFileName.GetPath();

    /* Update the library search path list. */
    if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
        wxGetApp().GetLibraryPathList().Remove( oldPath );
    wxGetApp().GetLibraryPathList().Insert( fn.GetPath(), 0 );

    frame->m_NetlistFileName = fn;

    if( frame->ReadNetList() )
    {
        frame->SetLastProject( fn.GetFullPath() );

        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
                  wxT( " " ) + fn.GetFullPath() );
    }
    else
    {
        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
    }

    frame->ReCreateMenuBar();

}

// Create a new application object
// Create a new application object
IMPLEMENT_APP( WinEDA_App )
IMPLEMENT_APP( WinEDA_App )



/************************************/
/************************************/
/* Called to initialize the program */
/* Called to initialize the program */
/************************************/
/************************************/
+9 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,15 @@ int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };
// not wxApp)
// not wxApp)
IMPLEMENT_APP( WinEDA_App )
IMPLEMENT_APP( WinEDA_App )


/* MacOSX: Needed for file association 
 * http://wiki.wxwidgets.org/WxMac-specific_topics
 */
void WinEDA_App::MacOpenFile(const wxString &fileName) {
    WinEDA_SchematicFrame * frame = ((WinEDA_SchematicFrame*) GetTopWindow());
    frame->LoadOneEEProject( fileName, false );
}


bool WinEDA_App::OnInit()
bool WinEDA_App::OnInit()
{
{
    wxFileName             fn;
    wxFileName             fn;
+71 −65
Original line number Original line Diff line number Diff line
@@ -119,17 +119,16 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
    wxSize  size = GetClientSize();
    wxSize  size = GetClientSize();
    size.y -= m_MsgFrameHeight + 2;
    size.y -= m_MsgFrameHeight + 2;


    m_LibListSize.y = size.y;
    m_LibListSize.y = -1;


    wxPoint win_pos( 0, 0 );
    wxPoint win_pos( 0, 0 );


#if !defined(KICAD_AUIMANAGER)
    if( Library == NULL )
    if( Library == NULL )
    {
    {
        // Creates the libraries window display
        // Creates the libraries window display
        m_LibListWindow =
        m_LibListWindow =
            new wxSashLayoutWindow( this, ID_LIBVIEW_LIBWINDOW, win_pos,
            new wxSashLayoutWindow( this, ID_LIBVIEW_LIBWINDOW, win_pos,
                                    m_LibListSize, wxCLIP_CHILDREN | wxSW_3D,
                                    wxDefaultSize, wxCLIP_CHILDREN | wxSW_3D,
                                    wxT( "LibWindow" ) );
                                    wxT( "LibWindow" ) );
        m_LibListWindow->SetOrientation( wxLAYOUT_VERTICAL );
        m_LibListWindow->SetOrientation( wxLAYOUT_VERTICAL );
        m_LibListWindow->SetAlignment( wxLAYOUT_LEFT );
        m_LibListWindow->SetAlignment( wxLAYOUT_LEFT );
@@ -137,9 +136,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
        m_LibListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
        m_LibListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
        m_LibList =
        m_LibList =
            new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
            new wxListBox( m_LibListWindow, ID_LIBVIEW_LIB_LIST,
                           wxPoint( 0, 0 ),
                           wxPoint( 0, 0 ), wxDefaultSize,
                           m_LibListWindow->GetClientSize() -
                           wxSize( EXTRA_BORDER_SIZE * 2, 0 ),
                           0, NULL, wxLB_HSCROLL );
                           0, NULL, wxLB_HSCROLL );
    }
    }
    else
    else
@@ -154,9 +151,8 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
    // Creates the component window display
    // Creates the component window display
    m_CmpListSize.y = size.y;
    m_CmpListSize.y = size.y;
    win_pos.x = m_LibListSize.x;
    win_pos.x = m_LibListSize.x;
    win_pos.y = 0;
    m_CmpListWindow = new wxSashLayoutWindow( this, ID_LIBVIEW_CMPWINDOW,
    m_CmpListWindow = new wxSashLayoutWindow( this, ID_LIBVIEW_CMPWINDOW,
                                              win_pos, m_CmpListSize,
                                              win_pos, wxDefaultSize,
                                              wxCLIP_CHILDREN | wxSW_3D,
                                              wxCLIP_CHILDREN | wxSW_3D,
                                              wxT( "CmpWindow" ) );
                                              wxT( "CmpWindow" ) );
    m_CmpListWindow->SetOrientation( wxLAYOUT_VERTICAL );
    m_CmpListWindow->SetOrientation( wxLAYOUT_VERTICAL );
@@ -164,35 +160,9 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
    m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, TRUE );
    m_CmpListWindow->SetSashVisible( wxSASH_RIGHT, TRUE );
    m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
    m_CmpListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
    m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
    m_CmpList = new wxListBox( m_CmpListWindow, ID_LIBVIEW_CMP_LIST,
                               wxPoint( 0, 0 ),
                               wxPoint( 0, 0 ), wxDefaultSize,
                               m_CmpListWindow->GetClientSize() -
                               wxSize( EXTRA_BORDER_SIZE * 2, 0 ),
                               0, NULL, wxLB_HSCROLL );
#else
    if( Library == NULL )
    {
        m_LibList =
            new wxListBox( this, ID_LIBVIEW_LIB_LIST,
                           wxPoint( 0, 0 ),
                           wxDefaultSize,
                           0, NULL, wxLB_HSCROLL );
    }
    else
    {
        m_libraryName = Library->GetName();
        m_entryName.Clear();
        m_unit = 1;
        m_convert = 1;
        m_LibListSize.x = 0;
    }

    m_CmpList = new wxListBox( this , ID_LIBVIEW_CMP_LIST,
                               wxPoint( 0, 0 ),
                               wxDefaultSize,
                               0, NULL, wxLB_HSCROLL );
                               0, NULL, wxLB_HSCROLL );


#endif

    if( m_LibList )
    if( m_LibList )
        ReCreateListLib();
        ReCreateListLib();


@@ -219,22 +189,47 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
    vert.TopDockable( false ).BottomDockable( false );
    vert.TopDockable( false ).BottomDockable( false );
    horiz.LeftDockable( false ).RightDockable( false );
    horiz.LeftDockable( false ).RightDockable( false );


    // Manage main toolbal
    m_auimgr.AddPane( m_HToolBar,
    m_auimgr.AddPane( m_HToolBar,
                      wxAuiPaneInfo( horiz ).Name( wxT ("m_HToolBar" ) ).Top().Row( 0 ) );
                      wxAuiPaneInfo( horiz ).Name( wxT ("m_HToolBar" ) ).Top().Row( 0 ) );


    m_auimgr.AddPane( m_LibList,
    wxSize minsize(60,-1);
                      wxAuiPaneInfo( vert ).Name( wxT( "m_LibList" ) ).Left().Row( 0 ) );
    // Manage the left window (list of libraries)
    if( m_LibListWindow )
        m_auimgr.AddPane( m_LibListWindow,
                      wxAuiPaneInfo( vert ).Name( wxT( "m_LibList" ) ).
                      Left().Row( 0 ).MinSize(minsize) );


    m_auimgr.AddPane( m_CmpList,
    // Manage the list of components)
                      wxAuiPaneInfo( vert ).Name( wxT( "m_CmpList" ) ).Left().Row( 1 ) );
    m_auimgr.AddPane( m_CmpListWindow,
                      wxAuiPaneInfo( vert ).Name( wxT( "m_CmpList" ) ).
                      Left().Row( 1 ).MinSize(minsize) );


    // Manage the draw panel
    m_auimgr.AddPane( DrawPanel,
    m_auimgr.AddPane( DrawPanel,
                      wxAuiPaneInfo( vert ).Name( wxT( "DrawFrame" ) ).Center() );
                      wxAuiPaneInfo( vert ).Name( wxT( "DrawFrame" ) ).Centre() );


    // Manage the message panel
    m_auimgr.AddPane( MsgPanel,
    m_auimgr.AddPane( MsgPanel,
                      wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
                      wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );


    /* Now the minimum windows are fixed, set library list
    and component list of the previous values from last viewlib use
    */
    if( m_LibListWindow )
    {
        wxAuiPaneInfo& pane = m_auimgr.GetPane(m_LibListWindow);
        pane.MinSize( wxSize(m_LibListSize.x, -1));
    }
    wxAuiPaneInfo& pane = m_auimgr.GetPane(m_CmpListWindow);
    pane.MinSize(wxSize(m_CmpListSize.x, -1));

    m_auimgr.Update();
    m_auimgr.Update();

#else
    m_CmpListWindow->SetSize(m_CmpListSize);
    if( m_LibListWindow )
        m_LibListWindow->SetSize(m_LibListSize);
#endif
#endif
}
}


@@ -267,6 +262,7 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
    m_LibListSize.y = GetClientSize().y - m_MsgFrameHeight;
    m_LibListSize.y = GetClientSize().y - m_MsgFrameHeight;
    m_CmpListSize.y = m_LibListSize.y;
    m_CmpListSize.y = m_LibListSize.y;


#ifndef KICAD_AUIMANAGER
    switch( event.GetId() )
    switch( event.GetId() )
    {
    {
    case ID_LIBVIEW_LIBWINDOW:
    case ID_LIBVIEW_LIBWINDOW:
@@ -275,6 +271,7 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
            m_LibListSize.x = event.GetDragRect().width;
            m_LibListSize.x = event.GetDragRect().width;
            m_LibListWindow->SetSize( m_LibListSize );
            m_LibListWindow->SetSize( m_LibListSize );
            m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) );
            m_CmpListWindow->SetPosition( wxPoint( m_LibListSize.x, 0 ) );
            m_CmpListWindow->SetSize( m_CmpListSize );
        }
        }
        break;
        break;


@@ -287,31 +284,39 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event )
    // Now, we must recalculate the position and size of subwindows
    // Now, we must recalculate the position and size of subwindows
    wxSizeEvent SizeEv;
    wxSizeEvent SizeEv;
    OnSize( SizeEv );
    OnSize( SizeEv );
#else
    switch( event.GetId() )
    {
    case ID_LIBVIEW_LIBWINDOW:
        if( m_LibListWindow )
        {
            wxAuiPaneInfo& pane = m_auimgr.GetPane(m_LibListWindow);
            m_LibListSize.x = event.GetDragRect().width;
            pane.MinSize(m_LibListSize);
            m_auimgr.Update();
        }
        break;

    case ID_LIBVIEW_CMPWINDOW:
    {
            wxAuiPaneInfo& pane = m_auimgr.GetPane(m_CmpListWindow);
            m_CmpListSize.x = event.GetDragRect().width;
            pane.MinSize(m_CmpListSize);
            m_auimgr.Update();
    }
        break;
    }
#endif
}
}




void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
{
{
    wxSize clientsize;
#ifndef KICAD_AUIMANAGER
    wxSize maintoolbar_size;
    wxSize clientsize = GetClientSize();
    wxSize Vtoolbar_size;

    clientsize    = GetClientSize();
    m_FrameSize   = clientsize;
    m_FrameSize   = clientsize;
    clientsize.y -= m_MsgFrameHeight;
    clientsize.y -= m_MsgFrameHeight;


    if( m_HToolBar )
    {
        maintoolbar_size = m_HToolBar->GetSize();
    }

    if( m_VToolBar )
    {
        Vtoolbar_size = m_VToolBar->GetSize();
        m_VToolBar->SetSize( clientsize.x - maintoolbar_size.y, 0, -1,
                             clientsize.y );
    }

    if( MsgPanel )
    if( MsgPanel )
    {
    {
        MsgPanel->SetSize( 0, clientsize.y, clientsize.x, m_MsgFrameHeight );
        MsgPanel->SetSize( 0, clientsize.y, clientsize.x, m_MsgFrameHeight );
@@ -319,10 +324,9 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )


    if( DrawPanel )
    if( DrawPanel )
    {
    {
        DrawPanel->SetSize( m_LibListSize.x + m_CmpListSize.x, 0,
        int xpos = m_LibListSize.x + m_CmpListSize.x;
                            clientsize.x - Vtoolbar_size.x -
        DrawPanel->SetSize( xpos, 0,
                            m_LibListSize.x - m_CmpListSize.x,
                            clientsize.x - xpos, clientsize.y );
                            clientsize.y );
    }
    }


    if( m_LibList && m_LibListWindow )
    if( m_LibList && m_LibListWindow )
@@ -342,15 +346,17 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv )
                            wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
                            wxSize( EXTRA_BORDER_SIZE * 2, 0 ) );
    }
    }


#if defined(KICAD_AUIMANAGER)
    SizeEv.Skip();

    // Ensure the panel is always redrawn (sometimes some garbage remains):
    DrawPanel->Refresh();
#else
    if( m_auimgr.GetManagedWindow() )
    if( m_auimgr.GetManagedWindow() )
        m_auimgr.Update();
        m_auimgr.Update();
#endif


    SizeEv.Skip();
    SizeEv.Skip();
#endif


    // Ensure the panel is always redrawn (sometimes some garbage remains):
    DrawPanel->Refresh();
}
}




+8 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,14 @@ Ki_PageDescr* g_GerberPageSizeList[] =


IMPLEMENT_APP( WinEDA_App )
IMPLEMENT_APP( WinEDA_App )


/* MacOSX: Needed for file association 
 * http://wiki.wxwidgets.org/WxMac-specific_topics
 */
void WinEDA_App::MacOpenFile(const wxString &fileName) {
    WinEDA_GerberFrame * frame = ((WinEDA_GerberFrame*)GetTopWindow());
    frame->LoadOneGerberFile( fileName, FALSE );
}



bool WinEDA_App::OnInit()
bool WinEDA_App::OnInit()
{
{
Loading