diff options
author | Stefan Knorr <heinzlesspam@gmail.com> | 2012-07-20 12:22:04 +0200 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-08-02 15:44:50 +0100 |
commit | 77e71450913129fb45da7c6216f2f1b17ce94d6c (patch) | |
tree | b665ad9920e606d5377a5d09565fa305537c29af /cui | |
parent | 57c8c34fcdc2d594d2da3593eb9d86d0daf4e18c (diff) |
Bring background image in About box back & more
+ revert background image removal
+ useful fallback logo text in case rsvg doesn't work on the platform
+ better calculation of dialog size
+ somewhat better high-contrast support
+ slightly modified background image
Change-Id: I1cd77dd7b47eec6bf8709b225ecf0d070f9bb869
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/about.cxx | 110 | ||||
-rw-r--r-- | cui/source/dialogs/about.hrc | 1 | ||||
-rw-r--r-- | cui/source/dialogs/about.src | 7 | ||||
-rw-r--r-- | cui/source/inc/about.hxx | 8 |
4 files changed, 85 insertions, 41 deletions
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index b45f686ed75d..826d872948bf 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -73,8 +73,8 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId) : aVersionText ( this, ResId( ABOUT_VERSION_TEXT, *rId.GetResMgr() ) ), aDescriptionText ( this, ResId( ABOUT_DESCRIPTION_TEXT, *rId.GetResMgr() ) ), aCopyrightText ( this, ResId( ABOUT_COPYRIGHT_TEXT, *rId.GetResMgr() ) ), - aCopyrightTextShadow ( this, ResId( ABOUT_COPYRIGHT_TEXT, *rId.GetResMgr() ) ), aLogoImage ( this ), + aLogoReplacement ( this, ResId( ABOUT_LOGO_REPLACEMENT, *rId.GetResMgr() ) ), aCreditsButton ( this, ResId( ABOUT_BTN_CREDITS, *rId.GetResMgr() ) ), aWebsiteButton ( this, ResId( ABOUT_BTN_WEBSITE, *rId.GetResMgr() ) ), aCancelButton ( this, ResId( ABOUT_BTN_CANCEL, *rId.GetResMgr() ) ), @@ -88,13 +88,14 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId) : m_aDescriptionTextStr(ResId(ABOUT_STR_DESCRIPTION, *rId.GetResMgr())) { // Populate text items + aLogoReplacement.SetText ( utl::ConfigManager::getProductName() ); + aVersionText.SetText( GetVersionString() ); aDescriptionText.SetText( m_aDescriptionTextStr ); rtl::OUString aCopyrightString = GetCopyrightString(); aCopyrightText.SetText( aCopyrightString ); - aCopyrightTextShadow.SetText( aCopyrightString ); StyleControls(); LayoutControls(); @@ -157,15 +158,21 @@ void AboutDialog::StyleControls() { // Make all the controls have a transparent background aLogoImage.SetBackground(); + aLogoReplacement.SetPaintTransparent( sal_True ); aVersionText.SetPaintTransparent( sal_True ); aDescriptionText.SetPaintTransparent( sal_True ); aCopyrightText.SetPaintTransparent( sal_True ); Font aLabelFont = GetSettings().GetStyleSettings().GetLabelFont(); Font aLargeFont = aLabelFont; - aLargeFont.SetSize( Size( 0, aLabelFont.GetSize().Height() * 1.3 ) ); + aLargeFont.SetSize( Size( 0, aLabelFont.GetSize().Height() * 3 ) ); + + // Logo Replacement Text + aLogoReplacement.SetControlFont( aLargeFont ); + aLogoReplacement.SetTextSelectable( sal_False ); // Description Text + aLargeFont.SetSize( Size( 0, aLabelFont.GetSize().Height() * 1.3 ) ); aDescriptionText.SetControlFont( aLargeFont ); aDescriptionText.SetTextSelectable( sal_False ); @@ -175,7 +182,16 @@ void AboutDialog::StyleControls() // Copyright Text aCopyrightText.SetTextSelectable( sal_False ); - aCopyrightTextShadow.SetTextSelectable( sal_False ); + + // If not in high-contrast mode, hard-code colors + if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) ) + { + aLogoReplacement.SetControlForeground( Color( 51, 51, 51 ) ); + aVersionText.SetControlForeground( Color( 102, 102, 102 ) ); + aDescriptionText.SetControlForeground( Color( 51, 51, 51 ) ); + aCopyrightText.SetControlForeground( Color( 102, 102, 102 ) ); + } + aCancelButton.GrabFocus(); } @@ -188,24 +204,43 @@ void AboutDialog::LayoutControls() sal_Int32 aIdealTextWidth = aScreenRect.GetWidth() / 2.4; sal_Int32 aDialogBorder = 12; - Size aDialogSize ( aIdealTextWidth + aDialogBorder * 2, 0); + Size aDialogSize ( aIdealTextWidth + aDialogBorder * 2, 0 ); + + // Preliminarily layout buttons, so we see if we need a wider window + Size aButtonSize; + Point aButtonPos; + sal_Int32 aButtonsWidth = 0; + LayoutButtons( aDialogSize.Width(), aDialogBorder, aButtonPos, aButtonSize, + aButtonsWidth ); + + if (aButtonsWidth > 0) + aDialogSize.Width() += aButtonsWidth; // Render and Position Logo Size aLogoSize( aIdealTextWidth, aIdealTextWidth / 20 ); - Point aLogoPos( aDialogBorder, aDialogBorder ); + Point aLogoPos( 0, 0 ); vcl::RenderGraphicRasterizer aRasterizerLogo = Application::LoadBrandSVG("flat_logo"); if ( !aRasterizerLogo.GetRenderGraphic().IsEmpty() && aRasterizerLogo.GetDefaultSizePixel().Width() > 0 && aRasterizerLogo.GetDefaultSizePixel().Height() > 0 ) { const float aLogoWidthHeightRatio = (float)aRasterizerLogo.GetDefaultSizePixel().Width() / (float)aRasterizerLogo.GetDefaultSizePixel().Height(); - aLogoSize = Size( aIdealTextWidth, aIdealTextWidth / aLogoWidthHeightRatio ); + aLogoSize.Width() = aDialogSize.Width() ; + aLogoSize.Height() = aLogoSize.Width() / aLogoWidthHeightRatio ; aLogoBitmap = aRasterizerLogo.Rasterize( aLogoSize ); aLogoImage.SetImage( Image( aLogoBitmap ) ); aLogoImage.SetPosSizePixel( aLogoPos, aLogoSize ); aLogoImage.Show(); } + else + { + aLogoPos.X() = aDialogBorder; + aLogoPos.Y() = aDialogBorder; + aLogoSize = aLogoReplacement.CalcMinimumSize(); + aLogoSize.Width() = aIdealTextWidth; + aLogoReplacement.SetPosSizePixel( aLogoPos, aLogoSize ); + } // Position version text sal_Int32 aLogoVersionSpacing = aLogoSize.Height() * 0.15; @@ -233,31 +268,42 @@ void AboutDialog::LayoutControls() aCopyrightSize.Width() = aIdealTextWidth; aCopyrightText.SetSizePixel( aCopyrightSize ); - // Layout Buttons - Size aButtonSize; - Point aButtonPos; - sal_Int32 aButtonsWidth = 0; - LayoutButtons( aDialogSize.Width(), aDialogBorder, aCopyrightPos, - aCopyrightText.GetSizePixel().Height(), - aVersionDescriptionSpacing, aButtonPos, aButtonSize, aButtonsWidth ); + // Move buttons into final place + sal_Int32 aButtonPosY = aDialogBorder + aCopyrightPos.Y() + + aCopyrightText.GetSizePixel().Height() + aVersionDescriptionSpacing; + MoveControl(aCreditsButton, 0, aButtonPosY); + MoveControl(aWebsiteButton, 0, aButtonPosY); + MoveControl(aCancelButton, 0, aButtonPosY); + // The centers everything again, if aDialogSize.Width() has become wider + // before; the -20 "fixes" a weird text centering bug + MoveControl(aVersionText, (aDialogSize.Width() - aVersionText.GetSizePixel().Width() - 20)/2, 0); + MoveControl(aDescriptionText, (aDialogSize.Width() - aDescriptionText.GetSizePixel().Width() - 20)/2, 0); + MoveControl(aCopyrightText, (aDialogSize.Width() - aCopyrightText.GetSizePixel().Width() - 20)/2, 0); - // Obtain preliminary dimensions for the dialog + aDialogSize.Height() = aButtonPosY + aButtonSize.Height() + aDialogBorder; - // Make sure the dialog is tall enough - aDialogSize.Height() = aButtonPos.Y() + aButtonSize.Height() + aDialogBorder; - // If dialog isn't wide enough to accommodate the buttons - if (aButtonsWidth > 0) - { - aDialogSize.Width() += aButtonsWidth; - MoveControl(aLogoImage, aButtonsWidth / 2, 0); - MoveControl(aVersionText, aButtonsWidth / 2, 0); - MoveControl(aDescriptionText, aButtonsWidth / 2, 0); - MoveControl(aCopyrightText, aButtonsWidth / 2, 0); - if (aButtonsWidth <= 0) - MoveControl(aCancelButton, aButtonsWidth, 0); + // Layout background image + if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) ) { + vcl::RenderGraphicRasterizer aRasterizerBackground = Application::LoadBrandSVG("shell/about"); + + if ( !aRasterizerBackground.GetRenderGraphic().IsEmpty() && + aRasterizerBackground.GetDefaultSizePixel().Width() > 0 && aRasterizerBackground.GetDefaultSizePixel().Height() > 0 ) + { + const float aBackgroundWidthHeightRatio = (float)aRasterizerBackground.GetDefaultSizePixel().Width() / + (float)aRasterizerBackground.GetDefaultSizePixel().Height(); + Size aBackgroundSize (aDialogSize.Width(), aDialogSize.Width() / aBackgroundWidthHeightRatio ); + + if ( aBackgroundSize.Height() < aDialogSize.Height()) + { + aBackgroundSize.Width() = aDialogSize.Height() * aBackgroundWidthHeightRatio ; + aBackgroundSize.Height() = aDialogSize.Height(); + } + + aBackgroundBitmap = aRasterizerBackground.Rasterize( aBackgroundSize ); + } } SetOutputSizePixel( aDialogSize ); @@ -265,9 +311,8 @@ void AboutDialog::LayoutControls() } void AboutDialog::LayoutButtons(sal_Int32 aDialogWidth, sal_Int32 aDialogBorder, - Point aCopyrightPos, sal_Int32 aCopyrightTextHeight, - sal_Int32 aVersionDescriptionSpacing, Point& aButtonPos, - Size& aButtonSize, sal_Int32& aButtonsWidth ) + Point& aButtonPos, Size& aButtonSize, + sal_Int32& aButtonsWidth ) { // Position credits button sal_Int32 aButtonVPadding = 5; @@ -300,7 +345,7 @@ void AboutDialog::LayoutButtons(sal_Int32 aDialogWidth, sal_Int32 aDialogBorder, } aButtonPos.X() = aDialogBorder; - aButtonPos.Y() = aCopyrightPos.Y() + aCopyrightTextHeight + aVersionDescriptionSpacing; + aButtonPos.Y() = 0; aCreditsButton.SetPosPixel( aButtonPos ); @@ -324,8 +369,7 @@ void AboutDialog::MoveControl(Control& rControl, sal_Int32 X, sal_Int32 Y) void AboutDialog::Paint( const Rectangle& rRect ) { SetClipRegion( rRect ); - Point aPos( 0, 0 ); - + Point aPos ( rRect.GetWidth() - aBackgroundBitmap.GetSizePixel().Width(), rRect.GetHeight() - aBackgroundBitmap.GetSizePixel().Height() ); DrawBitmapEx( aPos, aBackgroundBitmap ); } diff --git a/cui/source/dialogs/about.hrc b/cui/source/dialogs/about.hrc index 0afbe0b8654a..8de642a8eb09 100644 --- a/cui/source/dialogs/about.hrc +++ b/cui/source/dialogs/about.hrc @@ -25,6 +25,7 @@ #define ABOUT_STR_BASED 5 #define ABOUT_STR_BASED_DERIVED 6 #define ABOUT_STR_LINK_CREDITS 8 +#define ABOUT_LOGO_REPLACEMENT 9 #define ABOUT_BTN_CREDITS 10 #define ABOUT_DESCRIPTION_TEXT 11 #define ABOUT_COPYRIGHT_TEXT 12 diff --git a/cui/source/dialogs/about.src b/cui/source/dialogs/about.src index 37938644f83a..70dfd3bc10b9 100644 --- a/cui/source/dialogs/about.src +++ b/cui/source/dialogs/about.src @@ -32,7 +32,7 @@ ModalDialog RID_DEFAULTABOUT OutputSize = TRUE ; Moveable = TRUE ; SVLook = TRUE ; - MultiLineEdit ABOUT_DESCRIPTION_TEXT + MultiLineEdit ABOUT_LOGO_REPLACEMENT { Border = FALSE ; IgnoreTab = TRUE ; @@ -42,16 +42,17 @@ ModalDialog RID_DEFAULTABOUT CENTER = TRUE ; RIGHT = FALSE ; }; - MultiLineEdit ABOUT_COPYRIGHT_TEXT + MultiLineEdit ABOUT_DESCRIPTION_TEXT { Border = FALSE ; IgnoreTab = TRUE ; ReadOnly = TRUE ; + AutoVScroll = TRUE ; LEFT = FALSE ; CENTER = TRUE ; RIGHT = FALSE ; }; - MultiLineEdit ABOUT_COPYRIGHT_TEXT_SHADOW + MultiLineEdit ABOUT_COPYRIGHT_TEXT { Border = FALSE ; IgnoreTab = TRUE ; diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx index 51040753a8a9..1a4e75b19a47 100644 --- a/cui/source/inc/about.hxx +++ b/cui/source/inc/about.hxx @@ -46,11 +46,12 @@ private: BitmapEx aBackgroundBitmap; BitmapEx aLogoBitmap; + MultiLineEdit aVersionText; MultiLineEdit aDescriptionText; MultiLineEdit aCopyrightText; - MultiLineEdit aCopyrightTextShadow; FixedImage aLogoImage; + MultiLineEdit aLogoReplacement; PushButton aCreditsButton; PushButton aWebsiteButton; CancelButton aCancelButton; @@ -68,10 +69,7 @@ private: void StyleControls(); void LayoutControls(); void LayoutButtons(sal_Int32 aContentWidth, sal_Int32 aDialogBorder, - Point aDescriptionPos, - sal_Int32 aDescriptionTextHeight, - sal_Int32 aVersionDescriptionSpacing, Point& aButtonPos, - Size& aButtonSize, sal_Int32& aButtonsWidth ); + Point& aButtonPos, Size& aButtonSize, sal_Int32& aButtonsWidth ); void MoveControl(Control& rControl, sal_Int32 X, sal_Int32 Y); rtl::OUString GetBuildId(); rtl::OUString GetVersionString(); |