bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{
    LSET lset = m_PrintParams.m_PrintMaskLayer;

    // compute layer mask from page number if we want one page per layer
    if( m_PrintParams.m_OptionPrintPage == 0 )  // One page per layer
    {
        // This sequence is TBD, call a different
        // sequencer if needed, such as Seq().  Could not find documentation on
        // page order.
        LSEQ seq = lset.UIOrder();

        // aPage starts at 1, not 0
        if( unsigned( aPage-1 ) < seq.size() )
            m_PrintParams.m_PrintMaskLayer = LSET( seq[aPage-1] );
    }

    if( !m_PrintParams.m_PrintMaskLayer.any() )
        return false;

    // In Pcbnew we can want the layer EDGE always printed
    if( m_PrintParams.m_Flags == 1 )
        m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts );

    DrawPage();

    m_PrintParams.m_PrintMaskLayer = lset;

    return true;
}
// Reload the Layers
void PCB_LAYER_BOX_SELECTOR::Resync()
{
    Clear();

    // Tray to fix a minimum width fot the BitmapComboBox
    int minwidth = 80;

    wxClientDC dc( GetParent() );   // The DC for "this" is not always initialized

    const int BM_SIZE = 14;

    LSET show = LSET::AllLayersMask() & ~m_layerMaskDisable;
    LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
    wxString layerstatus;

    for( LSEQ seq = show.UIOrder();  seq;  ++seq )
    {
        LAYER_ID   layerid = *seq;

        if( !m_showNotEnabledBrdlayers && !activated[layerid] )
            continue;
        else if( !activated[layerid] )
            layerstatus = wxT( " " ) + _( "(not activated)" );
        else
            layerstatus.Empty();

        wxBitmap   layerbmp( BM_SIZE, BM_SIZE );
        SetBitmapLayer( layerbmp, layerid );

        wxString layername = GetLayerName( layerid ) + layerstatus;

        if( m_layerhotkeys && m_hotkeys )
        {
            int id = layer2hotkey_id( layerid );

            if( id != -1 )
                layername = AddHotkeyName( layername, m_hotkeys, id, IS_COMMENT );
        }

        Append( layername, layerbmp, (void*)(intptr_t) layerid );

        int w, h;
        dc.GetTextExtent ( layername, &w, &h );
        minwidth = std::max( minwidth, w );
    }

    minwidth += BM_SIZE + 35;    // Take in account the bitmap size and margins
    SetMinSize( wxSize( minwidth, -1 ) );
}
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{
    LSET lset = m_PrintParams.m_PrintMaskLayer;
    int pageCount = lset.count();
    wxString layer;
    LAYER_ID extractLayer;

    // compute layer mask from page number if we want one page per layer
    if( m_PrintParams.m_OptionPrintPage == 0 )  // One page per layer
    {
        // This sequence is TBD, call a different
        // sequencer if needed, such as Seq().  Could not find documentation on
        // page order.
        LSEQ seq = lset.UIOrder();

        // aPage starts at 1, not 0
        if( unsigned( aPage-1 ) < seq.size() )
            m_PrintParams.m_PrintMaskLayer = LSET( seq[aPage-1] );
    }

    if( !m_PrintParams.m_PrintMaskLayer.any() )
        return false;

    extractLayer = m_PrintParams.m_PrintMaskLayer.ExtractLayer();
    if( extractLayer == UNDEFINED_LAYER )
        layer = _( "Multiple Layers" );
    else
        layer = LSET::Name( extractLayer );

    // In Pcbnew we can want the layer EDGE always printed
    if( m_PrintParams.m_Flags == 1 )
        m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts );

    DrawPage( layer, aPage, pageCount );

    m_PrintParams.m_PrintMaskLayer = lset;

    return true;
}