From cd7f8fb9ae6412887d11b82ad1c9195404e87033 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 24 Sep 2015 12:32:14 +0200 Subject: Improve preview of theme color sets - add color set name Change-Id: I1f7b3668ba9dfbab1da283741e99754de2d6be47 --- sw/source/uibase/sidebar/ThemePanel.cxx | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index a6db69e1f83f..256ab5b2e06c 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -401,17 +401,39 @@ BitmapEx GenerateColorPreview(const svx::ColorSet& rColorSet) { ScopedVclPtrInstance pVirtualDev(*Application::GetDefaultDevice()); sal_Int32 nScaleFactor = pVirtualDev->GetDPIScaleFactor(); - long BORDER = 2 * nScaleFactor; - long SIZE = 12 * nScaleFactor; + long BORDER = 3 * nScaleFactor; + long SIZE = 14 * nScaleFactor; + long LABEL_HEIGHT = 16 * nScaleFactor; + long LABEL_TEXT_HEIGHT = 14 * nScaleFactor; - Size aSize(BORDER * 7 + SIZE * 6, BORDER * 3 + SIZE * 2); + Size aSize(BORDER * 7 + SIZE * 6 + BORDER * 2, BORDER * 3 + SIZE * 2 + LABEL_HEIGHT); pVirtualDev->SetOutputSizePixel(aSize); + pVirtualDev->SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetFaceColor())); + pVirtualDev->Erase(); long x = BORDER; - long y1 = BORDER; + long y1 = BORDER + LABEL_HEIGHT; long y2 = y1 + SIZE + BORDER; pVirtualDev->SetLineColor(COL_LIGHTGRAY); + pVirtualDev->SetFillColor(COL_LIGHTGRAY); + Rectangle aNameRect(Point(0, 0), Size(aSize.Width(), LABEL_HEIGHT)); + pVirtualDev->DrawRect(aNameRect); + + vcl::Font aFont; + OUString aName = rColorSet.getName(); + aFont.SetSize(Size(0, LABEL_TEXT_HEIGHT)); + pVirtualDev->SetFont(aFont); + + Size aTextSize(pVirtualDev->GetTextWidth(aName), pVirtualDev->GetTextHeight()); + + Point aPoint((aNameRect.GetWidth() / 2.0) - (aTextSize.Width() / 2.0), + (aNameRect.GetHeight() / 2.0) - (aTextSize.Height() / 2.0)); + + pVirtualDev->DrawText(aPoint, aName); + + pVirtualDev->SetLineColor(COL_LIGHTGRAY); + pVirtualDev->SetFillColor(); for (sal_uInt32 i = 0; i < 12; i += 2) { @@ -422,6 +444,8 @@ BitmapEx GenerateColorPreview(const svx::ColorSet& rColorSet) pVirtualDev->DrawRect(Rectangle(x, y2, x + SIZE, y2 + SIZE)); x += SIZE + BORDER; + if (i == 2 || i == 8) + x += BORDER; } return pVirtualDev->GetBitmapEx(Point(), aSize); @@ -456,6 +480,7 @@ ThemePanel::ThemePanel(vcl::Window* pParent, get(mpValueSetColors, "valueset_colors"); get(mpApplyButton, "apply"); + mpValueSetColors->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); mpValueSetColors->SetColCount(2); mpValueSetColors->SetLineCount(4); -- cgit v1.2.3