summaryrefslogtreecommitdiffstats
path: root/forms/source/solar/inc/navtoolbar.hxx
blob: 5b643b367ce103c5cdc387aad85dfef6a16482e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX
#define INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX

#include <vcl/field.hxx>

#include <memory>


namespace frm
{


    class IFeatureDispatcher;
    class DocumentCommandImageProvider;
    class ICommandDescriptionProvider;
    class ImplNavToolBar;
    typedef std::shared_ptr< const DocumentCommandImageProvider >  PCommandImageProvider;

    class NavigationToolBar final : public vcl::Window
    {
    public:
        enum ImageSize
        {
            eSmall,
            eLarge
        };

        enum FunctionGroup
        {
            ePosition,
            eNavigation,
            eRecordActions,
            eFilterSort
        };

    private:
        const IFeatureDispatcher*       m_pDispatcher;
        const std::shared_ptr< const DocumentCommandImageProvider >
                                        m_pImageProvider;
        ImageSize                       m_eImageSize;
        VclPtr<ImplNavToolBar>          m_pToolbar;
        ::std::vector< VclPtr<vcl::Window> > m_aChildWins;
        const OUString                  m_sModuleId;

    public:
        NavigationToolBar(
            vcl::Window* _pParent,
            WinBits _nStyle,
            const PCommandImageProvider& _pImageProvider,
            const OUString & sModuleId
        );
        virtual ~NavigationToolBar( ) override;
        virtual void dispose() override;

        /** sets the dispatcher which is to be used for the features

            If the dispatcher is the same as the one which is currently set,
            then the states of the features are updated

            @param _pDispatcher
                the new (or old) dispatcher. The caller is responsible for
                ensuring the life time of the object does exceed the life time
                of the tool bar instance.
        */
        void    setDispatcher( const IFeatureDispatcher* _pDispatcher );

        /// enables or disables a given feature
        void    enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );

        /// checks or unchecks a given feature
        void    checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );

        /// sets the text of a given feature
        void    setFeatureText( sal_Int16 _nFeatureId, const OUString& _rText );

        /** retrieves the current image size
        */
        ImageSize    GetImageSize( ) const { return m_eImageSize; }

        /** sets the size of the images
        */
        void                SetImageSize( ImageSize _eSize );

        /** shows or hides a function group
        */
        void                ShowFunctionGroup( FunctionGroup _eGroup, bool _bShow );

        /** determines whether or not a given function group is currently visible
        */
        bool                IsFunctionGroupVisible( FunctionGroup _eGroup );

        // Window "overridables" (hiding the respective Window methods)
        void                SetControlBackground();
        void                SetControlBackground( const Color& rColor );
        void                SetTextLineColor( );
        void                SetTextLineColor( const Color& rColor );

    private:
        // Window overridables
        virtual void        Resize() override;
        virtual void        StateChanged( StateChangedType nType ) override;

        /// ctor implementation
        void implInit( );

        /// impl version of SetImageSize
        void    implSetImageSize( ImageSize _eSize );

        /// updates the images of our items
        void    implUpdateImages();

        /// enables or disables an item, plus possible dependent items
        void implEnableItem( sal_uInt16 _nItemId, bool _bEnabled );

        // iterating through item windows
        typedef void (NavigationToolBar::*ItemWindowHandler) (sal_uInt16, vcl::Window*) const;
        void    forEachItemWindow( ItemWindowHandler _handler );
        typedef void (*ItemWindowHandler2) (sal_uInt16, vcl::Window*, const void*);
        void    forEachItemWindow( ItemWindowHandler2 _handler, const void* _pParam );

        static void setItemBackground( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow, const void* _pColor );
        static void setTextLineColor( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow, const void* _pColor );
#if 0
        void setItemWindowZoom( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow, const void* /* _pParam */ ) const;
#endif
        void setItemControlFont( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow ) const;
        void setItemControlForeground( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow ) const;
        void adjustItemWindowWidth( sal_uInt16 _nItemId, vcl::Window* _pItemWindow ) const;
        static void enableItemRTL( sal_uInt16 /*_nItemId*/, vcl::Window* _pItemWindow, const void* _pIsRTLEnabled );
    };

    class RecordPositionInput : public NumericField
    {
    private:
        const IFeatureDispatcher*   m_pDispatcher;

    public:
        RecordPositionInput( vcl::Window* _pParent );

        /** sets the dispatcher which is to be used for the features
        */
        void    setDispatcher( const IFeatureDispatcher* _pDispatcher );

    protected:
        // Window overridables
        virtual void LoseFocus() override;
        virtual void KeyInput( const KeyEvent& rKeyEvent ) override;

    private:
        void FirePosition( bool _bForce );
    };


}   // namespace frm


#endif // INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */