From 150e2b8a19a536707d6dbdfeb61a66cc9e90af27 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 15 Jun 2023 17:38:43 +0100 Subject: [PATCH] Separate BITMAP2CMP_PANEL from BITMAP2CMP_FRAME. This is primarily to allow wxFormBuilder to create the panel without the dangerous hack of passing a wxWindow ID into KIWAY_PLAYER's ctor. --- bitmap2component/CMakeLists.txt | 8 +- bitmap2component/bitmap2cmp_frame.cpp | 444 ++++++++++++++++++ .../{bitmap2cmp_gui.h => bitmap2cmp_frame.h} | 79 +--- bitmap2component/bitmap2cmp_main.cpp | 4 +- ...itmap2cmp_gui.cpp => bitmap2cmp_panel.cpp} | 442 ++--------------- bitmap2component/bitmap2cmp_panel.h | 100 ++++ ...gui_base.cpp => bitmap2cmp_panel_base.cpp} | 78 ++- ...gui_base.fbp => bitmap2cmp_panel_base.fbp} | 164 ++----- ...cmp_gui_base.h => bitmap2cmp_panel_base.h} | 22 +- common/kiway_player.cpp | 21 +- eeschema/sim/simulator_frame.cpp | 3 + include/kiway_player.h | 10 - 12 files changed, 706 insertions(+), 669 deletions(-) create mode 100644 bitmap2component/bitmap2cmp_frame.cpp rename bitmap2component/{bitmap2cmp_gui.h => bitmap2cmp_frame.h} (61%) rename bitmap2component/{bitmap2cmp_gui.cpp => bitmap2cmp_panel.cpp} (55%) create mode 100644 bitmap2component/bitmap2cmp_panel.h rename bitmap2component/{bitmap2cmp_gui_base.cpp => bitmap2cmp_panel_base.cpp} (80%) rename bitmap2component/{bitmap2cmp_gui_base.fbp => bitmap2cmp_panel_base.fbp} (95%) rename bitmap2component/{bitmap2cmp_gui_base.h => bitmap2cmp_panel_base.h} (83%) diff --git a/bitmap2component/CMakeLists.txt b/bitmap2component/CMakeLists.txt index 232a7f5868..95f17e3fbc 100644 --- a/bitmap2component/CMakeLists.txt +++ b/bitmap2component/CMakeLists.txt @@ -14,15 +14,17 @@ set( BITMAP2COMPONENT_SRCS bitmap2cmp_main.cpp bitmap2cmp_settings.cpp bitmap2component.cpp - bitmap2cmp_gui_base.cpp - bitmap2cmp_gui.cpp + bitmap2cmp_panel_base.cpp + bitmap2cmp_frame.cpp + bitmap2cmp_panel.cpp + bitmap2cmp_panel_base.cpp ../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found) ) set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES COMPILE_DEFINITIONS "TOP_FRAME=FRAME_BM2CMP" ) -set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES +set_source_files_properties(bitmap2cmp_frame.cpp PROPERTIES COMPILE_DEFINITIONS "COMPILING_DLL" ) diff --git a/bitmap2component/bitmap2cmp_frame.cpp b/bitmap2component/bitmap2cmp_frame.cpp new file mode 100644 index 0000000000..55eee9c618 --- /dev/null +++ b/bitmap2component/bitmap2cmp_frame.cpp @@ -0,0 +1,444 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2010 jean-pierre.charras + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI + +IMAGE_SIZE::IMAGE_SIZE() +{ + m_outputSize = 0.0; + m_originalDPI = DEFAULT_DPI; + m_originalSizePixels = 0; + m_unit = EDA_UNITS::MILLIMETRES; +} + + +void IMAGE_SIZE::SetOutputSizeFromInitialImageSize() +{ + // Safety-check to guarantee no divide-by-zero + m_originalDPI = std::max( 1, m_originalDPI ); + + // Set the m_outputSize value from the m_originalSizePixels and the selected unit + if( m_unit == EDA_UNITS::MILLIMETRES ) + m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI * 25.4; + else if( m_unit == EDA_UNITS::INCHES ) + m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI; + else + m_outputSize = m_originalDPI; +} + + +int IMAGE_SIZE::GetOutputDPI() +{ + int outputDPI; + + if( m_unit == EDA_UNITS::MILLIMETRES ) + outputDPI = GetOriginalSizePixels() / ( m_outputSize / 25.4 ); + else if( m_unit == EDA_UNITS::INCHES ) + outputDPI = GetOriginalSizePixels() / m_outputSize; + else + outputDPI = KiROUND( m_outputSize ); + + // Zero is not a DPI, and may cause divide-by-zero errors... + outputDPI = std::max( 1, outputDPI ); + + return outputDPI; +} + + +void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit ) +{ + // Set the unit used for m_outputSize, and convert the old m_outputSize value + // to the value in new unit + if( aUnit == m_unit ) + return; + + // Convert m_outputSize to mm: + double size_mm; + + if( m_unit == EDA_UNITS::MILLIMETRES ) + { + size_mm = m_outputSize; + } + else if( m_unit == EDA_UNITS::INCHES ) + { + size_mm = m_outputSize * 25.4; + } + else + { + // m_outputSize is the DPI, not an image size + // the image size is m_originalSizePixels / m_outputSize (in inches) + if( m_outputSize ) + size_mm = m_originalSizePixels / m_outputSize * 25.4; + else + size_mm = 0; + } + + // Convert m_outputSize to new value: + if( aUnit == EDA_UNITS::MILLIMETRES ) + { + m_outputSize = size_mm; + } + else if( aUnit == EDA_UNITS::INCHES ) + { + m_outputSize = size_mm / 25.4; + } + else + { + if( size_mm ) + m_outputSize = m_originalSizePixels / size_mm * 25.4; + else + m_outputSize = 0; + } + + m_unit = aUnit; +} + + +BEGIN_EVENT_TABLE( BITMAP2CMP_FRAME, KIWAY_PLAYER ) + EVT_MENU( wxID_EXIT, BITMAP2CMP_FRAME::OnExit ) + EVT_MENU( wxID_OPEN, BITMAP2CMP_FRAME::OnLoadFile ) +END_EVENT_TABLE() + + +BITMAP2CMP_FRAME::BITMAP2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) : + KIWAY_PLAYER( aKiway, aParent, FRAME_BM2CMP, _( "Image Converter" ), wxDefaultPosition, + wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( "bitmap2cmp" ), unityScale ), + m_panel( nullptr ), + m_statusBar( nullptr ) +{ + // Give an icon + wxIcon icon; + wxIconBundle icon_bundle; + + icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component ) ); + icon_bundle.AddIcon( icon ); + icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component_32 ) ); + icon_bundle.AddIcon( icon ); + icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component_16 ) ); + icon_bundle.AddIcon( icon ); + + SetIcons( icon_bundle ); + + wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL ); + SetSizer( mainSizer ); + + m_panel = new BITMAP2CMP_PANEL( this ); + mainSizer->Add( m_panel, 1, wxEXPAND, 5 ); + + m_statusBar = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY ); + + ReCreateMenuBar(); + + LoadSettings( config() ); + + GetSizer()->SetSizeHints( this ); + + SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y ); + + if ( m_framePos == wxDefaultPosition ) + Centre(); +} + + +BITMAP2CMP_FRAME::~BITMAP2CMP_FRAME() +{ + SaveSettings( config() ); + /* + * This needed for OSX: avoids further OnDraw processing after this + * destructor and before the native window is destroyed + */ + Freeze(); +} + + +wxWindow* BITMAP2CMP_FRAME::GetToolCanvas() const +{ + return m_panel->GetCurrentPage(); +} + + +void BITMAP2CMP_FRAME::doReCreateMenuBar() +{ + // wxWidgets handles the Mac Application menu behind the scenes, but that means + // we always have to start from scratch with a new wxMenuBar. + wxMenuBar* oldMenuBar = GetMenuBar(); + wxMenuBar* menuBar = new wxMenuBar(); + + wxMenu* fileMenu = new wxMenu; + + wxMenuItem* item = new wxMenuItem( fileMenu, wxID_OPEN, _( "Open..." ) + wxT( "\tCtrl+O" ), + _( "Load source image" ) ); + + fileMenu->Append( item ); + +#ifndef __WXMAC__ + // Mac moves Quit to the App menu so we don't need a separator on Mac + fileMenu->AppendSeparator(); +#endif + + item = new wxMenuItem( fileMenu, wxID_EXIT, _( "Quit" ) + wxT( "\tCtrl+Q" ), + _( "Quit Image Converter" ) ); + + if( Pgm().GetCommonSettings()->m_Appearance.use_icons_in_menus ) + item->SetBitmap( KiBitmap( BITMAPS::exit ) ); + + fileMenu->Append( item ); + + menuBar->Append( fileMenu, _( "&File" ) ); + + SetMenuBar( menuBar ); + delete oldMenuBar; +} + + +void BITMAP2CMP_FRAME::OnExit( wxCommandEvent& event ) +{ + Destroy(); +} + + +void BITMAP2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) +{ + EDA_BASE_FRAME::LoadSettings( aCfg ); + + BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ); + + if( cfg ) + { + m_bitmapFileName = cfg->m_BitmapFileName; + m_convertedFileName = cfg->m_ConvertedFileName; + m_panel->LoadSettings( cfg ); + } +} + + +void BITMAP2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) +{ + EDA_BASE_FRAME::SaveSettings( aCfg ); + + BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ); + + if( cfg ) + { + cfg->m_BitmapFileName = m_bitmapFileName; + cfg->m_ConvertedFileName = m_convertedFileName; + m_panel->SaveSettings( cfg ); + } +} + + +void BITMAP2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) +{ + wxFileName fn( m_bitmapFileName ); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists( path ) ) + path = m_mruPath; + + wxFileDialog fileDlg( this, _( "Choose Image" ), path, wxEmptyString, + _( "Image Files" ) + wxS( " " )+ wxImage::GetImageExtWildcard(), + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); + + int diag = fileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + wxString fullFilename = fileDlg.GetPath(); + + if( !OpenProjectFiles( std::vector( 1, fullFilename ) ) ) + return; + + fn = fullFilename; + m_mruPath = fn.GetPath(); + SetStatusText( fullFilename ); + Refresh(); +} + + +bool BITMAP2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) +{ + m_bitmapFileName = aFileSet[0]; + + return m_panel->OpenProjectFiles( aFileSet, aCtl ); +} + + +void BITMAP2CMP_FRAME::ExportLogo() +{ + wxFileName fn( m_convertedFileName ); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxFileDialog fileDlg( this, _( "Create Logo File" ), path, wxEmptyString, + DrawingSheetFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + int diag = fileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + fn = fileDlg.GetPath(); + fn.SetExt( DrawingSheetFileExtension ); + m_convertedFileName = fn.GetFullPath(); + + FILE* outfile; + outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + + if( outfile == nullptr ) + { + wxString msg; + msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); + wxMessageBox( msg ); + return; + } + + std::string buffer; + m_panel->ExportToBuffer( buffer, KICAD_WKS_LOGO ); + fputs( buffer.c_str(), outfile ); + fclose( outfile ); +} + + +void BITMAP2CMP_FRAME::ExportPostScriptFormat() +{ + wxFileName fn( m_convertedFileName ); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists( path ) ) + path = ::wxGetCwd(); + + wxFileDialog fileDlg( this, _( "Create PostScript File" ), path, wxEmptyString, + PSFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( fileDlg.ShowModal() != wxID_OK ) + return; + + fn = fileDlg.GetPath(); + fn.SetExt( wxT( "ps" ) ); + m_convertedFileName = fn.GetFullPath(); + + FILE* outfile; + outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + + if( outfile == nullptr ) + { + wxString msg; + msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); + wxMessageBox( msg ); + return; + } + + std::string buffer; + m_panel->ExportToBuffer( buffer, POSTSCRIPT_FMT ); + fputs( buffer.c_str(), outfile ); + fclose( outfile ); +} + + +void BITMAP2CMP_FRAME::ExportEeschemaFormat() +{ + wxFileName fn( m_convertedFileName ); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxFileDialog fileDlg( this, _( "Create Symbol Library" ), path, wxEmptyString, + KiCadSymbolLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( fileDlg.ShowModal() != wxID_OK ) + return; + + fn = EnsureFileExtension( fileDlg.GetPath(), KiCadSymbolLibFileExtension ); + m_convertedFileName = fn.GetFullPath(); + + FILE* outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + + if( outfile == nullptr ) + { + wxString msg; + msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); + wxMessageBox( msg ); + return; + } + + std::string buffer; + m_panel->ExportToBuffer( buffer, EESCHEMA_FMT ); + fputs( buffer.c_str(), outfile ); + fclose( outfile ); +} + + +void BITMAP2CMP_FRAME::ExportPcbnewFormat() +{ + wxFileName fn( m_convertedFileName ); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists( path ) ) + path = m_mruPath; + + wxFileDialog fileDlg( this, _( "Create Footprint Library" ), path, wxEmptyString, + KiCadFootprintLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + + if( fileDlg.ShowModal() != wxID_OK ) + return; + + fn = EnsureFileExtension( fileDlg.GetPath(), KiCadFootprintFileExtension ); + m_convertedFileName = fn.GetFullPath(); + + FILE* outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + + if( outfile == nullptr ) + { + wxString msg; + msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); + wxMessageBox( msg ); + return; + } + + std::string buffer; + m_panel->ExportToBuffer( buffer, PCBNEW_KICAD_MOD ); + fputs( buffer.c_str(), outfile ); + fclose( outfile ); + m_mruPath = fn.GetPath(); +} + + diff --git a/bitmap2component/bitmap2cmp_gui.h b/bitmap2component/bitmap2cmp_frame.h similarity index 61% rename from bitmap2component/bitmap2cmp_gui.h rename to bitmap2component/bitmap2cmp_frame.h index 513e928787..737b821246 100644 --- a/bitmap2component/bitmap2cmp_gui.h +++ b/bitmap2component/bitmap2cmp_frame.h @@ -23,12 +23,13 @@ #ifndef BITMOP2CMP_GUI_H_ #define BITMOP2CMP_GUI_H_ -#include "bitmap2component.h" +#include +#include -#include "bitmap2cmp_gui_base.h" #include #include +class BITMAP2CMP_PANEL; class IMAGE_SIZE { @@ -82,97 +83,55 @@ private: int m_originalSizePixels; // The original image size read from file, in pixels }; -class BM2CMP_FRAME : public BM2CMP_FRAME_BASE + +class BITMAP2CMP_FRAME : public KIWAY_PLAYER { public: - BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ); - ~BM2CMP_FRAME(); + BITMAP2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ); + ~BITMAP2CMP_FRAME(); // overload KIWAY_PLAYER virtual bool OpenProjectFiles( const std::vector& aFilenames, int aCtl = 0 ) override; void OnExit( wxCommandEvent& event ); - void OnLoadFile( wxCommandEvent& event ) override; - -DECLARE_EVENT_TABLE() - -private: - // Event handlers - void OnPaintInit( wxPaintEvent& event ) override; - void OnPaintGreyscale( wxPaintEvent& event ) override; - void OnPaintBW( wxPaintEvent& event ) override; - void OnExportToFile( wxCommandEvent& event ) override; - void OnExportToClipboard( wxCommandEvent& event ) override; - - ///< @return the EDA_UNITS from the m_PixelUnit choice - EDA_UNITS getUnitFromSelection(); - - // return a string giving the output size, according to the selected unit - wxString FormatOutputSize( double aSize ); + void OnLoadFile( wxCommandEvent& event ); /** * Generate a schematic library which contains one component: * the logo */ - void exportEeschemaFormat(); + void ExportEeschemaFormat(); /** * Generate a footprint in S expr format */ - void exportPcbnewFormat(); + void ExportPcbnewFormat(); /** * Generate a postscript file */ - void exportPostScriptFormat(); + void ExportPostScriptFormat(); /** * Generate a file suitable to be copied into a drawing sheet (.kicad_wks) file */ - void exportLogo(); - - void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) - void OnNegativeClicked( wxCommandEvent& event ) override; - void OnThresholdChange( wxScrollEvent& event ) override; - - void OnSizeChangeX( wxCommandEvent& event ) override; - void OnSizeChangeY( wxCommandEvent& event ) override; - void OnSizeUnitChange( wxCommandEvent& event ) override; - - void ToggleAspectRatioLock( wxCommandEvent& event ) override; - - void NegateGreyscaleImage(); - /** - * generate a export data of the current bitmap. - * @param aOutput is a string buffer to fill with data - * @param aFormat is the format to generate - */ - void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ); - - void updateImageInfo(); - void OnFormatChange( wxCommandEvent& event ) override; - void exportBitmap( OUTPUT_FMT_ID aFormat ); + void ExportLogo(); void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; wxWindow* GetToolCanvas() const override; +DECLARE_EVENT_TABLE() + protected: void doReCreateMenuBar() override; private: - wxImage m_Pict_Image; - wxBitmap m_Pict_Bitmap; - wxImage m_Greyscale_Image; - wxBitmap m_Greyscale_Bitmap; - wxImage m_NB_Image; - wxBitmap m_BN_Bitmap; - IMAGE_SIZE m_outputSizeX; - IMAGE_SIZE m_outputSizeY; - bool m_Negative; - wxString m_BitmapFileName; - wxString m_ConvertedFileName; - double m_AspectRatio; + BITMAP2CMP_PANEL* m_panel; + wxStatusBar* m_statusBar; + + wxString m_bitmapFileName; + wxString m_convertedFileName; }; #endif// BITMOP2CMP_GUI_H_ diff --git a/bitmap2component/bitmap2cmp_main.cpp b/bitmap2component/bitmap2cmp_main.cpp index 87812efd0f..05cf3df553 100644 --- a/bitmap2component/bitmap2cmp_main.cpp +++ b/bitmap2component/bitmap2cmp_main.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include @@ -41,7 +41,7 @@ static struct IFACE : public KIFACE_BASE { InitSettings( new BITMAP2CMP_SETTINGS ); Pgm().GetSettingsManager().RegisterSettings( KifaceSettings() ); - return new BM2CMP_FRAME( aKiway, aParent ); + return new BITMAP2CMP_FRAME( aKiway, aParent ); } /** diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_panel.cpp similarity index 55% rename from bitmap2component/bitmap2cmp_gui.cpp rename to bitmap2component/bitmap2cmp_panel.cpp index ab991c847d..c53f4ec46c 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_panel.cpp @@ -22,140 +22,33 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "bitmap2cmp_gui.h" -#include "bitmap2component.h" +#include +#include +#include #include #include #include #include #include #include // for KiROUND -#include +#include #include -#include -#include -#include #include #include -#include #include #include #include - -#include "bitmap2cmp_gui_base.h" -#include "pgm_base.h" - #define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI -IMAGE_SIZE::IMAGE_SIZE() + +BITMAP2CMP_PANEL::BITMAP2CMP_PANEL( BITMAP2CMP_FRAME* aParent ) : + BITMAP2CMP_PANEL_BASE( aParent ), + m_parentFrame( aParent ) { - m_outputSize = 0.0; - m_originalDPI = DEFAULT_DPI; - m_originalSizePixels = 0; - m_unit = EDA_UNITS::MILLIMETRES; -} - - -void IMAGE_SIZE::SetOutputSizeFromInitialImageSize() -{ - // Safety-check to guarantee no divide-by-zero - m_originalDPI = std::max( 1, m_originalDPI ); - - // Set the m_outputSize value from the m_originalSizePixels and the selected unit - if( m_unit == EDA_UNITS::MILLIMETRES ) - m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI * 25.4; - else if( m_unit == EDA_UNITS::INCHES ) - m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI; - else - m_outputSize = m_originalDPI; -} - - -int IMAGE_SIZE::GetOutputDPI() -{ - int outputDPI; - - if( m_unit == EDA_UNITS::MILLIMETRES ) - outputDPI = GetOriginalSizePixels() / ( m_outputSize / 25.4 ); - else if( m_unit == EDA_UNITS::INCHES ) - outputDPI = GetOriginalSizePixels() / m_outputSize; - else - outputDPI = KiROUND( m_outputSize ); - - // Zero is not a DPI, and may cause divide-by-zero errors... - outputDPI = std::max( 1, outputDPI ); - - return outputDPI; -} - - -void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit ) -{ - // Set the unit used for m_outputSize, and convert the old m_outputSize value - // to the value in new unit - if( aUnit == m_unit ) - return; - - // Convert m_outputSize to mm: - double size_mm; - - if( m_unit == EDA_UNITS::MILLIMETRES ) - { - size_mm = m_outputSize; - } - else if( m_unit == EDA_UNITS::INCHES ) - { - size_mm = m_outputSize * 25.4; - } - else - { - // m_outputSize is the DPI, not an image size - // the image size is m_originalSizePixels / m_outputSize (in inches) - if( m_outputSize ) - size_mm = m_originalSizePixels / m_outputSize * 25.4; - else - size_mm = 0; - } - - // Convert m_outputSize to new value: - if( aUnit == EDA_UNITS::MILLIMETRES ) - { - m_outputSize = size_mm; - } - else if( aUnit == EDA_UNITS::INCHES ) - { - m_outputSize = size_mm / 25.4; - } - else - { - if( size_mm ) - m_outputSize = m_originalSizePixels / size_mm * 25.4; - else - m_outputSize = 0; - } - - m_unit = aUnit; -} - - -BEGIN_EVENT_TABLE( BM2CMP_FRAME, BM2CMP_FRAME_BASE ) - EVT_MENU( wxID_EXIT, BM2CMP_FRAME::OnExit ) - EVT_MENU( wxID_OPEN, BM2CMP_FRAME::OnLoadFile ) -END_EVENT_TABLE() - - -BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) : - BM2CMP_FRAME_BASE( aParent ) -{ - m_ident = FRAME_BM2CMP; // Initialized to wxID_ANY by wxFormBuilder - SetKiway( this, aKiway ); - for( wxString unit : { _( "mm" ), _( "Inch" ), _( "DPI" ) } ) m_PixelUnit->Append( unit ); - LoadSettings( config() ); - m_outputSizeX.SetUnit( getUnitFromSelection() ); m_outputSizeY.SetUnit( getUnitFromSelection() ); m_outputSizeX.SetOutputSize( 0, getUnitFromSelection() ); @@ -164,99 +57,24 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); - // Give an icon - wxIcon icon; - wxIconBundle icon_bundle; - - icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component ) ); - icon_bundle.AddIcon( icon ); - icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component_32 ) ); - icon_bundle.AddIcon( icon ); - icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_bitmap2component_16 ) ); - icon_bundle.AddIcon( icon ); - - SetIcons( icon_bundle ); - - ReCreateMenuBar(); - - GetSizer()->SetSizeHints( this ); - m_buttonExportFile->Enable( false ); m_buttonExportClipboard->Enable( false ); - - SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y ); - - if ( m_framePos == wxDefaultPosition ) - Centre(); } -BM2CMP_FRAME::~BM2CMP_FRAME() +BITMAP2CMP_PANEL::~BITMAP2CMP_PANEL() { - SaveSettings( config() ); - /* - * This needed for OSX: avoids further OnDraw processing after this - * destructor and before the native window is destroyed - */ - Freeze(); } -wxWindow* BM2CMP_FRAME::GetToolCanvas() const +wxWindow* BITMAP2CMP_PANEL::GetCurrentPage() { return m_Notebook->GetCurrentPage(); } -void BM2CMP_FRAME::doReCreateMenuBar() +void BITMAP2CMP_PANEL::LoadSettings( BITMAP2CMP_SETTINGS* cfg ) { - // wxWidgets handles the Mac Application menu behind the scenes, but that means - // we always have to start from scratch with a new wxMenuBar. - wxMenuBar* oldMenuBar = GetMenuBar(); - wxMenuBar* menuBar = new wxMenuBar(); - - wxMenu* fileMenu = new wxMenu; - - wxMenuItem* item = new wxMenuItem( fileMenu, wxID_OPEN, _( "Open..." ) + wxT( "\tCtrl+O" ), - _( "Load source image" ) ); - - fileMenu->Append( item ); - -#ifndef __WXMAC__ - // Mac moves Quit to the App menu so we don't need a separator on Mac - fileMenu->AppendSeparator(); -#endif - - item = new wxMenuItem( fileMenu, wxID_EXIT, _( "Quit" ) + wxT( "\tCtrl+Q" ), - _( "Quit Image Converter" ) ); - - if( Pgm().GetCommonSettings()->m_Appearance.use_icons_in_menus ) - item->SetBitmap( KiBitmap( BITMAPS::exit ) ); - - fileMenu->Append( item ); - - menuBar->Append( fileMenu, _( "&File" ) ); - - SetMenuBar( menuBar ); - delete oldMenuBar; -} - - -void BM2CMP_FRAME::OnExit( wxCommandEvent& event ) -{ - Destroy(); -} - - -void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) -{ - EDA_BASE_FRAME::LoadSettings( aCfg ); - - BITMAP2CMP_SETTINGS* cfg = static_cast( aCfg ); - - m_BitmapFileName = cfg->m_BitmapFileName; - m_ConvertedFileName = cfg->m_ConvertedFileName; - int u_select = cfg->m_Units; if( u_select < 0 || u_select > 2 ) // Validity control @@ -291,23 +109,17 @@ void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) } -void BM2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) +void BITMAP2CMP_PANEL::SaveSettings( BITMAP2CMP_SETTINGS* cfg ) { - EDA_BASE_FRAME::SaveSettings( aCfg ); - - BITMAP2CMP_SETTINGS* cfg = static_cast( aCfg ); - - cfg->m_BitmapFileName = m_BitmapFileName; - cfg->m_ConvertedFileName = m_ConvertedFileName; - cfg->m_Threshold = m_sliderThreshold->GetValue(); - cfg->m_Negative = m_checkNegative->IsChecked(); - cfg->m_LastFormat = m_rbOutputFormat->GetSelection(); - cfg->m_LastModLayer = m_chPCBLayer->GetSelection(); - cfg->m_Units = m_PixelUnit->GetSelection(); + cfg->m_Threshold = m_sliderThreshold->GetValue(); + cfg->m_Negative = m_checkNegative->IsChecked(); + cfg->m_LastFormat = m_rbOutputFormat->GetSelection(); + cfg->m_LastModLayer = m_chPCBLayer->GetSelection(); + cfg->m_Units = m_PixelUnit->GetSelection(); } -void BM2CMP_FRAME::OnPaintInit( wxPaintEvent& event ) +void BITMAP2CMP_PANEL::OnPaintInit( wxPaintEvent& event ) { #ifdef __WXMAC__ // Otherwise fails due: using wxPaintDC without being in a native paint event @@ -326,7 +138,7 @@ void BM2CMP_FRAME::OnPaintInit( wxPaintEvent& event ) } -void BM2CMP_FRAME::OnPaintGreyscale( wxPaintEvent& event ) +void BITMAP2CMP_PANEL::OnPaintGreyscale( wxPaintEvent& event ) { #ifdef __WXMAC__ // Otherwise fails due: using wxPaintDC without being in a native paint event @@ -345,7 +157,7 @@ void BM2CMP_FRAME::OnPaintGreyscale( wxPaintEvent& event ) } -void BM2CMP_FRAME::OnPaintBW( wxPaintEvent& event ) +void BITMAP2CMP_PANEL::OnPaintBW( wxPaintEvent& event ) { #ifdef __WXMAC__ // Otherwise fails due: using wxPaintDC without being in a native paint event @@ -363,41 +175,17 @@ void BM2CMP_FRAME::OnPaintBW( wxPaintEvent& event ) } -void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnLoadFile( wxCommandEvent& event ) { - wxFileName fn( m_BitmapFileName ); - wxString path = fn.GetPath(); - - if( path.IsEmpty() || !wxDirExists( path ) ) - path = m_mruPath; - - wxFileDialog fileDlg( this, _( "Choose Image" ), path, wxEmptyString, - _( "Image Files" ) + wxS( " " )+ wxImage::GetImageExtWildcard(), - wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) - return; - - wxString fullFilename = fileDlg.GetPath(); - - if( !OpenProjectFiles( std::vector( 1, fullFilename ) ) ) - return; - - fn = fullFilename; - m_mruPath = fn.GetPath(); - SetStatusText( fullFilename ); - Refresh(); + m_parentFrame->OnLoadFile( event ); } -bool BM2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) +bool BITMAP2CMP_PANEL::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) { m_Pict_Image.Destroy(); - m_BitmapFileName = aFileSet[0]; - if( !m_Pict_Image.LoadFile( m_BitmapFileName ) ) + if( !m_Pict_Image.LoadFile( aFileSet[0] ) ) { // LoadFile has its own UI, no need for further failure notification here return false; @@ -485,7 +273,7 @@ bool BM2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int // return a string giving the output size, according to the selected unit -wxString BM2CMP_FRAME::FormatOutputSize( double aSize ) +wxString BITMAP2CMP_PANEL::FormatOutputSize( double aSize ) { wxString text; @@ -499,7 +287,7 @@ wxString BM2CMP_FRAME::FormatOutputSize( double aSize ) return text; } -void BM2CMP_FRAME::updateImageInfo() +void BITMAP2CMP_PANEL::updateImageInfo() { // Note: the image resolution text controls are not modified here, to avoid a race between // text change when entered by user and a text change if it is modified here. @@ -517,7 +305,7 @@ void BM2CMP_FRAME::updateImageInfo() } -EDA_UNITS BM2CMP_FRAME::getUnitFromSelection() +EDA_UNITS BITMAP2CMP_PANEL::getUnitFromSelection() { // return the EDA_UNITS from the m_PixelUnit choice switch( m_PixelUnit->GetSelection() ) @@ -530,7 +318,7 @@ EDA_UNITS BM2CMP_FRAME::getUnitFromSelection() } -void BM2CMP_FRAME::OnSizeChangeX( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnSizeChangeX( wxCommandEvent& event ) { double new_size; @@ -559,7 +347,7 @@ void BM2CMP_FRAME::OnSizeChangeX( wxCommandEvent& event ) } -void BM2CMP_FRAME::OnSizeChangeY( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnSizeChangeY( wxCommandEvent& event ) { double new_size; @@ -588,7 +376,7 @@ void BM2CMP_FRAME::OnSizeChangeY( wxCommandEvent& event ) } -void BM2CMP_FRAME::OnSizeUnitChange( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnSizeUnitChange( wxCommandEvent& event ) { m_outputSizeX.SetUnit( getUnitFromSelection() ); m_outputSizeY.SetUnit( getUnitFromSelection() ); @@ -599,7 +387,7 @@ void BM2CMP_FRAME::OnSizeUnitChange( wxCommandEvent& event ) } -void BM2CMP_FRAME::ToggleAspectRatioLock( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::ToggleAspectRatioLock( wxCommandEvent& event ) { if( m_aspectRatioCheckbox->GetValue() ) { @@ -610,7 +398,7 @@ void BM2CMP_FRAME::ToggleAspectRatioLock( wxCommandEvent& event ) } -void BM2CMP_FRAME::Binarize( double aThreshold ) +void BITMAP2CMP_PANEL::Binarize( double aThreshold ) { int h = m_Greyscale_Image.GetHeight(); int w = m_Greyscale_Image.GetWidth(); @@ -639,7 +427,7 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) } -void BM2CMP_FRAME::NegateGreyscaleImage( ) +void BITMAP2CMP_PANEL::NegateGreyscaleImage( ) { unsigned char pix; int h = m_Greyscale_Image.GetHeight(); @@ -657,7 +445,7 @@ void BM2CMP_FRAME::NegateGreyscaleImage( ) } -void BM2CMP_FRAME::OnNegativeClicked( wxCommandEvent& ) +void BITMAP2CMP_PANEL::OnNegativeClicked( wxCommandEvent& ) { if( m_checkNegative->GetValue() != m_Negative ) { @@ -672,14 +460,14 @@ void BM2CMP_FRAME::OnNegativeClicked( wxCommandEvent& ) } -void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event ) +void BITMAP2CMP_PANEL::OnThresholdChange( wxScrollEvent& event ) { Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() ); Refresh(); } -void BM2CMP_FRAME::OnExportToFile( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnExportToFile( wxCommandEvent& event ) { // choices of m_rbOutputFormat are expected to be in same order as // OUTPUT_FMT_ID. See bitmap2component.h @@ -688,7 +476,7 @@ void BM2CMP_FRAME::OnExportToFile( wxCommandEvent& event ) } -void BM2CMP_FRAME::OnExportToClipboard( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnExportToClipboard( wxCommandEvent& event ) { // choices of m_rbOutputFormat are expected to be in same order as // OUTPUT_FMT_ID. See bitmap2component.h @@ -715,161 +503,19 @@ void BM2CMP_FRAME::OnExportToClipboard( wxCommandEvent& event ) } -void BM2CMP_FRAME::exportBitmap( OUTPUT_FMT_ID aFormat ) +void BITMAP2CMP_PANEL::exportBitmap( OUTPUT_FMT_ID aFormat ) { switch( aFormat ) { - case EESCHEMA_FMT: exportEeschemaFormat(); break; - case PCBNEW_KICAD_MOD: exportPcbnewFormat(); break; - case POSTSCRIPT_FMT: exportPostScriptFormat(); break; - case KICAD_WKS_LOGO: exportLogo(); break; + case EESCHEMA_FMT: m_parentFrame->ExportEeschemaFormat(); break; + case PCBNEW_KICAD_MOD: m_parentFrame->ExportPcbnewFormat(); break; + case POSTSCRIPT_FMT: m_parentFrame->ExportPostScriptFormat(); break; + case KICAD_WKS_LOGO: m_parentFrame->ExportLogo(); break; } } -void BM2CMP_FRAME::exportLogo() -{ - wxFileName fn( m_ConvertedFileName ); - wxString path = fn.GetPath(); - - if( path.IsEmpty() || !wxDirExists(path) ) - path = ::wxGetCwd(); - - wxFileDialog fileDlg( this, _( "Create Logo File" ), path, wxEmptyString, - DrawingSheetFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) - return; - - fn = fileDlg.GetPath(); - fn.SetExt( DrawingSheetFileExtension ); - m_ConvertedFileName = fn.GetFullPath(); - - FILE* outfile; - outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); - - if( outfile == nullptr ) - { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_ConvertedFileName ); - wxMessageBox( msg ); - return; - } - - std::string buffer; - ExportToBuffer( buffer, KICAD_WKS_LOGO ); - fputs( buffer.c_str(), outfile ); - fclose( outfile ); -} - - -void BM2CMP_FRAME::exportPostScriptFormat() -{ - wxFileName fn( m_ConvertedFileName ); - wxString path = fn.GetPath(); - - if( path.IsEmpty() || !wxDirExists( path ) ) - path = ::wxGetCwd(); - - wxFileDialog fileDlg( this, _( "Create PostScript File" ), path, wxEmptyString, - PSFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( fileDlg.ShowModal() != wxID_OK ) - return; - - fn = fileDlg.GetPath(); - fn.SetExt( wxT( "ps" ) ); - m_ConvertedFileName = fn.GetFullPath(); - - FILE* outfile; - outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); - - if( outfile == nullptr ) - { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_ConvertedFileName ); - wxMessageBox( msg ); - return; - } - - std::string buffer; - ExportToBuffer( buffer, POSTSCRIPT_FMT ); - fputs( buffer.c_str(), outfile ); - fclose( outfile ); -} - - -void BM2CMP_FRAME::exportEeschemaFormat() -{ - wxFileName fn( m_ConvertedFileName ); - wxString path = fn.GetPath(); - - if( path.IsEmpty() || !wxDirExists(path) ) - path = ::wxGetCwd(); - - wxFileDialog fileDlg( this, _( "Create Symbol Library" ), path, wxEmptyString, - KiCadSymbolLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( fileDlg.ShowModal() != wxID_OK ) - return; - - fn = EnsureFileExtension( fileDlg.GetPath(), KiCadSymbolLibFileExtension ); - m_ConvertedFileName = fn.GetFullPath(); - - FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); - - if( outfile == nullptr ) - { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_ConvertedFileName ); - wxMessageBox( msg ); - return; - } - - std::string buffer; - ExportToBuffer( buffer, EESCHEMA_FMT ); - fputs( buffer.c_str(), outfile ); - fclose( outfile ); -} - - -void BM2CMP_FRAME::exportPcbnewFormat() -{ - wxFileName fn( m_ConvertedFileName ); - wxString path = fn.GetPath(); - - if( path.IsEmpty() || !wxDirExists( path ) ) - path = m_mruPath; - - wxFileDialog fileDlg( this, _( "Create Footprint Library" ), path, wxEmptyString, - KiCadFootprintLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - - if( fileDlg.ShowModal() != wxID_OK ) - return; - - fn = EnsureFileExtension( fileDlg.GetPath(), KiCadFootprintFileExtension ); - m_ConvertedFileName = fn.GetFullPath(); - - FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); - - if( outfile == nullptr ) - { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_ConvertedFileName ); - wxMessageBox( msg ); - return; - } - - std::string buffer; - ExportToBuffer( buffer, PCBNEW_KICAD_MOD ); - fputs( buffer.c_str(), outfile ); - fclose( outfile ); - m_mruPath = fn.GetPath(); -} - - -void BM2CMP_FRAME::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) +void BITMAP2CMP_PANEL::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) { // Create a potrace bitmap int h = m_NB_Image.GetHeight(); @@ -910,7 +556,7 @@ void BM2CMP_FRAME::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) } -void BM2CMP_FRAME::OnFormatChange( wxCommandEvent& event ) +void BITMAP2CMP_PANEL::OnFormatChange( wxCommandEvent& event ) { bool enable = m_rbOutputFormat->GetSelection() == PCBNEW_KICAD_MOD; m_chPCBLayer->Enable( enable ); diff --git a/bitmap2component/bitmap2cmp_panel.h b/bitmap2component/bitmap2cmp_panel.h new file mode 100644 index 0000000000..1147705bae --- /dev/null +++ b/bitmap2component/bitmap2cmp_panel.h @@ -0,0 +1,100 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2019-2022 Kicad Developers, see AUTHORS.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 BITMAP2CMP_PANEL_H +#define BITMAP2CMP_PANEL_H + +#include +#include + + +class BITMAP2CMP_FRAME; +class BITMAP2CMP_SETTINGS; + + +class BITMAP2CMP_PANEL : public BITMAP2CMP_PANEL_BASE +{ +public: + BITMAP2CMP_PANEL( BITMAP2CMP_FRAME* aParent ); + ~BITMAP2CMP_PANEL(); + + bool OpenProjectFiles( const std::vector& aFilenames, int aCtl = 0 ); + + void OnLoadFile( wxCommandEvent& event ) override; + + void LoadSettings( BITMAP2CMP_SETTINGS* aCfg ); + void SaveSettings( BITMAP2CMP_SETTINGS* aCfg ); + + wxWindow* GetCurrentPage(); + + /** + * generate a export data of the current bitmap. + * @param aOutput is a string buffer to fill with data + * @param aFormat is the format to generate + */ + void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ); + +private: + // Event handlers + void OnPaintInit( wxPaintEvent& event ) override; + void OnPaintGreyscale( wxPaintEvent& event ) override; + void OnPaintBW( wxPaintEvent& event ) override; + void OnExportToFile( wxCommandEvent& event ) override; + void OnExportToClipboard( wxCommandEvent& event ) override; + + ///< @return the EDA_UNITS from the m_PixelUnit choice + EDA_UNITS getUnitFromSelection(); + + // return a string giving the output size, according to the selected unit + wxString FormatOutputSize( double aSize ); + + void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) + void OnNegativeClicked( wxCommandEvent& event ) override; + void OnThresholdChange( wxScrollEvent& event ) override; + + void OnSizeChangeX( wxCommandEvent& event ) override; + void OnSizeChangeY( wxCommandEvent& event ) override; + void OnSizeUnitChange( wxCommandEvent& event ) override; + + void ToggleAspectRatioLock( wxCommandEvent& event ) override; + + void NegateGreyscaleImage(); + + void updateImageInfo(); + void OnFormatChange( wxCommandEvent& event ) override; + void exportBitmap( OUTPUT_FMT_ID aFormat ); + +private: + BITMAP2CMP_FRAME* m_parentFrame; + + wxImage m_Pict_Image; + wxBitmap m_Pict_Bitmap; + wxImage m_Greyscale_Image; + wxBitmap m_Greyscale_Bitmap; + wxImage m_NB_Image; + wxBitmap m_BN_Bitmap; + IMAGE_SIZE m_outputSizeX; + IMAGE_SIZE m_outputSizeY; + bool m_Negative; + double m_AspectRatio; +}; +#endif// BITMAP2CMP_PANEL diff --git a/bitmap2component/bitmap2cmp_gui_base.cpp b/bitmap2component/bitmap2cmp_panel_base.cpp similarity index 80% rename from bitmap2component/bitmap2cmp_gui_base.cpp rename to bitmap2component/bitmap2cmp_panel_base.cpp index 19d66be8a1..2bd5f29049 100644 --- a/bitmap2component/bitmap2cmp_gui_base.cpp +++ b/bitmap2component/bitmap2cmp_panel_base.cpp @@ -1,24 +1,16 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "bitmap2cmp_gui_base.h" +#include "bitmap2cmp_panel_base.h" /////////////////////////////////////////////////////////////////////////// -BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : KIWAY_PLAYER( parent, id, title, pos, size, style ) +BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - m_menubar = new wxMenuBar( 0 ); - m_menu1 = new wxMenu(); - m_menubar->Append( m_menu1, _("dummy") ); - - this->SetMenuBar( m_menubar ); - wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -106,6 +98,9 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_buttonLoad = new wxButton( this, wxID_ANY, _("Load Source Image"), wxDefaultPosition, wxDefaultSize, 0 ); brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + brightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + wxStaticBoxSizer* sbSizerImgPrms; sbSizerImgPrms = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Size") ), wxVERTICAL ); @@ -184,47 +179,46 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS brightSizer->Add( m_buttonExportClipboard, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bMainSizer->Add( brightSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bMainSizer->Add( brightSizer, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - m_statusBar = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY ); // Connect Events - m_InitialPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintInit ), NULL, this ); - m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintGreyscale ), NULL, this ); - m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintBW ), NULL, this ); - m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_aspectRatioCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this ); - m_UnitSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeX ), NULL, this ); - m_UnitSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeY ), NULL, this ); - m_PixelUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeUnitChange ), NULL, this ); - m_sliderThreshold->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); - m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); - m_checkNegative->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnNegativeClicked ), NULL, this ); - m_rbOutputFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this ); - m_buttonExportFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this ); - m_buttonExportClipboard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this ); + m_InitialPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintInit ), NULL, this ); + m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintGreyscale ), NULL, this ); + m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintBW ), NULL, this ); + m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnLoadFile ), NULL, this ); + m_aspectRatioCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); + m_UnitSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeX ), NULL, this ); + m_UnitSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeY ), NULL, this ); + m_PixelUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeUnitChange ), NULL, this ); + m_sliderThreshold->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); + m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); + m_checkNegative->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnNegativeClicked ), NULL, this ); + m_rbOutputFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_buttonExportFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToFile ), NULL, this ); + m_buttonExportClipboard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToClipboard ), NULL, this ); } -BM2CMP_FRAME_BASE::~BM2CMP_FRAME_BASE() +BITMAP2CMP_PANEL_BASE::~BITMAP2CMP_PANEL_BASE() { // Disconnect Events - m_InitialPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintInit ), NULL, this ); - m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintGreyscale ), NULL, this ); - m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintBW ), NULL, this ); - m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_aspectRatioCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this ); - m_UnitSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeX ), NULL, this ); - m_UnitSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeY ), NULL, this ); - m_PixelUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeUnitChange ), NULL, this ); - m_sliderThreshold->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); - m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); - m_checkNegative->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnNegativeClicked ), NULL, this ); - m_rbOutputFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this ); - m_buttonExportFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this ); - m_buttonExportClipboard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this ); + m_InitialPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintInit ), NULL, this ); + m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintGreyscale ), NULL, this ); + m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintBW ), NULL, this ); + m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnLoadFile ), NULL, this ); + m_aspectRatioCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); + m_UnitSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeX ), NULL, this ); + m_UnitSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeY ), NULL, this ); + m_PixelUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeUnitChange ), NULL, this ); + m_sliderThreshold->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); + m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); + m_checkNegative->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnNegativeClicked ), NULL, this ); + m_rbOutputFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_buttonExportFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToFile ), NULL, this ); + m_buttonExportClipboard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToClipboard ), NULL, this ); } diff --git a/bitmap2component/bitmap2cmp_gui_base.fbp b/bitmap2component/bitmap2cmp_panel_base.fbp similarity index 95% rename from bitmap2component/bitmap2cmp_gui_base.fbp rename to bitmap2component/bitmap2cmp_panel_base.fbp index fd9d93e6e0..92ed307a8a 100644 --- a/bitmap2component/bitmap2cmp_gui_base.fbp +++ b/bitmap2component/bitmap2cmp_panel_base.fbp @@ -11,13 +11,13 @@ res UTF-8 connect - bitmap2cmp_gui_base + bitmap2cmp_panel_base 1000 none 1 - bitmap2cmp_gui + bitmap2cmp_panel . @@ -29,63 +29,29 @@ 0 0 0 - + 0 wxAUI_MGR_DEFAULT - 1 - 0 1 impl_virtual - 0 wxID_ANY - BM2CMP_FRAME_BASE + BITMAP2CMP_PANEL_BASE -1,-1 - wxCLOSE_BOX|wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER - KIWAY_PLAYER; kiway_player.h - Image Converter + ; ; forward_declare 0 wxTAB_TRAVERSAL - 1 - - - - 1 - 0 - 1 - - - 0 - wxID_ANY - - - m_menubar - protected - - - - ; ; forward_declare - - - - - - dummy - m_menu1 - protected - - bMainSizer @@ -117,7 +83,6 @@ Dock 0 Left - 0 1 1 @@ -174,7 +139,6 @@ Dock 0 Left - 0 1 1 @@ -235,7 +199,6 @@ Dock 0 Left - 0 1 1 @@ -296,7 +259,6 @@ Dock 0 Left - 0 1 1 @@ -336,7 +298,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + wxEXPAND|wxALL 0 @@ -347,7 +309,7 @@ 5 wxEXPAND|wxALL 0 - + wxID_ANY Image Information @@ -355,11 +317,11 @@ wxVERTICAL 1 none - + 5 wxEXPAND 0 - + 4 wxBOTH 1,2 @@ -396,7 +358,6 @@ Dock 0 Left - 0 1 1 @@ -458,7 +419,6 @@ Dock 0 Left - 0 1 1 @@ -520,7 +480,6 @@ Dock 0 Left - 0 1 1 @@ -582,7 +541,6 @@ Dock 0 Left - 0 1 1 @@ -619,11 +577,11 @@ -1 - + 5 wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -644,7 +602,6 @@ Dock 0 Left - 0 1 1 @@ -681,11 +638,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -706,7 +663,6 @@ Dock 0 Left - 0 1 1 @@ -743,11 +699,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 - + 1 1 1 @@ -768,7 +724,6 @@ Dock 0 Left - 0 1 1 @@ -805,11 +760,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 - + 1 1 1 @@ -830,7 +785,6 @@ Dock 0 Left - 0 1 1 @@ -892,7 +846,6 @@ Dock 0 Left - 0 1 1 @@ -954,7 +907,6 @@ Dock 0 Left - 0 1 1 @@ -1016,7 +968,6 @@ Dock 0 Left - 0 1 1 @@ -1053,11 +1004,11 @@ -1 - + 5 0 - + 0 protected 0 @@ -1097,7 +1048,6 @@ Dock 0 Left - 0 1 1 @@ -1142,11 +1092,21 @@ OnLoadFile + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 wxALL|wxEXPAND 0 - + wxID_ANY Output Size @@ -1154,11 +1114,11 @@ wxVERTICAL 1 none - + 5 wxBOTTOM 0 - + 1 1 1 @@ -1180,7 +1140,6 @@ Dock 0 Left - 0 1 1 @@ -1220,11 +1179,11 @@ ToggleAspectRatioLock - + 5 wxEXPAND 0 - + bSizerRes wxHORIZONTAL @@ -1254,7 +1213,6 @@ Dock 0 Left - 0 1 1 @@ -1316,7 +1274,6 @@ Dock 0 Left - 0 1 1 @@ -1382,7 +1339,6 @@ Dock 0 Left - 0 1 1 @@ -1449,7 +1405,6 @@ Dock 0 Left - 0 1 1 @@ -1497,7 +1452,7 @@ 5 wxALL|wxEXPAND 0 - + wxID_ANY Options @@ -1505,11 +1460,11 @@ wxVERTICAL 1 none - + 5 wxLEFT 0 - + 1 1 1 @@ -1530,7 +1485,6 @@ Dock 0 Left - 0 1 1 @@ -1567,11 +1521,11 @@ -1 - + 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -1592,7 +1546,6 @@ Dock 0 Left - 0 1 1 @@ -1635,11 +1588,11 @@ OnThresholdChange - + 5 wxBOTTOM 0 - + 1 1 1 @@ -1661,7 +1614,6 @@ Dock 0 Left - 0 1 1 @@ -1707,7 +1659,7 @@ 5 wxEXPAND|wxRIGHT|wxLEFT 0 - + wxID_ANY Pcb Layer for Graphics @@ -1715,11 +1667,11 @@ wxVERTICAL 1 protected - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -1741,7 +1693,6 @@ Dock 0 Left - 0 1 1 @@ -1808,7 +1759,6 @@ Dock 0 Left - 0 1 1 @@ -1880,7 +1830,6 @@ Dock 0 Left - 0 1 1 @@ -1955,7 +1904,6 @@ Dock 0 Left - 0 1 1 @@ -2003,30 +1951,6 @@ - - - - 1 - 0 - 1 - - 1 - - 0 - wxID_ANY - - - m_statusBar - protected - - - wxSTB_SIZEGRIP - - - - - - diff --git a/bitmap2component/bitmap2cmp_gui_base.h b/bitmap2component/bitmap2cmp_panel_base.h similarity index 83% rename from bitmap2component/bitmap2cmp_gui_base.h rename to bitmap2component/bitmap2cmp_panel_base.h index fdfbc00979..ce2479e918 100644 --- a/bitmap2component/bitmap2cmp_gui_base.h +++ b/bitmap2component/bitmap2cmp_panel_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -10,14 +10,12 @@ #include #include #include -#include "kiway_player.h" -#include -#include +#include #include #include #include #include -#include +#include #include #include #include @@ -32,22 +30,19 @@ #include #include #include -#include -#include +#include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class BM2CMP_FRAME_BASE +/// Class BITMAP2CMP_PANEL_BASE /////////////////////////////////////////////////////////////////////////////// -class BM2CMP_FRAME_BASE : public KIWAY_PLAYER +class BITMAP2CMP_PANEL_BASE : public wxPanel { private: protected: - wxMenuBar* m_menubar; - wxMenu* m_menu1; wxNotebook* m_Notebook; wxScrolledWindow* m_InitialPicturePanel; wxScrolledWindow* m_GreyscalePicturePanel; @@ -77,7 +72,6 @@ class BM2CMP_FRAME_BASE : public KIWAY_PLAYER wxRadioBox* m_rbOutputFormat; wxButton* m_buttonExportFile; wxButton* m_buttonExportClipboard; - wxStatusBar* m_statusBar; // Virtual event handlers, override them in your derived class virtual void OnPaintInit( wxPaintEvent& event ) { event.Skip(); } @@ -97,9 +91,9 @@ class BM2CMP_FRAME_BASE : public KIWAY_PLAYER public: - BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Image Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCLOSE_BOX|wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - ~BM2CMP_FRAME_BASE(); + ~BITMAP2CMP_PANEL_BASE(); }; diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index 4fa97a09fa..a715d8d1d7 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -55,27 +55,8 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType } -// Don't use this one; it's only for wxFormBuilder, and it must be augmented with code to -// correct the m_ident and set the m_kiway early in derived constructor. -// -// Because of its inherent danger, it's also declared private and requires friend-class -// declarations for each usage. -// -KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, - const wxPoint& aPos, const wxSize& aSize, long aStyle, - const wxString& aWdoName ) : - EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName, nullptr, - unityScale ), - m_modal( false ), - m_modal_loop( nullptr ), - m_modal_resultant_parent( nullptr ), - m_modal_ret_val( false ), - m_socketServer( nullptr ) +KIWAY_PLAYER::~KIWAY_PLAYER() throw() { -} - - -KIWAY_PLAYER::~KIWAY_PLAYER() throw() { // socket server must be destructed before we complete // destructing the frame or else we could crash diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index cb510c1186..3dcc2921f7 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -110,6 +110,9 @@ END_EVENT_TABLE() SIMULATOR_FRAME::SIMULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_SIMULATOR, _( "Simulator" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( "simulator" ), unityScale ), + m_schematicFrame( nullptr ), + m_toolBar( nullptr ), + m_panel( nullptr ), m_lastSimPlot( nullptr ), m_simFinished( false ), m_workbookModified( false ) diff --git a/include/kiway_player.h b/include/kiway_player.h index edac4c3c0f..10ef84ccf7 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -175,16 +175,6 @@ public: */ virtual void ExecuteRemoteCommand( const char* cmdline ){} - -private: - friend class BM2CMP_FRAME_BASE; - - /// Don't use this one, only wxformbuilder uses it, and it must be augmented with correcting - /// m_ident and calling a SetKiway() early in derived constructor. - KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, - const wxPoint& aPos, const wxSize& aSize, long aStyle, - const wxString& aWdoName = wxFrameNameStr ); - protected: /// event handler, routes to derivative specific virtual KiwayMailIn()