LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/control - VertSplitView.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-12-27 Functions: 0 11 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 "VertSplitView.hxx"
      21             : 
      22             : #include <tools/debug.hxx>
      23             : #include <vcl/split.hxx>
      24             : 
      25             : #define SPLITTER_WIDTH  80
      26             : 
      27             : using namespace ::dbaui;
      28             : 
      29             : //==================================================================
      30             : // class OSplitterView
      31             : //==================================================================
      32             : DBG_NAME(OSplitterView)
      33           0 : OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER
      34             :     ,m_pSplitter( NULL )
      35             :     ,m_pLeft(NULL)
      36             :     ,m_pRight(NULL)
      37           0 :     ,m_bVertical(_bVertical)
      38             : {
      39             :     DBG_CTOR(OSplitterView,NULL);
      40           0 :     ImplInitSettings( sal_True, sal_True, sal_True );
      41           0 : }
      42             : // -----------------------------------------------------------------------------
      43           0 : OSplitterView::~OSplitterView()
      44             : {
      45             :     DBG_DTOR(OSplitterView,NULL);
      46           0 :     m_pRight = m_pLeft = NULL;
      47           0 : }
      48             : //------------------------------------------------------------------------------
      49           0 : IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ )
      50             : {
      51             :     OSL_ENSURE(m_pSplitter, "Splitter is NULL!");
      52           0 :     if ( m_bVertical )
      53             :     {
      54           0 :         long nPosY = m_pSplitter->GetPosPixel().Y();
      55           0 :         m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nPosY ) );
      56             :     }
      57             :     else
      58           0 :         m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
      59             : 
      60           0 :     Resize();
      61           0 :     return 0L;
      62             : }
      63             : // -----------------------------------------------------------------------------
      64           0 : void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
      65             : {
      66           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
      67             : 
      68           0 :     if ( bFont )
      69             :     {
      70           0 :         Font aFont = rStyleSettings.GetAppFont();
      71           0 :         if ( IsControlFont() )
      72           0 :             aFont.Merge( GetControlFont() );
      73           0 :         SetPointFont( aFont );
      74             : //      Set/*Zoomed*/PointFont( aFont );
      75             :     }
      76             : 
      77           0 :     if ( bFont || bForeground )
      78             :     {
      79           0 :         Color aTextColor = rStyleSettings.GetButtonTextColor();
      80           0 :         if ( IsControlForeground() )
      81           0 :             aTextColor = GetControlForeground();
      82           0 :         SetTextColor( aTextColor );
      83             :     }
      84             : 
      85           0 :     if ( bBackground )
      86             :     {
      87           0 :         if( IsControlBackground() )
      88           0 :             SetBackground( GetControlBackground() );
      89             :         else
      90           0 :             SetBackground( rStyleSettings.GetFaceColor() );
      91             :     }
      92           0 : }
      93             : // -----------------------------------------------------------------------
      94           0 : void OSplitterView::DataChanged( const DataChangedEvent& rDCEvt )
      95             : {
      96           0 :     Window::DataChanged( rDCEvt );
      97             : 
      98           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
      99           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     100             :     {
     101           0 :         ImplInitSettings( sal_True, sal_True, sal_True );
     102           0 :         Invalidate();
     103             :     }
     104           0 : }
     105             : // -----------------------------------------------------------------------------
     106           0 : void OSplitterView::GetFocus()
     107             : {
     108           0 :     Window::GetFocus();
     109             : 
     110             :     // forward the focus to the current cell of the editor control
     111           0 :     if ( m_pLeft )
     112           0 :         m_pLeft->GrabFocus();
     113           0 :     else if ( m_pRight )
     114           0 :         m_pRight->GrabFocus();
     115           0 : }
     116             : 
     117             : // -------------------------------------------------------------------------
     118           0 : void OSplitterView::Resize()
     119             : {
     120           0 :     Window::Resize();
     121             :     OSL_ENSURE( m_pRight, "No init called!");
     122             : 
     123           0 :     Point   aSplitPos;
     124           0 :     Size    aSplitSize;
     125           0 :     Point   aPlaygroundPos( 0,0 );
     126           0 :     Size    aPlaygroundSize( GetOutputSizePixel() );
     127             : 
     128           0 :     if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter )
     129             :     {
     130           0 :         aSplitPos   = m_pSplitter->GetPosPixel();
     131           0 :         aSplitSize  = m_pSplitter->GetOutputSizePixel();
     132           0 :         if ( m_bVertical )
     133             :         {
     134             :             // calculate the splitter pos and size
     135           0 :             aSplitPos.Y() = aPlaygroundPos.Y();
     136           0 :             aSplitSize.Height() = aPlaygroundSize.Height();
     137             : 
     138           0 :             if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() ))
     139           0 :                 aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width();
     140             : 
     141           0 :             if( aSplitPos.X() <= aPlaygroundPos.X() )
     142           0 :                 aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.3);
     143             : 
     144             :             // the tree pos and size
     145           0 :             Point   aTreeViewPos( aPlaygroundPos );
     146           0 :             Size    aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() );
     147             : 
     148             :             // set the size of treelistbox
     149           0 :             m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
     150             : 
     151             :             //set the size of the splitter
     152           0 :             m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) );
     153           0 :             m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
     154             :         }
     155             :         else
     156             :         {
     157           0 :             aSplitPos.X() = aPlaygroundPos.X();
     158           0 :             aSplitSize.Width() = aPlaygroundSize.Width();
     159             : 
     160           0 :             if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
     161           0 :                 aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
     162             : 
     163           0 :             if( aSplitPos.Y() <= aPlaygroundPos.Y() )
     164           0 :                 aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3);
     165             : 
     166             :             // the tree pos and size
     167           0 :             Point   aTreeViewPos( aPlaygroundPos );
     168           0 :             Size    aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y());
     169             : 
     170             :             // set the size of treelistbox
     171           0 :             m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
     172             : 
     173             :             //set the size of the splitter
     174           0 :             m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) );
     175           0 :             m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
     176             :         }
     177             :     }
     178             : 
     179           0 :     if ( m_pRight )
     180             :     {
     181           0 :         if ( m_bVertical )
     182           0 :             m_pRight->setPosSizePixel( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(),
     183           0 :                                    aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height());
     184             :         else
     185           0 :             m_pRight->setPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(),
     186           0 :                                    aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y());
     187             :     }
     188             : 
     189           0 : }
     190             : // -----------------------------------------------------------------------------
     191           0 : void OSplitterView::set(Window* _pRight,Window* _pLeft)
     192             : {
     193           0 :     m_pLeft = _pLeft;
     194           0 :     m_pRight = _pRight;
     195           0 : }
     196             : // -----------------------------------------------------------------------------
     197           0 : void OSplitterView::setSplitter(Splitter* _pSplitter)
     198             : {
     199           0 :     m_pSplitter = _pSplitter;
     200           0 :     if ( m_pSplitter )
     201             :     {
     202           0 :         m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() );
     203           0 :         m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) );
     204           0 :         m_pSplitter->Show();
     205           0 :         LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter);
     206             :     }
     207           0 : }
     208             : 
     209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10