Pastey GTK2IUP

include pGUI.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)   
    string title = IupGetAttribute(ctl,"TIP"), 
           question = IupGetAttribute(ctl,"QUESTION"), 
           answer = IupGetAttribute(ctl,"ANSWER") 
      
    answer = substitute_all(decode_base64(answer),{"<i>","</i>"},{"",""}) 
      
    -- now we build our own custom dialog;  
      
    Ihandle ans = IupLabel(answer,`FONT="Courier Bold Italic 18"`) 
          
    Ihandle bx = IupHbox({IupFill(),ans,IupFill()},"MARGIN=10x20") 
          
    Ihandle expd = IupExpander(bx,`TITLE="Click here to see the answer...",STATE=CLOSE`) 
      
    Ihandle icon = IupLabel("","IMAGE=IUP_IconMessageHelp, PADDING=10,10") 
    Ihandle qu = IupHbox({IupFill(),icon,IupLabel(question),IupFill()},"MARGIN=0x20") 
    IupSetAttribute(qu,"NORMALIZESIZE","VERTICAL") 
    Ihandln dlg = IupDialog(IupVbox({qu,expd}),"RASTERSIZE=600x250") 
    IupSetAttribute(dlg,"TITLE",title) 
    IupSetAttributeHandle(dlg,"PARENTDIALOG",IupGetDialog(ctl)) 
      
    IupPopup(dlg,IUP_CURRENT,IUP_MOUSEPOS) 
    dlg = IupDestroy(dlg) 
      
    return IUP_DEFAULT 
end function 
 
IupOpen()  
IupImageLibOpen()  
 
Ihandle lbl = IupHbox({IupFill(),IupLabel(docs),IupFill()}) 
 
Ihandle btn1 = IupButton("Question _1",Icallback(ShowMe),`TIP="World History", IMAGE=IUP_MessageHelp, PADDING=5x5`) 
IupSetAttribute(btn1,"QUESTION",q1) 
IupSetAttribute(btn1,"ANSWER",a1) 
  
Ihandle btn2 = IupButton("Question _2",Icallback(ShowMe),`TIP="Science", IMAGE=IUP_MessageHelp, PADDING=5x5`) 
IupSetAttribute(btn2,"QUESTION",q2) 
IupSetAttribute(btn2,"ANSWER",a2) 
        
Ihandle btn3 = IupButton("Question _3",Icallback(ShowMe),`TIP="Business", IMAGE=IUP_MessageHelp, PADDING=5x5`) 
IupSetAttribute(btn3,"QUESTION",q3) 
IupSetAttribute(btn3,"ANSWER",a3) 
  
Ihandle box = IupHbox({btn1,IupFill(),btn2,IupFill(),btn3},"GAP=5") 
 
Ihandle pan = IupVbox({lbl,IupFill(),box},"GAP=10,MARGIN=10x10") 
  
Ihandle win = IupDialog(pan,`TITLE="IupExpander and Data Passing"`) 
 
IupShow(win) 
IupMainLoop()