fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / hintwin.cxx
blobb9d5113da83cc9369a3f8fd39bdba9fb4d7ae09f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
21 #include "global.hxx"
23 #define HINT_LINESPACE 2
24 #define HINT_INDENT 3
25 #define HINT_MARGIN 4
27 ScHintWindow::ScHintWindow( vcl::Window* pParent, const OUString& rTit, const OUString& rMsg ) :
28 Window( pParent, WinBits( WB_BORDER ) ),
29 aTitle( rTit ),
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 );
42 SetFont( aHeadFont );
43 Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
44 SetFont( aTextFont );
46 Size aTextSize;
47 sal_Int32 nIndex = 0;
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 */ )
73 SetFont( aHeadFont );
74 DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
76 SetFont( aTextFont );
77 sal_Int32 nIndex = 0;
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: */