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