43#include <wx/filedlg.h>
47#define DEFAULT_DPI 300
54 m_unit = EDA_UNITS::MILLIMETRES;
64 if(
m_unit == EDA_UNITS::MILLIMETRES )
66 else if(
m_unit == EDA_UNITS::INCHES )
77 if(
m_unit == EDA_UNITS::MILLIMETRES )
79 else if(
m_unit == EDA_UNITS::INCHES )
85 outputDPI = std::max( 1, outputDPI );
101 if(
m_unit == EDA_UNITS::MILLIMETRES )
105 else if(
m_unit == EDA_UNITS::INCHES )
120 if( aUnit == EDA_UNITS::MILLIMETRES )
124 else if( aUnit == EDA_UNITS::INCHES )
151 wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( "bitmap2cmp" ),
unityScale ),
153 m_statusBar(
nullptr )
155 m_aboutTitle =
_HKI(
"KiCad Image Converter" );
159 wxIconBundle icon_bundle;
162 icon_bundle.AddIcon( icon );
164 icon_bundle.AddIcon( icon );
166 icon_bundle.AddIcon( icon );
168 icon_bundle.AddIcon( icon );
170 icon_bundle.AddIcon( icon );
172 SetIcons( icon_bundle );
174 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
175 SetSizer( mainSizer );
178 mainSizer->Add( m_panel, 1, wxEXPAND, 5 );
180 m_statusBar = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY );
192 m_toolManager->InitTools();
197 GetSizer()->SetSizeHints(
this );
199 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
201 if ( m_framePos == wxDefaultPosition )
254 wxCHECK( base_frame, );
258 wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
272 if( !openRecentMenu )
275 openRecentMenu->
SetIcon( BITMAPS::recent );
277 fileHistory.UseMenu( openRecentMenu );
282 openRecentMenu->
SetTitle(
_(
"Open Recent" ) );
285 wxMenuItem* item = fileMenu->
Add( openRecentMenu->
Clone() );
292 fileMenu->AppendSeparator();
293 fileMenu->
AddQuit(
_(
"Image Converter" ) );
301 prefsMenu->AppendSeparator();
307 menuBar->Append( fileMenu,
_(
"&File" ) );
308 menuBar->Append( prefsMenu,
_(
"&Preferences" ) );
309 base_frame->AddStandardHelpMenu( menuBar );
311 base_frame->SetMenuBar( menuBar );
327 wxSizer* mainSizer =
m_panel->GetContainingSizer();
332 mainSizer->Add(
m_panel, 1, wxEXPAND, 5 );
353 title = filename.GetFullName() + wxT(
" \u2014 " );
356 title +=
_(
"Image Converter" );
391 wxString
path = fn.GetPath();
393 if(
path.IsEmpty() || !wxDirExists(
path ) )
396 wxFileDialog fileDlg(
this,
_(
"Choose Image" ),
path, wxEmptyString,
397 _(
"Image Files" ) + wxS(
" " )+ wxImage::GetImageExtWildcard(),
398 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
400 if( fileDlg.ShowModal() != wxID_OK )
403 wxString fullFilename = fileDlg.GetPath();
410 SetStatusText( fullFilename );
433 wxString
path = fn.GetPath();
435 if(
path.IsEmpty() || !wxDirExists(
path) )
438 wxFileDialog fileDlg(
this,
_(
"Create Drawing Sheet File" ),
path, wxEmptyString,
441 if( fileDlg.ShowModal() != wxID_OK )
444 fn = fileDlg.GetPath();
452 wxMessageBox( wxString::Format(
_(
"File '%s' could not be created." ),
m_outFileName ) );
458 fputs( buffer.c_str(), outfile );
466 wxString
path = fn.GetPath();
468 if(
path.IsEmpty() || !wxDirExists(
path ) )
471 wxFileDialog fileDlg(
this,
_(
"Create PostScript File" ),
path, wxEmptyString,
474 if( fileDlg.ShowModal() != wxID_OK )
477 fn = fileDlg.GetPath();
478 fn.SetExt( wxT(
"ps" ) );
485 wxMessageBox( wxString::Format(
_(
"File '%s' could not be created." ),
m_outFileName ) );
491 fputs( buffer.c_str(), outfile );
499 wxString
path = fn.GetPath();
501 if(
path.IsEmpty() || !wxDirExists(
path ) )
504 wxFileDialog fileDlg(
this,
_(
"Create Symbol Library" ),
path, wxEmptyString,
506 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
508 if( fileDlg.ShowModal() != wxID_OK )
518 wxMessageBox( wxString::Format(
_(
"File '%s' could not be created." ),
m_outFileName ) );
524 fputs( buffer.c_str(), outfile );
532 wxString
path = fn.GetPath();
534 if(
path.IsEmpty() || !wxDirExists(
path ) )
537 wxFileDialog fileDlg(
this,
_(
"Create Footprint Library" ),
path, wxEmptyString,
539 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
541 if( fileDlg.ShowModal() != wxID_OK )
551 wxMessageBox( wxString::Format(
_(
"File '%s' could not be created." ),
m_outFileName ) );
557 fputs( buffer.c_str(), outfile );
constexpr EDA_IU_SCALE unityScale
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
@ icon_bitmap2component_32
@ icon_bitmap2component_16
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION openPreferences
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handle actions for the various symbol editor and viewers.
void ExportPcbnewFormat()
Generate a footprint in S expr format.
void ExportDrawingSheetFormat()
Generate a file suitable to be copied into a drawing sheet (.kicad_wks) file.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void ExportEeschemaFormat()
Generate a schematic library which contains one component: the logo.
void OnExit(wxCommandEvent &aEvent)
Event handler for the wxID_EXIT and wxID_CLOSE events.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnFileHistory(wxCommandEvent &event)
void doReCreateMenuBar() override
wxWindow * GetToolCanvas() const override
Canvas access.
void ExportPostScriptFormat()
Generate a postscript file.
BITMAP2CMP_PANEL * m_panel
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0) override
Open a project or set of files given by aFileList.
void OnClearFileHistory(wxCommandEvent &event)
void ShowChangedLanguage() override
void SetOutputSize(const IMAGE_SIZE &aSizeX, const IMAGE_SIZE &aSizeY)
void LoadSettings(BITMAP2CMP_SETTINGS *aCfg)
IMAGE_SIZE GetOutputSizeX() const
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0)
wxWindow * GetCurrentPage()
void SaveSettings(BITMAP2CMP_SETTINGS *aCfg)
IMAGE_SIZE GetOutputSizeY() const
void ExportToBuffer(std::string &aOutput, OUTPUT_FMT_ID aFormat)
generate a export data of the current bitmap.
Handle actions that are shared between different applications.
The base frame for deriving all KiCad main window classes.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Remove all files from the file history.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
FILE_HISTORY & GetFileHistory()
Get the frame's main file history.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
This class implements a file history object to store a list of files, that can then be added to a men...
static SELECTION_CONDITION FileHistoryNotEmpty(const FILE_HISTORY &aHistory)
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items i...
void UpdateClearText(wxMenu *aMenu, wxString aClearText)
Update the text displayed on the menu item that clears the entire menu.
void AddFilesToMenu() override
Add the files to all registered menus.
void SetUnit(EDA_UNITS aUnit)
int GetOriginalSizePixels()
void SetOutputSizeFromInitialImageSize()
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
static const std::string KiCadSymbolLibFileExtension
static const std::string DrawingSheetFileExtension
static const std::string KiCadFootprintFileExtension
static wxString KiCadSymbolLibFileWildcard()
static wxString KiCadFootprintLibFileWildcard()
static wxString PSFileWildcard()
static wxString DrawingSheetFileWildcard()
Common command IDs shared by more than one of the KiCad applications.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
Definition of file extensions used in Kicad.