<motifinit
motif application=`SortDemo' create! ;
motif_form new: `f' parent=`motif' create! ;
motif_bulletin_board new: `bb' parent=`f' @ `topAttachment' : XmATTACH_FORM @ `leftAttachment' : XmATTACH_FORM @ `rightAttachment' : XmATTACH_FORM @ `width' : 384 @ `height' : 384 create! ;
motif_push_button new: `pb1' parent=`f' @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [bb id?] @ `bottomAttachment' : XmATTACH_FORM @ `leftAttachment' : XmATTACH_FORM @ `rightAttachment' : XmATTACH_POSITION @ `rightPosition' : 50 @ `labelString' : `Push to generate labels' activate_action=`generate_labels' create! ;
actions new: `generate_labels' tick_actions=` scalar new: `x' new: `y';
loop new: `l' resolution= 1 duration= 4 tick_actions=` x drand48! * 300 integerize!; y drand48! * 300 integerize!; motif_label_gadget new! generate_name! parent=`bb' @ `x' : x @ `y' : y create! ; ' end_actions=` bb @ `width' : 384 @ `height' : 384; ' start! ; ' ;
motif_push_button new: `pb2' parent=`f' @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [bb id?] @ `leftAttachment' : XmATTACH_WIDGET @ `leftWidget' : [pb1 id?] @ `rightAttachment' : XmATTACH_FORM @ `labelString' : `Push to sort labels' activate_action=`sort_labels' create! ;
actions new: `sort_labels' tick_actions=` collection new: `c' members=[motif_label_gadget instances?];
-- parser parse: `! Data before sorting:'; s_vector new: `names' = [c members?] /* print:`components' */; vector new: `x' = [c @ `x' scalar_value?] /* print:`components' */; vector new: `y' = [c @ `y' scalar_value?] /* print:`components' */; multi_key_sort new: `sorter' data=(`y', `x', `names') sort! ; -- parser parse: `! Data after sorting:'; -- names print:`components'; -- x print:`components'; -- y print:`components'; ' ;
motif on! start!;