LibreOffice Module vcl (master)
1
vcl
source
window
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
31
class
SalMenuItem
;
32
33
struct
MenuItemData
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
40
SalLayoutGlyphs
aTextGlyphs
;
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')
55
bool
bHiddenOnGUI
;
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
62
MenuItemData
()
63
:
nId
(0)
64
,
eType
(
MenuItemType
::
DONTKNOW
)
65
,
nBits
(
MenuItemBits
::
NONE
)
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)
78
,
eType
(
MenuItemType
::
DONTKNOW
)
79
,
nBits
(
MenuItemBits
::
NONE
)
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
}
92
~MenuItemData
();
93
95
SalLayoutGlyphs
*
GetTextGlyphs
(
const
OutputDevice
* pOutputDevice);
96
97
bool
HasCheck
()
const
98
{
99
return
bChecked
|| (
nBits
& (
MenuItemBits::RADIOCHECK
|
MenuItemBits::CHECKABLE
|
MenuItemBits::AUTOCHECK
) );
100
}
101
};
102
103
class
MenuItemList
104
{
105
private
:
106
::std::vector< std::unique_ptr<MenuItemData> >
maItemList
;
107
108
public
:
109
MenuItemList
() {}
110
~MenuItemList
();
111
112
MenuItemData
*
Insert
(
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
136
MenuItemData
*
SearchItem
(
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: */
Image
Definition:
image.hxx:40
MenuItemList
Definition:
menuitemlist.hxx:104
MenuItemList::GetItemCount
size_t GetItemCount(sal_Unicode cSelectChar) const
Definition:
menuitemlist.cxx:261
MenuItemList::MenuItemList
MenuItemList()
Definition:
menuitemlist.hxx:109
MenuItemList::size
size_t size() const
Definition:
menuitemlist.hxx:145
MenuItemList::Remove
void Remove(size_t nPos)
Definition:
menuitemlist.cxx:139
MenuItemList::GetData
MenuItemData * GetData(sal_uInt16 nSVId, size_t &rPos) const
Definition:
menuitemlist.cxx:152
MenuItemList::InsertSeparator
void InsertSeparator(const OUString &rIdent, size_t nPos)
Definition:
menuitemlist.cxx:107
MenuItemList::Clear
void Clear()
Definition:
menuitemlist.cxx:147
MenuItemList::GetDataFromPos
MenuItemData * GetDataFromPos(size_t nPos) const
Definition:
menuitemlist.hxx:131
MenuItemList::~MenuItemList
~MenuItemList()
Definition:
menuitemlist.cxx:63
MenuItemList::maItemList
::std::vector< std::unique_ptr< MenuItemData > > maItemList
Definition:
menuitemlist.hxx:106
MenuItemList::Insert
MenuItemData * Insert(sal_uInt16 nId, MenuItemType eType, MenuItemBits nBits, const OUString &rStr, Menu *pMenu, size_t nPos, const OUString &rIdent)
Definition:
menuitemlist.cxx:67
MenuItemList::GetData
MenuItemData * GetData(sal_uInt16 nSVId) const
Definition:
menuitemlist.hxx:126
MenuItemList::SearchItem
MenuItemData * SearchItem(sal_Unicode cSelectChar, vcl::KeyCode aKeyCode, size_t &rPos, size_t &nDuplicates, size_t nCurrentPos) const
Definition:
menuitemlist.cxx:165
Menu
Definition:
menu.hxx:116
OutputDevice
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition:
outdev.hxx:170
SalLayoutGlyphs
Definition:
glyphitem.hxx:32
SalMenuItem
Definition:
salmenu.hxx:53
Size
VclPtr< Menu >
vcl::KeyCode
Definition:
keycod.hxx:35
glyphitem.hxx
image.hxx
keycod.hxx
KeyFuncType::DONTKNOW
@ DONTKNOW
nPos
sal_uInt16 nPos
menu.hxx
MenuUserDataReleaseFunction
void(* MenuUserDataReleaseFunction)(void *)
Definition:
menu.hxx:113
aStr
aStr
NONE
NONE
std
salmenu.hxx
MenuItemData
Definition:
menuitemlist.hxx:34
MenuItemData::bHiddenOnGUI
bool bHiddenOnGUI
Definition:
menuitemlist.hxx:55
MenuItemData::aAccelKey
vcl::KeyCode aAccelKey
Definition:
menuitemlist.hxx:50
MenuItemData::bIsTemporary
bool bIsTemporary
Definition:
menuitemlist.hxx:54
MenuItemData::bEnabled
bool bEnabled
Definition:
menuitemlist.hxx:52
MenuItemData::aTextGlyphs
SalLayoutGlyphs aTextGlyphs
Text layout of aText.
Definition:
menuitemlist.hxx:40
MenuItemData::~MenuItemData
~MenuItemData()
Definition:
menuitemlist.cxx:36
MenuItemData::pSubMenu
VclPtr< Menu > pSubMenu
Definition:
menuitemlist.hxx:38
MenuItemData::nId
sal_uInt16 nId
Definition:
menuitemlist.hxx:35
MenuItemData::aImage
Image aImage
Definition:
menuitemlist.hxx:49
MenuItemData::sIdent
OUString sIdent
Definition:
menuitemlist.hxx:45
MenuItemData::bVisible
bool bVisible
Definition:
menuitemlist.hxx:53
MenuItemData::MenuItemData
MenuItemData()
Definition:
menuitemlist.hxx:62
MenuItemData::aSz
Size aSz
Definition:
menuitemlist.hxx:56
MenuItemData::nUserValue
void * nUserValue
Definition:
menuitemlist.hxx:47
MenuItemData::bChecked
bool bChecked
Definition:
menuitemlist.hxx:51
MenuItemData::aUserValueReleaseFunc
MenuUserDataReleaseFunction aUserValueReleaseFunc
Definition:
menuitemlist.hxx:48
MenuItemData::nBits
MenuItemBits nBits
Definition:
menuitemlist.hxx:37
MenuItemData::GetTextGlyphs
SalLayoutGlyphs * GetTextGlyphs(const OutputDevice *pOutputDevice)
Computes aText's text layout (glyphs), cached in aTextGlyphs.
Definition:
menuitemlist.cxx:44
MenuItemData::aAccessibleDescription
OUString aAccessibleDescription
Definition:
menuitemlist.hxx:58
MenuItemData::pSalMenuItem
std::unique_ptr< SalMenuItem > pSalMenuItem
Definition:
menuitemlist.hxx:60
MenuItemData::eType
MenuItemType eType
Definition:
menuitemlist.hxx:36
MenuItemData::aHelpId
OUString aHelpId
Definition:
menuitemlist.hxx:46
MenuItemData::aAccessibleName
OUString aAccessibleName
Definition:
menuitemlist.hxx:57
MenuItemData::MenuItemData
MenuItemData(OUString aStr)
Definition:
menuitemlist.hxx:76
MenuItemData::aHelpText
OUString aHelpText
Definition:
menuitemlist.hxx:41
MenuItemData::aCommandStr
OUString aCommandStr
Definition:
menuitemlist.hxx:43
MenuItemData::aHelpCommandStr
OUString aHelpCommandStr
Definition:
menuitemlist.hxx:44
MenuItemData::aText
OUString aText
Definition:
menuitemlist.hxx:39
MenuItemData::HasCheck
bool HasCheck() const
Definition:
menuitemlist.hxx:97
MenuItemData::aTipHelpText
OUString aTipHelpText
Definition:
menuitemlist.hxx:42
sal_Unicode
sal_uInt16 sal_Unicode
vclenum.hxx
MenuItemType
MenuItemType
Definition:
vclenum.hxx:30
MenuItemBits
MenuItemBits
Definition:
vclenum.hxx:33
MenuItemBits::CHECKABLE
@ CHECKABLE
MenuItemBits::RADIOCHECK
@ RADIOCHECK
MenuItemBits::AUTOCHECK
@ AUTOCHECK
Generated on Sun Jul 30 2023 04:35:50 for LibreOffice Module vcl (master) by
1.9.3