The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.internal.view.menu; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.graphics.drawable.Drawable; |
| 21 | import android.view.Menu; |
| 22 | import android.view.MenuItem; |
| 23 | import android.view.SubMenu; |
| 24 | import android.view.View; |
| 25 | |
| 26 | /** |
| 27 | * The model for a sub menu, which is an extension of the menu. Most methods are proxied to |
| 28 | * the parent menu. |
| 29 | */ |
| 30 | public class SubMenuBuilder extends MenuBuilder implements SubMenu { |
| 31 | private MenuBuilder mParentMenu; |
| 32 | private MenuItemImpl mItem; |
| 33 | |
| 34 | public SubMenuBuilder(Context context, MenuBuilder parentMenu, MenuItemImpl item) { |
| 35 | super(context); |
| 36 | |
| 37 | mParentMenu = parentMenu; |
| 38 | mItem = item; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public void setQwertyMode(boolean isQwerty) { |
| 43 | mParentMenu.setQwertyMode(isQwerty); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public boolean isQwertyMode() { |
| 48 | return mParentMenu.isQwertyMode(); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void setShortcutsVisible(boolean shortcutsVisible) { |
| 53 | mParentMenu.setShortcutsVisible(shortcutsVisible); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean isShortcutsVisible() { |
| 58 | return mParentMenu.isShortcutsVisible(); |
| 59 | } |
| 60 | |
| 61 | public Menu getParentMenu() { |
| 62 | return mParentMenu; |
| 63 | } |
| 64 | |
| 65 | public MenuItem getItem() { |
| 66 | return mItem; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public Callback getCallback() { |
| 71 | return mParentMenu.getCallback(); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public void setCallback(Callback callback) { |
| 76 | mParentMenu.setCallback(callback); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public MenuBuilder getRootMenu() { |
| 81 | return mParentMenu; |
| 82 | } |
| 83 | |
| 84 | public SubMenu setIcon(Drawable icon) { |
| 85 | mItem.setIcon(icon); |
| 86 | return this; |
| 87 | } |
| 88 | |
| 89 | public SubMenu setIcon(int iconRes) { |
| 90 | mItem.setIcon(iconRes); |
| 91 | return this; |
| 92 | } |
| 93 | |
| 94 | public SubMenu setHeaderIcon(Drawable icon) { |
| 95 | return (SubMenu) super.setHeaderIconInt(icon); |
| 96 | } |
| 97 | |
| 98 | public SubMenu setHeaderIcon(int iconRes) { |
| 99 | return (SubMenu) super.setHeaderIconInt(iconRes); |
| 100 | } |
| 101 | |
| 102 | public SubMenu setHeaderTitle(CharSequence title) { |
| 103 | return (SubMenu) super.setHeaderTitleInt(title); |
| 104 | } |
| 105 | |
| 106 | public SubMenu setHeaderTitle(int titleRes) { |
| 107 | return (SubMenu) super.setHeaderTitleInt(titleRes); |
| 108 | } |
| 109 | |
| 110 | public SubMenu setHeaderView(View view) { |
| 111 | return (SubMenu) super.setHeaderViewInt(view); |
| 112 | } |
| 113 | |
| 114 | } |