--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbwxButtonSelectFilesDirectory.h"
+#include "bbwxPackage.h"
+
+#include <wx/filedlg.h>
+#include <wx/dirdlg.h>
+
+
+namespace bbwx
+{
+
+
+ //--------------------------------------------------------------------------
+ class ButtonSelectFilesDirectoryWidget : public wxPanel
+ {
+ public:
+ ButtonSelectFilesDirectoryWidget(ButtonSelectFilesDirectory* box, wxWindow *parent,
+ wxString title);
+ ~ButtonSelectFilesDirectoryWidget();
+ void OnButton( wxEvent& );
+ void SetLabel(wxString title);
+ void SetColour(wxColour color);
+
+ private:
+ void SelectDirectory();
+ void SelectFiles();
+
+ ButtonSelectFilesDirectory *mBox;
+ wxButton *mwxButton;
+ };
+
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+
+ ButtonSelectFilesDirectoryWidget::ButtonSelectFilesDirectoryWidget(ButtonSelectFilesDirectory* box,
+ wxWindow *parent,
+ wxString title )
+ : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
+ mBox(box)
+ {
+ wxPanel *panel = this;
+ mwxButton = new wxButton( panel, -1, title);
+ Connect( mwxButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED ,
+ (wxObjectEventFunction)
+ (void (wxPanel::*)(wxEvent&))
+ &ButtonSelectFilesDirectoryWidget::OnButton );
+ wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
+ sizer -> Add( mwxButton,1,wxGROW | wxALL,10 );
+ sizer -> AddGrowableCol(0);
+ panel -> SetSizer(sizer);
+ panel -> SetAutoLayout(true);
+ panel -> Layout();
+ }
+
+ ButtonSelectFilesDirectoryWidget::~ButtonSelectFilesDirectoryWidget()
+ {
+ }
+
+
+ void ButtonSelectFilesDirectoryWidget::SelectFiles( )
+ {
+
+ long style;
+ if (mBox->bbGetInputOpenSave()=="Save")
+ {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+ style = wxSAVE | wxOVERWRITE_PROMPT;
+#else
+ style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
+#endif
+ } else {
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
+ style = wxOPEN | wxFILE_MUST_EXIST;
+#else
+ style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
+#endif
+ }
+
+ std::string wc(mBox->bbGetInputWildcard());
+ if (wc=="")
+ {
+ wc = "*"; // Any file must be shown
+ }
+
+ wxFileDialog* FD = new wxFileDialog( 0,
+ bbtk::std2wx(mBox->bbGetInputMessage()),
+ bbtk::std2wx(mBox->bbGetInputDefaultDir()),
+ bbtk::std2wx(mBox->bbGetInputDefaultFile()),
+ bbtk::std2wx(wc),
+ style,
+ wxDefaultPosition);
+//EED
+
+ int result_FD = FD->ShowModal();
+
+ // This line is need it by windows //EED
+ FD->SetReturnCode( result_FD );
+
+ if (FD->GetReturnCode()==wxID_OK)
+ {
+ mBox->bbSetOutputOut( bbtk::wx2std (FD->GetPath()) );
+ mBox->bbSignalOutputModification(std::string("Out"));
+ } else {
+ mBox->bbSetOutputOut(" ");
+ mBox->bbSignalOutputModification(std::string("Out"));
+ }
+ }
+
+void ButtonSelectFilesDirectoryWidget:: SelectDirectory()
+{
+ wxDirDialog* FD = new wxDirDialog( 0,
+ bbtk::std2wx(mBox->bbGetInputMessage()),
+ bbtk::std2wx(mBox->bbGetInputDefaultDir()));
+
+ if (FD->ShowModal()==wxID_OK)
+ {
+ mBox->bbSetOutputOut( bbtk::wx2std (FD->GetPath()) );
+ mBox->bbSignalOutputModification(std::string("Out"));
+ mBox->bbSetInputDefaultDir( bbtk::wx2std (FD->GetPath()) );
+ } else {
+ mBox->bbSetOutputOut("");
+ mBox->bbSignalOutputModification(std::string("Out"));
+ mBox->bbSetInputDefaultDir("");
+ }
+
+}
+
+void ButtonSelectFilesDirectoryWidget::OnButton( wxEvent& )
+{
+ printf("EED ButtonSelectFilesDirectoryWidget::OnButton Start\n");
+ if (mBox->bbGetInputType()==0)
+ {
+ SelectFiles();
+ } else if (mBox->bbGetInputType()==1){
+ SelectDirectory();
+ }
+
+ printf("EED ButtonSelectFilesDirectoryWidget::OnButton End\n");
+
+}
+
+ //--------------------------------------------------------------------------
+ void ButtonSelectFilesDirectoryWidget::SetLabel(wxString title)
+ {
+ mwxButton->SetLabel(title);
+ }
+
+
+
+
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ButtonSelectFilesDirectory)
+BBTK_BLACK_BOX_IMPLEMENTATION(ButtonSelectFilesDirectory,bbtk::WxBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ButtonSelectFilesDirectory::Process()
+{
+
+ ButtonSelectFilesDirectoryWidget* w = (ButtonSelectFilesDirectoryWidget*)bbGetOutputWidget();
+ if (w)
+ {
+ UpdateLabel();
+ }
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ButtonSelectFilesDirectory::CreateWidget(wxWindow* parent)
+{
+
+ bbSetOutputWidget
+ ( new ButtonSelectFilesDirectoryWidget ( this, //bbGetWxParent(),
+ parent,
+ bbtk::std2wx(bbGetInputLabel()) ) );
+
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ButtonSelectFilesDirectory::bbUserSetDefaultValues()
+{
+ bbSetInputType(0);
+ bbSetInputOpenSave("Open");
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ButtonSelectFilesDirectory::bbUserInitializeProcessing()
+{
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void ButtonSelectFilesDirectory::bbUserFinalizeProcessing()
+{
+
+}
+
+void ButtonSelectFilesDirectory::UpdateLabel()
+{
+ ButtonSelectFilesDirectoryWidget* wxwidget = (ButtonSelectFilesDirectoryWidget*)bbGetOutputWidget();
+ wxwidget->SetLabel( bbtk::std2wx( bbGetInputLabel() ) );
+}
+
+
+
+}// EO namespace bbwx
+
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifdef _USE_WXWIDGETS_
+#ifndef __bbwxButtonSelectFilesDirectory_h_INCLUDED__
+#define __bbwxButtonSelectFilesDirectory_h_INCLUDED__
+
+#include "bbwx_EXPORT.h"
+#include "bbtkWxBlackBox.h"
+
+namespace bbwx
+{
+
+class bbwx_EXPORT ButtonSelectFilesDirectory
+ :
+ public bbtk::WxBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(ButtonSelectFilesDirectory,bbtk::WxBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ friend class ButtonSelectFilesDirectoryWidget;
+
+ BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_INPUT(Label,std::string);
+ BBTK_DECLARE_INPUT(Wildcard,std::string);
+ BBTK_DECLARE_INPUT(OpenSave,std::string);
+ BBTK_DECLARE_INPUT(Title,std::string);
+ BBTK_DECLARE_INPUT(Message,std::string);
+ BBTK_DECLARE_INPUT(DefaultDir,std::string);
+ BBTK_DECLARE_INPUT(DefaultFile,std::string);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_PROCESS(Process);
+ void Process();
+ BBTK_CREATE_WIDGET(CreateWidget);
+ void CreateWidget(wxWindow*);
+
+ protected:
+
+
+ private:
+ void UpdateLabel();
+
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ButtonSelectFilesDirectory,bbtk::WxBlackBox);
+ BBTK_NAME("ButtonSelectFilesDirectory");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("__CategoryBlackBox__");
+ BBTK_INPUT(ButtonSelectFilesDirectory,Type,"(default 0) 0:Files 1:Directory",int,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,Label,"Label",std::string,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,Wildcard,"A wildcard, such as \"*.*\" or \"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif\"",std::string,"wildcard");
+ BBTK_INPUT(ButtonSelectFilesDirectory,OpenSave,"(Just for Type 0 -Files ) Open for an open dialog (default) / Save for a save dialog",std::string,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,Title,"Title of the dialog",std::string,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,Message,"Message to show on the dialog",std::string,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,DefaultDir,"The default directory",std::string,"");
+ BBTK_INPUT(ButtonSelectFilesDirectory,DefaultFile,"The default filename",std::string,"file name");
+
+ BBTK_OUTPUT(ButtonSelectFilesDirectory,Out,"File/Directory string",std::string,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ButtonSelectFilesDirectory);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+}
+// EO namespace bbwx
+
+#endif // __bbwxButtonSelectFilesDirectory_h_INCLUDED__
+#endif // _USE_WXWIDGETS_
+