39 #include <wx/filedlg.h> 40 #include <wx/filename.h> 41 #include <wx/stdpaths.h> 45 wxCommandEvent saveEvent;
46 saveEvent.SetId( wxID_SAVE );
59 if( filename != wxEmptyString )
74 ::wxSetWorkingDirectory( ::wxPathOnly( filename ) );
79 msg.Printf(
_(
"File \"%s\" loaded"), filename );
98 int id =
event.GetId();
102 if( filename.IsEmpty() &&
id == wxID_SAVE )
129 wxFileDialog openFileDialog(
this,
_(
"Append Existing Drawing Sheet" ),
130 wxEmptyString, wxEmptyString,
133 if( openFileDialog.ShowModal() == wxID_CANCEL )
136 filename = openFileDialog.GetPath();
140 msg.Printf(
_(
"Unable to load %s file" ), filename );
147 msg.Printf(
_(
"File \"%s\" inserted" ), filename );
148 SetStatusText( msg );
155 wxFileDialog openFileDialog(
this,
_(
"Open" ), wxEmptyString, wxEmptyString,
158 if( openFileDialog.ShowModal() == wxID_CANCEL )
161 filename = openFileDialog.GetPath();
165 msg.Printf(
_(
"Unable to load %s file" ), filename );
171 msg.Printf(
_(
"File \"%s\" saved." ), filename );
172 SetStatusText( msg );
180 msg.Printf(
_(
"Unable to write '%s'." ), filename );
185 msg.Printf(
_(
"File '%s' saved."), filename );
186 SetStatusText( msg );
193 wxFileDialog openFileDialog(
this,
_(
"Save As" ), dir, wxEmptyString,
195 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
197 if( openFileDialog.ShowModal() == wxID_CANCEL )
200 filename = openFileDialog.GetPath();
205 wxFileName fn(filename);
212 msg.Printf(
_(
"Failed to create file '%s'." ), filename );
218 msg.Printf(
_(
"File \"%s\" saved."), filename );
219 SetStatusText( msg );
235 if( wxFileExists( aFullFileName ) )
251 wxFileName fn = aFullFileName;
259 "It will be converted to the new format when saved." ),
263 if( fn.FileExists() && !fn.IsFileWritable() )
277 if( wxFileExists( aFullFileName ) )
279 const bool append =
true;
291 if( !aFullFileName.IsEmpty() )
293 wxStandardPaths& paths = wxStandardPaths::Get();
294 wxString tempFile = wxFileName::CreateTempFileName(
295 paths.GetTempDir() + wxFileName::GetPathSeparator() + wxT(
"pledit" ) );
304 wxRemoveFile( tempFile);
309 if( !wxRenameFile( tempFile, aFullFileName ) )
void OnFileHistory(wxCommandEvent &event)
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
void ClearList()
Erase the list of items.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Handle the graphic items list to draw/plot the frame and title block.
void HardRedraw() override
Refresh the library tree and redraw the window.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool SaveDrawingSheetFile(const wxString &aFullFileName)
Save the current layout in a .kicad_wks drawing sheet file.
void Save(const wxString &aFullFileName)
Save the description in a file.
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool InsertDrawingSheetFile(const wxString &aFullFileName)
Load a .kicad_wks drawing sheet file, and add items to the current layout list.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
wxString GetCurrentFileName() const override
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
bool saveCurrentPageLayout()
bool IsContentModified() const override
Get if the drawing sheet has been modified but not saved.
Definition of file extensions used in Kicad.
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
void SetContentModified(bool aModified=true)
void SetCurrentFileName(const wxString &aName)
Store the current layout description file filename.
const std::string DrawingSheetFileExtension
bool LoadDrawingSheet(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
OUTDATED_SAVE Messages that should be cleared on save.
void OnNewDrawingSheet()
Must be called to initialize parameters when a new drawing sheet is loaded.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
wxString DrawingSheetFileWildcard()
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool LoadDrawingSheetFile(const wxString &aFullFileName)
Load a .kicad_wks drawing sheet file.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
void Files_io(wxCommandEvent &event)