LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/gallery2 - GalleryControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 110 0.9 %
Date: 2013-07-09 Functions: 2 12 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "sidebar/PanelFactory.hxx"
      19             : 
      20             : #include "GalleryControl.hxx"
      21             : 
      22             : #include "gallery.hrc"
      23             : #include "svx/galmisc.hxx"
      24             : #include "svx/gallery1.hxx"
      25             : #include "galbrws1.hxx"
      26             : #include "galbrws2.hxx"
      27             : #include "GallerySplitter.hxx"
      28             : #include <vcl/svapp.hxx>
      29             : #include <sfx2/sidebar/Theme.hxx>
      30             : 
      31             : #include <boost/bind.hpp>
      32             : 
      33             : namespace svx { namespace sidebar {
      34             : 
      35             : static const sal_Int32 gnInitialVerticalSplitPosition (150);
      36             : 
      37             : 
      38           0 : GalleryControl::GalleryControl (
      39             :     SfxBindings* /*pBindings*/,
      40             :     Window* pParentWindow)
      41           0 :     : Window(pParentWindow, GAL_RES(RID_SVXDLG_GALLERYBROWSER)),
      42           0 :       mpGallery (Gallery::GetGalleryInstance()),
      43             :       mpSplitter(new GallerySplitter(
      44             :               this,
      45           0 :               GAL_RES(GALLERY_SPLITTER),
      46           0 :               ::boost::bind(&GalleryControl::InitSettings, this))),
      47             :       mpBrowser1(new GalleryBrowser1(
      48             :               this,
      49           0 :               GAL_RES(GALLERY_BROWSER1),
      50             :               mpGallery,
      51             :               ::boost::bind(&GalleryControl::GalleryKeyInput,this,_1,_2),
      52           0 :               ::boost::bind(&GalleryControl::ThemeSelectionHasChanged, this))),
      53           0 :       mpBrowser2(new GalleryBrowser2(this, GAL_RES(GALLERY_BROWSER2), mpGallery)),
      54           0 :       maLastSize(GetOutputSizePixel()),
      55           0 :       mbIsInitialResize(true)
      56             : {
      57           0 :     FreeResource();
      58             : 
      59           0 :     mpBrowser1->SelectTheme(0);
      60           0 :     mpBrowser1->Show(sal_True);
      61             : 
      62           0 :     mpBrowser2->Show(sal_True);
      63             : 
      64           0 :     mpSplitter->SetHorizontal(false);
      65           0 :     mpSplitter->SetSplitHdl( LINK( this, GalleryControl, SplitHdl ) );
      66           0 :     mpSplitter->Show( sal_True );
      67             : 
      68           0 :     InitSettings();
      69           0 : }
      70             : 
      71             : 
      72             : 
      73             : 
      74           0 : GalleryControl::~GalleryControl (void)
      75             : {
      76           0 : }
      77             : 
      78             : 
      79             : 
      80             : 
      81           0 : void GalleryControl::InitSettings (void)
      82             : {
      83           0 :     SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
      84           0 :     SetControlBackground( GALLERY_DLG_COLOR );
      85           0 :     SetControlForeground( GALLERY_DLG_COLOR );
      86             : 
      87           0 :     mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
      88           0 :     mpSplitter->SetControlBackground( GALLERY_DLG_COLOR );
      89           0 :     mpSplitter->SetControlForeground( GALLERY_DLG_COLOR );
      90             : 
      91           0 :     mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
      92           0 :     mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR );
      93           0 :     mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR );
      94             : 
      95           0 :     mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
      96           0 :     mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR );
      97           0 :     mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR );
      98             : 
      99           0 :     const Wallpaper aBackground (sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground));
     100           0 :     mpSplitter->SetBackground(aBackground);
     101           0 :     SetBackground(aBackground);
     102           0 :     mpBrowser2->SetBackground(aBackground);
     103           0 : }
     104             : 
     105             : 
     106             : 
     107             : 
     108           0 : void GalleryControl::Resize (void)
     109             : {
     110             :     // call parent
     111           0 :     Window::Resize();
     112             : 
     113             :     // update hor/ver
     114           0 :     const Size aNewSize( GetOutputSizePixel() );
     115           0 :     if (aNewSize.Width()<=0 || aNewSize.Height()<=0)
     116           0 :         return;
     117             : 
     118           0 :     const bool bNewLayoutHorizontal(aNewSize.Width() > aNewSize.Height());
     119           0 :     const bool bOldLayoutHorizontal(mpSplitter->IsHorizontal());
     120           0 :     long nSplitPos( bOldLayoutHorizontal ? mpSplitter->GetPosPixel().X() : mpSplitter->GetPosPixel().Y());
     121           0 :     const long nSplitSize( bOldLayoutHorizontal ? mpSplitter->GetOutputSizePixel().Width() : mpSplitter->GetOutputSizePixel().Height());
     122             : 
     123           0 :     if(bNewLayoutHorizontal != bOldLayoutHorizontal)
     124             :     {
     125           0 :         mpSplitter->SetHorizontal(bNewLayoutHorizontal);
     126             :     }
     127             :     else
     128             :     {
     129           0 :         if (mbIsInitialResize)
     130             :         {
     131           0 :             nSplitPos = gnInitialVerticalSplitPosition;
     132           0 :             if (nSplitPos > aNewSize.Height()/2)
     133           0 :                 nSplitPos = aNewSize.Height()/2;
     134             :         }
     135             :     }
     136           0 :     mbIsInitialResize = false;
     137             : 
     138           0 :     const long nFrameLen = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
     139           0 :     const long nFrameLen2 = nFrameLen << 1;
     140             : 
     141           0 :     if(bNewLayoutHorizontal)
     142             :     {
     143           0 :         mpBrowser1->SetPosSizePixel(
     144             :             Point( nFrameLen, nFrameLen ),
     145           0 :             Size(nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2) );
     146             : 
     147           0 :         mpSplitter->SetPosSizePixel(
     148             :             Point( nSplitPos, 0),
     149           0 :             Size( nSplitSize, aNewSize.Height() ) );
     150             : 
     151           0 :         mpSplitter->SetDragRectPixel(
     152             :             Rectangle(
     153             :                 Point( nFrameLen2, 0 ),
     154           0 :                 Size( aNewSize.Width() - ( nFrameLen2 << 1 ) - nSplitSize, aNewSize.Height() ) ) );
     155             : 
     156           0 :         mpBrowser2->SetPosSizePixel(
     157             :             Point( nSplitPos + nSplitSize, nFrameLen ),
     158           0 :             Size( aNewSize.Width() - nSplitSize - nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2 ) );
     159             :     }
     160             :     else
     161             :     {
     162           0 :         mpBrowser1->SetPosSizePixel(
     163             :             Point( nFrameLen, nFrameLen ),
     164           0 :             Size(aNewSize.Width() - nFrameLen2, nSplitPos - nFrameLen));
     165             : 
     166           0 :         mpSplitter->SetPosSizePixel(
     167             :             Point( 0, nSplitPos),
     168           0 :             Size( aNewSize.Width(), nSplitSize ) );
     169             : 
     170           0 :         mpSplitter->SetDragRectPixel(
     171             :             Rectangle(
     172             :                 Point( 0, nFrameLen2 ),
     173           0 :                 Size( aNewSize.Width(), aNewSize.Height() - ( nFrameLen2 << 1 ) - nSplitSize ) ));
     174             : 
     175           0 :         mpBrowser2->SetPosSizePixel(
     176             :             Point( nFrameLen, nSplitPos + nSplitSize ),
     177           0 :             Size( aNewSize.Width() - nFrameLen2, aNewSize.Height() - nSplitSize - nSplitPos - nFrameLen ));
     178             :     }
     179             : 
     180           0 :     maLastSize = aNewSize;
     181             : }
     182             : 
     183             : 
     184             : 
     185             : 
     186           0 : sal_Bool GalleryControl::GalleryKeyInput( const KeyEvent& rKEvt, Window* )
     187             : {
     188           0 :     const sal_uInt16    nCode = rKEvt.GetKeyCode().GetCode();
     189           0 :     sal_Bool            bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
     190           0 :                            ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
     191             : 
     192           0 :     if( bRet )
     193             :     {
     194           0 :         if( !rKEvt.GetKeyCode().IsShift() )
     195             :         {
     196           0 :             if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
     197           0 :                 mpBrowser2->GetViewWindow()->GrabFocus();
     198           0 :             else if( mpBrowser2->GetViewWindow()->HasFocus() )
     199           0 :                 mpBrowser2->maViewBox.GrabFocus();
     200           0 :             else if( mpBrowser2->maViewBox.HasFocus() )
     201           0 :                 mpBrowser1->maNewTheme.GrabFocus();
     202             :             else
     203           0 :                 mpBrowser1->mpThemes->GrabFocus();
     204             :         }
     205             :         else
     206             :         {
     207           0 :             if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) )
     208           0 :                 mpBrowser1->maNewTheme.GrabFocus();
     209           0 :             else if( mpBrowser1->maNewTheme.HasFocus() )
     210           0 :                 mpBrowser2->maViewBox.GrabFocus();
     211           0 :             else if( mpBrowser2->maViewBox.HasFocus() )
     212           0 :                 mpBrowser2->GetViewWindow()->GrabFocus();
     213             :             else
     214           0 :                 mpBrowser1->mpThemes->GrabFocus();
     215             :         }
     216             :     }
     217             : 
     218           0 :     return bRet;
     219             : }
     220             : 
     221             : 
     222             : 
     223             : 
     224           0 : void GalleryControl::GetFocus (void)
     225             : {
     226           0 :     Window::GetFocus();
     227           0 :     mpBrowser1->GrabFocus();
     228           0 : }
     229             : 
     230             : 
     231             : 
     232             : 
     233           0 : void GalleryControl::ThemeSelectionHasChanged (void)
     234             : {
     235           0 :     mpBrowser2->SelectTheme(mpBrowser1->GetSelectedTheme());
     236           0 : }
     237             : 
     238             : 
     239           0 : IMPL_LINK( GalleryControl, SplitHdl, void*, EMPTYARG )
     240             : {
     241           0 :     if(mpSplitter->IsHorizontal())
     242             :     {
     243           0 :         mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) );
     244             :     }
     245             :     else
     246             :     {
     247           0 :         mpSplitter->SetPosPixel( Point( mpSplitter->GetPosPixel().X(), mpSplitter->GetSplitPosPixel() ) );
     248             :     }
     249             : 
     250           0 :     Resize();
     251             : 
     252           0 :     return 0L;
     253             : }
     254             : 
     255             : 
     256         258 : } } // end of namespace svx::sidebar

Generated by: LCOV version 1.10