//Build issues on ubuntu prior to cross porting
Code: Select all
cmake -DCMAKE_C_FLAGS="-fPIC" \
-DCMAKE_CXX_FLAGS="-fPIC" \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_EXPORT_COMPILE_COMMANDS="1" \
-DwxBUILD_PRECOMP="0" \
-DwxUSE_EXPAT="OFF" \ //On = does not build on MacOS or Linux
-DwxUSE_REGEX="builtin" \
-DwxUSE_ZLIB="builtin" \
-DwxUSE_LIBJPEG="builtin" \
-DwxUSE_LIBPNG="builtin" \
-DwxUSE_LIBTIFF="OFF" \ //On = does not build on MacOS or Linux after last weeks pull
-DwxUSE_LIBLZMA="OFF" \ //On =does not build on MacOS
-DwxBUILD_SAMPLES="SOME" \
-DwxBUILD_SHARED="0" \ //for the sake of porting, but will revert to native package .so for legacy testing
.
//if I missed something obvious, than I would welcome any feedback.
Code: Select all
...
strFilePaths = new wxArrayString(); //copy to public var in class
strFilePaths->Alloc(50);
strFilePaths->Add(wxT("empty!"));
wxString list_image_choices[] = {
_("drop files here..."),
};
image_scan = new wxListBox(feel_my_pane, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, list_image_choices, wxLB_ALWAYS_SB|wxLB_SINGLE|wxLB_SORT);
//in wxFrame
this->DragAcceptFiles(true);
this->SetDropTarget(new DnDFile(image_scan, strFilePaths)); //may or may not bind the frame under GTK2.0
...
class DnDFile : public wxFileDropTarget
{
public:
DnDFile(wxListBox *pOwner = NULL, wxArrayString *strOwner = NULL) {
m_pOwner = pOwner; *strOwner;
};
virtual bool OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) wxOVERRIDE;
private:
wxListBox *m_pOwner;
wxArrayString *str_pOwner;
};
bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
{
std::cout << "\n DnDFile::OnDropFiles \n" << std::endl;
wxArrayString filenameTotal(filenames);
wxFileName parseFileName;
static wxSortedArrayString fileExtFilter;
if ( fileExtFilter.empty() )
{
fileExtFilter.push_back(wxS("jpeg")); //supported media files
fileExtFilter.push_back(wxS("jpg"));
fileExtFilter.push_back(wxS("png"));
fileExtFilter.push_back(wxS("gif"));
fileExtFilter.push_back(wxS("svg"));
}
if((m_pOwner != NULL) && (str_pOwner != NULL) )
{
if((str_pOwner->GetCount() <= 0) || (str_pOwner->GetCount() > m_pOwner->GetCount() ) ) //empty defunt list?
{
m_pOwner->Clear();
str_pOwner->Empty();
//str_pOwner->Clear();
}
for ( size_t n = 0; n < filenameTotal.GetCount(); n++ )
{
parseFileName.Assign(filenameTotal[n]);
if( ( fileExtFilter.Index(parseFileName.GetExt().MakeLower()) != wxNOT_FOUND ) && //check file type ext
(wxFileExists(filenameTotal[n])) &&
( str_pOwner->Index(filenameTotal[n], true, false) == wxNOT_FOUND ) //remove dupes, bug: wxArrayString->Index needs all params to work
)
{
std::cout << "\n ========== Add; " << filenameTotal[n] << std::endl;
//m_pOwner->Insert((filenameTotal[n]), m_pOwner->GetCount()); // bug: wxArrayString* ptr Segmentation fault
//str_pOwner->Add((filenameTotal[n])); // bug: wxListBox* ptr Segmentation fault
m_pOwner->Append(parseFileName.GetName().MakeLower() + "." + parseFileName.GetExt().MakeLower()); //sometimes seg falts on repeated adds
str_pOwner->Insert((filenameTotal[n]), str_pOwner->GetCount());
}else{
//recurse into sub-dirs?
if (wxDirExists(filenameTotal[n]))
{
wxDir dir(filenameTotal[n]);
if(dir.IsOpened())
{
dir.GetAllFiles(filenameTotal[n], &filenameTotal,wxALL_FILES_PATTERN, wxDIR_FILES|wxDIR_DIRS);
}
}
}
}
std::cout << "\n Probed filenameTotal.GetCount(); \n" << filenameTotal.GetCount() << std::endl;
std::cout << "\n ADDED str_pOwner->GetCount \n" << str_pOwner->GetCount() << std::endl;
for ( size_t n = 0; n < str_pOwner->GetCount(); n++ )
{
std::cout << str_pOwner->Item(n) << std::endl;
}
}
std::cout << "\n ==================== " << std::endl;
return true;
}