kosenko / ui

Boost.UI library
272 stars 20 forks source link

FileDialog #2

Closed tolstenko closed 6 years ago

tolstenko commented 6 years ago

Could you please provide some example using FileDialog? I couldn find the implementation in your code.

kosenko commented 6 years ago

File dialogs aren't implemented yet. But you can use native API, see native example.

For example:

#include <boost/ui.hpp>
#include <wx/wx.h>
#include <boost/ui/native/all.hpp>

namespace ui = boost::ui;

int ui_main()
{
    ui::dialog dlg("Test dialog");

    ui::button(dlg, "Press me")
        .on_press([&]
        {
            wxFileDialog  openFileDialog(ui::native::from_widget(dlg),
                                         _("Open XYZ file"), "", "",
                                         "XYZ files (*.xyz)|*.xyz|All files|*.*",
                                         wxFD_OPEN|wxFD_FILE_MUST_EXIST);
            if (openFileDialog.ShowModal() == wxID_CANCEL)
                return;

            ui::info_dialog( ui::native::to_uistring(openFileDialog.GetPath()) );
        });

    dlg.show_modal();

    return 0;
}

int main(int argc, char* argv[])
{
    return ui::entry(&ui_main, argc, argv);
}
tolstenko commented 6 years ago

Cool! Thanks!

kosenko commented 6 years ago

I have added boost::ui::prompt_filename() and boost::ui::prompt_directory() for file dialogs.