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