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