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
17package android.support.v7.internal.view.menu;
18
19import android.graphics.drawable.Drawable;
20
21/**
22 * Minimal interface for a menu view.  {@link #initialize(MenuBuilder)} must be called for the menu
23 * to be functional.
24 *
25 * @hide
26 */
27public interface MenuView {
28
29    /**
30     * Initializes the menu to the given menu. This should be called after the view is inflated.
31     *
32     * @param menu The menu that this MenuView should display.
33     */
34    public void initialize(MenuBuilder menu);
35
36    /**
37     * Returns the default animations to be used for this menu when entering/exiting.
38     *
39     * @return A resource ID for the default animations to be used for this menu.
40     */
41    public int getWindowAnimations();
42
43    /**
44     * Minimal interface for a menu item view.  {@link #initialize(MenuItemImpl, int)} must be
45     * called for the item to be functional.
46     */
47    public interface ItemView {
48
49        /**
50         * Initializes with the provided MenuItemData.  This should be called after the view is
51         * inflated.
52         *
53         * @param itemData The item that this ItemView should display.
54         * @param menuType The type of this menu, one of TYPE_ICON, TYPE_EXPANDED or TYPE_DIALOG.
55         */
56        public void initialize(MenuItemImpl itemData, int menuType);
57
58        /**
59         * Gets the item data that this view is displaying.
60         *
61         * @return the item data, or null if there is not one
62         */
63        public MenuItemImpl getItemData();
64
65        /**
66         * Sets the title of the item view.
67         *
68         * @param title The title to set.
69         */
70        public void setTitle(CharSequence title);
71
72        /**
73         * Sets the enabled state of the item view.
74         *
75         * @param enabled Whether the item view should be enabled.
76         */
77        public void setEnabled(boolean enabled);
78
79        /**
80         * Displays the checkbox for the item view.  This does not ensure the item view will be
81         * checked, for that use {@link #setChecked}.
82         *
83         * @param checkable Whether to display the checkbox or to hide it
84         */
85        public void setCheckable(boolean checkable);
86
87        /**
88         * Checks the checkbox for the item view.  If the checkbox is hidden, it will NOT be made
89         * visible, call {@link #setCheckable(boolean)} for that.
90         *
91         * @param checked Whether the checkbox should be checked
92         */
93        public void setChecked(boolean checked);
94
95        /**
96         * Sets the shortcut for the item.
97         *
98         * @param showShortcut Whether a shortcut should be shown(if false, the value of shortcutKey
99         *                     should be ignored).
100         * @param shortcutKey  The shortcut key that should be shown on the ItemView.
101         */
102        public void setShortcut(boolean showShortcut, char shortcutKey);
103
104        /**
105         * Set the icon of this item view.
106         *
107         * @param icon The icon of this item. null to hide the icon.
108         */
109        public void setIcon(Drawable icon);
110
111        /**
112         * Whether this item view prefers displaying the condensed title rather than the normal
113         * title. If a condensed title is not available, the normal title will be used.
114         *
115         * @return Whether this item view prefers displaying the condensed title.
116         */
117        public boolean prefersCondensedTitle();
118
119        /**
120         * Whether this item view shows an icon.
121         *
122         * @return Whether this item view shows an icon.
123         */
124        public boolean showsIcon();
125    }
126}
127