Pastey longhand version

include pGUIC.e
constant docs = `  

 
    Elements have a Data space  
    which you can use to declare and pass   
    multiple key/value pairs`  

 
constant -- answers are encrypted to avoid overturning the legumes;  
   
q1 = "What is purple and conquered the world?",  
a1 = "PGk+QWxleGFuZGVyIHRoZSBHcmFwZSE8L2k+",  
  
q2 = "What lies at the bottom of the ocean and twitches?",  
a2 = "PGk+QSBuZXJ2b3VzIHdyZWNrLjwvaT4=",  
  
q3 = "Why is Christmas just like another day at the office?",  
a3 = "WW91IGRvIGFsbCBvZiB0aGUgd29yayBhbmQgdGhlIGZhdCBndXkKaW4gdGhlIHN1aXQgZ2V0cyBhbGwgdGhlIGNyZWRpdC4="  
 
function ShowMe(Ihandle ctl) 
--?{"dict_dize",dict_size(hdict)} 
    Element button = get_element_by_handle(ctl) 
    string title = button.tooltip_text, 
           question = button.get_data("Question"), -- get data items by name;  
           answer = button.get_data("Answer")  
      
    answer = substitute_all(decode_base64(answer),{"<i>","</i>"},{"",""}) 
      
    -- now we build our own custom dialog;  
      
    Label ans = new() 
          ans.title = answer 
          ans.font = "Courier Bold Italic 18"  
          
    Hbox bx = new() 
         bx.add(Filler()) 
         bx.add(ans) 
         bx.add(Filler()) 
         bx.margin = "10x20" 
          
    Expander expd = new() 
             expd.title = "Click here to see the answer..."  
             expd.add(bx)   
             expd.state = "CLOSE" 
      
    Label icon = new() 
          icon.image = "IUP_IconMessageHelp" 
          icon.padding = "10x10" 
 
    Label qlbl = new() 
          qlbl.title = question 
 
    Hbox qbox = new() 
         qbox.add(Filler()) 
         qbox.add(icon) 
         qbox.add(qlbl) 
         qbox.add(Filler()) 
         qbox.margin = "0x20" 
         qbox.normalizesize = "vertical" 
 
    Vbox vbox = new() 
         vbox.add(qbox) 
         vbox.add(expd) 
 
    Window dlg = new() 
           dlg.add(vbox) 
           dlg.title = title 
           dlg.size = "600x250" 
           dlg.parent = ctl 
      
    dlg.popup(IUP_LEFTPARENT,IUP_TOPPARENT) 
      
--  delete(dlg) -- NB crashes on <= 0.8.3 
 
    return 1  
end function   
 
IupOpen()  
IupImageLibOpen()  
 
Label lbl = new({docs}) 
Hbox lbox = new({{Filler(),lbl,Filler()}})  
 
Button btn1 = new()  
       btn1.title = "Question _1"  
       btn1.action = ShowMe 
       btn1.tooltip_text = "World History"  
       btn1.image = "IUP_MessageHelp"  
       btn1.padding = "5x5"  
       btn1.set_data("Question",q1)  
       btn1.set_data("Answer",a1)  
  
Button btn2 = new()  
       btn2.title = "Question _2"  
       btn2.action = ShowMe 
       btn2.tooltip_text = "Science"  
       btn2.image = "IUP_MessageHelp"  
       btn2.padding = "5x5"  
       btn2.set_data("Question",q2)  
       btn2.set_data("Answer",a2)  
        
Button btn3 = new()  
       btn3.title = "Question _3"  
       btn3.action = ShowMe 
       btn3.tooltip_text = "Business"  
       btn3.image = "IUP_MessageHelp"  
       btn3.padding = "5x5" 
       btn3.set_data("Question",q3)  
       btn3.set_data("Answer",a3)  
  
Hbox box = new() 
     box.add(btn1) 
     box.add(Filler()) 
     box.add(btn2) 
     box.add(Filler()) 
     box.add(btn3) 
     box.gap = 5 
 
--procedure set(struct s, string field, object v) 
--  s[field] = v 
--end procedure 
 
Vbox pan = new() 
     pan.add(lbox) 
     pan.add(Filler()) 
     pan.add(box) 
     pan.gap = 10 
--   set(pan,"gap",10) 
     pan.margin = "10x10" 
--   set(pan,"margin","10x10") 
  
Window win = new() 
    win.add(pan) 
    win.title = `IupExpander and Data Passing`  
 
win.show()  
IupMainLoop() 
--delete(win) -- (may crash on <= 0.8.3)