1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "hintwin.hxx"
23 #define HINT_LINESPACE 2
27 //==================================================================
29 ScHintWindow::ScHintWindow( Window
* pParent
, const OUString
& rTit
, const OUString
& rMsg
) :
30 Window( pParent
, WinBits( WB_BORDER
) ),
32 aMessage( convertLineEnd(rMsg
, LINEEND_CR
) )
34 // Hellgelb, wie Notizen in detfunc.cxx
35 Color
aYellow( 255,255,192 ); // hellgelb
36 SetBackground( aYellow
);
38 aTextFont
= GetFont();
39 aTextFont
.SetTransparent( sal_True
);
40 aTextFont
.SetWeight( WEIGHT_NORMAL
);
41 aHeadFont
= aTextFont
;
42 aHeadFont
.SetWeight( WEIGHT_BOLD
);
45 Size
aHeadSize( GetTextWidth( aTitle
), GetTextHeight() );
50 while ( nIndex
!= -1 )
52 OUString aLine
= aMessage
.getToken( 0, CHAR_CR
, nIndex
);
53 Size
aLineSize( GetTextWidth( aLine
), GetTextHeight() );
54 nTextHeight
= aLineSize
.Height();
55 aTextSize
.Height() += nTextHeight
;
56 if ( aLineSize
.Width() > aTextSize
.Width() )
57 aTextSize
.Width() = aLineSize
.Width();
59 aTextSize
.Width() += HINT_INDENT
;
61 aTextStart
= Point( HINT_MARGIN
+ HINT_INDENT
,
62 aHeadSize
.Height() + HINT_MARGIN
+ HINT_LINESPACE
);
64 Size
aWinSize( std::max( aHeadSize
.Width(), aTextSize
.Width() ) + 2 * HINT_MARGIN
+ 1,
65 aHeadSize
.Height() + aTextSize
.Height() + HINT_LINESPACE
+ 2 * HINT_MARGIN
+ 1 );
66 SetOutputSizePixel( aWinSize
);
70 ScHintWindow::~ScHintWindow()
75 void ScHintWindow::Paint( const Rectangle
& /* rRect */ )
78 DrawText( Point(HINT_MARGIN
,HINT_MARGIN
), aTitle
);
82 Point aLineStart
= aTextStart
;
83 while ( nIndex
!= -1 )
85 OUString aLine
= aMessage
.getToken( 0, CHAR_CR
, nIndex
);
86 DrawText( aLineStart
, aLine
);
87 aLineStart
.Y() += nTextHeight
;
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */