LibreOffice Module vcl (master) 1
menuitemlist.hxx
Go to the documentation of this file.
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#include <utility>
21#include <vcl/vclenum.hxx>
22#include <vcl/glyphitem.hxx>
23#include <vcl/image.hxx>
24#include <vcl/keycod.hxx>
25#include <vcl/menu.hxx>
26#include <salmenu.hxx>
27
28#include <memory>
29#include <vector>
30
31class SalMenuItem;
32
34{
35 sal_uInt16 nId; // SV Id
36 MenuItemType eType; // MenuItem-Type
37 MenuItemBits nBits; // MenuItem-Bits
38 VclPtr<Menu> pSubMenu; // Pointer to SubMenu
39 OUString aText; // Menu-Text
41 OUString aHelpText; // Help-String
42 OUString aTipHelpText; // TipHelp-String (eg, expanded filenames)
43 OUString aCommandStr; // CommandString
44 OUString aHelpCommandStr; // Help command string (to reference external help)
45 OUString sIdent;
46 OUString aHelpId; // Help-Id
47 void* nUserValue; // User value
48 MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed
49 Image aImage; // Image
50 vcl::KeyCode aAccelKey; // Accelerator-Key
51 bool bChecked; // Checked
52 bool bEnabled; // Enabled
53 bool bVisible; // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
54 bool bIsTemporary; // Temporary inserted ('No selection possible')
56 Size aSz; // only temporarily valid
57 OUString aAccessibleName; // accessible name
58 OUString aAccessibleDescription; // accessible description
59
60 std::unique_ptr<SalMenuItem> pSalMenuItem; // access to native menu
61
63 : nId(0)
66 , pSubMenu(nullptr)
67 , nUserValue(nullptr)
68 , aUserValueReleaseFunc(nullptr)
69 , bChecked(false)
70 , bEnabled(false)
71 , bVisible(false)
72 , bIsTemporary(false)
73 , bHiddenOnGUI(false)
74 {
75 }
76 MenuItemData( OUString aStr )
77 : nId(0)
80 , pSubMenu(nullptr)
81 , aText(std::move(aStr))
82 , nUserValue(nullptr)
83 , aUserValueReleaseFunc(nullptr)
84 , aImage()
85 , bChecked(false)
86 , bEnabled(false)
87 , bVisible(false)
88 , bIsTemporary(false)
89 , bHiddenOnGUI(false)
90 {
91 }
93
95 SalLayoutGlyphs* GetTextGlyphs(const OutputDevice* pOutputDevice);
96
97 bool HasCheck() const
98 {
100 }
101};
102
104{
105private:
106 ::std::vector< std::unique_ptr<MenuItemData> > maItemList;
107
108public:
111
113 sal_uInt16 nId,
114 MenuItemType eType,
115 MenuItemBits nBits,
116 const OUString& rStr,
117 Menu* pMenu,
118 size_t nPos,
119 const OUString &rIdent
120 );
121 void InsertSeparator(const OUString &rIdent, size_t nPos);
122 void Remove( size_t nPos );
123 void Clear();
124
125 MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
126 MenuItemData* GetData( sal_uInt16 nSVId ) const
127 {
128 size_t nTemp;
129 return GetData( nSVId, nTemp );
130 }
131 MenuItemData* GetDataFromPos( size_t nPos ) const
132 {
133 return ( nPos < maItemList.size() ) ? maItemList[ nPos ].get() : nullptr;
134 }
135
137 sal_Unicode cSelectChar,
138 vcl::KeyCode aKeyCode,
139 size_t& rPos,
140 size_t& nDuplicates,
141 size_t nCurrentPos
142 ) const;
143 size_t GetItemCount( sal_Unicode cSelectChar ) const;
144 size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
145 size_t size() const
146 {
147 return maItemList.size();
148 }
149};
150
151/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: image.hxx:40
size_t GetItemCount(sal_Unicode cSelectChar) const
size_t size() const
void Remove(size_t nPos)
MenuItemData * GetData(sal_uInt16 nSVId, size_t &rPos) const
void InsertSeparator(const OUString &rIdent, size_t nPos)
MenuItemData * GetDataFromPos(size_t nPos) const
::std::vector< std::unique_ptr< MenuItemData > > maItemList
MenuItemData * Insert(sal_uInt16 nId, MenuItemType eType, MenuItemBits nBits, const OUString &rStr, Menu *pMenu, size_t nPos, const OUString &rIdent)
MenuItemData * GetData(sal_uInt16 nSVId) const
MenuItemData * SearchItem(sal_Unicode cSelectChar, vcl::KeyCode aKeyCode, size_t &rPos, size_t &nDuplicates, size_t nCurrentPos) const
Definition: menu.hxx:116
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
sal_uInt16 nPos
void(* MenuUserDataReleaseFunction)(void *)
Definition: menu.hxx:113
aStr
NONE
vcl::KeyCode aAccelKey
SalLayoutGlyphs aTextGlyphs
Text layout of aText.
VclPtr< Menu > pSubMenu
sal_uInt16 nId
OUString sIdent
void * nUserValue
MenuUserDataReleaseFunction aUserValueReleaseFunc
MenuItemBits nBits
SalLayoutGlyphs * GetTextGlyphs(const OutputDevice *pOutputDevice)
Computes aText's text layout (glyphs), cached in aTextGlyphs.
OUString aAccessibleDescription
std::unique_ptr< SalMenuItem > pSalMenuItem
MenuItemType eType
OUString aHelpId
OUString aAccessibleName
MenuItemData(OUString aStr)
OUString aHelpText
OUString aCommandStr
OUString aHelpCommandStr
OUString aText
bool HasCheck() const
OUString aTipHelpText
sal_uInt16 sal_Unicode
MenuItemType
Definition: vclenum.hxx:30
MenuItemBits
Definition: vclenum.hxx:33