(function() { load("Motif") load("Xbae") # Number of rows and columns in the matrix to use in the example r = 100 c = 20 X = XApplication("matrix") main = Widget("form","XmMainWindow",X@widget,propogate = T) mb = Widget("menu","XmMenuBar", main) # note that we create this as unmanaged as this is the # window that get's popped up when we click in the # cascade button. Thus it shouldn't be managed yet. menu = Widget("file","PullDownMenu", mb,manage=F) cmenu = Widget("file","XmCascadeButton", mb, subMenuId=menu) cbs = list(Save=Quote(print(Print)), Load=Quote({print(Glossary); print(length(Glossary))}), # Print=Quote(print(Reload)), Print=NULL, Quit=Quote(Xit(XApp)) ) items = vector("list",length(cbs)) for(i in names(cbs)) { items[[i]] = Widget(i, "XmPushButton", menu) if(!is.null(cbs[[i]])) Callback(cbs[[i]],items[[i]],"activate") } Callback( Quote(Callback(Quote(print("Hi there")),Glossary.widget,"activate")), items[["Print"]],"activate") help.menu = Widget("help","PullDownMenu", mb,manage=F) help.cmenu = Widget("help","XmCascadeButton", mb, subMenuId=help.menu) cbs = list(Index=Quote({load("HTML");if(exists(".Help"))Help("help",widget=.Help$widget) else .Help=Help("help",app=XApp)}), Glossary=Quote({load("HTML");if(exists(".Help"))Help("class",widget=.Help$widget) else .Help=Help("class",app=XApp)})) # cbs = list(Index=Quote({load("HTML");Help("help")}), Glossary=Quote({load("HTML");if(exists(".Help"))Help("class",widget=.Help$widget) else .Help=Help("class",app=XApp)})) items = vector("list",length(cbs)) for(i in names(cbs)) { items[[i]] = Widget(i, "XmPushButton", help.menu) Callback(cbs[[i]],items[[i]],"activate") } assign("Glossary.widget", items[["Glossary"]], where = X@frame) # Put this back when setResource handles it correctly # setResource(mb,menuHelpWidget=help.cmenu) mat = Widget("mat", "XbaeMatrix", main) data = matrix(as.character(round(rnorm(r*c),4)), r,c) dimnames(data) <- list(paste("Obs",1:r),paste("X",1:c)) XMatrix(data,mat) # note that if we set this resource before the call to XMatrix # then this gets reset when we reset the number of columns. # So it amounts to no change! resize = XResource("allowColumnResize", T) aligns = XResource("columnLabelAlignments",rep("XmALIGNMENT_CENTER",c)) setResource(mat, resize, aligns, columnAlignments=rep("XmALIGNMENT_END",c)) setMainWindowComponents(main,menubar=mb, work=mat) XRealize(X) invisible(return(X)) })()