Commit 7c99a242 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Remove 2 global variables: g_DrawBgColor and g_ShowPageLimits.

They are now member of EDA_DRAW_FRAME.
This change could fix Bug #1330781 (Background color change in Eeschema affects background color in Pcbnew)
Show page limits has meaning only for the schematic editor,  the board editor and the page layout editor.
Draw background color selection exists only in eeschema and  page layout editor.
In pcbnew, only a black background is allowed.
A side effect is now the user should set the background color in schematic editor, and the library editor (2 different options).
The default is still the white color.
parent 94d78047
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
    m_LastGridSizeId      = 0;
    m_DrawGrid            = true;       // hide/Show grid. default = show
    m_GridColor           = DARKGRAY;   // Grid color
    m_showPageLimits      = false;
    m_drawBgColor         = BLACK;      // the background color of the draw canvas:
                                        // BLACK for Pcbnew, BLACK or WHITeEfor eeschema
    m_snapToGrid          = true;
    m_MsgFrameHeight      = EDA_MSG_PANEL::GetRequiredHeight();
    m_movingCursorWithKeyboard = false;
+10 −6
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
    m_scrollIncrementX = std::min( size.x / 8, 10 );
    m_scrollIncrementY = std::min( size.y / 8, 10 );

    SetBackgroundColour( MakeColour( g_DrawBgColor ) );
    SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );

#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
    SetBackgroundStyle( wxBG_STYLE_CUSTOM );
@@ -528,9 +528,11 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
{
    GRSetDrawMode( DC, GR_COPY );

    EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();

    GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
                   m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
                   0, g_DrawBgColor, g_DrawBgColor );
                   0, bgColor, bgColor );

    // Set to one (1) to draw bounding box validate bounding box calculation.
#if DEBUG_SHOW_CLIP_RECT
@@ -583,10 +585,12 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
    if( Screen == NULL )
        return;

    if( ( g_DrawBgColor != WHITE ) && ( g_DrawBgColor != BLACK ) )
        g_DrawBgColor = BLACK;
    EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();

    if( ( bgColor != WHITE ) && ( bgColor != BLACK ) )
        bgColor = BLACK;

    if( g_DrawBgColor == WHITE )
    if( bgColor == WHITE )
    {
        g_XorMode    = GR_NXOR;
        g_GhostColor = BLACK;
@@ -599,7 +603,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )

    GRResetPenAndBrush( DC );

    DC->SetBackground( g_DrawBgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
    DC->SetBackground( bgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
    DC->SetBackgroundMode( wxSOLID );

    if( erasebg )
+0 −31
Original line number Diff line number Diff line
@@ -31,12 +31,6 @@
#include <pgm_base.h>

#include <common.h>
#include <gr_basic.h>


static const wxChar showPageLimitsKey[]  = wxT( "ShowPageLimits" );
static const wxChar backgroundColorKey[] = wxT( "BackgroundColor" );


/// Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
/// A non-member function so it an be moved easily, plus it's nobody's business.
@@ -97,24 +91,7 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
bool KIFACE_I::start_common( int aCtlBits )
{
    m_start_flags = aCtlBits;

    m_bm.Init();

    m_bm.m_config->Read( showPageLimitsKey, &g_ShowPageLimits );

    // FIXME OSX Mountain Lion (10.8)
    // Seems that Read doesn't found anything and ColorFromInt
    // Asserts - I'm unable to reproduce on 10.7

    int draw_bg_color = BLACK;      // Default for all apps but Eeschema

    if( m_id == KIWAY::FACE_SCH )
        draw_bg_color = WHITE;      // Default for Eeschema

    m_bm.m_config->Read( backgroundColorKey, &draw_bg_color );

    g_DrawBgColor = ColorFromInt( draw_bg_color );

    setSearchPaths( &m_bm.m_search, m_id );

    return true;
@@ -123,14 +100,6 @@ bool KIFACE_I::start_common( int aCtlBits )

void KIFACE_I::end_common()
{
    if( m_bm.m_config )
    {
        // Save common preferences; the background still uses the old legacy
        // color numbers, not the new names
        m_bm.m_config->Write( showPageLimitsKey, g_ShowPageLimits );
        m_bm.m_config->Write( backgroundColorKey, int( g_DrawBgColor ) );
    }

    m_bm.End();
}
+2 −2
Original line number Diff line number Diff line
@@ -83,12 +83,12 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
    wxSize  pageSize = pageInfo.GetSizeMils();

    // if not printing, draw the page limits:
    if( !aScreen->m_IsPrinting && g_ShowPageLimits )
    if( !aScreen->m_IsPrinting && m_showPageLimits )
    {
        GRSetDrawMode( aDC, GR_COPY );
        GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
                pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
                g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
                m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
    }

    TITLE_BLOCK t_block = GetTitleBlock();
+0 −2
Original line number Diff line number Diff line
@@ -294,8 +294,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
    // SetFootprintLibTablePath();
    */

    g_DrawBgColor = BLACK;

    try
    {
        // The global table is not related to a specific project.  All projects
Loading