Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / inspectorhelpwindow.cxx
blob1af39dc0707f45dc5defcb5bec7f2506b07998e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #include "inspectorhelpwindow.hxx"
29 #include "modulepcr.hxx"
30 #include "propresid.hrc"
32 /** === begin UNO includes === **/
33 /** === end UNO includes === **/
35 //........................................................................
36 namespace pcr
38 //........................................................................
40 /** === begin UNO using === **/
41 /** === end UNO using === **/
43 //====================================================================
44 //= InspectorHelpWindow
45 //====================================================================
46 //--------------------------------------------------------------------
47 InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
48 :Window( _pParent, WB_DIALOGCONTROL )
49 ,m_aSeparator( this )
50 ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
51 ,m_nMinLines( 3 )
52 ,m_nMaxLines( 8 )
54 SetBackground();
55 SetPaintTransparent(sal_True);
56 m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
57 m_aSeparator.SetBackground();
58 m_aSeparator.Show();
60 m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
61 m_aHelpText.SetBackground();
62 m_aHelpText.SetPaintTransparent(sal_True);
63 m_aHelpText.Show();
66 //--------------------------------------------------------------------
67 void InspectorHelpWindow::SetText( const XubString& _rStr )
69 m_aHelpText.SetText( _rStr );
72 //--------------------------------------------------------------------
73 void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
75 m_nMinLines = _nMinLines;
76 m_nMaxLines = _nMaxLines;
79 //--------------------------------------------------------------------
80 long InspectorHelpWindow::impl_getHelpTextBorderHeight()
82 sal_Int32 nTop(0), nBottom(0), nDummy(0);
83 m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
84 return nTop + nBottom;
87 //--------------------------------------------------------------------
88 long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
90 Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
91 Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
92 return aSeparatorSize.Height() + a3AppFontSize.Height();
95 //--------------------------------------------------------------------
96 long InspectorHelpWindow::GetMinimalHeightPixel()
98 return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
101 //--------------------------------------------------------------------
102 long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
104 return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
107 //--------------------------------------------------------------------
108 long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
110 return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
113 //--------------------------------------------------------------------
114 long InspectorHelpWindow::GetOptimalHeightPixel()
116 // --- calc the height as needed for the mere text window
117 long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
118 long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
120 Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
121 aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
122 TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
123 long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
125 long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
127 // --- then add the space above the text window
128 return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
131 //--------------------------------------------------------------------
132 void InspectorHelpWindow::Resize()
134 Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
136 Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
138 Rectangle aSeparatorArea( aPlayground );
139 aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
140 m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
142 Rectangle aTextArea( aPlayground );
143 aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
144 m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
147 //........................................................................
148 } // namespace pcr
149 //........................................................................
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */