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

Generated by: LCOV version 1.10