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 FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
25 #define FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
26 
27 #include <vcl/toolbox.hxx>
28 #include <vcl/field.hxx>
29 
30 #include <boost/shared_ptr.hpp>
31 
32 //.........................................................................
33 namespace frm
34 {
35 //.........................................................................
36 
37     class IFeatureDispatcher;
38     class ICommandImageProvider;
39     class ICommandDescriptionProvider;
40 
41     class ImplNavToolBar;
42 
43     //=====================================================================
44     //= NavigationToolBar
45     //=====================================================================
46     class NavigationToolBar : public Window
47     {
48     public:
49         enum ImageSize
50         {
51             eSmall,
52             eLarge
53         };
54 
55         enum FunctionGroup
56         {
57             ePosition,
58             eNavigation,
59             eRecordActions,
60             eFilterSort
61         };
62 
63     private:
64         const IFeatureDispatcher*       m_pDispatcher;
65         const ::boost::shared_ptr< const ICommandImageProvider >
66                                         m_pImageProvider;
67         const ::boost::shared_ptr< const ICommandDescriptionProvider >
68                                         m_pDescriptionProvider;
69         ImageSize                       m_eImageSize;
70         ImplNavToolBar*                 m_pToolbar;
71         ::std::vector< Window* >        m_aChildWins;
72 
73     public:
74         NavigationToolBar(
75             Window* _pParent,
76             WinBits _nStyle,
77             const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider,
78             const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider
79         );
80         ~NavigationToolBar( );
81 
82         /** sets the dispatcher which is to be used for the features
83 
84             If the dispatcher is the same as the one which is currently set,
85             then the states of the features are updated
86 
87             @param _pDispatcher
88                 the new (or old) dispatcher. The caller is reponsible for
89                 ensuring the life time of the object does exceed the life time
90                 of the tool bar instance.
91         */
92         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
93 
94         /// enables or disables a given feature
95         void    enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );
96 
97         /// checks or unchecks a given feature
98         void    checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );
99 
100         /// sets the text of a given feature
101         void    setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText );
102 
103         /** retrieves the current image size
104         */
GetImageSize() const105         inline ImageSize    GetImageSize( ) const { return m_eImageSize; }
106 
107         /** sets the size of the images
108         */
109         void                SetImageSize( ImageSize _eSize );
110 
111         /** shows or hides a function group
112         */
113         void                ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow );
114 
115         /** determines whether or not a given function group is currently visible
116         */
117         bool                IsFunctionGroupVisible( FunctionGroup _eGroup );
118 
119         // Window "overridables" (hiding the respective Window methods)
120         void                SetControlBackground();
121         void                SetControlBackground( const Color& rColor );
122         void                SetTextLineColor( );
123         void                SetTextLineColor( const Color& rColor );
124 
125     protected:
126         // Window overridables
127         virtual void        Resize();
128         virtual void        StateChanged( StateChangedType nType );
129 
130         /// ctor implementation
131         void implInit( );
132 
133         /// impl version of SetImageSize
134         void    implSetImageSize( ImageSize _eSize );
135 
136         /// updates the images of our items
137         void    implUpdateImages();
138 
139         /// enables or disables an item, plus possible dependent items
140         void implEnableItem( sal_uInt16 _nItemId, bool _bEnabled );
141 
142         /** update the states of all features, using the callback
143         */
144         void updateFeatureStates( );
145 
146         // iterating through item windows
147 		typedef void (NavigationToolBar::*ItemWindowHandler) (sal_uInt16, Window*, const void*) const;
148         void    forEachItemWindow( ItemWindowHandler _handler, const void* _pParam );
149 
150         void setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
151         void setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
152 #if 0
153         void setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
154 #endif
155         void setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
156         void setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
157         void adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const;
158         void enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const;
159     };
160 
161     //=====================================================================
162     //= RecordPositionInput
163     //=====================================================================
164     class RecordPositionInput : public NumericField
165     {
166     private:
167         const IFeatureDispatcher*   m_pDispatcher;
168 
169     public:
170         RecordPositionInput( Window* _pParent );
171         ~RecordPositionInput();
172 
173         /** sets the dispatcher which is to be used for the features
174         */
175         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
176 
177     protected:
178         // Window overridables
179         virtual void LoseFocus();
180         virtual void KeyInput( const KeyEvent& rKeyEvent );
181 
182     private:
183         void FirePosition( sal_Bool _bForce );
184     };
185 
186 //.........................................................................
187 }   // namespace frm
188 //.........................................................................
189 
190 #endif // FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
191