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