xref: /trunk/main/extensions/source/propctrlr/inspectorhelpwindow.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
24cdf0e10cSrcweir #include "precompiled_extensions.hxx"
25cdf0e10cSrcweir #include "inspectorhelpwindow.hxx"
26cdf0e10cSrcweir #include "modulepcr.hxx"
27cdf0e10cSrcweir #ifndef EXTENSIONS_PROPRESID_HRC
28cdf0e10cSrcweir #include "propresid.hrc"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /** === begin UNO includes === **/
32cdf0e10cSrcweir /** === end UNO includes === **/
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //........................................................................
35cdf0e10cSrcweir namespace pcr
36cdf0e10cSrcweir {
37cdf0e10cSrcweir //........................................................................
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     /** === begin UNO using === **/
40cdf0e10cSrcweir     /** === end UNO using === **/
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     //====================================================================
43cdf0e10cSrcweir     //= InspectorHelpWindow
44cdf0e10cSrcweir     //====================================================================
45cdf0e10cSrcweir     //--------------------------------------------------------------------
InspectorHelpWindow(Window * _pParent)46cdf0e10cSrcweir     InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
47cdf0e10cSrcweir         :Window( _pParent, WB_DIALOGCONTROL )
48cdf0e10cSrcweir         ,m_aSeparator( this )
49cdf0e10cSrcweir         ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
50cdf0e10cSrcweir         ,m_nMinLines( 3 )
51cdf0e10cSrcweir         ,m_nMaxLines( 8 )
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         SetBackground();
54cdf0e10cSrcweir         SetPaintTransparent(sal_True);
55cdf0e10cSrcweir         m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
56cdf0e10cSrcweir         m_aSeparator.SetBackground();
57cdf0e10cSrcweir         m_aSeparator.Show();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
60cdf0e10cSrcweir         m_aHelpText.SetBackground();
61cdf0e10cSrcweir         m_aHelpText.SetPaintTransparent(sal_True);
62cdf0e10cSrcweir         m_aHelpText.Show();
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     //--------------------------------------------------------------------
SetText(const XubString & _rStr)66cdf0e10cSrcweir     void InspectorHelpWindow::SetText( const XubString& _rStr )
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir         m_aHelpText.SetText( _rStr );
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     //--------------------------------------------------------------------
SetLimits(sal_Int32 _nMinLines,sal_Int32 _nMaxLines)72cdf0e10cSrcweir     void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         m_nMinLines = _nMinLines;
75cdf0e10cSrcweir         m_nMaxLines = _nMaxLines;
76cdf0e10cSrcweir     }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_getHelpTextBorderHeight()79cdf0e10cSrcweir     long InspectorHelpWindow::impl_getHelpTextBorderHeight()
80cdf0e10cSrcweir     {
81cdf0e10cSrcweir         sal_Int32 nTop(0), nBottom(0), nDummy(0);
82cdf0e10cSrcweir         m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
83cdf0e10cSrcweir         return nTop + nBottom;
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_getSpaceAboveTextWindow()87cdf0e10cSrcweir     long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
90cdf0e10cSrcweir         Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
91cdf0e10cSrcweir         return aSeparatorSize.Height() + a3AppFontSize.Height();
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     //--------------------------------------------------------------------
GetMinimalHeightPixel()95cdf0e10cSrcweir     long InspectorHelpWindow::GetMinimalHeightPixel()
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
98cdf0e10cSrcweir     }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_getMinimalTextWindowHeight()101cdf0e10cSrcweir     long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     //--------------------------------------------------------------------
impl_getMaximalTextWindowHeight()107cdf0e10cSrcweir     long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir         return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     //--------------------------------------------------------------------
GetOptimalHeightPixel()113cdf0e10cSrcweir     long InspectorHelpWindow::GetOptimalHeightPixel()
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         // --- calc the height as needed for the mere text window
116cdf0e10cSrcweir         long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
117cdf0e10cSrcweir         long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
120cdf0e10cSrcweir         aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
121cdf0e10cSrcweir             TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
122cdf0e10cSrcweir         long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         // --- then add the space above the text window
127cdf0e10cSrcweir         return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
128cdf0e10cSrcweir     }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     //--------------------------------------------------------------------
Resize()131cdf0e10cSrcweir     void InspectorHelpWindow::Resize()
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir         Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         Rectangle aSeparatorArea( aPlayground );
138cdf0e10cSrcweir         aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
139cdf0e10cSrcweir         m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         Rectangle aTextArea( aPlayground );
142cdf0e10cSrcweir         aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
143cdf0e10cSrcweir         m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir //........................................................................
147cdf0e10cSrcweir } // namespace pcr
148cdf0e10cSrcweir //........................................................................
149