LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppTitleWindow.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 85 85 100.0 %
Date: 2014-11-03 Functions: 12 12 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          48 : OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,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          48 : , m_bShift(_bShift)
      37             : {
      38             : 
      39          48 :     setTitle(_nTitleId);
      40          48 :     SetBorderStyle(WindowBorderStyle::MONO);
      41          48 :     ImplInitSettings( true, true, true );
      42             : 
      43          48 :     vcl::Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle };
      44         192 :     for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
      45         144 :         pWindows[i]->Show();
      46          48 : }
      47             : 
      48          84 : OTitleWindow::~OTitleWindow()
      49             : {
      50          36 :     if ( m_pChild )
      51             :     {
      52          36 :         m_pChild->Hide();
      53          36 :         boost::scoped_ptr<vcl::Window> aTemp(m_pChild);
      54          36 :         m_pChild = NULL;
      55             :     }
      56             : 
      57          48 : }
      58             : 
      59          48 : void OTitleWindow::setChildWindow(vcl::Window* _pChild)
      60             : {
      61          48 :     m_pChild = _pChild;
      62          48 : }
      63             : 
      64             : #define SPACE_BORDER    1
      65         146 : void OTitleWindow::Resize()
      66             : {
      67             :     // parent window dimension
      68         146 :     Size aOutputSize( GetOutputSize() );
      69         146 :     long nOutputWidth   = aOutputSize.Width();
      70         146 :     long nOutputHeight  = aOutputSize.Height();
      71             : 
      72         146 :     Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
      73         146 :     sal_Int32 nXOffset = aTextSize.Width();
      74         146 :     sal_Int32 nYOffset = aTextSize.Height();
      75         146 :     sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
      76             : 
      77             :     m_aSpace1.SetPosSizePixel(  Point(SPACE_BORDER, SPACE_BORDER ),
      78         146 :                                 Size(nXOffset , nHeight - SPACE_BORDER) );
      79         146 :     m_aSpace2.SetPosSizePixel(  Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
      80         292 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
      81         292 :     m_aTitle.SetPosSizePixel(   Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
      82         438 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
      83         146 :     if ( m_pChild )
      84             :     {
      85         226 :         m_pChild->SetPosSizePixel(  Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
      86         372 :                                     Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
      87             :     }
      88         146 : }
      89             : 
      90          54 : void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
      91             : {
      92          54 :     if ( _nTitleId != 0 )
      93             :     {
      94          38 :         m_aTitle.SetText(ModuleRes(_nTitleId));
      95             :     }
      96          54 : }
      97             : 
      98          24 : void OTitleWindow::GetFocus()
      99             : {
     100          24 :     Window::GetFocus();
     101          24 :     if ( m_pChild )
     102          14 :         m_pChild->GrabFocus();
     103          24 : }
     104             : 
     105          50 : long OTitleWindow::GetWidthPixel() const
     106             : {
     107          50 :     Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
     108          50 :     sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width();
     109             : 
     110          50 :     return nWidth;
     111             : }
     112             : 
     113          48 : void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
     114             : {
     115          48 :     Window::DataChanged( rDCEvt );
     116             : 
     117         144 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     118          96 :         (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     119         192 :         (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     120          96 :         ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     121          48 :         (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     122             :     {
     123          48 :         ImplInitSettings( true, true, true );
     124          48 :         Invalidate();
     125             :     }
     126          48 : }
     127             : 
     128          96 : void OTitleWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     129             : {
     130          96 :     AllSettings aAllSettings = GetSettings();
     131         192 :     StyleSettings aStyle = aAllSettings.GetStyleSettings();
     132          96 :     aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
     133          96 :     aAllSettings.SetStyleSettings(aStyle);
     134          96 :     SetSettings(aAllSettings);
     135             : 
     136          96 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     137          96 :     if( bFont )
     138             :     {
     139          96 :         vcl::Font aFont;
     140          96 :         aFont = rStyleSettings.GetFieldFont();
     141          96 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     142          96 :         SetPointFont( aFont );
     143             :     }
     144             : 
     145          96 :     if( bForeground || bFont )
     146             :     {
     147          96 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
     148          96 :         SetTextFillColor();
     149             :     }
     150             : 
     151          96 :     if( bBackground )
     152          96 :         SetBackground( rStyleSettings.GetFieldColor() );
     153             : 
     154          96 :     vcl::Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle};
     155         384 :     for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
     156             :     {
     157         288 :         vcl::Font aFont = pWindows[i]->GetFont();
     158         288 :         aFont.SetWeight(WEIGHT_BOLD);
     159         288 :         pWindows[i]->SetFont(aFont);
     160         288 :         pWindows[i]->SetTextColor( aStyle.GetLightColor() );
     161         288 :         pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) );
     162         384 :     }
     163          96 : }
     164             : 
     165          72 : } // namespace dbaui
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10