Exemplo n.º 1
0
bool wxSTEditorTreeCtrl::Create(wxWindow *parent, wxWindowID id,
                                const wxPoint& pos, const wxSize& size,
                                long style, const wxString& name)
{
    if (!wxTreeCtrl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
        return false;

    wxImageList* imageList = new wxImageList(16, 16, true, 3);
    imageList->Add(wxArtProvider::GetBitmap(wxART_FOLDER,      wxART_MENU, wxSize(16, 16)));
    imageList->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_MENU, wxSize(16, 16)));
    imageList->Add(wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_MENU, wxSize(16, 16)));
    AssignImageList(imageList);

    m_popupMenu = new wxMenu;
    m_popupMenu->Append(ID_STT_FILE_OPEN,  wxGetStockLabelEx(wxID_OPEN), _("Open file"));
    m_popupMenu->Append(ID_STT_FILE_CLOSE, _("Close"), _("Close selected page"));
    m_popupMenu->Append(ID_STT_FILE_PROPERTIES, wxGetStockLabelEx(wxID_PROPERTIES), _("Show document properties dialog"));
    m_popupMenu->AppendSeparator();
    m_popupMenu->Append(ID_STT_EXPAND_ALL,   _("Expand all paths"),   _("Expand all paths"));
    m_popupMenu->Append(ID_STT_COLLAPSE_ALL, _("Collapse all paths"), _("Collapse all paths"));
    m_popupMenu->AppendSeparator();
    m_popupMenu->AppendRadioItem(ID_STT_SHOW_FILENAME_ONLY,      _("Show only the filename"), _("Show only the filename"));
    m_popupMenu->AppendRadioItem(ID_STT_SHOW_FILEPATH_ONLY,      _("Show only the full file path"), _("Show only the full file path"));
    m_popupMenu->AppendRadioItem(ID_STT_SHOW_PATH_THEN_FILENAME, _("Show files grouped by paths"), _("Show files grouped by paths"));
    m_popupMenu->AppendRadioItem(ID_STT_SHOW_ALL_PATHS,          _("Show all paths"), _("Show all paths"));

    m_popupMenu->Check(ID_STT_SHOW_PATH_THEN_FILENAME, true);

    return true;
}
Exemplo n.º 2
0
int wxLoadFileSelector(wxWindow* parent, wxFileName* fileName, const wxArrayString& extensions)
{
    const wxString filter = wxJoin(extensions, wxT('|'), 0);
    wxString defaultPath = GetDefaultPath(*fileName);
    wxString caption = wxGetStockLabelEx(wxID_OPEN, wxSTOCK_PLAINTEXT);
    wxFileDialog fileDialog(parent, caption, defaultPath, fileName->GetFullName(), filter, wxFD_DEFAULT_STYLE_OPEN | wxFD_CHANGE_DIR);

    if (fileDialog.ShowModal() != wxID_OK)
        return wxNOT_FOUND;
    fileName->Assign(fileDialog.GetPath());
    return fileDialog.GetFilterIndex();
}
Exemplo n.º 3
0
int wxSaveFileSelector(wxWindow* parent, wxFileName* fileName, const wxArrayString& extensions)
{
    const wxString filter = wxJoin(extensions, wxT('|'), 0);
    const wxString ext = wxString(wxT(".")) + fileName->GetExt();
    wxString defaultPath = GetDefaultPath(*fileName);
    wxString caption = wxGetStockLabelEx(wxID_SAVE, wxSTOCK_PLAINTEXT);
    wxFileDialog fileDialog(parent, caption, defaultPath, fileName->GetFullName(), filter, wxFD_DEFAULT_STYLE_SAVE | wxFD_CHANGE_DIR);

    if (!fileName->GetExt().empty())
        for (wxArrayString::const_iterator it = extensions.begin(); it != extensions.end(); it++)
            if (it->EndsWith(ext))
            {
                int index = (int)(it - extensions.begin());
                fileDialog.SetFilterIndex(index);
                break;
            }

    if (fileDialog.ShowModal() != wxID_OK)
        return wxNOT_FOUND;
    fileName->Assign(fileDialog.GetPath());
    return fileDialog.GetFilterIndex();
}
Exemplo n.º 4
0
wxSTEditorFrame* wxStEditApp::CreateMainFrame()
{
    wxSTEditorFrame* frame = new wxSTEditorFrame();

    if (!frame->Create(NULL, wxID_ANY))
    {
       wxDELETE(frame);
       return NULL;
    }

    // ------------------------------------------------------------------------
    // load the prefs/style/langs from the config, if we're using one
    if (frame->GetConfigBase())
        m_steOptions.LoadConfig(*frame->GetConfigBase());

    // must call this if you want any of the options, else blank frame
    frame->CreateOptions(m_steOptions);

    // Get the "Help" menu
    wxMenu* menu = new wxMenu; //frame->GetMenuBar()->GetMenu(frame->GetMenuBar()->GetMenuCount()-1);

    // Add our help dialogs
    menu->Append(ID_SHOW_HELP, wxGetStockLabel(wxID_HELP), wxString::Format(_("Show help on using %s"), STE_APPDISPLAYNAME));
    menu->Append(ID_SHOW_README, _("Programming help..."), wxString::Format(_("Show help on the %s library"), STE_APPDISPLAYNAME));

    // just use connect here, we could also use static event tables, but this
    //  is easy enough to do.
    frame->Connect(ID_SHOW_HELP, wxEVT_COMMAND_MENU_SELECTED,
                    wxCommandEventHandler(wxStEditApp::OnMenuEvent), NULL, this);
    frame->Connect(ID_SHOW_README, wxEVT_COMMAND_MENU_SELECTED,
                    wxCommandEventHandler(wxStEditApp::OnMenuEvent), NULL, this);
#if (wxVERSION_NUMBER >= 2900) || defined(__WXMSW__)
    menu->Append(ID_SHOW_USAGE, _("C&ommand line usage..."), _("Show command line help"));
    frame->Connect(ID_SHOW_USAGE, wxEVT_COMMAND_MENU_SELECTED,
                    wxCommandEventHandler(wxStEditApp::OnMenuEvent), NULL, this);
#endif
    // add menu item for testing the shell
    menu->AppendSeparator();
    menu->Append(ID_TEST_STESHELL, _("Test STE shell..."), _("Test the STE shell component"));
    frame->Connect(ID_TEST_STESHELL, wxEVT_COMMAND_MENU_SELECTED,
                    wxCommandEventHandler(wxStEditApp::OnMenuEvent), NULL, this);

    menu->AppendSeparator();
    wxMenuItem* item = new wxMenuItem(menu, wxID_ABOUT, wxGetStockLabelEx(wxID_ABOUT), _("About this program"));
    item->SetBitmap(wxArtProvider::GetBitmap(wxART_STEDIT_APP)); // wx 2.8 bug: bitmap not shown, unless Add(wxAcceleratorEntry(wxID_ABOUT)) above is remove
    menu->Append(item);

    wxAcceleratorHelper::SetAccelText(menu, *m_steOptions.GetMenuManager()->GetAcceleratorArray());

    wxMenuBar* menubar = frame->GetMenuBar();
    menubar->Append(menu, wxGetStockLabelEx(wxID_HELP));

    item = menubar->FindItem(ID_STN_WINDOWS);
    if (item)
    {
        item->GetMenu()->Append(ID_NEW_STEFRAME, _("&New editor window"), _("Open a new editor window"));
        frame->Connect(ID_NEW_STEFRAME, wxEVT_COMMAND_MENU_SELECTED,
                        wxCommandEventHandler(wxStEditApp::OnMenuEvent), NULL, this);
    }

    return frame;
}