102c50d82SAndre Fischer /************************************************************** 202c50d82SAndre Fischer * 302c50d82SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 402c50d82SAndre Fischer * or more contributor license agreements. See the NOTICE file 502c50d82SAndre Fischer * distributed with this work for additional information 602c50d82SAndre Fischer * regarding copyright ownership. The ASF licenses this file 702c50d82SAndre Fischer * to you under the Apache License, Version 2.0 (the 802c50d82SAndre Fischer * "License"); you may not use this file except in compliance 902c50d82SAndre Fischer * with the License. You may obtain a copy of the License at 1002c50d82SAndre Fischer * 1102c50d82SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1202c50d82SAndre Fischer * 1302c50d82SAndre Fischer * Unless required by applicable law or agreed to in writing, 1402c50d82SAndre Fischer * software distributed under the License is distributed on an 1502c50d82SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1602c50d82SAndre Fischer * KIND, either express or implied. See the License for the 1702c50d82SAndre Fischer * specific language governing permissions and limitations 1802c50d82SAndre Fischer * under the License. 1902c50d82SAndre Fischer * 2002c50d82SAndre Fischer *************************************************************/ 2102c50d82SAndre Fischer 2202c50d82SAndre Fischer #include "sidebar/PanelFactory.hxx" 2302c50d82SAndre Fischer 2402c50d82SAndre Fischer #include "GalleryControl.hxx" 2502c50d82SAndre Fischer 2602c50d82SAndre Fischer #include "gallery.hrc" 2702c50d82SAndre Fischer #include "svx/galmisc.hxx" 2802c50d82SAndre Fischer #include "svx/gallery1.hxx" 2902c50d82SAndre Fischer #include "galbrws1.hxx" 3002c50d82SAndre Fischer #include "galbrws2.hxx" 3102c50d82SAndre Fischer #include "GallerySplitter.hxx" 3202c50d82SAndre Fischer #include <vcl/svapp.hxx> 3302c50d82SAndre Fischer 3402c50d82SAndre Fischer #include <boost/bind.hpp> 3502c50d82SAndre Fischer 3602c50d82SAndre Fischer namespace svx { namespace sidebar { 3702c50d82SAndre Fischer 38*a8eaca58SAndre Fischer static const sal_Int32 gnInitialVerticalSplitPosition (150); 39*a8eaca58SAndre Fischer 40*a8eaca58SAndre Fischer 4102c50d82SAndre Fischer GalleryControl::GalleryControl ( 4202c50d82SAndre Fischer SfxBindings* pBindings, 4302c50d82SAndre Fischer Window* pParentWindow) 4402c50d82SAndre Fischer : Window(pParentWindow, GAL_RESID(RID_SVXDLG_GALLERYBROWSER)), 4502c50d82SAndre Fischer mpGallery (Gallery::GetGalleryInstance()), 4602c50d82SAndre Fischer mpBrowser1(new GalleryBrowser1( 4702c50d82SAndre Fischer this, 4802c50d82SAndre Fischer GAL_RESID(GALLERY_BROWSER1), 4902c50d82SAndre Fischer mpGallery, 5002c50d82SAndre Fischer ::boost::bind(&GalleryControl::KeyInput,this,_1,_2), 5102c50d82SAndre Fischer ::boost::bind(&GalleryControl::ThemeSelectionHasChanged, this))), 5202c50d82SAndre Fischer mpSplitter(new GallerySplitter( 5302c50d82SAndre Fischer this, 5402c50d82SAndre Fischer GAL_RESID(GALLERY_SPLITTER), 5502c50d82SAndre Fischer ::boost::bind(&GalleryControl::InitSettings, this))), 5602c50d82SAndre Fischer mpBrowser2(new GalleryBrowser2(this, GAL_RESID(GALLERY_BROWSER2), mpGallery)), 57*a8eaca58SAndre Fischer maLastSize(GetOutputSizePixel()), 58*a8eaca58SAndre Fischer mbIsInitialResize(true) 5902c50d82SAndre Fischer { 6002c50d82SAndre Fischer FreeResource(); 61*a8eaca58SAndre Fischer 62*a8eaca58SAndre Fischer // SetSizePixel(Size(300,600)); 6302c50d82SAndre Fischer 6402c50d82SAndre Fischer mpBrowser1->SelectTheme(0); 6502c50d82SAndre Fischer mpBrowser1->Show(sal_True); 66*a8eaca58SAndre Fischer 6702c50d82SAndre Fischer mpBrowser2->Show(sal_True); 6802c50d82SAndre Fischer 69*a8eaca58SAndre Fischer mpSplitter->SetHorizontal(false); 7002c50d82SAndre Fischer mpSplitter->SetSplitHdl( LINK( this, GalleryControl, SplitHdl ) ); 7102c50d82SAndre Fischer mpSplitter->Show( sal_True ); 7202c50d82SAndre Fischer 7302c50d82SAndre Fischer InitSettings(); 7402c50d82SAndre Fischer } 7502c50d82SAndre Fischer 7602c50d82SAndre Fischer 7702c50d82SAndre Fischer 7802c50d82SAndre Fischer 7902c50d82SAndre Fischer GalleryControl::~GalleryControl (void) 8002c50d82SAndre Fischer { 8102c50d82SAndre Fischer } 8202c50d82SAndre Fischer 8302c50d82SAndre Fischer 8402c50d82SAndre Fischer 8502c50d82SAndre Fischer 8602c50d82SAndre Fischer void GalleryControl::InitSettings (void) 8702c50d82SAndre Fischer { 8802c50d82SAndre Fischer SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 8902c50d82SAndre Fischer SetControlBackground( GALLERY_DLG_COLOR ); 9002c50d82SAndre Fischer SetControlForeground( GALLERY_DLG_COLOR ); 9102c50d82SAndre Fischer 9202c50d82SAndre Fischer mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 9302c50d82SAndre Fischer mpSplitter->SetControlBackground( GALLERY_DLG_COLOR ); 9402c50d82SAndre Fischer mpSplitter->SetControlForeground( GALLERY_DLG_COLOR ); 9502c50d82SAndre Fischer 9602c50d82SAndre Fischer mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 9702c50d82SAndre Fischer mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR ); 9802c50d82SAndre Fischer mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR ); 9902c50d82SAndre Fischer 10002c50d82SAndre Fischer mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 10102c50d82SAndre Fischer mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR ); 10202c50d82SAndre Fischer mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR ); 10302c50d82SAndre Fischer } 10402c50d82SAndre Fischer 10502c50d82SAndre Fischer 10602c50d82SAndre Fischer 10702c50d82SAndre Fischer 10802c50d82SAndre Fischer void GalleryControl::Resize (void) 10902c50d82SAndre Fischer { 11002c50d82SAndre Fischer // call parent 11102c50d82SAndre Fischer Window::Resize(); 11202c50d82SAndre Fischer 11302c50d82SAndre Fischer // update hor/ver 11402c50d82SAndre Fischer const Size aNewSize( GetOutputSizePixel() ); 115*a8eaca58SAndre Fischer if (aNewSize.Width()<=0 || aNewSize.Height()<=0) 116*a8eaca58SAndre Fischer return; 117*a8eaca58SAndre Fischer 11802c50d82SAndre Fischer const bool bNewLayoutHorizontal(aNewSize.Width() > aNewSize.Height()); 11902c50d82SAndre Fischer const bool bOldLayoutHorizontal(mpSplitter->IsHorizontal()); 120*a8eaca58SAndre Fischer long nSplitPos( bOldLayoutHorizontal ? mpSplitter->GetPosPixel().X() : mpSplitter->GetPosPixel().Y()); 12102c50d82SAndre Fischer const long nSplitSize( bOldLayoutHorizontal ? mpSplitter->GetOutputSizePixel().Width() : mpSplitter->GetOutputSizePixel().Height()); 12202c50d82SAndre Fischer 12302c50d82SAndre Fischer if(bNewLayoutHorizontal != bOldLayoutHorizontal) 12402c50d82SAndre Fischer { 12502c50d82SAndre Fischer mpSplitter->SetHorizontal(bNewLayoutHorizontal); 12602c50d82SAndre Fischer } 127*a8eaca58SAndre Fischer else 128*a8eaca58SAndre Fischer { 129*a8eaca58SAndre Fischer if (mbIsInitialResize) 130*a8eaca58SAndre Fischer { 131*a8eaca58SAndre Fischer nSplitPos = gnInitialVerticalSplitPosition; 132*a8eaca58SAndre Fischer if (nSplitPos > aNewSize.Height()/2) 133*a8eaca58SAndre Fischer nSplitPos = aNewSize.Height()/2; 134*a8eaca58SAndre Fischer } 135*a8eaca58SAndre Fischer } 136*a8eaca58SAndre Fischer mbIsInitialResize = false; 13702c50d82SAndre Fischer 13802c50d82SAndre Fischer const long nFrameLen = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); 13902c50d82SAndre Fischer const long nFrameLen2 = nFrameLen << 1; 14002c50d82SAndre Fischer 14102c50d82SAndre Fischer if(bNewLayoutHorizontal) 14202c50d82SAndre Fischer { 14302c50d82SAndre Fischer mpBrowser1->SetPosSizePixel( 14402c50d82SAndre Fischer Point( nFrameLen, nFrameLen ), 14502c50d82SAndre Fischer Size(nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2) ); 14602c50d82SAndre Fischer 14702c50d82SAndre Fischer mpSplitter->SetPosSizePixel( 14802c50d82SAndre Fischer Point( nSplitPos, 0), 14902c50d82SAndre Fischer Size( nSplitSize, aNewSize.Height() ) ); 15002c50d82SAndre Fischer 15102c50d82SAndre Fischer mpSplitter->SetDragRectPixel( 15202c50d82SAndre Fischer Rectangle( 15302c50d82SAndre Fischer Point( nFrameLen2, 0 ), 15402c50d82SAndre Fischer Size( aNewSize.Width() - ( nFrameLen2 << 1 ) - nSplitSize, aNewSize.Height() ) ) ); 15502c50d82SAndre Fischer 15602c50d82SAndre Fischer mpBrowser2->SetPosSizePixel( 15702c50d82SAndre Fischer Point( nSplitPos + nSplitSize, nFrameLen ), 15802c50d82SAndre Fischer Size( aNewSize.Width() - nSplitSize - nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2 ) ); 15902c50d82SAndre Fischer } 16002c50d82SAndre Fischer else 16102c50d82SAndre Fischer { 16202c50d82SAndre Fischer mpBrowser1->SetPosSizePixel( 16302c50d82SAndre Fischer Point( nFrameLen, nFrameLen ), 16402c50d82SAndre Fischer Size(aNewSize.Width() - nFrameLen2, nSplitPos - nFrameLen)); 16502c50d82SAndre Fischer 16602c50d82SAndre Fischer mpSplitter->SetPosSizePixel( 16702c50d82SAndre Fischer Point( 0, nSplitPos), 16802c50d82SAndre Fischer Size( aNewSize.Width(), nSplitSize ) ); 16902c50d82SAndre Fischer 17002c50d82SAndre Fischer mpSplitter->SetDragRectPixel( 17102c50d82SAndre Fischer Rectangle( 17202c50d82SAndre Fischer Point( 0, nFrameLen2 ), 17302c50d82SAndre Fischer Size( aNewSize.Width(), aNewSize.Height() - ( nFrameLen2 << 1 ) - nSplitSize ) )); 17402c50d82SAndre Fischer 17502c50d82SAndre Fischer mpBrowser2->SetPosSizePixel( 17602c50d82SAndre Fischer Point( nFrameLen, nSplitPos + nSplitSize ), 17702c50d82SAndre Fischer Size( aNewSize.Width() - nFrameLen2, aNewSize.Height() - nSplitSize - nSplitPos - nFrameLen )); 17802c50d82SAndre Fischer } 17902c50d82SAndre Fischer 18002c50d82SAndre Fischer maLastSize = aNewSize; 18102c50d82SAndre Fischer } 18202c50d82SAndre Fischer 18302c50d82SAndre Fischer 18402c50d82SAndre Fischer 18502c50d82SAndre Fischer 18602c50d82SAndre Fischer sal_Bool GalleryControl::KeyInput( const KeyEvent& rKEvt, Window* ) 18702c50d82SAndre Fischer { 18802c50d82SAndre Fischer const sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); 18902c50d82SAndre Fischer sal_Bool bRet = ( !rKEvt.GetKeyCode().IsMod1() && 19002c50d82SAndre Fischer ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) ); 19102c50d82SAndre Fischer 19202c50d82SAndre Fischer if( bRet ) 19302c50d82SAndre Fischer { 19402c50d82SAndre Fischer if( !rKEvt.GetKeyCode().IsShift() ) 19502c50d82SAndre Fischer { 19602c50d82SAndre Fischer if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) ) 19702c50d82SAndre Fischer mpBrowser2->GetViewWindow()->GrabFocus(); 19802c50d82SAndre Fischer else if( mpBrowser2->GetViewWindow()->HasFocus() ) 19902c50d82SAndre Fischer mpBrowser2->maViewBox.GrabFocus(); 20002c50d82SAndre Fischer else if( mpBrowser2->maViewBox.HasFocus() ) 20102c50d82SAndre Fischer mpBrowser1->maNewTheme.GrabFocus(); 20202c50d82SAndre Fischer else 20302c50d82SAndre Fischer mpBrowser1->mpThemes->GrabFocus(); 20402c50d82SAndre Fischer } 20502c50d82SAndre Fischer else 20602c50d82SAndre Fischer { 20702c50d82SAndre Fischer if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) ) 20802c50d82SAndre Fischer mpBrowser1->maNewTheme.GrabFocus(); 20902c50d82SAndre Fischer else if( mpBrowser1->maNewTheme.HasFocus() ) 21002c50d82SAndre Fischer mpBrowser2->maViewBox.GrabFocus(); 21102c50d82SAndre Fischer else if( mpBrowser2->maViewBox.HasFocus() ) 21202c50d82SAndre Fischer mpBrowser2->GetViewWindow()->GrabFocus(); 21302c50d82SAndre Fischer else 21402c50d82SAndre Fischer mpBrowser1->mpThemes->GrabFocus(); 21502c50d82SAndre Fischer } 21602c50d82SAndre Fischer } 21702c50d82SAndre Fischer 21802c50d82SAndre Fischer return bRet; 21902c50d82SAndre Fischer } 22002c50d82SAndre Fischer 22102c50d82SAndre Fischer 22202c50d82SAndre Fischer 22302c50d82SAndre Fischer 22402c50d82SAndre Fischer void GalleryControl::GetFocus (void) 22502c50d82SAndre Fischer { 22602c50d82SAndre Fischer Window::GetFocus(); 22702c50d82SAndre Fischer mpBrowser1->GrabFocus(); 22802c50d82SAndre Fischer } 22902c50d82SAndre Fischer 23002c50d82SAndre Fischer 23102c50d82SAndre Fischer 23202c50d82SAndre Fischer 23302c50d82SAndre Fischer void GalleryControl::ThemeSelectionHasChanged (void) 23402c50d82SAndre Fischer { 23502c50d82SAndre Fischer mpBrowser2->SelectTheme(mpBrowser1->GetSelectedTheme()); 23602c50d82SAndre Fischer } 23702c50d82SAndre Fischer 23802c50d82SAndre Fischer 23902c50d82SAndre Fischer 24002c50d82SAndre Fischer 24102c50d82SAndre Fischer INetURLObject GalleryControl::GetURL (void) const 24202c50d82SAndre Fischer { 24302c50d82SAndre Fischer return mpBrowser2->GetURL(); 24402c50d82SAndre Fischer } 24502c50d82SAndre Fischer 24602c50d82SAndre Fischer 24702c50d82SAndre Fischer 24802c50d82SAndre Fischer 24902c50d82SAndre Fischer String GalleryControl::GetFilterName (void) const 25002c50d82SAndre Fischer { 25102c50d82SAndre Fischer return mpBrowser2->GetFilterName(); 25202c50d82SAndre Fischer } 25302c50d82SAndre Fischer 25402c50d82SAndre Fischer 25502c50d82SAndre Fischer 25602c50d82SAndre Fischer 25702c50d82SAndre Fischer Graphic GalleryControl::GetGraphic(void) const 25802c50d82SAndre Fischer { 25902c50d82SAndre Fischer return mpBrowser2->GetGraphic(); 26002c50d82SAndre Fischer } 26102c50d82SAndre Fischer 26202c50d82SAndre Fischer 26302c50d82SAndre Fischer 26402c50d82SAndre Fischer 26502c50d82SAndre Fischer sal_Bool GalleryControl::GetVCDrawModel( FmFormModel& rModel ) const 26602c50d82SAndre Fischer { 26702c50d82SAndre Fischer return mpBrowser2->GetVCDrawModel( rModel ); 26802c50d82SAndre Fischer } 26902c50d82SAndre Fischer 27002c50d82SAndre Fischer 27102c50d82SAndre Fischer 27202c50d82SAndre Fischer 27302c50d82SAndre Fischer sal_Bool GalleryControl::IsLinkage (void) const 27402c50d82SAndre Fischer { 27502c50d82SAndre Fischer return mpBrowser2->IsLinkage(); 27602c50d82SAndre Fischer } 27702c50d82SAndre Fischer 27802c50d82SAndre Fischer 27902c50d82SAndre Fischer 28002c50d82SAndre Fischer 28102c50d82SAndre Fischer IMPL_LINK( GalleryControl, SplitHdl, void*, EMPTYARG ) 28202c50d82SAndre Fischer { 28302c50d82SAndre Fischer if(mpSplitter->IsHorizontal()) 28402c50d82SAndre Fischer { 28502c50d82SAndre Fischer mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) ); 28602c50d82SAndre Fischer } 28702c50d82SAndre Fischer else 28802c50d82SAndre Fischer { 28902c50d82SAndre Fischer mpSplitter->SetPosPixel( Point( mpSplitter->GetPosPixel().X(), mpSplitter->GetSplitPosPixel() ) ); 29002c50d82SAndre Fischer } 29102c50d82SAndre Fischer 29202c50d82SAndre Fischer Resize(); 29302c50d82SAndre Fischer 29402c50d82SAndre Fischer return 0L; 29502c50d82SAndre Fischer } 29602c50d82SAndre Fischer 29702c50d82SAndre Fischer 29802c50d82SAndre Fischer } } // end of namespace svx::sidebar 299