blob: 1d90c36358c7a74dc103277e9ccce7737e66f7ff (
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
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/base/models/menu_model.h"
namespace ui {
int MenuModel::GetFirstItemIndex(gfx::NativeMenu native_menu) const {
return 0;
}
bool MenuModel::IsVisibleAt(int index) const {
return true;
}
bool MenuModel::GetModelAndIndexForCommandId(int command_id,
MenuModel** model, int* index) {
const int item_count = (*model)->GetItemCount();
const int index_offset = (*model)->GetFirstItemIndex(NULL);
for (int i = 0; i < item_count; ++i) {
const int candidate_index = i + index_offset;
if ((*model)->GetTypeAt(candidate_index) == TYPE_SUBMENU) {
MenuModel* submenu_model = (*model)->GetSubmenuModelAt(candidate_index);
if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
*model = submenu_model;
return true;
}
}
if ((*model)->GetCommandIdAt(candidate_index) == command_id) {
*index = candidate_index;
return true;
}
}
return false;
}
const gfx::Font* MenuModel::GetLabelFontAt(int index) const {
return NULL;
}
// Default implementation ignores the disposition.
void MenuModel::ActivatedAtWithDisposition(int index, int disposition) {
ActivatedAt(index);
}
} // namespace ui
|