LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - inspectorhelpwindow.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 52 1.9 %
Date: 2014-11-03 Functions: 2 12 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include "inspectorhelpwindow.hxx"
      20             : #include "modulepcr.hxx"
      21             : #include "propresid.hrc"
      22             : 
      23             : 
      24             : namespace pcr
      25             : {
      26             : 
      27             :     //= InspectorHelpWindow
      28             : 
      29             : 
      30           0 :     InspectorHelpWindow::InspectorHelpWindow( vcl::Window* _pParent )
      31             :         :Window( _pParent, WB_DIALOGCONTROL )
      32             :         ,m_aSeparator( this )
      33             :         ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
      34             :         ,m_nMinLines( 3 )
      35           0 :         ,m_nMaxLines( 8 )
      36             :     {
      37           0 :         SetBackground();
      38           0 :         SetPaintTransparent(true);
      39           0 :         m_aSeparator.SetText( PcrRes(RID_STR_HELP_SECTION_LABEL).toString() );
      40           0 :         m_aSeparator.SetBackground();
      41           0 :         m_aSeparator.Show();
      42             : 
      43           0 :         m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
      44           0 :         m_aHelpText.SetBackground();
      45           0 :         m_aHelpText.SetPaintTransparent(true);
      46           0 :         m_aHelpText.Show();
      47           0 :     }
      48             : 
      49             : 
      50           0 :     void InspectorHelpWindow::SetText( const OUString& _rStr )
      51             :     {
      52           0 :         m_aHelpText.SetText( _rStr );
      53           0 :     }
      54             : 
      55             : 
      56           0 :     void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
      57             :     {
      58           0 :         m_nMinLines = _nMinLines;
      59           0 :         m_nMaxLines = _nMaxLines;
      60           0 :     }
      61             : 
      62             : 
      63           0 :     long InspectorHelpWindow::impl_getHelpTextBorderHeight()
      64             :     {
      65           0 :         sal_Int32 nTop(0), nBottom(0), nDummy(0);
      66           0 :         m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
      67           0 :         return nTop + nBottom;
      68             :     }
      69             : 
      70             : 
      71           0 :     long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
      72             :     {
      73           0 :         Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
      74           0 :         Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
      75           0 :         return aSeparatorSize.Height() + a3AppFontSize.Height();
      76             :     }
      77             : 
      78             : 
      79           0 :     long InspectorHelpWindow::GetMinimalHeightPixel()
      80             :     {
      81           0 :         return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
      82             :     }
      83             : 
      84             : 
      85           0 :     long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
      86             :     {
      87           0 :         return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
      88             :     }
      89             : 
      90             : 
      91           0 :     long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
      92             :     {
      93           0 :         return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
      94             :     }
      95             : 
      96             : 
      97           0 :     long InspectorHelpWindow::GetOptimalHeightPixel()
      98             :     {
      99             :         // --- calc the height as needed for the mere text window
     100           0 :         long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
     101           0 :         long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
     102             : 
     103           0 :         Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
     104             :         aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
     105           0 :             TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
     106           0 :         long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
     107             : 
     108           0 :         long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
     109             : 
     110             :         // --- then add the space above the text window
     111           0 :         return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
     112             :     }
     113             : 
     114             : 
     115           0 :     void InspectorHelpWindow::Resize()
     116             :     {
     117           0 :         Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
     118             : 
     119           0 :         Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
     120             : 
     121           0 :         Rectangle aSeparatorArea( aPlayground );
     122           0 :         aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
     123           0 :         m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
     124             : 
     125           0 :         Rectangle aTextArea( aPlayground );
     126           0 :         aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
     127           0 :         m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
     128           0 :     }
     129             : 
     130             : 
     131          12 : } // namespace pcr
     132             : 
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10