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