Exemplo n.º 1
0
int
WelcomePage::DoGetPopupMenuSelection(wxCommandLinkButton* btn, const wxArrayString& strings, const wxString& menuTitle)
{
    BitmapLoader bl;
    BitmapLoader::BitmapMap_t bmps = bl.MakeStandardMimeMap();

    m_idToName.clear();
    wxUnusedVar(menuTitle);
    wxMenu menu;

    for(size_t i = 0; i < strings.GetCount(); i++) {

        wxBitmap bmp = bmps[FileExtManager::TypeText];
        wxString filename = strings.Item(i);
        if(filename.Find("@") != wxNOT_FOUND) {
            filename = filename.AfterFirst('@');
        }
        filename.Trim().Trim(false);
        FileExtManager::FileType type = FileExtManager::GetType(filename);
        if(bmps.count(type)) {
            bmp = bmps[type];
        }

        wxMenuItem* item = new wxMenuItem(&menu, wxID_ANY, strings.Item(i));
        item->SetBitmap(bmp);
        m_idToName.insert(std::make_pair(item->GetId(), strings.Item(i)));
        menu.Append(item);
    }

    // get the best position to show the menu
    wxPoint pos = btn->GetPosition();
    pos = m_scrollWin247->CalcScrolledPosition(pos);

    pos.y += btn->GetSize().y;
#ifdef __WXGTK__
    pos.y += 5;
    pos.x += 5;
#elif defined(__WXMAC__)
    pos.y += 10;
    pos.x += 10;
#else // MSW
    pos.y += 5;
    pos.x += 5;
#endif
    return GetPopupMenuSelectionFromUser(menu, pos);
}
Exemplo n.º 2
0
BitmapLoader::BitmapMap_t BitmapLoader::MakeStandardMimeMap()
{
    BitmapLoader::BitmapMap_t images;
    images[FileExtManager::TypeExe] = LoadBitmap(wxT("console"));
    images[FileExtManager::TypeHtml] = LoadBitmap(wxT("mime-html"));
    images[FileExtManager::TypeArchive] = LoadBitmap(wxT("archive"));
    images[FileExtManager::TypePhp] = LoadBitmap(wxT("mime-php"));
    images[FileExtManager::TypeDll] = LoadBitmap(wxT("dll"));
    images[FileExtManager::TypeFormbuilder] = LoadBitmap(wxT("blocks"));
    images[FileExtManager::TypeCodedesigner] = LoadBitmap(wxT("mime-txt"));
    images[FileExtManager::TypeBmp] = LoadBitmap(wxT("mime-bmp"));
    images[FileExtManager::TypeMakefile] = LoadBitmap(wxT("cog"));
    images[FileExtManager::TypeSourceC] = LoadBitmap(wxT("mime-c"));
    images[FileExtManager::TypeSourceCpp] = LoadBitmap(wxT("mime-cpp"));
    images[FileExtManager::TypeHeader] = LoadBitmap(wxT("mime-h"));
    images[FileExtManager::TypeText] = LoadBitmap(wxT("mime-txt"));
    images[FileExtManager::TypeScript] = LoadBitmap(wxT("execute"));
    images[FileExtManager::TypeXml] = LoadBitmap(wxT("mime-xml"));
    images[FileExtManager::TypeErd] = LoadBitmap(wxT("mime-txt"));
    images[FileExtManager::TypePython] = LoadBitmap(wxT("mime-python"));
    images[FileExtManager::TypeCSS] = LoadBitmap(wxT("mime-css"));
    images[FileExtManager::TypeJS] = LoadBitmap(wxT("mime-js"));
    images[FileExtManager::TypeWorkspace] = LoadBitmap("cxx-workspace");
    images[FileExtManager::TypeWorkspacePHP] = LoadBitmap("php-workspace");
    images[FileExtManager::TypeWorkspaceNodeJS] = LoadBitmap("nodejs-workspace");
    images[FileExtManager::TypeProject] = LoadBitmap(wxT("project"));
    images[FileExtManager::TypeWxCrafter] = LoadBitmap(wxT("blocks"));
    images[FileExtManager::TypeXRC] = LoadBitmap(wxT("mime-xml"));
    images[FileExtManager::TypeResource] = LoadBitmap(wxT("tools"));
    images[FileExtManager::TypeSQL] = LoadBitmap(wxT("mime-sql"));
    images[FileExtManager::TypeFolder] = LoadBitmap("folder-yellow");
    images[FileExtManager::TypeFolderExpanded] = LoadBitmap("folder-yellow-opened");
    images[FileExtManager::TypeProjectActive] = LoadBitmap(wxT("project"));
    images[FileExtManager::TypeAsm] = LoadBitmap(wxT("mime-as"));
    images[FileExtManager::TypeCMake] = LoadBitmap(wxT("cmake"));
    images[FileExtManager::TypeQMake] = LoadBitmap(wxT("qt"));

    BitmapLoader::BitmapMap_t merged;
    merged.insert(m_userBitmaps.begin(), m_userBitmaps.end());
    merged.insert(images.begin(), images.end());
    return merged;
}
Exemplo n.º 3
0
BitmapLoader::BitmapMap_t BitmapLoader::MakeStandardMimeMap()
{
    BitmapLoader::BitmapMap_t images;
    images[FileExtManager::TypeExe] = LoadBitmap(wxT("mime/16/exe"));
    images[FileExtManager::TypeHtml] = LoadBitmap(wxT("mime/16/html"));
    images[FileExtManager::TypeArchive] = LoadBitmap(wxT("mime/16/zip"));
    images[FileExtManager::TypePhp] = LoadBitmap(wxT("mime/16/php"));
    images[FileExtManager::TypeDll] = LoadBitmap(wxT("mime/16/dll"));
    images[FileExtManager::TypeFormbuilder] = LoadBitmap(wxT("mime/16/wxfb"));
    images[FileExtManager::TypeCodedesigner] = LoadBitmap(wxT("mime/16/cd"));
    images[FileExtManager::TypeBmp] = LoadBitmap(wxT("mime/16/bmp"));
    images[FileExtManager::TypeMakefile] = LoadBitmap(wxT("mime/16/makefile"));
    images[FileExtManager::TypeSourceC] = LoadBitmap(wxT("mime/16/c"));
    images[FileExtManager::TypeSourceCpp] = LoadBitmap(wxT("mime/16/cpp"));
    images[FileExtManager::TypeHeader] = LoadBitmap(wxT("mime/16/h"));
    images[FileExtManager::TypeText] = LoadBitmap(wxT("mime/16/text"));
    images[FileExtManager::TypeScript] = LoadBitmap(wxT("mime/16/script"));
    images[FileExtManager::TypeXml] = LoadBitmap(wxT("mime/16/xml"));
    images[FileExtManager::TypeErd] = LoadBitmap(wxT("mime/16/erd"));
    images[FileExtManager::TypePython] = LoadBitmap(wxT("mime/16/python"));
    images[FileExtManager::TypeCSS] = LoadBitmap(wxT("mime/16/css"));
    images[FileExtManager::TypeJS] = LoadBitmap(wxT("mime/16/javascript"));
    images[FileExtManager::TypeWorkspace] = LoadBitmap(wxT("workspace/16/workspace"));
    images[FileExtManager::TypeWorkspacePHP] = LoadBitmap(wxT("workspace/16/workspace_php"));
    images[FileExtManager::TypeProject] = LoadBitmap(wxT("workspace/16/project"));
    images[FileExtManager::TypeWxCrafter] = LoadBitmap(wxT("mime/16/wxcp"));
    images[FileExtManager::TypeXRC] = LoadBitmap(wxT("mime/16/xml"));
    images[FileExtManager::TypeResource] = LoadBitmap(wxT("mime/16/res"));
    images[FileExtManager::TypeSQL] = LoadBitmap(wxT("mime/16/sql"));
    images[FileExtManager::TypeFolder] = LoadBitmap(wxT("mime/16/folder"));
    images[FileExtManager::TypeProjectActive] = LoadBitmap(wxT("workspace/16/project_active"));
    images[FileExtManager::TypeAsm] = LoadBitmap(wxT("mime/16/asm"));
    images[FileExtManager::TypeCMake] = LoadBitmap(wxT("mime/16/cmake"));
    images[FileExtManager::TypeQMake] = LoadBitmap(wxT("mime/16/qmake"));

    BitmapLoader::BitmapMap_t merged;
    merged.insert(m_userBitmaps.begin(), m_userBitmaps.end());
    merged.insert(images.begin(), images.end());
    return merged;
}
NotebookNavigationDlg::NotebookNavigationDlg(wxWindow* parent, Notebook* book)
    : NotebookNavigationDlgBase(parent)
    , m_book(book)
    , m_selection(wxNOT_FOUND)
{
    clTab::Vec_t allTabs;
    clTabHistory::Ptr_t history = m_book->GetHistory();
    clGetManager()->GetAllTabs(allTabs);

    BitmapLoader::BitmapMap_t bmps = clGetManager()->GetStdIcons()->MakeStandardMimeMap();

#ifdef __WXOSX__
    wxBitmap saveBmp = wxNullBitmap;
#else
    wxBitmap saveBmp = clGetManager()->GetStdIcons()->LoadBitmap("file_save");
#endif
    std::map<void*, clTab> tabsInfoMap;
    for(size_t i = 0; i < allTabs.size(); ++i) {
        tabsInfoMap.insert(std::make_pair((void*)allTabs.at(i).window, allTabs.at(i)));
    }

    const wxArrayPtrVoid& windows = history->GetHistory();
    // Populate the list
    for(size_t i = 0; i < windows.GetCount(); ++i) {
        int index = m_book->FindPage((wxWindow*)windows.Item(i));
        if(index != wxNOT_FOUND) {
            wxString label = m_book->GetPageText(index);
            wxBitmap bmp = m_book->GetPageBitmap(index);

            wxVector<wxVariant> cols;
            TabData* d = new TabData;
            d->bmp = bmp;
            d->label = label;
            d->index = index;

            // add extra info
            wxVariant modifiedItem;
            wxVariant nullBmp;
            nullBmp << wxNullBitmap;
            std::map<void*, clTab>::iterator iter = tabsInfoMap.find(windows.Item(i));
            if(iter != tabsInfoMap.end()) {
                d->isFile = iter->second.isFile;
                d->filename = iter->second.filename;
                if(iter->second.isModified) {
                    modifiedItem << saveBmp;
                    cols.push_back(modifiedItem);
                } else {
                    cols.push_back(nullBmp);
                }
            } else {
                cols.push_back(nullBmp);
            }

            // Prepare the display item
            wxString text;
            if(d->isFile && d->filename.GetDirCount()) {
                wxFileName fn(d->filename.GetFullName());
                fn.AppendDir(d->filename.GetDirs().Last());
                text << fn.GetFullPath();
            } else {
                text << d->label;
            }

            // If the tab has a bitmap - use it
            // otherwise, try to assign one
            if(!d->bmp.IsOk()) {
                if(d->isFile) {
                    FileExtManager::FileType type =
                        FileExtManager::GetType(d->filename.GetFullName(), FileExtManager::TypeText);
                    if(bmps.count(type)) {
                        d->bmp = bmps.find(type)->second;
                    }
                }
            }

#ifdef __WXOSX__
            if(iter != tabsInfoMap.end() && iter->second.isModified) {
                text.Prepend("*");
            }
#endif
            cols.push_back(::MakeIconText(text, d->bmp));
            m_dvListCtrl->AppendItem(cols, (wxUIntPtr)d);
        }
    }

    if(m_dvListCtrl->GetItemCount() > 1) {
        m_dvListCtrl->Select(m_dvListCtrl->RowToItem(1));
    } else {
        m_dvListCtrl->Select(m_dvListCtrl->RowToItem(0));
    }

    m_dvListCtrl->CallAfter(&wxDataViewCtrl::SetFocus);
    SetMinClientSize(wxSize(500, 300));
#ifdef __WXOSX__
    SetSize(wxSize(500, 300));
#endif
    CentreOnParent();

    wxTheApp->Bind(wxEVT_KEY_DOWN, &NotebookNavigationDlg::OnKeyDown, this);
    wxTheApp->Bind(wxEVT_KEY_UP, &NotebookNavigationDlg::OnKeyUp, this);
}