LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - VertSplitView.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 64 96 66.7 %
Date: 2014-04-11 Functions: 8 11 72.7 %
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           5 : OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER
      32             :     ,m_pSplitter( NULL )
      33             :     ,m_pLeft(NULL)
      34             :     ,m_pRight(NULL)
      35           5 :     ,m_bVertical(_bVertical)
      36             : {
      37           5 :     ImplInitSettings( sal_True, sal_True, sal_True );
      38           5 : }
      39             : 
      40           2 : OSplitterView::~OSplitterView()
      41             : {
      42           1 :     m_pRight = m_pLeft = NULL;
      43           1 : }
      44             : 
      45          10 : IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ )
      46             : {
      47             :     OSL_ENSURE(m_pSplitter, "Splitter is NULL!");
      48           5 :     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           5 :         m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
      55             : 
      56           5 :     Resize();
      57           5 :     return 0L;
      58             : }
      59             : 
      60           5 : void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
      61             : {
      62           5 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
      63             : 
      64           5 :     if ( bFont )
      65             :     {
      66           5 :         Font aFont = rStyleSettings.GetAppFont();
      67           5 :         if ( IsControlFont() )
      68           0 :             aFont.Merge( GetControlFont() );
      69           5 :         SetPointFont( aFont );
      70             : //      Set/*Zoomed*/PointFont( aFont );
      71             :     }
      72             : 
      73           5 :     if ( bFont || bForeground )
      74             :     {
      75           5 :         Color aTextColor = rStyleSettings.GetButtonTextColor();
      76           5 :         if ( IsControlForeground() )
      77           0 :             aTextColor = GetControlForeground();
      78           5 :         SetTextColor( aTextColor );
      79             :     }
      80             : 
      81           5 :     if ( bBackground )
      82             :     {
      83           5 :         if( IsControlBackground() )
      84           0 :             SetBackground( GetControlBackground() );
      85             :         else
      86           5 :             SetBackground( rStyleSettings.GetFaceColor() );
      87             :     }
      88           5 : }
      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( sal_True, sal_True, sal_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          24 : void OSplitterView::Resize()
     114             : {
     115          24 :     Window::Resize();
     116             :     OSL_ENSURE( m_pRight, "No init called!");
     117             : 
     118          24 :     Point   aSplitPos;
     119          24 :     Size    aSplitSize;
     120          24 :     Point   aPlaygroundPos( 0,0 );
     121          24 :     Size    aPlaygroundSize( GetOutputSizePixel() );
     122             : 
     123          24 :     if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter )
     124             :     {
     125          24 :         aSplitPos   = m_pSplitter->GetPosPixel();
     126          24 :         aSplitSize  = m_pSplitter->GetOutputSizePixel();
     127          24 :         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          24 :             aSplitPos.X() = aPlaygroundPos.X();
     153          24 :             aSplitSize.Width() = aPlaygroundSize.Width();
     154             : 
     155          24 :             if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
     156          10 :                 aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
     157             : 
     158          24 :             if( aSplitPos.Y() <= aPlaygroundPos.Y() )
     159          15 :                 aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3);
     160             : 
     161             :             // the tree pos and size
     162          24 :             Point   aTreeViewPos( aPlaygroundPos );
     163          24 :             Size    aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y());
     164             : 
     165             :             // set the size of treelistbox
     166          24 :             m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
     167             : 
     168             :             //set the size of the splitter
     169          24 :             m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) );
     170          24 :             m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
     171             :         }
     172             :     }
     173             : 
     174          24 :     if ( m_pRight )
     175             :     {
     176          24 :         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          48 :             m_pRight->setPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(),
     181          72 :                                    aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y());
     182             :     }
     183             : 
     184          24 : }
     185             : 
     186           6 : void OSplitterView::set(Window* _pRight,Window* _pLeft)
     187             : {
     188           6 :     m_pLeft = _pLeft;
     189           6 :     m_pRight = _pRight;
     190           6 : }
     191             : 
     192           6 : void OSplitterView::setSplitter(Splitter* _pSplitter)
     193             : {
     194           6 :     m_pSplitter = _pSplitter;
     195           6 :     if ( m_pSplitter )
     196             :     {
     197           5 :         m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() );
     198           5 :         m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) );
     199           5 :         m_pSplitter->Show();
     200           5 :         LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter);
     201             :     }
     202           6 : }
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10