xref: /AOO41X/main/svx/source/gallery2/galbrws1.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <vcl/lstbox.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/menu.hxx>
27 #include <svl/lstner.hxx>
28 #include <vector>
29 #include "svx/galbrws.hxx"
30 
31 #include <boost/function.hpp>
32 
33 // -----------------
34 // - GalleryButton -
35 // -----------------
36 
37 class GalleryButton : public PushButton
38 {
39 private:
40 
41     virtual void    KeyInput( const KeyEvent& rKEvt );
42 
43 public:
44 
45                     GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
46                     ~GalleryButton();
47 };
48 
49 // -----------------------
50 // - GalleryThemeListBox -
51 // -----------------------
52 
53 class GalleryThemeListBox : public ListBox
54 {
55 protected:
56 
57     void            InitSettings();
58 
59     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
60     virtual long    PreNotify( NotifyEvent& rNEvt );
61 
62 public:
63 
64                     GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
65                     ~GalleryThemeListBox();
66 };
67 
68 // -------------------
69 // - GalleryBrowser1 -
70 // -------------------
71 
72 class Gallery;
73 class GalleryThemeEntry;
74 class GalleryTheme;
75 class VclAbstractDialog2;
76 struct ExchangeData;
77 class SfxItemSet;
78 
79 namespace svx { namespace sidebar { class GalleryControl; } }
80 
81 class GalleryBrowser1 : public Control, SfxListener
82 {
83     friend class GalleryBrowser;
84     friend class svx::sidebar::GalleryControl;
85     friend class GalleryThemeListBox;
86     using Control::Notify;
87     using Window::KeyInput;
88 
89 private:
90 
91     GalleryButton           maNewTheme;
92     GalleryThemeListBox*    mpThemes;
93     Gallery*                mpGallery;
94     ExchangeData*           mpExchangeData;
95     SfxItemSet*             mpThemePropsDlgItemSet;
96 
97     Image                   aImgNormal;
98     Image                   aImgDefault;
99     Image                   aImgReadOnly;
100     Image                   aImgImported;
101 
102     ::boost::function<sal_Bool(const KeyEvent&,Window*)> maKeyInputHandler;
103     ::boost::function<void(void)> maThemeSlectionHandler;
104 
105     void                    ImplAdjustControls();
106     sal_uIntPtr                 ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
107     void                    ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData );
108     void                    ImplGetExecuteVector(::std::vector< sal_uInt16 >& o_aExec);
109     void                    ImplExecute( sal_uInt16 nId );
110     void                    ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew );
111     void                    ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew );
112 
113     // Control
114     virtual void            Resize();
115     virtual void            GetFocus();
116 
117     // SfxListener
118     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
119 
120                             DECL_LINK( ClickNewThemeHdl, void* );
121                             DECL_LINK( SelectThemeHdl, void* );
122                             DECL_LINK( ShowContextMenuHdl, void* );
123                             DECL_LINK( PopupMenuHdl, Menu* );
124                             DECL_LINK( EndNewThemePropertiesDlgHdl, VclAbstractDialog2* );
125                             DECL_LINK( EndThemePropertiesDlgHdl, VclAbstractDialog2* );
126                             DECL_LINK( DestroyThemePropertiesDlgHdl, VclAbstractDialog2* );
127 
128 public:
129 
130                             GalleryBrowser1(
131                                 Window* pParent,
132                                 const ResId& rResId,
133                                 Gallery* pGallery,
134                                 const ::boost::function<sal_Bool(const KeyEvent&,Window*)>& rKeyInputHandler,
135                                 const ::boost::function<void(void)>& rThemeSlectionHandler);
136                             ~GalleryBrowser1();
137 
SelectTheme(const String & rThemeName)138     void                    SelectTheme( const String& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
SelectTheme(sal_uIntPtr nThemePos)139     void                    SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); }
GetSelectedTheme()140     String                  GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); }
141 
142     void                    ShowContextMenu();
143     sal_Bool                    KeyInput( const KeyEvent& rKEvt, Window* pWindow );
144 };
145