1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 // MARKER(update_precomp.py): autogen include statement, do not remove
28 #include "precompiled_extensions.hxx"
29 #include "inspectorhelpwindow.hxx"
30 #include "modulepcr.hxx"
31 #ifndef EXTENSIONS_PROPRESID_HRC
32 #include "propresid.hrc"
35 /** === begin UNO includes === **/
36 /** === end UNO includes === **/
38 //........................................................................
41 //........................................................................
43 /** === begin UNO using === **/
44 /** === end UNO using === **/
46 //====================================================================
47 //= InspectorHelpWindow
48 //====================================================================
49 //--------------------------------------------------------------------
50 InspectorHelpWindow::InspectorHelpWindow( Window
* _pParent
)
51 :Window( _pParent
, WB_DIALOGCONTROL
)
53 ,m_aHelpText( this, WB_LEFT
| WB_READONLY
| WB_AUTOVSCROLL
)
58 SetPaintTransparent(TRUE
);
59 m_aSeparator
.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL
) ) );
60 m_aSeparator
.SetBackground();
63 m_aHelpText
.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
64 m_aHelpText
.SetBackground();
65 m_aHelpText
.SetPaintTransparent(TRUE
);
69 //--------------------------------------------------------------------
70 void InspectorHelpWindow::SetText( const XubString
& _rStr
)
72 m_aHelpText
.SetText( _rStr
);
75 //--------------------------------------------------------------------
76 void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
)
78 m_nMinLines
= _nMinLines
;
79 m_nMaxLines
= _nMaxLines
;
82 //--------------------------------------------------------------------
83 long InspectorHelpWindow::impl_getHelpTextBorderHeight()
85 sal_Int32
nTop(0), nBottom(0), nDummy(0);
86 m_aHelpText
.GetBorder( nDummy
, nTop
, nDummy
, nBottom
);
87 return nTop
+ nBottom
;
90 //--------------------------------------------------------------------
91 long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
93 Size
aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT
) );
94 Size
a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT
) );
95 return aSeparatorSize
.Height() + a3AppFontSize
.Height();
98 //--------------------------------------------------------------------
99 long InspectorHelpWindow::GetMinimalHeightPixel()
101 return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
104 //--------------------------------------------------------------------
105 long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
107 return impl_getHelpTextBorderHeight() + m_aHelpText
.GetTextHeight() * m_nMinLines
;
110 //--------------------------------------------------------------------
111 long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
113 return impl_getHelpTextBorderHeight() + m_aHelpText
.GetTextHeight() * m_nMaxLines
;
116 //--------------------------------------------------------------------
117 long InspectorHelpWindow::GetOptimalHeightPixel()
119 // --- calc the height as needed for the mere text window
120 long nMinTextWindowHeight
= impl_getMinimalTextWindowHeight();
121 long nMaxTextWindowHeight
= impl_getMaximalTextWindowHeight();
123 Rectangle
aTextRect( Point( 0, 0 ), m_aHelpText
.GetOutputSizePixel() );
124 aTextRect
= m_aHelpText
.GetTextRect( aTextRect
, m_aHelpText
.GetText(),
125 TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_MULTILINE
| TEXT_DRAW_WORDBREAK
);
126 long nActTextWindowHeight
= impl_getHelpTextBorderHeight() + aTextRect
.GetHeight();
128 long nOptTextWindowHeight
= ::std::max( nMinTextWindowHeight
, ::std::min( nMaxTextWindowHeight
, nActTextWindowHeight
) );
130 // --- then add the space above the text window
131 return nOptTextWindowHeight
+ impl_getSpaceAboveTextWindow();
134 //--------------------------------------------------------------------
135 void InspectorHelpWindow::Resize()
137 Size
a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT
) );
139 Rectangle
aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
141 Rectangle
aSeparatorArea( aPlayground
);
142 aSeparatorArea
.Bottom() = aSeparatorArea
.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT
).Height();
143 m_aSeparator
.SetPosSizePixel( aSeparatorArea
.TopLeft(), aSeparatorArea
.GetSize() );
145 Rectangle
aTextArea( aPlayground
);
146 aTextArea
.Top() = aSeparatorArea
.Bottom() + a3AppFont
.Height();
147 m_aHelpText
.SetPosSizePixel( aTextArea
.TopLeft(), aTextArea
.GetSize() );
150 //........................................................................
152 //........................................................................