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