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

Generated by: LCOV version 1.10