void CEquationEditorWindow::ZoomDFS( float coef, std::shared_ptr<IBaseExprModel> node ) { for( auto child : node->GetChildren() ) { ZoomDFS( coef, child ); } CRect rect = node->GetRect(); int heightNew = ( int ) rect.GetHeight() * coef; int widthNew = ( int ) rect.GetWidth() * coef; rect.Set( rect.Left(), rect.Top(), rect.Left() + widthNew, rect.Top() + heightNew ); node->SetRect( rect ); std::wstring text = node->GetText(); if( text.length() > 0 ) { std::shared_ptr<CEditControlModel> eNode = std::dynamic_pointer_cast<CEditControlModel>(node); std::vector<int> symbolsWidthsNew; for( int i = 0; i < text.length(); i++ ) { int symbolWidth = GetSymbolWidth( text[i], heightNew ); symbolsWidthsNew.push_back( symbolWidth ); } eNode->UpdateSymbolsWidths( symbolsWidthsNew ); } }
void C4MenuItem::DrawElement(C4TargetFacet &cgo) { // get target pos C4Facet cgoOut(cgo.Surface, cgo.TargetX + rcBounds.x, cgo.TargetY + rcBounds.y, rcBounds.Wdt, rcBounds.Hgt); // Select mark if (iStyle!=C4MN_Style_Info) if (fSelected && TextDisplayProgress) pDraw->DrawBoxDw(cgo.Surface, cgoOut.X, cgoOut.Y, cgoOut.X + cgoOut.Wdt - 1, cgoOut.Y + cgoOut.Hgt - 1, C4RGB(0xca, 0, 0)); // Symbol/text areas C4Facet cgoItemSymbol,cgoItemText; cgoItemSymbol=cgoItemText=cgoOut; int32_t iSymWidth; if ((iSymWidth = GetSymbolWidth(cgoItemText.Hgt))) { // get symbol area cgoItemSymbol=cgoItemText.Truncate(C4FCT_Left, iSymWidth); } // cgoItemSymbol.Hgt is 0. This means rcBounds.Hgt is 0. That // makes no sense at this point, so let's just draw in a // square area at item y. C4Facet cgoSymbolOut(cgoItemSymbol.Surface, cgoItemSymbol.X, cgoItemSymbol.Y, cgoItemSymbol.Wdt, cgoItemSymbol.Wdt); // Draw item symbol: // Draw if there is no text progression at all (TextDisplayProgress==-1, or if it's progressed far enough already (TextDisplayProgress>0) if(pSymbolObj && TextDisplayProgress) { pSymbolObj->DrawPicture(cgoSymbolOut, false, NULL); } else if (pSymbolGraphics && TextDisplayProgress) { pSymbolGraphics->Draw(cgoSymbolOut, dwSymbolClr ? dwSymbolClr : 0xffffffff, NULL, 0, 0, NULL); } else if (Symbol.Surface && TextDisplayProgress) Symbol.DrawClr(cgoItemSymbol, true, dwSymbolClr); // Draw item text pDraw->StorePrimaryClipper(); pDraw->SubPrimaryClipper(cgoItemText.X, cgoItemText.Y, cgoItemText.X+cgoItemText.Wdt-1, cgoItemText.Y+cgoItemText.Hgt-1); switch (iStyle) { case C4MN_Style_Context: pDraw->TextOut(Caption,::GraphicsResource.FontRegular, 1.0, cgoItemText.Surface,cgoItemText.X,cgoItemText.Y,C4Draw::DEFAULT_MESSAGE_COLOR,ALeft); break; case C4MN_Style_Info: { StdStrBuf sText; ::GraphicsResource.FontRegular.BreakMessage(InfoCaption, cgoItemText.Wdt, &sText, true); pDraw->TextOut(sText.getData(), ::GraphicsResource.FontRegular, 1.0, cgoItemText.Surface,cgoItemText.X,cgoItemText.Y); break; } case C4MN_Style_Dialog: { // cut buffer at text display pos char cXChg='\0'; int iStopPos = 0; if (TextDisplayProgress>-1) { iStopPos = std::min<int>(TextDisplayProgress, strlen(Caption)); cXChg = Caption[iStopPos]; Caption[iStopPos] = '\0'; } // display broken text StdStrBuf sText; ::GraphicsResource.FontRegular.BreakMessage(Caption, cgoItemText.Wdt, &sText, true); pDraw->TextOut(sText.getData(),::GraphicsResource.FontRegular, 1.0, cgoItemText.Surface,cgoItemText.X,cgoItemText.Y); // restore complete text if (cXChg) Caption[iStopPos] = cXChg; break; } } pDraw->RestorePrimaryClipper(); // Draw count if (Count!=C4MN_Item_NoCount) { char szCount[10+1]; sprintf(szCount,"%ix",Count); pDraw->TextOut(szCount, ::GraphicsResource.FontRegular, 1.0, cgoItemText.Surface, cgoItemText.X+cgoItemText.Wdt-1, cgoItemText.Y+cgoItemText.Hgt-1-::GraphicsResource.FontRegular.GetLineHeight(), C4Draw::DEFAULT_MESSAGE_COLOR, ARight); } }