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