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 ScHintWindow::ScHintWindow( vcl::Window
* pParent
, const OUString
& rTit
, const OUString
& rMsg
) :
28 Window( pParent
, WinBits( WB_BORDER
) ),
30 aMessage( convertLineEnd(rMsg
, LINEEND_CR
) )
32 // Hellgelb, wie Notizen in detfunc.cxx
33 Color
aYellow( 255,255,192 ); // hellgelb
34 SetBackground( aYellow
);
36 aTextFont
= GetFont();
37 aTextFont
.SetTransparent( true );
38 aTextFont
.SetWeight( WEIGHT_NORMAL
);
39 aHeadFont
= aTextFont
;
40 aHeadFont
.SetWeight( WEIGHT_BOLD
);
43 Size
aHeadSize( GetTextWidth( aTitle
), GetTextHeight() );
48 while ( nIndex
!= -1 )
50 OUString aLine
= aMessage
.getToken( 0, CHAR_CR
, nIndex
);
51 Size
aLineSize( GetTextWidth( aLine
), GetTextHeight() );
52 nTextHeight
= aLineSize
.Height();
53 aTextSize
.Height() += nTextHeight
;
54 if ( aLineSize
.Width() > aTextSize
.Width() )
55 aTextSize
.Width() = aLineSize
.Width();
57 aTextSize
.Width() += HINT_INDENT
;
59 aTextStart
= Point( HINT_MARGIN
+ HINT_INDENT
,
60 aHeadSize
.Height() + HINT_MARGIN
+ HINT_LINESPACE
);
62 Size
aWinSize( std::max( aHeadSize
.Width(), aTextSize
.Width() ) + 2 * HINT_MARGIN
+ 1,
63 aHeadSize
.Height() + aTextSize
.Height() + HINT_LINESPACE
+ 2 * HINT_MARGIN
+ 1 );
64 SetOutputSizePixel( aWinSize
);
67 ScHintWindow::~ScHintWindow()
71 void ScHintWindow::Paint( vcl::RenderContext
& /*rRenderContext*/, const Rectangle
& /* rRect */ )
74 DrawText( Point(HINT_MARGIN
,HINT_MARGIN
), aTitle
);
78 Point aLineStart
= aTextStart
;
79 while ( nIndex
!= -1 )
81 OUString aLine
= aMessage
.getToken( 0, CHAR_CR
, nIndex
);
82 DrawText( aLineStart
, aLine
);
83 aLineStart
.Y() += nTextHeight
;
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */