xref: /trunk/main/forms/source/solar/inc/navtoolbar.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
29 #define FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
30 
31 #include <vcl/toolbox.hxx>
32 #include <vcl/field.hxx>
33 
34 #include <boost/shared_ptr.hpp>
35 
36 //.........................................................................
37 namespace frm
38 {
39 //.........................................................................
40 
41     class IFeatureDispatcher;
42     class ICommandImageProvider;
43     class ICommandDescriptionProvider;
44 
45     class ImplNavToolBar;
46 
47     //=====================================================================
48     //= NavigationToolBar
49     //=====================================================================
50     class NavigationToolBar : public Window
51     {
52     public:
53         enum ImageSize
54         {
55             eSmall,
56             eLarge
57         };
58 
59         enum FunctionGroup
60         {
61             ePosition,
62             eNavigation,
63             eRecordActions,
64             eFilterSort
65         };
66 
67     private:
68         const IFeatureDispatcher*       m_pDispatcher;
69         const ::boost::shared_ptr< const ICommandImageProvider >
70                                         m_pImageProvider;
71         const ::boost::shared_ptr< const ICommandDescriptionProvider >
72                                         m_pDescriptionProvider;
73         ImageSize                       m_eImageSize;
74         ImplNavToolBar*                 m_pToolbar;
75         ::std::vector< Window* >        m_aChildWins;
76 
77     public:
78         NavigationToolBar(
79             Window* _pParent,
80             WinBits _nStyle,
81             const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider,
82             const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider
83         );
84         ~NavigationToolBar( );
85 
86         /** sets the dispatcher which is to be used for the features
87 
88             If the dispatcher is the same as the one which is currently set,
89             then the states of the features are updated
90 
91             @param _pDispatcher
92                 the new (or old) dispatcher. The caller is reponsible for
93                 ensuring the life time of the object does exceed the life time
94                 of the tool bar instance.
95         */
96         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
97 
98         /// enables or disables a given feature
99         void    enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );
100 
101         /// checks or unchecks a given feature
102         void    checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );
103 
104         /// sets the text of a given feature
105         void    setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText );
106 
107         /** retrieves the current image size
108         */
109         inline ImageSize    GetImageSize( ) const { return m_eImageSize; }
110 
111         /** sets the size of the images
112         */
113         void                SetImageSize( ImageSize _eSize );
114 
115         /** shows or hides a function group
116         */
117         void                ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow );
118 
119         /** determines whether or not a given function group is currently visible
120         */
121         bool                IsFunctionGroupVisible( FunctionGroup _eGroup );
122 
123         // Window "overridables" (hiding the respective Window methods)
124         void                SetControlBackground();
125         void                SetControlBackground( const Color& rColor );
126         void                SetTextLineColor( );
127         void                SetTextLineColor( const Color& rColor );
128 
129     protected:
130         // Window overridables
131         virtual void        Resize();
132         virtual void        StateChanged( StateChangedType nType );
133 
134         /// ctor implementation
135         void implInit( );
136 
137         /// impl version of SetImageSize
138         void    implSetImageSize( ImageSize _eSize );
139 
140         /// updates the images of our items
141         void    implUpdateImages();
142 
143         /// enables or disables an item, plus possible dependent items
144         void implEnableItem( sal_uInt16 _nItemId, bool _bEnabled );
145 
146         /** update the states of all features, using the callback
147         */
148         void updateFeatureStates( );
149 
150         // iterating through item windows
151 		typedef void (NavigationToolBar::*ItemWindowHandler) (sal_uInt16, Window*, const void*) const;
152         void    forEachItemWindow( ItemWindowHandler _handler, const void* _pParam );
153 
154         void setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
155         void setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
156 #if 0
157         void setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
158 #endif
159         void setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
160         void setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
161         void adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const;
162         void enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const;
163     };
164 
165     //=====================================================================
166     //= RecordPositionInput
167     //=====================================================================
168     class RecordPositionInput : public NumericField
169     {
170     private:
171         const IFeatureDispatcher*   m_pDispatcher;
172 
173     public:
174         RecordPositionInput( Window* _pParent );
175         ~RecordPositionInput();
176 
177         /** sets the dispatcher which is to be used for the features
178         */
179         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
180 
181     protected:
182         // Window overridables
183         virtual void LoseFocus();
184         virtual void KeyInput( const KeyEvent& rKeyEvent );
185 
186     private:
187         void FirePosition( sal_Bool _bForce );
188     };
189 
190 //.........................................................................
191 }   // namespace frm
192 //.........................................................................
193 
194 #endif // FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
195