Ejemplo n.º 1
0
void SpectraMainFrame::DoOpenDocument(wxCommandEvent&)
{
	wxString doc_path = wxLoadFileSelector(
		wxGetTranslation(wxT("Select file to load"), wxT("Dialog")),
		wxT(".wav"),
		(const wxChar*)0,
		this
	); // TODO a customized dialog
	try
	{
		StartCoroutine(
			std::make_shared<SpectraMainFrameDocumentLoader>(
				this,
				SpectraLoadDocFromFile(doc_path)
			),
			false
		);
	}
	catch(oglplus::MissingFunction& mfe) { parent_app.HandleError(mfe); }
	catch(oglplus::ProgramBuildError& pbe) { parent_app.HandleError(pbe); }
	catch(oglplus::LimitError& le) { parent_app.HandleError(le); }
	catch(oglplus::OutOfMemory& oom) { parent_app.HandleError(oom); }
	catch(oglplus::Error& err) { parent_app.HandleError(err); }
	catch(const std::exception& se) { parent_app.HandleError(se); }
}
Ejemplo n.º 2
0
void wxPicToolFrame::OnbtnPicClick(wxCommandEvent& event)
{
    wxString fn = wxLoadFileSelector("", "pic");
    if (!fn.size())
        return;
    txtPic->SetValue(fn);
}
Ejemplo n.º 3
0
void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
{
#if wxUSE_FILEDLG
    wxString filename = wxLoadFileSelector(wxT("image"), wxEmptyString, wxEmptyString, this);
    if ( filename.empty() )
        return;

    static const int THUMBNAIL_WIDTH = 320;
    static const int THUMBNAIL_HEIGHT = 240;

    wxImage image;
    image.SetOption(wxIMAGE_OPTION_MAX_WIDTH, THUMBNAIL_WIDTH);
    image.SetOption(wxIMAGE_OPTION_MAX_HEIGHT, THUMBNAIL_HEIGHT);

    wxStopWatch sw;
    if ( !image.LoadFile(filename) )
    {
        wxLogError(wxT("Couldn't load image from '%s'."), filename.c_str());
        return;
    }

    int origWidth = image.GetOptionInt( wxIMAGE_OPTION_ORIGINAL_WIDTH );
    int origHeight = image.GetOptionInt( wxIMAGE_OPTION_ORIGINAL_HEIGHT );

    const long loadTime = sw.Time();

    MyImageFrame * const frame = new MyImageFrame(this, filename, image);
    wxLogStatus(frame, "Loaded \"%s\" in %ldms; original size was (%d, %d)",
                filename, loadTime, origWidth, origHeight);
#else
    wxLogError( wxT("Couldn't create file selector dialog") );
    return;
#endif // wxUSE_FILEDLG
}
Ejemplo n.º 4
0
void PathBehaviorEditor::OnBitmapButton6Click(wxCommandEvent& event)
{
    if(ToggleButton1->GetValue())
    {
        wxString filename = wxLoadFileSelector(_("Choose an image to be displayed"), "Images (*.png;*.jpg)|*.png;*.jpg");

        if(!filename.empty())
        {
            if(previewPnlState.backgroundBitmap != NULL)
                delete previewPnlState.backgroundBitmap;

            previewPnlState.backgroundBitmap = new wxBitmap(filename, wxBITMAP_TYPE_ANY);

            bgImgXSpin->Enable(true);
            bgImgYSpin->Enable(true);
        }
        else
        {
            ToggleButton1->SetValue(false);
        }
    }
    else
    {
        if(previewPnlState.backgroundBitmap != NULL)
            delete previewPnlState.backgroundBitmap;

        previewPnlState.backgroundBitmap = NULL;

        bgImgXSpin->Enable(false);
        bgImgYSpin->Enable(false);
    }

    previewPnl->Refresh();
    previewPnl->Update();
}
Ejemplo n.º 5
0
// Ask for filename to load
extern "C" WXEXPORT
wxString* wxLoadFileSelector_func(wxc_string what,
                   wxc_string extension,
                   wxc_string default_name,
                   wxWindow *parent)
{
	return new wxString(wxLoadFileSelector(wxstr(what),
	    wxstr(extension),
	    wxstr(default_name),
	    parent));
}
Ejemplo n.º 6
0
wxString MyFrame::LoadUserImage(wxImage& image)
{
    wxString filename;

#if wxUSE_FILEDLG
    filename = wxLoadFileSelector(wxT("image"), wxEmptyString);
    if ( !filename.empty() )
    {
        if ( !image.LoadFile(filename) )
        {
            wxLogError(wxT("Couldn't load image from '%s'."), filename.c_str());

            return wxEmptyString;
        }
    }
#endif // wxUSE_FILEDLG

    return filename;
}