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.text.style; 18 19import android.graphics.Paint; 20import android.graphics.Canvas; 21import android.os.Parcel; 22import android.text.Layout; 23import android.text.ParcelableSpan; 24import android.text.TextUtils; 25 26public interface LeadingMarginSpan 27extends ParagraphStyle 28{ 29 public int getLeadingMargin(boolean first); 30 public void drawLeadingMargin(Canvas c, Paint p, 31 int x, int dir, 32 int top, int baseline, int bottom, 33 CharSequence text, int start, int end, 34 boolean first, Layout layout); 35 36 public static class Standard implements LeadingMarginSpan, ParcelableSpan { 37 private final int mFirst, mRest; 38 39 public Standard(int first, int rest) { 40 mFirst = first; 41 mRest = rest; 42 } 43 44 public Standard(int every) { 45 this(every, every); 46 } 47 48 public Standard(Parcel src) { 49 mFirst = src.readInt(); 50 mRest = src.readInt(); 51 } 52 53 public int getSpanTypeId() { 54 return TextUtils.LEADING_MARGIN_SPAN; 55 } 56 57 public int describeContents() { 58 return 0; 59 } 60 61 public void writeToParcel(Parcel dest, int flags) { 62 dest.writeInt(mFirst); 63 dest.writeInt(mRest); 64 } 65 66 public int getLeadingMargin(boolean first) { 67 return first ? mFirst : mRest; 68 } 69 70 public void drawLeadingMargin(Canvas c, Paint p, 71 int x, int dir, 72 int top, int baseline, int bottom, 73 CharSequence text, int start, int end, 74 boolean first, Layout layout) { 75 ; 76 } 77 } 78} 79