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 :
20 : #include "hintwin.hxx"
21 : #include "global.hxx"
22 :
23 : #define HINT_LINESPACE 2
24 : #define HINT_INDENT 3
25 : #define HINT_MARGIN 4
26 :
27 : //==================================================================
28 :
29 0 : ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) :
30 : Window( pParent, WinBits( WB_BORDER ) ),
31 : aTitle( rTit ),
32 0 : aMessage( convertLineEnd(rMsg, LINEEND_CR) )
33 : {
34 : // Hellgelb, wie Notizen in detfunc.cxx
35 0 : Color aYellow( 255,255,192 ); // hellgelb
36 0 : SetBackground( aYellow );
37 :
38 0 : aTextFont = GetFont();
39 0 : aTextFont.SetTransparent( sal_True );
40 0 : aTextFont.SetWeight( WEIGHT_NORMAL );
41 0 : aHeadFont = aTextFont;
42 0 : aHeadFont.SetWeight( WEIGHT_BOLD );
43 :
44 0 : SetFont( aHeadFont );
45 0 : Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
46 0 : SetFont( aTextFont );
47 :
48 0 : Size aTextSize;
49 0 : xub_StrLen nIndex = 0;
50 0 : while ( nIndex != STRING_NOTFOUND )
51 : {
52 0 : String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
53 0 : Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
54 0 : nTextHeight = aLineSize.Height();
55 0 : aTextSize.Height() += nTextHeight;
56 0 : if ( aLineSize.Width() > aTextSize.Width() )
57 0 : aTextSize.Width() = aLineSize.Width();
58 0 : }
59 0 : aTextSize.Width() += HINT_INDENT;
60 :
61 : aTextStart = Point( HINT_MARGIN + HINT_INDENT,
62 0 : aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
63 :
64 0 : Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
65 0 : aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
66 0 : SetOutputSizePixel( aWinSize );
67 0 : }
68 :
69 :
70 0 : ScHintWindow::~ScHintWindow()
71 : {
72 0 : }
73 :
74 :
75 0 : void ScHintWindow::Paint( const Rectangle& /* rRect */ )
76 : {
77 0 : SetFont( aHeadFont );
78 0 : DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
79 :
80 0 : SetFont( aTextFont );
81 0 : xub_StrLen nIndex = 0;
82 0 : Point aLineStart = aTextStart;
83 0 : while ( nIndex != STRING_NOTFOUND )
84 : {
85 0 : String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
86 0 : DrawText( aLineStart, aLine );
87 0 : aLineStart.Y() += nTextHeight;
88 0 : }
89 0 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|