xref: /aoo41x/main/svx/source/gallery2/galbrws1.hxx (revision 3334a7e6)
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 // -----------------
32 // - GalleryButton -
33 // -----------------
34 
35 class GalleryButton : public PushButton
36 {
37 private:
38 
39 	virtual void	KeyInput( const KeyEvent& rKEvt );
40 
41 public:
42 
43                     GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
44                     ~GalleryButton();
45 };
46 
47 // -----------------------
48 // - GalleryThemeListBox -
49 // -----------------------
50 
51 class GalleryThemeListBox : public ListBox
52 {
53 protected:
54 
55     void            InitSettings();
56 
57     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
58 	virtual long	PreNotify( NotifyEvent& rNEvt );
59 
60 public:
61 
62 					GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
63 					~GalleryThemeListBox();
64 };
65 
66 // -------------------
67 // - GalleryBrowser1 -
68 // -------------------
69 
70 class Gallery;
71 class GalleryThemeEntry;
72 class GalleryTheme;
73 class VclAbstractDialog2;
74 struct ExchangeData;
75 class SfxItemSet;
76 
77 class GalleryBrowser1 : public Control, SfxListener
78 {
79 	friend class GalleryBrowser;
80 	friend class GalleryThemeListBox;
81 	using Control::Notify;
82 	using Window::KeyInput;
83 
84 private:
85 
86 	GalleryButton           maNewTheme;
87 	GalleryThemeListBox*	mpThemes;
88 	Gallery*				mpGallery;
89     ExchangeData*           mpExchangeData;
90     SfxItemSet*             mpThemePropsDlgItemSet;
91 
92 	Image					aImgNormal;
93 	Image					aImgDefault;
94 	Image					aImgReadOnly;
95 	Image					aImgImported;
96 
97 	void					ImplAdjustControls();
98 	sal_uIntPtr					ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
99 	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 String & rThemeName, bool bCreateNew );
103     void                    ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew );
104 
105 	// Control
106 	virtual void			Resize();
107 	virtual void			GetFocus();
108 
109 	// SfxListener
110 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
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( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery );
123 							~GalleryBrowser1();
124 
125 	void					SelectTheme( const String& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
126 	void					SelectTheme( sal_uIntPtr nThemePos ) { mpThemes->SelectEntryPos( (sal_uInt16) nThemePos ); SelectThemeHdl( NULL ); }
127 	String					GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); }
128 
129 	void					ShowContextMenu();
130     sal_Bool                    KeyInput( const KeyEvent& rKEvt, Window* pWindow );
131 };
132