1*2d785d7eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2d785d7eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2d785d7eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2d785d7eSAndrew Rist  * distributed with this work for additional information
6*2d785d7eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2d785d7eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2d785d7eSAndrew Rist  * "License"); you may not use this file except in compliance
9*2d785d7eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2d785d7eSAndrew Rist  *
11*2d785d7eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2d785d7eSAndrew Rist  *
13*2d785d7eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2d785d7eSAndrew Rist  * software distributed under the License is distributed on an
15*2d785d7eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2d785d7eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2d785d7eSAndrew Rist  * specific language governing permissions and limitations
18*2d785d7eSAndrew Rist  * under the License.
19*2d785d7eSAndrew Rist  *
20*2d785d7eSAndrew Rist  *************************************************************/
21*2d785d7eSAndrew Rist 
22*2d785d7eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
25cdf0e10cSrcweir #define FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/toolbox.hxx>
28cdf0e10cSrcweir #include <vcl/field.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir //.........................................................................
33cdf0e10cSrcweir namespace frm
34cdf0e10cSrcweir {
35cdf0e10cSrcweir //.........................................................................
36cdf0e10cSrcweir 
37cdf0e10cSrcweir     class IFeatureDispatcher;
38cdf0e10cSrcweir     class ICommandImageProvider;
39cdf0e10cSrcweir     class ICommandDescriptionProvider;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     class ImplNavToolBar;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     //=====================================================================
44cdf0e10cSrcweir     //= NavigationToolBar
45cdf0e10cSrcweir     //=====================================================================
46cdf0e10cSrcweir     class NavigationToolBar : public Window
47cdf0e10cSrcweir     {
48cdf0e10cSrcweir     public:
49cdf0e10cSrcweir         enum ImageSize
50cdf0e10cSrcweir         {
51cdf0e10cSrcweir             eSmall,
52cdf0e10cSrcweir             eLarge
53cdf0e10cSrcweir         };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         enum FunctionGroup
56cdf0e10cSrcweir         {
57cdf0e10cSrcweir             ePosition,
58cdf0e10cSrcweir             eNavigation,
59cdf0e10cSrcweir             eRecordActions,
60cdf0e10cSrcweir             eFilterSort
61cdf0e10cSrcweir         };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     private:
64cdf0e10cSrcweir         const IFeatureDispatcher*       m_pDispatcher;
65cdf0e10cSrcweir         const ::boost::shared_ptr< const ICommandImageProvider >
66cdf0e10cSrcweir                                         m_pImageProvider;
67cdf0e10cSrcweir         const ::boost::shared_ptr< const ICommandDescriptionProvider >
68cdf0e10cSrcweir                                         m_pDescriptionProvider;
69cdf0e10cSrcweir         ImageSize                       m_eImageSize;
70cdf0e10cSrcweir         ImplNavToolBar*                 m_pToolbar;
71cdf0e10cSrcweir         ::std::vector< Window* >        m_aChildWins;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     public:
74cdf0e10cSrcweir         NavigationToolBar(
75cdf0e10cSrcweir             Window* _pParent,
76cdf0e10cSrcweir             WinBits _nStyle,
77cdf0e10cSrcweir             const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider,
78cdf0e10cSrcweir             const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider
79cdf0e10cSrcweir         );
80cdf0e10cSrcweir         ~NavigationToolBar( );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         /** sets the dispatcher which is to be used for the features
83cdf0e10cSrcweir 
84cdf0e10cSrcweir             If the dispatcher is the same as the one which is currently set,
85cdf0e10cSrcweir             then the states of the features are updated
86cdf0e10cSrcweir 
87cdf0e10cSrcweir             @param _pDispatcher
88cdf0e10cSrcweir                 the new (or old) dispatcher. The caller is reponsible for
89cdf0e10cSrcweir                 ensuring the life time of the object does exceed the life time
90cdf0e10cSrcweir                 of the tool bar instance.
91cdf0e10cSrcweir         */
92cdf0e10cSrcweir         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         /// enables or disables a given feature
95cdf0e10cSrcweir         void    enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         /// checks or unchecks a given feature
98cdf0e10cSrcweir         void    checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         /// sets the text of a given feature
101cdf0e10cSrcweir         void    setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         /** retrieves the current image size
104cdf0e10cSrcweir         */
GetImageSize() const105cdf0e10cSrcweir         inline ImageSize    GetImageSize( ) const { return m_eImageSize; }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         /** sets the size of the images
108cdf0e10cSrcweir         */
109cdf0e10cSrcweir         void                SetImageSize( ImageSize _eSize );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         /** shows or hides a function group
112cdf0e10cSrcweir         */
113cdf0e10cSrcweir         void                ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         /** determines whether or not a given function group is currently visible
116cdf0e10cSrcweir         */
117cdf0e10cSrcweir         bool                IsFunctionGroupVisible( FunctionGroup _eGroup );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         // Window "overridables" (hiding the respective Window methods)
120cdf0e10cSrcweir         void                SetControlBackground();
121cdf0e10cSrcweir         void                SetControlBackground( const Color& rColor );
122cdf0e10cSrcweir         void                SetTextLineColor( );
123cdf0e10cSrcweir         void                SetTextLineColor( const Color& rColor );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     protected:
126cdf0e10cSrcweir         // Window overridables
127cdf0e10cSrcweir         virtual void        Resize();
128cdf0e10cSrcweir         virtual void        StateChanged( StateChangedType nType );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         /// ctor implementation
131cdf0e10cSrcweir         void implInit( );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         /// impl version of SetImageSize
134cdf0e10cSrcweir         void    implSetImageSize( ImageSize _eSize );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         /// updates the images of our items
137cdf0e10cSrcweir         void    implUpdateImages();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         /// enables or disables an item, plus possible dependent items
140cdf0e10cSrcweir         void implEnableItem( sal_uInt16 _nItemId, bool _bEnabled );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         /** update the states of all features, using the callback
143cdf0e10cSrcweir         */
144cdf0e10cSrcweir         void updateFeatureStates( );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         // iterating through item windows
147cdf0e10cSrcweir 		typedef void (NavigationToolBar::*ItemWindowHandler) (sal_uInt16, Window*, const void*) const;
148cdf0e10cSrcweir         void    forEachItemWindow( ItemWindowHandler _handler, const void* _pParam );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         void setItemBackground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
151cdf0e10cSrcweir         void setTextLineColor( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* _pColor ) const;
152cdf0e10cSrcweir #if 0
153cdf0e10cSrcweir         void setItemWindowZoom( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
154cdf0e10cSrcweir #endif
155cdf0e10cSrcweir         void setItemControlFont( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
156cdf0e10cSrcweir         void setItemControlForeground( sal_uInt16 /* _nItemId */, Window* _pItemWindow, const void* /* _pParam */ ) const;
157cdf0e10cSrcweir         void adjustItemWindowWidth( sal_uInt16 _nItemId, Window* _pItemWindow, const void* /* _pParam */ ) const;
158cdf0e10cSrcweir         void enableItemRTL( sal_uInt16 /*_nItemId*/, Window* _pItemWindow, const void* _pIsRTLEnabled ) const;
159cdf0e10cSrcweir     };
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     //=====================================================================
162cdf0e10cSrcweir     //= RecordPositionInput
163cdf0e10cSrcweir     //=====================================================================
164cdf0e10cSrcweir     class RecordPositionInput : public NumericField
165cdf0e10cSrcweir     {
166cdf0e10cSrcweir     private:
167cdf0e10cSrcweir         const IFeatureDispatcher*   m_pDispatcher;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     public:
170cdf0e10cSrcweir         RecordPositionInput( Window* _pParent );
171cdf0e10cSrcweir         ~RecordPositionInput();
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         /** sets the dispatcher which is to be used for the features
174cdf0e10cSrcweir         */
175cdf0e10cSrcweir         void    setDispatcher( const IFeatureDispatcher* _pDispatcher );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     protected:
178cdf0e10cSrcweir         // Window overridables
179cdf0e10cSrcweir         virtual void LoseFocus();
180cdf0e10cSrcweir         virtual void KeyInput( const KeyEvent& rKeyEvent );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     private:
183cdf0e10cSrcweir         void FirePosition( sal_Bool _bForce );
184cdf0e10cSrcweir     };
185cdf0e10cSrcweir 
186cdf0e10cSrcweir //.........................................................................
187cdf0e10cSrcweir }   // namespace frm
188cdf0e10cSrcweir //.........................................................................
189cdf0e10cSrcweir 
190cdf0e10cSrcweir #endif // FORMS_SOLAR_CONTROL_NAVTOOLBAR_HXX
191