LibreOffice Module vcl (master)  1
aboutdialog.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <vcl/layout.hxx>
11 #include <vcl/svapp.hxx>
12 #include <vcl/settings.hxx>
13 #include <aboutdialog.hxx>
14 
15 using namespace ::com::sun::star::uno;
16 using namespace ::com::sun::star::beans;
17 using namespace ::com::sun::star;
18 using namespace vcl;
19 
21  : Dialog(pParent, nStyle, eFlag)
22  , m_xBuilder(new VclBuilder(this, getUIRootDir(), "vcl/ui/aboutbox.ui"))
23 {
24  m_xBuilder->get(m_xContents, "about");
25  m_xBuilder->get(m_xLogoReplacement, "logoreplacement");
26  m_xBuilder->get(m_xLogoImage, "logo");
27  m_xBuilder->get(m_xVersion, "version");
28  m_xBuilder->get(m_xDescriptionText, "description");
29  m_xBuilder->get(m_xCopyrightText, "copyright");
30  m_xBuilder->get(m_xBuildIdLink, "buildIdLink");
31 
32  // tdf#127148 so tabbing into the widget will auto select-all
33  AllSettings aSettings = m_xVersion->GetSettings();
34  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
35  aStyleSettings.SetSelectionOptions(aStyleSettings.GetSelectionOptions()
37  aSettings.SetStyleSettings(aStyleSettings);
38  m_xVersion->SetSettings(aSettings, true);
39 
40 #ifndef MACOSX
42 #endif
43 }
44 
46 {
48 
49  // move it now that the content area exists
50  m_xContents->SetParent(pBox);
51 
52  StyleControls();
53 }
54 
56 
58 {
59  m_xVersion.clear();
66  m_xBuilder.reset();
68 }
69 
71 {
72  // Make all the controls have a transparent background
78 
79  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
80 
81  const vcl::Font& aLabelFont = rStyleSettings.GetLabelFont();
82  vcl::Font aLargeFont = aLabelFont;
83  aLargeFont.SetFontSize(Size(0, aLabelFont.GetFontSize().Height() * 3));
84 
85  // Logo Replacement Text
87 
88  // Description Text
89  aLargeFont.SetFontSize(Size(0, aLabelFont.GetFontSize().Height() * 1.3));
91 }
92 
93 void AboutDialog::SetLogo(const Image& rLogoBitmap)
94 {
95  if (!rLogoBitmap)
96  {
97  m_xLogoImage->Hide();
99  }
100  else
101  {
103  m_xLogoImage->SetImage(rLogoBitmap);
104  m_xLogoImage->Show();
105  }
106 }
107 
108 void AboutDialog::SetBackground(const Image& rBackgroundBitmap)
109 {
110  m_aBackgroundBitmap = rBackgroundBitmap.GetBitmapEx();
111  Invalidate();
112 }
113 
114 void AboutDialog::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/)
115 {
116  Size aSize(GetOutputSizePixel());
117  Point aPos(aSize.Width() - m_aBackgroundBitmap.GetSizePixel().Width(),
119 
120  rRenderContext.DrawBitmapEx(aPos, m_aBackgroundBitmap);
121 }
122 
123 bool AboutDialog::set_property(const OString& rKey, const OUString& rValue)
124 {
125  if (rKey == "version")
126  m_xVersion->SetText(rValue);
127  else if (rKey == "copyright")
128  m_xCopyrightText->SetText(rValue);
129  else if (rKey == "comments")
130  m_xDescriptionText->SetText(rValue);
131  else if (rKey == "website")
132  m_xBuildIdLink->SetURL(rValue);
133  else if (rKey == "website_label")
134  m_xBuildIdLink->SetText(rValue);
135  else if (rKey == "program_name")
136  m_xLogoReplacement->SetText(rValue);
137  else
138  return Dialog::set_property(rKey, rValue);
139  return true;
140 }
141 
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
long Width() const
void SetFontSize(const Size &)
Definition: font/font.cxx:117
BitmapEx m_aBackgroundBitmap
Definition: aboutdialog.hxx:24
void SetStyleSettings(const StyleSettings &rSet)
long Height() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SelectionOptions GetSelectionOptions() const
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:705
VclPtr< FixedText > m_xDescriptionText
Definition: aboutdialog.hxx:30
virtual void SetSettings(const AllSettings &rSettings) override
VclPtr< FixedText > m_xCopyrightText
Definition: aboutdialog.hxx:31
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: aboutdialog.cxx:57
virtual bool set_property(const OString &rKey, const OUString &rValue) override
sal_Int64 WinBits
void SetBackground()
void SetControlFont()
Definition: window2.cxx:409
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dialog.cxx:608
const vcl::Font & GetLabelFont() const
VclPtr< VclMultiLineEdit > m_xVersion
Definition: aboutdialog.hxx:28
void Hide()
Definition: window.hxx:934
std::unique_ptr< VclBuilder > m_xBuilder
Definition: aboutdialog.hxx:26
void clear()
Definition: vclptr.hxx:190
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: dialog.cxx:1330
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
void SetParent(vcl::Window *pNewParent)
Definition: stacking.cxx:842
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1160
VclPtr< VclContainer > m_xContents
Definition: aboutdialog.hxx:27
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
const Size & GetFontSize() const
Definition: font/font.cxx:673
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1022
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
void SetImage(const Image &rImage)
Definition: fixed.cxx:933
void SetLogo(const Image &rLogoBitmap)
Definition: aboutdialog.cxx:93
void RequestDoubleBuffering(bool bRequest)
Enable/disable double-buffering of the frame window and all its children.
Definition: window.cxx:3818
InitFlag
Definition: dialog.hxx:37
VclPtr< FixedText > m_xLogoReplacement
Definition: aboutdialog.hxx:33
void SetSelectionOptions(SelectionOptions nOptions)
VclPtr< FixedHyperlink > m_xBuildIdLink
Definition: aboutdialog.hxx:29
Definition: image.hxx:40
VclPtr< FixedImage > m_xLogoImage
Definition: aboutdialog.hxx:32
virtual void set_content_area(VclBox *pBox)
Definition: dialog.cxx:590
AboutDialog(vcl::Window *pParent, WinBits nStyle=WB_STDDIALOG, InitFlag eFlag=InitFlag::Default)
Definition: aboutdialog.cxx:20
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
virtual void set_content_area(VclBox *pBox) override
Definition: aboutdialog.cxx:45
virtual ~AboutDialog() override
Definition: aboutdialog.cxx:55
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83
virtual void SetText(const OUString &rStr) override
Definition: vclmedit.cxx:1144
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2151
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override