BOOL CUploadTipCtrl::OnPrepare() { CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 100 ) ) return FALSE; CalcSizeHelper(); return ( m_sz.cx > 0 ); }
BOOL CNeighbourTipCtrl::OnPrepare() { CSingleLock pLock( &Network.m_pSection ); if ( ! pLock.Lock( 100 ) ) return FALSE; const CNeighbour* pNeighbour = Neighbours.Get( m_nNeighbour ); if ( pNeighbour == NULL ) return FALSE; CalcSizeHelper(); // CoolInterface.LoadIconsTo( m_pProtocols, protocolIDs, FALSE, LVSIL_NORMAL ); return TRUE; }
BOOL CMatchTipCtrl::OnPrepare() { if ( ! Settings.Interface.TipSearch ) return FALSE; if ( m_pHit ) LoadFromHit(); else if ( m_pFile ) LoadFromFile(); else return FALSE; CalcSizeHelper(); return ( m_sz.cx > 0 ); }
BOOL CAlbumTipCtrl::OnPrepare() { CSingleLock pLock( &Library.m_pSection ); if ( ! pLock.Lock( 250 ) ) return FALSE; if ( ! m_pAlbumFolder || ! LibraryFolders.CheckAlbum( m_pAlbumFolder ) ) return FALSE; // Basic data m_sName = m_pAlbumFolder->m_sName; m_sType = L"Virtual Folder"; m_nIcon32 = 0; m_nIcon48 = 0; m_bCollection = bool( m_pAlbumFolder->m_oCollSHA1 ); // Metadata m_pMetadata.Clear(); if ( m_pAlbumFolder->m_pSchema != NULL ) { CString strText; LPCTSTR pszColon = _tcschr( m_pAlbumFolder->m_pSchema->m_sTitle, ':' ); m_sType = pszColon ? pszColon + 1 : m_pAlbumFolder->m_pSchema->m_sTitle; LoadString( strText, IDS_TIP_FOLDER ); if ( Settings.General.LanguageRTL ) m_sType = L"\x202A" + m_sType + L" \x200E" + strText; else m_sType += L" " + strText; m_nIcon48 = m_pAlbumFolder->m_pSchema->m_nIcon48; m_nIcon32 = m_pAlbumFolder->m_pSchema->m_nIcon32; if ( m_pAlbumFolder->m_pXML != NULL ) { m_pMetadata.Setup( m_pAlbumFolder->m_pSchema, FALSE ); m_pMetadata.Combine( m_pAlbumFolder->m_pXML ); m_pMetadata.Clean(); } } CalcSizeHelper(); return m_sz.cx > 0; }
BOOL CLibraryTipCtrl::OnPrepare() { CSingleLock oLock( &Library.m_pSection ); if ( ! oLock.Lock( 300 ) ) return FALSE; CLibraryFile* pLibraryFile = NULL; CPeerProjectFile* pFile = NULL; if ( m_nFileIndex ) { pLibraryFile = Library.LookupFile( m_nFileIndex ); pFile = static_cast< CPeerProjectFile* >( pLibraryFile ); } else if ( m_pFile ) { pLibraryFile = LibraryMaps.LookupFileByHash( m_pFile ); pFile = m_pFile; } else return FALSE; if ( ! pFile ) return FALSE; CSingleLock pLock( &m_pSection, TRUE ); // Basic data m_sName = pFile->m_sName.IsEmpty() ? pFile->m_sPath : pFile->m_sName; if ( pLibraryFile ) m_sPath = pLibraryFile->GetPath(); else m_sPath.Empty(); m_sSize = Settings.SmartVolume( pFile->GetSize() ); if ( pLibraryFile ) m_sFolder = pLibraryFile->GetFolder(); else m_sFolder.Empty(); // Ghost files have no location // Type information and icons m_sType = ShellIcons.GetTypeString( m_sName ); m_nIcon = ShellIcons.Get( m_sPath.IsEmpty() ? m_sName : m_sPath, 48 ); // URN if ( Settings.General.GUIMode != GUI_BASIC ) { m_sSHA1 = pFile->m_oSHA1.toShortUrn(); m_sTTH = pFile->m_oTiger.toShortUrn(); m_sED2K = pFile->m_oED2K.toShortUrn(); m_sBTH = pFile->m_oBTH.toShortUrn(); m_sMD5 = pFile->m_oMD5.toShortUrn(); } else // Basic Mode { m_sSHA1.Empty(); m_sTTH.Empty(); m_sED2K.Empty(); m_sBTH.Empty(); m_sMD5.Empty(); } // Metadata CSchemaPtr pSchema = pLibraryFile ? pLibraryFile->m_pSchema : NULL; m_pMetadata.Clear(); if ( ! m_sFolder.IsEmpty() ) m_pMetadata.Add( LoadString( IDS_TIP_LOCATION ), m_sFolder ); if ( ! m_sType.IsEmpty() ) m_pMetadata.Add( LoadString( IDS_TIP_TYPE ), m_sType ); if ( m_sSize ) m_pMetadata.Add( LoadString( IDS_TIP_SIZE ), m_sSize ); if ( pLibraryFile ) { CString strData, strFormat = LoadString( IDS_TIP_TODAYTOTAL ); strData.Format( strFormat, pLibraryFile->m_nHitsToday, pLibraryFile->m_nHitsTotal ); m_pMetadata.Add( LoadString( IDS_TIP_HITS ), strData ); strData.Format( strFormat, pLibraryFile->m_nUploadsToday, pLibraryFile->m_nUploadsTotal ); m_pMetadata.Add( LoadString( IDS_TIP_UPLOADS ), strData ); if ( pLibraryFile->m_pMetadata && pSchema ) { m_pMetadata.Setup( pSchema, FALSE ); m_pMetadata.Combine( pLibraryFile->m_pMetadata ); m_pMetadata.Clean(); } } oLock.Unlock(); CalcSizeHelper(); return m_sz.cx > 0; }
DWORD CRichtextLayout::CalcSize(CCalcInfo* pci, SIZE* psize, SIZE* psizeDefault) { Assert(ElementOwner()); Assert(pci); Assert(psize); CScopeFlag csfCalcing(this); CRichtext* pTextarea = DYNCAST(CRichtext, ElementOwner()); Listen(); CSaveCalcInfo sci(pci, this); CSize sizeOriginal; DWORD grfReturn; GetSize(&sizeOriginal); if(_fForceLayout) { pci->_grfLayout |= LAYOUT_FORCE; _fForceLayout = FALSE; } grfReturn = (pci->_grfLayout & LAYOUT_FORCE); if(pci->_grfLayout & LAYOUT_FORCE) { _fSizeThis = TRUE; _fAutoBelow = FALSE; _fPositionSet = FALSE; _fContainsRelative = FALSE; } BOOL fRecalcText = FALSE; BOOL fNormalMode = pci->_smMode==SIZEMODE_NATURAL || pci->_smMode==SIZEMODE_SET || pci->_smMode==SIZEMODE_FULLSIZE; BOOL fWidthChanged = (fNormalMode ? psize->cx!=sizeOriginal.cx : FALSE); BOOL fHeightChanged = (fNormalMode ? psize->cy!=sizeOriginal.cy : FALSE); fRecalcText = (fNormalMode && (IsDirty() || _fSizeThis || fWidthChanged || fHeightChanged)) || (pci->_grfLayout&LAYOUT_FORCE) || (pci->_smMode==SIZEMODE_MMWIDTH && !_fMinMaxValid) || (pci->_smMode==SIZEMODE_MINWIDTH && (!_fMinMaxValid || _xMin<0)); // If this site is in need of sizing, then size it if(fRecalcText) { //BUGBUG (gideons) should modify Cols and Rows if user resizes CUnitValue uvWidth = pTextarea->GetFirstBranch()->GetCascadedwidth(); CUnitValue uvHeight = pTextarea->GetFirstBranch()->GetCascadedheight(); int charX = 1; int charY = 1; // If dirty, ensure display tree nodes exist if(_fSizeThis && (EnsureDispNode(pci, (grfReturn&LAYOUT_FORCE))==S_FALSE)) { grfReturn |= LAYOUT_HRESIZE | LAYOUT_VRESIZE; } SetWrap(); _fContentsAffectSize = FALSE; if(uvWidth.IsNullOrEnum() || uvHeight.IsNullOrEnum()) { charX = pTextarea->GetAAcols(); Assert(charX > 0); charY = pTextarea->GetAArows(); Assert(charY > 0); } grfReturn |= CalcSizeHelper(pci, charX, charY, psize); if(fNormalMode) { grfReturn |= super::CalcSize(pci, psize); } if(psizeDefault) { *psizeDefault = *psize; } // If size changes occurred, size the display nodes if(fNormalMode && grfReturn&(LAYOUT_FORCE|LAYOUT_HRESIZE|LAYOUT_VRESIZE)) { SizeDispNode(pci, *psize); SizeContentDispNode(CSize(_dp.GetMaxWidth(), _dp.GetHeight())); } if(pci->_smMode == SIZEMODE_MMWIDTH) { // for minmax mode min width is returned in cy. _xMin = psize->cy = psize->cx; } } else { grfReturn = super::CalcSize(pci, psize); } return grfReturn; }
BOOL CLibraryTipCtrl::OnPrepare() { { CQuickLock oLock( Library.m_pSection ); CLibraryFile* pFile = Library.LookupFile( (DWORD)m_pContext ); if ( pFile == NULL ) return FALSE; CSingleLock pLock( &m_pSection, TRUE ); // Basic data m_sName = pFile->m_sName; m_sPath = pFile->GetPath(); m_nIndex = pFile->m_nIndex; m_sSize = Settings.SmartVolume( pFile->GetSize(), FALSE ); m_nIcon = 0; if ( pFile->m_pFolder != NULL ) m_sFolder = pFile->m_pFolder->m_sPath; m_sType.Empty(); m_sSHA1.Empty(); m_sTTH.Empty(); m_sED2K.Empty(); // Type information and icons m_sType = ShellIcons.GetTypeString( m_sName ); m_nIcon = ShellIcons.Get( m_sName, 48 ); // URN if ( pFile->m_bSHA1 && Settings.General.GUIMode != GUI_BASIC) { m_sSHA1 = _T("sha1:") + CSHA::HashToString( &pFile->m_pSHA1 ); } if ( pFile->m_bTiger && Settings.General.GUIMode != GUI_BASIC) { m_sTTH = _T("tree:tiger/:") + CTigerNode::HashToString( &pFile->m_pTiger ); } if ( pFile->m_bED2K && Settings.General.GUIMode != GUI_BASIC) { m_sED2K = _T("ed2k:") + CED2K::HashToString( &pFile->m_pED2K ); } // Metadata CSchema* pSchema = pFile->m_pSchema; CString str, sData, sFormat; m_pMetadata.Clear(); LoadString( str, IDS_TIP_LOCATION ); m_pMetadata.Add( str, m_sFolder ); LoadString( str, IDS_TIP_TYPE ); m_pMetadata.Add( str, m_sType ); LoadString( str, IDS_TIP_SIZE ); m_pMetadata.Add( str, m_sSize ); LoadString( sFormat, IDS_TIP_TODAYTOTAL ); sData.Format( sFormat, pFile->m_nHitsToday, pFile->m_nHitsTotal ); LoadString( str, IDS_TIP_HITS ); m_pMetadata.Add( str, sData ); sData.Format( sFormat, pFile->m_nUploadsToday, pFile->m_nUploadsTotal ); LoadString( str, IDS_TIP_UPLOADS ); m_pMetadata.Add( str, sData ); if ( pFile->m_pMetadata && pSchema ) { m_pMetadata.Setup( pSchema, FALSE ); m_pMetadata.Combine( pFile->m_pMetadata ); m_pMetadata.Clean(); } } CalcSizeHelper(); return m_sz.cx > 0; }