Beispiel #1
0
void LAYER_WIDGET::OnTabChange( wxNotebookEvent& event )
{
//    wxFocusEvent    event( wxEVT_SET_FOCUS );
//    m_FocusOwner->AddPendingEvent( event );

    passOnFocus();      // does not work in this context, probably because we have receive control here too early.
}
Beispiel #2
0
void LAYER_WIDGET::SelectLayerRow( int aRow )
{
    // enable the layer tab at index 0
    m_notebook->SetSelection( 0 );

    INDICATOR_ICON* oldIndicator = (INDICATOR_ICON*) getLayerComp( m_CurrentRow, 0 );
    if( oldIndicator )
        oldIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );

    INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
    if( newIndicator )
    {
        newIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::ON );

        // Make sure the desired layer row is visible.
        // It seems that as of 2.8.2, setting the focus does this.
        // I don't expect the scrolling to be needed at all because
        // the minimum window size may end up being established so that the
        // scroll bars will not be visible.
        getLayerComp( aRow, 1 )->SetFocus();
    }

    m_CurrentRow = aRow;

    // give the focus back to the app.
    passOnFocus();
}
Beispiel #3
0
void LAYER_WIDGET::OnRenderCheckBox( wxCommandEvent& event )
{
    wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
    LAYER_NUM id = getDecodedId( eventSource->GetId() );
    OnRenderEnable( id, eventSource->IsChecked() );
    passOnFocus();
}
Beispiel #4
0
void LAYER_WIDGET::OnLayerCheckBox( wxCommandEvent& event )
{
    wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
    LAYER_NUM layer = getDecodedId( eventSource->GetId() );
    OnLayerVisible( layer, eventSource->IsChecked() );
    passOnFocus();
}
void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
{
    wxMenu          menu;

    AddRightClickMenuItems( &menu );
    PopupMenu( &menu );

    passOnFocus();
}
void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
{
    wxMenu          menu;

    // menu text is capitalized:
    // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
    menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_COPPERS, _( "Show All Copper Layers" ) ) );
    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS_BUT_ACTIVE,  _( "Hide All Copper Layers But Active" ) ) );
    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS,  _( "Hide All Copper Layers" ) ) );

    PopupMenu( &menu );

    passOnFocus();
}
Beispiel #7
0
void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event )
{
    int row;
    LAYER_NUM layer;

    wxWindow* eventSource = (wxWindow*) event.GetEventObject();

    // if mouse event is coming from the m_LayerScrolledWindow and not one
    // of its children, we have to find the row manually based on y coord.
    if( eventSource == m_LayerScrolledWindow )
    {
        int y = event.GetY();

        wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights();

        int height = 0;

        int rowCount = GetLayerRowCount();
        for( row = 0;  row<rowCount;  ++row )
        {
            if( y < height + heights[row] )
                break;

            height += heights[row];
        }

        if( row >= rowCount )
            row = rowCount - 1;

        layer = getDecodedId( getLayerComp( row, 0 )->GetId() );
    }

    else
    {
        // all nested controls on a given row will have their ID encoded with
        // encodeId(), and the corresponding decoding is getDecodedId()
        int id = eventSource->GetId();
        layer  = getDecodedId( id );
        row    = findLayerRow( layer );
    }

    if( OnLayerSelect( layer ) )    // if client allows this change.
        SelectLayerRow( row );

    passOnFocus();
}
Beispiel #8
0
void LAYER_WIDGET::OnLayerSwatchChanged( wxCommandEvent& aEvent )
{
    auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );

    COLOR4D newColor = eventSource->GetSwatchColor();

    LAYER_NUM layer = getDecodedId( eventSource->GetId() );

    // tell the client code.
    OnLayerColorChange( layer, newColor );

    // notify others
    wxCommandEvent event( EVT_LAYER_COLOR_CHANGE );
    wxPostEvent( this, event );

    passOnFocus();
}
Beispiel #9
0
void LAYER_WIDGET::OnRightDownRender( wxMouseEvent& aEvent, COLOR_SWATCH* aColorSwatch, const wxString& aRenderName )
{
    wxMenu menu;

    AddMenuItem( &menu, ID_CHANGE_RENDER_COLOR,
                 _( "Change Render Color for " ) + aRenderName,
                 KiBitmap( setcolor_board_body_xpm ) );

    menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [this, aColorSwatch]( wxCommandEvent& event ) {
        if ( event.GetId() == ID_CHANGE_RENDER_COLOR ) {
            aColorSwatch->GetNewSwatchColor();
        } else {
            event.Skip();
        }
    } );

    PopupMenu( &menu );
    passOnFocus();
}
void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
{
    wxMenu          menu;

    // Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt)
    menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS,
                                 _("Show All Layers") ) );

    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
                                 _( "Hide All Layers But Active" ) ) );

    menu.Append( new wxMenuItem( &menu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
                                 _( "Always Hide All Layers But Active" ) ) );

    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS,
                                 _( "Hide All Layers" ) ) );

    menu.AppendSeparator();
    menu.Append( new wxMenuItem( &menu, ID_SORT_GBR_LAYERS,
                                 _( "Sort Layers if X2 Mode" ) ) );
    PopupMenu( &menu );

    passOnFocus();
}
Beispiel #11
0
void LAYER_WIDGET::OnRenderSwatchChanged( wxCommandEvent& aEvent )
{
    auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );

    COLOR4D newColor = eventSource->GetSwatchColor();

    LAYER_NUM id = getDecodedId( eventSource->GetId() );

    if( id == LAYER_PCB_BACKGROUND )
    {
        // Update all swatch backgrounds
        int count = GetLayerRowCount();
        int row;
        int col = 1;    // bitmap button is column 1 in layers tab
        for( row = 0; row < count; ++row )
        {
            COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
            if( swatch )
                swatch->SetSwatchBackground( newColor );
        }

        count = GetRenderRowCount();
        col = 0;    // bitmap button is column 0 in render tab
        for( row = 0; row < count; ++row )
        {
            COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
            if( swatch )
                swatch->SetSwatchBackground( newColor );
        }
    }

    // tell the client code.
    OnRenderColorChange( id, newColor );

    passOnFocus();
}