xref: /trunk/main/extensions/source/bibliography/toolbar.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 #ifndef _BIB_TOOLBAR_HXX
25 #define _BIB_TOOLBAR_HXX
26 
27 #include <com/sun/star/frame/XController.hpp>
28 #include <com/sun/star/frame/XStatusListener.hpp>
29 
30 
31 #include <vcl/toolbox.hxx>
32 #include <vcl/lstbox.hxx>
33 #include <vcl/edit.hxx>
34 #include <vcl/fixed.hxx>
35 #include <svl/svarray.hxx>
36 #include <vcl/timer.hxx>
37 #include <cppuhelper/implbase1.hxx> // helper for implementations
38 
39 class BibDataManager;
40 class BibToolBar;
41 
42 class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener>
43 {
44 private:
45 
46     sal_uInt16      nIndex;
47     rtl::OUString           aCommand;
48 
49 protected:
50 
51     BibToolBar      *pToolBar;
52 
53 public:
54 
55     BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
56     ~BibToolBarListener();
57 
58     rtl::OUString           GetCommand();
59 
60     // ::com::sun::star::lang::XEventListener
61     // we do not hold References to dispatches, so there is nothing to do on disposal
disposing(const::com::sun::star::lang::EventObject &)62     virtual void    SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*Source*/){};
63 
64     // ::com::sun::star::frame::XStatusListener
65     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event);
66 
67 };
68 
69 class BibTBListBoxListener: public BibToolBarListener
70 {
71 public:
72 
73     BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
74     ~BibTBListBoxListener();
75 
76     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event);
77 
78 };
79 
80 class BibTBEditListener: public BibToolBarListener
81 {
82 public:
83 
84     BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
85     ~BibTBEditListener();
86 
87     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event);
88 
89 };
90 
91 class BibTBQueryMenuListener:   public BibToolBarListener
92 {
93 public:
94 
95     BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
96     ~BibTBQueryMenuListener();
97 
98     virtual void    SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event);
99 
100 };
101 
102 
103 typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener>* BibToolBarListenerPtr;
104 SV_DECL_PTRARR_DEL( BibToolBarListenerArr, BibToolBarListenerPtr, 4, 4 )
105 
106 class BibToolBar:   public ToolBox
107 {
108     private:
109 
110         BibToolBarListenerArr   aListenerArr;
111         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >            xController;
112         Timer                   aTimer;
113 //      Timer                   aMenuTimer;
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         rtl::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 );
143         void                    InitListener();
144         virtual void            Select();
145         virtual void            Click();
146         long                    PreNotify( NotifyEvent& rNEvt );
147 
148 
149     public:
150 
151         BibToolBar(Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK );
152         ~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 XubString&,sal_uInt16 nPos=LISTBOX_APPEND );
160         void    SelectSourceEntry(const XubString& );
161 
162         void    EnableQuery(sal_Bool bFlag=sal_True);
163         void    SetQueryString(const XubString& );
164         void    AdjustToolBox();
165 
166         void    ClearFilterMenu();
167         sal_uInt16  InsertFilterItem(const XubString& );
168         void    SelectFilterItem(sal_uInt16 nId);
169 
170         void    statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event);
171 
SetDatMan(BibDataManager & rDatMan)172         void    SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;}
173         void    SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs);
174 };
175 
176 
177 
178 
179 #endif
180