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 _BIB_TOOLBAR_HXX
21 : #define _BIB_TOOLBAR_HXX
22 :
23 : #include <com/sun/star/frame/XController.hpp>
24 : #include <com/sun/star/frame/XStatusListener.hpp>
25 :
26 :
27 : #include <vcl/toolbox.hxx>
28 : #include <vcl/lstbox.hxx>
29 : #include <vcl/edit.hxx>
30 : #include <vcl/fixed.hxx>
31 : #include <vcl/timer.hxx>
32 : #include <cppuhelper/implbase1.hxx>
33 : #include <boost/ptr_container/ptr_vector.hpp>
34 :
35 : class BibDataManager;
36 : class BibToolBar;
37 :
38 : class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener>
39 : {
40 : private:
41 :
42 : sal_uInt16 nIndex;
43 : OUString aCommand;
44 :
45 : protected:
46 :
47 : BibToolBar *pToolBar;
48 :
49 : public:
50 :
51 : BibToolBarListener(BibToolBar *pTB, const OUString& aStr, sal_uInt16 nId);
52 : virtual ~BibToolBarListener();
53 :
54 : OUString GetCommand() const;
55 :
56 : // ::com::sun::star::lang::XEventListener
57 : // we do not hold References to dispatches, so there is nothing to do on disposal
58 0 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*Source*/)
59 0 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE {};
60 :
61 : // ::com::sun::star::frame::XStatusListener
62 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
63 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
64 :
65 : };
66 :
67 : class BibTBListBoxListener: public BibToolBarListener
68 : {
69 : public:
70 :
71 : BibTBListBoxListener(BibToolBar *pTB, const OUString& aStr, sal_uInt16 nId);
72 : virtual ~BibTBListBoxListener();
73 :
74 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
75 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
76 :
77 : };
78 :
79 : class BibTBEditListener: public BibToolBarListener
80 : {
81 : public:
82 :
83 : BibTBEditListener(BibToolBar *pTB, const OUString& aStr, sal_uInt16 nId);
84 : virtual ~BibTBEditListener();
85 :
86 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
87 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
88 :
89 : };
90 :
91 : class BibTBQueryMenuListener: public BibToolBarListener
92 : {
93 : public:
94 :
95 : BibTBQueryMenuListener(BibToolBar *pTB, const OUString& aStr, sal_uInt16 nId);
96 : virtual ~BibTBQueryMenuListener();
97 :
98 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
99 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
100 :
101 : };
102 :
103 :
104 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener> BibToolBarListenerRef;
105 : typedef boost::ptr_vector<BibToolBarListenerRef> BibToolBarListenerArr;
106 :
107 : class BibToolBar: public ToolBox
108 : {
109 : private:
110 :
111 : BibToolBarListenerArr aListenerArr;
112 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController;
113 : Timer aTimer;
114 : ImageList aImgLst;
115 : ImageList aImgLstHC;
116 : ImageList aBigImgLst;
117 : ImageList aBigImgLstHC;
118 : FixedText aFtSource;
119 : ListBox aLBSource;
120 : FixedText aFtQuery;
121 : Edit aEdQuery;
122 : PopupMenu aPopupMenu;
123 : sal_uInt16 nMenuId;
124 : sal_uInt16 nSelMenuItem;
125 : OUString aQueryField;
126 : Link aLayoutManager;
127 : sal_Int16 nSymbolsSize;
128 : sal_Int16 nOutStyle;
129 :
130 : BibDataManager* pDatMan;
131 : DECL_LINK( SelHdl, ListBox* );
132 : DECL_LINK( SendSelHdl, Timer* );
133 : DECL_LINK( MenuHdl, ToolBox* );
134 : DECL_LINK( OptionsChanged_Impl, void* );
135 : DECL_LINK( SettingsChanged_Impl, void* );
136 :
137 : void ApplyImageList();
138 : void RebuildToolbar();
139 :
140 : protected:
141 :
142 : void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
143 : void InitListener();
144 : virtual void Select() SAL_OVERRIDE;
145 : virtual void Click() SAL_OVERRIDE;
146 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
147 :
148 :
149 : public:
150 :
151 : BibToolBar(Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK );
152 : virtual ~BibToolBar();
153 :
154 : void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &);
155 :
156 : void ClearSourceList();
157 : void UpdateSourceList(sal_Bool bFlag=sal_True);
158 : void EnableSourceList(sal_Bool bFlag=sal_True);
159 : void InsertSourceEntry(const OUString&,sal_Int32 nPos=LISTBOX_APPEND );
160 : void SelectSourceEntry(const OUString& );
161 :
162 : void EnableQuery(sal_Bool bFlag=sal_True);
163 : void SetQueryString(const OUString& );
164 : void AdjustToolBox();
165 :
166 : void ClearFilterMenu();
167 : sal_uInt16 InsertFilterItem(const OUString& );
168 : void SelectFilterItem(sal_uInt16 nId);
169 :
170 : void statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
171 : throw( ::com::sun::star::uno::RuntimeException );
172 :
173 0 : void SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;}
174 : void SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs);
175 : };
176 :
177 :
178 :
179 :
180 : #endif
181 :
182 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|