LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppTitleWindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 82 82 100.0 %
Date: 2014-04-11 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "AppTitleWindow.hxx"
      21             : #include "moduledbu.hxx"
      22             : #include <vcl/svapp.hxx>
      23             : #include <vcl/settings.hxx>
      24             : #include <tools/debug.hxx>
      25             : #include <boost/scoped_ptr.hpp>
      26             : 
      27             : namespace dbaui
      28             : {
      29             : 
      30          15 : OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift)
      31             : : Window(_pParent,_nBits | WB_DIALOGCONTROL)
      32             : , m_aSpace1(this)
      33             : , m_aSpace2(this)
      34             : , m_aTitle(this)
      35             : , m_pChild(NULL)
      36          15 : , m_bShift(_bShift)
      37             : {
      38             : 
      39          15 :     setTitle(_nTitleId);
      40          15 :     SetBorderStyle(WINDOW_BORDER_MONO);
      41          15 :     ImplInitSettings( sal_True, sal_True, sal_True );
      42             : 
      43          15 :     Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle };
      44          60 :     for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
      45          45 :         pWindows[i]->Show();
      46          15 : }
      47             : 
      48           7 : OTitleWindow::~OTitleWindow()
      49             : {
      50           3 :     if ( m_pChild )
      51             :     {
      52           3 :         m_pChild->Hide();
      53           3 :         boost::scoped_ptr<Window> aTemp(m_pChild);
      54           3 :         m_pChild = NULL;
      55             :     }
      56             : 
      57           4 : }
      58             : 
      59          15 : void OTitleWindow::setChildWindow(Window* _pChild)
      60             : {
      61          15 :     m_pChild = _pChild;
      62          15 : }
      63             : 
      64             : #define SPACE_BORDER    1
      65          49 : void OTitleWindow::Resize()
      66             : {
      67             :     // parent window dimension
      68          49 :     Size aOutputSize( GetOutputSize() );
      69          49 :     long nOutputWidth   = aOutputSize.Width();
      70          49 :     long nOutputHeight  = aOutputSize.Height();
      71             : 
      72          49 :     Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
      73          49 :     sal_Int32 nXOffset = aTextSize.Width();
      74          49 :     sal_Int32 nYOffset = aTextSize.Height();
      75          49 :     sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
      76             : 
      77             :     m_aSpace1.SetPosSizePixel(  Point(SPACE_BORDER, SPACE_BORDER ),
      78          49 :                                 Size(nXOffset , nHeight - SPACE_BORDER) );
      79             :     m_aSpace2.SetPosSizePixel(  Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
      80          49 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
      81             :     m_aTitle.SetPosSizePixel(   Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
      82          49 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
      83          49 :     if ( m_pChild )
      84             :     {
      85          49 :         m_pChild->SetPosSizePixel(  Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
      86          98 :                                     Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
      87             :     }
      88          49 : }
      89             : 
      90          17 : void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
      91             : {
      92          17 :     if ( _nTitleId != 0 )
      93             :     {
      94          12 :         m_aTitle.SetText(ModuleRes(_nTitleId));
      95             :     }
      96          17 : }
      97             : 
      98           6 : void OTitleWindow::GetFocus()
      99             : {
     100           6 :     Window::GetFocus();
     101           6 :     if ( m_pChild )
     102           5 :         m_pChild->GrabFocus();
     103           6 : }
     104             : 
     105          17 : long OTitleWindow::GetWidthPixel() const
     106             : {
     107          17 :     Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
     108          17 :     sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width();
     109             : 
     110          17 :     return nWidth;
     111             : }
     112             : 
     113          15 : void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
     114             : {
     115          15 :     Window::DataChanged( rDCEvt );
     116             : 
     117          45 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     118          30 :         (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     119          60 :         (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     120          30 :         ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     121          15 :         (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     122             :     {
     123          15 :         ImplInitSettings( sal_True, sal_True, sal_True );
     124          15 :         Invalidate();
     125             :     }
     126          15 : }
     127             : 
     128          30 : void OTitleWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
     129             : {
     130          30 :     AllSettings aAllSettings = GetSettings();
     131          60 :     StyleSettings aStyle = aAllSettings.GetStyleSettings();
     132          30 :     aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
     133          30 :     aAllSettings.SetStyleSettings(aStyle);
     134          30 :     SetSettings(aAllSettings);
     135             : 
     136          30 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     137          30 :     if( bFont )
     138             :     {
     139          30 :         Font aFont;
     140          30 :         aFont = rStyleSettings.GetFieldFont();
     141          30 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     142          30 :         SetPointFont( aFont );
     143             :     }
     144             : 
     145          30 :     if( bForeground || bFont )
     146             :     {
     147          30 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
     148          30 :         SetTextFillColor();
     149             :     }
     150             : 
     151          30 :     if( bBackground )
     152          30 :         SetBackground( rStyleSettings.GetFieldColor() );
     153             : 
     154          30 :     Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle};
     155         120 :     for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
     156             :     {
     157          90 :         Font aFont = pWindows[i]->GetFont();
     158          90 :         aFont.SetWeight(WEIGHT_BOLD);
     159          90 :         pWindows[i]->SetFont(aFont);
     160          90 :         pWindows[i]->SetTextColor( aStyle.GetLightColor() );
     161          90 :         pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) );
     162         120 :     }
     163          30 : }
     164             : 
     165             : } // namespace dbaui
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10