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 : // -----------------
30 : // - GalleryButton -
31 : // -----------------
32 :
33 : class GalleryButton : public PushButton
34 : {
35 : private:
36 :
37 : virtual void KeyInput( const KeyEvent& rKEvt );
38 :
39 : public:
40 :
41 : GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
42 : ~GalleryButton();
43 : };
44 :
45 : // -----------------------
46 : // - GalleryThemeListBox -
47 : // -----------------------
48 :
49 : class GalleryThemeListBox : public ListBox
50 : {
51 : protected:
52 :
53 : void InitSettings();
54 :
55 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
56 : virtual long PreNotify( NotifyEvent& rNEvt );
57 :
58 : public:
59 :
60 : GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
61 : ~GalleryThemeListBox();
62 : };
63 :
64 : // -------------------
65 : // - GalleryBrowser1 -
66 : // -------------------
67 :
68 : class Gallery;
69 : class GalleryThemeEntry;
70 : class GalleryTheme;
71 : class VclAbstractDialog2;
72 : struct ExchangeData;
73 : class SfxItemSet;
74 :
75 : namespace svx { namespace sidebar { class GalleryControl; } }
76 :
77 : class GalleryBrowser1 : public Control, SfxListener
78 : {
79 : friend class GalleryBrowser;
80 : friend class svx::sidebar::GalleryControl;
81 : friend class GalleryThemeListBox;
82 : using Control::Notify;
83 : using Window::KeyInput;
84 :
85 : private:
86 :
87 : GalleryButton maNewTheme;
88 : GalleryThemeListBox* mpThemes;
89 : Gallery* mpGallery;
90 : ExchangeData* mpExchangeData;
91 : SfxItemSet* mpThemePropsDlgItemSet;
92 :
93 : Image aImgNormal;
94 : Image aImgDefault;
95 : Image aImgReadOnly;
96 : Image aImgImported;
97 :
98 : ::boost::function<sal_Bool(const KeyEvent&,Window*)> maKeyInputHandler;
99 : ::boost::function<void(void)> maThemeSlectionHandler;
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(
127 : Window* pParent,
128 : const ResId& rResId,
129 : Gallery* pGallery,
130 : const ::boost::function<sal_Bool(const KeyEvent&,Window*)>& rKeyInputHandler,
131 : const ::boost::function<void(void)>& rThemeSlectionHandler);
132 : ~GalleryBrowser1();
133 :
134 : void SelectTheme( const String& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
135 0 : void SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); }
136 0 : String GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); }
137 :
138 : void ShowContextMenu();
139 : sal_Bool KeyInput( const KeyEvent& rKEvt, Window* pWindow );
140 : };
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|