bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl()
{
    // Check for color conflicts with background color to give user a chance to bail
    // out before making changes.

    COLOR4D bgcolor = currentColors[ LAYER_SCHEMATIC_BACKGROUND ];

    for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
    {
        if( bgcolor == currentColors[ clyr ] && clyr != LAYER_SCHEMATIC_BACKGROUND )
        {
            wxString msg = _( "Some items have the same color as the background\n"
                              "and they will not be seen on the screen.  Are you\n"
                              "sure you want to use these colors?" );

            if( wxMessageBox( msg,  _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
                return false;

            break;
        }
    }

    for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr )
        SetLayerColor( currentColors[ clyr ], clyr );

    SetLayerColor( currentColors[ LAYER_WORKSHEET ], (SCH_LAYER_ID) LAYER_WORKSHEET );

    return true;
}
bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{
    // Update color of background
    EDA_COLOR_T bgcolor = WHITE;

    if( m_SelBgColor->GetSelection() > 0 )
        bgcolor =  BLACK;

    m_parent->SetDrawBgColor( bgcolor );
    currentColors[ LAYER_BACKGROUND ] = bgcolor;

    bool warning = false;

    for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
    {
        SetLayerColor( currentColors[ clyr ], clyr );

        if(  bgcolor == GetLayerColor( clyr ) && clyr != LAYER_BACKGROUND )
            warning = true;
    }

    m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) );

    if( bgcolor == GetLayerColor( LAYER_GRID ) )
        warning = true;

    return warning;
}
Example #3
0
EXPORT void ResetLayers( void )
{
	int inx;
	for ( inx=0;inx<NUM_LAYERS; inx++ ) {
		strcpy( layers[inx].name, inx==0?_("Main"):"" );
		layers[inx].visible = TRUE;
		layers[inx].frozen = FALSE;
		layers[inx].onMap = TRUE;
		layers[inx].objCount = 0;
		SetLayerColor( inx, layerColorTab[inx%COUNT(layerColorTab)] );
		if ( inx<NUM_BUTTONS ) {
			wButtonSetLabel( layer_btns[inx], (char*)show_layer_bmps[inx] );
		}
	}
	wControlSetBalloonText( (wControl_p)layer_btns[0], _("Main") );
	for ( inx=1; inx<NUM_BUTTONS; inx++ ) {
		wControlSetBalloonText( (wControl_p)layer_btns[inx], _("Show/Hide Layer") );
	}
	curLayer = 0;
	layerVisible = TRUE;
	layerFrozen = FALSE;
	layerOnMap = TRUE;
	layerColor = layers[0].color;
	strcpy( layerName, layers[0].name );
 	LoadLayerLists();

	if (layerL) {
		ParamLoadControls( &layerPG );
		ParamLoadMessage( &layerPG, I_COUNT, "0" );
	}
}
Example #4
0
EXPORT void RestoreLayers( void )
{
	int inx;
	char * label;
	wDrawColor color;

	assert( layers_save != NULL );
	memcpy( layers, layers_save, NUM_LAYERS * sizeof layers[0] );
	free( layers_save );
	
	for ( inx=0; inx<NUM_BUTTONS; inx++ ) {
		color = layers[inx].color;
		layers[inx].color = -1;
		SetLayerColor( inx, color );
		if ( layers[inx].name[0] == '\0' ) {
			if ( inx == 0 ) {
				label = _("Main");
			} else {
				label = _("Show/Hide Layer");
			}
		} else {
			label = layers[inx].name;
		}
		wControlSetBalloonText( (wControl_p)layer_btns[inx], label );
	}
	if (layerL) {
		ParamLoadControls( &layerPG );
		ParamLoadMessage( &layerPG, I_COUNT, "0" );
	}
	LoadLayerLists();
}
bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{
    // Update color of background
    if( m_SelBgColor->GetSelection() == 0 )
        g_DrawBgColor = WHITE;
    else
        g_DrawBgColor = BLACK;

    bool warning = false;

    for( int ii = 0;  ii < MAX_LAYERS;  ii++ )
    {
        SetLayerColor( currentColors[ ii ], ii );

        if( g_DrawBgColor == ReturnLayerColor( ii ) )
            warning = true;
    }

    m_Parent->SetGridColor( ReturnLayerColor( LAYER_GRID ) );

    if( g_DrawBgColor == ReturnLayerColor( LAYER_GRID ) )
        warning = true;

    return warning;
}
Example #6
0
static void LayerUpdate( void )
{
	BOOL_T redraw;
	ParamLoadData( &layerPG );
	if (layerCurrent < 0 || layerCurrent >= NUM_LAYERS)
		return;
	if (layerCurrent == curLayer && layerFrozen) {
		NoticeMessage( MSG_LAYER_FREEZE, _("Ok"), NULL );
		layerFrozen = FALSE;
		ParamLoadControl( &layerPG, I_FRZ );
	}
	if (layerCurrent == curLayer && !layerVisible) {
		NoticeMessage( MSG_LAYER_HIDE, _("Ok"), NULL );
		layerVisible = TRUE;
		ParamLoadControl( &layerPG, I_VIS );
	}
	
	if( strcmp( layers[(int)layerCurrent].name, layerName ) ||
		layerColor != layers[(int)layerCurrent].color || 
		layers[(int)layerCurrent].visible != (BOOL_T)layerVisible ||
		layers[(int)layerCurrent].frozen != (BOOL_T)layerFrozen ||
		layers[(int)layerCurrent].onMap != (BOOL_T)layerOnMap ) {
		
			changed = TRUE;
			SetWindowTitle();
	}

	if ( layerL ) {
		strncpy( layers[(int)layerCurrent].name, layerName, sizeof layers[(int)layerCurrent].name );
		sprintf( message, "%2d %c %s", (int)layerCurrent+1, layers[(int)layerCurrent].objCount>0?'+':'-', layers[(int)layerCurrent].name );
		wListSetValues( layerL, layerCurrent, message, NULL, NULL );
	}

	sprintf( message, "%2d : %s", (int)layerCurrent+1, layers[(int)layerCurrent].name );
	wListSetValues( setLayerL, layerCurrent, message, NULL, NULL );
	if (layerCurrent < NUM_BUTTONS) {
		if (strlen(layers[(int)layerCurrent].name)>0)
			wControlSetBalloonText( (wControl_p)layer_btns[(int)layerCurrent], layers[(int)layerCurrent].name );
		else
			wControlSetBalloonText( (wControl_p)layer_btns[(int)layerCurrent], _("Show/Hide Layer") );
	}
	redraw = ( layerColor != layers[(int)layerCurrent].color ||
			   (BOOL_T)layerVisible != layers[(int)layerCurrent].visible );
	if ( (!layerRedrawMap) && redraw)
		RedrawLayer( (LAYER_T)layerCurrent, FALSE );

	SetLayerColor( layerCurrent, layerColor );

	if (layerCurrent<NUM_BUTTONS && layers[(int)layerCurrent].visible!=(BOOL_T)layerVisible) {
		wButtonSetBusy( layer_btns[(int)layerCurrent], layerVisible );
	}
	layers[(int)layerCurrent].visible = (BOOL_T)layerVisible;
	layers[(int)layerCurrent].frozen = (BOOL_T)layerFrozen;
	layers[(int)layerCurrent].onMap = (BOOL_T)layerOnMap;
	if ( layerRedrawMap )
		DoRedraw();
	else if (redraw)
		RedrawLayer( (LAYER_T)layerCurrent, TRUE );
	layerRedrawMap = FALSE;
}
Example #7
0
EXPORT BOOL_T ReadLayers( char * line )
{
	char * name;
	int inx, visible, frozen, color, onMap;
	long rgb;

	/* older files didn't support layers */

	if (paramVersion < 7)
		return TRUE;

	/* set the current layer */

	if ( strncmp( line, "CURRENT", 7 ) == 0 ) {
		curLayer = atoi( line+7 );
		if ( curLayer < 0 )
			curLayer = 0;

		if (layerL)
			wListSetIndex( layerL, curLayer );
		if (setLayerL)
			wListSetIndex( setLayerL, curLayer );
			
		return TRUE;
	}

	/* get the properties for a layer from the file and update the layer accordingly */

	if (!GetArgs( line, "ddddl0000q", &inx, &visible, &frozen, &onMap, &rgb, &name ))
		return FALSE;
	if (paramVersion < 9) {
		if ( rgb >= 0 && (int)rgb < sizeof oldColorMap/sizeof oldColorMap[0] )
			rgb = wRGB( oldColorMap[(int)rgb][0], oldColorMap[(int)rgb][1], oldColorMap[(int)rgb][2] );
		else
			rgb = 0;
	}
	if (inx < 0 || inx >= NUM_LAYERS)
		return FALSE;
	color = wDrawFindColor(rgb);
	SetLayerColor( inx, color );
	strncpy( layers[inx].name, name, sizeof layers[inx].name );
	layers[inx].visible = visible;
	layers[inx].frozen = frozen;
	layers[inx].onMap = onMap;
	layers[inx].color = color;
	if (inx<NUM_BUTTONS) {
		if (strlen(name) > 0) {
			wControlSetBalloonText( (wControl_p)layer_btns[(int)inx], layers[inx].name );
		}
		wButtonSetBusy( layer_btns[(int)inx], visible );
	}
	return TRUE;
}
Example #8
0
void
LayerSystemDefaults( void )
{
	int inx;
	
	for ( inx=0;inx<NUM_LAYERS; inx++ ) {
		strcpy( layers[inx].name, inx==0?_("Main"):"" );
		layers[inx].visible = TRUE;
		layers[inx].frozen = FALSE;
		layers[inx].onMap = TRUE;
		layers[inx].objCount = 0;
		SetLayerColor( inx, layerColorTab[inx%COUNT(layerColorTab)] );
	}	
}
bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl()
{
    bool warning = false;

    // Check for color conflicts with background color to give user a chance to bail
    // out before making changes.

    EDA_COLOR_T bgcolor = WHITE;

    if( m_SelBgColor->GetSelection() > 0 )
        bgcolor =  BLACK;

    for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
    {
        if( bgcolor == currentColors[ clyr ] && clyr != LAYER_BACKGROUND )
        {
            warning = true;
            break;
        }
    }

    // Prompt the user if an item has the same color as the background
    // because this item cannot be seen:
    if( warning )
    {
        if( wxMessageBox( _( "Some items have the same color as the background\n"
                             "and they will not be seen on the screen.  Are you\n"
                             "sure you want to use these colors?" ),
                          _( "Warning" ),
                          wxYES_NO | wxICON_QUESTION, this ) == wxNO )
            return false;
    }

    // Update color of background
    GetDrawFrame()->SetDrawBgColor( bgcolor );
    currentColors[ LAYER_BACKGROUND ] = bgcolor;


    for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
    {
        SetLayerColor( currentColors[ clyr ], clyr );
    }

    GetDrawFrame()->SetGridColor( GetLayerColor( LAYER_GRID ) );
    GetDrawFrame()->GetCanvas()->Refresh();

    return true;
}
Example #10
0
static void
LayerPrefLoad( void )
{
	
	int inx;
	char layersSaved[ 3 * NUM_LAYERS ];
	char layerOption[ 20 ];
	const char *layerValue;
	const char *prefString;
	long rgb;
	int color;	
	long flags;

	/* reset layer preferences to system default */
	LayerSystemDefaults();
			
	prefString = wPrefGetString( LAYERPREF_SECTION, "layers" );
	if( prefString && prefString[ 0 ] ) {
		strncpy( layersSaved, prefString, sizeof( layersSaved ));
		prefString = strtok( layersSaved, "," );
		while( prefString ) {
			inx = atoi( prefString );
			sprintf( layerOption, LAYERPREF_NAME ".%d", inx );
			layerValue = wPrefGetString( LAYERPREF_SECTION, layerOption );
			if( layerValue )
				strcpy( layers[inx].name, layerValue );
			else 
				*(layers[inx].name) = '\0';
			
			/* get and set the color, using the system default color in case color is not available from prefs */
			sprintf( layerOption, LAYERPREF_COLOR ".%d", inx );
			wPrefGetInteger( LAYERPREF_SECTION, layerOption, &rgb, layerColorTab[inx%COUNT(layerColorTab)] ); 
			color = wDrawFindColor(rgb);
			SetLayerColor( inx, color );
			
			/* get and set the flags */
			sprintf( layerOption, LAYERPREF_FLAGS ".%d", inx );
			wPrefGetInteger( LAYERPREF_SECTION, layerOption, &flags, LAYERPREF_ONMAP | LAYERPREF_VISIBLE );

			layers[inx].frozen = ((flags & LAYERPREF_FROZEN) != 0 );
			layers[inx].onMap = ((flags & LAYERPREF_ONMAP) != 0 );
			layers[inx].visible = (( flags & LAYERPREF_VISIBLE ) != 0 );
						
			prefString = strtok( NULL, ",");
		}
	}
}
void SCH_BASE_FRAME::SetDrawBgColor( COLOR4D aColor)
{
    m_drawBgColor= aColor;
    SetLayerColor( aColor, LAYER_SCHEMATIC_BACKGROUND );
}
Example #12
0
bool EDA_APP::OnInit()
{
    wxFileName      filename;
    SCH_EDIT_FRAME* frame = NULL;
    bool fileReady = false;

    InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T );

    if( argc > 1 )
        filename = argv[1];

    if( filename.IsOk() )
    {
        if( filename.GetExt() != SchematicFileExtension )
            filename.SetExt( SchematicFileExtension );

        if( !wxGetApp().LockFile( filename.GetFullPath() ) )
        {
            DisplayError( NULL, _( "This file is already open." ) );
            return false;
        }

        fileReady = true;
    }

    if( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) )
            return false;
    }

    // Give a default colour for all layers
    // (actual color will be initialized by config)
    for( int ii = 0; ii < NB_SCH_LAYERS; ii++ )
        SetLayerColor( DARKGRAY, ii );

    // read current setup and reopen last directory if no filename to open in
    // command line
    bool reopenLastUsedDirectory = argc == 1;
    GetSettings( reopenLastUsedDirectory );

   /* Must be called before creating the main frame in order to
    * display the real hotkeys in menus or tool tips */
    ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr );

    // Create main frame (schematic frame) :
    frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );

    SetTopWindow( frame );
    frame->Show( true );

    CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER );

    frame->Zoom_Automatique( true );

    // Load file specified in the command line:
    if( fileReady )
    {
        if( !filename.GetPath().IsEmpty() )
            // wxSetWorkingDirectory does not like empty paths
            wxSetWorkingDirectory( filename.GetPath() );

        if( frame->LoadOneEEProject( filename.GetFullName(), false ) )
            frame->GetCanvas()->Refresh( true );
    }
    else
    {
        // Read a default config file if no file to load.
        frame->LoadProjectFile( wxEmptyString, true );
        frame->GetCanvas()->Refresh( true );
    }

    return true;
}