1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inspectorhelpwindow.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_extensions.hxx"
32 #include "inspectorhelpwindow.hxx"
33 #include "modulepcr.hxx"
34 #ifndef EXTENSIONS_PROPRESID_HRC
35 #include "propresid.hrc"
38 /** === begin UNO includes === **/
39 /** === end UNO includes === **/
41 //........................................................................
44 //........................................................................
46 /** === begin UNO using === **/
47 /** === end UNO using === **/
49 //====================================================================
50 //= InspectorHelpWindow
51 //====================================================================
52 //--------------------------------------------------------------------
53 InspectorHelpWindow::InspectorHelpWindow( Window
* _pParent
)
54 :Window( _pParent
, WB_DIALOGCONTROL
)
56 ,m_aHelpText( this, WB_LEFT
| WB_READONLY
| WB_AUTOVSCROLL
)
61 SetPaintTransparent(TRUE
);
62 m_aSeparator
.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL
) ) );
63 m_aSeparator
.SetBackground();
66 m_aHelpText
.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
67 m_aHelpText
.SetBackground();
68 m_aHelpText
.SetPaintTransparent(TRUE
);
72 //--------------------------------------------------------------------
73 void InspectorHelpWindow::SetText( const XubString
& _rStr
)
75 m_aHelpText
.SetText( _rStr
);
78 //--------------------------------------------------------------------
79 void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines
, sal_Int32 _nMaxLines
)
81 m_nMinLines
= _nMinLines
;
82 m_nMaxLines
= _nMaxLines
;
85 //--------------------------------------------------------------------
86 long InspectorHelpWindow::impl_getHelpTextBorderHeight()
88 sal_Int32
nTop(0), nBottom(0), nDummy(0);
89 m_aHelpText
.GetBorder( nDummy
, nTop
, nDummy
, nBottom
);
90 return nTop
+ nBottom
;
93 //--------------------------------------------------------------------
94 long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
96 Size
aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT
) );
97 Size
a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT
) );
98 return aSeparatorSize
.Height() + a3AppFontSize
.Height();
101 //--------------------------------------------------------------------
102 long InspectorHelpWindow::GetMinimalHeightPixel()
104 return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
107 //--------------------------------------------------------------------
108 long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
110 return impl_getHelpTextBorderHeight() + m_aHelpText
.GetTextHeight() * m_nMinLines
;
113 //--------------------------------------------------------------------
114 long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
116 return impl_getHelpTextBorderHeight() + m_aHelpText
.GetTextHeight() * m_nMaxLines
;
119 //--------------------------------------------------------------------
120 long InspectorHelpWindow::GetOptimalHeightPixel()
122 // --- calc the height as needed for the mere text window
123 long nMinTextWindowHeight
= impl_getMinimalTextWindowHeight();
124 long nMaxTextWindowHeight
= impl_getMaximalTextWindowHeight();
126 Rectangle
aTextRect( Point( 0, 0 ), m_aHelpText
.GetOutputSizePixel() );
127 aTextRect
= m_aHelpText
.GetTextRect( aTextRect
, m_aHelpText
.GetText(),
128 TEXT_DRAW_LEFT
| TEXT_DRAW_TOP
| TEXT_DRAW_MULTILINE
| TEXT_DRAW_WORDBREAK
);
129 long nActTextWindowHeight
= impl_getHelpTextBorderHeight() + aTextRect
.GetHeight();
131 long nOptTextWindowHeight
= ::std::max( nMinTextWindowHeight
, ::std::min( nMaxTextWindowHeight
, nActTextWindowHeight
) );
133 // --- then add the space above the text window
134 return nOptTextWindowHeight
+ impl_getSpaceAboveTextWindow();
137 //--------------------------------------------------------------------
138 void InspectorHelpWindow::Resize()
140 Size
a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT
) );
142 Rectangle
aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
144 Rectangle
aSeparatorArea( aPlayground
);
145 aSeparatorArea
.Bottom() = aSeparatorArea
.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT
).Height();
146 m_aSeparator
.SetPosSizePixel( aSeparatorArea
.TopLeft(), aSeparatorArea
.GetSize() );
148 Rectangle
aTextArea( aPlayground
);
149 aTextArea
.Top() = aSeparatorArea
.Bottom() + a3AppFont
.Height();
150 m_aHelpText
.SetPosSizePixel( aTextArea
.TopLeft(), aTextArea
.GetSize() );
153 //........................................................................
155 //........................................................................