1package body agar.gui.widget.radio is 2 3 use type c.int; 4 5 package cbinds is 6 function allocate 7 (parent : widget_access_t; 8 flags : flags_t; 9 items : agar.core.types.void_ptr_t) return radio_access_t; 10 pragma import (c, allocate, "AG_RadioNew"); 11 12 function add_item 13 (radio : radio_access_t; 14 text : cs.chars_ptr) return c.int; 15 pragma import (c, add_item, "AG_RadioAddItemS"); 16 17 function add_item_hotkey 18 (radio : radio_access_t; 19 key : c.int; 20 text : cs.chars_ptr) return c.int; 21 pragma import (c, add_item_hotkey, "AG_RadioAddItemHKS"); 22 end cbinds; 23 24 function allocate 25 (parent : widget_access_t; 26 flags : flags_t) return radio_access_t is 27 begin 28 return cbinds.allocate 29 (parent => parent, 30 flags => flags, 31 items => agar.core.types.null_ptr); 32 end allocate; 33 34 function add_item 35 (radio : radio_access_t; 36 text : string) return boolean 37 is 38 c_txt : aliased c.char_array := c.to_c (text); 39 begin 40 return cbinds.add_item 41 (radio => radio, 42 text => cs.to_chars_ptr (c_txt'unchecked_access)) = 0; 43 end add_item; 44 45 function add_item_hotkey 46 (radio : radio_access_t; 47 key : c.int; 48 text : string) return boolean 49 is 50 c_txt : aliased c.char_array := c.to_c (text); 51 begin 52 return cbinds.add_item_hotkey 53 (radio => radio, 54 key => key, 55 text => cs.to_chars_ptr (c_txt'unchecked_access)) = 0; 56 end add_item_hotkey; 57 58 function widget (radio : radio_access_t) return widget_access_t is 59 begin 60 return radio.widget'access; 61 end widget; 62 63end agar.gui.widget.radio; 64