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