void PHPOutlineTree::BuildTree(const wxFileName& filename) { m_filename = filename; PHPSourceFile sourceFile(filename, NULL); sourceFile.SetParseFunctionBody(false); sourceFile.Parse(); wxWindowUpdateLocker locker(this); DeleteAllItems(); wxTreeItemId root = AddRoot(wxT("Root")); wxImageList* images = new wxImageList(clGetScaledSize(16), clGetScaledSize(16), true); images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/globals"))); // 0 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_private"))); // 1 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_protected"))); // 2 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_public"))); // 3 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_private"))); // 4 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_protected"))); // 5 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_public"))); // 6 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/namespace"))); // 7 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/class"))); // 8 images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/enumerator"))); // 9 AssignImageList(images); // Build the tree view BuildTree(root, sourceFile.Namespace()); if(HasChildren(GetRootItem())) { ExpandAll(); } }
int wxCodeCompletionBox::GetSingleLineHeight() const { wxBitmap bmp(1, 1); wxMemoryDC memDC(bmp); memDC.SetFont(m_ccFont); m_canvas->PrepareDC(memDC); wxSize size = memDC.GetTextExtent("Tp"); int singleLineHeight = size.y + (2 * Y_SPACER) + clGetScaledSize(2); // the extra pixel is for the border line if(singleLineHeight < clGetScaledSize(16)) { singleLineHeight = clGetScaledSize(16) + clGetScaledSize(2); // at least 16 pixels for image } return singleLineHeight; }
wxImageList* BitmapLoader::MakeStandardMimeImageList() { #if defined(__WXMSW__) || defined(__WXGTK__) wxImageList* imageList = new wxImageList(clGetScaledSize(16), clGetScaledSize(16)); #else wxImageList* imageList = new wxImageList(16, 16); #endif m_fileIndexMap.clear(); AddImage(imageList->Add(LoadBitmap(wxT("console"))), FileExtManager::TypeExe); AddImage(imageList->Add(LoadBitmap(wxT("mime-html"))), FileExtManager::TypeHtml); AddImage(imageList->Add(LoadBitmap(wxT("archive"))), FileExtManager::TypeArchive); AddImage(imageList->Add(LoadBitmap(wxT("mime-php"))), FileExtManager::TypePhp); AddImage(imageList->Add(LoadBitmap(wxT("dll"))), FileExtManager::TypeDll); AddImage(imageList->Add(LoadBitmap(wxT("blocks"))), FileExtManager::TypeFormbuilder); AddImage(imageList->Add(LoadBitmap(wxT("mime-txt"))), FileExtManager::TypeCodedesigner); AddImage(imageList->Add(LoadBitmap(wxT("mime-bmp"))), FileExtManager::TypeBmp); AddImage(imageList->Add(LoadBitmap(wxT("cog"))), FileExtManager::TypeMakefile); AddImage(imageList->Add(LoadBitmap(wxT("mime-c"))), FileExtManager::TypeSourceC); AddImage(imageList->Add(LoadBitmap(wxT("mime-cpp"))), FileExtManager::TypeSourceCpp); AddImage(imageList->Add(LoadBitmap(wxT("mime-h"))), FileExtManager::TypeHeader); AddImage(imageList->Add(LoadBitmap(wxT("mime-txt"))), FileExtManager::TypeText); AddImage(imageList->Add(LoadBitmap(wxT("execute"))), FileExtManager::TypeScript); AddImage(imageList->Add(LoadBitmap(wxT("mime-xml"))), FileExtManager::TypeXml); AddImage(imageList->Add(LoadBitmap(wxT("mime-txt"))), FileExtManager::TypeErd); AddImage(imageList->Add(LoadBitmap(wxT("mime-python"))), FileExtManager::TypePython); AddImage(imageList->Add(LoadBitmap(wxT("mime-css"))), FileExtManager::TypeCSS); AddImage(imageList->Add(LoadBitmap(wxT("mime-js"))), FileExtManager::TypeJS); AddImage(imageList->Add(LoadBitmap(wxT("cxx-workspace"))), FileExtManager::TypeWorkspace); AddImage(imageList->Add(LoadBitmap(wxT("php-workspace"))), FileExtManager::TypeWorkspacePHP); AddImage(imageList->Add(LoadBitmap(wxT("nodejs-workspace"))), FileExtManager::TypeWorkspaceNodeJS); AddImage(imageList->Add(LoadBitmap(wxT("project"))), FileExtManager::TypeProject); AddImage(imageList->Add(LoadBitmap(wxT("blocks"))), FileExtManager::TypeWxCrafter); AddImage(imageList->Add(LoadBitmap(wxT("mime-xml"))), FileExtManager::TypeXRC); AddImage(imageList->Add(LoadBitmap(wxT("tools"))), FileExtManager::TypeResource); AddImage(imageList->Add(LoadBitmap(wxT("mime-sql"))), FileExtManager::TypeSQL); AddImage(imageList->Add(LoadBitmap(wxT("folder-yellow"))), FileExtManager::TypeFolder); AddImage(imageList->Add(LoadBitmap(wxT("folder-yellow-opened"))), FileExtManager::TypeFolderExpanded); AddImage(imageList->Add(LoadBitmap(wxT("mime-as"))), FileExtManager::TypeAsm); AddImage(imageList->Add(LoadBitmap(wxT("cmake"))), FileExtManager::TypeCMake); AddImage(imageList->Add(LoadBitmap(wxT("qt"))), FileExtManager::TypeQMake); std::for_each( m_userBitmaps.begin(), m_userBitmaps.end(), [&](const std::pair<FileExtManager::FileType, wxBitmap>& p) { AddImage(imageList->Add(GetIcon(p.second)), p.first); }); return imageList; }
//---------------------------------------------------------------- // accessory function //---------------------------------------------------------------- wxImageList* svSymbolTree::CreateSymbolTreeImages() { wxImageList* images = new wxImageList(clGetScaledSize(16), clGetScaledSize(16), true); BitmapLoader* bmpLoader = clGetManager()->GetStdIcons(); images->Add(bmpLoader->LoadBitmap(wxT("mime-cpp"))); // 0 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/namespace"))); // 1 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/globals"))); // 2 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/class"))); // 3 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/struct"))); // 4 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/function_public"))); // 5 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/function_protected"))); // 6 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/function_private"))); // 7 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/member_public"))); // 8 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/member_protected"))); // 9 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/member_private"))); // 10 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/typedef"))); // 11 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/macro"))); // 12 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/enum"))); // 13 images->Add(bmpLoader->LoadBitmap(wxT("cc/16/enumerator"))); // 14 images->Add(bmpLoader->LoadBitmap(wxT("mime-cpp"))); // 15 images->Add(bmpLoader->LoadBitmap(wxT("mime-h"))); // 16 return images; }
void wxCodeCompletionBox::OnPaint(wxPaintEvent& event) { // Paint the background colour wxAutoBufferedPaintDC dc(m_canvas); // Invalidate all item rects before we draw them for(size_t i = 0; i < m_entries.size(); ++i) { m_entries.at(i)->m_itemRect = wxRect(); } wxRect rect = GetClientRect(); m_scrollArea = wxRect(rect.GetWidth() - SCROLLBAR_WIDTH + rect.GetTopLeft().x, rect.GetTopLeft().y, SCROLLBAR_WIDTH, rect.GetHeight()); dc.SetFont(m_ccFont); int singleLineHeight = GetSingleLineHeight(); m_canvas->PrepareDC(dc); // Draw the entire box with single solid colour dc.SetBrush(m_useLightColours ? m_bgColour : m_lightBorder); dc.SetPen(m_penColour); #ifdef __WXOSX__ rect.Inflate(1, 1); #endif dc.DrawRectangle(rect); // Shrink the rectangle by 2 to provide a 2 pixle // border rect.Deflate(2, 2); dc.SetBrush(m_bgColour); dc.SetPen(m_bgColour); dc.DrawRectangle(rect); // We want to have a scrollbar alike. We do this by reducing the size of the // items area by 5 pixels rect.SetWidth(rect.GetWidth() - SCROLLBAR_WIDTH); int firstIndex = m_index; int lastIndex = m_index + LINES_PER_PAGE; if(lastIndex > (int)m_entries.size()) { lastIndex = m_entries.size(); } // if the number of items to display is less from the number of lines // on the box, try prepending items from the top while(firstIndex > 0 && ((lastIndex - firstIndex) != LINES_PER_PAGE)) { --firstIndex; } // Paint the entries, starting from m_index => m_index + 7 wxCoord y = 0; // Initial coord for drawing the first line wxCoord textX = m_bitmaps.empty() ? 2 : clGetScaledSize(20); wxCoord bmpX = clGetScaledSize(2); // Draw all items from firstIndex => lastIndex for(int i = firstIndex; i < lastIndex; ++i) { bool isSelected = (i == m_index); wxRect itemRect(0, y, rect.GetWidth(), singleLineHeight); if(isSelected) { // highlight the selection dc.SetBrush(m_selection); dc.SetPen(m_selection); dc.DrawRectangle(itemRect); } dc.SetTextForeground(isSelected ? m_selectedTextColour : m_textColour); dc.SetPen(m_lightBorder); dc.DrawLine(2, y, itemRect.GetWidth() + 2, y); // If this item has a bitmap, draw it wxCodeCompletionBoxEntry::Ptr_t entry = m_entries.at(i); if(entry->GetImgIndex() != wxNOT_FOUND && entry->GetImgIndex() < (int)m_bitmaps.size()) { const wxBitmap& bmp = m_bitmaps.at(entry->GetImgIndex()); wxCoord bmpY = ((singleLineHeight - bmp.GetScaledHeight()) / 2) + itemRect.y; dc.DrawBitmap(bmp, bmpX, bmpY); } // Draw the text dc.SetClippingRegion(itemRect); // Truncate the text to fit the screen wxString choppedText; DrawingUtils::TruncateText(entry->GetText(), itemRect.GetWidth(), dc, choppedText); wxSize itemTextSize = dc.GetTextExtent(choppedText); wxCoord textY = ((singleLineHeight - itemTextSize.GetHeight()) / 2) + itemRect.y; dc.DrawText(choppedText, textX, textY); dc.DestroyClippingRegion(); y += singleLineHeight; dc.SetPen(m_darkBorder); dc.DrawLine(2, y, itemRect.GetWidth() + 2, y); entry->m_itemRect = itemRect; } //===================-------------------------------------- // draw the scrollbar //===================-------------------------------------- wxRect scrollRect = m_scrollArea; scrollRect.Deflate(0, 2); scrollRect.SetWidth(scrollRect.GetWidth() - 2); dc.GradientFillLinear(scrollRect, m_scrollBgColour, m_scrollBgColour); DoDrawBottomScrollButton(dc); DoDrawTopScrollButton(dc); }