update dev300-m58
[ooovba.git] / padmin / source / titlectrl.cxx
blob66ef87a297bdd67f0b983a4b071d137e8d4cfcae
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: titlectrl.cxx,v $
10 * $Revision: 1.4 $
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 #ifndef _PAD_NEWPPDLG_HXX_
32 #include <titlectrl.hxx>
33 #endif
35 using namespace padmin;
37 TitleImage::TitleImage( Window* pParent, const ResId& rResId ) :
38 Control( pParent, rResId ),
39 m_bArranged( false )
41 Font aFont = GetFont();
42 aFont.SetHeight( aFont.GetHeight()*3/2 );
43 SetFont( aFont );
46 // -----------------------------------------------------------------------
48 TitleImage::~TitleImage()
52 // -----------------------------------------------------------------------
54 void TitleImage::arrange()
56 m_bArranged = true;
57 Size aCtrlSize( GetSizePixel() );
58 Size aImageSize( m_aImage.GetSizePixel() );
59 Size aTextSize( GetTextWidth( m_aText ), GetTextHeight() );
61 m_aImagePos.Y() = ( aCtrlSize.Height() - aImageSize.Height() ) / 2;
62 m_aImagePos.X() = m_aImagePos.Y() < 0 ? -m_aImagePos.Y() : m_aImagePos.Y();
63 m_aTextPos.X() = m_aImagePos.X() + aImageSize.Width() + aTextSize.Height()/2;
64 m_aTextPos.Y() = ( aCtrlSize.Height() - aTextSize.Height() ) / 2;
67 // -----------------------------------------------------------------------
69 void TitleImage::Paint( const Rectangle& )
71 if( ! m_bArranged )
72 arrange();
74 SetLineColor( m_aBGColor );
75 SetFillColor( m_aBGColor );
76 DrawRect( Rectangle( Point( 0, 0 ), Size( GetSizePixel() ) ) );
77 DrawImage( m_aImagePos, m_aImage );
78 DrawText( m_aTextPos, m_aText );
81 // -----------------------------------------------------------------------
83 void TitleImage::SetText( const String& rText )
85 m_aText = rText;
86 m_bArranged = false;
87 Invalidate();
90 // -----------------------------------------------------------------------
92 void TitleImage::SetImage( const Image& rImage )
94 m_aImage = rImage;
95 m_bArranged = false;
96 Invalidate();
99 // -----------------------------------------------------------------------
101 void TitleImage::SetBackgroundColor( const Color& rColor )
103 m_aBGColor = rColor;
104 Invalidate();