Hi, The next installment of my preferences work is simple, I pulled the color configuration dialog into the eeschema preferences dialog. I deleted the original color dialog, removing it from libedit as well (it's just redundant there, it edits the same settings that are shared across both).
Unlike with the hotkeys I didn't have to reimplement anything, in fact git recognizes this as a rename of dialogs/dialog_color_config to widgets/widget_eeschema_color_config :) Comments welcome. -- Chris
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index c8d9a46..fd13769 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -25,8 +25,6 @@ set( EESCHEMA_DLGS dialogs/dialog_bom.cpp dialogs/dialog_bom_base.cpp dialogs/dialog_bom_cfg_keywords.cpp - dialogs/dialog_color_config.cpp - dialogs/dialog_color_config_base.cpp dialogs/dialog_choose_component.cpp dialogs/dialog_choose_component_base.cpp dialogs/dialog_lib_edit_text.cpp @@ -72,6 +70,11 @@ set( EESCHEMA_DLGS dialogs/dialog_schematic_find_base.cpp ) +set( EESCHEMA_WIDGETS + widgets/widget_eeschema_color_config.cpp + ) + + set( EESCHEMA_SRCS autoplace_fields.cpp annotate.cpp @@ -90,6 +93,7 @@ set( EESCHEMA_SRCS controle.cpp cross-probing.cpp ${EESCHEMA_DLGS} + ${EESCHEMA_WIDGETS} edit_component_in_schematic.cpp edit_bitmap.cpp edit_label.cpp diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp deleted file mode 100644 index c59b067..0000000 --- a/eeschema/dialogs/dialog_color_config.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* Set up color Layers for Eeschema - */ - -#include <fctsys.h> -#include <draw_frame.h> -#include <class_drawpanel.h> - -#include <general.h> - -#include <dialog_color_config.h> - - -#define ID_COLOR_SETUP 1800 - -// Specify the width and height of every (color-displaying / bitmap) button -const int BUTT_SIZE_X = 16; -const int BUTT_SIZE_Y = 16; - - -/********************/ -/* Layer menu list. */ -/********************/ - -struct COLORBUTTON -{ - wxString m_Name; - int m_Layer; -}; - -struct BUTTONINDEX -{ - wxString m_Name; - COLORBUTTON* m_Buttons; -}; - -static COLORBUTTON generalColorButtons[] = { - { _( "Wire" ), LAYER_WIRE }, - { _( "Bus" ), LAYER_BUS }, - { _( "Junction" ), LAYER_JUNCTION }, - { _( "Label" ), LAYER_LOCLABEL }, - { _( "Global label" ), LAYER_GLOBLABEL }, - { _( "Net name" ), LAYER_NETNAM }, - { _( "Notes" ), LAYER_NOTES }, - { _( "No connect symbol" ), LAYER_NOCONNECT }, - { wxT( "" ), -1 } // Sentinel marking end of list. -}; - -static COLORBUTTON componentColorButtons[] = { - { _( "Body" ), LAYER_DEVICE }, - { _( "Body background" ), LAYER_DEVICE_BACKGROUND }, - { _( "Pin" ), LAYER_PIN }, - { _( "Pin number" ), LAYER_PINNUM }, - { _( "Pin name" ), LAYER_PINNAM }, - { _( "Reference" ), LAYER_REFERENCEPART }, - { _( "Value" ), LAYER_VALUEPART }, - { _( "Fields" ), LAYER_FIELDS }, - { wxT( "" ), -1 } // Sentinel marking end of list. -}; - -static COLORBUTTON sheetColorButtons[] = { - { _( "Sheet" ), LAYER_SHEET }, - { _( "Sheet file name" ), LAYER_SHEETFILENAME }, - { _( "Sheet name" ), LAYER_SHEETNAME }, - { _( "Sheet label" ), LAYER_SHEETLABEL }, - { _( "Hierarchical label" ),LAYER_HIERLABEL }, - { wxT( "" ), -1 } // Sentinel marking end of list. -}; - -static COLORBUTTON miscColorButtons[] = { - { _( "ERC warning" ), LAYER_ERC_WARN }, - { _( "ERC error" ), LAYER_ERC_ERR }, - { _( "Grid" ), LAYER_GRID }, - { wxT( "" ), -1 } // Sentinel marking end of list. -}; - - -static BUTTONINDEX buttonGroups[] = { - { _( "General" ), generalColorButtons }, - { _( "Component" ), componentColorButtons }, - { _( "Sheet" ), sheetColorButtons }, - { _( "Miscellaneous" ), miscColorButtons }, - { wxT( "" ), NULL } -}; - - -static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ]; - - -DIALOG_COLOR_CONFIG::DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent ) : - DIALOG_COLOR_CONFIG_BASE( aParent ) -{ - m_parent = aParent; - CreateControls(); - - GetSizer()->SetSizeHints( this ); -} - - -void DIALOG_COLOR_CONFIG::CreateControls() -{ - wxStaticText* label; - int buttonId = 1800; - - 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( DIALOG_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( ( m_parent->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 ] = m_parent->GetDrawBgColor(); - - // Dialog now needs to be resized, but the associated command is found elsewhere. -} - - -void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event ) -{ - wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject(); - - wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) ); - - COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData(); - - wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); - - EDA_COLOR_T color = DisplayColorFrame( this, colorButton->m_Layer ); - - if( color < 0 || currentColors[ colorButton->m_Layer ] == color ) - return; - - currentColors[ colorButton->m_Layer ] = color; - - wxMemoryDC iconDC; - - wxBitmap bitmap = button->GetBitmapLabel(); - iconDC.SelectObject( bitmap ); - 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 ); - button->SetBitmapLabel( bitmap ); - button->Refresh(); - - Refresh( false ); -} - - -bool DIALOG_COLOR_CONFIG::TransferDataFromWindow() -{ - 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 - m_parent->SetDrawBgColor( bgcolor ); - currentColors[ LAYER_BACKGROUND ] = bgcolor; - - - for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr ) - { - SetLayerColor( currentColors[ clyr ], clyr ); - } - - m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) ); - m_parent->GetCanvas()->Refresh(); - - return true; -} diff --git a/eeschema/dialogs/dialog_color_config.h b/eeschema/dialogs/dialog_color_config.h deleted file mode 100644 index 0f07367..0000000 --- a/eeschema/dialogs/dialog_color_config.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007 G. Harland - * Copyright (C) 1992-2015 KiCad Developers, see CHANGELOG.TXT for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef DIALOG_COLOR_CONFIG_H_ -#define DIALOG_COLOR_CONFIG_H_ - -#include <dialog_color_config_base.h> - - -class wxBoxSizer; -class wxStaticLine; -class wxStdDialogButtonSizer; - - -/***********************************************/ -/* Derived class for the frame color settings. */ -/***********************************************/ - -class DIALOG_COLOR_CONFIG : public DIALOG_COLOR_CONFIG_BASE -{ -private: - EDA_DRAW_FRAME* m_parent; - wxRadioBox* m_SelBgColor; - - // Creates the controls and sizers - void CreateControls(); - - void SetColor( wxCommandEvent& aEvent ); - -public: - // Constructors and destructor - DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent ); - - bool TransferDataFromWindow(); -}; - -#endif // DIALOG_COLOR_CONFIG_H_ diff --git a/eeschema/dialogs/dialog_color_config_base.cpp b/eeschema/dialogs/dialog_color_config_base.cpp deleted file mode 100644 index 8991523..0000000 --- a/eeschema/dialogs/dialog_color_config_base.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_color_config_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_COLOR_CONFIG_BASE::DIALOG_COLOR_CONFIG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bmainSizer; - bmainSizer = new wxBoxSizer( wxVERTICAL ); - - m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - - - bmainSizer->Add( m_mainBoxSizer, 1, wxEXPAND, 5 ); - - m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bmainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerApply = new wxButton( this, wxID_APPLY ); - m_sdbSizer->AddButton( m_sdbSizerApply ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - bmainSizer->Add( m_sdbSizer, 0, wxALIGN_RIGHT|wxALL, 5 ); - - - this->SetSizer( bmainSizer ); - this->Layout(); - bmainSizer->Fit( this ); - - this->Centre( wxBOTH ); -} - -DIALOG_COLOR_CONFIG_BASE::~DIALOG_COLOR_CONFIG_BASE() -{ -} diff --git a/eeschema/dialogs/dialog_color_config_base.fbp b/eeschema/dialogs/dialog_color_config_base.fbp deleted file mode 100644 index d739b57..0000000 --- a/eeschema/dialogs/dialog_color_config_base.fbp +++ /dev/null @@ -1,217 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> -<wxFormBuilder_Project> - <FileVersion major="1" minor="13" /> - <object class="Project" expanded="1"> - <property name="class_decoration"></property> - <property name="code_generation">C++</property> - <property name="disconnect_events">1</property> - <property name="disconnect_mode">source_name</property> - <property name="disconnect_php_events">0</property> - <property name="disconnect_python_events">0</property> - <property name="embedded_files_path">res</property> - <property name="encoding">UTF-8</property> - <property name="event_generation">connect</property> - <property name="file">dialog_color_config_base</property> - <property name="first_id">1000</property> - <property name="help_provider">none</property> - <property name="internationalize">1</property> - <property name="name">dialog_color_config_base</property> - <property name="namespace"></property> - <property name="path">.</property> - <property name="precompiled_header"></property> - <property name="relative_path">1</property> - <property name="skip_lua_events">1</property> - <property name="skip_php_events">1</property> - <property name="skip_python_events">1</property> - <property name="ui_table">UI</property> - <property name="use_enum">0</property> - <property name="use_microsoft_bom">0</property> - <object class="Dialog" expanded="1"> - <property name="aui_managed">0</property> - <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> - <property name="bg"></property> - <property name="center">wxBOTH</property> - <property name="context_help"></property> - <property name="context_menu">1</property> - <property name="enabled">1</property> - <property name="event_handler">impl_virtual</property> - <property name="extra_style"></property> - <property name="fg"></property> - <property name="font"></property> - <property name="hidden">0</property> - <property name="id">wxID_ANY</property> - <property name="maximum_size"></property> - <property name="minimum_size"></property> - <property name="name">DIALOG_COLOR_CONFIG_BASE</property> - <property name="pos"></property> - <property name="size">-1,-1</property> - <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> - <property name="subclass">DIALOG_SHIM; dialog_shim.h</property> - <property name="title">EESchema Colors</property> - <property name="tooltip"></property> - <property name="window_extra_style"></property> - <property name="window_name"></property> - <property name="window_style"></property> - <event name="OnActivate"></event> - <event name="OnActivateApp"></event> - <event name="OnAuiFindManager"></event> - <event name="OnAuiPaneButton"></event> - <event name="OnAuiPaneClose"></event> - <event name="OnAuiPaneMaximize"></event> - <event name="OnAuiPaneRestore"></event> - <event name="OnAuiRender"></event> - <event name="OnChar"></event> - <event name="OnClose"></event> - <event name="OnEnterWindow"></event> - <event name="OnEraseBackground"></event> - <event name="OnHibernate"></event> - <event name="OnIconize"></event> - <event name="OnIdle"></event> - <event name="OnInitDialog"></event> - <event name="OnKeyDown"></event> - <event name="OnKeyUp"></event> - <event name="OnKillFocus"></event> - <event name="OnLeaveWindow"></event> - <event name="OnLeftDClick"></event> - <event name="OnLeftDown"></event> - <event name="OnLeftUp"></event> - <event name="OnMiddleDClick"></event> - <event name="OnMiddleDown"></event> - <event name="OnMiddleUp"></event> - <event name="OnMotion"></event> - <event name="OnMouseEvents"></event> - <event name="OnMouseWheel"></event> - <event name="OnPaint"></event> - <event name="OnRightDClick"></event> - <event name="OnRightDown"></event> - <event name="OnRightUp"></event> - <event name="OnSetFocus"></event> - <event name="OnSize"></event> - <event name="OnUpdateUI"></event> - <object class="wxBoxSizer" expanded="1"> - <property name="minimum_size"></property> - <property name="name">bmainSizer</property> - <property name="orient">wxVERTICAL</property> - <property name="permission">none</property> - <object class="sizeritem" expanded="1"> - <property name="border">5</property> - <property name="flag">wxEXPAND</property> - <property name="proportion">1</property> - <object class="wxBoxSizer" expanded="1"> - <property name="minimum_size"></property> - <property name="name">m_mainBoxSizer</property> - <property name="orient">wxHORIZONTAL</property> - <property name="permission">protected</property> - </object> - </object> - <object class="sizeritem" expanded="1"> - <property name="border">5</property> - <property name="flag">wxEXPAND | wxALL</property> - <property name="proportion">0</property> - <object class="wxStaticLine" expanded="1"> - <property name="BottomDockable">1</property> - <property name="LeftDockable">1</property> - <property name="RightDockable">1</property> - <property name="TopDockable">1</property> - <property name="aui_layer"></property> - <property name="aui_name"></property> - <property name="aui_position"></property> - <property name="aui_row"></property> - <property name="best_size"></property> - <property name="bg"></property> - <property name="caption"></property> - <property name="caption_visible">1</property> - <property name="center_pane">0</property> - <property name="close_button">1</property> - <property name="context_help"></property> - <property name="context_menu">1</property> - <property name="default_pane">0</property> - <property name="dock">Dock</property> - <property name="dock_fixed">0</property> - <property name="docking">Left</property> - <property name="enabled">1</property> - <property name="fg"></property> - <property name="floatable">1</property> - <property name="font"></property> - <property name="gripper">0</property> - <property name="hidden">0</property> - <property name="id">wxID_ANY</property> - <property name="max_size"></property> - <property name="maximize_button">0</property> - <property name="maximum_size"></property> - <property name="min_size"></property> - <property name="minimize_button">0</property> - <property name="minimum_size"></property> - <property name="moveable">1</property> - <property name="name">m_staticline</property> - <property name="pane_border">1</property> - <property name="pane_position"></property> - <property name="pane_size"></property> - <property name="permission">protected</property> - <property name="pin_button">1</property> - <property name="pos"></property> - <property name="resize">Resizable</property> - <property name="show">1</property> - <property name="size"></property> - <property name="style">wxLI_HORIZONTAL</property> - <property name="subclass"></property> - <property name="toolbar_pane">0</property> - <property name="tooltip"></property> - <property name="window_extra_style"></property> - <property name="window_name"></property> - <property name="window_style"></property> - <event name="OnChar"></event> - <event name="OnEnterWindow"></event> - <event name="OnEraseBackground"></event> - <event name="OnKeyDown"></event> - <event name="OnKeyUp"></event> - <event name="OnKillFocus"></event> - <event name="OnLeaveWindow"></event> - <event name="OnLeftDClick"></event> - <event name="OnLeftDown"></event> - <event name="OnLeftUp"></event> - <event name="OnMiddleDClick"></event> - <event name="OnMiddleDown"></event> - <event name="OnMiddleUp"></event> - <event name="OnMotion"></event> - <event name="OnMouseEvents"></event> - <event name="OnMouseWheel"></event> - <event name="OnPaint"></event> - <event name="OnRightDClick"></event> - <event name="OnRightDown"></event> - <event name="OnRightUp"></event> - <event name="OnSetFocus"></event> - <event name="OnSize"></event> - <event name="OnUpdateUI"></event> - </object> - </object> - <object class="sizeritem" expanded="1"> - <property name="border">5</property> - <property name="flag">wxALIGN_RIGHT|wxALL</property> - <property name="proportion">0</property> - <object class="wxStdDialogButtonSizer" expanded="1"> - <property name="Apply">1</property> - <property name="Cancel">1</property> - <property name="ContextHelp">0</property> - <property name="Help">0</property> - <property name="No">0</property> - <property name="OK">1</property> - <property name="Save">0</property> - <property name="Yes">0</property> - <property name="minimum_size"></property> - <property name="name">m_sdbSizer</property> - <property name="permission">protected</property> - <event name="OnApplyButtonClick"></event> - <event name="OnCancelButtonClick"></event> - <event name="OnContextHelpButtonClick"></event> - <event name="OnHelpButtonClick"></event> - <event name="OnNoButtonClick"></event> - <event name="OnOKButtonClick"></event> - <event name="OnSaveButtonClick"></event> - <event name="OnYesButtonClick"></event> - </object> - </object> - </object> - </object> - </object> -</wxFormBuilder_Project> diff --git a/eeschema/dialogs/dialog_color_config_base.h b/eeschema/dialogs/dialog_color_config_base.h deleted file mode 100644 index 83697b1..0000000 --- a/eeschema/dialogs/dialog_color_config_base.h +++ /dev/null @@ -1,52 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DIALOG_COLOR_CONFIG_BASE_H__ -#define __DIALOG_COLOR_CONFIG_BASE_H__ - -#include <wx/artprov.h> -#include <wx/xrc/xmlres.h> -#include <wx/intl.h> -class DIALOG_SHIM; - -#include "dialog_shim.h" -#include <wx/sizer.h> -#include <wx/gdicmn.h> -#include <wx/statline.h> -#include <wx/font.h> -#include <wx/colour.h> -#include <wx/settings.h> -#include <wx/string.h> -#include <wx/button.h> -#include <wx/dialog.h> - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_COLOR_CONFIG_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_COLOR_CONFIG_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxBoxSizer* m_mainBoxSizer; - wxStaticLine* m_staticline; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerApply; - wxButton* m_sdbSizerCancel; - - public: - - DIALOG_COLOR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("EESchema Colors"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_COLOR_CONFIG_BASE(); - -}; - -#endif //__DIALOG_COLOR_CONFIG_BASE_H__ diff --git a/eeschema/dialogs/dialog_eeschema_options.cpp b/eeschema/dialogs/dialog_eeschema_options.cpp index 5ce1477..4c32b14 100644 --- a/eeschema/dialogs/dialog_eeschema_options.cpp +++ b/eeschema/dialogs/dialog_eeschema_options.cpp @@ -31,6 +31,7 @@ #include <dialog_eeschema_options.h> #include <widgets/widget_hotkey_list.h> +#include "../widgets/widget_eeschema_color_config.h" #include <schframe.h> #include <hotkeys.h> @@ -59,6 +60,10 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) : m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, sections ); m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys ); + // Embed the color configurator + m_colorConfigCtrl = new WIDGET_EESCHEMA_COLOR_CONFIG( m_panelColors, GetParent() ); + m_colorConfigCtrl->InstallOnPanel( m_panelColors ); + // Make sure we select the first tab of the options tab page m_notebook->SetSelection( 0 ); @@ -288,6 +293,9 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataFromWindow() if( !m_hotkeyListCtrl->TransferDataFromControl() ) return false; + if( !m_colorConfigCtrl->TransferDataFromControl() ) + return false; + // Refresh hotkeys GetParent()->ReCreateMenuBar(); GetParent()->Refresh(); diff --git a/eeschema/dialogs/dialog_eeschema_options.h b/eeschema/dialogs/dialog_eeschema_options.h index d5daca2..8f18d05 100644 --- a/eeschema/dialogs/dialog_eeschema_options.h +++ b/eeschema/dialogs/dialog_eeschema_options.h @@ -34,13 +34,15 @@ #include <dialog_eeschema_options_base.h> #include <template_fieldnames.h> +class WIDGET_EESCHEMA_COLOR_CONFIG; class WIDGET_HOTKEY_LIST; class SCH_EDIT_FRAME; class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE { protected: - WIDGET_HOTKEY_LIST* m_hotkeyListCtrl; + WIDGET_HOTKEY_LIST* m_hotkeyListCtrl; + WIDGET_EESCHEMA_COLOR_CONFIG* m_colorConfigCtrl; /** @brief The template fieldnames for this dialog */ TEMPLATE_FIELDNAMES templateFields; diff --git a/eeschema/dialogs/dialog_eeschema_options_base.cpp b/eeschema/dialogs/dialog_eeschema_options_base.cpp index 9c85f9d..31f17cd 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.cpp +++ b/eeschema/dialogs/dialog_eeschema_options_base.cpp @@ -117,7 +117,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_panel5->SetSizer( bSizer82 ); m_panel5->Layout(); bSizer82->Fit( m_panel5 ); - m_notebook->AddPage( m_panel5, _("Display"), true ); + m_notebook->AddPage( m_panel5, _("Display"), false ); m_panel3 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer8; bSizer8 = new wxBoxSizer( wxVERTICAL ); @@ -233,7 +233,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_panel3->Layout(); bSizer8->Fit( m_panel3 ); m_notebook->AddPage( m_panel3, _("Editing"), false ); - m_controlsPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_tabControls = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer81; bSizer81 = new wxBoxSizer( wxVERTICAL ); @@ -253,46 +253,58 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx wxBoxSizer* bSizer13; bSizer13 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText20 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Hotkeys:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText20 = new wxStaticText( m_tabControls, wxID_ANY, _("Hotkeys:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText20->Wrap( -1 ); bSizer13->Add( m_staticText20, 1, wxALL, 5 ); - m_staticText21 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText21 = new wxStaticText( m_tabControls, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); bSizer13->Add( m_staticText21, 0, wxALL, 5 ); m_controlsSizer->Add( bSizer13, 0, wxEXPAND, 5 ); - m_panelHotkeys = new wxPanel( m_controlsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_panelHotkeys = new wxPanel( m_tabControls, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_controlsSizer->Add( m_panelHotkeys, 1, wxEXPAND | wxALL, 5 ); - m_checkEnableZoomCenter = new wxCheckBox( m_controlsPanel, wxID_ANY, _("Cen&ter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkEnableZoomCenter = new wxCheckBox( m_tabControls, wxID_ANY, _("Cen&ter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkEnableZoomCenter->SetToolTip( _("Keep the cursor at its current location when zooming") ); m_controlsSizer->Add( m_checkEnableZoomCenter, 0, wxTOP|wxRIGHT|wxLEFT, 3 ); - m_checkEnableMiddleButtonPan = new wxCheckBox( m_controlsPanel, xwID_ANY, _("&Use middle mouse button to pan"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkEnableMiddleButtonPan = new wxCheckBox( m_tabControls, xwID_ANY, _("&Use middle mouse button to pan"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkEnableMiddleButtonPan->SetToolTip( _("Use middle mouse button dragging to pan") ); m_controlsSizer->Add( m_checkEnableMiddleButtonPan, 0, wxTOP|wxRIGHT|wxLEFT, 3 ); - m_checkMiddleButtonPanLimited = new wxCheckBox( m_controlsPanel, wxID_ANY, _("&Limit panning to scroll size"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkMiddleButtonPanLimited = new wxCheckBox( m_tabControls, wxID_ANY, _("&Limit panning to scroll size"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkMiddleButtonPanLimited->SetToolTip( _("Middle mouse button panning limited by current scrollbar size") ); m_controlsSizer->Add( m_checkMiddleButtonPanLimited, 0, wxTOP|wxRIGHT|wxLEFT, 3 ); - m_checkAutoPan = new wxCheckBox( m_controlsPanel, wxID_ANY, _("&Pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkAutoPan = new wxCheckBox( m_tabControls, wxID_ANY, _("&Pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 ); m_controlsSizer->Add( m_checkAutoPan, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 ); bSizer81->Add( m_controlsSizer, 1, wxALL|wxEXPAND, 5 ); - m_controlsPanel->SetSizer( bSizer81 ); - m_controlsPanel->Layout(); - bSizer81->Fit( m_controlsPanel ); - m_notebook->AddPage( m_controlsPanel, _("Controls"), false ); + m_tabControls->SetSizer( bSizer81 ); + m_tabControls->Layout(); + bSizer81->Fit( m_tabControls ); + m_notebook->AddPage( m_tabControls, _("Controls"), false ); + m_tabColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer14; + bSizer14 = new wxBoxSizer( wxVERTICAL ); + + m_panelColors = new wxPanel( m_tabColors, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + bSizer14->Add( m_panelColors, 1, wxEXPAND | wxALL, 5 ); + + + m_tabColors->SetSizer( bSizer14 ); + m_tabColors->Layout(); + bSizer14->Fit( m_tabColors ); + m_notebook->AddPage( m_tabColors, _("Colors"), true ); m_panel2 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel2->SetToolTip( _("User defined field names for schematic components. ") ); diff --git a/eeschema/dialogs/dialog_eeschema_options_base.fbp b/eeschema/dialogs/dialog_eeschema_options_base.fbp index 668ac9f..9e4a0e6 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.fbp +++ b/eeschema/dialogs/dialog_eeschema_options_base.fbp @@ -187,7 +187,7 @@ <object class="notebookpage" expanded="0"> <property name="bitmap"></property> <property name="label">Display</property> - <property name="select">1</property> + <property name="select">0</property> <object class="wxPanel" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> @@ -3806,7 +3806,7 @@ <property name="minimize_button">0</property> <property name="minimum_size"></property> <property name="moveable">1</property> - <property name="name">m_controlsPanel</property> + <property name="name">m_tabControls</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> @@ -3845,7 +3845,7 @@ <event name="OnSetFocus"></event> <event name="OnSize"></event> <event name="OnUpdateUI"></event> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer81</property> <property name="orient">wxVERTICAL</property> @@ -3868,20 +3868,20 @@ <property name="vgap">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">1</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">m_controlsSizer</property> <property name="orient">wxVERTICAL</property> <property name="permission">protected</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer13</property> <property name="orient">wxHORIZONTAL</property> @@ -4054,11 +4054,11 @@ </object> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND | wxALL</property> <property name="proportion">1</property> - <object class="wxPanel" expanded="1"> + <object class="wxPanel" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> @@ -4491,6 +4491,172 @@ </object> </object> </object> + <object class="notebookpage" expanded="1"> + <property name="bitmap"></property> + <property name="label">Colors</property> + <property name="select">1</property> + <object class="wxPanel" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_tabColors</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxTAB_TRAVERSAL</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bSizer14</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND | wxALL</property> + <property name="proportion">1</property> + <object class="wxPanel" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_panelColors</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxTAB_TRAVERSAL</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + </object> + </object> + </object> <object class="notebookpage" expanded="0"> <property name="bitmap"></property> <property name="label">Default Fields</property> diff --git a/eeschema/dialogs/dialog_eeschema_options_base.h b/eeschema/dialogs/dialog_eeschema_options_base.h index 5b20e1c..eca809b 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.h +++ b/eeschema/dialogs/dialog_eeschema_options_base.h @@ -103,7 +103,7 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM wxCheckBox* m_checkAutoplaceFields; wxCheckBox* m_checkAutoplaceJustify; wxCheckBox* m_checkAutoplaceAlign; - wxPanel* m_controlsPanel; + wxPanel* m_tabControls; wxBoxSizer* m_controlsSizer; wxStaticText* m_staticText20; wxStaticText* m_staticText21; @@ -112,6 +112,8 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM wxCheckBox* m_checkEnableMiddleButtonPan; wxCheckBox* m_checkMiddleButtonPanLimited; wxCheckBox* m_checkAutoPan; + wxPanel* m_tabColors; + wxPanel* m_panelColors; wxPanel* m_panel2; wxGrid* m_fieldGrid; wxButton* addFieldButton; diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index cfc062a..1c77039 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -42,7 +42,6 @@ #include <general.h> #include <class_libentry.h> #include <hotkeys.h> -#include <dialogs/dialog_color_config.h> #include <transform.h> #include <wildcards_and_files_ext.h> diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 804045e..f2028ea 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -47,7 +47,6 @@ #include <dialog_hotkeys_editor.h> -#include <dialogs/dialog_color_config.h> #include <dialogs/dialog_eeschema_options.h> #include <dialogs/dialog_libedit_options.h> #include <dialogs/dialog_schematic_find.h> @@ -157,14 +156,6 @@ void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) } -void LIB_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent ) -{ - DIALOG_COLOR_CONFIG dlg( this ); - - dlg.ShowModal(); -} - - void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); @@ -195,14 +186,6 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent ) -{ - DIALOG_COLOR_CONFIG dlg( this ); - - dlg.ShowModal(); -} - - void SCH_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) { // Identical to LIB_EDIT_FRAME::InstallConfigFrame() diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index bd489a0..6663cf6 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -130,10 +130,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) - EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::OnColorConfig ) EVT_MENU( wxID_PREFERENCES, LIB_EDIT_FRAME::OnPreferencesOptions ) EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame ) - EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config ) // Multiple item selection context menu commands. EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem ) diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 6ae14ce..7b9cad0 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -193,7 +193,6 @@ public: static void EnsureActiveLibExists(); void InstallConfigFrame( wxCommandEvent& event ); - void OnColorConfig( wxCommandEvent& aEvent ); void OnPreferencesOptions( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 2e8047d..5ce4edf 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -375,13 +375,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() _( "Configure component libraries and paths" ), KiBitmap( library_xpm ) ); - // Colors - AddMenuItem( preferencesMenu, - ID_COLORS_SETUP, - _( "Set &Colors Scheme" ), - _( "Set color preferences" ), - KiBitmap( palette_xpm ) ); - // Options (Preferences on WXMAC) #ifdef __WXMAC__ diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index f2c9599..ed3abe6 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -238,13 +238,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() _( "Set Component Editor default values and options" ), KiBitmap( preference_xpm ) ); - // Colors - AddMenuItem( preferencesMenu, - ID_COLORS_SETUP, - _( "Set &Colors Scheme" ), - _( "Set color preferences" ), - KiBitmap( palette_xpm ) ); - // Language submenu Pgm().AddMenuLanguageList( preferencesMenu ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index a9c7a07..ea6d2f2 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -237,7 +237,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, SCH_EDIT_FRAME::Process_Config ) - EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig ) EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions ) EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor ) diff --git a/eeschema/schframe.h b/eeschema/schframe.h index f7309bc..45b820f 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -266,7 +266,6 @@ public: void SetPlotDirectoryName( const wxString& aDirName ) { m_plotDirectoryName = aDirName; } void Process_Special_Functions( wxCommandEvent& event ); - void OnColorConfig( wxCommandEvent& aEvent ); void Process_Config( wxCommandEvent& event ); void OnSelectTool( wxCommandEvent& aEvent ); diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp new file mode 100644 index 0000000..f23c2e9 --- /dev/null +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -0,0 +1,302 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* Set up color Layers for Eeschema + */ + +#include <fctsys.h> +#include <draw_frame.h> +#include <class_drawpanel.h> + +#include <general.h> + +#include "widget_eeschema_color_config.h" + +// Specify the width and height of every (color-displaying / bitmap) button +const int BUTT_SIZE_X = 16; +const int BUTT_SIZE_Y = 16; + + +/********************/ +/* Layer menu list. */ +/********************/ + +struct COLORBUTTON +{ + wxString m_Name; + int m_Layer; +}; + +struct BUTTONINDEX +{ + wxString m_Name; + COLORBUTTON* m_Buttons; +}; + +static COLORBUTTON generalColorButtons[] = { + { _( "Wire" ), LAYER_WIRE }, + { _( "Bus" ), LAYER_BUS }, + { _( "Junction" ), LAYER_JUNCTION }, + { _( "Label" ), LAYER_LOCLABEL }, + { _( "Global label" ), LAYER_GLOBLABEL }, + { _( "Net name" ), LAYER_NETNAM }, + { _( "Notes" ), LAYER_NOTES }, + { _( "No connect symbol" ), LAYER_NOCONNECT }, + { wxT( "" ), -1 } // Sentinel marking end of list. +}; + +static COLORBUTTON componentColorButtons[] = { + { _( "Body" ), LAYER_DEVICE }, + { _( "Body background" ), LAYER_DEVICE_BACKGROUND }, + { _( "Pin" ), LAYER_PIN }, + { _( "Pin number" ), LAYER_PINNUM }, + { _( "Pin name" ), LAYER_PINNAM }, + { _( "Reference" ), LAYER_REFERENCEPART }, + { _( "Value" ), LAYER_VALUEPART }, + { _( "Fields" ), LAYER_FIELDS }, + { wxT( "" ), -1 } // Sentinel marking end of list. +}; + +static COLORBUTTON sheetColorButtons[] = { + { _( "Sheet" ), LAYER_SHEET }, + { _( "Sheet file name" ), LAYER_SHEETFILENAME }, + { _( "Sheet name" ), LAYER_SHEETNAME }, + { _( "Sheet label" ), LAYER_SHEETLABEL }, + { _( "Hierarchical label" ),LAYER_HIERLABEL }, + { wxT( "" ), -1 } // Sentinel marking end of list. +}; + +static COLORBUTTON miscColorButtons[] = { + { _( "ERC warning" ), LAYER_ERC_WARN }, + { _( "ERC error" ), LAYER_ERC_ERR }, + { _( "Grid" ), LAYER_GRID }, + { wxT( "" ), -1 } // Sentinel marking end of list. +}; + + +static BUTTONINDEX buttonGroups[] = { + { _( "General" ), generalColorButtons }, + { _( "Component" ), componentColorButtons }, + { _( "Sheet" ), sheetColorButtons }, + { _( "Miscellaneous" ), miscColorButtons }, + { wxT( "" ), NULL } +}; + + +static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ]; + + +WIDGET_EESCHEMA_COLOR_CONFIG::WIDGET_EESCHEMA_COLOR_CONFIG( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) : + wxPanel( aParent ), m_drawFrame( aDrawFrame ) +{ + CreateControls(); +} + + +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. +} + + +void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event ) +{ + wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject(); + + wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) ); + + COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData(); + + wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); + + EDA_COLOR_T color = DisplayColorFrame( this, colorButton->m_Layer ); + + if( color < 0 || currentColors[ colorButton->m_Layer ] == color ) + return; + + currentColors[ colorButton->m_Layer ] = color; + + wxMemoryDC iconDC; + + wxBitmap bitmap = button->GetBitmapLabel(); + iconDC.SelectObject( bitmap ); + 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 ); + button->SetBitmapLabel( bitmap ); + button->Refresh(); + + Refresh( false ); +} + + +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; +} + + +void WIDGET_EESCHEMA_COLOR_CONFIG::InstallOnPanel( wxPanel* aPanel ) +{ + wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); + + sizer->Add( this, 1, wxALL | wxEXPAND, 0 ); + aPanel->SetSizer( sizer ); +} diff --git a/eeschema/widgets/widget_eeschema_color_config.h b/eeschema/widgets/widget_eeschema_color_config.h new file mode 100644 index 0000000..1f99a31 --- /dev/null +++ b/eeschema/widgets/widget_eeschema_color_config.h @@ -0,0 +1,69 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007 G. Harland + * Copyright (C) 1992-2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef WIDGET_EESCHEMA_COLOR_CONFIG_H_ +#define WIDGET_EESCHEMA_COLOR_CONFIG_H_ + +#include <wx/panel.h> +#include <wx/sizer.h> + +class wxBoxSizer; +class wxStaticLine; +class wxStdDialogButtonSizer; + + +/***********************************************/ +/* Derived class for the frame color settings. */ +/***********************************************/ + +class WIDGET_EESCHEMA_COLOR_CONFIG : public wxPanel +{ +private: + EDA_DRAW_FRAME* m_drawFrame; + wxRadioBox* m_SelBgColor; + wxBoxSizer* m_mainBoxSizer; + + // Creates the controls and sizers + void CreateControls(); + + void SetColor( wxCommandEvent& aEvent ); + + virtual EDA_DRAW_FRAME* GetDrawFrame() { return m_drawFrame; } + +public: + // Constructors and destructor + WIDGET_EESCHEMA_COLOR_CONFIG( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ); + + bool TransferDataFromControl(); + + /** + * Method InstallOnPanel + * Install this WIDGET_EESCHEMA_COLOR_CONFIG onto an empty panel. This is useful + * when combining with wxFormBuilder, as an empty panel can be left as a + * placeholder in the layout. + */ + void InstallOnPanel( wxPanel* aPanel ); +}; + +#endif // WIDGET_EESCHEMA_COLOR_CONFIG_H_ diff --git a/include/id.h b/include/id.h index c864171..a50a950 100644 --- a/include/id.h +++ b/include/id.h @@ -124,8 +124,6 @@ enum main_id ID_NO_TOOL_SELECTED, ID_SEL_BG_COLOR, - ID_COLORS_SETUP, - ID_REPEAT_BUTT, ID_LANGUAGE_CHOICE,
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp