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