update credits
[LibreOffice.git] / padmin / source / titlectrl.cxx
blob5d2cfb50a9844c8ad67c68e8a6a03f0999317689
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <titlectrl.hxx>
22 using namespace padmin;
24 TitleImage::TitleImage( Window* pParent, const ResId& rResId ) :
25 Control( pParent, rResId ),
26 m_bArranged( false )
28 Font aFont = GetFont();
29 aFont.SetHeight( aFont.GetHeight()*3/2 );
30 SetFont( aFont );
33 // -----------------------------------------------------------------------
35 TitleImage::~TitleImage()
39 // -----------------------------------------------------------------------
41 void TitleImage::arrange()
43 m_bArranged = true;
44 Size aCtrlSize( GetSizePixel() );
45 Size aImageSize( m_aImage.GetSizePixel() );
46 Size aTextSize( GetTextWidth( m_aText ), GetTextHeight() );
48 m_aImagePos.Y() = ( aCtrlSize.Height() - aImageSize.Height() ) / 2;
49 m_aImagePos.X() = m_aImagePos.Y() < 0 ? -m_aImagePos.Y() : m_aImagePos.Y();
50 m_aTextPos.X() = m_aImagePos.X() + aImageSize.Width() + aTextSize.Height()/2;
51 m_aTextPos.Y() = ( aCtrlSize.Height() - aTextSize.Height() ) / 2;
54 // -----------------------------------------------------------------------
56 void TitleImage::Paint( const Rectangle& )
58 if( ! m_bArranged )
59 arrange();
61 SetLineColor( m_aBGColor );
62 SetFillColor( m_aBGColor );
63 DrawRect( Rectangle( Point( 0, 0 ), Size( GetSizePixel() ) ) );
64 DrawImage( m_aImagePos, m_aImage );
65 DrawText( m_aTextPos, m_aText );
68 // -----------------------------------------------------------------------
70 void TitleImage::SetText( const OUString& rText )
72 m_aText = rText;
73 m_bArranged = false;
74 Invalidate();
77 // -----------------------------------------------------------------------
79 void TitleImage::SetImage( const Image& rImage )
81 m_aImage = rImage;
82 m_bArranged = false;
83 Invalidate();
86 // -----------------------------------------------------------------------
88 void TitleImage::SetBackgroundColor( const Color& rColor )
90 m_aBGColor = rColor;
91 Invalidate();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */