1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX
21 #define INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX
23 #include <vcl/toolbox.hxx>
24 #include <vcl/field.hxx>
26 #include <boost/shared_ptr.hpp>
33 class IFeatureDispatcher
;
34 class ICommandImageProvider
;
35 class ICommandDescriptionProvider
;
39 class NavigationToolBar
: public vcl::Window
57 const IFeatureDispatcher
* m_pDispatcher
;
58 const ::boost::shared_ptr
< const ICommandImageProvider
>
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
;
68 vcl::Window
* _pParent
,
70 const ::boost::shared_ptr
< const ICommandImageProvider
>& _pImageProvider
,
71 const ::boost::shared_ptr
< const ICommandDescriptionProvider
>& _pDescriptionProvider
73 virtual ~NavigationToolBar( );
74 virtual void dispose() SAL_OVERRIDE
;
76 /** sets the dispatcher which is to be used for the features
78 If the dispatcher is the same as the one which is currently set,
79 then the states of the features are updated
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.
86 void setDispatcher( const IFeatureDispatcher
* _pDispatcher
);
88 /// enables or disables a given feature
89 void enableFeature( sal_Int16 _nFeatureId
, bool _bEnabled
);
91 /// checks or unchecks a given feature
92 void checkFeature( sal_Int16 _nFeatureId
, bool _bEnabled
);
94 /// sets the text of a given feature
95 void setFeatureText( sal_Int16 _nFeatureId
, const OUString
& _rText
);
97 /** retrieves the current image size
99 inline ImageSize
GetImageSize( ) const { return m_eImageSize
; }
101 /** sets the size of the images
103 void SetImageSize( ImageSize _eSize
);
105 /** shows or hides a function group
107 void ShowFunctionGroup( FunctionGroup _eGroup
, bool _bShow
);
109 /** determines whether or not a given function group is currently visible
111 bool IsFunctionGroupVisible( FunctionGroup _eGroup
);
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
);
120 // Window overridables
121 virtual void Resize() SAL_OVERRIDE
;
122 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
124 /// ctor implementation
127 /// impl version of SetImageSize
128 void implSetImageSize( ImageSize _eSize
);
130 /// updates the images of our items
131 void implUpdateImages();
133 /// enables or disables an item, plus possible dependent items
134 void implEnableItem( sal_uInt16 _nItemId
, bool _bEnabled
);
136 /** update the states of all features, using the callback
138 void updateFeatureStates( );
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
);
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
);
149 void setItemWindowZoom( sal_uInt16
/* _nItemId */, vcl::Window
* _pItemWindow
, const void* /* _pParam */ ) const;
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
);
157 class RecordPositionInput
: public NumericField
160 const IFeatureDispatcher
* m_pDispatcher
;
163 RecordPositionInput( vcl::Window
* _pParent
);
165 /** sets the dispatcher which is to be used for the features
167 void setDispatcher( const IFeatureDispatcher
* _pDispatcher
);
170 // Window overridables
171 virtual void LoseFocus() SAL_OVERRIDE
;
172 virtual void KeyInput( const KeyEvent
& rKeyEvent
) SAL_OVERRIDE
;
175 void FirePosition( bool _bForce
);
182 #endif // INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */