2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.text.style;
19 import android.graphics.Paint;
20 import android.text.TextPaint;
23 * The classes that affect character-level text formatting in a way that
24 * changes the width or height of characters extend this class.
26 public abstract class MetricAffectingSpan
27 extends CharacterStyle
28 implements UpdateLayout {
30 public abstract void updateMeasureState(TextPaint p);
33 * Returns "this" for most MetricAffectingSpans, but for
34 * MetricAffectingSpans that were generated by {@link #wrap},
35 * returns the underlying MetricAffectingSpan.
38 public MetricAffectingSpan getUnderlying() {
43 * A Passthrough MetricAffectingSpan is one that
44 * passes {@link #updateDrawState} and {@link #updateMeasureState}
45 * calls through to the specified MetricAffectingSpan
46 * while still being a distinct object,
47 * and is therefore able to be attached to the same Spannable
48 * to which the specified MetricAffectingSpan is already attached.
50 /* package */ static class Passthrough extends MetricAffectingSpan {
51 private MetricAffectingSpan mStyle;
54 * Creates a new Passthrough of the specfied MetricAffectingSpan.
56 public Passthrough(MetricAffectingSpan cs) {
61 * Passes updateDrawState through to the underlying MetricAffectingSpan.
64 public void updateDrawState(TextPaint tp) {
65 mStyle.updateDrawState(tp);
69 * Passes updateMeasureState through to the underlying MetricAffectingSpan.
72 public void updateMeasureState(TextPaint tp) {
73 mStyle.updateMeasureState(tp);
77 * Returns the MetricAffectingSpan underlying this one, or the one
78 * underlying it if it too is a Passthrough.
81 public MetricAffectingSpan getUnderlying() {
82 return mStyle.getUnderlying();