int main(int argc, char **argv) { Ihandle *dlg; Ihandle *lbl; IupOpen(&argc, &argv); IupMglPlotOpen(); lbl = IupMglLabel("\\int \\alpha \\sqrt{sin(\\pi x)^2 + \\gamma_{i_k}} dx"); IupSetAttribute(lbl, "RASTERSIZE", "400x80"); IupSetAttribute(lbl, "LABELFONTSIZE", "10"); // IupSetAttribute(lbl, "BGCOLOR", "255 255 0"); // IupSetAttribute(lbl, "FGCOLOR", "0 0 255"); dlg = IupDialog(IupVbox(lbl, NULL)); IupSetAttribute(dlg, "MARGIN", "10x10"); IupSetAttribute(dlg, "TITLE", "IupMglLabel Example"); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
void MglPlotTest(void) { static Ihandle *dlg = NULL; if (!dlg) { Ihandle *vboxr[MAXPLOT+1]; /* tabs containing the plots */ Ihandle *vboxl, *hbox, *lbl1, *lbl2, *lbl3, *bt1, *boxinfo, *boxdial1, *boxdial2, *f1, *f2; int ii; IupControlsOpen(); IupMglPlotOpen(); /* init IupMGLPlot library */ IupSetGlobal("MGLFONTS", "../etc/mglfonts"); /* create plots */ for (ii=0; ii<MAXPLOT; ii++) { plot[ii] = IupMglPlot(); IupSetAttribute(plot[ii], "OPENGL", "Yes"); } /* left panel: plot control Y zooming */ dial1 = IupDial("VERTICAL"); lbl1 = IupLabel("+"); lbl2 = IupLabel("-"); boxinfo = IupVbox(lbl1, IupFill(), lbl2, NULL); boxdial1 = IupHbox(boxinfo, dial1, NULL); IupSetAttribute(boxdial1, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "20x52"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "YES"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial1, "ACTIVE", "NO"); IupSetAttribute(dial1, "SIZE", "20x52"); IupSetCallback(dial1, "BUTTON_PRESS_CB", (Icallback)dial1_btndown_cb); IupSetCallback(dial1, "MOUSEMOVE_CB", (Icallback)dial1_btnup_cb); IupSetCallback(dial1, "BUTTON_RELEASE_CB", (Icallback)dial1_btnup_cb); tgg1 = IupToggle("Y Autoscale", NULL); IupSetCallback(tgg1, "ACTION", (Icallback)tgg1_cb); IupSetAttribute(tgg1, "VALUE", "ON"); f1 = IupFrame( IupVbox(boxdial1, tgg1, NULL) ); IupSetAttribute(f1, "TITLE", "Y Zoom"); /* X zooming */ dial2 = IupDial("HORIZONTAL"); lbl1 = IupLabel("-"); lbl2 = IupLabel("+"); boxinfo = IupHbox(lbl1, IupFill(), lbl2, NULL); boxdial2 = IupVbox(dial2, boxinfo, NULL); IupSetAttribute(boxdial2, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "64x16"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "HORIZONTAL"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial2, "ACTIVE", "NO"); IupSetAttribute(dial2, "SIZE", "64x16"); IupSetCallback(dial2, "BUTTON_PRESS_CB", (Icallback)dial2_btndown_cb); IupSetCallback(dial2, "MOUSEMOVE_CB", (Icallback)dial2_btnup_cb); IupSetCallback(dial2, "BUTTON_RELEASE_CB", (Icallback)dial2_btnup_cb); tgg2 = IupToggle("X Autoscale", NULL); IupSetCallback(tgg2, "ACTION", (Icallback)tgg2_cb); f2 = IupFrame( IupVbox(boxdial2, tgg2, NULL) ); IupSetAttribute(f2, "TITLE", "X Zoom"); lbl1 = IupLabel(""); IupSetAttribute(lbl1, "SEPARATOR", "HORIZONTAL"); tgg3 = IupToggle("Vertical Grid", NULL); IupSetCallback(tgg3, "ACTION", (Icallback)tgg3_cb); tgg4 = IupToggle("Horizontal Grid", NULL); IupSetCallback(tgg4, "ACTION", (Icallback)tgg4_cb); tgg6 = IupToggle("Box", NULL); IupSetCallback(tgg6, "ACTION", (Icallback)tgg6_cb); lbl2 = IupLabel(""); IupSetAttribute(lbl2, "SEPARATOR", "HORIZONTAL"); tgg5 = IupToggle("Legend", NULL); IupSetCallback(tgg5, "ACTION", (Icallback)tgg5_cb); lbl3 = IupLabel(""); IupSetAttribute(lbl3, "SEPARATOR", "HORIZONTAL"); bt1 = IupButton("Export", NULL); IupSetCallback(bt1, "ACTION", (Icallback)bt1_cb); vboxl = IupVbox(f1, f2, lbl1, tgg3, tgg4, tgg6, lbl2, tgg5, lbl3, bt1, NULL); IupSetAttribute(vboxl, "GAP", "4"); IupSetAttribute(vboxl, "EXPAND", "NO"); /* right panel: tabs with plots */ for (ii=0; ii<MAXPLOT; ii++) { vboxr[ii] = IupVbox(plot[ii], NULL); /* each plot a tab */ IupSetfAttribute(vboxr[ii], "TABTITLE", "Plot %d", ii); /* name each tab */ IupSetHandle(IupGetAttribute(vboxr[ii], "TABTITLE"), vboxr[ii]); } vboxr[MAXPLOT] = NULL; /* mark end of vector */ tabs = IupTabsv(vboxr); IupSetCallback(tabs, "TABCHANGE_CB", (Icallback)tabs_tabchange_cb); hbox = IupHbox(vboxl, tabs, NULL); IupSetAttribute(hbox, "MARGIN", "4x4"); IupSetAttribute(hbox, "GAP", "10"); dlg = IupDialog(hbox); IupSetAttribute(dlg, "TITLE", "IupMglPlot Example"); InitPlots(); /* It must be able to be done independent of dlg Mapping */ tabs_tabchange_cb(tabs, vboxr[0]); } IupSetAttribute(dlg, "SIZE", "300x"); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetAttribute(dlg, "SIZE", NULL); }