LCOV - code coverage report
Current view: top level - svx/source/gallery2 - galbrws.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 107 1.9 %
Date: 2014-04-11 Functions: 4 20 20.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 <vcl/split.hxx>
      21             : #include <vcl/ctrl.hxx>
      22             : #include <vcl/settings.hxx>
      23             : #include <unotools/pathoptions.hxx>
      24             : #include <sfx2/app.hxx>
      25             : #include <sfx2/sfxsids.hrc>
      26             : #include "gallery.hrc"
      27             : #include "svx/galmisc.hxx"
      28             : #include "svx/gallery1.hxx"
      29             : #include "galbrws1.hxx"
      30             : #include "galbrws2.hxx"
      31             : #include "svx/galbrws.hxx"
      32             : #include "GallerySplitter.hxx"
      33             : 
      34             : #include <boost/bind.hpp>
      35             : 
      36             : 
      37           0 : GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
      38           0 :     SfxChildWindow( _pParent, nId )
      39             : {
      40             : 
      41           0 :     pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RES( RID_SVXDLG_GALLERYBROWSER ) );
      42           0 :     eChildAlignment = SFX_ALIGN_TOP;
      43           0 :     ( (GalleryBrowser*) pWindow )->Initialize( pInfo );
      44           0 : };
      45             : 
      46           0 : GalleryChildWindow::~GalleryChildWindow()
      47             : {
      48           0 : }
      49             : 
      50         464 : SFX_IMPL_DOCKINGWINDOW_WITHID( GalleryChildWindow, SID_GALLERY )
      51             : 
      52             : // - GalleryBrowser -
      53             : 
      54             : 
      55           0 : GalleryBrowser::GalleryBrowser(
      56             :     SfxBindings* _pBindings,
      57             :     SfxChildWindow* pCW,
      58             :     Window* pParent,
      59             :     const ResId& rResId)
      60             : :   SfxDockingWindow(_pBindings, pCW, pParent, rResId),
      61           0 :     maLastSize(GetOutputSizePixel()),
      62             :     mpSplitter(0),
      63             :     mpBrowser1(0),
      64             :     mpBrowser2(0),
      65           0 :     mpGallery(0)
      66             : {
      67             : 
      68           0 :     mpGallery = Gallery::GetGalleryInstance();
      69             :     mpBrowser1 = new GalleryBrowser1(
      70             :         this,
      71           0 :         GAL_RES( GALLERY_BROWSER1 ),
      72             :         mpGallery,
      73             :         ::boost::bind(&GalleryBrowser::KeyInput,this,_1,_2),
      74           0 :         ::boost::bind(&GalleryBrowser::ThemeSelectionHasChanged, this));
      75           0 :     mpSplitter = new GallerySplitter( this, GAL_RES( GALLERY_SPLITTER ),
      76           0 :         ::boost::bind(&GalleryBrowser::InitSettings, this));
      77           0 :     mpBrowser2 = new GalleryBrowser2( this, GAL_RES( GALLERY_BROWSER2 ), mpGallery );
      78             : 
      79           0 :     FreeResource();
      80           0 :     SetMinOutputSizePixel(maLastSize);
      81             : 
      82           0 :     mpBrowser1->SelectTheme( 0 );
      83           0 :     mpBrowser1->Show( true );
      84           0 :     mpBrowser2->Show( true );
      85             : 
      86           0 :     const bool bLayoutHorizontal(maLastSize.Width() > maLastSize.Height());
      87           0 :     mpSplitter->SetHorizontal(bLayoutHorizontal);
      88           0 :     mpSplitter->SetSplitHdl( LINK( this, GalleryBrowser, SplitHdl ) );
      89           0 :     mpSplitter->Show( true );
      90             : 
      91           0 :     InitSettings();
      92           0 : }
      93             : 
      94           0 : GalleryBrowser::~GalleryBrowser()
      95             : {
      96           0 :     delete mpBrowser2;
      97           0 :     delete mpSplitter;
      98           0 :     delete mpBrowser1;
      99             : 
     100           0 : }
     101             : 
     102           0 : void GalleryBrowser::InitSettings()
     103             : {
     104           0 :     SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
     105           0 :     SetControlBackground( GALLERY_DLG_COLOR );
     106           0 :     SetControlForeground( GALLERY_DLG_COLOR );
     107             : 
     108           0 :     mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
     109           0 :     mpSplitter->SetControlBackground( GALLERY_DLG_COLOR );
     110           0 :     mpSplitter->SetControlForeground( GALLERY_DLG_COLOR );
     111             : 
     112           0 :     mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
     113           0 :     mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR );
     114           0 :     mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR );
     115             : 
     116           0 :     mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
     117           0 :     mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR );
     118           0 :     mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR );
     119           0 : }
     120             : 
     121           0 : void GalleryBrowser::Resize()
     122             : {
     123             :     // call parent
     124           0 :     SfxDockingWindow::Resize();
     125             : 
     126             :     // update hor/ver
     127           0 :     const Size aNewSize( GetOutputSizePixel() );
     128           0 :     const bool bNewLayoutHorizontal(aNewSize.Width() > aNewSize.Height());
     129           0 :     const bool bOldLayoutHorizontal(mpSplitter->IsHorizontal());
     130           0 :     const long nSplitPos( bOldLayoutHorizontal ? mpSplitter->GetPosPixel().X() : mpSplitter->GetPosPixel().Y());
     131           0 :     const long nSplitSize( bOldLayoutHorizontal ? mpSplitter->GetOutputSizePixel().Width() : mpSplitter->GetOutputSizePixel().Height());
     132             : 
     133           0 :     if(bNewLayoutHorizontal != bOldLayoutHorizontal)
     134             :     {
     135           0 :         mpSplitter->SetHorizontal(bNewLayoutHorizontal);
     136             :     }
     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             :         mpBrowser1->SetPosSizePixel(
     144             :             Point( nFrameLen, nFrameLen ),
     145           0 :             Size(nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2) );
     146             : 
     147             :         mpSplitter->SetPosSizePixel(
     148             :             Point( nSplitPos, 0),
     149           0 :             Size( nSplitSize, aNewSize.Height() ) );
     150             : 
     151             :         mpSplitter->SetDragRectPixel(
     152             :             Rectangle(
     153             :                 Point( nFrameLen2, 0 ),
     154           0 :                 Size( aNewSize.Width() - ( nFrameLen2 << 1 ) - nSplitSize, aNewSize.Height() ) ) );
     155             : 
     156             :         mpBrowser2->SetPosSizePixel(
     157             :             Point( nSplitPos + nSplitSize, nFrameLen ),
     158           0 :             Size( aNewSize.Width() - nSplitSize - nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2 ) );
     159             :     }
     160             :     else
     161             :     {
     162             :         mpBrowser1->SetPosSizePixel(
     163             :             Point( nFrameLen, nFrameLen ),
     164           0 :             Size(aNewSize.Width() - nFrameLen2, nSplitPos - nFrameLen));
     165             : 
     166             :         mpSplitter->SetPosSizePixel(
     167             :             Point( 0, nSplitPos),
     168           0 :             Size( aNewSize.Width(), nSplitSize ) );
     169             : 
     170             :         mpSplitter->SetDragRectPixel(
     171             :             Rectangle(
     172             :                 Point( 0, nFrameLen2 ),
     173           0 :                 Size( aNewSize.Width(), aNewSize.Height() - ( nFrameLen2 << 1 ) - nSplitSize ) ));
     174             : 
     175             :         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           0 : }
     182             : 
     183           0 : bool GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* )
     184             : {
     185           0 :     const sal_uInt16    nCode = rKEvt.GetKeyCode().GetCode();
     186           0 :     bool                bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
     187           0 :                            ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
     188             : 
     189           0 :     if( bRet )
     190             :     {
     191           0 :         if( !rKEvt.GetKeyCode().IsShift() )
     192             :         {
     193           0 :             if( mpBrowser1->mpThemes->HasChildPathFocus( true ) )
     194           0 :                 mpBrowser2->GetViewWindow()->GrabFocus();
     195           0 :             else if( mpBrowser2->GetViewWindow()->HasFocus() )
     196           0 :                 mpBrowser2->maViewBox.GrabFocus();
     197           0 :             else if( mpBrowser2->maViewBox.HasFocus() )
     198           0 :                 mpBrowser1->maNewTheme.GrabFocus();
     199             :             else
     200           0 :                 mpBrowser1->mpThemes->GrabFocus();
     201             :         }
     202             :         else
     203             :         {
     204           0 :             if( mpBrowser1->mpThemes->HasChildPathFocus( true ) )
     205           0 :                 mpBrowser1->maNewTheme.GrabFocus();
     206           0 :             else if( mpBrowser1->maNewTheme.HasFocus() )
     207           0 :                 mpBrowser2->maViewBox.GrabFocus();
     208           0 :             else if( mpBrowser2->maViewBox.HasFocus() )
     209           0 :                 mpBrowser2->GetViewWindow()->GrabFocus();
     210             :             else
     211           0 :                 mpBrowser1->mpThemes->GrabFocus();
     212             :         }
     213             :     }
     214             : 
     215           0 :     return bRet;
     216             : }
     217             : 
     218           0 : bool GalleryBrowser::Close()
     219             : {
     220           0 :     return SfxDockingWindow::Close();
     221             : }
     222             : 
     223           0 : void GalleryBrowser::GetFocus()
     224             : {
     225           0 :     SfxDockingWindow::GetFocus();
     226           0 :     mpBrowser1->GrabFocus();
     227           0 : }
     228             : 
     229           0 : void GalleryBrowser::ThemeSelectionHasChanged()
     230             : {
     231           0 :     mpBrowser2->SelectTheme( mpBrowser1->GetSelectedTheme() );
     232           0 : }
     233             : 
     234           0 : IMPL_LINK_NOARG(GalleryBrowser, SplitHdl)
     235             : {
     236           0 :     if(mpSplitter->IsHorizontal())
     237             :     {
     238           0 :         mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) );
     239             :     }
     240             :     else
     241             :     {
     242           0 :         mpSplitter->SetPosPixel( Point( mpSplitter->GetPosPixel().X(), mpSplitter->GetSplitPosPixel() ) );
     243             :     }
     244             : 
     245           0 :     Resize();
     246             : 
     247           0 :     return 0L;
     248         297 : }
     249             : 
     250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10