1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_svx.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <vcl/split.hxx> 26cdf0e10cSrcweir #include <vcl/ctrl.hxx> 27cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 28cdf0e10cSrcweir #include <sfx2/app.hxx> 29cdf0e10cSrcweir #include <sfx2/sfxsids.hrc> 30cdf0e10cSrcweir #include "gallery.hrc" 31cdf0e10cSrcweir #include "svx/galmisc.hxx" 32cdf0e10cSrcweir #include "svx/gallery1.hxx" 33cdf0e10cSrcweir #include "galbrws1.hxx" 34cdf0e10cSrcweir #include "galbrws2.hxx" 35cdf0e10cSrcweir #include "svx/galbrws.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ------------------- 38cdf0e10cSrcweir // - GallerySplitter - 39cdf0e10cSrcweir // ------------------- 40cdf0e10cSrcweir 41cdf0e10cSrcweir class GallerySplitter : public Splitter 42cdf0e10cSrcweir { 43cdf0e10cSrcweir protected: 44cdf0e10cSrcweir 45cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 46cdf0e10cSrcweir 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir 49cdf0e10cSrcweir GallerySplitter( Window* pParent, const ResId& rResId ); 50cdf0e10cSrcweir virtual ~GallerySplitter(); 51cdf0e10cSrcweir }; 52cdf0e10cSrcweir 53cdf0e10cSrcweir // ----------------------------------------------------------------------------- 54cdf0e10cSrcweir DBG_NAME(GallerySplitter) 55cdf0e10cSrcweir 56*45fc0049SArmin Le Grand GallerySplitter::GallerySplitter( Window* pParent, const ResId& rResId ) 57*45fc0049SArmin Le Grand : Splitter( pParent, rResId ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir DBG_CTOR(GallerySplitter,NULL); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir // ----------------------------------------------------------------------------- 63cdf0e10cSrcweir 64cdf0e10cSrcweir GallerySplitter::~GallerySplitter() 65cdf0e10cSrcweir { 66cdf0e10cSrcweir DBG_DTOR(GallerySplitter,NULL); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70cdf0e10cSrcweir 71cdf0e10cSrcweir void GallerySplitter::DataChanged( const DataChangedEvent& rDCEvt ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir Splitter::DataChanged( rDCEvt ); 74cdf0e10cSrcweir static_cast< GalleryBrowser* >( GetParent() )->InitSettings(); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir // ------------------------- 78cdf0e10cSrcweir // - SvxGalleryChildWindow - 79cdf0e10cSrcweir // ------------------------- 80cdf0e10cSrcweir DBG_NAME(GalleryChildWindow) 81cdf0e10cSrcweir 82cdf0e10cSrcweir GalleryChildWindow::GalleryChildWindow( Window* _pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) : 83cdf0e10cSrcweir SfxChildWindow( _pParent, nId ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir DBG_CTOR(GalleryChildWindow,NULL); 86cdf0e10cSrcweir 87cdf0e10cSrcweir pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RESID( RID_SVXDLG_GALLERYBROWSER ) ); 88cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_TOP; 89cdf0e10cSrcweir ( (GalleryBrowser*) pWindow )->Initialize( pInfo ); 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ----------------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir GalleryChildWindow::~GalleryChildWindow() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir 97cdf0e10cSrcweir DBG_DTOR(GalleryChildWindow,NULL); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir // ----------------------------------------------------------------------------- 101cdf0e10cSrcweir 102cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW( GalleryChildWindow, SID_GALLERY ) 103cdf0e10cSrcweir 104cdf0e10cSrcweir // ------------------ 105cdf0e10cSrcweir // - GalleryBrowser - 106cdf0e10cSrcweir // ------------------ 107cdf0e10cSrcweir DBG_NAME(GalleryBrowser) 108cdf0e10cSrcweir 109*45fc0049SArmin Le Grand GalleryBrowser::GalleryBrowser( 110*45fc0049SArmin Le Grand SfxBindings* _pBindings, 111*45fc0049SArmin Le Grand SfxChildWindow* pCW, 112*45fc0049SArmin Le Grand Window* pParent, 113*45fc0049SArmin Le Grand const ResId& rResId) 114*45fc0049SArmin Le Grand : SfxDockingWindow(_pBindings, pCW, pParent, rResId), 115*45fc0049SArmin Le Grand maLastSize(GetOutputSizePixel()), 116*45fc0049SArmin Le Grand mpSplitter(0), 117*45fc0049SArmin Le Grand mpBrowser1(0), 118*45fc0049SArmin Le Grand mpBrowser2(0), 119*45fc0049SArmin Le Grand mpGallery(0) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir DBG_CTOR(GalleryBrowser,NULL); 122cdf0e10cSrcweir 123cdf0e10cSrcweir mpGallery = Gallery::GetGalleryInstance(); 124cdf0e10cSrcweir mpBrowser1 = new GalleryBrowser1( this, GAL_RESID( GALLERY_BROWSER1 ), mpGallery ); 125cdf0e10cSrcweir mpSplitter = new GallerySplitter( this, GAL_RESID( GALLERY_SPLITTER ) ); 126cdf0e10cSrcweir mpBrowser2 = new GalleryBrowser2( this, GAL_RESID( GALLERY_BROWSER2 ), mpGallery ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir FreeResource(); 129*45fc0049SArmin Le Grand SetMinOutputSizePixel(maLastSize); 130cdf0e10cSrcweir 131cdf0e10cSrcweir mpBrowser1->SelectTheme( 0 ); 132cdf0e10cSrcweir mpBrowser1->Show( sal_True ); 133cdf0e10cSrcweir mpBrowser2->Show( sal_True ); 134cdf0e10cSrcweir 135*45fc0049SArmin Le Grand const bool bLayoutHorizontal(maLastSize.Width() > maLastSize.Height()); 136*45fc0049SArmin Le Grand mpSplitter->SetHorizontal(bLayoutHorizontal); 137cdf0e10cSrcweir mpSplitter->SetSplitHdl( LINK( this, GalleryBrowser, SplitHdl ) ); 138cdf0e10cSrcweir mpSplitter->Show( sal_True ); 139cdf0e10cSrcweir 140cdf0e10cSrcweir InitSettings(); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir // ----------------------------------------------------------------------------- 144cdf0e10cSrcweir 145cdf0e10cSrcweir GalleryBrowser::~GalleryBrowser() 146cdf0e10cSrcweir { 147cdf0e10cSrcweir delete mpBrowser2; 148cdf0e10cSrcweir delete mpSplitter; 149cdf0e10cSrcweir delete mpBrowser1; 150cdf0e10cSrcweir 151cdf0e10cSrcweir DBG_DTOR(GalleryBrowser,NULL); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir // ----------------------------------------------------------------------------- 155cdf0e10cSrcweir 156cdf0e10cSrcweir void GalleryBrowser::InitSettings() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 159cdf0e10cSrcweir SetControlBackground( GALLERY_DLG_COLOR ); 160cdf0e10cSrcweir SetControlForeground( GALLERY_DLG_COLOR ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 163cdf0e10cSrcweir mpSplitter->SetControlBackground( GALLERY_DLG_COLOR ); 164cdf0e10cSrcweir mpSplitter->SetControlForeground( GALLERY_DLG_COLOR ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 167cdf0e10cSrcweir mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR ); 168cdf0e10cSrcweir mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) ); 171cdf0e10cSrcweir mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR ); 172cdf0e10cSrcweir mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir // ----------------------------------------------------------------------------- 176cdf0e10cSrcweir 177cdf0e10cSrcweir void GalleryBrowser::Resize() 178cdf0e10cSrcweir { 179*45fc0049SArmin Le Grand // call parent 180*45fc0049SArmin Le Grand SfxDockingWindow::Resize(); 181cdf0e10cSrcweir 182*45fc0049SArmin Le Grand // update hor/ver 183*45fc0049SArmin Le Grand const Size aNewSize( GetOutputSizePixel() ); 184*45fc0049SArmin Le Grand const bool bNewLayoutHorizontal(aNewSize.Width() > aNewSize.Height()); 185*45fc0049SArmin Le Grand const bool bOldLayoutHorizontal(mpSplitter->IsHorizontal()); 186*45fc0049SArmin Le Grand const long nSplitPos( bOldLayoutHorizontal ? mpSplitter->GetPosPixel().X() : mpSplitter->GetPosPixel().Y()); 187*45fc0049SArmin Le Grand const long nSplitSize( bOldLayoutHorizontal ? mpSplitter->GetOutputSizePixel().Width() : mpSplitter->GetOutputSizePixel().Height()); 188cdf0e10cSrcweir 189*45fc0049SArmin Le Grand if(bNewLayoutHorizontal != bOldLayoutHorizontal) 190*45fc0049SArmin Le Grand { 191*45fc0049SArmin Le Grand mpSplitter->SetHorizontal(bNewLayoutHorizontal); 192*45fc0049SArmin Le Grand } 193cdf0e10cSrcweir 194*45fc0049SArmin Le Grand const long nFrameLen = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width(); 195*45fc0049SArmin Le Grand const long nFrameLen2 = nFrameLen << 1; 196cdf0e10cSrcweir 197*45fc0049SArmin Le Grand if(bNewLayoutHorizontal) 198*45fc0049SArmin Le Grand { 199*45fc0049SArmin Le Grand mpBrowser1->SetPosSizePixel( 200*45fc0049SArmin Le Grand Point( nFrameLen, nFrameLen ), 201*45fc0049SArmin Le Grand Size(nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2) ); 202*45fc0049SArmin Le Grand 203*45fc0049SArmin Le Grand mpSplitter->SetPosSizePixel( 204*45fc0049SArmin Le Grand Point( nSplitPos, 0), 205*45fc0049SArmin Le Grand Size( nSplitSize, aNewSize.Height() ) ); 206*45fc0049SArmin Le Grand 207*45fc0049SArmin Le Grand mpSplitter->SetDragRectPixel( 208*45fc0049SArmin Le Grand Rectangle( 209*45fc0049SArmin Le Grand Point( nFrameLen2, 0 ), 210*45fc0049SArmin Le Grand Size( aNewSize.Width() - ( nFrameLen2 << 1 ) - nSplitSize, aNewSize.Height() ) ) ); 211*45fc0049SArmin Le Grand 212*45fc0049SArmin Le Grand mpBrowser2->SetPosSizePixel( 213*45fc0049SArmin Le Grand Point( nSplitPos + nSplitSize, nFrameLen ), 214*45fc0049SArmin Le Grand Size( aNewSize.Width() - nSplitSize - nSplitPos - nFrameLen, aNewSize.Height() - nFrameLen2 ) ); 215*45fc0049SArmin Le Grand } 216*45fc0049SArmin Le Grand else 217*45fc0049SArmin Le Grand { 218*45fc0049SArmin Le Grand mpBrowser1->SetPosSizePixel( 219*45fc0049SArmin Le Grand Point( nFrameLen, nFrameLen ), 220*45fc0049SArmin Le Grand Size(aNewSize.Width() - nFrameLen2, nSplitPos - nFrameLen)); 221*45fc0049SArmin Le Grand 222*45fc0049SArmin Le Grand mpSplitter->SetPosSizePixel( 223*45fc0049SArmin Le Grand Point( 0, nSplitPos), 224*45fc0049SArmin Le Grand Size( aNewSize.Width(), nSplitSize ) ); 225*45fc0049SArmin Le Grand 226*45fc0049SArmin Le Grand mpSplitter->SetDragRectPixel( 227*45fc0049SArmin Le Grand Rectangle( 228*45fc0049SArmin Le Grand Point( 0, nFrameLen2 ), 229*45fc0049SArmin Le Grand Size( aNewSize.Width(), aNewSize.Height() - ( nFrameLen2 << 1 ) - nSplitSize ) )); 230*45fc0049SArmin Le Grand 231*45fc0049SArmin Le Grand mpBrowser2->SetPosSizePixel( 232*45fc0049SArmin Le Grand Point( nFrameLen, nSplitPos + nSplitSize ), 233*45fc0049SArmin Le Grand Size( aNewSize.Width() - nFrameLen2, aNewSize.Height() - nSplitSize - nSplitPos - nFrameLen )); 234*45fc0049SArmin Le Grand } 235cdf0e10cSrcweir 236*45fc0049SArmin Le Grand maLastSize = aNewSize; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir // ----------------------------------------------------------------------------- 240cdf0e10cSrcweir 241cdf0e10cSrcweir sal_Bool GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir const sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); 244cdf0e10cSrcweir sal_Bool bRet = ( !rKEvt.GetKeyCode().IsMod1() && 245cdf0e10cSrcweir ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir if( bRet ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir if( !rKEvt.GetKeyCode().IsShift() ) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) ) 252cdf0e10cSrcweir mpBrowser2->GetViewWindow()->GrabFocus(); 253cdf0e10cSrcweir else if( mpBrowser2->GetViewWindow()->HasFocus() ) 254cdf0e10cSrcweir mpBrowser2->maViewBox.GrabFocus(); 255cdf0e10cSrcweir else if( mpBrowser2->maViewBox.HasFocus() ) 256cdf0e10cSrcweir mpBrowser1->maNewTheme.GrabFocus(); 257cdf0e10cSrcweir else 258cdf0e10cSrcweir mpBrowser1->mpThemes->GrabFocus(); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir else 261cdf0e10cSrcweir { 262cdf0e10cSrcweir if( mpBrowser1->mpThemes->HasChildPathFocus( sal_True ) ) 263cdf0e10cSrcweir mpBrowser1->maNewTheme.GrabFocus(); 264cdf0e10cSrcweir else if( mpBrowser1->maNewTheme.HasFocus() ) 265cdf0e10cSrcweir mpBrowser2->maViewBox.GrabFocus(); 266cdf0e10cSrcweir else if( mpBrowser2->maViewBox.HasFocus() ) 267cdf0e10cSrcweir mpBrowser2->GetViewWindow()->GrabFocus(); 268cdf0e10cSrcweir else 269cdf0e10cSrcweir mpBrowser1->mpThemes->GrabFocus(); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir return bRet; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir // ----------------------------------------------------------------------------- 277cdf0e10cSrcweir 278cdf0e10cSrcweir sal_Bool GalleryBrowser::Close() 279cdf0e10cSrcweir { 280cdf0e10cSrcweir return SfxDockingWindow::Close(); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir // ----------------------------------------------------------------------------- 284cdf0e10cSrcweir 285cdf0e10cSrcweir void GalleryBrowser::GetFocus() 286cdf0e10cSrcweir { 287cdf0e10cSrcweir SfxDockingWindow::GetFocus(); 288cdf0e10cSrcweir mpBrowser1->GrabFocus(); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir // ----------------------------------------------------------------------------- 292cdf0e10cSrcweir 293cdf0e10cSrcweir void GalleryBrowser::ThemeSelectionHasChanged() 294cdf0e10cSrcweir { 295cdf0e10cSrcweir mpBrowser2->SelectTheme( mpBrowser1->GetSelectedTheme() ); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir // ----------------------------------------------------------------------------- 299cdf0e10cSrcweir 300cdf0e10cSrcweir INetURLObject GalleryBrowser::GetURL() const 301cdf0e10cSrcweir { 302cdf0e10cSrcweir return mpBrowser2->GetURL(); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir // ----------------------------------------------------------------------------- 306cdf0e10cSrcweir 307cdf0e10cSrcweir String GalleryBrowser::GetFilterName() const 308cdf0e10cSrcweir { 309cdf0e10cSrcweir return mpBrowser2->GetFilterName(); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir // ----------------------------------------------------------------------------- 313cdf0e10cSrcweir 314cdf0e10cSrcweir Graphic GalleryBrowser::GetGraphic() const 315cdf0e10cSrcweir { 316cdf0e10cSrcweir return mpBrowser2->GetGraphic(); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir // ----------------------------------------------------------------------------- 320cdf0e10cSrcweir 321cdf0e10cSrcweir sal_Bool GalleryBrowser::GetVCDrawModel( FmFormModel& rModel ) const 322cdf0e10cSrcweir { 323cdf0e10cSrcweir return mpBrowser2->GetVCDrawModel( rModel ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir // ----------------------------------------------------------------------------- 327cdf0e10cSrcweir 328cdf0e10cSrcweir sal_Bool GalleryBrowser::IsLinkage() const 329cdf0e10cSrcweir { 330cdf0e10cSrcweir return mpBrowser2->IsLinkage(); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir // ----------------------------------------------------------------------------- 334cdf0e10cSrcweir 335cdf0e10cSrcweir IMPL_LINK( GalleryBrowser, SplitHdl, void*, EMPTYARG ) 336cdf0e10cSrcweir { 337*45fc0049SArmin Le Grand if(mpSplitter->IsHorizontal()) 338*45fc0049SArmin Le Grand { 339*45fc0049SArmin Le Grand mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) ); 340*45fc0049SArmin Le Grand } 341*45fc0049SArmin Le Grand else 342*45fc0049SArmin Le Grand { 343*45fc0049SArmin Le Grand mpSplitter->SetPosPixel( Point( mpSplitter->GetPosPixel().X(), mpSplitter->GetSplitPosPixel() ) ); 344*45fc0049SArmin Le Grand } 345*45fc0049SArmin Le Grand 346*45fc0049SArmin Le Grand Resize(); 347cdf0e10cSrcweir 348cdf0e10cSrcweir return 0L; 349cdf0e10cSrcweir } 350*45fc0049SArmin Le Grand 351*45fc0049SArmin Le Grand // ----------------------------------------------------------------------------- 352*45fc0049SArmin Le Grand // eof 353