blob: e81b6e3086dac761861fb7ac2d8e2104a205ccac (
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
|
/* 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/. */
#ifndef __nsMenuItem_h__
#define __nsMenuItem_h__
#include "mozilla/Attributes.h"
#include "nsCOMPtr.h"
#include "nsDbusmenu.h"
#include "nsMenuObject.h"
#include <glib.h>
class nsIAtom;
class nsIContent;
class nsStyleContext;
class nsMenuBar;
class nsMenuContainer;
/*
* This class represents 3 main classes of menuitems: labels, checkboxes and
* radio buttons (with/without an icon)
*/
class nsMenuItem final : public nsMenuObject {
public:
nsMenuItem(nsMenuContainer* aParent, nsIContent* aContent);
~nsMenuItem() override;
nsMenuObject::EType Type() const override;
private:
friend class nsMenuItemUncheckSiblingsRunnable;
enum {
eMenuItemFlag_ToggleState = (1 << 0)
};
enum EMenuItemType {
eMenuItemType_Normal,
eMenuItemType_Radio,
eMenuItemType_CheckBox
};
bool IsCheckboxOrRadioItem() const;
static void item_activated_cb(DbusmenuMenuitem* menuitem,
guint timestamp,
gpointer user_data);
void Activate(uint32_t aTimestamp);
void CopyAttrFromNodeIfExists(nsIContent* aContent, nsIAtom* aAtom);
void UpdateState();
void UpdateTypeAndState();
void UpdateAccel();
nsMenuBar* MenuBar();
void UncheckSiblings();
void InitializeNativeData() override;
void UpdateContentAttributes() override;
void Update(nsStyleContext* aStyleContext) override;
bool IsCompatibleWithNativeData(DbusmenuMenuitem* aNativeData) const override;
nsMenuObject::PropertyFlags SupportedProperties() const override;
void OnAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute) override;
EMenuItemType mType;
bool mIsChecked;
bool mNeedsUpdate;
nsCOMPtr<nsIContent> mKeyContent;
};
#endif /* __nsMenuItem_h__ */
|