aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java
new file mode 100644
index 0000000..9397ef8
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IViewMetadata.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.common.api;
+
+/**
+ * Metadata about a particular view. The metadata for a View can be found by asking the
+ * {@link IClientRulesEngine} for the metadata for a given class via
+ * {@link IClientRulesEngine#getMetadata}.
+ */
+public interface IViewMetadata {
+ /**
+ * Returns true if this view is a potential parent (e.g. it <b>can</b> have children).
+ *
+ * @return true if this view can have children
+ */
+ public boolean isParent();
+
+ /**
+ * Returns the display name views of this type (a name suitable to display to the
+ * user, normally capitalized and usually but not necessarily tied to the
+ * implementation class). To be clear, a specific view may have an id attribute and a
+ * text attribute, <b>neither</b> of these is the display name. Instead, the class
+ * android.widget.ZoomControls may have the display name "Zoom Controls", and an
+ * individual view created into a layout can for example have the id "ZoomControl01".
+ *
+ * @return the user visible name of views of this type (never null)
+ */
+ public String getDisplayName();
+
+ /**
+ * Returns the tooltip for this view, if any
+ *
+ * @return a tooltip, or null
+ */
+ public String getTooltip();
+
+ /**
+ * Returns the {@link FillPreference} of this view
+ *
+ * @return the {@link FillPreference} of this view
+ */
+ public FillPreference getFillPreference();
+
+ /**
+ * Types of fill behavior that views can prefer.
+ * <p>
+ * TODO: Consider better names. FillPolicy? Stretchiness?
+ */
+ public enum FillPreference {
+ /** This view does not want to fill */
+ NONE,
+ /** This view wants to always fill both horizontal and vertical */
+ BOTH,
+ /** This view wants to fill horizontally but not vertically */
+ WIDTH,
+ /** This view wants to fill vertically but not horizontally */
+ HEIGHT,
+ /**
+ * This view wants to fill in the opposite dimension of the context, e.g. in a
+ * vertical context it wants to fill horizontally, and vice versa
+ */
+ OPPOSITE,
+ /** This view wants to fill horizontally, but only in a vertical context */
+ WIDTH_IN_VERTICAL,
+ /** This view wants to fill vertically, but only in a horizontal context */
+ HEIGHT_IN_HORIZONTAL;
+
+ /**
+ * Returns true if this view wants to fill horizontally, if the context is
+ * vertical or horizontal as indicated by the parameter.
+ *
+ * @param verticalContext If true, the context is vertical, otherwise it is
+ * horizontal.
+ * @return true if this view wants to fill horizontally
+ */
+ public boolean fillHorizontally(boolean verticalContext) {
+ return (this == BOTH || this == WIDTH ||
+ (verticalContext && (this == OPPOSITE || this == WIDTH_IN_VERTICAL)));
+ }
+
+ /**
+ * Returns true if this view wants to fill vertically, if the context is
+ * vertical or horizontal as indicated by the parameter.
+ *
+ * @param verticalContext If true, the context is vertical, otherwise it is
+ * horizontal.
+ * @return true if this view wants to fill vertically
+ */
+ public boolean fillVertically(boolean verticalContext) {
+ return (this == BOTH || this == HEIGHT ||
+ (!verticalContext && (this == OPPOSITE || this == HEIGHT_IN_HORIZONTAL)));
+ }
+ }
+
+}