diff options
author | Siddhesh Wani | 2015-05-25 14:46:31 +0530 |
---|---|---|
committer | Siddhesh Wani | 2015-05-25 14:46:31 +0530 |
commit | 6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26 (patch) | |
tree | 1b7bd89fdcfd01715713d8a15db471dc75a96bbf /2.3-1/macros/sci2c_gui.sci | |
download | Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.gz Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.bz2 Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.zip |
Original Version
Diffstat (limited to '2.3-1/macros/sci2c_gui.sci')
-rw-r--r-- | 2.3-1/macros/sci2c_gui.sci | 421 |
1 files changed, 421 insertions, 0 deletions
diff --git a/2.3-1/macros/sci2c_gui.sci b/2.3-1/macros/sci2c_gui.sci new file mode 100644 index 00000000..c4ba0387 --- /dev/null +++ b/2.3-1/macros/sci2c_gui.sci @@ -0,0 +1,421 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Vincent COUVERT +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// + +function sci2c_gui() + +// Sizes +widgeth = 20; +widgetLabelWidth = 220; +btnh = 22; +btnw = 80; +defaultfont = "arial"; +margin = 13; +radiow = 85; + +// Figure creation +sci2cfig = figure("figure_name", gettext("Scilab to C conversion tool"),"tag","sci2cfig"); + +// Remove Scilab graphics menus & toolbar +delmenu(sci2cfig.figure_id, gettext("&File")); +delmenu(sci2cfig.figure_id, gettext("&Tools")); +delmenu(sci2cfig.figure_id, gettext("&Edit")); +delmenu(sci2cfig.figure_id, gettext("&?")); +toolbar(sci2cfig.figure_id, "off"); + +h = uimenu("parent", sci2cfig, "label", gettext("File")); +uimenu("parent", h, "label", gettext("Close"), "callback", "cb_sci2c_gui", "tag", "close_menu"); + +h = uimenu("parent", sci2cfig, "label", gettext("?")); +uimenu("parent", h, "label", gettext("Sci2c help page"), "callback", "cb_sci2c_gui", "tag", "sci2c_help_menu"); +uimenu("parent", h, "label", gettext("About SCI2C tools..."), "callback", "cb_sci2c_gui", "tag", "about_sci2c_menu"); + +figw = 800; +figh = 15*margin + btnh + 7*widgeth; +sci2cfig.axes_size = [figw figh]; +sci2cfig.auto_resize = "on"; +//sci2cfig.visible = "off"; // to be sure that no plot can appear in the window + +//------------------- +// --- Validation --- +//------------------- + +// Convert button +convertbtn = uicontrol("parent", sci2cfig,... + "backgroundcolor", [0.8 0.8 0.8],... + "style", "pushbutton",... + "string", gettext("Convert"),... + "position", [figw-2*margin-2*btnw margin btnw btnh],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "tag","convertbtn",... + "callback","cb_sci2c_gui"); + +// Cancel button +cancelbtn = uicontrol("parent", sci2cfig,... + "backgroundcolor", [0.8 0.8 0.8],... + "style", "pushbutton",... + "string", gettext("Cancel"),... + "position", [figw-margin-btnw margin btnw btnh],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "tag", "cancelbtn",... + "callback","cb_sci2c_gui"); + +//---------------- +// --- Options --- +//---------------- +// Frame +optframe = uicontrol("parent", sci2cfig,... + "relief", "groove",... + "style", "frame",... + "units", "pixels",... + "position", [margin 2*margin+btnh figw-2*margin 4*margin+4*widgeth],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "fontweight", "bold", ... + "horizontalalignment", "center"); +// Frame title +opttitle = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Options"),... + "units", "pixels",... + "position", [2*margin 2*margin+btnh+4*margin+4*widgeth-8 50 14],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 11,... + "horizontalalignment", "center"); + +// --- Building Tool --- +buildtooly = 2 * margin + 2 * btnh + margin; +buildtoollabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Tool to compile generated C code: "),... + "position",[2*margin buildtooly widgetLabelWidth widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12); +buildtoolradiowin = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("nmake for Windows with Visual Studio / Visual Express"),... + "position",[2*margin+widgetLabelWidth buildtooly 5 * radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "callback", "cb_sci2c_gui",... + "tag", "buildtoolradiowin"); +buildtoolradiounix = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("make for Unix / Windows with Cygwin"),... + "position",[2*margin+widgetLabelWidth buildtooly-widgeth 5 * radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "callback", "cb_sci2c_gui",... + "tag", "buildtoolradiounix"); +if getos() == "Windows" + set(buildtoolradiowin, "value", 1); + set(buildtoolradiounix, "value", 0); +else + set(buildtoolradiowin, "value", 0); + set(buildtoolradiounix, "value", 1); +end + +// --- Copy Scilab code into C option --- +sciintocy = buildtooly + margin + btnh ; +sciintoclabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Copy Scilab code into C: "),... + "position",[2*margin sciintocy widgetLabelWidth widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12); +sciintocradioyes = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("Yes"),... + "position",[2*margin+widgetLabelWidth sciintocy radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "value", 0,... + "callback", "cb_sci2c_gui",... + "tag", "sciintocradioyes"); +sciintocradiono = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("No"),... + "position",[2*margin+widgetLabelWidth+radiow sciintocy radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "value", 1,... + "callback", "cb_sci2c_gui",... + "tag", "sciintocradiono"); + +// --- Run mode option --- +runy = sciintocy + margin + widgeth; +runlabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Run mode: "),... + "position",[2*margin runy widgetLabelWidth widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12); +runradioall = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("All"),... + "position",[2*margin+widgetLabelWidth runy radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "value", 1,... + "callback", "cb_sci2c_gui",... + "tag", "runradioall"); +runradiotranslate = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("Translate"),... + "position",[2*margin+widgetLabelWidth+radiow runy radiow widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "value", 0,... + "callback", "cb_sci2c_gui",... + "tag", "runradiotranslate"); +runradiogenlib = uicontrol("parent", sci2cfig,... + "style", "radiobutton",... + "string", gettext("Generate library"),... + "position",[2*margin+widgetLabelWidth+2*radiow runy 120 widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "min", 0, ... + "max", 1, ... + "value", 0,... + "callback", "cb_sci2c_gui",... + "tag", "runradiogenlib"); + +// ------------------------ +// --- Output directory --- +// ------------------------ +// Frame +optframemaxy = 2*margin+btnh + 4*margin+4*widgeth; +outframe = uicontrol("parent", sci2cfig,... + "relief", "groove",... + "style", "frame",... + "units", "pixels",... + "position", [margin optframemaxy+margin figw-2*margin widgeth+2*margin],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "fontweight", "bold", ... + "horizontalalignment", "center"); +// Frame title +outtitle = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Output directory"),... + "units", "pixels",... + "position", [2*margin optframemaxy+margin+widgeth+2*margin-8 90 14],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 11,... + "horizontalalignment", "center"); +outlabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Directory name: "),... + "position",[2*margin optframemaxy+2*margin-1 100 widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12); +outedit = uicontrol("parent", sci2cfig,... + "style", "edit",... + "string", TMPDIR,... + "units", "pixels",... + "position",[3*margin+100 optframemaxy+2*margin-1 figw-6*margin-100-btnw widgeth],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12, ... + "tag", "outedit"); +outbtn = uicontrol("parent", sci2cfig,... + "backgroundcolor", [0.8 0.8 0.8],... + "style", "pushbutton",... + "string", gettext("Browse"),... + "position",[figw-2*margin-btnw optframemaxy+2*margin btnw btnh],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "callback", "cb_sci2c_gui",... + "tag", "outbtn"); + +// ------------------------------- +// --- SciLib main header file --- +// ------------------------------- +// Frame +outframemaxy = optframemaxy + 2*margin + widgeth + margin; +// headerframe = uicontrol("parent", sci2cfig,... +// "relief", "groove",... +// "style", "frame",... +// "units", "pixels",... +// "position", [margin outframemaxy+margin figw-2*margin widgeth+2*margin],... +// "fontname", defaultfont,... +// "fontunits", "points",... +// "fontsize", 12,... +// "fontweight", "bold", ... +// "horizontalalignment", "center"); +// // Frame title +// headertitle = uicontrol("parent", sci2cfig,... +// "style", "text",... +// "string", gettext("Scilab library header"),... +// "units", "pixels",... +// "position", [2*margin outframemaxy+margin+widgeth+2*margin-8 110 14],... +// "fontname", defaultfont,... +// "fontunits", "points",... +// "fontsize", 11,... +// "horizontalalignment", "center"); +// headerlabel = uicontrol("parent", sci2cfig,... +// "style", "text",... +// "string", gettext("File name: "),... +// "position",[2*margin outframemaxy+2*margin-1 100 widgeth],... +// "horizontalalignment", "left",... +// "fontname", defaultfont,... +// "fontunits", "points",... +// "fontsize", 12); +// headeredit = uicontrol("parent", sci2cfig,... +// "style", "edit",... +// "string", gettext("<enter a file name>"),... +// "units", "pixels",... +// "position",[3*margin+100 outframemaxy+2*margin-1 figw-6*margin-100-btnw widgeth],... +// "fontname", defaultfont,... +// "fontunits", "points",... +// "fontsize", 12, ... +// "tag", "headeredit"); +// headerbtn = uicontrol("parent", sci2cfig,... +// "backgroundcolor", [0.8 0.8 0.8],... +// "style", "pushbutton",... +// "string", gettext("Browse"),... +// "position",[figw-2*margin-btnw outframemaxy+2*margin btnw btnh],... +// "fontname", defaultfont,... +// "fontunits", "points",... +// "fontsize", 12,... +// "callback", "cb_sci2c_gui",... +// "tag", "headerbtn"); + +// ------------------------- +// --- File(s) selection --- +// ------------------------- +// Frame +headerframemaxy = outframemaxy //+ 2*margin + widgeth + margin; +selframe = uicontrol("parent", sci2cfig,... + "relief", "groove",... + "style", "frame",... + "units", "pixels",... + "position", [margin headerframemaxy+margin figw-2*margin 3*margin+2*widgeth],... + "fontname", "arial",... + "fontunits", "points",... + "fontsize", 12,... + "fontweight", "bold", ... + "horizontalalignment", "center"); +// Frame title +seltitle = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Input file"),... + "units", "pixels",... + "position", [2*margin headerframemaxy+margin+3*margin+2*widgeth-8 50 14],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 11,... + "horizontalalignment", "center", ... + "tag", "seltitle"); + +// --- Sub-functions selection --- +subfunslabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Sub-functions: "),... + "position",[2*margin headerframemaxy+2*margin-1 100 widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12); +subfunsedit = uicontrol("parent", sci2cfig,... + "style", "edit",... + "string", "",... + "units", "pixels",... + "position",[3*margin+100 headerframemaxy+2*margin-1 figw-6*margin-100-btnw widgeth],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12, ... + "tag", "subfunsedit"); +subfunsbtn = uicontrol("parent", sci2cfig,... + "backgroundcolor", [0.8 0.8 0.8],... + "style", "pushbutton",... + "string", gettext("Browse"),... + "position",[figw-2*margin-btnw headerframemaxy+2*margin btnw btnh],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "callback", "cb_sci2c_gui",... + "tag", "subfunsbtn"); + +// --- File selection --- +filelabel = uicontrol("parent", sci2cfig,... + "style", "text",... + "string", gettext("Main file name: "),... + "position",[2*margin headerframemaxy+3*margin-1+widgeth 100 widgeth],... + "horizontalalignment", "left",... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "tag", "filelabel"); + +fileedit = uicontrol("parent", sci2cfig,... + "style", "edit",... + "string", gettext("<enter a file name>"),... + "position",[3*margin+100 headerframemaxy+3*margin-1+widgeth figw-6*margin-100-btnw widgeth],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "tag", "fileedit"); + +filebtn = uicontrol("parent", sci2cfig,... + "backgroundcolor", [0.8 0.8 0.8],... + "style", "pushbutton",... + "string", gettext("Browse"),... + "position",[figw-2*margin-btnw headerframemaxy+3*margin+widgeth btnw btnh],... + "fontname", defaultfont,... + "fontunits", "points",... + "fontsize", 12,... + "callback", "cb_sci2c_gui",... + "tag", "filebtn"); + +endfunction |