<commit_before>// xyconvert - GUI to xylib
// Licence: Lesser GNU Public License 2.1 (LGPL)

#include <wx/wx.h>
#include <wx/aboutdlg.h>
#include <wx/cmdline.h>
#include <wx/filefn.h>
#include <wx/ffile.h>
#include <wx/filepicker.h>
#include <wx/settings.h>
#include <wx/infobar.h>
#include "xyconvert16.xpm"
#include "xyconvert48.xpm"
#include "xybrowser.h"

using namespace std;

class App : public wxApp
{
public:
    bool OnInit();
    void OnAbout(wxCommandEvent&);
    void OnConvert(wxCommandEvent&);
    void OnClose(wxCommandEvent&) { GetTopWindow()->Close(); }
    void OnDirCheckBox(wxCommandEvent&);
    void OnFolderChanged(wxFileCtrlEvent& event);
private:
    wxCheckBox *dir_cb, *overwrite, *header;
    wxDirPickerCtrl *dirpicker;
    XyFileBrowser *browser;
    wxTextCtrl *ext_tc;
    wxInfoBar *info_bar;
};

DECLARE_APP(App)
IMPLEMENT_APP(App)


static const wxCmdLineEntryDesc cmdLineDesc[] = {
    { wxCMD_LINE_SWITCH, "V", "version",
          "output version information and exit", wxCMD_LINE_VAL_NONE, 0 },
    { wxCMD_LINE_PARAM,  0, 0, "default-path", wxCMD_LINE_VAL_STRING,
                                                wxCMD_LINE_PARAM_OPTIONAL},
    { wxCMD_LINE_NONE, 0, 0, 0,  wxCMD_LINE_VAL_NONE, 0 }
};


bool App::OnInit()
{
    // to make life simpler, use the same version number as xylib
    wxString version = xylib_get_version();

    // reading numbers won't work with decimal points different than '.'
    setlocale(LC_NUMERIC, "C");

    SetAppName("xyConvert");
    wxCmdLineParser cmdLineParser(cmdLineDesc, argc, argv);
    if (cmdLineParser.Parse(false) != 0) {
        cmdLineParser.Usage();
        return false;
    }
    if (cmdLineParser.Found(wxT("V"))) {
        wxMessageOutput::Get()->Printf("xyConvert, powered by xylib "
                                       + version + "\n");
        return false;
    }

    wxFrame *frame = new wxFrame(NULL, wxID_ANY, "xyConvert");

#ifdef __WXOSX__
    wxMenu* dummy_menu = new wxMenu;
    dummy_menu->Append(wxID_ABOUT, "&About xyConvert");
    dummy_menu->Append(wxID_EXIT, "");
    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(dummy_menu, " ");
    frame->SetMenuBar(menuBar);
    Connect(wxID_ABOUT, wxEVT_MENU, wxCommandEventHandler(App::OnAbout));
#endif
<commit_msg>gui/xyconvert.cpp: fix for OSX<commit_after>// xyconvert - GUI to xylib
// Licence: Lesser GNU Public License 2.1 (LGPL)

#include <wx/wx.h>
#include <wx/aboutdlg.h>
#include <wx/cmdline.h>
#include <wx/filefn.h>
#include <wx/ffile.h>
#include <wx/filepicker.h>
#include <wx/settings.h>
#include <wx/infobar.h>
#include "xyconvert16.xpm"
#include "xyconvert48.xpm"
#include "xybrowser.h"

using namespace std;

class App : public wxApp
{
public:
    bool OnInit();
    void OnAbout(wxCommandEvent&);
    void OnConvert(wxCommandEvent&);
    void OnClose(wxCommandEvent&) { GetTopWindow()->Close(); }
    void OnDirCheckBox(wxCommandEvent&);
    void OnFolderChanged(wxFileCtrlEvent& event);
private:
    wxCheckBox *dir_cb, *overwrite, *header;
    wxDirPickerCtrl *dirpicker;
    XyFileBrowser *browser;
    wxTextCtrl *ext_tc;
    wxInfoBar *info_bar;
};

DECLARE_APP(App)
IMPLEMENT_APP(App)


static const wxCmdLineEntryDesc cmdLineDesc[] = {
    { wxCMD_LINE_SWITCH, "V", "version",
          "output version information and exit", wxCMD_LINE_VAL_NONE, 0 },
    { wxCMD_LINE_PARAM,  0, 0, "default-path", wxCMD_LINE_VAL_STRING,
                                                wxCMD_LINE_PARAM_OPTIONAL},
    { wxCMD_LINE_NONE, 0, 0, 0,  wxCMD_LINE_VAL_NONE, 0 }
};


bool App::OnInit()
{
    // to make life simpler, use the same version number as xylib
    wxString version = xylib_get_version();

    // reading numbers won't work with decimal points different than '.'
    setlocale(LC_NUMERIC, "C");

    SetAppName("xyConvert");
    wxCmdLineParser cmdLineParser(cmdLineDesc, argc, argv);
    if (cmdLineParser.Parse(false) != 0) {
        cmdLineParser.Usage();
        return false;
    }
    if (cmdLineParser.Found(wxT("V"))) {
        wxMessageOutput::Get()->Printf("xyConvert, powered by xylib "
                                       + version + "\n");
        return false;
    }
    //wxInitAllImageHandlers();
#ifdef __WXOSX__
    // wxInfoBar uses close_png in wxRendererMac::DrawTitleBarBitmap()
    wxImage::AddHandler(new wxPNGHandler);
#endif

    wxFrame *frame = new wxFrame(NULL, wxID_ANY, "xyConvert");

#ifdef __WXOSX__
    wxMenu* dummy_menu = new wxMenu;
    dummy_menu->Append(wxID_ABOUT, "&About xyConvert");
    dummy_menu->Append(wxID_EXIT, "");
    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(dummy_menu, " ");
    frame->SetMenuBar(menuBar);
    Connect(wxID_ABOUT, wxEVT_MENU, wxCommandEventHandler(App::OnAbout));
#endif

{'fraction_non_alphanumeric': 0.12749422390254148, 'fraction_numerical': 0.0058811174123083385, 'mean_word_length': 3.458801498127341, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3258742', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1620, 'n_words': 356}