44#include <wx/filedlg.h>
48#define DEFAULT_DPI 300
55 m_unit = EDA_UNITS::MILLIMETRES;
65 if(
m_unit == EDA_UNITS::MILLIMETRES )
67 else if(
m_unit == EDA_UNITS::INCHES )
78 if(
m_unit == EDA_UNITS::MILLIMETRES )
80 else if(
m_unit == EDA_UNITS::INCHES )
86 outputDPI = std::max( 1, outputDPI );
102 if(
m_unit == EDA_UNITS::MILLIMETRES )
106 else if(
m_unit == EDA_UNITS::INCHES )
121 if( aUnit == EDA_UNITS::MILLIMETRES )
125 else if( aUnit == EDA_UNITS::INCHES )
152 wxDefaultSize, wxDEFAULT_FRAME_STYLE, wxT( "bitmap2cmp" ),
unityScale ),
154 m_statusBar(
nullptr )
156 m_aboutTitle =
_HKI(
"KiCad Image Converter" );
160 wxIconBundle icon_bundle;
163 icon_bundle.AddIcon( icon );
165 icon_bundle.AddIcon( icon );
167 icon_bundle.AddIcon( icon );
169 icon_bundle.AddIcon( icon );
171 icon_bundle.AddIcon( icon );
173 SetIcons( icon_bundle );
175 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
176 SetSizer( mainSizer );
179 mainSizer->Add( m_panel, 1, wxEXPAND, 5 );
181 m_statusBar = this->CreateStatusBar( 1, wxSTB_SIZEGRIP, wxID_ANY );
193 m_toolManager->InitTools();
198 GetSizer()->SetSizeHints(
this );
200 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
202 if ( m_framePos == wxDefaultPosition )
255 wxCHECK( base_frame, );
259 wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
273 if( !openRecentMenu )
276 openRecentMenu->
SetIcon( BITMAPS::recent );
278 fileHistory.UseMenu( openRecentMenu );
283 openRecentMenu->
SetTitle(
_(
"Open Recent" ) );
286 wxMenuItem* item = fileMenu->
Add( openRecentMenu->
Clone() );
293 fileMenu->AppendSeparator();
294 fileMenu->
AddQuit(
_(
"Image Converter" ) );
302 prefsMenu->AppendSeparator();
308 menuBar->Append( fileMenu,
_(
"&File" ) );
309 menuBar->Append( prefsMenu,
_(
"&Preferences" ) );
310 base_frame->AddStandardHelpMenu( menuBar );
312 base_frame->SetMenuBar( menuBar );
328 wxSizer* mainSizer =
m_panel->GetContainingSizer();
333 mainSizer->Add(
m_panel, 1, wxEXPAND, 5 );
354 title = filename.GetFullName() + wxT(
" \u2014 " );
357 title +=
_(
"Image Converter" );
396 wxString
path = fn.GetPath();
398 if(
path.IsEmpty() || !wxDirExists(
path ) )
401 wxFileDialog fileDlg(
this,
_(
"Choose Image" ),
path, wxEmptyString,
402 _(
"Image Files" ) + wxS(
" " )+ wxImage::GetImageExtWildcard(),
403 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
405 int diag = fileDlg.ShowModal();
407 if( diag != wxID_OK )
410 wxString fullFilename = fileDlg.GetPath();
417 SetStatusText( fullFilename );
440 wxString
path = fn.GetPath();
442 if(
path.IsEmpty() || !wxDirExists(
path) )
445 wxFileDialog fileDlg(
this,
_(
"Create Drawing Sheet File" ),
path, wxEmptyString,
447 int diag = fileDlg.ShowModal();
449 if( diag != wxID_OK )
452 fn = fileDlg.GetPath();
459 if( outfile ==
nullptr )
469 fputs( buffer.c_str(), outfile );
477 wxString
path = fn.GetPath();
479 if(
path.IsEmpty() || !wxDirExists(
path ) )
482 wxFileDialog fileDlg(
this,
_(
"Create PostScript File" ),
path, wxEmptyString,
485 if( fileDlg.ShowModal() != wxID_OK )
488 fn = fileDlg.GetPath();
489 fn.SetExt( wxT(
"ps" ) );
495 if( outfile ==
nullptr )
505 fputs( buffer.c_str(), outfile );
513 wxString
path = fn.GetPath();
515 if(
path.IsEmpty() || !wxDirExists(
path) )
518 wxFileDialog fileDlg(
this,
_(
"Create Symbol Library" ),
path, wxEmptyString,
520 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
522 if( fileDlg.ShowModal() != wxID_OK )
530 if( outfile ==
nullptr )
540 fputs( buffer.c_str(), outfile );
548 wxString
path = fn.GetPath();
550 if(
path.IsEmpty() || !wxDirExists(
path ) )
553 wxFileDialog fileDlg(
this,
_(
"Create Footprint Library" ),
path, wxEmptyString,
555 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
557 if( fileDlg.ShowModal() != wxID_OK )
565 if( outfile ==
nullptr )
575 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)
wxString m_convertedFileName
void doReCreateMenuBar() override
wxString m_bitmapFileName
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.
wxString m_BitmapFileName
wxString m_ConvertedFileName
Handle actions that are shared between different applications.
The base frame for deriving all KiCad main window classes.
virtual APP_SETTINGS_BASE * config() const
Returns 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)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes 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)
Fetches 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()
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.