1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <vcl/lstbox.hxx> 29 #include <vcl/button.hxx> 30 #include <vcl/menu.hxx> 31 #include <svl/lstner.hxx> 32 #include <vector> 33 #include "svx/galbrws.hxx" 34 35 // ----------------- 36 // - GalleryButton - 37 // ----------------- 38 39 class GalleryButton : public PushButton 40 { 41 private: 42 43 virtual void KeyInput( const KeyEvent& rKEvt ); 44 45 public: 46 47 GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ); 48 ~GalleryButton(); 49 }; 50 51 // ----------------------- 52 // - GalleryThemeListBox - 53 // ----------------------- 54 55 class GalleryThemeListBox : public ListBox 56 { 57 protected: 58 59 void InitSettings(); 60 61 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 62 virtual long PreNotify( NotifyEvent& rNEvt ); 63 64 public: 65 66 GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits ); 67 ~GalleryThemeListBox(); 68 }; 69 70 // ------------------- 71 // - GalleryBrowser1 - 72 // ------------------- 73 74 class Gallery; 75 class GalleryThemeEntry; 76 class GalleryTheme; 77 class VclAbstractDialog2; 78 struct ExchangeData; 79 class SfxItemSet; 80 81 class GalleryBrowser1 : public Control, SfxListener 82 { 83 friend class GalleryBrowser; 84 friend class GalleryThemeListBox; 85 using Control::Notify; 86 using Window::KeyInput; 87 88 private: 89 90 GalleryButton maNewTheme; 91 GalleryThemeListBox* mpThemes; 92 Gallery* mpGallery; 93 ExchangeData* mpExchangeData; 94 SfxItemSet* mpThemePropsDlgItemSet; 95 96 Image aImgNormal; 97 Image aImgDefault; 98 Image aImgReadOnly; 99 Image aImgImported; 100 101 void ImplAdjustControls(); 102 sal_uIntPtr ImplInsertThemeEntry( const GalleryThemeEntry* pEntry ); 103 void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData ); 104 void ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec); 105 void ImplExecute( sal_uInt16 nId ); 106 void ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew ); 107 void ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew ); 108 109 // Control 110 virtual void Resize(); 111 virtual void GetFocus(); 112 113 // SfxListener 114 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 115 116 DECL_LINK( ClickNewThemeHdl, void* ); 117 DECL_LINK( SelectThemeHdl, void* ); 118 DECL_LINK( ShowContextMenuHdl, void* ); 119 DECL_LINK( PopupMenuHdl, Menu* ); 120 DECL_LINK( EndNewThemePropertiesDlgHdl, VclAbstractDialog2* ); 121 DECL_LINK( EndThemePropertiesDlgHdl, VclAbstractDialog2* ); 122 DECL_LINK( DestroyThemePropertiesDlgHdl, VclAbstractDialog2* ); 123 124 public: 125 126 GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ); 127 ~GalleryBrowser1(); 128 129 void SelectTheme( const String& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); } 130 void SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); } 131 String GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); } 132 133 void ShowContextMenu(); 134 sal_Bool KeyInput( const KeyEvent& rKEvt, Window* pWindow ); 135 }; 136