icons.anubis 1.92 KB
/*
 * Created by PyramIDE.
 * User: フランスのトトロ aka (David RENÉ) 
 * Date: 13/02/2016
 * Time: 10:31
 * © David RENÉ
 */

transmit tools/basis.anubis
transmit system/muscle.anubis
transmit calexium_lib/CXM_message_constants.anubis
transmit calexium_lib/web/CXM_json.anubis

transmit hayamiki_lib/model/types/hk_icon.anubis

public define String
/* Return the Anubis source of the type component
*/
  to_Anubis_source
  (
    HK_Icon icon
  )=
  if icon is
  {
    no_icon         then  "no_icon",
    icon16(icn_str) then  "icon16(\""+icn_str+"\")"
  }.

public define String
/* Return the Anubis source of the type component
*/
  to_String
  (
    HK_Icon icon
  )=
  if icon is
  {
    no_icon         then  "\"\"",
    icon16(icn_str) then  "\""+icn_str+"_icon\""
  }.

 /* *
  _HK_ICON message format:
  =======================
  +-----------+-----------+--------------------------------
  |  name     |  type     |      description
  +-----------+-----------+--------------------------------
  | "hk_icon" | String    | type of the icon. It sould be 
                              "no_icon"
                              "icon_16" __
    ______________________________________|
   |
   --> icon_16:
      +-----------+-----------+--------------------------------
      |  name     |  type     |      description
      +-----------+-----------+--------------------------------
      | "icn_str" | String    | String name of the 16x16 icon. 
  
     */
     


public define JsonValue
  to_JSON
  (    
    HK_Icon hk_icon
  )=
  with members = 
    if hk_icon is
    {
      no_icon           then  [ json_member("hk_icon", json_string("no_icon"))
                              ],
                              
      icon16(icn_str)   then  [ json_member("hk_icon", json_string("icon_16")),
                                json_member("icn_str", json_string(icn_str))
                              ]
    },
  
  json_object("_HK_ICON", members).