package cn.muchinfo.rma.view.autoWidget

import android.graphics.Color
import android.text.TextUtils
import android.util.TypedValue
import android.widget.TextView
import org.jetbrains.anko.internals.AnkoInternals
import org.jetbrains.anko.singleLine

var TextView.textSizeAuto: Number
    @Deprecated(AnkoInternals.NO_GETTER, level = DeprecationLevel.ERROR) get() = AnkoInternals.noGetter()
    set(value) {
        setTextSize(TypedValue.COMPLEX_UNIT_PX, autoSize(value).toFloat())
    }

var android.widget.TextView.textColorStr: String
    @Deprecated(AnkoInternals.NO_GETTER, level = DeprecationLevel.ERROR) get() = AnkoInternals.noGetter()
    set(v) = setTextColor(Color.parseColor(v))

var android.widget.TextView.textColorInt: Int
    @Deprecated(AnkoInternals.NO_GETTER, level = DeprecationLevel.ERROR) get() = AnkoInternals.noGetter()
    set(v) = setTextColor(resources.getColor(v))

var android.widget.TextView.hintColorStr: String
    @Deprecated(AnkoInternals.NO_GETTER, level = DeprecationLevel.ERROR) get() = AnkoInternals.noGetter()
    set(v) = setHintTextColor(Color.parseColor(v))


var android.widget.TextView.textStr: Int
    @Deprecated(AnkoInternals.NO_GETTER, level = DeprecationLevel.ERROR) get() = AnkoInternals.noGetter()
    set(v) = setText(resources.getString(v))

fun TextView.marquee() {
    ellipsize = TextUtils.TruncateAt.MARQUEE
    singleLine = true
    isFocusable = true
    isFocusableInTouchMode = true
    marqueeRepeatLimit = -1
    requestFocus()
}
