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 : #ifndef INCLUDED_SVX_SOURCE_GALLERY2_GALBRWS1_HXX
21 : #define INCLUDED_SVX_SOURCE_GALLERY2_GALBRWS1_HXX
22 :
23 : #include <vcl/lstbox.hxx>
24 : #include <vcl/button.hxx>
25 : #include <vcl/menu.hxx>
26 : #include <svl/lstner.hxx>
27 : #include <vector>
28 :
29 : #include <boost/function.hpp>
30 :
31 : class GalleryBrowser1;
32 :
33 : // - GalleryButton -
34 :
35 : class GalleryButton : public PushButton
36 : {
37 : private:
38 :
39 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
40 :
41 : public:
42 :
43 : GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
44 : virtual ~GalleryButton();
45 : };
46 :
47 : // - GalleryThemeListBox -
48 :
49 : class GalleryThemeListBox : public ListBox
50 : {
51 : protected:
52 :
53 : void InitSettings();
54 :
55 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
56 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
57 :
58 : public:
59 :
60 : GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
61 : virtual ~GalleryThemeListBox();
62 : };
63 :
64 : // - GalleryBrowser1 -
65 :
66 : class Gallery;
67 : class GalleryThemeEntry;
68 : class GalleryTheme;
69 : class VclAbstractDialog2;
70 : struct ExchangeData;
71 : class SfxItemSet;
72 :
73 : namespace svx { namespace sidebar { class GalleryControl; } }
74 :
75 : class GalleryBrowser1 : public Control, SfxListener
76 : {
77 : friend class GalleryBrowser;
78 : friend class svx::sidebar::GalleryControl;
79 : friend class GalleryThemeListBox;
80 : using Control::Notify;
81 : using Window::KeyInput;
82 :
83 : private:
84 :
85 : GalleryButton maNewTheme;
86 : GalleryThemeListBox* mpThemes;
87 : Gallery* mpGallery;
88 : ExchangeData* mpExchangeData;
89 : SfxItemSet* mpThemePropsDlgItemSet;
90 :
91 : Image aImgNormal;
92 : Image aImgDefault;
93 : Image aImgReadOnly;
94 : Image aImgImported;
95 :
96 : ::boost::function<sal_Bool(const KeyEvent&,Window*)> maKeyInputHandler;
97 : ::boost::function<void(void)> maThemeSlectionHandler;
98 :
99 : void ImplAdjustControls();
100 : sal_uIntPtr ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
101 : void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData );
102 : void ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec);
103 : void ImplExecute( sal_uInt16 nId );
104 : void ImplGalleryThemeProperties( const OUString & rThemeName, bool bCreateNew );
105 : void ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew );
106 :
107 : // Control
108 : virtual void Resize() SAL_OVERRIDE;
109 : virtual void GetFocus() SAL_OVERRIDE;
110 :
111 : // SfxListener
112 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
113 :
114 : DECL_LINK( ClickNewThemeHdl, void* );
115 : DECL_LINK( SelectThemeHdl, void* );
116 : DECL_LINK( ShowContextMenuHdl, void* );
117 : DECL_LINK( PopupMenuHdl, Menu* );
118 : DECL_LINK( EndNewThemePropertiesDlgHdl, VclAbstractDialog2* );
119 : DECL_LINK( EndThemePropertiesDlgHdl, VclAbstractDialog2* );
120 : DECL_LINK( DestroyThemePropertiesDlgHdl, VclAbstractDialog2* );
121 :
122 : public:
123 :
124 : GalleryBrowser1(
125 : vcl::Window* pParent,
126 : const ResId& rResId,
127 : Gallery* pGallery,
128 : const ::boost::function<sal_Bool(const KeyEvent&,Window*)>& rKeyInputHandler,
129 : const ::boost::function<void(void)>& rThemeSlectionHandler);
130 : virtual ~GalleryBrowser1();
131 :
132 : void SelectTheme( const OUString& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
133 0 : void SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); }
134 0 : OUString GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : OUString(); }
135 :
136 : void ShowContextMenu();
137 : bool KeyInput( const KeyEvent& rKEvt, vcl::Window* pWindow );
138 : };
139 :
140 : #endif // INCLUDED_SVX_SOURCE_GALLERY2_GALBRWS1_HXX
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|