Branch data 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 : :
28 : : /** === begin UNO using === **/
29 : : /** === end UNO using === **/
30 : :
31 : : //====================================================================
32 : : //= InspectorHelpWindow
33 : : //====================================================================
34 : : //--------------------------------------------------------------------
35 : 0 : InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
36 : : :Window( _pParent, WB_DIALOGCONTROL )
37 : : ,m_aSeparator( this )
38 : : ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
39 : : ,m_nMinLines( 3 )
40 : 0 : ,m_nMaxLines( 8 )
41 : : {
42 : 0 : SetBackground();
43 : 0 : SetPaintTransparent(sal_True);
44 : 0 : m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
45 : 0 : m_aSeparator.SetBackground();
46 : 0 : m_aSeparator.Show();
47 : :
48 : 0 : m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
49 : 0 : m_aHelpText.SetBackground();
50 : 0 : m_aHelpText.SetPaintTransparent(sal_True);
51 : 0 : m_aHelpText.Show();
52 : 0 : }
53 : :
54 : : //--------------------------------------------------------------------
55 : 0 : void InspectorHelpWindow::SetText( const XubString& _rStr )
56 : : {
57 : 0 : m_aHelpText.SetText( _rStr );
58 : 0 : }
59 : :
60 : : //--------------------------------------------------------------------
61 : 0 : void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
62 : : {
63 : 0 : m_nMinLines = _nMinLines;
64 : 0 : m_nMaxLines = _nMaxLines;
65 : 0 : }
66 : :
67 : : //--------------------------------------------------------------------
68 : 0 : long InspectorHelpWindow::impl_getHelpTextBorderHeight()
69 : : {
70 : 0 : sal_Int32 nTop(0), nBottom(0), nDummy(0);
71 : 0 : m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
72 : 0 : return nTop + nBottom;
73 : : }
74 : :
75 : : //--------------------------------------------------------------------
76 : 0 : long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
77 : : {
78 : 0 : Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
79 : 0 : Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
80 : 0 : return aSeparatorSize.Height() + a3AppFontSize.Height();
81 : : }
82 : :
83 : : //--------------------------------------------------------------------
84 : 0 : long InspectorHelpWindow::GetMinimalHeightPixel()
85 : : {
86 : 0 : return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
87 : : }
88 : :
89 : : //--------------------------------------------------------------------
90 : 0 : long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
91 : : {
92 : 0 : return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
93 : : }
94 : :
95 : : //--------------------------------------------------------------------
96 : 0 : long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
97 : : {
98 : 0 : return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
99 : : }
100 : :
101 : : //--------------------------------------------------------------------
102 : 0 : long InspectorHelpWindow::GetOptimalHeightPixel()
103 : : {
104 : : // --- calc the height as needed for the mere text window
105 : 0 : long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
106 : 0 : long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
107 : :
108 : 0 : Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
109 : : aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
110 : 0 : TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
111 : 0 : long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
112 : :
113 : 0 : long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
114 : :
115 : : // --- then add the space above the text window
116 : 0 : return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
117 : : }
118 : :
119 : : //--------------------------------------------------------------------
120 : 0 : void InspectorHelpWindow::Resize()
121 : : {
122 : 0 : Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
123 : :
124 : 0 : Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
125 : :
126 : 0 : Rectangle aSeparatorArea( aPlayground );
127 : 0 : aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
128 : 0 : m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
129 : :
130 : 0 : Rectangle aTextArea( aPlayground );
131 : 0 : aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
132 : 0 : m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
133 : 0 : }
134 : :
135 : : //........................................................................
136 : : } // namespace pcr
137 : : //........................................................................
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|