/** Get the full path to hItem, reversing up the tree to a root item. This function add's each found item to a VPtrArray collection object. Traverse the array backwards to get the forward path, or use GetPath(). Return value is the number of item in the array, not the number of items added. The only time this function returns the number of items added is if the array is 0 size when called.*/ VPTRARRAY_INDEX GetReversePath( VPtrArray& array, HTREEITEM hItem = NULL) { /* Starting at hItem, reverse tree until a root item is found to build reverse order path.*/ HTREEITEM hParent = ItemOrSelection(hItem); while ( hParent ) { /* Add to array.*/ if ( array.Add(hParent) != -1 ) { /* If this item is a root item, we are done. Call virtual function to determine.*/ if ( IsRootItem(hParent) ) break; else hParent = GetParent(hParent); } else break; } return array.Size(); }
void CItem::DrawAdditionalState(CDC *pdc, const CRect& rcLabel) const { if (!IsRootItem() && this == GetDocument()->GetZoomItem()) { CRect rc = rcLabel; rc.InflateRect(1, 0); rc.bottom++; CSelectStockObject sobrush(pdc, NULL_BRUSH); CPen pen(PS_SOLID, 2, GetDocument()->GetZoomColor()); CSelectObject sopen(pdc, &pen); pdc->Rectangle(rc); } }
wxObject* wxsPanel::OnBuildPreview(wxWindow* Parent,long Flags) { wxWindow* NewItem = 0; if ( Flags & pfExact ) { NewItem = new wxPanel(Parent,GetId(),Pos(Parent),Size(Parent),Style()); } else { NewItem = new PanelPreview(Parent,GetId(),Pos(Parent),Size(Parent),Style(),IsRootItem()); } NewItem->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); SetupWindow(NewItem,Flags); AddChildrenPreview(NewItem,Flags); return NewItem; }
void wxsDialog::OnBuildCreatingCode() { switch ( GetLanguage() ) { case wxsCPP: { AddHeader(_T("<wx/dialog.h>"),GetInfo().ClassName,hfInPCH); Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str()); if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) ) { Codef(_T("%ASetClientSize(%S);\n")); } if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) ) { Codef(_T("%AMove(%P);\n")); } BuildSetupWindowCode(); AddChildrenCode(); if ( Centered ) { Codef(_T("%ACenter();\n")); } return; } case wxsUnknownLanguage: // fall-through default: { wxsCodeMarks::Unknown(_T("wxsDialog::OnBuildCreatingCode"),GetLanguage()); } } }
void wxsFrame::OnBuildCreatingCode() { switch ( GetLanguage() ) { case wxsCPP: { AddHeader(_T("<wx/frame.h>"),GetInfo().ClassName,hfInPCH); #if wxCHECK_VERSION(2, 9, 0) Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str()); #else Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.c_str()); #endif if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) ) { Codef(_T("%ASetClientSize(%S);\n")); } if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) ) { Codef(_T("%AMove(%P);\n")); } BuildSetupWindowCode(); if ( !Icon.IsEmpty() ) { AddHeader(_T("<wx/icon.h>"), GetInfo().ClassName, hfLocal); Codef( _T("{\n") _T("\twxIcon FrameIcon;\n") _T("\tFrameIcon.CopyFromBitmap(%i);\n") _T("\t%ASetIcon(FrameIcon);\n") _T("}\n"), &Icon,_T("wxART_FRAME_ICON")); } AddChildrenCode(); if ( Centered ) { Codef(_T("%ACenter();\n")); } return; } default: { wxsCodeMarks::Unknown(_T("wxsFrame::OnBuildCreatingCode"),GetLanguage()); } } }
void wxsContainer::AddChildrenPreview(wxWindow* This,long Flags) { for ( int i=0; i<GetChildCount(); i++ ) { wxsItem* Child = GetChild(i); wxObject* ChildPreviewAsObject = Child->BuildPreview(This,Flags); if ( Child->GetType() == wxsTSizer ) { wxSizer* ChildPreviewAsSizer = wxDynamicCast(ChildPreviewAsObject,wxSizer); if ( ChildPreviewAsSizer ) { This->SetSizer(ChildPreviewAsSizer); } } } if ( IsRootItem() ) { // Adding all tools before calling Fit and SetSizeHints() wxsItemResData* Data = GetResourceData(); if ( Data ) { for ( int i=0; i<Data->GetToolsCount(); i++ ) { Data->GetTool(i)->BuildPreview(This,Flags); } } } for ( int i=0; i<GetChildCount(); i++ ) { wxsItem* Child = GetChild(i); if ( Child->GetType() == wxsTSizer ) { wxObject* ChildPreviewAsObject = Child->GetLastPreview(); wxSizer* ChildPreviewAsSizer = wxDynamicCast(ChildPreviewAsObject,wxSizer); wxWindow* ChildPreviewAsWindow = wxDynamicCast(ChildPreviewAsObject,wxWindow); if ( ChildPreviewAsSizer ) { // Child preview was created directly as sizer, we use it to // call Fit() and SetSizeHints() directly if ( GetBaseProps()->m_Size.IsDefault ) { ChildPreviewAsSizer->Fit(This); } ChildPreviewAsSizer->SetSizeHints(This); } else if ( ChildPreviewAsWindow ) { // Preview of sizer is given actually as some kind of panel which paints // some extra data of sizer. So we have to create out own sizer to call // Fit and SetSizeHints wxSizer* IndirectSizer = new wxBoxSizer(wxHORIZONTAL); IndirectSizer->Add(ChildPreviewAsWindow,1,wxEXPAND,0); This->SetSizer(IndirectSizer); if ( GetBaseProps()->m_Size.IsDefault ) { IndirectSizer->Fit(This); } IndirectSizer->SetSizeHints(This); } } } }
void wxsContainer::AddChildrenCode() { switch ( GetLanguage() ) { case wxsCPP: { wxsCoderContext* Context = GetCoderContext(); if ( !Context ) return; // Update parent in context and clear flRoot flag wxString PreviousParent = Context->m_WindowParent; Context->m_WindowParent = Codef(Context,_T("%O")); for ( int i=0; i<GetChildCount(); i++ ) { wxsItem* Child = GetChild(i); Child->BuildCode(Context); if ( Child->GetType() == wxsTSizer ) { // TODO: Is this right place to set-up sizer ? Codef(_T("%ASetSizer(%o);\n"),i); } } if ( IsRootItem() ) { // Adding all tools before calling Fit and SetSizeHints() wxsItemResData* Data = GetResourceData(); if ( Data ) { for ( int i=0; i<Data->GetToolsCount(); i++ ) { Data->GetTool(i)->BuildCode(Context); } } } for ( int i=0; i<GetChildCount(); i++ ) { wxsItem* Child = GetChild(i); if ( Child->GetType() == wxsTSizer ) { if ( GetBaseProps()->m_Size.IsDefault ) { wxString ChildAccessPrefix = Child->GetAccessPrefix(GetLanguage()); Codef(_T("%sFit(%O);\n"),ChildAccessPrefix.wx_str()); Codef(_T("%sSetSizeHints(%O);\n"),ChildAccessPrefix.wx_str()); } else { wxString ChildVarName = Child->GetVarName(); Codef(_T("SetSizer(%s);\n"), ChildVarName.wx_str()); Codef(_T("Layout();\n")); } } } Context->m_WindowParent = PreviousParent; return; } case wxsUnknownLanguage: default: { wxsCodeMarks::Unknown(_T("wxsContainer::AddChildrenCode"),GetLanguage()); } } }
CString CItem::GetText(int subitem) const { CString s; switch (subitem) { case COL_NAME: s = m_name; break; case COL_SUBTREEPERCENTAGE: if (IsDone()) { ASSERT(m_readJobs == 0); //s = "ok"; } else { if (m_readJobs == 1) s.LoadString(IDS_ONEREADJOB); else s.FormatMessage(IDS_sREADJOBS, FormatCount(m_readJobs)); } break; case COL_PERCENTAGE: if (GetOptions()->IsShowTimeSpent() && MustShowReadJobs() || IsRootItem()) { s.Format(_T("[%s s]"), FormatMilliseconds(GetTicksWorked())); } else { s.Format(_T("%s%%"), FormatDouble(GetFraction() * 100)); } break; case COL_SUBTREETOTAL: s = FormatBytes(GetSize()); break; case COL_ITEMS: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetItemsCount()); break; case COL_FILES: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetFilesCount()); break; case COL_SUBDIRS: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetSubdirsCount()); break; case COL_LASTCHANGE: if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) { s = FormatFileTime(m_lastChange); } break; case COL_ATTRIBUTES: if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN && GetType() != IT_MYCOMPUTER && GetType() != IT_FILESFOLDER) { s = FormatAttributes(GetAttributes()); } break; default: ASSERT(0); break; } return s; }
// 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; }