Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "hintwin.hxx"
30 : : #include "global.hxx"
31 : :
32 : : #define HINT_LINESPACE 2
33 : : #define HINT_INDENT 3
34 : : #define HINT_MARGIN 4
35 : :
36 : : //==================================================================
37 : :
38 : 0 : ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) :
39 : : Window( pParent, WinBits( WB_BORDER ) ),
40 : : aTitle( rTit ),
41 [ # # ][ # # ]: 0 : aMessage( convertLineEnd(rMsg, LINEEND_CR) )
[ # # ][ # # ]
[ # # ][ # # ]
42 : : {
43 : : // Hellgelb, wie Notizen in detfunc.cxx
44 : 0 : Color aYellow( 255,255,192 ); // hellgelb
45 [ # # ][ # # ]: 0 : SetBackground( aYellow );
[ # # ]
46 : :
47 [ # # ]: 0 : aTextFont = GetFont();
48 [ # # ]: 0 : aTextFont.SetTransparent( sal_True );
49 [ # # ]: 0 : aTextFont.SetWeight( WEIGHT_NORMAL );
50 [ # # ]: 0 : aHeadFont = aTextFont;
51 [ # # ]: 0 : aHeadFont.SetWeight( WEIGHT_BOLD );
52 : :
53 [ # # ]: 0 : SetFont( aHeadFont );
54 [ # # ][ # # ]: 0 : Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
55 [ # # ]: 0 : SetFont( aTextFont );
56 : :
57 : 0 : Size aTextSize;
58 : 0 : xub_StrLen nIndex = 0;
59 [ # # ]: 0 : while ( nIndex != STRING_NOTFOUND )
60 : : {
61 [ # # ]: 0 : String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
62 [ # # ][ # # ]: 0 : Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
63 : 0 : nTextHeight = aLineSize.Height();
64 : 0 : aTextSize.Height() += nTextHeight;
65 [ # # ]: 0 : if ( aLineSize.Width() > aTextSize.Width() )
66 : 0 : aTextSize.Width() = aLineSize.Width();
67 [ # # ]: 0 : }
68 : 0 : aTextSize.Width() += HINT_INDENT;
69 : :
70 : : aTextStart = Point( HINT_MARGIN + HINT_INDENT,
71 : 0 : aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
72 : :
73 : 0 : Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
74 : 0 : aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
75 [ # # ]: 0 : SetOutputSizePixel( aWinSize );
76 : 0 : }
77 : :
78 : :
79 [ # # ][ # # ]: 0 : ScHintWindow::~ScHintWindow()
[ # # ][ # # ]
80 : : {
81 [ # # ]: 0 : }
82 : :
83 : :
84 : 0 : void ScHintWindow::Paint( const Rectangle& /* rRect */ )
85 : : {
86 [ # # ]: 0 : SetFont( aHeadFont );
87 [ # # ]: 0 : DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
88 : :
89 [ # # ]: 0 : SetFont( aTextFont );
90 : 0 : xub_StrLen nIndex = 0;
91 : 0 : Point aLineStart = aTextStart;
92 [ # # ]: 0 : while ( nIndex != STRING_NOTFOUND )
93 : : {
94 [ # # ]: 0 : String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
95 [ # # ]: 0 : DrawText( aLineStart, aLine );
96 : 0 : aLineStart.Y() += nTextHeight;
97 [ # # ]: 0 : }
98 : 0 : }
99 : :
100 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|