void CWindowsMetaFileControl::AlignBounds(CRect& crBounds) { CRect crClient; GetClientRect(crClient); if (Aspect() == ASPECT_STRETCH) { crBounds = crClient; } else { int nImageWidth = crBounds.Width(); int nImageHeight = crBounds.Height(); int nTargetWidth = crClient.Width(); int nTargetHeight = crClient.Height(); int nNumerator = nTargetWidth; int nDenominator = nImageWidth; if (((long)nTargetWidth*(long)nImageHeight) > ((long)nTargetHeight*(long)nImageWidth)) { nNumerator = nTargetHeight; nDenominator = nImageHeight; } nImageWidth = MulDiv(nImageWidth, nNumerator, nDenominator); nImageHeight = MulDiv(nImageHeight, nNumerator, nDenominator); crBounds.SetRect(0, 0, nImageWidth, nImageHeight); int nXOffset = 0; if (HorizontalAlignment() != HORIZONTAL_ALIGN_LEFT) { nXOffset = nTargetWidth-nImageWidth; if (HorizontalAlignment() == HORIZONTAL_ALIGN_CENTER) { nXOffset /= 2; } } int nYOffset = 0; if (VerticalAlignment() != VERTICAL_ALIGN_TOP) { int nYOffset = nTargetHeight-nImageHeight; if (VerticalAlignment() == VERTICAL_ALIGN_MIDDLE) { nYOffset /= 2; } } crBounds.OffsetRect(nXOffset+crClient.left, nYOffset+crClient.top); } }
void CTextStyle::FromOldStyle(const TextStyle& style) { // Set some defaults. SetDefault(); // Copy the style information over. Font(style.get_face()); Size(MakeFixed(style.get_size(), style.get_size_fraction())); BaseSize(MakeFixed(style.get_base_size(), style.get_base_size_fraction())); Expansion(DivFixed(MakeFixed(style.get_base_size(), style.get_base_size_fraction()), MakeFixed(FONT_EXPANSION_UNIT))); Fill(style.get_pattern(), style.get_color()); Outline(style.get_outline(), style.get_color()); Shadow(style.get_shadow(), style.get_color()); m_Character.m_nEffectsVersion = 1; XFlipped(style.get_xflipped()); YFlipped(style.get_yflipped()); // Color(style.get_color()); Alignment(style.get_line_alignment()); VerticalAlignment(style.get_vertical_alignment()); // Left and right margin should be zero (default) unless set by user. // This fixes a problem converting old warp text boxes - they should // always have zero margins! LeftMargin(0); RightMargin(0); // LeftMargin(PageToInches(style.get_left_margin())); // RightMargin(PageToInches(style.get_right_margin())); LeadingType(LEADING_lines); Leading(MakeFixed(0.875)); Underline(style.UnderlineStyle()); // Update our metrics. UpdateFontMetrics(); }