bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / propctrlr / inspectorhelpwindow.cxx
blob1a47a5ce2e6ddb3230ac0b3102c8ce3a032eb839
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"
23 //........................................................................
24 namespace pcr
26 //====================================================================
27 //= InspectorHelpWindow
28 //====================================================================
29 //--------------------------------------------------------------------
30 InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
31 :Window( _pParent, WB_DIALOGCONTROL )
32 ,m_aSeparator( this )
33 ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
34 ,m_nMinLines( 3 )
35 ,m_nMaxLines( 8 )
37 SetBackground();
38 SetPaintTransparent(sal_True);
39 m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
40 m_aSeparator.SetBackground();
41 m_aSeparator.Show();
43 m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
44 m_aHelpText.SetBackground();
45 m_aHelpText.SetPaintTransparent(sal_True);
46 m_aHelpText.Show();
49 //--------------------------------------------------------------------
50 void InspectorHelpWindow::SetText( const OUString& _rStr )
52 m_aHelpText.SetText( _rStr );
55 //--------------------------------------------------------------------
56 void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
58 m_nMinLines = _nMinLines;
59 m_nMaxLines = _nMaxLines;
62 //--------------------------------------------------------------------
63 long InspectorHelpWindow::impl_getHelpTextBorderHeight()
65 sal_Int32 nTop(0), nBottom(0), nDummy(0);
66 m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
67 return nTop + nBottom;
70 //--------------------------------------------------------------------
71 long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
73 Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
74 Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
75 return aSeparatorSize.Height() + a3AppFontSize.Height();
78 //--------------------------------------------------------------------
79 long InspectorHelpWindow::GetMinimalHeightPixel()
81 return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
84 //--------------------------------------------------------------------
85 long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
87 return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
90 //--------------------------------------------------------------------
91 long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
93 return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
96 //--------------------------------------------------------------------
97 long InspectorHelpWindow::GetOptimalHeightPixel()
99 // --- calc the height as needed for the mere text window
100 long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
101 long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
103 Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
104 aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
105 TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
106 long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
108 long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
110 // --- then add the space above the text window
111 return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
114 //--------------------------------------------------------------------
115 void InspectorHelpWindow::Resize()
117 Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
119 Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
121 Rectangle aSeparatorArea( aPlayground );
122 aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
123 m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
125 Rectangle aTextArea( aPlayground );
126 aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
127 m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
130 //........................................................................
131 } // namespace pcr
132 //........................................................................
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */