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