merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / view / hintwin.cxx
blob2da616c47fba7653d4306a79dbb1ee718768765d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hintwin.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // System - Includes -----------------------------------------------------
38 // INCLUDE ---------------------------------------------------------------
40 #include "hintwin.hxx"
41 #include "global.hxx"
43 #define HINT_LINESPACE 2
44 #define HINT_INDENT 3
45 #define HINT_MARGIN 4
47 //==================================================================
49 ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) :
50 Window( pParent, WinBits( WB_BORDER ) ),
51 aTitle( rTit ),
52 aMessage( rMsg )
54 aMessage.ConvertLineEnd( LINEEND_CR );
56 // Hellgelb, wie Notizen in detfunc.cxx
57 Color aYellow( 255,255,192 ); // hellgelb
58 SetBackground( aYellow );
60 aTextFont = GetFont();
61 aTextFont.SetTransparent( TRUE );
62 aTextFont.SetWeight( WEIGHT_NORMAL );
63 aHeadFont = aTextFont;
64 aHeadFont.SetWeight( WEIGHT_BOLD );
66 SetFont( aHeadFont );
67 Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
68 SetFont( aTextFont );
70 Size aTextSize;
71 xub_StrLen nIndex = 0;
72 while ( nIndex != STRING_NOTFOUND )
74 String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
75 Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
76 nTextHeight = aLineSize.Height();
77 aTextSize.Height() += nTextHeight;
78 if ( aLineSize.Width() > aTextSize.Width() )
79 aTextSize.Width() = aLineSize.Width();
81 aTextSize.Width() += HINT_INDENT;
83 aTextStart = Point( HINT_MARGIN + HINT_INDENT,
84 aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
86 Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
87 aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
88 SetOutputSizePixel( aWinSize );
92 ScHintWindow::~ScHintWindow()
97 void __EXPORT ScHintWindow::Paint( const Rectangle& /* rRect */ )
99 SetFont( aHeadFont );
100 DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
102 SetFont( aTextFont );
103 xub_StrLen nIndex = 0;
104 Point aLineStart = aTextStart;
105 while ( nIndex != STRING_NOTFOUND )
107 String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
108 DrawText( aLineStart, aLine );
109 aLineStart.Y() += nTextHeight;