xref: /aoo41x/main/sc/source/ui/view/hintwin.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 // System - Includes -----------------------------------------------------
28 
29 
30 
31 // INCLUDE ---------------------------------------------------------------
32 
33 #include "hintwin.hxx"
34 #include "global.hxx"
35 
36 #define HINT_LINESPACE	2
37 #define HINT_INDENT		3
38 #define HINT_MARGIN		4
39 
40 //==================================================================
41 
ScHintWindow(Window * pParent,const String & rTit,const String & rMsg)42 ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) :
43 	Window( pParent, WinBits( WB_BORDER ) ),
44 	aTitle( rTit ),
45 	aMessage( rMsg )
46 {
47 	aMessage.ConvertLineEnd( LINEEND_CR );
48 
49 	//	Hellgelb, wie Notizen in detfunc.cxx
50 	Color aYellow( 255,255,192 );			// hellgelb
51 	SetBackground( aYellow );
52 
53 	aTextFont = GetFont();
54 	aTextFont.SetTransparent( sal_True );
55 	aTextFont.SetWeight( WEIGHT_NORMAL );
56 	aHeadFont = aTextFont;
57 	aHeadFont.SetWeight( WEIGHT_BOLD );
58 
59 	SetFont( aHeadFont );
60 	Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
61 	SetFont( aTextFont );
62 
63 	Size aTextSize;
64 	xub_StrLen nIndex = 0;
65 	while ( nIndex != STRING_NOTFOUND )
66 	{
67 		String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
68 		Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
69 		nTextHeight = aLineSize.Height();
70 		aTextSize.Height() += nTextHeight;
71 		if ( aLineSize.Width() > aTextSize.Width() )
72 			aTextSize.Width() = aLineSize.Width();
73 	}
74 	aTextSize.Width() += HINT_INDENT;
75 
76 	aTextStart = Point( HINT_MARGIN + HINT_INDENT,
77 						aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
78 
79 	Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
80 					aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
81 	SetOutputSizePixel( aWinSize );
82 }
83 
84 
~ScHintWindow()85 ScHintWindow::~ScHintWindow()
86 {
87 }
88 
89 
Paint(const Rectangle &)90 void __EXPORT ScHintWindow::Paint( const Rectangle& /* rRect */ )
91 {
92 	SetFont( aHeadFont );
93 	DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
94 
95 	SetFont( aTextFont );
96 	xub_StrLen nIndex = 0;
97 	Point aLineStart = aTextStart;
98 	while ( nIndex != STRING_NOTFOUND )
99 	{
100 		String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
101 		DrawText( aLineStart, aLine );
102 		aLineStart.Y() += nTextHeight;
103 	}
104 }
105