From 5156a1c119acc564baea2c1b41ef7542640c5581 Mon Sep 17 00:00:00 2001 From: jerryjacobs Date: Sun, 12 Jul 2009 18:27:30 +0000 Subject: [PATCH] Added load error dialog. To display file load errors in a wxTextCtrl with a message, this is the BUG 2802441 enhancement --- common/CMakeLists.txt | 2 + common/dialog_load_error.cpp | 32 +++ common/dialog_load_error.h | 26 +++ common/dialog_load_error_base.cpp | 59 ++++++ common/dialog_load_error_base.fbp | 272 ++++++++++++++++++++++++++ common/dialog_load_error_base.h | 49 +++++ cvpcb/listlib.cpp | 28 +-- eeschema/eelibs_read_libraryfiles.cpp | 9 +- include/common.h | 3 + 9 files changed, 465 insertions(+), 15 deletions(-) create mode 100644 common/dialog_load_error.cpp create mode 100644 common/dialog_load_error.h create mode 100644 common/dialog_load_error_base.cpp create mode 100644 common/dialog_load_error_base.fbp create mode 100644 common/dialog_load_error_base.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 31adcaec67..c32e886f26 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -23,6 +23,8 @@ set(COMMON_SRCS confirm.cpp copy_to_clipboard.cpp dialog_display_info_HTML_base.cpp + dialog_load_error.cpp + dialog_load_error_base.cpp dcsvg.cpp displlst.cpp dlist.cpp diff --git a/common/dialog_load_error.cpp b/common/dialog_load_error.cpp new file mode 100644 index 0000000000..1a1c82be8d --- /dev/null +++ b/common/dialog_load_error.cpp @@ -0,0 +1,32 @@ +#include "dialog_load_error.h" + +DIALOG_LOAD_ERROR::DIALOG_LOAD_ERROR( wxWindow* parent ) +: +DIALOG_LOAD_ERROR_BASE( parent ) +{ + +} + +void DIALOG_LOAD_ERROR::OnOkClick( wxCommandEvent& event ) +{ + Destroy(); +} + + +void DIALOG_LOAD_ERROR::ListClear(void) +{ + TextCtrlList->Clear(); +} + +void DIALOG_LOAD_ERROR::ListSet(wxString *list) +{ + wxString list_value = *list; + TextCtrlList->SetValue(list_value); +} + +void DIALOG_LOAD_ERROR::MessageSet(wxString *message) +{ + wxString message_value = *message; + StaticTextMessage->SetLabel(message_value); +} + diff --git a/common/dialog_load_error.h b/common/dialog_load_error.h new file mode 100644 index 0000000000..63a1795998 --- /dev/null +++ b/common/dialog_load_error.h @@ -0,0 +1,26 @@ +#ifndef __dialog_load_error__ +#define __dialog_load_error__ + +/** +@file +Subclass of DIALOG_LOAD_ERROR_BASE, which is generated by wxFormBuilder. +*/ + +#include "dialog_load_error_base.h" + +/** Implementing DIALOG_LOAD_ERROR_BASE */ +class DIALOG_LOAD_ERROR : public DIALOG_LOAD_ERROR_BASE +{ +protected: + // Handlers for DIALOG_LOAD_ERROR_BASE events. + void OnOkClick( wxCommandEvent& event ); + +public: + /** Constructor */ + DIALOG_LOAD_ERROR( wxWindow* parent ); + void ListSet(wxString *list); + void ListClear(); + void MessageSet(wxString *message); +}; + +#endif // __dialog_load_error__ diff --git a/common/dialog_load_error_base.cpp b/common/dialog_load_error_base.cpp new file mode 100644 index 0000000000..fd611ce60c --- /dev/null +++ b/common/dialog_load_error_base.cpp @@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Dec 19 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_load_error_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_LOAD_ERROR_BASE::DIALOG_LOAD_ERROR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxSize( 320,240 ), wxDefaultSize ); + + wxBoxSizer* MainSizer; + MainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* MessageSizer; + MessageSizer = new wxBoxSizer( wxVERTICAL ); + + StaticTextMessage = new wxStaticText( this, wxID_ANY, _("message dummy"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); + StaticTextMessage->Wrap( -1 ); + MessageSizer->Add( StaticTextMessage, 0, wxALIGN_LEFT|wxALIGN_TOP|wxALL|wxEXPAND, 5 ); + + MainSizer->Add( MessageSizer, 0, wxALIGN_BOTTOM|wxALIGN_LEFT|wxALIGN_RIGHT|wxALIGN_TOP|wxEXPAND, 5 ); + + wxBoxSizer* ListSizer; + ListSizer = new wxBoxSizer( wxVERTICAL ); + + TextCtrlList = new wxTextCtrl( this, wxID_ANY, _("list dummy"), wxPoint( 0,0 ), wxSize( -1,-1 ), wxTE_DONTWRAP|wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxNO_BORDER|wxVSCROLL ); + ListSizer->Add( TextCtrlList, 1, wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxEXPAND|wxALL, 5 ); + + MainSizer->Add( ListSizer, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); + + OkButton = new wxButton( this, wxID_ANY, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 ); + OkButton->SetDefault(); + bSizer5->Add( OkButton, 0, wxALIGN_RIGHT|wxALL, 5 ); + + MainSizer->Add( bSizer5, 0, wxEXPAND, 5 ); + + this->SetSizer( MainSizer ); + this->Layout(); + MainSizer->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + OkButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOAD_ERROR_BASE::OnOkClick ), NULL, this ); +} + +DIALOG_LOAD_ERROR_BASE::~DIALOG_LOAD_ERROR_BASE() +{ + // Disconnect Events + OkButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOAD_ERROR_BASE::OnOkClick ), NULL, this ); +} diff --git a/common/dialog_load_error_base.fbp b/common/dialog_load_error_base.fbp new file mode 100644 index 0000000000..f7d3e12374 --- /dev/null +++ b/common/dialog_load_error_base.fbp @@ -0,0 +1,272 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_load_error_base + 1000 + none + 1 + dialog_load_error + + . + + 1 + 0 + 0 + + + wxBOTH + + 1 + + + + 0 + wxID_ANY + + 320,240 + DIALOG_LOAD_ERROR_BASE + + + wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER + + Load Error! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MainSizer + wxVERTICAL + none + + 5 + wxALIGN_BOTTOM|wxALIGN_LEFT|wxALIGN_RIGHT|wxALIGN_TOP|wxEXPAND + 0 + + + MessageSizer + wxVERTICAL + none + + 5 + wxALIGN_LEFT|wxALIGN_TOP|wxALL|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + message dummy + + + StaticTextMessage + protected + + + wxALIGN_LEFT + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + ListSizer + wxVERTICAL + none + + 5 + wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxEXPAND|wxALL + 1 + + + + 1 + + + 0 + wxID_ANY + + 0 + -1,-1 + TextCtrlList + protected + 0,0 + -1,-1 + wxTE_DONTWRAP|wxTE_MULTILINE|wxTE_READONLY + + + list dummy + + + wxHSCROLL|wxNO_BORDER|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer5 + wxVERTICAL + none + + 5 + wxALIGN_RIGHT|wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Ok + + + OkButton + protected + + + + + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialog_load_error_base.h b/common/dialog_load_error_base.h new file mode 100644 index 0000000000..bc05069053 --- /dev/null +++ b/common/dialog_load_error_base.h @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Dec 19 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_load_error_base__ +#define __dialog_load_error_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_LOAD_ERROR_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_LOAD_ERROR_BASE : public wxDialog +{ + private: + + protected: + wxStaticText* StaticTextMessage; + wxTextCtrl* TextCtrlList; + wxButton* OkButton; + + // Virtual event handlers, overide them in your derived class + virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + + + public: + DIALOG_LOAD_ERROR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Load Error!"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); + ~DIALOG_LOAD_ERROR_BASE(); + +}; + +#endif //__dialog_load_error_base__ diff --git a/cvpcb/listlib.cpp b/cvpcb/listlib.cpp index b7dfb048e4..2e8426344a 100644 --- a/cvpcb/listlib.cpp +++ b/cvpcb/listlib.cpp @@ -19,13 +19,10 @@ #include "cvpcb.h" #include "protos.h" - -/* Bla */ +/* MDC file strings */ wxString mdc_files_not_found; wxString mdc_files_invalid; - - /* routines locales : */ static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list ); @@ -141,21 +138,28 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ReadDocLib( tmp, list ); } + + + /* Display if there are mdc files not found */ - if( mdc_files_not_found != wxT("")) + if( !mdc_files_not_found.IsEmpty() ) { - wxString message = _("The following mdc files could not be found:\n\n"); - message += mdc_files_not_found; - wxMessageBox( message, _("Load error!"), wxOK | wxICON_ERROR ); + wxString message = _("Some MDC files could not be found!"); + DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); + dialog->Show(); + dialog->MessageSet(&message); + dialog->ListSet(&mdc_files_not_found); mdc_files_not_found = wxT(""); } /* Display if there are mdc files invalid */ - if( mdc_files_invalid != wxT("")) + if( !mdc_files_invalid.IsEmpty() ) { - wxString message = _("The following mdc files are invalid:\n\n"); - message += mdc_files_invalid; - wxMessageBox( message, _("Load error!"), wxOK | wxICON_ERROR ); + wxString message = _("Some MDC files are invalid!"); + DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); + dialog->Show(); + dialog->MessageSet(&message); + dialog->ListSet(&mdc_files_invalid); mdc_files_invalid = wxT(""); } diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index 15889538e8..ddf05342fc 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -166,9 +166,12 @@ void LoadLibraries( WinEDA_SchematicFrame* frame ) /* Print the libraries not found */ if( !libraries_not_found.IsEmpty() ) { - wxString message = _("The following libraries could not be found:\n\n"); - message += libraries_not_found; - wxMessageBox( message, _("Load error!"), wxOK | wxICON_ERROR, frame ); + wxString message = _("The following libraries could not be found:"); + DIALOG_LOAD_ERROR *dialog = new DIALOG_LOAD_ERROR(NULL); + dialog->Show(); + dialog->MessageSet(&message); + dialog->ListSet(&libraries_not_found); + libraries_not_found = wxT(""); } diff --git a/include/common.h b/include/common.h index e4f0cb24fb..969cfed080 100644 --- a/include/common.h +++ b/include/common.h @@ -9,6 +9,9 @@ #include "wx/confbase.h" #include "wx/fileconf.h" +/* TODO how do i else need to include a common dialog ? */ +#include "../common/dialog_load_error.h" + class wxAboutDialogInfo; class BASE_SCREEN; class WinEDA_DrawFrame;