package com.aincc.lib.ui.widget.button;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.Button;
/**
*
* <h3><b>AButton</b></h3></br>
*
* @author aincc@barusoft.com
* @version 1.0.0
* @since 1.0.0
*/
public class AButton extends Button
{
/**
* context
*/
protected Context context;
/**
* offset
*/
protected PointF offset = new PointF();
/**
*
* @since 1.0.0
* @param context
*/
public AButton(Context context)
{
super(context);
initialize(context, null);
}
/**
*
* @since 1.0.0
* @param context
* @param attrs
*/
public AButton(Context context, AttributeSet attrs)
{
super(context, attrs);
initialize(context, attrs);
}
/**
*
* @since 1.0.0
* @param context
* @param attrs
* @param defStyle
*/
public AButton(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
initialize(context, attrs);
}
/**
*
* @since 1.0.0
* @param context
* @param attrs
*/
protected void initialize(Context context, AttributeSet attrs)
{
this.context = context;
}
@Override
public void getHitRect(Rect outRect)
{
Rect cur = new Rect();
super.getHitRect(cur);
if (null != outRect && null != offset)
{
outRect.bottom = (int) (cur.bottom + offset.y);
outRect.top = (int) (cur.top + offset.y);
outRect.left = (int) (cur.left + offset.x);
outRect.right = (int) (cur.right + offset.x);
}
else
{
outRect = cur;
}
}
/**
*
* @since 1.0.0
* @return offset
*/
public PointF getOffset()
{
return offset;
}
/**
*
* @since 1.0.0
* @param offset
*/
public void setOffset(PointF offset)
{
this.offset = offset;
}
}