41#include <wx/filedlg.h>
42#include <wx/filename.h>
43#include <wx/stdpaths.h>
47 wxCommandEvent saveEvent;
48 saveEvent.SetId( wxID_SAVE );
61 if( filename != wxEmptyString )
76 ::wxSetWorkingDirectory( ::wxPathOnly( filename ) );
81 msg.Printf(
_(
"File \"%s\" loaded"), filename );
100 int id =
event.GetId();
104 if( filename.IsEmpty() &&
id == wxID_SAVE )
131 wxFileDialog openFileDialog(
this,
_(
"Append Existing Drawing Sheet" ),
132 wxEmptyString, wxEmptyString,
135 if( openFileDialog.ShowModal() == wxID_CANCEL )
138 filename = openFileDialog.GetPath();
142 msg.Printf(
_(
"Unable to load %s file" ), filename );
149 msg.Printf(
_(
"File \"%s\" inserted" ), filename );
150 SetStatusText( msg );
157 wxFileDialog openFileDialog(
this,
_(
"Open Drawing Sheet" ), wxEmptyString, wxEmptyString,
160 if( openFileDialog.ShowModal() == wxID_CANCEL )
163 filename = openFileDialog.GetPath();
167 msg.Printf(
_(
"Unable to load %s file" ), filename );
173 msg.Printf(
_(
"File \"%s\" saved." ), filename );
174 SetStatusText( msg );
182 msg.Printf(
_(
"Unable to write '%s'." ), filename );
187 msg.Printf(
_(
"File '%s' saved."), filename );
188 SetStatusText( msg );
195 wxFileDialog openFileDialog(
this,
_(
"Save Drawing Sheet As" ), dir, wxEmptyString,
197 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
199 if( openFileDialog.ShowModal() == wxID_CANCEL )
202 filename = openFileDialog.GetPath();
207 wxFileName fn(filename);
214 msg.Printf(
_(
"Failed to create file '%s'." ), filename );
219 msg.Printf(
_(
"File '%s' saved." ), filename );
220 SetStatusText( msg );
236 if( wxFileExists( aFullFileName ) )
243 wxString::Format(
_(
"Error loading drawing sheet '%s'." ),
253 wxFileName fn = aFullFileName;
261 "It will be converted to the new format when saved." ),
265 if( fn.FileExists() && !fn.IsFileWritable() )
282 if( wxFileExists( aFullFileName ) )
284 const bool append =
true;
296 if( !aFullFileName.IsEmpty() )
298 wxString tempFile = wxFileName::CreateTempFileName(
"pledit" );
307 wxRemoveFile( tempFile);
315 if( !wxRenameFile( tempFile, aFullFileName ) )
void SetContentModified(bool aModified=true)
Handle the graphic items list to draw/plot the frame and title block.
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
void ClearList()
Erase the list of items.
void Save(const wxString &aFullFileName)
Save the description in a file.
std::vector< wxFileName > m_AcceptedFiles
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.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
void OnNewDrawingSheet()
Must be called to initialize parameters when a new drawing sheet is loaded.
void SetCurrentFileName(const wxString &aName)
Store the current layout description file filename.
bool IsContentModified() const override
Get if the drawing sheet has been modified but not saved.
void Files_io(wxCommandEvent &event)
bool saveCurrentPageLayout()
void OnClearFileHistory(wxCommandEvent &aEvent)
wxString GetCurrentFileName() const override
void OnFileHistory(wxCommandEvent &event)
void DoWithAcceptedFiles() override
Execute action on accepted dropped file.
void UpdateTitleAndInfo()
Display the short filename (if exists) loaded file on the caption of the main window.
bool SaveDrawingSheetFile(const wxString &aFullFileName)
Save the current layout in a .kicad_wks drawing sheet file.
bool InsertDrawingSheetFile(const wxString &aFullFileName)
Load a .kicad_wks drawing sheet file, and add items to the current layout list.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void HardRedraw() override
Refresh the library tree and redraw the window.
bool LoadDrawingSheetFile(const wxString &aFullFileName)
Load a .kicad_wks drawing sheet file.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
@ OUTDATED_SAVE
OUTDATED_SAVE Messages that should be cleared on save.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
MESSAGE_TYPE GetMessageType() const
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
static const std::string DrawingSheetFileExtension
static wxString DrawingSheetFileWildcard()
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition of file extensions used in Kicad.