# Class: Icon

### LuxModule: gui

An Icon is a small gui element for graphical symbols. An Icon in Luxinia could be of any type - 2D, 3D, animated and so on, so this class should provide some basic interface definititions and functions to create, delete and hiding the graphical representation of the Icon.

## Hierarchy

    o-+ Icon
      o-- ImageIcon
      o-- L2DIcon
      o-- L3DIcon

## Methods:

### Method overview:

- REASON.COLORCHANGE
- REASON.CREATEDVIS
- REASON.DELETEDVIS
- REASON.RESIZED
- REASON.SKINCHANGE
- REASON.VISCHANGE
- clone
- color
- contains
- createVisibles
- delete
- deleteVisibles
- getClip
- getHeight
- getSize
- getWidth
- height
- id
- new
- onDestroy
- selectIcon
- setBounds
- setClip
- setLocation
- setSortID
- setVisibility
- setZ
- surface
- toString
- update
- visibleflag
- width
- x
- y
- z

new (class, [width,height])
  returns: (Icon)
  Sets metatable index to class. Per default, a skin does not create any visual objects during start. These must be created by calling createVisibles.
REASON.COLORCHANGE
  {[string]}=colorchange - colorchange reason
REASON.CREATEDVIS
  {[string]}=createdvis - vischange reason
REASON.DELETEDVIS
  {[string]}=deletedvis - vischange reason
REASON.RESIZED
  {[string]}=resized - resized skin
REASON.SKINCHANGE
  {[string]}=skinchange - skinchange reason
REASON.VISCHANGE
  {[string]}=vischange - vischange reason
clone (Icon)
  returns: (Icon)
  Creates a copy of this Icon ready to be used. Must be overloaded, otherwise an error is thrown.
color (Icon,[r,g=1,b=1,a=1])
  returns: ([r,g,b,a])
  Sets the color of the icon - might depend on implementation.
contains (Icon, x,y)
  returns: (boolean)
  returns true if the specific pixel is clickable. Returns true per default
createVisibles (Icon,l2dnode parent)
  returns: ()
  Creates all visible resources required for displaying the icon. Might get called even if the visible information have been created already.
delete (Icon)
  returns: ()
  deletes the icon. This function might get called multiple times so flag your icon once you have deleted it. Per default the deletefunction will call the deleteVisibles function. If your Icon does not require further resources you can leave it this way.
deleteVisibles (Icon)
  returns: ()
  frees resources that are required for displaying the icon. Might get called even if the visible information have been deleted.
getClip (Icon)
  returns: ([x,y,w,h])
  gets clipping for icon or disables it if no clipping is passed
getHeight (Icon)
  returns: (h)
  returns height of the Icon
getSize (Icon)
  returns: (w,h)
  returns width and height of the Icon
getWidth (Icon)
  returns: (w)
  returns width of the Icon
height
  [float] - height of the icon
id
  [float] - l2d sortid
onDestroy (Icon)
  returns: ()
  called by the garbagecollector
selectIcon (Icon, icon)
  returns: ()

  Selects an Icon. This means a different representation of the same icon. If the icon is used by a Skin2D object, the Skin2D object will automaticly forward its selectSkin parameter to this function. So an icon that is assigned to a skin used by a component should provide the "surface" that are specific for this component.

  If no surface of that name exists the surface "default" is tried out, if that fails too the object handles the case on its own.
setBounds (Icon,x,y,w,h)
  returns: ()
  sets self.x, self.y, self.width and self.height to the given values and calls the update function
setClip (Icon,[x,y,w,h])
  returns: ()
  sets clipping for icon or disables it if no clipping is passed
setLocation (Icon,x,y)
  returns: ()
  sets new location for icon
setSortID (Icon, id)
  returns: ()
  sets sortids for l2d sorting
setVisibility (Icon,boolean visible)
  returns: ()
  Shows or hides the icon. Only affects Icons that have created visible resources.
setZ (Icon, z)
  returns: ()
  Z offset to l2dlayer
surface
  [string] - surface that should be used for this icon
toString (Icon)
  returns: (string)
  called by the tostring function and returns a string representing the icon information
update (Icon,reason)
  returns: ()
  function that is called if something has changed. The reason should be one of the constants defined in the Icon class and describes the reason why the icon was updated more precisly.
visibleflag
  [boolean] - true if the icon should be visible, but depends if the visible resources exists
width
  [float] - width of the icon
x
  [float] - position of the bounds of the icon
y
  [float] - position of the bounds of the icon
z
  [float] - z position in l2d layer