Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/toolkit/ivctrl.hxx
Line
Count
Source
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
#pragma once
21
22
#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23
#error "don't use this in new code"
24
#endif
25
26
#include <config_options.h>
27
#include <memory>
28
#include <vcl/dllapi.h>
29
#include <vcl/ctrl.hxx>
30
#include <tools/link.hxx>
31
#include <vcl/image.hxx>
32
#include <o3tl/deleter.hxx>
33
#include <o3tl/typed_flags_set.hxx>
34
35
class SvxIconChoiceCtrl_Impl;
36
37
enum class SvxIconViewFlags
38
{
39
    NONE           = 0x0000,
40
    SELECTED       = 0x0001,
41
    FOCUSED        = 0x0002,
42
};
43
namespace o3tl
44
{
45
    template<> struct typed_flags<SvxIconViewFlags> : is_typed_flags<SvxIconViewFlags, 0x000f> {};
46
}
47
48
class SvxIconChoiceCtrlEntry
49
{
50
    Image aImage;
51
52
    OUString aText;
53
    OUString aQuickHelpText;
54
55
    friend class SvxIconChoiceCtrl_Impl;
56
    friend class IcnCursor_Impl;
57
    friend class EntryList_Impl;
58
    friend class IcnGridMap_Impl;
59
60
    tools::Rectangle               aRect;              // Bounding-Rectangle of the entry
61
62
    sal_uInt16                      nX,nY;      // for keyboard control
63
    SvxIconViewFlags                nFlags;
64
65
0
    void                    ClearFlags( SvxIconViewFlags nMask ) { nFlags &= ~nMask; }
66
0
    void                    SetFlags( SvxIconViewFlags nMask ) { nFlags |= nMask; }
67
0
    void                    AssignFlags( SvxIconViewFlags _nFlags ) { nFlags = _nFlags; }
68
69
public:
70
                            SvxIconChoiceCtrlEntry( OUString aText, Image aImage );
71
72
0
    const Image&            GetImage () const { return aImage; }
73
0
    void                    SetText ( const OUString& rText ) { aText = rText; }
74
0
    const OUString&         GetText () const { return aText; }
75
    OUString UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC)  GetDisplayText() const;
76
0
    void                    SetQuickHelpText( const OUString& rText ) { aQuickHelpText = rText; }
77
0
    const OUString&         GetQuickHelpText() const { return aQuickHelpText; }
78
79
0
    SvxIconViewFlags        GetFlags() const { return nFlags; }
80
0
    bool                    IsSelected() const { return bool(nFlags & SvxIconViewFlags::SELECTED); }
81
0
    bool                    IsFocused() const { return bool(nFlags & SvxIconViewFlags::FOCUSED); }
82
};
83
84
85
/*
86
    Window-Bits:
87
        WB_ICON             // Text beneath the icon
88
        WB_SMALLICON        // Text right to the icon, position does not mind
89
        WB_DETAILS          // Text right to the icon, limited positioning
90
        WB_BORDER
91
        WB_NOHIDESELECTION  // Draw selection inactively, if not focused.
92
        WB_NOHSCROLL
93
        WB_NOVSCROLL
94
        WB_NODRAGSELECTION  // No selection with tracking rectangle
95
        WB_NOCOLUMNHEADER   // No Headerbar in Details view (Headerbar not implemented)
96
        WB_NOPOINTERFOCUS   // No GrabFocus at MouseButtonDown
97
*/
98
99
0
#define WB_ICON                 WB_RECTSTYLE
100
0
#define WB_SMALLICON            WB_SMALLSTYLE
101
0
#define WB_DETAILS              WB_VCENTER
102
0
#define WB_NOHSCROLL            WB_SPIN
103
0
#define WB_NOVSCROLL            WB_DRAG
104
0
#define WB_NODRAGSELECTION      WB_PATHELLIPSIS
105
0
#define WB_NOCOLUMNHEADER       WB_CENTER
106
107
class MnemonicGenerator;
108
109
class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvtIconChoiceCtrl final : public Control
110
{
111
    friend class SvxIconChoiceCtrl_Impl;
112
113
    Link<SvtIconChoiceCtrl*,void>  _aClickIconHdl;
114
    std::unique_ptr<SvxIconChoiceCtrl_Impl, o3tl::default_delete<SvxIconChoiceCtrl_Impl>> _pImpl;
115
116
    virtual void        KeyInput( const KeyEvent& rKEvt ) override;
117
    virtual void        Command( const CommandEvent& rCEvt ) override;
118
    virtual void        Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
119
    virtual void        MouseButtonDown( const MouseEvent& rMEvt ) override;
120
    virtual void        MouseMove( const MouseEvent& rMEvt ) override;
121
    virtual void        Resize() override;
122
    virtual void        GetFocus() override;
123
    virtual void        LoseFocus() override;
124
    void                ClickIcon();
125
    virtual void        DataChanged( const DataChangedEvent& rDCEvt ) override;
126
    virtual void        RequestHelp( const HelpEvent& rHEvt ) override;
127
128
    virtual void        FillLayoutData() const override;
129
130
    void                CallImplEventListeners(VclEventId nEvent, void* pData);
131
    long                m_nWidth;
132
133
public:
134
135
                        SvtIconChoiceCtrl( vcl::Window* pParent, WinBits nWinStyle );
136
    virtual             ~SvtIconChoiceCtrl() override;
137
    virtual void        dispose() override;
138
139
    void                SetFont( const vcl::Font& rFont );
140
    void                SetPointFont( const vcl::Font& rFont );
141
142
0
    void                SetClickHdl( const Link<SvtIconChoiceCtrl*,void>& rLink ) { _aClickIconHdl = rLink; }
143
144
    using Window::SetBackground;
145
    void                SetBackground( const Wallpaper& rWallpaper );
146
147
    void                ArrangeIcons();
148
    long                AdjustWidth(const long nWidth); // returns the effective width
149
150
151
    SvxIconChoiceCtrlEntry* InsertEntry( const OUString& rText,
152
                                         const Image& rImage);
153
154
    void RemoveEntry(sal_Int32 nEntryListPos);
155
156
    bool                DoKeyInput( const KeyEvent& rKEvt );
157
158
    sal_Int32               GetEntryCount() const;
159
    SvxIconChoiceCtrlEntry* GetEntry( sal_Int32 nPos ) const;
160
    sal_Int32               GetEntryListPos( SvxIconChoiceCtrlEntry const * pEntry ) const;
161
    using Window::SetCursor;
162
    void                    SetCursor( SvxIconChoiceCtrlEntry* pEntry );
163
    SvxIconChoiceCtrlEntry* GetCursor() const;
164
165
    SvxIconChoiceCtrlEntry* GetSelectedEntry() const;
166
167
    tools::Rectangle           GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const;
168
    tools::Rectangle           GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const;
169
170
    // ACCESSIBILITY ==========================================================
171
172
    /** Creates and returns the accessible object of the Box. */
173
    virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override;
174
};
175
176
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */