By taking a look at staves in the CK, I see they just have an enchantment attached, and this enchantment is associated to the exact same spell characters can cast. So, seems the only difference is that the cost is removed from the staff energy instead of being removed from the character's magicka pool.
My questions are: How can I identify if a spell is being cast by the character or from a staff? Where can I put the script to consume magicka from the character? And how can I cancel the cast if the caster has no enough magicka (not consuming the staff energy)?