LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppTitleWindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 106 106 100.0 %
Date: 2015-06-13 12:38:46 Functions: 14 14 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          21 : OTitleWindow::OTitleWindow(vcl::Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,bool _bShift)
      31             : : Window(_pParent,_nBits | WB_DIALOGCONTROL)
      32             : , m_aSpace1(VclPtr<FixedText>::Create(this))
      33             : , m_aSpace2(VclPtr<FixedText>::Create(this))
      34             : , m_aTitle(VclPtr<FixedText>::Create(this))
      35             : , m_pChild(NULL)
      36          21 : , m_bShift(_bShift)
      37             : {
      38             : 
      39          21 :     setTitle(_nTitleId);
      40          21 :     SetBorderStyle(WindowBorderStyle::MONO);
      41          21 :     ImplInitSettings( true, true, true );
      42             : 
      43          21 :     const StyleSettings& rStyle = Application::GetSettings().GetStyleSettings();
      44          21 :     vcl::Window* pWindows[] = { m_aSpace1.get(), m_aSpace2.get(), m_aTitle.get() };
      45          84 :     for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
      46             :     {
      47          63 :         vcl::Font aFont = pWindows[i]->GetControlFont();
      48          63 :         aFont.SetWeight(WEIGHT_BOLD);
      49          63 :         pWindows[i]->SetControlFont(aFont);
      50          63 :         pWindows[i]->SetControlForeground(rStyle.GetLightColor());
      51          63 :         pWindows[i]->SetControlBackground(rStyle.GetShadowColor());
      52          63 :         pWindows[i]->Show();
      53          63 :     }
      54          21 : }
      55             : 
      56          45 : OTitleWindow::~OTitleWindow()
      57             : {
      58          15 :     disposeOnce();
      59          30 : }
      60             : 
      61          15 : void OTitleWindow::dispose()
      62             : {
      63          15 :     if ( m_pChild )
      64             :     {
      65          15 :         m_pChild->Hide();
      66             :     }
      67          15 :     m_pChild.disposeAndClear();
      68          15 :     m_aSpace1.disposeAndClear();
      69          15 :     m_aSpace2.disposeAndClear();
      70          15 :     m_aTitle.disposeAndClear();
      71          15 :     vcl::Window::dispose();
      72          15 : }
      73             : 
      74          21 : void OTitleWindow::setChildWindow(vcl::Window* _pChild)
      75             : {
      76          21 :     m_pChild = _pChild;
      77          21 : }
      78             : 
      79             : #define SPACE_BORDER    1
      80          64 : void OTitleWindow::Resize()
      81             : {
      82             :     // parent window dimension
      83          64 :     Size aOutputSize( GetOutputSize() );
      84          64 :     long nOutputWidth   = aOutputSize.Width();
      85          64 :     long nOutputHeight  = aOutputSize.Height();
      86             : 
      87          64 :     Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
      88          64 :     sal_Int32 nXOffset = aTextSize.Width();
      89          64 :     sal_Int32 nYOffset = aTextSize.Height();
      90          64 :     sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
      91             : 
      92          64 :     m_aSpace1->SetPosSizePixel(  Point(SPACE_BORDER, SPACE_BORDER ),
      93          64 :                                 Size(nXOffset , nHeight - SPACE_BORDER) );
      94         128 :     m_aSpace2->SetPosSizePixel(  Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
      95         128 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
      96         192 :     m_aTitle->SetPosSizePixel(   Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
      97         192 :                                 Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
      98          64 :     if ( m_pChild )
      99             :     {
     100         163 :         m_pChild->SetPosSizePixel(  Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
     101         163 :                                     Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
     102             :     }
     103          64 : }
     104             : 
     105          24 : void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
     106             : {
     107          24 :     if ( _nTitleId != 0 )
     108             :     {
     109          17 :         m_aTitle->SetText(ModuleRes(_nTitleId));
     110             :     }
     111          24 : }
     112             : 
     113          10 : void OTitleWindow::GetFocus()
     114             : {
     115          10 :     Window::GetFocus();
     116          10 :     if ( m_pChild )
     117           6 :         m_pChild->GrabFocus();
     118          10 : }
     119             : 
     120          22 : long OTitleWindow::GetWidthPixel() const
     121             : {
     122          22 :     Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
     123          22 :     sal_Int32 nWidth = GetTextWidth(m_aTitle->GetText()) + 2*aTextSize.Width();
     124             : 
     125          22 :     return nWidth;
     126             : }
     127             : 
     128          21 : void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
     129             : {
     130          21 :     Window::DataChanged( rDCEvt );
     131             : 
     132          84 :     if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
     133          42 :         (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
     134         105 :         (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
     135          63 :         ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
     136          84 :         (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
     137             :     {
     138          21 :         ImplInitSettings( true, true, true );
     139          21 :         Invalidate();
     140             :     }
     141          21 : }
     142             : 
     143          42 : void OTitleWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     144             : {
     145             :     // FIXME RenderContext
     146          42 :     AllSettings aAllSettings = GetSettings();
     147          84 :     StyleSettings aStyle = aAllSettings.GetStyleSettings();
     148          42 :     aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
     149          42 :     aAllSettings.SetStyleSettings(aStyle);
     150          42 :     SetSettings(aAllSettings);
     151             : 
     152          42 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     153          42 :     if( bFont )
     154             :     {
     155          42 :         vcl::Font aFont;
     156          42 :         aFont = rStyleSettings.GetFieldFont();
     157          42 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     158          42 :         SetPointFont(*this, aFont);
     159             :     }
     160             : 
     161          42 :     if( bForeground || bFont )
     162             :     {
     163          42 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
     164          42 :         SetTextFillColor();
     165             :     }
     166             : 
     167          42 :     if( bBackground )
     168          84 :         SetBackground( rStyleSettings.GetFieldColor() );
     169          42 : }
     170             : 
     171          15 : void OTitleWindow::ApplySettings(vcl::RenderContext& rRenderContext)
     172             : {
     173             :     // FIXME RenderContext
     174          15 :     AllSettings aAllSettings = rRenderContext.GetSettings();
     175          30 :     StyleSettings aStyle = aAllSettings.GetStyleSettings();
     176          15 :     aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
     177          15 :     aAllSettings.SetStyleSettings(aStyle);
     178          15 :     rRenderContext.SetSettings(aAllSettings);
     179             : 
     180          15 :     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     181          30 :     vcl::Font aFont;
     182          15 :     aFont = rStyleSettings.GetFieldFont();
     183          15 :     aFont.SetColor(rStyleSettings.GetWindowTextColor());
     184          15 :     SetPointFont(*this, aFont);
     185             : 
     186          15 :     rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
     187          15 :     rRenderContext.SetTextFillColor();
     188             : 
     189          30 :     rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
     190          15 : }
     191             : 
     192          36 : } // namespace dbaui
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11