summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatsuDrag92018-06-15 14:55:30 +0530
committerNatsuDrag92018-06-15 14:55:30 +0530
commitc05949bafcc68a09153201097f7e46103bdb8864 (patch)
tree92d80b8c3bc58b0729527d736596e8f6ed8a717c
parenteeb03333b6c805035ef785f8a12845fd7deb2825 (diff)
downloadLDMicroGtk-c05949bafcc68a09153201097f7e46103bdb8864.tar.gz
LDMicroGtk-c05949bafcc68a09153201097f7e46103bdb8864.tar.bz2
LDMicroGtk-c05949bafcc68a09153201097f7e46103bdb8864.zip
Created ConfDialog and attached it MCU Parameters.
-rw-r--r--ldmicro/confdialog.cpp309
-rw-r--r--ldmicro/includes/ldmicro.h218
-rw-r--r--ldmicro/ldmicro.cpp444
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp18
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h7
-rw-r--r--ldmicro/maincontrols.cpp797
-rw-r--r--ldmicro/reg/t.pl205
7 files changed, 1161 insertions, 837 deletions
diff --git a/ldmicro/confdialog.cpp b/ldmicro/confdialog.cpp
index f908893..a70cbef 100644
--- a/ldmicro/confdialog.cpp
+++ b/ldmicro/confdialog.cpp
@@ -25,20 +25,25 @@
#include <linuxUI.h>
#include <stdio.h>
#include <stdlib.h>
+#include <iostream>
//#include <commctrl.h>
-
#include "ldmicro.h"
-// static HWND ConfDialog;
+using namespace std;
+
+static HWID ConfDialog;
-// static HWND CrystalTextbox;
-// static HWND CycleTextbox;
-// static HWND BaudTextbox;
+static HWID CrystalTextbox;
+static HWID CycleTextbox;
+static HWID BaudTextbox;
static LONG_PTR PrevCrystalProc;
static LONG_PTR PrevCycleProc;
static LONG_PTR PrevBaudProc;
+HWID Grid;
+HWID PackingBox;
+
//-----------------------------------------------------------------------------
// Don't allow any characters other than 0-9. in the text boxes.
//-----------------------------------------------------------------------------
@@ -65,93 +70,81 @@ static LONG_PTR PrevBaudProc;
// }
static void MakeControls(void)
-{
-// HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Cycle Time (ms):"),
-// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
-// 5, 13, 145, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(textLabel);
-
-// CycleTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
-// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 155, 12, 85, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(CycleTextbox);
-
-// HWND textLabel2 = CreateWindowEx(0, WC_STATIC,
-// _("Crystal Frequency (MHz):"),
-// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
-// 0, 43, 150, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(textLabel2);
-
-// CrystalTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
-// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 155, 42, 85, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(CrystalTextbox);
-
-// HWND textLabel3 = CreateWindowEx(0, WC_STATIC, _("UART Baud Rate (bps):"),
-// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
-// 5, 73, 145, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(textLabel3);
-
-// BaudTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
-// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 155, 72, 85, 21, ConfDialog, NULL, Instance, NULL);
-// NiceFont(BaudTextbox);
-
-// if(!UartFunctionUsed()) {
-// EnableWindow(BaudTextbox, FALSE);
-// EnableWindow(textLabel3, FALSE);
-// }
-
-// if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC ||
-// Prog.mcu->whichIsa == ISA_INTERPRETED))
-// {
-// EnableWindow(CrystalTextbox, FALSE);
-// EnableWindow(textLabel2, FALSE);
-// }
-
-// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
-// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
-// 258, 11, 70, 23, ConfDialog, NULL, Instance, NULL);
-// NiceFont(OkButton);
-
-// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
-// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 258, 41, 70, 23, ConfDialog, NULL, Instance, NULL);
-// NiceFont(CancelButton);
-
-// char explanation[1024] = "";
-
-// if(UartFunctionUsed()) {
-// if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) {
-// sprintf(explanation,
-// _("Serial (UART) will use pins %d and %d.\r\n\r\n"),
-// Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin);
-// } else {
-// strcpy(explanation,
-// _("Please select a micro with a UART.\r\n\r\n"));
-// }
-// } else {
-// strcpy(explanation, _("No serial instructions (UART Send/UART Receive) "
-// "are in use; add one to program before setting baud rate.\r\n\r\n")
-// );
-// }
-
-// strcat(explanation,
-// _("The cycle time for the 'PLC' runtime generated by LDmicro is user-"
-// "configurable. Very short cycle times may not be achievable due "
-// "to processor speed constraints, and very long cycle times may not "
-// "be achievable due to hardware overflows. Cycle times between 10 ms "
-// "and 100 ms will usually be practical.\r\n\r\n"
-// "The compiler must know what speed crystal you are using with the "
-// "micro to convert between timing in clock cycles and timing in "
-// "seconds. A 4 MHz to 20 MHz crystal is typical; check the speed "
-// "grade of the part you are using to determine the maximum allowable "
-// "clock speed before choosing a crystal."));
-
-// HWND textLabel4 = CreateWindowEx(0, WC_STATIC, explanation,
-// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
-// 11, 104, 310, 400, ConfDialog, NULL, Instance, NULL);
-// NiceFont(textLabel4);
+{
+ // Creating text labels
+ HWID textLabel = gtk_label_new ("Cycle Time (ms):");
+ HWID textLabel2 = gtk_label_new ("Crystal Frequency (MHz):");
+ HWID textLabel3 = gtk_label_new ("UART Baud Rate (bps):");
+
+ // Creating text boxes
+ CycleTextbox = gtk_entry_new ();
+ CrystalTextbox = gtk_entry_new ();
+ BaudTextbox = gtk_entry_new ();
+
+ if(!UartFunctionUsed()) {
+ gtk_widget_set_sensitive (BaudTextbox, FALSE);
+ gtk_widget_set_sensitive (textLabel3, FALSE);
+ }
+
+ if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC ||
+ Prog.mcu->whichIsa == ISA_INTERPRETED))
+ {
+ gtk_widget_set_sensitive (CrystalTextbox, FALSE);
+ gtk_widget_set_sensitive (textLabel2, FALSE);
+ }
+
+ HWID OkButton = gtk_button_new_with_label ("OK");
+ HWID CancelButton = gtk_button_new_with_label ("Cancel");
+
+ char explanation[1024] = "";
+
+ if(UartFunctionUsed()) {
+ if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) {
+ sprintf(explanation,
+ _("Serial (UART) will use pins %d and %d.\r\n\r\n"),
+ Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin);
+ }
+ else {
+ strcpy(explanation,
+ _("Please select a micro with a UART.\r\n\r\n"));
+ }
+ }
+ else {
+ strcpy(explanation, _("No serial instructions (UART Send/UART Receive) \n"
+ "are in use; add one to program before \n"
+ "setting baud rate.\r\n\r\n") );
+ }
+
+ strcat(explanation,
+ _("The cycle time for the 'PLC' runtime generated by \n" "LDmicro is user-"
+ "configurable. Very short cycle \n" "times may not be achievable due "
+ "to processor \n" "speed constraints, and very long cycle times may \n"
+ "not be achievable due to hardware overflows. Cycle \n" "times between 10 ms \n"
+ "and 100 ms will usually be practical.\r\n\r\n"
+ "The compiler must know what speed crystal you \n" "are using with the "
+ "micro to convert between timing \n" "in clock cycles and timing in"
+ "seconds. A 4 MHz to \n" "20 MHz crystal is typical; check the speed "
+ "grade of \n" "the part you are using to determine the maximum \n" "allowable"
+ "clock speed before choosing a crystal."));
+
+ HWID textLabel4 = gtk_label_new (explanation);
+
+ // Creating required containers for packing
+ Grid = gtk_grid_new();
+ PackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+
+ gtk_grid_attach (GTK_GRID (Grid), textLabel, 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (Grid), CycleTextbox, 3, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (Grid), OkButton, 6, 2, 2, 1);
+ gtk_grid_attach (GTK_GRID (Grid), textLabel2, 1, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (Grid), CrystalTextbox, 3, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (Grid), CancelButton, 6, 4, 2, 1);
+ gtk_grid_attach (GTK_GRID (Grid), textLabel3, 1, 6, 1, 1);
+ gtk_grid_attach (GTK_GRID (Grid), BaudTextbox, 3, 6, 1, 1);
+ gtk_grid_set_column_spacing (GTK_GRID (Grid), 2);
+
+ gtk_box_pack_start(GTK_BOX(PackingBox), Grid, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(PackingBox), textLabel4, TRUE, TRUE, 0);
// // Measure the explanation string, so that we know how to size our window
// RECT tr, cr;
@@ -182,68 +175,88 @@ static void MakeControls(void)
void ShowConfDialog(void)
{
-// // The window's height will be resized later, to fit the explanation text.
-// ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"),
-// WS_OVERLAPPED | WS_SYSMENU,
-// 100, 100, 0, 0, NULL, NULL, Instance, NULL);
-
-// MakeControls();
-
-// char buf[16];
-// sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0));
-// SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf);
-
-// sprintf(buf, "%.6f", Prog.mcuClock / 1e6);
-// SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf);
-
-// sprintf(buf, "%d", Prog.baudRate);
-// SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf);
-
-// EnableWindow(MainWindow, FALSE);
-// ShowWindow(ConfDialog, TRUE);
-// SetFocus(CycleTextbox);
+ // The window's height will be resized later, to fit the explanation text.
+ MakeControls();
+
+ ConfDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(ConfDialog), "PLC Configuration");
+ gtk_window_set_default_size(GTK_WINDOW(ConfDialog), 200, 250);
+ gtk_window_set_resizable (GTK_WINDOW (ConfDialog), FALSE);
+ gtk_container_add(GTK_CONTAINER(ConfDialog), PackingBox);
+ gtk_widget_add_events(ConfDialog, GDK_KEY_PRESS_MASK);
+ cout << "Created Window" << "\n";
+
+ gtk_widget_set_sensitive (MainWindow, FALSE);
+ gtk_widget_grab_focus (CycleTextbox);
+ gtk_widget_show_all (ConfDialog);
+
// 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;
-// }
-// }
+ DialogDone = FALSE;
+ DialogCancel = FALSE;
+ // g_signal_connect (G_OBJECT (ConfDialog), "keyboard_press",
+ // G_CALLBACK (KeyPressEnter), NULL);
+ // g_signal_connect (G_OBJECT (ConfDialog), "keyboard_press",
+ // G_CALLBACK (KeyPressEsc), NULL);
+
+ // while (!DialogDone) {
+ // if (KeyPressEnter(ConfDialog, GDK_KEY_PRESS, NULL)){
+ // DialogDone = TRUE;
+ // break;
+ // }
+ // else if (KeyPressEsc(ConfDialog, GDK_KEY_PRESS, NULL)){
+ // DialogDone = TRUE;
+ // DialogCancel = TRUE;
+ // break;
+ // }
+ // }
+ // 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(ConfDialog, &msg)) continue;
// TranslateMessage(&msg);
// DispatchMessage(&msg);
// }
-// if(!DialogCancel) {
-// char buf[16];
-// SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
-// (LPARAM)(buf));
-// Prog.cycleTime = (int)(1000*atof(buf) + 0.5);
-// if(Prog.cycleTime == 0) {
-// Error(_("Zero cycle time not valid; resetting to 10 ms."));
-// Prog.cycleTime = 10000;
-// }
-
-// SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
-// (LPARAM)(buf));
-// Prog.mcuClock = (int)(1e6*atof(buf) + 0.5);
-
-// SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
-// (LPARAM)(buf));
-// Prog.baudRate = atoi(buf);
-// }
-
-// EnableWindow(MainWindow, TRUE);
-// DestroyWindow(ConfDialog);
-// return;
-}
+ if(!DialogCancel) {
+ char* buf;
+
+ buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY (CycleTextbox)));
+ Prog.cycleTime = (int)(1000*atof(buf) + 0.5);
+ if(Prog.cycleTime == 0) {
+ Error(_("Zero cycle time not valid; resetting to 10 ms."));
+ Prog.cycleTime = 10000;
+ }
+
+ buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY(CrystalTextbox)));
+ Prog.mcuClock = (int)(1e6*atof(buf) + 0.5);
+
+ buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY(BaudTextbox)));
+ Prog.baudRate = atoi(buf);
+ }
+
+ char buf[16];
+ sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0));
+ gtk_entry_set_text (GTK_ENTRY (CycleTextbox), buf);
+
+ sprintf(buf, "%.6f", Prog.mcuClock / 1e6);
+ gtk_entry_set_text (GTK_ENTRY (CrystalTextbox), buf);
+
+ sprintf(buf, "%d", Prog.baudRate);
+ gtk_entry_set_text (GTK_ENTRY (BaudTextbox), buf);
+
+ gtk_widget_set_sensitive (MainWindow, TRUE);
+ // gtk_widget_destroy (ConfDialog);
+
+ return;
+} \ No newline at end of file
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 64f16c8..a36bd3c 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -51,79 +51,151 @@ typedef signed long SDWORD;
#define NUM_SUPPORTED_MCUS 16
// Menu IDs
-extern HMENU MNU_NEW;
-extern HMENU MNU_OPEN;
-extern HMENU MNU_SAVE;
-extern HMENU MNU_SAVE_AS;
-extern HMENU MNU_EXPORT;
-extern HMENU MNU_EXIT;
-
-extern HMENU MNU_UNDO;
-extern HMENU MNU_REDO;
-extern HMENU MNU_PUSH_RUNG_UP;
-extern HMENU MNU_PUSH_RUNG_DOWN;
-extern HMENU MNU_INSERT_RUNG_BEFORE;
-extern HMENU MNU_INSERT_RUNG_AFTER;
-extern HMENU MNU_DELETE_ELEMENT;
-extern HMENU MNU_DELETE_RUNG;
-
-extern HMENU MNU_INSERT_COMMENT;
-extern HMENU MNU_INSERT_CONTACTS;
-extern HMENU MNU_INSERT_COIL;
-extern HMENU MNU_INSERT_TON;
-extern HMENU MNU_INSERT_TOF;
-extern HMENU MNU_INSERT_RTO;
-extern HMENU MNU_INSERT_RES;
-extern HMENU MNU_INSERT_OSR;
-extern HMENU MNU_INSERT_OSF;
-extern HMENU MNU_INSERT_CTU;
-extern HMENU MNU_INSERT_CTD;
-extern HMENU MNU_INSERT_CTC;
-extern HMENU MNU_INSERT_ADD;
-extern HMENU MNU_INSERT_SUB;
-extern HMENU MNU_INSERT_MUL;
-extern HMENU MNU_INSERT_DIV;
-extern HMENU MNU_INSERT_MOV;
-extern HMENU MNU_INSERT_READ_ADC;
-extern HMENU MNU_INSERT_SET_PWM;
-extern HMENU MNU_INSERT_UART_SEND;
-extern HMENU MNU_INSERT_UART_RECV;
-extern HMENU MNU_INSERT_EQU;
-extern HMENU MNU_INSERT_NEQ;
-extern HMENU MNU_INSERT_GRT;
-extern HMENU MNU_INSERT_GEQ;
-extern HMENU MNU_INSERT_LES;
-extern HMENU MNU_INSERT_LEQ;
-extern HMENU MNU_INSERT_OPEN;
-extern HMENU MNU_INSERT_SHORT;
-extern HMENU MNU_INSERT_MASTER_RLY;
-extern HMENU MNU_INSERT_SHIFT_REG;
-extern HMENU MNU_INSERT_LUT;
-extern HMENU MNU_INSERT_FMTD_STR;
-extern HMENU MNU_INSERT_PERSIST;
-extern HMENU MNU_MAKE_NORMAL;
-extern HMENU MNU_NEGATE;
-extern HMENU MNU_MAKE_SET_ONLY;
-extern HMENU MNU_MAKE_RESET_ONLY;
-extern HMENU MNU_INSERT_PWL;
-
-extern HMENU MNU_MCU_SETTINGS;
-extern HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1];
-extern HMENU MNU_MICRO_CONTROLLER;
-
-extern HMENU MNU_SIMULATION_MODE;
-extern HMENU MNU_START_SIMULATION;
-extern HMENU MNU_STOP_SIMULATION;
-extern HMENU MNU_SINGLE_CYCLE;
-
-extern HMENU MNU_COMPILE;
-extern HMENU MNU_COMPILE_AS;
-
-extern HMENU MNU_MANUAL;
-extern HMENU MNU_ABOUT;
-
-extern HMENU MNU_ADV_SIMULATION;
-
+#define MNU_NEW 0x01
+#define MNU_OPEN 0x02
+#define MNU_SAVE 0x03
+#define MNU_SAVE_AS 0x04
+#define MNU_EXPORT 0x05
+#define MNU_EXIT 0x06
+
+#define MNU_UNDO 0x10
+#define MNU_REDO 0x11
+#define MNU_PUSH_RUNG_UP 0x12
+#define MNU_PUSH_RUNG_DOWN 0x13
+#define MNU_INSERT_RUNG_BEFORE 0x14
+#define MNU_INSERT_RUNG_AFTER 0x15
+#define MNU_DELETE_ELEMENT 0x16
+#define MNU_DELETE_RUNG 0x17
+
+#define MNU_INSERT_COMMENT 0x20
+#define MNU_INSERT_CONTACTS 0x21
+#define MNU_INSERT_COIL 0x22
+#define MNU_INSERT_TON 0x23
+#define MNU_INSERT_TOF 0x24
+#define MNU_INSERT_RTO 0x25
+#define MNU_INSERT_RES 0x26
+#define MNU_INSERT_OSR 0x27
+#define MNU_INSERT_OSF 0x28
+#define MNU_INSERT_CTU 0x29
+#define MNU_INSERT_CTD 0x2a
+#define MNU_INSERT_CTC 0x2b
+#define MNU_INSERT_ADD 0x2c
+#define MNU_INSERT_SUB 0x2d
+#define MNU_INSERT_MUL 0x2e
+#define MNU_INSERT_DIV 0x2f
+#define MNU_INSERT_MOV 0x30
+#define MNU_INSERT_READ_ADC 0x31
+#define MNU_INSERT_SET_PWM 0x32
+#define MNU_INSERT_UART_SEND 0x33
+#define MNU_INSERT_UART_RECV 0x34
+#define MNU_INSERT_EQU 0x35
+#define MNU_INSERT_NEQ 0x36
+#define MNU_INSERT_GRT 0x37
+#define MNU_INSERT_GEQ 0x38
+#define MNU_INSERT_LES 0x39
+#define MNU_INSERT_LEQ 0x3a
+#define MNU_INSERT_OPEN 0x3b
+#define MNU_INSERT_SHORT 0x3c
+#define MNU_INSERT_MASTER_RLY 0x3d
+#define MNU_INSERT_SHIFT_REG 0x3e
+#define MNU_INSERT_LUT 0x3f
+#define MNU_INSERT_FMTD_STR 0x40
+#define MNU_INSERT_PERSIST 0x41
+#define MNU_MAKE_NORMAL 0x42
+#define MNU_NEGATE 0x43
+#define MNU_MAKE_SET_ONLY 0x44
+#define MNU_MAKE_RESET_ONLY 0x45
+#define MNU_INSERT_PWL 0x46
+
+#define MNU_MCU_SETTINGS 0x50
+#define MNU_PROCESSOR_0 0xa0
+
+#define MNU_SIMULATION_MODE 0x60
+#define MNU_START_SIMULATION 0x61
+#define MNU_STOP_SIMULATION 0x62
+#define MNU_SINGLE_CYCLE 0x63
+
+#define MNU_COMPILE 0x70
+#define MNU_COMPILE_AS 0x71
+
+#define MNU_MANUAL 0x80
+#define MNU_ABOUT 0x81
+
+// #define MNU_ADV_SIMULATION
+
+// New menu items here
+extern HMENU NewMenu;
+extern HMENU OpenMenu;
+extern HMENU SaveMenu;
+extern HMENU SaveAsMenu;
+extern HMENU ExportMenu;
+extern HMENU ExitMenu;
+
+extern HMENU UndoMenu;
+extern HMENU RedoMenu;
+extern HMENU PushRungUpMenu;
+extern HMENU PushRungDownMenu;
+extern HMENU InsertRungBeforeMenu;
+extern HMENU InsertRungAfterMenu;
+extern HMENU DeleteElementMenu;
+extern HMENU DeleteRungMenu;
+
+extern HMENU InsertCommentMenu;
+extern HMENU InsertContactsMenu;
+extern HMENU InsertCoilMenu;
+extern HMENU InsertTonMenu;
+extern HMENU InsertTofMenu;
+extern HMENU InsertRtoMenu;
+extern HMENU InsertResMenu;
+extern HMENU InsertOsrMenu;
+extern HMENU InsertOsfMenu;
+extern HMENU InsertCtuMenu;
+extern HMENU InsertCtdMenu;
+extern HMENU InsertCtcMenu;
+extern HMENU InsertAddMenu;
+extern HMENU InsertSubMenu;
+extern HMENU InsertMulMenu;
+extern HMENU InsertDivMenu;
+extern HMENU InsertMovMenu;
+extern HMENU InsertReadAdcMenu;
+extern HMENU InsertSetPwmMenu;
+extern HMENU InsertUartSendMenu;
+extern HMENU InsertUartRecvMenu;
+extern HMENU InsertEquMenu;
+extern HMENU InsertNeqMenu;
+extern HMENU InsertGrtMenu;
+extern HMENU InsertGeqMenu;
+extern HMENU InsertLesMenu;
+extern HMENU InsertLeqMenu;
+extern HMENU InsertOpenMenu;
+extern HMENU InsertShortMenu;
+extern HMENU InsertMasterRlyMenu;
+extern HMENU InsertShiftRegMenu;
+extern HMENU InsertLutMenu;
+extern HMENU InsertFmtdStrMenu;
+extern HMENU InsertPersistMenu;
+extern HMENU MakeNormalMenu;
+extern HMENU NegateMenu;
+extern HMENU MakeSetOnlyMenu;
+extern HMENU MakeResetOnlyMenu;
+extern HMENU InsertPwlMenu;
+
+extern HMENU McuSettingsMenu;
+extern HMENU ProcessorMenuItems[NUM_SUPPORTED_MCUS+1];
+extern HMENU MicroControllerMenu;
+
+extern HMENU SimulationModeMenu;
+extern HMENU StartSimulationMenu;
+extern HMENU StopSimulationMenu;
+extern HMENU SingleCycleMenu;
+
+extern HMENU CompileMenu;
+extern HMENU CompileAsMenu;
+
+extern HMENU ManualMenu;
+extern HMENU AboutMenu;
+
+// extern HMENU MNU_ADV_SIMULATION;
// Columns within the I/O etc. listview.
#define LV_IO_NAME 0x00
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 6851d9d..fa2e17f 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -31,6 +31,10 @@
#include "ldmicro.h"
#include "freezeLD.h"
#include "mcutable.h"
+#include <iomanip>
+#include <iostream>
+
+using namespace std;
HINSTANCE Instance;
@@ -273,17 +277,17 @@ static void CompileProgram(BOOL compileAs)
// changed so that we ask if user wants to save before exiting, and update
// the I/O list.
//-----------------------------------------------------------------------------
-// void ProgramChanged(void)
-// {
-// ProgramChangedNotSaved = TRUE;
-// GenerateIoListDontLoseSelection();
-// RefreshScrollbars();
-// }
-// #define CHANGING_PROGRAM(x) { \
-// UndoRemember(); \
-// x; \
-// ProgramChanged(); \
-// }
+void ProgramChanged(void)
+{
+ ProgramChangedNotSaved = TRUE;
+ GenerateIoListDontLoseSelection();
+ // RefreshScrollbars();
+}
+#define CHANGING_PROGRAM(x) { \
+ UndoRemember(); \
+ x; \
+ ProgramChanged();\
+ }
//-----------------------------------------------------------------------------
// Hook that we install when the user starts dragging the `splitter,' in case
@@ -322,155 +326,156 @@ static void CompileProgram(BOOL compileAs)
//-----------------------------------------------------------------------------
// Handle a selection from the menu bar of the main window.
//-----------------------------------------------------------------------------
-// static void ProcessMenu(int code)
-// {
-// if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) {
-// strcpy(CurrentCompileFile, "");
-// Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0];
-// RefreshControlsToSettings();
-// return;
-// }
-// if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) {
-// Prog.mcu = NULL;
-// strcpy(CurrentCompileFile, "");
-// RefreshControlsToSettings();
-// return;
-// }
-
-// switch(code) {
-// case MNU_NEW:
-// if(CheckSaveUserCancels()) break;
-// NewProgram();
-// strcpy(CurrentSaveFile, "");
-// strcpy(CurrentCompileFile, "");
-// GenerateIoListDontLoseSelection();
-// RefreshScrollbars();
-// UpdateMainWindowTitleBar();
-// break;
-
-// case MNU_OPEN:
-// if(CheckSaveUserCancels()) break;
-// OpenDialog();
-// break;
-
-// case MNU_SAVE:
-// SaveProgram();
-// UpdateMainWindowTitleBar();
-// break;
-
-// case MNU_SAVE_AS:
-// SaveAsDialog();
-// UpdateMainWindowTitleBar();
-// break;
-
-// case MNU_EXPORT:
-// ExportDialog();
-// break;
-
-// case MNU_EXIT:
-// if(CheckSaveUserCancels()) break;
-// PostQuitMessage(0);
-// break;
-
-// case MNU_INSERT_COMMENT:
-// CHANGING_PROGRAM(AddComment(_("--add comment here--")));
-// break;
-
-// case MNU_INSERT_CONTACTS:
-// CHANGING_PROGRAM(AddContact());
-// break;
-
-// case MNU_INSERT_COIL:
-// CHANGING_PROGRAM(AddCoil());
-// break;
-
-// case MNU_INSERT_TON:
-// CHANGING_PROGRAM(AddTimer(ELEM_TON));
-// break;
-
-// case MNU_INSERT_TOF:
-// CHANGING_PROGRAM(AddTimer(ELEM_TOF));
-// break;
-
-// case MNU_INSERT_RTO:
-// CHANGING_PROGRAM(AddTimer(ELEM_RTO));
-// break;
-
-// case MNU_INSERT_CTU:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTU));
-// break;
-
-// case MNU_INSERT_CTD:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTD));
-// break;
-
-// case MNU_INSERT_CTC:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTC));
-// break;
-
-// case MNU_INSERT_RES:
-// CHANGING_PROGRAM(AddReset());
-// break;
-
-// case MNU_INSERT_OPEN:
-// CHANGING_PROGRAM(AddEmpty(ELEM_OPEN));
-// break;
-
-// case MNU_INSERT_SHORT:
-// CHANGING_PROGRAM(AddEmpty(ELEM_SHORT));
-// break;
-
-// case MNU_INSERT_MASTER_RLY:
-// CHANGING_PROGRAM(AddMasterRelay());
-// break;
-
-// case MNU_INSERT_SHIFT_REG:
-// CHANGING_PROGRAM(AddShiftRegister());
-// break;
+static void ProcessMenu(GtkMenuItem* men, gpointer gpcode)
+{
+ int code = GPOINTER_TO_INT(gpcode);
+ if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) {
+ strcpy(CurrentCompileFile, "");
+ Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0];
+ RefreshControlsToSettings();
+ return;
+ }
+ if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) {
+ Prog.mcu = NULL;
+ strcpy(CurrentCompileFile, "");
+ RefreshControlsToSettings();
+ return;
+ }
-// case MNU_INSERT_LUT:
-// CHANGING_PROGRAM(AddLookUpTable());
-// break;
+ switch(code) {
+ case MNU_NEW:
+ // if(CheckSaveUserCancels()) break;
+ // NewProgram();
+ // strcpy(CurrentSaveFile, "");
+ // strcpy(CurrentCompileFile, "");
+ // GenerateIoListDontLoseSelection();
+ // RefreshScrollbars();
+ // UpdateMainWindowTitleBar();
+ break;
+
+ case MNU_OPEN:
+ // if(CheckSaveUserCancels()) break;
+ // OpenDialog();
+ break;
+
+ case MNU_SAVE:
+ // SaveProgram();
+ // UpdateMainWindowTitleBar();
+ break;
+
+ case MNU_SAVE_AS:
+ // SaveAsDialog();
+ // UpdateMainWindowTitleBar();
+ break;
+
+ case MNU_EXPORT:
+ // ExportDialog();
+ break;
+
+ case MNU_EXIT:
+ // if(CheckSaveUserCancels()) break;
+ // PostQuitMessage(0);
+ break;
+
+ case MNU_INSERT_COMMENT:
+ // CHANGING_PROGRAM(AddComment(_("--add comment here--")));
+ break;
+
+ case MNU_INSERT_CONTACTS:
+ // CHANGING_PROGRAM(AddContact());
+ break;
+
+ case MNU_INSERT_COIL:
+ // CHANGING_PROGRAM(AddCoil());
+ break;
+
+ case MNU_INSERT_TON:
+ // CHANGING_PROGRAM(AddTimer(ELEM_TON));
+ break;
+
+ case MNU_INSERT_TOF:
+ // CHANGING_PROGRAM(AddTimer(ELEM_TOF));
+ break;
+
+ case MNU_INSERT_RTO:
+ // CHANGING_PROGRAM(AddTimer(ELEM_RTO));
+ break;
+
+ case MNU_INSERT_CTU:
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTU));
+ break;
+
+ case MNU_INSERT_CTD:
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTD));
+ break;
+
+ case MNU_INSERT_CTC:
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTC));
+ break;
+
+ case MNU_INSERT_RES:
+ // CHANGING_PROGRAM(AddReset());
+ break;
+
+ case MNU_INSERT_OPEN:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_OPEN));
+ break;
+
+ case MNU_INSERT_SHORT:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_SHORT));
+ break;
+
+ case MNU_INSERT_MASTER_RLY:
+ // CHANGING_PROGRAM(AddMasterRelay());
+ break;
+
+ case MNU_INSERT_SHIFT_REG:
+ // CHANGING_PROGRAM(AddShiftRegister());
+ break;
+
+ case MNU_INSERT_LUT:
+ // CHANGING_PROGRAM(AddLookUpTable());
+ break;
-// case MNU_INSERT_PWL:
-// CHANGING_PROGRAM(AddPiecewiseLinear());
-// break;
+ case MNU_INSERT_PWL:
+ // CHANGING_PROGRAM(AddPiecewiseLinear());
+ break;
-// case MNU_INSERT_FMTD_STR:
-// CHANGING_PROGRAM(AddFormattedString());
-// break;
+ case MNU_INSERT_FMTD_STR:
+ // CHANGING_PROGRAM(AddFormattedString());
+ break;
-// case MNU_INSERT_OSR:
-// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING));
-// break;
+ case MNU_INSERT_OSR:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING));
+ break;
-// case MNU_INSERT_OSF:
-// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING));
-// break;
+ case MNU_INSERT_OSF:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING));
+ break;
-// case MNU_INSERT_MOV:
-// CHANGING_PROGRAM(AddMove());
-// break;
+ case MNU_INSERT_MOV:
+ // CHANGING_PROGRAM(AddMove());
+ break;
-// case MNU_INSERT_SET_PWM:
-// CHANGING_PROGRAM(AddSetPwm());
-// break;
+ case MNU_INSERT_SET_PWM:
+ // CHANGING_PROGRAM(AddSetPwm());
+ break;
-// case MNU_INSERT_READ_ADC:
-// CHANGING_PROGRAM(AddReadAdc());
-// break;
+ case MNU_INSERT_READ_ADC:
+ // CHANGING_PROGRAM(AddReadAdc());
+ break;
-// case MNU_INSERT_UART_SEND:
-// CHANGING_PROGRAM(AddUart(ELEM_UART_SEND));
-// break;
+ case MNU_INSERT_UART_SEND:
+ // CHANGING_PROGRAM(AddUart(ELEM_UART_SEND));
+ break;
-// case MNU_INSERT_UART_RECV:
-// CHANGING_PROGRAM(AddUart(ELEM_UART_RECV));
-// break;
+ case MNU_INSERT_UART_RECV:
+ // CHANGING_PROGRAM(AddUart(ELEM_UART_RECV));
+ break;
-// case MNU_INSERT_PERSIST:
-// CHANGING_PROGRAM(AddPersist());
-// break;
+ case MNU_INSERT_PERSIST:
+ // CHANGING_PROGRAM(AddPersist());
+ break;
// {
// int elem;
@@ -496,91 +501,97 @@ static void CompileProgram(BOOL compileAs)
// break;
// }
-// case MNU_MAKE_NORMAL:
-// CHANGING_PROGRAM(MakeNormalSelected());
-// break;
+ case MNU_MAKE_NORMAL:
+ // CHANGING_PROGRAM(MakeNormalSelected());
+ break;
-// case MNU_NEGATE:
-// CHANGING_PROGRAM(NegateSelected());
-// break;
+ case MNU_NEGATE:
+ // CHANGING_PROGRAM(NegateSelected());
+ break;
-// case MNU_MAKE_SET_ONLY:
-// CHANGING_PROGRAM(MakeSetOnlySelected());
-// break;
+ case MNU_MAKE_SET_ONLY:
+ // CHANGING_PROGRAM(MakeSetOnlySelected());
+ break;
-// case MNU_MAKE_RESET_ONLY:
-// CHANGING_PROGRAM(MakeResetOnlySelected());
-// break;
+ case MNU_MAKE_RESET_ONLY:
+ // CHANGING_PROGRAM(MakeResetOnlySelected());
+ break;
-// case MNU_UNDO:
-// UndoUndo();
-// break;
+ case MNU_UNDO:
+ // UndoUndo();
+ break;
-// case MNU_REDO:
-// UndoRedo();
-// break;
+ case MNU_REDO:
+ // UndoRedo();
+ break;
-// case MNU_INSERT_RUNG_BEFORE:
-// CHANGING_PROGRAM(InsertRung(FALSE));
-// break;
+ case MNU_INSERT_RUNG_BEFORE:
+ // CHANGING_PROGRAM(InsertRung(FALSE));
+ break;
-// case MNU_INSERT_RUNG_AFTER:
-// CHANGING_PROGRAM(InsertRung(TRUE));
-// break;
+ case MNU_INSERT_RUNG_AFTER:
+ // CHANGING_PROGRAM(InsertRung(TRUE));
+ break;
-// case MNU_DELETE_RUNG:
-// CHANGING_PROGRAM(DeleteSelectedRung());
-// break;
+ case MNU_DELETE_RUNG:
+ // CHANGING_PROGRAM(DeleteSelectedRung());
+ break;
-// case MNU_PUSH_RUNG_UP:
-// CHANGING_PROGRAM(PushRungUp());
-// break;
+ case MNU_PUSH_RUNG_UP:
+ // CHANGING_PROGRAM(PushRungUp());
+ break;
-// case MNU_PUSH_RUNG_DOWN:
-// CHANGING_PROGRAM(PushRungDown());
-// break;
+ case MNU_PUSH_RUNG_DOWN:
+ // CHANGING_PROGRAM(PushRungDown());
+ break;
-// case MNU_DELETE_ELEMENT:
-// CHANGING_PROGRAM(DeleteSelectedFromProgram());
-// break;
+ case MNU_DELETE_ELEMENT:
+ // CHANGING_PROGRAM(DeleteSelectedFromProgram());
+ break;
-// case MNU_MCU_SETTINGS:
-// CHANGING_PROGRAM(ShowConfDialog());
-// break;
+ case MNU_MCU_SETTINGS:
+ CHANGING_PROGRAM(ShowConfDialog());
+ break;
-// case MNU_SIMULATION_MODE:
-// ToggleSimulationMode();
-// break;
+ case MNU_SIMULATION_MODE:
+ // ToggleSimulationMode();
+ break;
-// case MNU_START_SIMULATION:
-// StartSimulation();
-// break;
+ case MNU_START_SIMULATION:
+ // StartSimulation();
+ break;
-// case MNU_STOP_SIMULATION:
-// StopSimulation();
-// break;
+ case MNU_STOP_SIMULATION:
+ // StopSimulation();
+ break;
-// case MNU_SINGLE_CYCLE:
-// SimulateOneCycle(TRUE);
-// break;
+ case MNU_SINGLE_CYCLE:
+ // SimulateOneCycle(TRUE);
+ break;
-// case MNU_COMPILE:
-// CompileProgram(FALSE);
-// break;
+ case MNU_COMPILE:
+ // CompileProgram(FALSE);
+ break;
-// case MNU_COMPILE_AS:
-// CompileProgram(TRUE);
-// break;
+ case MNU_COMPILE_AS:
+ // CompileProgram(TRUE);
+ break;
-// case MNU_MANUAL:
-// ShowHelpDialog(FALSE);
-// break;
+ case MNU_MANUAL:
+ // ShowHelpDialog(FALSE);
+ break;
+
+ case MNU_ABOUT:
+ // ShowHelpDialog(TRUE);
+ break;
+ }
+}
+
+void MenuHandler (){
+ g_signal_connect(G_OBJECT(McuSettingsMenu), "activate",
+ G_CALLBACK(ProcessMenu), GINT_TO_POINTER(MNU_MCU_SETTINGS));
+}
-// case MNU_ABOUT:
-// ShowHelpDialog(TRUE);
-// break;
-// }
-// }
//-----------------------------------------------------------------------------
// WndProc for MainWindow.
@@ -1144,8 +1155,7 @@ int main(int argc, char** argv)
// WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX |
// WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX
MainWindow = CreateWindowEx(0, "LDmicro", "",
- 0,
- 10, 10, 800, 600, NULL, top, NULL, NULL);
+ 0, 10, 10, 800, 600, NULL, top, NULL, NULL);
g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LDMicro_close), NULL);
ThawWindowPos(MainWindow);
@@ -1157,6 +1167,8 @@ int main(int argc, char** argv)
MakeMainWindowControls();
MainWindowResized();
+ // CHANGING_PROGRAM(ShowConfDialog());
+ MenuHandler();
// NewProgram();
// strcpy(CurrentSaveFile, "");
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index c20dec1..670e864 100644
--- a/ldmicro/lib/linuxUI/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -1,5 +1,7 @@
#include "linuxUI.h"
+void AddMenuAccelerators (void);
+
/// EnableMenuItem Variables
const UINT MF_ENABLED = 0;
const UINT MF_GRAYED = 1;
@@ -213,4 +215,18 @@ HWID CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
gtk_window_set_icon(GTK_WINDOW(window), WinClR_it->hIcon);
return window;
-} \ No newline at end of file
+}
+
+// bool KeyPressEnter(HWID widget, GdkEventKey* event, gpointer* data) {
+// if (event->keyval == GDK_KEY_Return){
+// return TRUE;
+// }
+// return FALSE;
+// }
+
+// bool KeyPressEsc(HWID widget, GdkEventKey* event, gpointer* data) {
+// if (event->keyval == GDK_KEY_Escape){
+// return TRUE;
+// }
+// return FALSE;
+// }
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 4ddf164..279bf86 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -51,10 +51,9 @@ extern const UINT MF_UNCHECKED;
extern GtkAccelGroup* AccelGroup;
extern GClosure* closure;
-
/// ListStore
-extern GtkWidget *view;
-extern GtkTreeViewColumn *column;
+extern HWID view;
+extern HTVC column;
/// data types
typedef struct OpenFileInfoData {
@@ -76,6 +75,8 @@ BOOL GetSaveFileName(OPENFILENAME* );
void EnableMenuItem(HMENU, HMENU, UINT);
void CheckMenuItem(HMENU, HMENU, UINT);
HBRUSH GetStockObject(int fnObject);
+// bool KeyPressEnter (HWID, GdkEventKey, gpointer);
+// bool KeyPressEsc (HWID, GdkEventKey, gpointer);
HWID CreateWindowEx(
DWORD dwExStyle,
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 9a3d737..c46676d 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -31,76 +31,76 @@
#include "ldmicro.h"
// Menu IDs
-HMENU MNU_NEW;
-HMENU MNU_OPEN;
-HMENU MNU_SAVE;
-HMENU MNU_SAVE_AS;
-HMENU MNU_EXPORT;
-HMENU MNU_EXIT;
-
-HMENU MNU_UNDO;
-HMENU MNU_REDO;
-HMENU MNU_PUSH_RUNG_UP;
-HMENU MNU_PUSH_RUNG_DOWN;
-HMENU MNU_INSERT_RUNG_BEFORE;
-HMENU MNU_INSERT_RUNG_AFTER;
-HMENU MNU_DELETE_ELEMENT;
-HMENU MNU_DELETE_RUNG;
-
-HMENU MNU_INSERT_COMMENT;
-HMENU MNU_INSERT_CONTACTS;
-HMENU MNU_INSERT_COIL;
-HMENU MNU_INSERT_TON;
-HMENU MNU_INSERT_TOF;
-HMENU MNU_INSERT_RTO;
-HMENU MNU_INSERT_RES;
-HMENU MNU_INSERT_OSR;
-HMENU MNU_INSERT_OSF;
-HMENU MNU_INSERT_CTU;
-HMENU MNU_INSERT_CTD;
-HMENU MNU_INSERT_CTC;
-HMENU MNU_INSERT_ADD;
-HMENU MNU_INSERT_SUB;
-HMENU MNU_INSERT_MUL;
-HMENU MNU_INSERT_DIV;
-HMENU MNU_INSERT_MOV;
-HMENU MNU_INSERT_READ_ADC;
-HMENU MNU_INSERT_SET_PWM;
-HMENU MNU_INSERT_UART_SEND;
-HMENU MNU_INSERT_UART_RECV;
-HMENU MNU_INSERT_EQU;
-HMENU MNU_INSERT_NEQ;
-HMENU MNU_INSERT_GRT;
-HMENU MNU_INSERT_GEQ;
-HMENU MNU_INSERT_LES;
-HMENU MNU_INSERT_LEQ;
-HMENU MNU_INSERT_OPEN;
-HMENU MNU_INSERT_SHORT;
-HMENU MNU_INSERT_MASTER_RLY;
-HMENU MNU_INSERT_SHIFT_REG;
-HMENU MNU_INSERT_LUT;
-HMENU MNU_INSERT_FMTD_STR;
-HMENU MNU_INSERT_PERSIST;
-HMENU MNU_MAKE_NORMAL;
-HMENU MNU_NEGATE;
-HMENU MNU_MAKE_SET_ONLY;
-HMENU MNU_MAKE_RESET_ONLY;
-HMENU MNU_INSERT_PWL;
-
-HMENU MNU_MCU_SETTINGS;
-HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1];
-HMENU MNU_MICRO_CONTROLLER; // Item for Microcontroller
-
-HMENU MNU_SIMULATION_MODE;
-HMENU MNU_START_SIMULATION;
-HMENU MNU_STOP_SIMULATION;
-HMENU MNU_SINGLE_CYCLE;
-
-HMENU MNU_COMPILE;
-HMENU MNU_COMPILE_AS;
-
-HMENU MNU_MANUAL;
-HMENU MNU_ABOUT;
+HMENU NewMenu;
+HMENU OpenMenu;
+HMENU SaveMenu;
+HMENU SaveAsMenu_AS;
+HMENU ExportMenu;
+HMENU ExitMenu;
+
+HMENU UndoMenu;
+HMENU RedoMenu;
+HMENU PushRungUpMenu;
+HMENU PushRungDownMenu;
+HMENU InsertRungBeforeMenu;
+HMENU InsertRungAfterMenu;
+HMENU DeleteElementMenu;
+HMENU DeleteRungMenu;
+
+HMENU InsertCommentMenu;
+HMENU InsertContactsMenu;
+HMENU InsertCoilMenu;
+HMENU InsertTonMenu;
+HMENU InsertTofMenu;
+HMENU InsertRtoMenu;
+HMENU InsertResMenu;
+HMENU InsertOsrMenu;
+HMENU InsertOsfMenu;
+HMENU InsertCtuMenu;
+HMENU InsertCtdMenu;
+HMENU InsertCtcMenu;
+HMENU InsertAddMenu;
+HMENU InsertSubMenu;
+HMENU InsertMulMenu;
+HMENU InsertDivMenu;
+HMENU InsertMovMenu;
+HMENU InsertReadAdcMenu;
+HMENU InsertSetPwmMenu;
+HMENU InsertUartSendMenu;
+HMENU InsertUartRecvMenu;
+HMENU InsertEquMenu;
+HMENU InsertNeqMenu;
+HMENU InsertGrtMenu;
+HMENU InsertGeqMenu;
+HMENU InsertLesMenu;
+HMENU InsertLeqMenu;
+HMENU InsertOpenMenu;
+HMENU InsertShortMenu;
+HMENU InsertMasterRlyMenu;
+HMENU InsertShiftRegMenu;
+HMENU InsertLutMenu;
+HMENU InsertFmtdStrMenu;
+HMENU InsertPersistMenu;
+HMENU MakeNormalMenu;
+HMENU NegateMenu;
+HMENU MakeSetOnlyMenu;
+HMENU MakeResetOnlyMenu;
+HMENU InsertPwlMenu;
+
+HMENU McuSettingsMenu;
+HMENU ProcessorMenuItems[NUM_SUPPORTED_MCUS+1];
+HMENU MicroControllerMenu; // Item for Microcontroller
+
+HMENU SimulationModeMenu;
+HMENU StartSimulationMenu;
+HMENU StopSimulationMenu;
+HMENU SingleCycleMenu;
+
+HMENU CompileMenu;
+HMENU CompileAsMenu;
+
+HMENU ManualMenu;
+HMENU AboutMenu;
// scrollbars for the ladder logic area
// static HWND HorizScrollBar;
@@ -119,9 +119,9 @@ static HMENU InstructionMenu;
static HMENU ProcessorMenu;
static HMENU SimulateMenu;
static HMENU TopMenu; // Menu Bar
-static HMENU settings;
-static HMENU compile;
-static HMENU help;
+static HMENU Settings;
+static HMENU Compile;
+static HMENU Help;
HMENU ScrollWindow;
// listview used to maintain the list of I/O pins with symbolic names, plus
@@ -137,6 +137,117 @@ GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList);
// whether the simulation is running in real time
static BOOL RealTimeSimulationRunning;
+// Displaying keyboard shortcuts for each menu item
+void AddMenuAccelerators (void){
+ // Declaring the accelerator group for keyboard shortcuts
+ AccelGroup = gtk_accel_group_new ();
+
+ // Creating keyboard shortcuts for File menu
+ gtk_widget_add_accelerator (NewMenu, "activate", AccelGroup, GDK_KEY_N,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (OpenMenu, "activate", AccelGroup, GDK_KEY_O,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (SaveMenu, "activate", AccelGroup, GDK_KEY_S,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (ExportMenu, "activate", AccelGroup, GDK_KEY_E,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+ // Creating keyboard shortcuts for Edit menu
+ gtk_widget_add_accelerator (UndoMenu, "activate", AccelGroup, GDK_KEY_Z,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (RedoMenu, "activate", AccelGroup, GDK_KEY_Y,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertRungBeforeMenu, "activate", AccelGroup, GDK_KEY_F6,
+ GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertRungAfterMenu, "activate", AccelGroup, GDK_KEY_V,
+ GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (PushRungUpMenu, "activate", AccelGroup, GDK_KEY_uparrow,
+ GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (PushRungDownMenu, "activate", AccelGroup, GDK_KEY_downarrow,
+ GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (DeleteElementMenu, "activate", AccelGroup, GDK_KEY_Delete,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (DeleteRungMenu, "activate", AccelGroup, GDK_KEY_Delete,
+ GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+
+ // Creating keyboard shortcuts for Instructions menu
+ gtk_widget_add_accelerator (InsertCommentMenu, "activate", AccelGroup, GDK_KEY_semicolon,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertContactsMenu, "activate", AccelGroup, GDK_KEY_C,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertOsrMenu, "activate", AccelGroup, GDK_KEY_backslash,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertOsfMenu, "activate", AccelGroup, GDK_KEY_slash,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertTonMenu, "activate", AccelGroup, GDK_KEY_O,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertTofMenu, "activate", AccelGroup, GDK_KEY_F,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertRtoMenu, "activate", AccelGroup, GDK_KEY_T,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertCtuMenu, "activate", AccelGroup, GDK_KEY_U,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertCtdMenu, "activate", AccelGroup, GDK_KEY_I,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertCtcMenu, "activate", AccelGroup, GDK_KEY_J,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertEquMenu, "activate", AccelGroup, GDK_KEY_equal,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertGrtMenu, "activate", AccelGroup, GDK_KEY_greater,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertGeqMenu, "activate", AccelGroup, GDK_KEY_Stop,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertLesMenu, "activate", AccelGroup, GDK_KEY_less,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertLeqMenu, "activate", AccelGroup, GDK_KEY_comma,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertCoilMenu, "activate", AccelGroup, GDK_KEY_L,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertResMenu, "activate", AccelGroup, GDK_KEY_E,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertMovMenu, "activate", AccelGroup, GDK_KEY_M,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertAddMenu, "activate", AccelGroup, GDK_KEY_plus,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertSubMenu, "activate", AccelGroup, GDK_KEY_minus,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertMulMenu, "activate", AccelGroup, GDK_KEY_multiply,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertDivMenu, "activate", AccelGroup, GDK_KEY_D,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (InsertReadAdcMenu, "activate", AccelGroup, GDK_KEY_P,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (MakeNormalMenu, "activate", AccelGroup, GDK_KEY_A,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (NegateMenu, "activate", AccelGroup, GDK_KEY_N,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (MakeSetOnlyMenu, "activate", AccelGroup, GDK_KEY_S,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (MakeResetOnlyMenu, "activate", AccelGroup, GDK_KEY_R,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+
+ // Creating keyboard shortcuts for Simulation menu
+ gtk_widget_add_accelerator (SimulationModeMenu, "activate", AccelGroup, GDK_KEY_M,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (StartSimulationMenu, "activate", AccelGroup, GDK_KEY_R,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (StopSimulationMenu, "activate", AccelGroup, GDK_KEY_H,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (SingleCycleMenu, "activate", AccelGroup, GDK_KEY_space,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+
+ // Creating keyboard shortcuts for Compile menu
+ gtk_widget_add_accelerator (CompileMenu, "activate", AccelGroup, GDK_KEY_F5,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+
+ // Creating keyboard shortcuts for Help menu
+ gtk_widget_add_accelerator (ManualMenu, "activate", AccelGroup, GDK_KEY_F1,
+ GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+
+ gtk_window_add_accel_group (GTK_WINDOW (MainWindow), AccelGroup);
+
+}
+
//-----------------------------------------------------------------------------
// Create the top-level menu bar for the main window. Mostly static, but we
// create the "select processor" menu from the list in mcutable.h dynamically.
@@ -153,7 +264,6 @@ HMENU MakeMainWindowMenus(void)
HWID CompileLabel; // Compile menu label
HWID HelpLabel; // Help menu label
HWID SimulateLabel; // Simulate menu label
- HMENU ProcessorMenuItems; // Processor menu items
HMENU FileMenuSeparator; // File menu separator
HMENU EditMenuSeparator; // Edit menu separator
HMENU InstructionMenuSeparator; // Instruction menu separator
@@ -169,16 +279,12 @@ HMENU MakeMainWindowMenus(void)
// Creating various menus
FileMenu = gtk_menu_new();
EditMenu = gtk_menu_new();
- settings = gtk_menu_new();
+ Settings = gtk_menu_new();
ProcessorMenu = gtk_menu_new();
InstructionMenu = gtk_menu_new();
SimulateMenu = gtk_menu_new();
- compile = gtk_menu_new();
- help = gtk_menu_new();
-
- // Declaring the accelerator group for keyboard shortcuts
- AccelGroup = gtk_accel_group_new ();
- gtk_window_add_accel_group (GTK_WINDOW (MainWindow), AccelGroup);
+ Compile = gtk_menu_new();
+ Help = gtk_menu_new();
// Creating labels for each menu
FileLabel = gtk_menu_item_new_with_mnemonic("_File");
@@ -190,311 +296,209 @@ HMENU MakeMainWindowMenus(void)
HelpLabel = gtk_menu_item_new_with_mnemonic("_Help");
// Creating labels for File Menu
- MNU_NEW = gtk_menu_item_new_with_mnemonic("_New");
- MNU_OPEN = gtk_menu_item_new_with_mnemonic("_Open");
- MNU_SAVE = gtk_menu_item_new_with_mnemonic("_Save");
- MNU_SAVE_AS = gtk_menu_item_new_with_mnemonic("_Save As");
- MNU_EXPORT = gtk_menu_item_new_with_mnemonic("_Export As Text");
- MNU_EXIT = gtk_menu_item_new_with_mnemonic("_Exit");
+ NewMenu = gtk_menu_item_new_with_mnemonic("_New");
+ OpenMenu = gtk_menu_item_new_with_mnemonic("_Open");
+ SaveMenu = gtk_menu_item_new_with_mnemonic("_Save");
+ SaveAsMenu_AS = gtk_menu_item_new_with_mnemonic("_Save As");
+ ExportMenu = gtk_menu_item_new_with_mnemonic("_Export As Text");
+ ExitMenu = gtk_menu_item_new_with_mnemonic("_Exit");
- // Creating keyboard shortcuts for File menu
- gtk_widget_add_accelerator (MNU_NEW, "activate", AccelGroup, GDK_KEY_N,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_OPEN, "activate", AccelGroup, GDK_KEY_O,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_SAVE, "activate", AccelGroup, GDK_KEY_S,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_EXPORT, "activate", AccelGroup, GDK_KEY_E,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
-
// Appending menu items (labels) to File menu and adding separators
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN);
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE);
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS);
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), NewMenu); // Appending menu items
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), OpenMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), SaveMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), SaveAsMenu_AS);
FileMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator);
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT);
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), ExportMenu);
FileMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator);
- gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT);
+ gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), ExitMenu);
// Creating labels for Edit Menu
- MNU_UNDO = gtk_menu_item_new_with_mnemonic("_Undo");
- MNU_REDO = gtk_menu_item_new_with_mnemonic("_Redo");
- MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_mnemonic("_Insert rung Before");
- MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_mnemonic("_Insert Rung After");
- MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Up");
- MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Down");
- MNU_DELETE_ELEMENT = gtk_menu_item_new_with_mnemonic("_Delete Selected Element");
- MNU_DELETE_RUNG = gtk_menu_item_new_with_mnemonic("_Delete Rung");
-
- // Creating keyboard shortcuts for Edit menu
- gtk_widget_add_accelerator (MNU_UNDO, "activate", AccelGroup, GDK_KEY_Z,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_REDO, "activate", AccelGroup, GDK_KEY_Y,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_RUNG_BEFORE, "activate", AccelGroup, GDK_KEY_F6,
- GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_RUNG_AFTER, "activate", AccelGroup, GDK_KEY_V,
- GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_PUSH_RUNG_UP, "activate", AccelGroup, GDK_KEY_uparrow,
- GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_PUSH_RUNG_DOWN, "activate", AccelGroup, GDK_KEY_downarrow,
- GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_DELETE_ELEMENT, "activate", AccelGroup, GDK_KEY_Delete,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_DELETE_RUNG, "activate", AccelGroup, GDK_KEY_Delete,
- GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ UndoMenu = gtk_menu_item_new_with_mnemonic("_Undo");
+ RedoMenu = gtk_menu_item_new_with_mnemonic("_Redo");
+ InsertRungBeforeMenu = gtk_menu_item_new_with_mnemonic("_Insert rung Before");
+ InsertRungAfterMenu = gtk_menu_item_new_with_mnemonic("_Insert Rung After");
+ PushRungUpMenu = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Up");
+ PushRungDownMenu = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Down");
+ DeleteElementMenu = gtk_menu_item_new_with_mnemonic("_Delete Selected Element");
+ DeleteRungMenu = gtk_menu_item_new_with_mnemonic("_Delete Rung");
// Appending menu items to Edit menu and adding separators
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), UndoMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), RedoMenu);
EditMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), InsertRungBeforeMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), InsertRungAfterMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), PushRungUpMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), PushRungDownMenu);
EditMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT);
- gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), DeleteElementMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), DeleteRungMenu);
// Creating labels for Settings Menu
- MNU_MCU_SETTINGS = gtk_menu_item_new_with_mnemonic ("_MCU Parameters...");
- MNU_MICRO_CONTROLLER = gtk_menu_item_new_with_mnemonic ("_Microcontroller");
+ McuSettingsMenu = gtk_menu_item_new_with_mnemonic ("_MCU Parameters...");
+ MicroControllerMenu = gtk_menu_item_new_with_mnemonic ("_Microcontroller");
// Appending menu items to Settings menu
- gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS);
- gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MICRO_CONTROLLER);
+ gtk_menu_shell_append (GTK_MENU_SHELL (Settings), McuSettingsMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (Settings), MicroControllerMenu);
// Appending the microcontroller names to "Microcontroller" item
for (i = 0; i < NUM_SUPPORTED_MCUS; i++){
- MNU_PROCESSOR[i] = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName);
- gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[i]);
+ ProcessorMenuItems[i] = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName);
+ gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems[i]);
}
- MNU_PROCESSOR[NUM_SUPPORTED_MCUS] = gtk_check_menu_item_new_with_label ("(no microcontroller)");
- gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[NUM_SUPPORTED_MCUS]);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_MICRO_CONTROLLER), ProcessorMenu);
+ ProcessorMenuItems[NUM_SUPPORTED_MCUS] = gtk_check_menu_item_new_with_label ("(no microcontroller)");
+ gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems[NUM_SUPPORTED_MCUS]);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(MicroControllerMenu), ProcessorMenu);
// Creating labels for Instruction Menu and adding separators
- MNU_INSERT_COMMENT = gtk_menu_item_new_with_mnemonic("_Insert Comment");
- MNU_INSERT_CONTACTS = gtk_menu_item_new_with_mnemonic("_Insert Contacts");
- MNU_INSERT_OSR = gtk_menu_item_new_with_mnemonic("_Insert OSR (One Shot Rising)");
- MNU_INSERT_OSF = gtk_menu_item_new_with_mnemonic("_Insert OSF (One Shot Falling)");
- MNU_INSERT_TON = gtk_menu_item_new_with_mnemonic("_Insert TON (Delayed Turn On)");
- MNU_INSERT_TOF = gtk_menu_item_new_with_mnemonic("_Insert TOF (Delayed Turn Off)");
- MNU_INSERT_RTO = gtk_menu_item_new_with_mnemonic("_Insert RTO (Retentive Delayed Turn On)");
- MNU_INSERT_CTU = gtk_menu_item_new_with_mnemonic("_Insert CTU (Count Up)");
- MNU_INSERT_CTD = gtk_menu_item_new_with_mnemonic("_Insert CTD (Count Down)");
- MNU_INSERT_CTC = gtk_menu_item_new_with_mnemonic("_Insert CTC (Count Circular)");
- MNU_INSERT_EQU = gtk_menu_item_new_with_mnemonic("_Insert EQU (Compare for Equals)");
- MNU_INSERT_NEQ = gtk_menu_item_new_with_mnemonic("_Insert NEQ (Compare for Not Equals)");
- MNU_INSERT_GRT = gtk_menu_item_new_with_mnemonic("_Insert GRT (Compare for Greater Than)");
- MNU_INSERT_GEQ = gtk_menu_item_new_with_mnemonic("_Insert GEQ (Compare for Greater Than or Equal)");
- MNU_INSERT_LES = gtk_menu_item_new_with_mnemonic("_Insert LES (Compare for Less Than)");
- MNU_INSERT_LEQ = gtk_menu_item_new_with_mnemonic("_Insert LEQ (Compare for Less Than or Equal)");
- MNU_INSERT_OPEN = gtk_menu_item_new_with_mnemonic("_Insert Open Circuit");
- MNU_INSERT_SHORT = gtk_menu_item_new_with_mnemonic("_Insert Short Circuit");
- MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_mnemonic("_Insert Master Control Relay");
- MNU_INSERT_COIL = gtk_menu_item_new_with_mnemonic("_Insert Coil");
- MNU_INSERT_RES = gtk_menu_item_new_with_mnemonic("_Insert RES (Counter/RTO Reset)");
- MNU_INSERT_MOV = gtk_menu_item_new_with_mnemonic("_Insert MOV (Move)");
- MNU_INSERT_ADD = gtk_menu_item_new_with_mnemonic("_Insert ADD (16-bit Integer Ad)");
- MNU_INSERT_SUB = gtk_menu_item_new_with_mnemonic("_Insert SUB (16-bit Integer Subtract)");
- MNU_INSERT_MUL = gtk_menu_item_new_with_mnemonic("_Insert MUL (16-bit Integer Multiply)");
- MNU_INSERT_DIV = gtk_menu_item_new_with_mnemonic("_Insert DIV (16-bit Integer Division)");
- MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_mnemonic("_Insert Shift Register");
- MNU_INSERT_LUT = gtk_menu_item_new_with_mnemonic("_Insert Look-Up Table");
- MNU_INSERT_PWL = gtk_menu_item_new_with_mnemonic("_Insert Piecewise Linear");
- MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_mnemonic("_Insert Formatted String Over UART");
- MNU_INSERT_UART_SEND = gtk_menu_item_new_with_mnemonic("_Insert UART Send");
- MNU_INSERT_UART_RECV = gtk_menu_item_new_with_mnemonic("_Insert UART Receive");
- MNU_INSERT_SET_PWM = gtk_menu_item_new_with_mnemonic("_Insert Set PWM Output");
- MNU_INSERT_READ_ADC = gtk_menu_item_new_with_mnemonic("_Insert A/D Converter Read");
- MNU_INSERT_PERSIST = gtk_menu_item_new_with_mnemonic("_Insert Make Persistent");
- MNU_MAKE_NORMAL = gtk_menu_item_new_with_mnemonic("_Make Normal");
- MNU_NEGATE = gtk_menu_item_new_with_mnemonic("_Make Negated");
- MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_mnemonic("_Make Set-Only");
- MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_mnemonic("_Make Reset-Only");
-
- // Creating keyboard shortcuts for Instructions menu
- gtk_widget_add_accelerator (MNU_INSERT_COMMENT, "activate", AccelGroup, GDK_KEY_semicolon,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_CONTACTS, "activate", AccelGroup, GDK_KEY_C,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_OSR, "activate", AccelGroup, GDK_KEY_backslash,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_OSF, "activate", AccelGroup, GDK_KEY_slash,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_TON, "activate", AccelGroup, GDK_KEY_O,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_TOF, "activate", AccelGroup, GDK_KEY_F,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_RTO, "activate", AccelGroup, GDK_KEY_T,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_CTU, "activate", AccelGroup, GDK_KEY_U,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_CTD, "activate", AccelGroup, GDK_KEY_I,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_CTC, "activate", AccelGroup, GDK_KEY_J,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_EQU, "activate", AccelGroup, GDK_KEY_equal,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_GRT, "activate", AccelGroup, GDK_KEY_greater,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_GEQ, "activate", AccelGroup, GDK_KEY_Stop,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_LES, "activate", AccelGroup, GDK_KEY_less,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_LEQ, "activate", AccelGroup, GDK_KEY_comma,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_COIL, "activate", AccelGroup, GDK_KEY_L,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_RES, "activate", AccelGroup, GDK_KEY_E,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_MOV, "activate", AccelGroup, GDK_KEY_M,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_ADD, "activate", AccelGroup, GDK_KEY_plus,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_SUB, "activate", AccelGroup, GDK_KEY_minus,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_MUL, "activate", AccelGroup, GDK_KEY_multiply,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_DIV, "activate", AccelGroup, GDK_KEY_D,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_INSERT_READ_ADC, "activate", AccelGroup, GDK_KEY_P,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_MAKE_NORMAL, "activate", AccelGroup, GDK_KEY_A,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_NEGATE, "activate", AccelGroup, GDK_KEY_N,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_MAKE_SET_ONLY, "activate", AccelGroup, GDK_KEY_S,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_MAKE_RESET_ONLY, "activate", AccelGroup, GDK_KEY_R,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ InsertCommentMenu = gtk_menu_item_new_with_mnemonic("_Insert Comment");
+ InsertContactsMenu = gtk_menu_item_new_with_mnemonic("_Insert Contacts");
+ InsertOsrMenu = gtk_menu_item_new_with_mnemonic("_Insert OSR (One Shot Rising)");
+ InsertOsfMenu = gtk_menu_item_new_with_mnemonic("_Insert OSF (One Shot Falling)");
+ InsertTonMenu = gtk_menu_item_new_with_mnemonic("_Insert TON (Delayed Turn On)");
+ InsertTofMenu = gtk_menu_item_new_with_mnemonic("_Insert TOF (Delayed Turn Off)");
+ InsertRtoMenu = gtk_menu_item_new_with_mnemonic("_Insert RTO (Retentive Delayed Turn On)");
+ InsertCtuMenu = gtk_menu_item_new_with_mnemonic("_Insert CTU (Count Up)");
+ InsertCtdMenu = gtk_menu_item_new_with_mnemonic("_Insert CTD (Count Down)");
+ InsertCtcMenu = gtk_menu_item_new_with_mnemonic("_Insert CTC (Count Circular)");
+ InsertEquMenu = gtk_menu_item_new_with_mnemonic("_Insert EQU (Compare for Equals)");
+ InsertNeqMenu = gtk_menu_item_new_with_mnemonic("_Insert NEQ (Compare for Not Equals)");
+ InsertGrtMenu = gtk_menu_item_new_with_mnemonic("_Insert GRT (Compare for Greater Than)");
+ InsertGeqMenu = gtk_menu_item_new_with_mnemonic("_Insert GEQ (Compare for Greater Than or Equal)");
+ InsertLesMenu = gtk_menu_item_new_with_mnemonic("_Insert LES (Compare for Less Than)");
+ InsertLeqMenu = gtk_menu_item_new_with_mnemonic("_Insert LEQ (Compare for Less Than or Equal)");
+ InsertOpenMenu = gtk_menu_item_new_with_mnemonic("_Insert Open Circuit");
+ InsertShortMenu = gtk_menu_item_new_with_mnemonic("_Insert Short Circuit");
+ InsertMasterRlyMenu = gtk_menu_item_new_with_mnemonic("_Insert Master Control Relay");
+ InsertCoilMenu = gtk_menu_item_new_with_mnemonic("_Insert Coil");
+ InsertResMenu = gtk_menu_item_new_with_mnemonic("_Insert RES (Counter/RTO Reset)");
+ InsertMovMenu = gtk_menu_item_new_with_mnemonic("_Insert MOV (Move)");
+ InsertAddMenu = gtk_menu_item_new_with_mnemonic("_Insert ADD (16-bit Integer Ad)");
+ InsertSubMenu = gtk_menu_item_new_with_mnemonic("_Insert SUB (16-bit Integer Subtract)");
+ InsertMulMenu = gtk_menu_item_new_with_mnemonic("_Insert MUL (16-bit Integer Multiply)");
+ InsertDivMenu = gtk_menu_item_new_with_mnemonic("_Insert DIV (16-bit Integer Division)");
+ InsertShiftRegMenu = gtk_menu_item_new_with_mnemonic("_Insert Shift Register");
+ InsertLutMenu = gtk_menu_item_new_with_mnemonic("_Insert Look-Up Table");
+ InsertPwlMenu = gtk_menu_item_new_with_mnemonic("_Insert Piecewise Linear");
+ InsertFmtdStrMenu = gtk_menu_item_new_with_mnemonic("_Insert Formatted String Over UART");
+ InsertUartSendMenu = gtk_menu_item_new_with_mnemonic("_Insert UART Send");
+ InsertUartRecvMenu = gtk_menu_item_new_with_mnemonic("_Insert UART Receive");
+ InsertSetPwmMenu = gtk_menu_item_new_with_mnemonic("_Insert Set PWM Output");
+ InsertReadAdcMenu = gtk_menu_item_new_with_mnemonic("_Insert A/D Converter Read");
+ InsertPersistMenu = gtk_menu_item_new_with_mnemonic("_Insert Make Persistent");
+ MakeNormalMenu = gtk_menu_item_new_with_mnemonic("_Make Normal");
+ NegateMenu = gtk_menu_item_new_with_mnemonic("_Make Negated");
+ MakeSetOnlyMenu = gtk_menu_item_new_with_mnemonic("_Make Set-Only");
+ MakeResetOnlyMenu = gtk_menu_item_new_with_mnemonic("_Make Reset-Only");
// Appending menu items to Instruction menu and adding separators
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCommentMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertContactsMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOsrMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOsfMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertTonMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertTofMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertRtoMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtuMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtdMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtcMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertEquMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertNeqMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertGrtMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertGeqMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLesMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLeqMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOpenMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertShortMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMasterRlyMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCoilMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertResMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMovMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertAddMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertSubMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMulMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertDivMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertShiftRegMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLutMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertPwlMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertFmtdStrMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertUartSendMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertUartRecvMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertSetPwmMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertReadAdcMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertPersistMenu);
InstructionMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY);
- gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeNormalMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), NegateMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeSetOnlyMenu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeResetOnlyMenu);
// Creating labels for Compile Menu
- MNU_COMPILE = gtk_menu_item_new_with_mnemonic("_Compile");
- MNU_COMPILE_AS = gtk_menu_item_new_with_mnemonic("_Compile As...");
-
- // Creating keyboard shortcuts for Compile menu
- gtk_widget_add_accelerator (MNU_COMPILE, "activate", AccelGroup, GDK_KEY_F5,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ CompileMenu = gtk_menu_item_new_with_mnemonic("_Compile");
+ CompileAsMenu = gtk_menu_item_new_with_mnemonic("_Compile As...");
// Appending menu items to Compile menu
- gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE);
- gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS);
+ gtk_menu_shell_append(GTK_MENU_SHELL (Compile), CompileMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (Compile), CompileAsMenu);
// Creating labels for Help Menu
- MNU_MANUAL = gtk_menu_item_new_with_mnemonic("_Manual...");
- MNU_ABOUT = gtk_menu_item_new_with_mnemonic("_About...");
-
- // Creating keyboard shortcuts for Help menu
- gtk_widget_add_accelerator (MNU_MANUAL, "activate", AccelGroup, GDK_KEY_F1,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ ManualMenu = gtk_menu_item_new_with_mnemonic("_Manual...");
+ AboutMenu = gtk_menu_item_new_with_mnemonic("_About...");
// Appending menu items to Help menu
- gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL);
- gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT);
+ gtk_menu_shell_append(GTK_MENU_SHELL (Help), ManualMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (Help), AboutMenu);
// Creating labels for Simulation Menu
- MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_mnemonic("_Simulation Mode");
- MNU_START_SIMULATION = gtk_menu_item_new_with_mnemonic("_Start Real-Time Simulation");
- MNU_STOP_SIMULATION = gtk_menu_item_new_with_mnemonic("_Halt Simulation");
- MNU_SINGLE_CYCLE = gtk_menu_item_new_with_mnemonic("_Single Cycle");
-
- // Creating keyboard shortcuts for Edit menu
- gtk_widget_add_accelerator (MNU_SIMULATION_MODE, "activate", AccelGroup, GDK_KEY_M,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_START_SIMULATION, "activate", AccelGroup, GDK_KEY_R,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_STOP_SIMULATION, "activate", AccelGroup, GDK_KEY_H,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MNU_SINGLE_CYCLE, "activate", AccelGroup, GDK_KEY_space,
- GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE);
+ SimulationModeMenu = gtk_check_menu_item_new_with_mnemonic("_Simulation Mode");
+ StartSimulationMenu = gtk_menu_item_new_with_mnemonic("_Start Real-Time Simulation");
+ StopSimulationMenu = gtk_menu_item_new_with_mnemonic("_Halt Simulation");
+ SingleCycleMenu = gtk_menu_item_new_with_mnemonic("_Single Cycle");
// Appending menu items to Simulate menu and adding separators
- gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE);
- gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION);
- gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION);
- gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE);
+ gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), SimulationModeMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), StartSimulationMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), StopSimulationMenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), SingleCycleMenu);
SimulateMenuSeparator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator);
// Creating submenus for each menu
gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), Settings);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), Compile);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), Help);
// Appending the menu item to the menu bar
gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel);
@@ -507,7 +511,8 @@ HMENU MakeMainWindowMenus(void)
// Packing the menu bar into the box for alignment
gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0);
-
+ AddMenuAccelerators ();
+
return MenuBox;
}
@@ -581,14 +586,14 @@ void MakeMainWindowControls(void)
GTK_POLICY_ALWAYS);
// Creating a pane to separate Scrolled Window and other widgets
- gtk_paned_add1 (GTK_PANED (pane), ScrollWindow);
+ gtk_paned_pack1 (GTK_PANED (pane), ScrollWindow, TRUE, TRUE);
gtk_paned_set_position (GTK_PANED (pane), 0);
gtk_widget_set_vexpand (ScrollWindow, TRUE);
gtk_widget_set_hexpand (ScrollWindow, TRUE);
// Appending tree view to pane and pane to grid
- gtk_paned_pack2 (GTK_PANED(pane), view, FALSE, FALSE);
- gtk_paned_set_position (GTK_PANED (pane), 250);
+ gtk_paned_pack2 (GTK_PANED(pane), view, FALSE, TRUE);
+ gtk_paned_set_position (GTK_PANED (pane), 400);
gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1);
// Creating Status Bar and attaching to grid
@@ -636,66 +641,66 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther,
BOOL canPushDown, BOOL canPushUp, BOOL canInsertComment)
{
- EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP,
+ EnableMenuItem(EditMenu, PushRungUpMenu,
canPushUp ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN,
+ EnableMenuItem(EditMenu, PushRungDownMenu,
canPushDown ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(EditMenu, MNU_DELETE_RUNG,
+ EnableMenuItem(EditMenu, DeleteRungMenu,
(Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(InstructionMenu, MNU_NEGATE,
+ EnableMenuItem(InstructionMenu, NegateMenu,
canNegate ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL,
+ EnableMenuItem(InstructionMenu, MakeNormalMenu,
canNormal ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY,
+ EnableMenuItem(InstructionMenu, MakeResetOnlyMenu,
canResetOnly ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY,
+ EnableMenuItem(InstructionMenu, MakeSetOnlyMenu,
canSetOnly ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT,
+ EnableMenuItem(InstructionMenu, InsertCommentMenu,
canInsertComment ? MF_ENABLED : MF_GRAYED);
- EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT,
+ EnableMenuItem(EditMenu, DeleteElementMenu,
canDelete ? MF_ENABLED : MF_GRAYED);
int t;
t = canInsertEnd ? MF_ENABLED : MF_GRAYED;
- EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t);
+ EnableMenuItem(InstructionMenu, InsertCoilMenu, t);
+ EnableMenuItem(InstructionMenu, InsertResMenu, t);
+ EnableMenuItem(InstructionMenu, InsertMovMenu, t);
+ EnableMenuItem(InstructionMenu, InsertAddMenu, t);
+ EnableMenuItem(InstructionMenu, InsertSubMenu, t);
+ EnableMenuItem(InstructionMenu, InsertMulMenu, t);
+ EnableMenuItem(InstructionMenu, InsertDivMenu, t);
+ EnableMenuItem(InstructionMenu, InsertCtcMenu, t);
+ EnableMenuItem(InstructionMenu, InsertPersistMenu, t);
+ EnableMenuItem(InstructionMenu, InsertReadAdcMenu, t);
+ EnableMenuItem(InstructionMenu, InsertSetPwmMenu, t);
+ EnableMenuItem(InstructionMenu, InsertMasterRlyMenu, t);
+ EnableMenuItem(InstructionMenu, InsertShiftRegMenu, t);
+ EnableMenuItem(InstructionMenu, InsertLutMenu, t);
+ EnableMenuItem(InstructionMenu, InsertPwlMenu, t);
t = canInsertOther ? MF_ENABLED : MF_GRAYED;
- EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t);
- EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t);
+ EnableMenuItem(InstructionMenu, InsertTonMenu, t);
+ EnableMenuItem(InstructionMenu, InsertTofMenu, t);
+ EnableMenuItem(InstructionMenu, InsertOsrMenu, t);
+ EnableMenuItem(InstructionMenu, InsertOsfMenu, t);
+ EnableMenuItem(InstructionMenu, InsertRtoMenu, t);
+ EnableMenuItem(InstructionMenu, InsertContactsMenu, t);
+ EnableMenuItem(InstructionMenu, InsertCtuMenu, t);
+ EnableMenuItem(InstructionMenu, InsertCtdMenu, t);
+ EnableMenuItem(InstructionMenu, InsertEquMenu, t);
+ EnableMenuItem(InstructionMenu, InsertNeqMenu, t);
+ EnableMenuItem(InstructionMenu, InsertGrtMenu, t);
+ EnableMenuItem(InstructionMenu, InsertGeqMenu, t);
+ EnableMenuItem(InstructionMenu, InsertLesMenu, t);
+ EnableMenuItem(InstructionMenu, InsertLeqMenu, t);
+ EnableMenuItem(InstructionMenu, InsertShortMenu, t);
+ EnableMenuItem(InstructionMenu, InsertOpenMenu, t);
+ EnableMenuItem(InstructionMenu, InsertUartSendMenu, t);
+ EnableMenuItem(InstructionMenu, InsertUartRecvMenu, t);
+ EnableMenuItem(InstructionMenu, InsertFmtdStrMenu, t);
}
//-----------------------------------------------------------------------------
@@ -703,8 +708,8 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
//-----------------------------------------------------------------------------
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
{
- // EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED);
- // EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(EditMenu, UndoMenu, undoEnabled ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(EditMenu, RedoMenu, redoEnabled ? MF_ENABLED : MF_GRAYED);
}
//-----------------------------------------------------------------------------
@@ -715,24 +720,24 @@ void ToggleSimulationMode(void)
{
InSimulationMode = !InSimulationMode;
if(InSimulationMode) {
- EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED);
- EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED);
+ EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_ENABLED);
+ EnableMenuItem(SimulateMenu, SingleCycleMenu, MF_ENABLED);
- EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED);
- EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED);
- EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED);
- EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED);
- EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED);
+ EnableMenuItem(FileMenu, OpenMenu, MF_GRAYED);
+ EnableMenuItem(FileMenu, SaveMenu, MF_GRAYED);
+ EnableMenuItem(FileMenu, SaveAsMenu_AS, MF_GRAYED);
+ EnableMenuItem(FileMenu, NewMenu, MF_GRAYED);
+ EnableMenuItem(FileMenu, ExportMenu, MF_GRAYED);
EnableMenuItem(TopMenu, EditMenu, MF_GRAYED);
- EnableMenuItem(TopMenu, settings, MF_GRAYED);
+ EnableMenuItem(TopMenu, Settings, MF_GRAYED);
EnableMenuItem(TopMenu, InstructionMenu, MF_GRAYED);
- EnableMenuItem(TopMenu, compile, MF_GRAYED);
+ EnableMenuItem(TopMenu, Compile, MF_GRAYED);
- CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED);
+ CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_CHECKED);
// ClearSimulationData(); // simulation.cpp, ldmicro.h
- // Recheck InSimulationMode, because there could have been a compile
+ // Recheck InSimulationMode, because there could have been a Compile
// error, which would have kicked us out of simulation mode.
// if(UartFunctionUsed() && InSimulationMode) {
// ShowUartSimulationWindow(); // simulate.cpp
@@ -742,22 +747,22 @@ void ToggleSimulationMode(void)
RealTimeSimulationRunning = FALSE;
// KillTimer(MainWindow, TIMER_SIMULATE);
- EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED);
- EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED);
- EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED);
+ EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED);
+ EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED);
+ EnableMenuItem(SimulateMenu, SingleCycleMenu, MF_GRAYED);
- EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED);
- EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED);
- EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED);
- EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED);
- EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED);
+ EnableMenuItem(FileMenu, OpenMenu, MF_ENABLED);
+ EnableMenuItem(FileMenu, SaveMenu, MF_ENABLED);
+ EnableMenuItem(FileMenu, SaveAsMenu_AS, MF_ENABLED);
+ EnableMenuItem(FileMenu, NewMenu, MF_ENABLED);
+ EnableMenuItem(FileMenu, ExportMenu, MF_ENABLED);
EnableMenuItem(TopMenu, EditMenu, MF_ENABLED);
- EnableMenuItem(TopMenu, settings, MF_ENABLED);
+ EnableMenuItem(TopMenu, Settings, MF_ENABLED);
EnableMenuItem(TopMenu, InstructionMenu, MF_ENABLED);
- EnableMenuItem(TopMenu, compile, MF_ENABLED);
+ EnableMenuItem(TopMenu, Compile, MF_ENABLED);
- CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED);
+ CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_UNCHECKED);
// if(UartFunctionUsed()) {
// DestroyUartSimulationWindow();
@@ -807,18 +812,18 @@ void RefreshControlsToSettings(void)
}
for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
if(&SupportedMcus[i] == Prog.mcu) {
- CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_CHECKED);
+ CheckMenuItem(ProcessorMenu, ProcessorMenuItems[i], MF_CHECKED);
}
else {
- CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_UNCHECKED);
+ CheckMenuItem(ProcessorMenu, ProcessorMenuItems[i], MF_UNCHECKED);
}
}
// `(no microcontroller)' setting
if (!Prog.mcu){
- CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_CHECKED);
+ CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_CHECKED);
}
else {
- CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_UNCHECKED);
+ CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_UNCHECKED);
}
}
@@ -869,8 +874,8 @@ void MainWindowResized(void)
void StartSimulation(void)
{
RealTimeSimulationRunning = TRUE;
- EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED);
- EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED);
+ EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED);
+ EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_ENABLED);
// StartSimulationTimer();
UpdateMainWindowTitleBar();
}
@@ -883,8 +888,8 @@ void StopSimulation(void)
{
RealTimeSimulationRunning = FALSE;
- EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED);
- EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED);
+ EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_ENABLED);
+ EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED);
// KillTimer(MainWindow, TIMER_SIMULATE);
UpdateMainWindowTitleBar();
diff --git a/ldmicro/reg/t.pl b/ldmicro/reg/t.pl
new file mode 100644
index 0000000..b388e96
--- /dev/null
+++ b/ldmicro/reg/t.pl
@@ -0,0 +1,205 @@
+ 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