bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / propctrlr / inspectorhelpwindow.cxx
blobc0090fa582bd8f52e9c8b66f9e60504d20b04d27
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "inspectorhelpwindow.hxx"
20 #include "modulepcr.hxx"
21 #include "propresid.hrc"
24 namespace pcr
27 //= InspectorHelpWindow
30 InspectorHelpWindow::InspectorHelpWindow( vcl::Window* _pParent )
31 :Window( _pParent, WB_DIALOGCONTROL )
32 ,m_aSeparator( VclPtr<FixedLine>::Create(this) )
33 ,m_aHelpText( VclPtr<MultiLineEdit>::Create(this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL) )
34 ,m_nMinLines( 3 )
35 ,m_nMaxLines( 8 )
37 SetBackground();
38 SetPaintTransparent(true);
39 m_aSeparator->SetText( PcrRes(RID_STR_HELP_SECTION_LABEL).toString() );
40 m_aSeparator->SetBackground();
41 m_aSeparator->Show();
43 m_aHelpText->SetControlBackground( /*m_aSeparator->GetBackground().GetColor() */);
44 m_aHelpText->SetBackground();
45 m_aHelpText->SetPaintTransparent(true);
46 m_aHelpText->Show();
49 InspectorHelpWindow::~InspectorHelpWindow()
51 disposeOnce();
54 void InspectorHelpWindow::dispose()
56 m_aSeparator.disposeAndClear();
57 m_aHelpText.disposeAndClear();
58 vcl::Window::dispose();
61 void InspectorHelpWindow::SetText( const OUString& _rStr )
63 m_aHelpText->SetText( _rStr );
67 void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
69 m_nMinLines = _nMinLines;
70 m_nMaxLines = _nMaxLines;
74 long InspectorHelpWindow::impl_getHelpTextBorderHeight()
76 sal_Int32 nTop(0), nBottom(0), nDummy(0);
77 m_aHelpText->GetBorder( nDummy, nTop, nDummy, nBottom );
78 return nTop + nBottom;
82 long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
84 Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
85 Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
86 return aSeparatorSize.Height() + a3AppFontSize.Height();
90 long InspectorHelpWindow::GetMinimalHeightPixel()
92 return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
96 long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
98 return impl_getHelpTextBorderHeight() + m_aHelpText->GetTextHeight() * m_nMinLines;
102 long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
104 return impl_getHelpTextBorderHeight() + m_aHelpText->GetTextHeight() * m_nMaxLines;
108 long InspectorHelpWindow::GetOptimalHeightPixel()
110 // --- calc the height as needed for the mere text window
111 long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
112 long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
114 Rectangle aTextRect( Point( 0, 0 ), m_aHelpText->GetOutputSizePixel() );
115 aTextRect = m_aHelpText->GetTextRect( aTextRect, m_aHelpText->GetText(),
116 DrawTextFlags::Left | DrawTextFlags::Top | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak );
117 long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
119 long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
121 // --- then add the space above the text window
122 return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
126 void InspectorHelpWindow::Resize()
128 Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
130 Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
132 Rectangle aSeparatorArea( aPlayground );
133 aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
134 m_aSeparator->SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
136 Rectangle aTextArea( aPlayground );
137 aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
138 m_aHelpText->SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
142 } // namespace pcr
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */