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

Generated by: LCOV version 1.10