1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hintwin.cxx,v $
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"
43 #define HINT_LINESPACE 2
47 //==================================================================
49 ScHintWindow::ScHintWindow( Window
* pParent
, const String
& rTit
, const String
& rMsg
) :
50 Window( pParent
, WinBits( WB_BORDER
) ),
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
);
67 Size
aHeadSize( GetTextWidth( aTitle
), GetTextHeight() );
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 */ )
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
;