summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatsuDrag92018-06-28 19:36:54 +0530
committerGitHub2018-06-28 19:36:54 +0530
commitd1a10c4a51f5ebc5fe2c9b2a39856e5cd1fb0e7f (patch)
treeef616ca18044c1c0794a66c10f55a8388388049e
parentf573d931f1777e47e8ad5e5415b7170dfa0af579 (diff)
parent3e7b5fcf5d796ad852723686352e2a6410684a7f (diff)
downloadLDMicroGtk-d1a10c4a51f5ebc5fe2c9b2a39856e5cd1fb0e7f.tar.gz
LDMicroGtk-d1a10c4a51f5ebc5fe2c9b2a39856e5cd1fb0e7f.tar.bz2
LDMicroGtk-d1a10c4a51f5ebc5fe2c9b2a39856e5cd1fb0e7f.zip
Merge pull request #20 from akshay-c/master
Merging with master
-rw-r--r--README.md49
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h11
-rw-r--r--ldmicro/reg/t.pl205
-rw-r--r--ldmicro/schematic.cpp36
-rw-r--r--ldmicro/simpledialog.cpp1022
5 files changed, 712 insertions, 611 deletions
diff --git a/README.md b/README.md
index 38e0436..0f0b022 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,36 @@
+# About LDMicro
+LDmicro is a ladder logic editor, simulator and compiler for 8-bit microcontrollers. It can generate native code for Atmel AVR and Microchip PIC16 CPUs from a ladder diagram.
+
# LDMicro for Linux
-This is a linux compatible version of the original LDMicro program.
+This is a Linux compatible version of the original LDMicro program for windows created by Jonathan Westhues, and proted to Linux under [FOSSEE](https://github.com/FOSSEE) fellowship program 2018 by [Ramana R](https://github.com/Rr42) and [Rohit I](https://github.com/NatsuDrag9), under the mentorship of [Akshay C](https://github.com/akshay-c).
+
+GitHub repository of LDMicro for windows can be found [here](https://github.com/akshay-c/LDmicro).
+
+# Instructions
+Before modifying contents of this git account, kindly make sure that you do not add unnecessary files that are created during the make process. In order to do so ensure that you add appropriate command to the makefile and execute "make clean" script before uploading your changes to git.
+
+# Building LDMicro for Linux
+LDmicro for Linux is built using MinGW C++ compiler.
+
+### Building the Makefile
+In order to generate the Makefile that can be used to compile the project, simply run the following commands from a terminal in the project directory:
+```
+cd /LDmicro/
+mkdir build
+cd build/
+cmake ..
+```
-GitHub repository of LDMicro for windows can be found [here](https://github.com/akshay-c/LDmicro)
+### Building LDMicro for Linux
+Simply run `make` in the build directory of the project to compile.
+
+_Note_: In order to compile the Makefile must first be generated (see [Building the Makefile](#building-the-makefile)).
+
+Multiple Perl Scripts are executed during the build phase. In order to execute these scripts, you need perl. This project uses ActivePerl Community Edition, which can be obtained from the following website:
+
+http://www.activestate.com/activeperl
+
+or install the perl packages from the terminal (see [External package dependencies](#external-package-dependencies)).
## External package dependencies
The install commands for all the packages required to compile LDMicro for Linux are given below:
@@ -17,19 +46,9 @@ _Note_: Be sure to run `sudo apt-get update` and `sudo apt-get upgrade` before r
```
* Perl: `sudo apt-get install perl`
-## LDMicro for Linux can be compiled and run using the following commands
-### To cmpile using cmake use the following commands
-```
-cd /LDmicro/
-mkdir build
-cd build/
-cmake ..
-make
-```
-### To run program in linux use the following command
-
-# To run program in shell mode use the below command
+## Running and testing LDMicro for Linux
+### To run program in shell mode use the below command
`./LDmicro /c <.ld file to compile> <.hex destination file>`
-# To run program in GUI mode use the below command
+### To run program in GUI mode use the below command
`sudo ./LDMicro`
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index ce0b812..c9379c2 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -198,6 +198,17 @@ typedef struct _RECT {
LONG bottom;
} RECT, *PRECT;
+typedef struct SimpleDialogDataTag {
+ UINT uflag;
+ int boxes;
+ char **dests;
+ char *str1;
+ char *str2;
+ char *str3;
+ int *num1;
+ int *num2;
+} SimpleDialogData;
+
/// Variables
extern std::vector<HEAPRECORD> HeapRecord;
diff --git a/ldmicro/reg/t.pl b/ldmicro/reg/t.pl
deleted file mode 100644
index b388e96..0000000
--- a/ldmicro/reg/t.pl
+++ /dev/null
@@ -1,205 +0,0 @@
- 0:set bit '$mcr'
- 1:#
- 2:# start rung 2
- 3:let bit '$rung_top' := '$mcr'
- 4:
- 5:# start series [
- 6:if not 'Rosc' {
- 7: clear bit '$rung_top'
- 8:}
- 9:
- 10:if not '$Tof_antiglitch' {
- 11: let var 'Tof' := 9
- 12:}
- 13:set bit '$Tof_antiglitch'
- 14:if not '$rung_top' {
- 15: if 'Tof' < 9 {
- 16: increment 'Tof'
- 17: set bit '$rung_top'
- 18: }
- 19:} else {
- 20: let var 'Tof' := 0
- 21:}
- 22:
- 23:if '$rung_top' {
- 24: if 'Ton' < 9 {
- 25: increment 'Ton'
- 26: clear bit '$rung_top'
- 27: }
- 28:} else {
- 29: let var 'Ton' := 0
- 30:}
- 31:
- 32:if '$rung_top' {
- 33: clear bit 'Rosc'
- 34:} else {
- 35: set bit 'Rosc'
- 36:}
- 37:
- 38:# ] finish series
- 39:#
- 40:# start rung 3
- 41:let bit '$rung_top' := '$mcr'
- 42:
- 43:# start series [
- 44:if not 'Rosc' {
- 45: clear bit '$rung_top'
- 46:}
- 47:
- 48:if not 'Xup' {
- 49: clear bit '$rung_top'
- 50:}
- 51:
- 52:if '$rung_top' {
- 53: if not '$oneShot_0000' {
- 54: increment 'Ccnt'
- 55: }
- 56:}
- 57:let bit '$oneShot_0000' := '$rung_top'
- 58:if 'Ccnt' < 20 {
- 59: clear bit '$rung_top'
- 60:} else {
- 61: set bit '$rung_top'
- 62:}
- 63:
- 64:if 'Trto' < 999 {
- 65: if '$rung_top' {
- 66: increment 'Trto'
- 67: }
- 68: clear bit '$rung_top'
- 69:} else {
- 70: set bit '$rung_top'
- 71:}
- 72:
- 73:let bit 'Yup' := '$rung_top'
- 74:
- 75:# ] finish series
- 76:#
- 77:# start rung 4
- 78:let bit '$rung_top' := '$mcr'
- 79:
- 80:# start series [
- 81:if not 'Rosc' {
- 82: clear bit '$rung_top'
- 83:}
- 84:
- 85:if not 'Xdown' {
- 86: clear bit '$rung_top'
- 87:}
- 88:
- 89:if '$rung_top' {
- 90: if not '$oneShot_0001' {
- 91: let var '$scratch' := 1
- 92: let var 'Ccnt' := 'Ccnt' - '$scratch'
- 93: }
- 94:}
- 95:let bit '$oneShot_0001' := '$rung_top'
- 96:if 'Ccnt' < 10 {
- 97: clear bit '$rung_top'
- 98:} else {
- 99: set bit '$rung_top'
-100:}
-101:
-102:let bit 'Ydown' := '$rung_top'
-103:
-104:# ] finish series
-105:#
-106:# start rung 5
-107:let bit '$rung_top' := '$mcr'
-108:
-109:# start series [
-110:if not 'Xres' {
-111: clear bit '$rung_top'
-112:}
-113:
-114:# start parallel [
-115:clear bit '$parOut_0000'
-116:let bit '$parThis_0000' := '$rung_top'
-117:let bit '$scratch' := '$parThis_0000'
-118:if '$oneShot_0002' {
-119: clear bit '$parThis_0000'
-120:}
-121:let bit '$oneShot_0002' := '$scratch'
-122:
-123:if '$parThis_0000' {
-124: set bit '$parOut_0000'
-125:}
-126:let bit '$parThis_0000' := '$rung_top'
-127:let bit '$scratch' := '$parThis_0000'
-128:if not '$parThis_0000' {
-129: if '$oneShot_0003' {
-130: set bit '$parThis_0000'
-131: }
-132:} else {
-133: clear bit '$parThis_0000'
-134:}
-135:let bit '$oneShot_0003' := '$scratch'
-136:
-137:if '$parThis_0000' {
-138: set bit '$parOut_0000'
-139:}
-140:let bit '$rung_top' := '$parOut_0000'
-141:# ] finish parallel
-142:if '$rung_top' {
-143: let var 'Trto' := 0
-144:}
-145:
-146:# ] finish series
-147:#
-148:# start rung 6
-149:let bit '$rung_top' := '$mcr'
-150:
-151:# start series [
-152:if not 'Rosc' {
-153: clear bit '$rung_top'
-154:}
-155:
-156:if '$rung_top' {
-157: if not '$oneShot_0004' {
-158: increment 'Ccirc'
-159: if 'Ccirc' < 8 {
-160: } else {
-161: let var 'Ccirc' := 0
-162: }
-163: }
-164:}
-165:let bit '$oneShot_0004' := '$rung_top'
-166:
-167:# ] finish series
-168:#
-169:# start rung 7
-170:let bit '$rung_top' := '$mcr'
-171:
-172:# start series [
-173:let var '$scratch2' := 3
-174:if 'Ccirc' == '$scratch2' {
-175:} else {
-176: clear bit '$rung_top'
-177:}
-178:
-179:let bit '$scratch' := '$rung_top'
-180:if not '$rung_top' {
-181: if '$oneShot_0005' {
-182: set bit '$rung_top'
-183: }
-184:} else {
-185: clear bit '$rung_top'
-186:}
-187:let bit '$oneShot_0005' := '$scratch'
-188:
-189:if not '$Tpulse_antiglitch' {
-190: let var 'Tpulse' := 19
-191:}
-192:set bit '$Tpulse_antiglitch'
-193:if not '$rung_top' {
-194: if 'Tpulse' < 19 {
-195: increment 'Tpulse'
-196: set bit '$rung_top'
-197: }
-198:} else {
-199: let var 'Tpulse' := 0
-200:}
-201:
-202:let bit 'Ypulse' := '$rung_top'
-203:
-204:# ] finish series
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index 8a6fa04..661f841 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -422,15 +422,15 @@ void EditSelectedElement(void)
case ELEM_TON:
case ELEM_TOF:
case ELEM_RTO:
- // ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay),
- // Selected->d.timer.name);
+ ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay),
+ Selected->d.timer.name);
break;
case ELEM_CTU:
case ELEM_CTD:
case ELEM_CTC:
- // ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max),
- // Selected->d.counter.name);
+ ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max),
+ Selected->d.counter.name);
break;
case ELEM_EQU:
@@ -439,16 +439,16 @@ void EditSelectedElement(void)
case ELEM_GEQ:
case ELEM_LES:
case ELEM_LEQ:
- // ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1,
- // Selected->d.cmp.op2);
+ ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1,
+ Selected->d.cmp.op2);
break;
case ELEM_ADD:
case ELEM_SUB:
case ELEM_MUL:
case ELEM_DIV:
- // ShowMathDialog(SelectedWhich, Selected->d.math.dest,
- // Selected->d.math.op1, Selected->d.math.op2);
+ ShowMathDialog(SelectedWhich, Selected->d.math.dest,
+ Selected->d.math.op1, Selected->d.math.op2);
break;
case ELEM_RES:
@@ -456,35 +456,35 @@ void EditSelectedElement(void)
break;
case ELEM_MOVE:
- // ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src);
+ ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src);
break;
case ELEM_SET_PWM:
- // ShowSetPwmDialog(Selected->d.setPwm.name,
- // &(Selected->d.setPwm.targetFreq));
+ ShowSetPwmDialog(Selected->d.setPwm.name,
+ &(Selected->d.setPwm.targetFreq));
break;
case ELEM_READ_ADC:
- // ShowReadAdcDialog(Selected->d.readAdc.name+1);
+ ShowReadAdcDialog(Selected->d.readAdc.name+1);
break;
case ELEM_UART_RECV:
case ELEM_UART_SEND:
- // ShowUartDialog(SelectedWhich, Selected->d.uart.name);
+ ShowUartDialog(SelectedWhich, Selected->d.uart.name);
break;
case ELEM_PERSIST:
- // ShowPersistDialog(Selected->d.persist.var);
+ ShowPersistDialog(Selected->d.persist.var);
break;
case ELEM_SHIFT_REGISTER:
- // ShowShiftRegisterDialog(Selected->d.shiftRegister.name,
- // &(Selected->d.shiftRegister.stages));
+ ShowShiftRegisterDialog(Selected->d.shiftRegister.name,
+ &(Selected->d.shiftRegister.stages));
break;
case ELEM_FORMATTED_STRING:
- // ShowFormattedStringDialog(Selected->d.fmtdStr.var,
- // Selected->d.fmtdStr.string);
+ ShowFormattedStringDialog(Selected->d.fmtdStr.var,
+ Selected->d.fmtdStr.string);
break;
case ELEM_PIECEWISE_LINEAR:
diff --git a/ldmicro/simpledialog.cpp b/ldmicro/simpledialog.cpp
index 14aab25..0d63a22 100644
--- a/ldmicro/simpledialog.cpp
+++ b/ldmicro/simpledialog.cpp
@@ -29,394 +29,670 @@
#include "ldmicro.h"
-static HWND SimpleDialog;
+static HWID SimpleDialog;
+static HWID OkButton;
+static HWID CancelButton;
#define MAX_BOXES 5
-static HWND Textboxes[MAX_BOXES];
-static HWND Labels[MAX_BOXES];
+static HWID Textboxes[MAX_BOXES];
+static HWID Labels[MAX_BOXES];
static LONG_PTR PrevAlnumOnlyProc[MAX_BOXES];
static LONG_PTR PrevNumOnlyProc[MAX_BOXES];
static BOOL NoCheckingOnBox[MAX_BOXES];
+static BOOL SIMPLE_DIALOG_ACTIVE = FALSE;
+
+static SimpleDialogData SDdata;
+
+/// Simple dialog data flags
+#define SD_TIMER 0x0000001
+#define SD_COUNTER 0x0000002
+#define SD_CMP 0x0000003
+#define SD_MOVE 0x0000004
+#define SD_READ_ADC 0x0000005
+#define SD_SET_PWM 0x0000006
+#define SD_UART 0x0000007
+#define SD_MATH 0x0000008
+#define SD_SHIFT_REGISTER 0x0000009
+#define SD_FORMATTED_STRING 0x0000010
+#define SD_PERSIST 0x0000011
+
//-----------------------------------------------------------------------------
// Don't allow any characters other than -A-Za-z0-9_ in the box.
//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK MyAlnumOnlyProc(HWND hwnd, UINT msg, WPARAM wParam,
-// LPARAM lParam)
-// {
-// if(msg == WM_CHAR) {
-// if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
-// wParam == '\b' || wParam == '-' || wParam == '\''))
-// {
-// return 0;
-// }
-// }
-
-// int i;
-// for(i = 0; i < MAX_BOXES; i++) {
-// if(hwnd == Textboxes[i]) {
-// return CallWindowProc((WNDPROC)PrevAlnumOnlyProc[i], hwnd, msg,
-// wParam, lParam);
-// }
-// }
-// oops();
-// }
+static void MyAlnumOnlyProc (GtkEditable *editable, gchar *NewText, gint length,
+ gint *position, gpointer data)
+{
+ for (int i = 0; i < length; i++)
+ {
+ if (!(isalpha (NewText[i]) || NewText[i] == '_' || isdigit (NewText[i]) ||
+ NewText[i] == '\b' || NewText[i] == '\'' || NewText[i] == '-'))
+ {
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
+ return;
+ }
+ }
+ // if(msg == WM_CHAR) {
+ // if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
+ // wParam == '\b' || wParam == '-' || wParam == '\''))
+ // {
+ // return 0;
+ // }
+ // }
+
+ // int i;
+ // for(i = 0; i < MAX_BOXES; i++) {
+ // if(hwnd == Textboxes[i]) {
+ // return CallWindowProc((WNDPROC)PrevAlnumOnlyProc[i], hwnd, msg,
+ // wParam, lParam);
+ // }
+ // }
+ // oops();
+}
//-----------------------------------------------------------------------------
// Don't allow any characters other than -0-9. in the box.
//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK MyNumOnlyProc(HWND hwnd, UINT msg, WPARAM wParam,
-// LPARAM lParam)
-// {
-// if(msg == WM_CHAR) {
-// if(!(isdigit(wParam) || wParam == '.' || wParam == '\b'
-// || wParam == '-'))
-// {
-// return 0;
-// }
-// }
-
-// int i;
-// for(i = 0; i < MAX_BOXES; i++) {
-// if(hwnd == Textboxes[i]) {
-// return CallWindowProc((WNDPROC)PrevNumOnlyProc[i], hwnd, msg,
-// wParam, lParam);
-// }
-// }
-// oops();
-// }
-
-// static void MakeControls(int boxes, char **labels, DWORD fixedFontMask)
-// {
-// int i;
-// HDC hdc = GetDC(SimpleDialog);
-// SelectObject(hdc, MyNiceFont);
-
-// SIZE si;
-
-// int maxLen = 0;
-// for(i = 0; i < boxes; i++) {
-// GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
-// if(si.cx > maxLen) maxLen = si.cx;
-// }
-
-// int adj;
-// if(maxLen > 70) {
-// adj = maxLen - 70;
-// } else {
-// adj = 0;
-// }
-
-// for(i = 0; i < boxes; i++) {
-// GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
-
-// Labels[i] = CreateWindowEx(0, WC_STATIC, labels[i],
-// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
-// (80 + adj) - si.cx - 4, 13 + i*30, si.cx, 21,
-// SimpleDialog, NULL, Instance, NULL);
-// NiceFont(Labels[i]);
-
-// Textboxes[i] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
-// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS |
-// WS_VISIBLE,
-// 80 + adj, 12 + 30*i, 120 - adj, 21,
-// SimpleDialog, NULL, Instance, NULL);
-
-// if(fixedFontMask & (1 << i)) {
-// FixedFont(Textboxes[i]);
-// } else {
-// NiceFont(Textboxes[i]);
-// }
-// }
-// ReleaseDC(SimpleDialog, hdc);
-
-// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
-// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
-// 218, 11, 70, 23, SimpleDialog, NULL, Instance, NULL);
-// NiceFont(OkButton);
-
-// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
-// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 218, 41, 70, 23, SimpleDialog, NULL, Instance, NULL);
-// NiceFont(CancelButton);
-// }
-
-// BOOL ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask,
-// DWORD alnumOnlyMask, DWORD fixedFontMask, char **dests)
-// {
-// BOOL didCancel;
-
-// if(boxes > MAX_BOXES) oops();
-
-// SimpleDialog = CreateWindowClient(0, "LDmicroDialog", title,
-// WS_OVERLAPPED | WS_SYSMENU,
-// 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), NULL, NULL,
-// Instance, NULL);
-
-// MakeControls(boxes, labels, fixedFontMask);
+static void MyNumOnlyProc (GtkEditable *editable, gchar *NewText, gint length,
+ gint *position, gpointer data)
+{
+ for (int i = 0; i < length; i++)
+ {
+ if (!(isdigit (NewText[i]) || NewText[i] == '\b' ||
+ NewText[i] == '.' || NewText[i] == '-'))
+ {
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
+ return;
+ }
+ }
+ // if(msg == WM_CHAR) {
+ // if(!(isdigit(wParam) || wParam == '.' || wParam == '\b'
+ // || wParam == '-'))
+ // {
+ // return 0;
+ // }
+ // }
+
+ // int i;
+ // for(i = 0; i < MAX_BOXES; i++) {
+ // if(hwnd == Textboxes[i]) {
+ // return CallWindowProc((WNDPROC)PrevNumOnlyProc[i], hwnd, msg,
+ // wParam, lParam);
+ // }
+ // }
+ // oops();
+}
+
+static void MakeControls(int boxes, char **labels, DWORD fixedFontMask)
+{
+ int i;
+ // HDC hdc = GetDC(SimpleDialog);
+ // SelectObject(hdc, MyNiceFont);
+
+ // SIZE si;
+
+ // int maxLen = 0;
+ // for(i = 0; i < boxes; i++) {
+ // GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
+ // if(si.cx > maxLen) maxLen = si.cx;
+ // }
+
+ // int adj;
+ // if(maxLen > 70) {
+ // adj = maxLen - 70;
+ // } else {
+ // adj = 0;
+ // }
+ HWID grid = gtk_grid_new();
+
+ for(i = 0; i < boxes; i++) {
+ // GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
+
+ Labels[i] = gtk_label_new (labels[i]);
+ // CreateWindowEx(0, WC_STATIC, labels[i],
+ // WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
+ // (80 + adj) - si.cx - 4, 13 + i*30, si.cx, 21,
+ // SimpleDialog, NULL, Instance, NULL);
+ NiceFont(Labels[i]);
+ gtk_grid_attach (GTK_GRID (grid), Labels[i], 0, i, 1, 1);
+
+ Textboxes[i] = gtk_entry_new ();
+ // CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
+ // WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS |
+ // WS_VISIBLE,
+ // 80 + adj, 12 + 30*i, 120 - adj, 21,
+ // SimpleDialog, NULL, Instance, NULL);
+
+ if(fixedFontMask & (1 << i)) {
+ FixedFont(Textboxes[i]);
+ } else {
+ NiceFont(Textboxes[i]);
+ }
+ gtk_grid_attach (GTK_GRID (grid), Textboxes[i], 1, i, 1, 1);
+ }
+ // ReleaseDC(SimpleDialog, hdc);
+
+ OkButton = gtk_button_new_with_label (_("OK"));
+ // CreateWindowEx(0, WC_BUTTON, _("OK"),
+ // WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
+ // 218, 11, 70, 23, SimpleDialog, NULL, Instance, NULL);
+ NiceFont(OkButton);
+ gtk_grid_attach (GTK_GRID (grid), OkButton, 2, 0, 1, 1);
+
+ CancelButton = gtk_button_new_with_label(_("Cancel"));
+ // CreateWindowEx(0, WC_BUTTON, _("Cancel"),
+ // WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
+ // 218, 41, 70, 23, SimpleDialog, NULL, Instance, NULL);
+ NiceFont(CancelButton);
+ gtk_grid_attach (GTK_GRID (grid), CancelButton, 2, 1, 1, 1);
+ gtk_container_add(GTK_CONTAINER(SimpleDialog), grid);
+}
+
+void SimpleDialogWrapUp()
+{
+ // if(!didCancel)
+ for(int i = 0; i < SDdata.boxes; i++) {
+ if(NoCheckingOnBox[i]) {
+ // char get[64];
+ // SendMessage(Textboxes[i], WM_GETTEXT, 60, (LPARAM)get);
+ char *get = (char*)gtk_entry_get_text (GTK_ENTRY(Textboxes[i]));
+ strcpy(SDdata.dests[i], get);
+ if (strlen(get) < 60)
+ strcpy(SDdata.dests[i], get);
+ else
+ {
+ strncpy(SDdata.dests[i], get, 60);
+ SDdata.dests[i][60] = '\0';
+ }
+ } else {
+ char get[20];
+ // SendMessage(Textboxes[i], WM_GETTEXT, 15, (LPARAM)get);
+ char *str = (char*)gtk_entry_get_text (GTK_ENTRY(Textboxes[i]));
+ strcpy(get, str);
+ if (strlen(str) < 15)
+ strcpy(get, str);
+ else
+ {
+ strncpy(get, str, 15);
+ get[15] = '\0';
+ }
+
+ if( (!strchr(get, '\'')) ||
+ (get[0] == '\'' && get[2] == '\'' && strlen(get)==3) )
+ {
+ if(strlen(get) == 0) {
+ Error(_("Empty textbox; not permitted."));
+ } else {
+ strcpy(SDdata.dests[i], get);
+ }
+ } else {
+ Error(_("Bad use of quotes: <%s>"), get);
+ }
+ }
+ }
+
+ switch(SDdata.uflag)
+ {
+ case SD_TIMER:
+ {
+ SDdata.str1[0] = 'T';
+ strcpy(SDdata.str1+1, SDdata.dests[0]);
+ g_print("%s, %s\n", SDdata.str1, SDdata.dests[0]);
+ double del = atof(SDdata.dests[1]);
+ if(del > 2140000) { // 2**31/1000, don't overflow signed int
+ Error(_("Delay too long; maximum is 2**31 us."));
+ } else if(del <= 0) {
+ Error(_("Delay cannot be zero or negative."));
+ } else {
+ *SDdata.num1 = (int)(1000*del + 0.5);
+ }
+ break;
+ }
+ case SD_COUNTER:
+ {
+ *SDdata.num1 = atoi(SDdata.dests[1]);
+ break;
+ }
+ case SD_CMP:
+ {
+ break;
+ }
+ case SD_MOVE:
+ {
+ break;
+ }
+ case SD_READ_ADC:
+ {
+ break;
+ }
+ case SD_SET_PWM:
+ {
+ *SDdata.num1 = atoi(SDdata.dests[1]);
+ break;
+ }
+ case SD_UART:
+ {
+ break;
+ }
+ case SD_MATH:
+ {
+ break;
+ }
+ case SD_SHIFT_REGISTER:
+ {
+ *SDdata.num1 = atoi(SDdata.dests[1]);
+
+ if(*SDdata.num1 <= 0 || *SDdata.num1 >= 200)
+ {
+ Error(_("Not a reasonable size for a shift register."));
+ *SDdata.num1 = 1;
+ }
+ break;
+ }
+ case SD_FORMATTED_STRING:
+ {
+ break;
+ }
+ case SD_PERSIST:
+ {
+ break;
+ }
+ }
+
+ DestroyWindow(SimpleDialog);
+ SIMPLE_DIALOG_ACTIVE = FALSE;
+}
+
+void SimpleDialogCancelProc()
+{
+ DestroyWindow(SimpleDialog);
+ SIMPLE_DIALOG_ACTIVE = FALSE;
+}
+
+static gboolean SimpleDialogKeyPressProc(HWID widget, GdkEventKey* event, gpointer data)
+{
+ if(event -> keyval == GDK_KEY_Return)
+ {
+ // DialogDone = TRUE;
+ SimpleDialogWrapUp();
+ } else if(event -> keyval == GDK_KEY_Escape)
+ {
+ // DialogDone = TRUE;
+ // DialogCancel = TRUE;
+ SimpleDialogCancelProc();
+ }
+
+ return FALSE;
+}
+
+void ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask,
+ DWORD alnumOnlyMask, DWORD fixedFontMask, char **dests)
+{
+ if(SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SIMPLE_DIALOG_ACTIVE = TRUE;
+
+ BOOL didCancel = FALSE;
+
+ if(boxes > MAX_BOXES) oops();
+
+ SimpleDialog = CreateWindowClient(GTK_WINDOW_TOPLEVEL, GDK_WINDOW_TYPE_HINT_NORMAL,
+ title, 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), GTK_WINDOW(MainWindow) );
+ // CreateWindowClient(0, "LDmicroDialog", title,
+ // WS_OVERLAPPED | WS_SYSMENU,
+ // 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), NULL, NULL,
+ // Instance, NULL);
+
+ MakeControls(boxes, labels, fixedFontMask);
-// int i;
-// for(i = 0; i < boxes; i++) {
-// SendMessage(Textboxes[i], WM_SETTEXT, 0, (LPARAM)dests[i]);
-
-// if(numOnlyMask & (1 << i)) {
-// PrevNumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
-// (LONG_PTR)MyNumOnlyProc);
-// }
-// if(alnumOnlyMask & (1 << i)) {
-// PrevAlnumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
-// (LONG_PTR)MyAlnumOnlyProc);
-// }
-// }
-
-// EnableWindow(MainWindow, FALSE);
-// ShowWindow(SimpleDialog, TRUE);
-// SetFocus(Textboxes[0]);
-// SendMessage(Textboxes[0], EM_SETSEL, 0, -1);
-
-// MSG msg;
-// DWORD ret;
-// DialogDone = FALSE;
-// DialogCancel = FALSE;
-// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
-// if(msg.message == WM_KEYDOWN) {
-// if(msg.wParam == VK_RETURN) {
-// DialogDone = TRUE;
-// break;
-// } else if(msg.wParam == VK_ESCAPE) {
-// DialogDone = TRUE;
-// DialogCancel = TRUE;
-// break;
-// }
-// }
-
-// if(IsDialogMessage(SimpleDialog, &msg)) continue;
-// TranslateMessage(&msg);
-// DispatchMessage(&msg);
-// }
-
-// didCancel = DialogCancel;
-
-// if(!didCancel) {
-// for(i = 0; i < boxes; i++) {
-// if(NoCheckingOnBox[i]) {
-// char get[64];
-// SendMessage(Textboxes[i], WM_GETTEXT, 60, (LPARAM)get);
-// strcpy(dests[i], get);
-// } else {
-// char get[20];
-// SendMessage(Textboxes[i], WM_GETTEXT, 15, (LPARAM)get);
-
-// if( (!strchr(get, '\'')) ||
-// (get[0] == '\'' && get[2] == '\'' && strlen(get)==3) )
-// {
-// if(strlen(get) == 0) {
-// Error(_("Empty textbox; not permitted."));
-// } else {
-// strcpy(dests[i], get);
-// }
-// } else {
-// Error(_("Bad use of quotes: <%s>"), get);
-// }
-// }
-// }
-// }
-
-// EnableWindow(MainWindow, TRUE);
-// DestroyWindow(SimpleDialog);
-
-// return !didCancel;
-// }
-
-// void ShowTimerDialog(int which, int *delay, char *name)
-// {
-// char *s;
-// switch(which) {
-// case ELEM_TON: s = _("Turn-On Delay"); break;
-// case ELEM_TOF: s = _("Turn-Off Delay"); break;
-// case ELEM_RTO: s = _("Retentive Turn-On Delay"); break;
-// default: oops(); break;
-// }
+ int i;
+ for(i = 0; i < boxes; i++)
+ {
+ // SendMessage(Textboxes[i], WM_SETTEXT, 0, (LPARAM)dests[i]);
+ gtk_entry_set_text (GTK_ENTRY(Textboxes[i]), dests[i]);
+
+ if(numOnlyMask & (1 << i))
+ {
+ g_signal_connect (G_OBJECT(Textboxes[i]), "insert-text",
+ G_CALLBACK(MyNumOnlyProc), NULL);
+ // PrevNumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
+ // (LONG_PTR)MyNumOnlyProc);
+ } else if(alnumOnlyMask & (1 << i))
+ {
+ g_signal_connect (G_OBJECT(Textboxes[i]), "insert-text",
+ G_CALLBACK(MyAlnumOnlyProc), NULL);
+ // PrevAlnumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
+ // (LONG_PTR)MyAlnumOnlyProc);
+ }
+ }
+
+ g_signal_connect (CancelButton, "clicked", G_CALLBACK (SimpleDialogCancelProc), NULL);
+ g_signal_connect (OkButton, "clicked", G_CALLBACK (SimpleDialogWrapUp), NULL);
+ g_signal_connect (SimpleDialog, "key_press_event", G_CALLBACK (SimpleDialogKeyPressProc), NULL);
+
+ // EnableWindow(MainWindow, FALSE);
+ // ShowWindow(SimpleDialog, TRUE);
+ gtk_widget_show_all(SimpleDialog);
+ // SetFocus(Textboxes[0]);
+ // SendMessage(Textboxes[0], EM_SETSEL, 0, -1);
+
+ // MSG msg;
+ // DWORD ret;
+ // DialogDone = FALSE;
+ // DialogCancel = FALSE;
+ // while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
+ // if(msg.message == WM_KEYDOWN) {
+ // if(msg.wParam == VK_RETURN) {
+ // DialogDone = TRUE;
+ // break;
+ // } else if(msg.wParam == VK_ESCAPE) {
+ // DialogDone = TRUE;
+ // DialogCancel = TRUE;
+ // break;
+ // }
+ // }
+
+ // if(IsDialogMessage(SimpleDialog, &msg)) continue;
+ // TranslateMessage(&msg);
+ // DispatchMessage(&msg);
+ // }
+
+ // didCancel = DialogCancel;
+
+
+
+ // EnableWindow(MainWindow, TRUE);
+ // DestroyWindow(SimpleDialog);
+
+ // return !didCancel;
+}
+
+void ShowTimerDialog(int which, int *delay, char *name)
+{
+ char *s;
+ switch(which) {
+ case ELEM_TON: s = _("Turn-On Delay"); break;
+ case ELEM_TOF: s = _("Turn-Off Delay"); break;
+ case ELEM_RTO: s = _("Retentive Turn-On Delay"); break;
+ default: oops(); break;
+ }
-// char *labels[] = { _("Name:"), _("Delay (ms):") };
-
-// char delBuf[16];
-// char nameBuf[16];
-// sprintf(delBuf, "%.3f", (*delay / 1000.0));
-// strcpy(nameBuf, name+1);
-// char *dests[] = { nameBuf, delBuf };
-
-// if(ShowSimpleDialog(s, 2, labels, (1 << 1), (1 << 0), (1 << 0), dests)) {
-// name[0] = 'T';
-// strcpy(name+1, nameBuf);
-// double del = atof(delBuf);
-// if(del > 2140000) { // 2**31/1000, don't overflow signed int
-// Error(_("Delay too long; maximum is 2**31 us."));
-// } else if(del <= 0) {
-// Error(_("Delay cannot be zero or negative."));
-// } else {
-// *delay = (int)(1000*del + 0.5);
-// }
-// }
-// }
-
-// void ShowCounterDialog(int which, int *maxV, char *name)
-// {
-// char *title;
-
-// switch(which) {
-// case ELEM_CTU: title = _("Count Up"); break;
-// case ELEM_CTD: title = _("Count Down"); break;
-// case ELEM_CTC: title = _("Circular Counter"); break;
-
-// default: oops();
-// }
-
-// char *labels[] = { _("Name:"), (which == ELEM_CTC ? _("Max value:") :
-// _("True if >= :")) };
-// char maxS[128];
-// sprintf(maxS, "%d", *maxV);
-// char *dests[] = { name+1, maxS };
-// ShowSimpleDialog(title, 2, labels, 0x2, 0x1, 0x1, dests);
-// *maxV = atoi(maxS);
-// }
-
-// void ShowCmpDialog(int which, char *op1, char *op2)
-// {
-// char *title;
-// char *l2;
-// switch(which) {
-// case ELEM_EQU:
-// title = _("If Equals");
-// l2 = "= :";
-// break;
-
-// case ELEM_NEQ:
-// title = _("If Not Equals");
-// l2 = "/= :";
-// break;
-
-// case ELEM_GRT:
-// title = _("If Greater Than");
-// l2 = "> :";
-// break;
-
-// case ELEM_GEQ:
-// title = _("If Greater Than or Equal To");
-// l2 = ">= :";
-// break;
-
-// case ELEM_LES:
-// title = _("If Less Than");
-// l2 = "< :";
-// break;
-
-// case ELEM_LEQ:
-// title = _("If Less Than or Equal To");
-// l2 = "<= :";
-// break;
-
-// default:
-// oops();
-// }
-// char *labels[] = { _("'Closed' if:"), l2 };
-// char *dests[] = { op1, op2 };
-// ShowSimpleDialog(title, 2, labels, 0, 0x3, 0x3, dests);
-// }
-
-// void ShowMoveDialog(char *dest, char *src)
-// {
-// char *labels[] = { _("Destination:"), _("Source:") };
-// char *dests[] = { dest, src };
-// ShowSimpleDialog(_("Move"), 2, labels, 0, 0x3, 0x3, dests);
-// }
-
-// void ShowReadAdcDialog(char *name)
-// {
-// char *labels[] = { _("Destination:") };
-// char *dests[] = { name };
-// ShowSimpleDialog(_("Read A/D Converter"), 1, labels, 0, 0x1, 0x1, dests);
-// }
-
-// void ShowSetPwmDialog(char *name, int *targetFreq)
-// {
-// char freq[100];
-// sprintf(freq, "%d", *targetFreq);
-
-// char *labels[] = { _("Duty cycle var:"), _("Frequency (Hz):") };
-// char *dests[] = { name, freq };
-// ShowSimpleDialog(_("Set PWM Duty Cycle"), 2, labels, 0x2, 0x1, 0x1, dests);
-
-// *targetFreq = atoi(freq);
-// }
-
-// void ShowUartDialog(int which, char *name)
-// {
-// char *labels[] = { (which == ELEM_UART_RECV) ? _("Destination:") :
-// _("Source:") };
-// char *dests[] = { name };
-
-// ShowSimpleDialog((which == ELEM_UART_RECV) ? _("Receive from UART") :
-// _("Send to UART"), 1, labels, 0, 0x1, 0x1, dests);
-// }
-
-// void ShowMathDialog(int which, char *dest, char *op1, char *op2)
-// {
-// char *l2, *title;
-// if(which == ELEM_ADD) {
-// l2 = "+ :";
-// title = _("Add");
-// } else if(which == ELEM_SUB) {
-// l2 = "- :";
-// title = _("Subtract");
-// } else if(which == ELEM_MUL) {
-// l2 = "* :";
-// title = _("Multiply");
-// } else if(which == ELEM_DIV) {
-// l2 = "/ :";
-// title = _("Divide");
-// } else oops();
-
-// char *labels[] = { _("Destination:"), _("is set := :"), l2 };
-// char *dests[] = { dest, op1, op2 };
-// ShowSimpleDialog(title, 3, labels, 0, 0x7, 0x7, dests);
-// }
-
-// void ShowShiftRegisterDialog(char *name, int *stages)
-// {
-// char stagesStr[20];
-// sprintf(stagesStr, "%d", *stages);
-
-// char *labels[] = { _("Name:"), _("Stages:") };
-// char *dests[] = { name, stagesStr };
-// ShowSimpleDialog(_("Shift Register"), 2, labels, 0x2, 0x1, 0x1, dests);
-
-// *stages = atoi(stagesStr);
-
-// if(*stages <= 0 || *stages >= 200) {
-// Error(_("Not a reasonable size for a shift register."));
-// *stages = 1;
-// }
-// }
-
-// void ShowFormattedStringDialog(char *var, char *string)
-// {
-// char *labels[] = { _("Variable:"), _("String:") };
-// char *dests[] = { var, string };
-// NoCheckingOnBox[0] = TRUE;
-// NoCheckingOnBox[1] = TRUE;
-// ShowSimpleDialog(_("Formatted String Over UART"), 2, labels, 0x0,
-// 0x1, 0x3, dests);
-// NoCheckingOnBox[0] = FALSE;
-// NoCheckingOnBox[1] = FALSE;
-// }
-
-// void ShowPersistDialog(char *var)
-// {
-// char *labels[] = { _("Variable:") };
-// char *dests[] = { var };
-// ShowSimpleDialog(_("Make Persistent"), 1, labels, 0, 1, 1, dests);
-// }
+ char *labels[] = { _("Name:"), _("Delay (ms):") };
+
+ char delBuf[16];
+ char nameBuf[16];
+ sprintf(delBuf, "%.3f", (*delay / 1000.0));
+ strcpy(nameBuf, name+1);
+ char *dests[] = { nameBuf, delBuf };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_TIMER;
+ SDdata.boxes = 2;
+ SDdata.str1 = name;
+ SDdata.num1 = delay;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = new char[16];
+ SDdata.dests[1] = new char[16];
+ sprintf(SDdata.dests[1], "%.3f", (*delay / 1000.0));
+ strcpy(SDdata.dests[0], name+1);
+
+ ShowSimpleDialog(s, 2, labels, (1 << 1), (1 << 0), (1 << 0), dests);
+}
+
+void ShowCounterDialog(int which, int *maxV, char *name)
+{
+ char *title;
+
+ switch(which) {
+ case ELEM_CTU: title = _("Count Up"); break;
+ case ELEM_CTD: title = _("Count Down"); break;
+ case ELEM_CTC: title = _("Circular Counter"); break;
+
+ default: oops();
+ }
+
+ char *labels[] = { _("Name:"), (which == ELEM_CTC ? _("Max value:") :
+ _("True if >= :")) };
+ char maxS[128];
+ sprintf(maxS, "%d", *maxV);
+ char *dests[] = { name+1, maxS };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_COUNTER;
+ SDdata.boxes = 2;
+ SDdata.str1 = name;
+ SDdata.num1 = maxV;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = name+1;
+ SDdata.dests[1] = new char[128];
+ sprintf(SDdata.dests[1], "%d", *maxV);
+
+ ShowSimpleDialog(title, 2, labels, 0x2, 0x1, 0x1, dests);
+}
+
+void ShowCmpDialog(int which, char *op1, char *op2)
+{
+ char *title;
+ char *l2;
+ switch(which) {
+ case ELEM_EQU:
+ title = _("If Equals");
+ l2 = "= :";
+ break;
+
+ case ELEM_NEQ:
+ title = _("If Not Equals");
+ l2 = "/= :";
+ break;
+
+ case ELEM_GRT:
+ title = _("If Greater Than");
+ l2 = "> :";
+ break;
+
+ case ELEM_GEQ:
+ title = _("If Greater Than or Equal To");
+ l2 = ">= :";
+ break;
+
+ case ELEM_LES:
+ title = _("If Less Than");
+ l2 = "< :";
+ break;
+
+ case ELEM_LEQ:
+ title = _("If Less Than or Equal To");
+ l2 = "<= :";
+ break;
+
+ default:
+ oops();
+ }
+ char *labels[] = { _("'Closed' if:"), l2 };
+ char *dests[] = { op1, op2 };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_CMP;
+ SDdata.boxes = 2;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = op1;
+ SDdata.dests[1] = op2;
+
+ ShowSimpleDialog(title, 2, labels, 0, 0x3, 0x3, dests);
+}
+
+void ShowMoveDialog(char *dest, char *src)
+{
+ char *labels[] = { _("Destination:"), _("Source:") };
+ char *dests[] = { dest, src };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_MOVE;
+ SDdata.boxes = 2;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = dest;
+ SDdata.dests[1] = src;
+
+ ShowSimpleDialog(_("Move"), 2, labels, 0, 0x3, 0x3, dests);
+}
+
+void ShowReadAdcDialog(char *name)
+{
+ char *labels[] = { _("Destination:") };
+ char *dests[] = { name };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_READ_ADC;
+ SDdata.boxes = 1;
+ SDdata.dests = new char*[1];
+ SDdata.dests[0] = name;
+
+ ShowSimpleDialog(_("Read A/D Converter"), 1, labels, 0, 0x1, 0x1, dests);
+}
+
+void ShowSetPwmDialog(char *name, int *targetFreq)
+{
+ char freq[100];
+ sprintf(freq, "%d", *targetFreq);
+
+ char *labels[] = { _("Duty cycle var:"), _("Frequency (Hz):") };
+ char *dests[] = { name, freq };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_SET_PWM;
+ SDdata.boxes = 2;
+ SDdata.num1 = targetFreq;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = name;
+ SDdata.dests[1] = new char[100];
+ sprintf(SDdata.dests[1], "%d", *targetFreq);
+
+ ShowSimpleDialog(_("Set PWM Duty Cycle"), 2, labels, 0x2, 0x1, 0x1, dests);
+}
+
+void ShowUartDialog(int which, char *name)
+{
+ char *labels[] = { (which == ELEM_UART_RECV) ? _("Destination:") :
+ _("Source:") };
+ char *dests[] = { name };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_UART;
+ SDdata.boxes = 1;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = name;
+
+ ShowSimpleDialog((which == ELEM_UART_RECV) ? _("Receive from UART") :
+ _("Send to UART"), 1, labels, 0, 0x1, 0x1, dests);
+}
+
+void ShowMathDialog(int which, char *dest, char *op1, char *op2)
+{
+ char *l2, *title;
+ if(which == ELEM_ADD) {
+ l2 = "+ :";
+ title = _("Add");
+ } else if(which == ELEM_SUB) {
+ l2 = "- :";
+ title = _("Subtract");
+ } else if(which == ELEM_MUL) {
+ l2 = "* :";
+ title = _("Multiply");
+ } else if(which == ELEM_DIV) {
+ l2 = "/ :";
+ title = _("Divide");
+ } else oops();
+
+ char *labels[] = { _("Destination:"), _("is set := :"), l2 };
+ char *dests[] = { dest, op1, op2 };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_MATH;
+ SDdata.boxes = 3;
+ SDdata.dests = new char*[3];
+ SDdata.dests[0] = dest;
+ SDdata.dests[1] = op1;
+ SDdata.dests[2] = op2;
+
+ ShowSimpleDialog(title, 3, labels, 0, 0x7, 0x7, dests);
+}
+
+void ShowShiftRegisterDialog(char *name, int *stages)
+{
+ char stagesStr[20];
+ sprintf(stagesStr, "%d", *stages);
+
+ char *labels[] = { _("Name:"), _("Stages:") };
+ char *dests[] = { name, stagesStr };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_SHIFT_REGISTER;
+ SDdata.boxes = 2;
+ SDdata.num1 = stages;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = name;
+ SDdata.dests[1] = new char[20];
+ sprintf(SDdata.dests[1], "%d", *stages);
+
+ ShowSimpleDialog(_("Shift Register"), 2, labels, 0x2, 0x1, 0x1, dests);
+}
+
+void ShowFormattedStringDialog(char *var, char *string)
+{
+ char *labels[] = { _("Variable:"), _("String:") };
+ char *dests[] = { var, string };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_FORMATTED_STRING;
+ SDdata.boxes = 2;
+ SDdata.dests = new char*[2];
+ SDdata.dests[0] = var;
+ SDdata.dests[1] = string;
+
+ NoCheckingOnBox[0] = TRUE;
+ NoCheckingOnBox[1] = TRUE;
+ ShowSimpleDialog(_("Formatted String Over UART"), 2, labels, 0x0,
+ 0x1, 0x3, dests);
+ NoCheckingOnBox[0] = FALSE;
+ NoCheckingOnBox[1] = FALSE;
+}
+
+void ShowPersistDialog(char *var)
+{
+ char *labels[] = { _("Variable:") };
+ char *dests[] = { var };
+
+ if (SIMPLE_DIALOG_ACTIVE)
+ return;
+
+ SDdata.uflag = SD_PERSIST;
+ SDdata.boxes = 1;
+ SDdata.dests = new char*[1];
+ SDdata.dests[0] = var;
+
+ ShowSimpleDialog(_("Make Persistent"), 1, labels, 0, 1, 1, dests);
+}