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