1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 // System - Includes ----------------------------------------------------- 32 33 34 35 // INCLUDE --------------------------------------------------------------- 36 37 #include "hintwin.hxx" 38 #include "global.hxx" 39 40 #define HINT_LINESPACE 2 41 #define HINT_INDENT 3 42 #define HINT_MARGIN 4 43 44 //================================================================== 45 46 ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) : 47 Window( pParent, WinBits( WB_BORDER ) ), 48 aTitle( rTit ), 49 aMessage( rMsg ) 50 { 51 aMessage.ConvertLineEnd( LINEEND_CR ); 52 53 // Hellgelb, wie Notizen in detfunc.cxx 54 Color aYellow( 255,255,192 ); // hellgelb 55 SetBackground( aYellow ); 56 57 aTextFont = GetFont(); 58 aTextFont.SetTransparent( sal_True ); 59 aTextFont.SetWeight( WEIGHT_NORMAL ); 60 aHeadFont = aTextFont; 61 aHeadFont.SetWeight( WEIGHT_BOLD ); 62 63 SetFont( aHeadFont ); 64 Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() ); 65 SetFont( aTextFont ); 66 67 Size aTextSize; 68 xub_StrLen nIndex = 0; 69 while ( nIndex != STRING_NOTFOUND ) 70 { 71 String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex ); 72 Size aLineSize( GetTextWidth( aLine ), GetTextHeight() ); 73 nTextHeight = aLineSize.Height(); 74 aTextSize.Height() += nTextHeight; 75 if ( aLineSize.Width() > aTextSize.Width() ) 76 aTextSize.Width() = aLineSize.Width(); 77 } 78 aTextSize.Width() += HINT_INDENT; 79 80 aTextStart = Point( HINT_MARGIN + HINT_INDENT, 81 aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE ); 82 83 Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1, 84 aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 ); 85 SetOutputSizePixel( aWinSize ); 86 } 87 88 89 ScHintWindow::~ScHintWindow() 90 { 91 } 92 93 94 void __EXPORT ScHintWindow::Paint( const Rectangle& /* rRect */ ) 95 { 96 SetFont( aHeadFont ); 97 DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle ); 98 99 SetFont( aTextFont ); 100 xub_StrLen nIndex = 0; 101 Point aLineStart = aTextStart; 102 while ( nIndex != STRING_NOTFOUND ) 103 { 104 String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex ); 105 DrawText( aLineStart, aLine ); 106 aLineStart.Y() += nTextHeight; 107 } 108 } 109