LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/formdlg - privsplt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 160 0.6 %
Date: 2013-07-09 Functions: 2 14 14.3 %
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 "privsplt.hxx"
      21             : 
      22             : /*************************************************************************
      23             : #*  Member:     ScPrivatSplit
      24             : #*------------------------------------------------------------------------
      25             : #*
      26             : #*  Klasse:     MD_Test
      27             : #*
      28             : #*  Funktion:   Konstruktor der Klasse ScPrivatSplit
      29             : #*
      30             : #*  Input:      ---
      31             : #*
      32             : #*  Output:     ---
      33             : #*
      34             : #************************************************************************/
      35             : 
      36           0 : ScPrivatSplit::ScPrivatSplit( Window* pParent, const ResId& rResId,
      37             :                              SC_SPLIT_DIRECTION eSplit):
      38           0 :                         Control( pParent, rResId )
      39             : {
      40           0 :     Point aPos=GetPosPixel();
      41           0 :     nOldX=(short)aPos.X();
      42           0 :     nOldY=(short)aPos.Y();
      43           0 :     nNewX=(short)aPos.X();
      44           0 :     nNewY=(short)aPos.Y();
      45           0 :     eScSplit=eSplit;
      46           0 :     aXMovingRange.Min()=nNewX;
      47           0 :     aXMovingRange.Max()=nNewX;
      48           0 :     aYMovingRange.Min()=nNewY;
      49           0 :     aYMovingRange.Max()=nNewY;
      50             : 
      51           0 :     aWinPointer=GetPointer();
      52             : 
      53           0 :     aMovingFlag=false;
      54           0 :     if(eScSplit==SC_SPLIT_HORZ)
      55             :     {
      56           0 :         aWinPointer=Pointer(POINTER_HSPLIT);
      57             :     }
      58             :     else
      59             :     {
      60           0 :         aWinPointer=Pointer(POINTER_VSPLIT);
      61             :     }
      62           0 :     SetPointer(aWinPointer);
      63           0 : }
      64             : 
      65             : 
      66             : /*************************************************************************
      67             : #*  Member:     MouseButtonDown
      68             : #*------------------------------------------------------------------------
      69             : #*
      70             : #*  Klasse:     ScPrivatSplit
      71             : #*
      72             : #*  Funktion:   Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
      73             : #*              werden alle Mauseingaben an dieses Control weitergeleitet.
      74             : #*
      75             : #*  Input:      ---
      76             : #*
      77             : #*  Output:     ---
      78             : #*
      79             : #************************************************************************/
      80             : 
      81           0 : void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
      82             : {
      83           0 :     Point aPos=LogicToPixel(rMEvt.GetPosPixel());
      84             : 
      85           0 :     nOldX=(short)aPos.X();
      86           0 :     nOldY=(short)aPos.Y();
      87             : 
      88           0 :     CaptureMouse();
      89           0 : }
      90             : 
      91             : /*************************************************************************
      92             : #*  Member:     MouseButtonUp
      93             : #*------------------------------------------------------------------------
      94             : #*
      95             : #*  Klasse:     ScPrivatSplit
      96             : #*
      97             : #*  Funktion:   Ende einer Benutzeraktion mit der Maus. Es werden
      98             : #*              die aktuelle Maus- Koordinaten ermittelt und fuer
      99             : #*              die Verschiebung des Fensters verwendet.
     100             : #*
     101             : #*  Input:      ---
     102             : #*
     103             : #*  Output:     ---
     104             : #*
     105             : #************************************************************************/
     106             : 
     107           0 : void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
     108             : {
     109           0 :     ReleaseMouse();
     110             : 
     111           0 :     Point aPos=LogicToPixel(rMEvt.GetPosPixel());
     112           0 :     Point a2Pos=GetPosPixel();
     113           0 :     Point a3Pos=a2Pos;
     114             : 
     115           0 :     if(eScSplit==SC_SPLIT_HORZ)
     116             :     {
     117           0 :         nNewX=(short)aPos.X();
     118           0 :         nDeltaX=nNewX-nOldX;
     119           0 :         a2Pos.X()+=nDeltaX;
     120           0 :         if(a2Pos.X()<aXMovingRange.Min())
     121             :         {
     122           0 :             nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
     123           0 :             a2Pos.X()=aXMovingRange.Min();
     124             :         }
     125           0 :         else if(a2Pos.X()>aXMovingRange.Max())
     126             :         {
     127           0 :             nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
     128           0 :             a2Pos.X()=aXMovingRange.Max();
     129             :         }
     130             :     }
     131             :     else
     132             :     {
     133           0 :         nNewY=(short)aPos.Y();
     134           0 :         nDeltaY=nNewY-nOldY;
     135           0 :         a2Pos.Y()+=nDeltaY;
     136           0 :         if(a2Pos.Y()<aYMovingRange.Min())
     137             :         {
     138           0 :             nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
     139           0 :             a2Pos.Y()=aYMovingRange.Min();
     140             :         }
     141           0 :         else if(a2Pos.Y()>aYMovingRange.Max())
     142             :         {
     143           0 :             nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
     144           0 :             a2Pos.Y()=aYMovingRange.Max();
     145             :         }
     146             :     }
     147           0 :     SetPosPixel(a2Pos);
     148           0 :     Invalidate();
     149           0 :     Update();
     150           0 :     CtrModified();
     151           0 : }
     152             : 
     153             : /*************************************************************************
     154             : #*  Member:     MouseMove
     155             : #*------------------------------------------------------------------------
     156             : #*
     157             : #*  Klasse:     ScPrivatSplit
     158             : #*
     159             : #*  Funktion:   Reagiert kontinuierlich auf Mausbewegungen. Es werden
     160             : #*              die aktuelle Maus- Koordinaten ermittelt und fuer
     161             : #*              die Verschiebung des Fensters verwendet.
     162             : #*
     163             : #*  Input:      ---
     164             : #*
     165             : #*  Output:     ---
     166             : #*
     167             : #************************************************************************/
     168             : 
     169           0 : void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
     170             : {
     171           0 :     Point aPos=LogicToPixel(rMEvt.GetPosPixel());
     172           0 :     Point a2Pos=GetPosPixel();
     173           0 :     Point a3Pos=a2Pos;
     174           0 :     if(rMEvt.IsLeft())
     175             :     {
     176           0 :         if(eScSplit==SC_SPLIT_HORZ)
     177             :         {
     178           0 :             nNewX=(short)aPos.X();
     179           0 :             nDeltaX=nNewX-nOldX;
     180           0 :             a2Pos.X()+=nDeltaX;
     181             : 
     182           0 :             if(a2Pos.X()<aXMovingRange.Min())
     183             :             {
     184           0 :                 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
     185           0 :                 a2Pos.X()=aXMovingRange.Min();
     186             :             }
     187           0 :             else if(a2Pos.X()>aXMovingRange.Max())
     188             :             {
     189           0 :                 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
     190           0 :                 a2Pos.X()=aXMovingRange.Max();
     191             :             }
     192             :         }
     193             :         else
     194             :         {
     195           0 :             nNewY=(short)aPos.Y();
     196           0 :             nDeltaY=nNewY-nOldY;
     197           0 :             a2Pos.Y()+=nDeltaY;
     198           0 :             if(a2Pos.Y()<aYMovingRange.Min())
     199             :             {
     200           0 :                 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
     201           0 :                 a2Pos.Y()=aYMovingRange.Min();
     202             :             }
     203           0 :             else if(a2Pos.Y()>aYMovingRange.Max())
     204             :             {
     205           0 :                 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
     206           0 :                 a2Pos.Y()=aYMovingRange.Max();
     207             :             }
     208             :         }
     209             : 
     210           0 :         SetPosPixel(a2Pos);
     211             : 
     212           0 :         CtrModified();
     213           0 :         Invalidate();
     214           0 :         Update();
     215             :     }
     216           0 : }
     217             : 
     218             : /*************************************************************************
     219             : #*  Member:     SetYRange
     220             : #*------------------------------------------------------------------------
     221             : #*
     222             : #*  Klasse:     ScPrivatSplit
     223             : #*
     224             : #*  Funktion:   Setzt den Range fuer die Y- Verschiebung
     225             : #*
     226             : #*  Input:      neuer Bereich
     227             : #*
     228             : #*  Output:     ---
     229             : #*
     230             : #************************************************************************/
     231           0 : void ScPrivatSplit::SetYRange(Range cRgeY)
     232             : {
     233           0 :     aYMovingRange=cRgeY;
     234           0 : }
     235             : 
     236             : 
     237             : 
     238             : /*************************************************************************
     239             : #*  Member:     GetDeltaY
     240             : #*------------------------------------------------------------------------
     241             : #*
     242             : #*  Klasse:     ScPrivatSplit
     243             : #*
     244             : #*  Funktion:   Liefert die relative x-Verschiebung zurueck
     245             : #*
     246             : #*  Input:      ---
     247             : #*
     248             : #*  Output:     ---
     249             : #*
     250             : #************************************************************************/
     251           0 : short ScPrivatSplit::GetDeltaX()
     252             : {
     253           0 :     return nDeltaX;
     254             : }
     255             : 
     256             : /*************************************************************************
     257             : #*  Member:     GetDeltaY
     258             : #*------------------------------------------------------------------------
     259             : #*
     260             : #*  Klasse:     ScPrivatSplit
     261             : #*
     262             : #*  Funktion:   Liefert die relative y-Verschiebung zurueck
     263             : #*
     264             : #*  Input:      ---
     265             : #*
     266             : #*  Output:     ---
     267             : #*
     268             : #************************************************************************/
     269           0 : short ScPrivatSplit::GetDeltaY()
     270             : {
     271           0 :     return nDeltaY;
     272             : }
     273             : 
     274             : /*************************************************************************
     275             : #*  Member:     CtrModified
     276             : #*------------------------------------------------------------------------
     277             : #*
     278             : #*  Klasse:     ScPrivatSplit
     279             : #*
     280             : #*  Funktion:   Teilt einem installierten Handler mit, dass
     281             : #*              eine Veraenderung eingetreten ist.
     282             : #*
     283             : #*  Input:      ---
     284             : #*
     285             : #*  Output:     ---
     286             : #*
     287             : #************************************************************************/
     288           0 : void ScPrivatSplit::CtrModified()
     289             : {
     290           0 :     aCtrModifiedLink.Call( this );
     291           0 : }
     292             : 
     293           0 : void ScPrivatSplit::MoveSplitTo(Point aPos)
     294             : {
     295           0 :     Point a2Pos=GetPosPixel();
     296           0 :     nOldX=(short)a2Pos.X();
     297           0 :     nOldY=(short)a2Pos.Y();
     298           0 :     Point a3Pos=a2Pos;
     299             : 
     300           0 :     if(eScSplit==SC_SPLIT_HORZ)
     301             :     {
     302           0 :         nNewX=(short)aPos.X();
     303           0 :         nDeltaX=nNewX-nOldX;
     304           0 :         a2Pos.X()+=nDeltaX;
     305           0 :         if(a2Pos.X()<aXMovingRange.Min())
     306             :         {
     307           0 :             nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
     308           0 :             a2Pos.X()=aXMovingRange.Min();
     309             :         }
     310           0 :         else if(a2Pos.X()>aXMovingRange.Max())
     311             :         {
     312           0 :             nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
     313           0 :             a2Pos.X()=aXMovingRange.Max();
     314             :         }
     315             :     }
     316             :     else
     317             :     {
     318           0 :         nNewY=(short)aPos.Y();
     319           0 :         nDeltaY=nNewY-nOldY;
     320           0 :         a2Pos.Y()+=nDeltaY;
     321           0 :         if(a2Pos.Y()<aYMovingRange.Min())
     322             :         {
     323           0 :             nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
     324           0 :             a2Pos.Y()=aYMovingRange.Min();
     325             :         }
     326           0 :         else if(a2Pos.Y()>aYMovingRange.Max())
     327             :         {
     328           0 :             nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
     329           0 :             a2Pos.Y()=aYMovingRange.Max();
     330             :         }
     331             :     }
     332           0 :     SetPosPixel(a2Pos);
     333           0 :     Invalidate();
     334           0 :     Update();
     335           0 :     CtrModified();
     336           0 : }
     337             : 
     338             : 
     339           0 : void ScPrivatSplit::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
     340             : {
     341           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     342             : 
     343           0 :     if ( bFont )
     344             :     {
     345           0 :         Font aFont = rStyleSettings.GetAppFont();
     346           0 :         if ( IsControlFont() )
     347           0 :             aFont.Merge( GetControlFont() );
     348           0 :         SetFont( aFont );
     349             :     }
     350             : 
     351           0 :     if ( bFont || bForeground )
     352             :     {
     353           0 :         Color aTextColor = rStyleSettings.GetButtonTextColor();
     354           0 :         if ( IsControlForeground() )
     355           0 :             aTextColor = GetControlForeground();
     356           0 :         SetTextColor( aTextColor );
     357             :     }
     358             : 
     359           0 :     if ( bBackground )
     360             :     {
     361           0 :         SetBackground( rStyleSettings.GetFaceColor());
     362             :     }
     363           0 :     if ( IsBackground() )
     364             :     {
     365           0 :         SetFillColor( GetBackground().GetColor() );
     366           0 :         SetBackground();
     367             :     }
     368           0 :     Invalidate();
     369           0 : }
     370             : 
     371             : // -----------------------------------------------------------------------
     372             : 
     373           0 : void ScPrivatSplit::StateChanged( StateChangedType nType )
     374             : {
     375           0 :     if ( (nType == STATE_CHANGE_ZOOM) ||
     376             :          (nType == STATE_CHANGE_CONTROLFONT) )
     377             :     {
     378           0 :         ImplInitSettings( sal_True, false, false );
     379           0 :         Invalidate();
     380             :     }
     381           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     382             :     {
     383           0 :         ImplInitSettings( false, sal_True, false );
     384           0 :         Invalidate();
     385             :     }
     386           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     387             :     {
     388           0 :         ImplInitSettings( false, false, sal_True );
     389           0 :         Invalidate();
     390             :     }
     391             : 
     392           0 :     Control::StateChanged( nType );
     393           0 : }
     394             : 
     395             : // -----------------------------------------------------------------------
     396             : 
     397           0 : void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
     398             : {
     399           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     400           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     401             :     {
     402           0 :         ImplInitSettings( sal_True, sal_True, sal_True );
     403           0 :         Invalidate();
     404             :     }
     405             :     else
     406           0 :         Window::DataChanged( rDCEvt );
     407          93 : }
     408             : 
     409             : 
     410             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10