Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <vcl/lstbox.hxx>
21 : #include <vcl/button.hxx>
22 : #include <vcl/menu.hxx>
23 : #include <svl/lstner.hxx>
24 : #include <vector>
25 : #include "svx/galbrws.hxx"
26 :
27 : #include <boost/function.hpp>
28 :
29 : // - GalleryButton -
30 :
31 : class GalleryButton : public PushButton
32 : {
33 : private:
34 :
35 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
36 :
37 : public:
38 :
39 : GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
40 : virtual ~GalleryButton();
41 : };
42 :
43 : // - GalleryThemeListBox -
44 :
45 : class GalleryThemeListBox : public ListBox
46 : {
47 : protected:
48 :
49 : void InitSettings();
50 :
51 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
52 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
53 :
54 : public:
55 :
56 : GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
57 : virtual ~GalleryThemeListBox();
58 : };
59 :
60 : // - GalleryBrowser1 -
61 :
62 : class Gallery;
63 : class GalleryThemeEntry;
64 : class GalleryTheme;
65 : class VclAbstractDialog2;
66 : struct ExchangeData;
67 : class SfxItemSet;
68 :
69 : namespace svx { namespace sidebar { class GalleryControl; } }
70 :
71 : class GalleryBrowser1 : public Control, SfxListener
72 : {
73 : friend class GalleryBrowser;
74 : friend class svx::sidebar::GalleryControl;
75 : friend class GalleryThemeListBox;
76 : using Control::Notify;
77 : using Window::KeyInput;
78 :
79 : private:
80 :
81 : GalleryButton maNewTheme;
82 : GalleryThemeListBox* mpThemes;
83 : Gallery* mpGallery;
84 : ExchangeData* mpExchangeData;
85 : SfxItemSet* mpThemePropsDlgItemSet;
86 :
87 : Image aImgNormal;
88 : Image aImgDefault;
89 : Image aImgReadOnly;
90 : Image aImgImported;
91 :
92 : ::boost::function<sal_Bool(const KeyEvent&,Window*)> maKeyInputHandler;
93 : ::boost::function<void(void)> maThemeSlectionHandler;
94 :
95 : void ImplAdjustControls();
96 : sal_uIntPtr ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
97 : void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData );
98 : void ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec);
99 : void ImplExecute( sal_uInt16 nId );
100 : void ImplGalleryThemeProperties( const OUString & rThemeName, bool bCreateNew );
101 : void ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew );
102 :
103 : // Control
104 : virtual void Resize() SAL_OVERRIDE;
105 : virtual void GetFocus() SAL_OVERRIDE;
106 :
107 : // SfxListener
108 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
109 :
110 : DECL_LINK( ClickNewThemeHdl, void* );
111 : DECL_LINK( SelectThemeHdl, void* );
112 : DECL_LINK( ShowContextMenuHdl, void* );
113 : DECL_LINK( PopupMenuHdl, Menu* );
114 : DECL_LINK( EndNewThemePropertiesDlgHdl, VclAbstractDialog2* );
115 : DECL_LINK( EndThemePropertiesDlgHdl, VclAbstractDialog2* );
116 : DECL_LINK( DestroyThemePropertiesDlgHdl, VclAbstractDialog2* );
117 :
118 : public:
119 :
120 : GalleryBrowser1(
121 : Window* pParent,
122 : const ResId& rResId,
123 : Gallery* pGallery,
124 : const ::boost::function<sal_Bool(const KeyEvent&,Window*)>& rKeyInputHandler,
125 : const ::boost::function<void(void)>& rThemeSlectionHandler);
126 : virtual ~GalleryBrowser1();
127 :
128 : void SelectTheme( const OUString& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
129 0 : void SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); }
130 0 : OUString GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : OUString(); }
131 :
132 : void ShowContextMenu();
133 : sal_Bool KeyInput( const KeyEvent& rKEvt, Window* pWindow );
134 : };
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|