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;
}
コード例 #2
0
ファイル: DUIDecorate.cpp プロジェクト: achellies/DUI
VOID CDUIFramePanel::DrawFrameWithColor(HDC dc)
{
	RECT rtLeft, rtRight, rtTop, rtBottom;
	GetDrawFrame(rtLeft, rtRight, rtTop, rtBottom);

 	CDUIRenderEngine::DrawColor(dc, rtLeft, m_uiData.m_clrFrame);
 	CDUIRenderEngine::DrawColor(dc, rtRight, m_uiData.m_clrFrame);
 	CDUIRenderEngine::DrawColor(dc, rtTop, m_uiData.m_clrFrame);
 	CDUIRenderEngine::DrawColor(dc, rtBottom, m_uiData.m_clrFrame);
}
コード例 #3
0
ファイル: DUIDecorate.cpp プロジェクト: achellies/DUI
VOID CDUIFramePanel::DrawFrameWithImage(HDC dc)
{
	CalculateImageFrame();
	
	RECT rtLeft, rtRight, rtTop, rtBottom;
	GetDrawFrame(rtLeft, rtRight, rtTop, rtBottom);
	
	CRefPtr<CImageList>& pLeftImage = m_uiData.m_pImageLeft;
	CRefPtr<CImageList>& pRightImage = m_uiData.m_pImageRight;
	CRefPtr<CImageList>& pTopImage = m_uiData.m_pImageTop;
	CRefPtr<CImageList>& pBottomImage = m_uiData.m_pImageBottom;
	if(!pLeftImage.IsNull() && !pLeftImage->IsNull())
	{
		INT nImageIndex = m_nImageIndex;
		if(nImageIndex >= pLeftImage->GetItemCount()) nImageIndex = 0;
		pLeftImage->VerticalStretch(dc, rtLeft, nImageIndex);
	}
	
	if(!pRightImage.IsNull() && !pRightImage->IsNull())
	{
		INT nImageIndex = m_nImageIndex;
		if(nImageIndex >= pRightImage->GetItemCount()) nImageIndex = 0;
		pRightImage->VerticalStretch(dc, rtRight, nImageIndex);
	}
	
	if(!pBottomImage.IsNull() && !pBottomImage->IsNull())
	{
		INT nImageIndex = m_nImageIndex;
		if(nImageIndex >= pBottomImage->GetItemCount()) nImageIndex = 0;
		pBottomImage->HorizontalStretch(dc, rtBottom, nImageIndex);
	}
	
	if(!pTopImage.IsNull() && !pTopImage->IsNull())
	{
		INT nImageIndex = m_nImageIndex;
		if(nImageIndex >= pTopImage->GetItemCount()) nImageIndex = 0;
		pTopImage->HorizontalStretch(dc, rtTop, nImageIndex);
	}
}
void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
{
    wxStaticText*   label;
    int             buttonId = 1800;

    m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
    SetSizer( m_mainBoxSizer );

    BUTTONINDEX* groups = buttonGroups;
    wxBoxSizer* columnBoxSizer = NULL;

    while( groups->m_Buttons != NULL )
    {
        COLORBUTTON* buttons = groups->m_Buttons;

        columnBoxSizer = new wxBoxSizer( wxVERTICAL );
        m_mainBoxSizer->Add( columnBoxSizer, 1, wxALIGN_TOP | wxLEFT | wxTOP, 5 );
        wxBoxSizer* rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
        columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );

        // Add a text string to identify the column of color select buttons.
        label = new wxStaticText( this, wxID_ANY, groups->m_Name );

        // Make the column label font bold.
        wxFont font( label->GetFont() );
        font.SetWeight( wxFONTWEIGHT_BOLD );
        label->SetFont( font );

        rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );

        while( buttons->m_Layer >= 0 )
        {
            rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
            columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 );

            wxMemoryDC iconDC;
            wxBitmap   bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );

            iconDC.SelectObject( bitmap );

            EDA_COLOR_T color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
            currentColors[ buttons->m_Layer ] = color;

            iconDC.SetPen( *wxBLACK_PEN );

            wxBrush brush;
            ColorSetBrush( &brush, color );
            brush.SetStyle( wxBRUSHSTYLE_SOLID );
            iconDC.SetBrush( brush );
            iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );

            wxBitmapButton* bitmapButton = new wxBitmapButton(
                                    this, buttonId, bitmap, wxDefaultPosition,
                                    wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) );
            bitmapButton->SetClientData( (void*) buttons );

            rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );

            label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) );
            rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
            buttonId += 1;
            buttons++;
        }

        groups++;
    }

    Connect( 1800, buttonId - 1, wxEVT_COMMAND_BUTTON_CLICKED,
             wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) );

    wxArrayString selBgColorStrings;
    selBgColorStrings.Add( _( "White" ) );
    selBgColorStrings.Add( _( "Black" ) );
    m_SelBgColor = new wxRadioBox( this, wxID_ANY, _( "Background Color" ),
                                   wxDefaultPosition, wxDefaultSize,
                                   selBgColorStrings, 1, wxRA_SPECIFY_COLS );
    m_SelBgColor->SetSelection( ( GetDrawFrame()->GetDrawBgColor() == BLACK ) ? 1 : 0 );

    if( columnBoxSizer )
    {
        // Add a spacer to improve appearance.
        columnBoxSizer->AddSpacer( 5 );
        columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 );
    }

    currentColors[ LAYER_BACKGROUND ] =  GetDrawFrame()->GetDrawBgColor();

    // Dialog now needs to be resized, but the associated command is found elsewhere.
}