CLocalFileBase* CLocalFolder::GetChild( int iChild ) { ASSERT( IsExpanded( ) ); return m_Childs[ iChild ]; }
void CmpCtrl::SaveDisplay( ) { if ( m_rootId.IsOk() && ItemHasChildren( m_rootId ) ) CmpEnv::s_expand_root = IsExpanded( m_rootId ); if ( m_cmpId.IsOk() && ItemHasChildren( m_cmpId ) ) CmpEnv::s_expand_cmp = IsExpanded( m_cmpId ); if ( m_booksId.IsOk() && ItemHasChildren( m_booksId ) ) CmpEnv::s_expand_book = IsExpanded( m_booksId ); }
void CLocalTreeView::Refresh() { wxLogNull nullLog; const wxString separator = wxFileName::GetPathSeparator(); std::list<t_dir> dirsToCheck; #ifdef __WXMSW__ int prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); wxTreeItemIdValue tmp; wxTreeItemId child = GetFirstChild(m_drives, tmp); while (child) { if (IsExpanded(child)) { wxString drive = GetItemText(child); int pos = drive.Find(_T(" ")); if (pos != -1) drive = drive.Left(pos); t_dir dir; dir.dir = drive + separator; dir.item = child; dirsToCheck.push_back(dir); } child = GetNextSibling(child); } #else t_dir dir; dir.dir = separator; dir.item = GetRootItem(); dirsToCheck.push_back(dir); #endif CFilterManager filter; while (!dirsToCheck.empty()) { t_dir dir = dirsToCheck.front(); dirsToCheck.pop_front(); // Step 1: Check if directory exists CLocalFileSystem local_filesystem; if (!local_filesystem.BeginFindFiles(dir.dir, true)) { // Dir does exist (listed in parent) but may not be accessible. // Recurse into children anyhow, they might be accessible again. wxTreeItemIdValue value; wxTreeItemId child = GetFirstChild(dir.item, value); while (child) { t_dir subdir; subdir.dir = dir.dir + GetItemText(child) + separator; subdir.item = child; dirsToCheck.push_back(subdir); child = GetNextSibling(child); } continue; } // Step 2: Enumerate subdirectories on disk and sort them std::list<wxString> dirs; wxString file; const wxLongLong size(-1); bool was_link; bool is_dir; int attributes; wxDateTime date; while (local_filesystem.GetNextFile(file, was_link, is_dir, 0, &date, &attributes)) { if (file == _T("")) { wxGetApp().DisplayEncodingWarning(); continue; } if (filter.FilenameFiltered(file, dir.dir, true, size, true, attributes, date.IsValid() ? &date : 0)) continue; dirs.push_back(file); } dirs.sort(sortfunc); bool inserted = false; // Step 3: Merge list of subdirectories with subtree. wxTreeItemId child = GetLastChild(dir.item); std::list<wxString>::reverse_iterator iter = dirs.rbegin(); while (child || iter != dirs.rend()) { int cmp; if (child && iter != dirs.rend()) #ifdef __WXMSW__ cmp = GetItemText(child).CmpNoCase(*iter); #else cmp = GetItemText(child).Cmp(*iter); #endif else if (child) cmp = 1; else cmp = -1; if (!cmp) { // Found item with same name. Mark it for further processing if (!IsExpanded(child)) { wxString path = dir.dir + *iter + separator; if (!CheckSubdirStatus(child, path)) { t_dir subdir; subdir.dir = path; subdir.item = child; dirsToCheck.push_front(subdir); } } else { t_dir subdir; subdir.dir = dir.dir + *iter + separator; subdir.item = child; dirsToCheck.push_front(subdir); } child = GetPrevSibling(child); ++iter; } else if (cmp > 0) { // Subdirectory currently in tree no longer exists. // Delete child from tree, unless current selection // is in the subtree. wxTreeItemId sel = GetSelection(); while (sel && sel != child) sel = GetItemParent(sel); wxTreeItemId prev = GetPrevSibling(child); if (!sel) Delete(child); child = prev; } else if (cmp < 0) { // New subdirectory, add treeitem wxString fullname = dir.dir + *iter + separator; wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname), #ifdef __WXMSW__ -1 #else GetIconIndex(opened_dir, fullname) #endif ); CheckSubdirStatus(newItem, fullname); ++iter; inserted = true; } } if (inserted) SortChildren(dir.item); }
void clRowEntry::Render(wxWindow* win, wxDC& dc, const clColours& c, int row_index, clSearchText* searcher) { wxUnusedVar(searcher); wxRect rowRect = GetItemRect(); bool zebraColouring = (m_tree->HasStyle(wxTR_ROW_LINES) || m_tree->HasStyle(wxDV_ROW_LINES)); bool even_row = ((row_index % 2) == 0); // Define the clipping region bool hasHeader = (m_tree->GetHeader() && !m_tree->GetHeader()->empty()); // Not cell related clColours colours = c; if(zebraColouring) { // Set Zebra colouring, only if no user colour was provided for the given line colours.SetItemBgColour(even_row ? c.GetAlternateColour() : c.GetBgColour()); } // Override default item bg colour with the user's one if(GetBgColour().IsOk()) { colours.SetItemBgColour(GetBgColour()); } wxRect selectionRect = rowRect; wxPoint deviceOrigin = dc.GetDeviceOrigin(); selectionRect.SetX(-deviceOrigin.x); if(IsSelected()) { DrawSimpleSelection(win, dc, selectionRect, colours); } else if(IsHovered()) { dc.SetPen(colours.GetHoverBgColour()); dc.SetBrush(colours.GetHoverBgColour()); dc.DrawRectangle(selectionRect); } else if(colours.GetItemBgColour().IsOk()) { dc.SetBrush(colours.GetItemBgColour()); dc.SetPen(colours.GetItemBgColour()); dc.DrawRectangle(selectionRect); } // Per cell drawings for(size_t i = 0; i < m_cells.size(); ++i) { bool last_cell = (i == (m_cells.size() - 1)); colours = c; // reset the colours wxFont f = clScrolledPanel::GetDefaultFont(); clCellValue& cell = GetColumn(i); if(cell.GetFont().IsOk()) { f = cell.GetFont(); } if(cell.GetTextColour().IsOk()) { colours.SetItemTextColour(cell.GetTextColour()); } if(cell.GetBgColour().IsOk()) { colours.SetItemBgColour(cell.GetBgColour()); } dc.SetFont(f); wxColour buttonColour = IsSelected() ? colours.GetSelbuttonColour() : colours.GetButtonColour(); wxRect cellRect = GetCellRect(i); // We use a helper class to clip the drawings this ensures that if we exit the scope // the clipping region is restored properly clClipperHelper clipper(dc); if(hasHeader) { clipper.Clip(cellRect); } int textXOffset = cellRect.GetX(); if((i == 0) && !IsListItem()) { // The expand button is only make sense for the first cell if(HasChildren()) { wxRect buttonRect = GetButtonRect(); buttonRect.Deflate(1); textXOffset += buttonRect.GetWidth(); if(m_tree->IsNativeTheme() && !IS_OSX) { int flags = wxCONTROL_CURRENT; if(IsExpanded()) { flags |= wxCONTROL_EXPANDED; } int button_width = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X); wxRect modButtonRect = buttonRect; modButtonRect.SetWidth(button_width); modButtonRect.SetHeight(button_width); modButtonRect = modButtonRect.CenterIn(buttonRect); wxRendererNative::Get().DrawTreeItemButton(win, dc, modButtonRect, flags); } else { wxRect buttonRect = GetButtonRect(); if(textXOffset >= cellRect.GetWidth()) { // if we cant draw the button (off screen etc) SetRects(GetItemRect(), wxRect()); continue; } buttonRect.Deflate((buttonRect.GetWidth() / 3), (buttonRect.GetHeight() / 3)); wxRect tribtn = buttonRect; dc.SetPen(wxPen(buttonColour, 2)); if(IsExpanded()) { tribtn.SetHeight(tribtn.GetHeight() - tribtn.GetHeight() / 2); tribtn = tribtn.CenterIn(buttonRect); wxPoint middleLeft = wxPoint((tribtn.GetLeft() + tribtn.GetWidth() / 2), tribtn.GetBottom()); dc.DrawLine(tribtn.GetTopLeft(), middleLeft); dc.DrawLine(tribtn.GetTopRight(), middleLeft); } else { tribtn.SetWidth(tribtn.GetWidth() - tribtn.GetWidth() / 2); tribtn = tribtn.CenterIn(buttonRect); wxPoint middleLeft = wxPoint(tribtn.GetRight(), (tribtn.GetY() + (tribtn.GetHeight() / 2))); wxPoint p1 = tribtn.GetTopLeft(); wxPoint p2 = tribtn.GetBottomLeft(); dc.DrawLine(p1, middleLeft); dc.DrawLine(middleLeft, p2); } } } else { wxRect buttonRect(rowRect); buttonRect.SetWidth(rowRect.GetHeight()); buttonRect.Deflate(1); textXOffset += buttonRect.GetWidth(); if(textXOffset >= cellRect.GetWidth()) { SetRects(GetItemRect(), wxRect()); continue; } } } int itemIndent = IsListItem() ? clHeaderItem::X_SPACER : (GetIndentsCount() * m_tree->GetIndent()); int bitmapIndex = cell.GetBitmapIndex(); if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) { bitmapIndex = cell.GetBitmapSelectedIndex(); } // Draw checkbox if(cell.IsBool()) { // Render the checkbox textXOffset += X_SPACER; int checkboxSize = GetCheckBoxWidth(win); wxRect checkboxRect = wxRect(textXOffset, rowRect.GetY(), checkboxSize, checkboxSize); checkboxRect = checkboxRect.CenterIn(rowRect, wxVERTICAL); dc.SetPen(colours.GetItemTextColour()); RenderCheckBox(win, dc, colours, checkboxRect, cell.GetValueBool()); cell.SetCheckboxRect(checkboxRect); textXOffset += checkboxRect.GetWidth(); textXOffset += X_SPACER; } else { cell.SetCheckboxRect(wxRect()); // clear the checkbox rect } // Draw the bitmap if(bitmapIndex != wxNOT_FOUND) { const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex); if(bmp.IsOk()) { textXOffset += IsListItem() ? 0 : X_SPACER; int bitmapY = rowRect.GetY() + ((rowRect.GetHeight() - bmp.GetScaledHeight()) / 2); // if((textXOffset + bmp.GetScaledWidth()) >= cellRect.GetWidth()) { continue; } dc.DrawBitmap(bmp, itemIndent + textXOffset, bitmapY, true); textXOffset += bmp.GetScaledWidth(); textXOffset += X_SPACER; } } // Draw the text wxRect textRect(dc.GetTextExtent(cell.GetValueString())); textRect = textRect.CenterIn(rowRect, wxVERTICAL); int textY = textRect.GetY(); int textX = (i == 0 ? itemIndent : clHeaderItem::X_SPACER) + textXOffset; RenderText(win, dc, colours, cell.GetValueString(), textX, textY, i); textXOffset += textRect.GetWidth(); textXOffset += X_SPACER; if(cell.IsChoice()) { // draw the drop down arrow. Make it aligned to the right wxRect dropDownRect(cellRect.GetTopRight().x - rowRect.GetHeight(), rowRect.GetY(), rowRect.GetHeight(), rowRect.GetHeight()); dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL); DrawingUtils::DrawDropDownArrow(win, dc, dropDownRect, wxNullColour); // Keep the rect to test clicks cell.SetDropDownRect(dropDownRect); textXOffset += dropDownRect.GetWidth(); textXOffset += X_SPACER; // Draw a separator line between the drop down arrow and the rest of the cell content dropDownRect.Deflate(3); dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL); dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE)); dc.DrawLine(dropDownRect.GetTopLeft(), dropDownRect.GetBottomLeft()); } else { cell.SetDropDownRect(wxRect()); } if(!last_cell) { cellRect.SetHeight(rowRect.GetHeight()); dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE)); dc.DrawLine(cellRect.GetTopRight(), cellRect.GetBottomRight()); } } }
void CRemoteTreeView::SetDirectoryListing(std::shared_ptr<CDirectoryListing> const& pListing, bool modified) { m_busy = true; if (!pListing) { m_ExpandAfterList = wxTreeItemId(); DeleteAllItems(); AddRoot(_T("")); m_busy = false; if (FindFocus() == this) { wxNavigationKeyEvent *evt = new wxNavigationKeyEvent(); evt->SetFromTab(true); evt->SetEventObject(this); evt->SetDirection(true); QueueEvent(evt); } Enable(false); m_contextMenuItem = wxTreeItemId(); return; } Enable(true); #ifdef __WXGTK__ GetParent()->m_dirtyTabOrder = true; #endif if (pListing->get_unsure_flags() && !(pListing->get_unsure_flags() & ~(CDirectoryListing::unsure_unknown | CDirectoryListing::unsure_file_mask))) { // Just files changed, does not affect directory tree m_busy = false; return; } #ifndef __WXMSW__ Freeze(); #endif wxTreeItemId parent = MakeParent(pListing->path, !modified); if (!parent) { m_busy = false; #ifndef __WXMSW__ Thaw(); #endif return; } if (!IsExpanded(parent) && parent != m_ExpandAfterList) { DeleteChildren(parent); CFilterManager filter; if (HasSubdirs(*pListing, filter)) AppendItem(parent, _T(""), -1, -1); } else { RefreshItem(parent, *pListing, !modified); if (m_ExpandAfterList == parent) { #ifndef __WXMSW__ // Prevent CalculatePositions from being called wxGenericTreeItem *anchor = m_anchor; m_anchor = 0; #endif Expand(parent); #ifndef __WXMSW__ m_anchor = anchor; #endif } } m_ExpandAfterList = wxTreeItemId(); SetItemImages(parent, false); #ifndef __WXMSW__ Thaw(); #endif if (!modified) SafeSelectItem(parent); #ifndef __WXMSW__ else Refresh(); #endif m_busy = false; }
void RegTreeCtrl::GoTo(const wxString& location) { wxStringTokenizer tk(location, wxT("\\")); wxTreeItemId id = GetRootItem(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( tk.HasMoreTokens() ) { wxString subkey = tk.GetNextToken(); wxTreeItemId idCurrent = id; if ( !IsExpanded(idCurrent) ) Expand(idCurrent); wxTreeItemIdValue dummy; id = GetFirstChild(idCurrent, dummy); if ( idCurrent == GetRootItem() ) { // special case: we understand both HKCU and HKEY_CURRENT_USER here #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t key = 0; key < wxRegKey::nStdKeys; key++ ) { if ( subkey == wxRegKey::GetStdKeyName(key) || subkey == wxRegKey::GetStdKeyShortName(key) ) { break; } id = GetNextChild(idCurrent, dummy); } } else { // enum all children #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( id.IsOk() ) { if ( subkey == ((TreeNode *)GetItemData(id))->m_strName ) break; id = GetNextChild(idCurrent, dummy); } } if ( !id.IsOk() ) { wxLogError(wxT("No such key '%s'."), location.c_str()); return; } } if ( id.IsOk() ) SelectItem(id); }
// This function generates the HTML output for ExportHTML. The reason this was made separate // from GetHTML is because it uses style sheets. This lets the user easily customize the look // of the HTML file after it is saved, just by changing a value here and there. // Styled ID Tags: pghdr = This is used for the header that gives the eMule build and date. // sec = Sections, ie Transfer, Connection, Session, Cumulative // item = Items, ie UL:DL Ratio, Peak Connections, Downloaded Data // bdy = The BODY tag. Used to control the background color. CString CStatisticsTree::GetHTMLForExport(HTREEITEM theItem, int theItemLevel, bool firstItem) { static int s_iHtmlId; if (theItem==NULL && theItemLevel==0 && firstItem) s_iHtmlId = 0; CString strBuffer, strItem, strImage, strChild, strTab; int nImage=0, nSelectedImage=0; HTREEITEM hCurrent; CString strDivStart, strDiv, strDivA, strDivEnd, strJ, strName; strBuffer.Empty(); if (firstItem) hCurrent = GetRootItem(); else hCurrent = theItem; while (hCurrent != NULL) { strItem.Empty(); if (ItemHasChildren(hCurrent)) { s_iHtmlId++; strJ.Format(_T("%d"),s_iHtmlId); if (IsExpanded(hCurrent)) { strChild = _T("visible"); strDiv = _T("<div id=\"T") + strJ + _T("\" style=\"margin-left:18px\">"); } else { strChild = _T("hidden"); strDiv = _T("<div id=\"T") + strJ + _T("\" style=\"margin-left:18px; visibility:hidden; position:absolute\">"); } strDivStart = _T("<a href=\"javascript:togglevisible('") + strJ + _T("')\">"); strDivEnd = _T("</div>"); strDivA = _T("</a>"); strName = _T("name=\"I") + strJ + _T("\""); } else { strChild = _T("space"); strDiv=_T(""); strDivStart=_T(""); strDivEnd=_T(""); strName=_T(""); } strBuffer += _T("\n"); for (int i = 0; i < theItemLevel; i++) strBuffer += _T("\t"); strItem += strDivStart; strItem += _T("<img ") + strName + _T("src=\"stats_") + strChild + _T(".gif\" align=\"middle\"> "); strItem += strDivA; if (GetItemImage(hCurrent, nImage, nSelectedImage)) strImage.Format(_T("%u"),nImage); else strImage.Format(_T("%u"),0); strItem += _T("<img src=\"stats_") + strImage + _T(".gif\" align=\"middle\"> "); if (IsBold(hCurrent)) strItem += _T("<b>") + GetItemText(hCurrent) + _T("</b>"); else strItem += GetItemText(hCurrent); if (theItemLevel==0) strBuffer.Append(_T("\n")); strBuffer += strItem + _T("<br />"); if (ItemHasChildren(hCurrent)) { strTab = _T("\n"); for (int i = 0; i < theItemLevel; i++) strTab += _T("\t"); strBuffer += strTab + strDiv; strBuffer += strTab + _T("\t") + GetHTMLForExport(GetChildItem(hCurrent), theItemLevel+1, false); strBuffer += strTab + strDivEnd; } hCurrent = GetNextItem(hCurrent, TVGN_NEXT); } return strBuffer; }
void CLocalTreeView::Refresh() { wxLogNull nullLog; const wxString separator = wxFileName::GetPathSeparator(); std::list<t_dir> dirsToCheck; #ifdef __WXMSW__ int prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); wxTreeItemIdValue tmp; wxTreeItemId child = GetFirstChild(m_drives, tmp); while (child) { if (IsExpanded(child)) { wxString drive = GetItemText(child); int pos = drive.Find(_T(" ")); if (pos != -1) drive = drive.Left(pos); t_dir dir; dir.dir = drive + separator; dir.item = child; dirsToCheck.push_back(dir); } child = GetNextSibling(child); } #else t_dir dir; dir.dir = separator; dir.item = GetRootItem(); dirsToCheck.push_back(dir); #endif CFilterDialog filter; while (!dirsToCheck.empty()) { t_dir dir = dirsToCheck.front(); dirsToCheck.pop_front(); wxDir find(dir.dir); if (!find.IsOpened()) { // Dir does exist (listed in parent) but may not be accessible. // Recurse into children anyhow, they might be accessible again. wxTreeItemIdValue value; wxTreeItemId child = GetFirstChild(dir.item, value); while (child) { t_dir subdir; subdir.dir = dir.dir + GetItemText(child) + separator; subdir.item = child; dirsToCheck.push_back(subdir); child = GetNextSibling(child); } continue; } wxString file; bool found = find.GetFirst(&file, _T(""), wxDIR_DIRS | wxDIR_HIDDEN); std::list<wxString> dirs; while (found) { if (file == _T("")) { wxGetApp().DisplayEncodingWarning(); found = find.GetNext(&file); continue; } wxFileName fn(dir.dir + file); const bool isDir = fn.DirExists(); wxLongLong size; wxStructStat buf; int result = wxStat(fn.GetFullPath(), &buf); if (!isDir && !result) size = buf.st_size; else size = -1; int attributes; #ifdef __WXMSW__ DWORD tmp = GetFileAttributes(fn.GetFullPath()); if (tmp == INVALID_FILE_ATTRIBUTES) attributes = 0; else attributes = tmp; #else if (!result) attributes = buf.st_mode & 0x777; else attributes = -1; #endif //__WXMSW__ if (!filter.FilenameFiltered(file, isDir, size , true, attributes)) dirs.push_back(file); found = find.GetNext(&file); } dirs.sort(sortfunc); bool inserted = false; wxTreeItemId child = GetLastChild(dir.item); std::list<wxString>::reverse_iterator iter = dirs.rbegin(); while (child && iter != dirs.rend()) { #ifdef __WXMSW__ int cmp = GetItemText(child).CmpNoCase(*iter); #else int cmp = GetItemText(child).Cmp(*iter); #endif if (!cmp) { if (!IsExpanded(child)) { wxTreeItemId subchild = GetLastChild(child); if (subchild && GetItemText(subchild) == _T("")) { if (!HasSubdir(dir.dir + *iter + separator)) Delete(subchild); } else if (!subchild) { if (HasSubdir(dir.dir + *iter + separator)) AppendItem(child, _T("")); } else { t_dir subdir; subdir.dir = dir.dir + *iter + separator; subdir.item = child; dirsToCheck.push_front(subdir); } } else { t_dir subdir; subdir.dir = dir.dir + *iter + separator; subdir.item = child; dirsToCheck.push_front(subdir); } child = GetPrevSibling(child); iter++; } else if (cmp > 0) { wxTreeItemId sel = GetSelection(); while (sel && sel != child) sel = GetItemParent(sel); wxTreeItemId prev = GetPrevSibling(child); if (!sel) Delete(child); child = prev; } else if (cmp < 0) { wxString fullname = dir.dir + *iter + separator; wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname), GetIconIndex(opened_dir, fullname)); if (HasSubdir(fullname)) AppendItem(newItem, _T("")); iter++; inserted = true; } } while (child) { wxTreeItemId sel = GetSelection(); while (sel && sel != child) sel = GetItemParent(sel); wxTreeItemId prev = GetPrevSibling(child); if (!sel) Delete(child); child = prev; } while (iter != dirs.rend()) { wxString fullname = dir.dir + *iter + separator; wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname), GetIconIndex(opened_dir, fullname)); if (HasSubdir(fullname)) AppendItem(newItem, _T("")); iter++; inserted = true; } if (inserted) SortChildren(dir.item); } #ifdef __WXMSW__ SetErrorMode(prevErrorMode); #endif }
void TBarWindow::MessageReceived(BMessage* message) { switch (message->what) { case kFindButton: { BMessenger tracker(kTrackerSignature); tracker.SendMessage(message); break; } case kMsgLocation: GetLocation(message); break; case kMsgSetLocation: SetLocation(message); break; case kMsgIsExpanded: IsExpanded(message); break; case kMsgExpand: Expand(message); break; case kMsgGetItemInfo: ItemInfo(message); break; case kMsgHasItem: ItemExists(message); break; case kMsgCountItems: CountItems(message); break; case kMsgMaxItemSize: MaxItemSize(message); break; case kMsgAddAddOn: case kMsgAddView: AddItem(message); break; case kMsgRemoveItem: RemoveItem(message); break; case 'iloc': GetIconFrame(message); break; default: BWindow::MessageReceived(message); break; } }
const FSlateBrush* FSequencerFolderNode::GetIconBrush() const { return IsExpanded() ? FolderOpenBrush : FolderClosedBrush; }
/* Under all platforms there is no reaction when pressing "ENTER". Expected would be e.g. to open the file in an editor. */ void cbTreeCtrl::OnKeyDown(wxKeyEvent& event) { // Don't care about special key combinations if ( !this || (event.GetModifiers()!=wxMOD_NONE) ) { event.Skip(); return; } wxArrayTreeItemIds selections; // Don't care if no selection has been made if ( GetSelections(selections)<1 ) { event.Skip(); return; } long keycode = event.GetKeyCode(); wxTreeItemId itemId = selections[0]; // Don't care if item is invalid if ( !itemId.IsOk() ) { event.Skip(); return; } switch (keycode) { case WXK_RETURN: case WXK_NUMPAD_ENTER: { wxTreeEvent te = wxTreeEvent(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, this, itemId); wxPostEvent(this, te); break; } #ifndef __WXMSW__ /* Under wxGTK, there is no navigation possible using cursor keys. */ case WXK_UP: { wxTreeItemId itemIdPrev = GetPrevVisible(itemId); if (itemIdPrev.IsOk()) { SelectItem(itemId, false); SelectItem(itemIdPrev, true); } else { wxTreeItemId itemIdParent = GetItemParent(itemId); if (itemIdParent.IsOk()) { SelectItem(itemId, false); SelectItem(itemIdParent, true); } } break; } case WXK_DOWN: { wxTreeItemId itemIdNext = GetNextVisible(itemId); if (itemIdNext.IsOk()) { SelectItem(itemId, false); SelectItem(itemIdNext, true); } break; } case WXK_LEFT: { if ( ItemHasChildren(itemId) && IsExpanded(itemId) ) Collapse(itemId); else { wxTreeItemId itemIdParent = GetItemParent(itemId); if (itemIdParent.IsOk()) { SelectItem(itemId, false); SelectItem(itemIdParent, true); } } break; } case WXK_RIGHT: { if ( ItemHasChildren(itemId) && !IsExpanded(itemId) ) Expand(itemId); else { wxTreeItemIdValue cookie; wxTreeItemId itemIdChild = GetFirstChild(itemId, cookie); if (itemIdChild.IsOk()) { SelectItem(itemId, false); SelectItem(itemIdChild, true); } } break; } #endif // !__WXMSW__ default: event.Skip(); } }
// Return: false if deleted bool CItem::StartRefresh() { ASSERT(GetType() != IT_FREESPACE); ASSERT(GetType() != IT_UNKNOWN); m_ticksWorked = 0; // Special case IT_MYCOMPUTER if (GetType() == IT_MYCOMPUTER) { ZeroMemory(&m_lastChange, sizeof(m_lastChange)); for (int i=0; i < GetChildrenCount(); i++) GetChild(i)->StartRefresh(); return true; } ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY || GetType() == IT_FILESFOLDER); bool wasExpanded = IsVisible() && IsExpanded(); int oldScrollPosition = 0; if (IsVisible()) oldScrollPosition = GetScrollPosition(); UncacheImage(); // Upward clear data UpdateLastChange(); UpwardSetUndone(); UpwardAddReadJobs(-GetReadJobs()); ASSERT(GetReadJobs() == 0); if (GetType() == IT_FILE) GetParent()->UpwardAddFiles(-1); else UpwardAddFiles(-GetFilesCount()); ASSERT(GetFilesCount() == 0); if (GetType() == IT_DIRECTORY || GetType() == IT_DRIVE) UpwardAddSubdirs(-GetSubdirsCount()); ASSERT(GetSubdirsCount() == 0); UpwardAddSize(-GetSize()); ASSERT(GetSize() == 0); RemoveAllChildren(); UpwardRecalcLastChange(); // Special case IT_FILESFOLDER if (GetType() == IT_FILESFOLDER) { CFileFindWDS finder; BOOL b = finder.FindFile(GetFindPattern()); while (b) { b = finder.FindNextFile(); if (finder.IsDirectory()) continue; FILEINFO fi; fi.name = finder.GetFileName(); fi.attributes = finder.GetAttributes(); // Retrieve file size fi.length = finder.GetCompressedLength(); finder.GetLastWriteTime(&fi.lastWriteTime); AddFile(fi); UpwardAddFiles(1); } SetDone(); if (wasExpanded) GetTreeListControl()->ExpandItem(this); return true; } ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY); // The item may have been deleted. bool deleted = false; if (GetType() == IT_DRIVE) deleted = !DriveExists(GetPath()); else if (GetType() == IT_FILE) deleted = !FileExists(GetPath()); else if (GetType() == IT_DIRECTORY) deleted = !FolderExists(GetPath()); if (deleted) { if (GetParent() == NULL) { GetDocument()->UnlinkRoot(); } else { GetParent()->UpwardRecalcLastChange(); GetParent()->RemoveChild(GetParent()->FindChildIndex(this)); // --> delete this } return false; } // Case IT_FILE if (GetType() == IT_FILE) { CFileFindWDS finder; BOOL b = finder.FindFile(GetPath()); if (b) { finder.FindNextFile(); if (!finder.IsDirectory()) { FILEINFO fi; fi.name = finder.GetFileName(); fi.attributes = finder.GetAttributes(); // Retrieve file size fi.length = finder.GetCompressedLength(); finder.GetLastWriteTime(&fi.lastWriteTime); SetLastChange(fi.lastWriteTime); UpwardAddSize(fi.length); UpwardUpdateLastChange(GetLastChange()); GetParent()->UpwardAddFiles(1); } } SetDone(); return true; } ASSERT(GetType() == IT_DRIVE || GetType() == IT_DIRECTORY); if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsMountPoint(GetPath()) && !GetOptions()->IsFollowMountPoints()) return true; if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsJunctionPoint(GetPath()) && !GetOptions()->IsFollowJunctionPoints()) return true; // Initiate re-read SetReadJobDone(false); // Re-create <free space> and <unknown> if (GetType() == IT_DRIVE) { if (GetDocument()->OptionShowFreeSpace()) CreateFreeSpaceItem(); if (GetDocument()->OptionShowUnknown()) CreateUnknownItem(); } DoSomeWork(0); if (wasExpanded) GetTreeListControl()->ExpandItem(this); if (IsVisible()) SetScrollPosition(oldScrollPosition); return true; }
void CLocalTreeView::Refresh() { wxLogNull nullLog; const wxString separator = wxFileName::GetPathSeparator(); std::list<t_dir> dirsToCheck; #ifdef __WXMSW__ int prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); wxTreeItemIdValue tmp; wxTreeItemId child = GetFirstChild(m_drives, tmp); while (child) { if (IsExpanded(child)) { wxString drive = GetItemText(child); int pos = drive.Find(_T(" ")); if (pos != -1) drive = drive.Left(pos); t_dir dir; dir.dir = drive + separator; dir.item = child; dirsToCheck.push_back(dir); } child = GetNextSibling(child); } #else t_dir dir; dir.dir = separator; dir.item = GetRootItem(); dirsToCheck.push_back(dir); #endif CFilterManager filter; while (!dirsToCheck.empty()) { t_dir dir = dirsToCheck.front(); dirsToCheck.pop_front(); CLocalFileSystem local_filesystem; if (!local_filesystem.BeginFindFiles(dir.dir, true)) { // Dir does exist (listed in parent) but may not be accessible. // Recurse into children anyhow, they might be accessible again. wxTreeItemIdValue value; wxTreeItemId child = GetFirstChild(dir.item, value); while (child) { t_dir subdir; subdir.dir = dir.dir + GetItemText(child) + separator; subdir.item = child; dirsToCheck.push_back(subdir); child = GetNextSibling(child); } continue; } std::list<wxString> dirs; wxString file; const wxLongLong size(-1); bool was_link; bool is_dir; int attributes; while (local_filesystem.GetNextFile(file, was_link, is_dir, 0, 0, &attributes)) { if (file == _T("")) { wxGetApp().DisplayEncodingWarning(); continue; } if (filter.FilenameFiltered(file, dir.dir, true, size, true, attributes)) continue; dirs.push_back(file); } dirs.sort(sortfunc); bool inserted = false; wxTreeItemId child = GetLastChild(dir.item); std::list<wxString>::reverse_iterator iter = dirs.rbegin(); while (child && iter != dirs.rend()) { #ifdef __WXMSW__ int cmp = GetItemText(child).CmpNoCase(*iter); #else int cmp = GetItemText(child).Cmp(*iter); #endif if (!cmp) { if (!IsExpanded(child)) { wxString path = dir.dir + *iter + separator; if (!CheckSubdirStatus(child, path)) { t_dir subdir; subdir.dir = path; subdir.item = child; dirsToCheck.push_front(subdir); } } else { t_dir subdir; subdir.dir = dir.dir + *iter + separator; subdir.item = child; dirsToCheck.push_front(subdir); } child = GetPrevSibling(child); iter++; } else if (cmp > 0) { wxTreeItemId sel = GetSelection(); while (sel && sel != child) sel = GetItemParent(sel); wxTreeItemId prev = GetPrevSibling(child); if (!sel) Delete(child); child = prev; } else if (cmp < 0) { wxString fullname = dir.dir + *iter + separator; wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname), #ifdef __WXMSW__ -1 #else GetIconIndex(opened_dir, fullname) #endif ); CheckSubdirStatus(newItem, fullname); iter++; inserted = true; } } while (child) { wxTreeItemId sel = GetSelection(); while (sel && sel != child) sel = GetItemParent(sel); wxTreeItemId prev = GetPrevSibling(child); if (!sel) Delete(child); child = prev; } while (iter != dirs.rend()) { wxString fullname = dir.dir + *iter + separator; wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname), #ifdef __WXMSW__ -1 #else GetIconIndex(opened_dir, fullname) #endif ); CheckSubdirStatus(newItem, fullname); iter++; inserted = true; } if (inserted) SortChildren(dir.item); } #ifdef __WXMSW__ SetErrorMode(prevErrorMode); #endif }
//---------------------------------------------------------------------------------------- void PgmCtrl::OnSelChanged(wxMouseEvent& WXUNUSED(event)) { int i; Temp0.Empty(); Temp1.Empty(); #if wxUSE_STATUSBAR pDoc->p_MainFrame->SetStatusText(Temp0,0); #endif // wxUSE_STATUSBAR // Get the Information that we need wxTreeItemId itemId = GetSelection(); TreeData *item = (TreeData *)GetItemData(itemId); if (item != NULL ) { int Treffer = 0; Temp1.Printf(_T("%s"),item->m_desc.c_str()); //-------------------------------------------------------------------------------------- if (Temp1 == _T("Language English")) { Temp0 = _T("std"); p_ProgramCfg->Write(_T("/Local/langid"),Temp0); Temp0 = _("-I-> After a programm restart, the language will be changed to English."); wxMessageBox(Temp0); } if (Temp1 == _T("Language German")) { Temp0 = _T("de"); p_ProgramCfg->Write(_T("/Local/langid"),Temp0); Temp0 = _("-I-> After a programm restart, the language will be changed to German."); wxMessageBox(Temp0); } //-------------------------------------------------------------------------------------- if (Temp1 == _T("wxConfigBase Delete")) { if (p_ProgramCfg->DeleteAll()) // Default Diretory for wxFileSelector Temp0 = _("-I-> wxConfigBase.p_ProgramCfg->DeleteAll() was successful."); else Temp0 = _("-E-> wxConfigBase.p_ProgramCfg->DeleteAll() was not successful !"); wxBell(); // Ding_a_Ling Treffer++; } //-------------------------------------------------------------------------------------- if (Temp1.Contains(_T("ODBC-"))) { Temp1 = Temp1.Mid(5,wxSTRING_MAXLEN); for (i=0;i<pDoc->i_DSN;i++) { if (Temp1 == (pDoc->p_DSN+i)->Dsn) { pDoc->OnChosenDSN(i); } } Treffer++; } //-------------------------------------------------------------------------------------- if (Treffer == 0) { //------------------------------------------------------------------------------------- Temp0.Printf(_("Item '%s': %sselected, %sexpanded, %sbold, %u children (%u immediately under this item)."), item->m_desc.c_str(), bool2String(IsSelected(itemId)), bool2String(IsExpanded(itemId)), bool2String(IsBold(itemId)), GetChildrenCount(itemId), GetChildrenCount(itemId)); LogBuf.Printf(_T("-I-> PgmCtrl::OnSelChanged - %s"),Temp0.c_str()); wxLogMessage( _T("%s"), LogBuf.c_str() ); //------------------------------------------------------------------------------------- } } }
void FolderTree::Refresh() { //Just in case this will take some time //CWaitCursor wait; SetRedraw(FALSE); //Get the item which is currently selected HTREEITEM hSelItem = GetSelectedItem(); tstring sItem; bool bExpanded = false; if (hSelItem) { sItem = ItemToPath(hSelItem); bExpanded = IsExpanded(hSelItem); } theSharedEnumerator.Refresh(); //Remove all nodes that currently exist Clear(); //Display the folder items in the tree if (m_sRootFolder.empty()) { //Should we insert a "My Computer" node if (m_bShowMyComputer) { FolderTreeItemInfo* pItem = new FolderTreeItemInfo; pItem->m_bNetworkNode = false; int nIcon = 0; int nSelIcon = 0; //Get the localized name and correct icons for "My Computer" LPITEMIDLIST lpMCPidl; if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &lpMCPidl))) { SHFILEINFO sfi; if (SHGetFileInfo((LPCTSTR)lpMCPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME)) pItem->m_sRelativePath = sfi.szDisplayName; nIcon = GetIconIndex(lpMCPidl); nSelIcon = GetSelIconIndex(lpMCPidl); //Free up the pidl now that we are finished with it //ASSERT(m_pMalloc); m_pMalloc->Free(lpMCPidl); m_pMalloc->Release(); } //Add it to the tree control m_hMyComputerRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false); SetHasSharedChildren(m_hMyComputerRoot); } //Display all the drives if (!m_bShowMyComputer) DisplayDrives(TVI_ROOT, false); //Display homegroup /*if (m_bDisplayNetwork) { FolderTreeItemInfo* pItem = new FolderTreeItemInfo; //pItem-> = true; int nIcon = 0; int nSelIcon = 0; //Get the localized name and correct icons for "Network Neighborhood" LPITEMIDLIST lpNNPidl; //SHGetKnownFolderIDList(FOLDERID_HomeGroup, 0, NULL, &lpNNPidl); if (SUCCEEDED(SHGetKnownFolderIDList(FOLDERID_HomeGroup, 0, NULL, &lpNNPidl))) { SHFILEINFO sfi; if (SHGetFileInfo((LPCTSTR)lpNNPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME)) pItem->m_sRelativePath = sfi.szDisplayName; nIcon = GetIconIndex(lpNNPidl); nSelIcon = GetSelIconIndex(lpNNPidl); //Free up the pidl now that we are finished with it //ASSERT(m_pMalloc); m_pMalloc->Free(lpNNPidl); m_pMalloc->Release(); } //Add it to the tree control m_hHomegroupRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false, shared); SetHasSharedChildren(m_hHomegroupRoot, shared); //checkRemovedDirs(Util::emptyStringT, TVI_ROOT, shared); }*/ //Also add network neighborhood if requested to do so if (m_bDisplayNetwork) { FolderTreeItemInfo* pItem = new FolderTreeItemInfo; pItem->m_bNetworkNode = true; int nIcon = 0; int nSelIcon = 0; //Get the localized name and correct icons for "Network Neighborhood" LPITEMIDLIST lpNNPidl; if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_NETWORK, &lpNNPidl))) { SHFILEINFO sfi; if (SHGetFileInfo((LPCTSTR)lpNNPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME)) pItem->m_sRelativePath = sfi.szDisplayName; nIcon = GetIconIndex(lpNNPidl); nSelIcon = GetSelIconIndex(lpNNPidl); //Free up the pidl now that we are finished with it //ASSERT(m_pMalloc); m_pMalloc->Free(lpNNPidl); m_pMalloc->Release(); } //Add it to the tree control m_hNetworkRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false); SetHasSharedChildren(m_hNetworkRoot); //checkRemovedDirs(Util::emptyStringT, TVI_ROOT, shared); } } else { DisplayPath(m_sRootFolder, TVI_ROOT, false); } //Reselect the initially selected item if (hSelItem) SetSelectedPath(sItem, bExpanded); //Turn back on the redraw flag SetRedraw(true); }
void CTreeCanvas::RenderObject(bool expanded, HeeksObj* prev_object, bool prev_object_expanded, HeeksObj* object, HeeksObj* next_object, int level) { int save_x = m_xpos; RenderBranchIcons(object, next_object, expanded, level); int label_start_x = m_xpos; // find icon info if(!render_just_for_calculation)m_dc->DrawBitmap(object->GetIcon(), m_xpos, m_ypos); m_xpos += 16; wxString str(object->GetShortStringOrTypeString()); if(!render_just_for_calculation) { if(render_labels && wxGetApp().m_marked_list->ObjectMarked(object)) { m_dc->SetBackgroundMode(wxSOLID); m_dc->SetTextBackground(*wxBLUE); m_dc->SetTextForeground(*wxWHITE); } else { m_dc->SetBackgroundMode(wxTRANSPARENT); m_dc->SetTextForeground(*wxBLACK); } m_dc->DrawText(str, m_xpos, m_ypos); } int text_width = 0; if(render_just_for_calculation || !render_labels) { // just make a guess, we don't have a valid m_dc text_width = 10 * str.Len(); } else { wxSize text_size = m_dc->GetTextExtent(str); text_width = text_size.GetWidth(); } int label_end_x = m_xpos + 8 + text_width; if(!render_just_for_calculation && render_labels) { AddLabelButton(expanded, prev_object, prev_object_expanded, object, next_object, label_start_x, label_end_x); } if(label_end_x > m_max_xpos)m_max_xpos = label_end_x; m_ypos += 18; bool end_object = (next_object == NULL); end_child_list.push_back(end_object); m_xpos = save_x; if(expanded) { HeeksObj* prev_child = NULL; bool prev_child_expanded = false; HeeksObj* child = object->GetFirstChild(); while(child) { HeeksObj* next_child = object->GetNextChild(); bool expanded = IsExpanded(child); RenderObject(expanded, prev_child, prev_child_expanded, child, next_child, level + 1); prev_child = child; prev_child_expanded = expanded; child = next_child; } } end_child_list.pop_back(); }
void CustomDropDown::OnCursorReleasedOutside(const Input::Cursor& cursor) { if (!mItemsList->layout->IsPointInside(o2Input.GetCursorPos()) && IsExpanded()) Collapse(); }