build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / window / menuitemlist.hxx
blob556a5a0495972335cca5fd655d3eec0be8b29832
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <rsc/rsc-vcl-shared-types.hxx>
21 #include <vcl/image.hxx>
22 #include <vcl/keycod.hxx>
23 #include <vcl/menu.hxx>
25 #include <com/sun/star/i18n/XCharacterClassification.hpp>
27 #include <vector>
29 class SalMenuItem;
31 struct MenuItemData
33 sal_uInt16 nId; // SV Id
34 MenuItemType eType; // MenuItem-Type
35 MenuItemBits nBits; // MenuItem-Bits
36 VclPtr<Menu> pSubMenu; // Pointer to SubMenu
37 VclPtr<Menu> pAutoSubMenu; // Pointer to SubMenu from Resource
38 OUString aText; // Menu-Text
39 OUString aHelpText; // Help-String
40 OUString aTipHelpText; // TipHelp-String (eg, expanded filenames)
41 OUString aCommandStr; // CommandString
42 OUString aHelpCommandStr; // Help command string (to reference external help)
43 OString sIdent;
44 OString aHelpId; // Help-Id
45 sal_uLong nUserValue; // User value
46 MenuUserDataReleaseFunction aUserValueReleaseFunc; // called when MenuItemData is destroyed
47 Image aImage; // Image
48 vcl::KeyCode aAccelKey; // Accelerator-Key
49 bool bChecked; // Checked
50 bool bEnabled; // Enabled
51 bool bVisible; // Visible (note: this flag will not override MenuFlags::HideDisabledEntries when true)
52 bool bIsTemporary; // Temporary inserted ('No selection possible')
53 Size aSz; // only temporarily valid
54 OUString aAccessibleName; // accessible name
56 SalMenuItem* pSalMenuItem; // access to native menu
58 MenuItemData()
59 : nId(0)
60 , eType(MenuItemType::DONTKNOW)
61 , nBits(MenuItemBits::NONE)
62 , pSubMenu(nullptr)
63 , pAutoSubMenu(nullptr)
64 , nUserValue(0)
65 , aUserValueReleaseFunc(nullptr)
66 , bChecked(false)
67 , bEnabled(false)
68 , bVisible(false)
69 , bIsTemporary(false)
70 , pSalMenuItem(nullptr)
73 MenuItemData( const OUString& rStr, const Image& rImage )
74 : nId(0)
75 , eType(MenuItemType::DONTKNOW)
76 , nBits(MenuItemBits::NONE)
77 , pSubMenu(nullptr)
78 , pAutoSubMenu(nullptr)
79 , aText(rStr)
80 , nUserValue(0)
81 , aUserValueReleaseFunc(nullptr)
82 , aImage(rImage)
83 , bChecked(false)
84 , bEnabled(false)
85 , bVisible(false)
86 , bIsTemporary(false)
87 , pSalMenuItem(nullptr)
90 ~MenuItemData();
91 bool HasCheck() const
93 return bChecked || ( nBits & ( MenuItemBits::RADIOCHECK | MenuItemBits::CHECKABLE | MenuItemBits::AUTOCHECK ) );
97 class MenuItemList
99 private:
100 typedef ::std::vector< MenuItemData* > MenuItemDataList_impl;
101 MenuItemDataList_impl maItemList;
103 public:
104 MenuItemList() {}
105 ~MenuItemList();
107 MenuItemData* Insert(
108 sal_uInt16 nId,
109 MenuItemType eType,
110 MenuItemBits nBits,
111 const OUString& rStr,
112 const Image& rImage,
113 Menu* pMenu,
114 size_t nPos,
115 const OString &rIdent
117 void InsertSeparator(const OString &rIdent, size_t nPos);
118 void Remove( size_t nPos );
119 void Clear();
121 MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
122 MenuItemData* GetData( sal_uInt16 nSVId ) const
124 size_t nTemp;
125 return GetData( nSVId, nTemp );
127 MenuItemData* GetDataFromPos( size_t nPos ) const
129 return ( nPos < maItemList.size() ) ? maItemList[ nPos ] : nullptr;
132 MenuItemData* SearchItem(
133 sal_Unicode cSelectChar,
134 vcl::KeyCode aKeyCode,
135 sal_uInt16& rPos,
136 sal_uInt16& nDuplicates,
137 sal_uInt16 nCurrentPos
138 ) const;
139 size_t GetItemCount( sal_Unicode cSelectChar ) const;
140 size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
141 size_t size()
143 return maItemList.size();
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */