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

Generated by: LCOV version 1.10