summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/CMakeLists.txt6
-rw-r--r--ldmicro/circuit.cpp20
-rw-r--r--ldmicro/draw_outputdev.cpp9
-rw-r--r--ldmicro/helpdialog.cpp88
-rw-r--r--ldmicro/includes/ldmicro.h13
-rw-r--r--ldmicro/iolist.cpp69
-rw-r--r--ldmicro/ldinterpret.c14
-rw-r--r--ldmicro/ldmicro.cpp1030
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h5
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp136
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h101
-rw-r--r--ldmicro/loadsave.cpp14
-rw-r--r--ldmicro/maincontrols.cpp119
-rw-r--r--ldmicro/schematic.cpp6
-rw-r--r--ldmicro/simulate.cpp2
-rwxr-xr-x[-rw-r--r--]ldmicro/txt2c.pl0
16 files changed, 896 insertions, 736 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index 8e60465..7fa3577 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -64,7 +64,7 @@ IF(UNIX)
add_custom_command(
OUTPUT ${OBJDIR}/helptext.cpp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND perl txt2c.pl > ${OBJDIR}/helptext.cpp
+ COMMAND perl txt2c.pl > ${OBJDItR}/helptext.cpp
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/manual*.txt")
set(SCRIPT_GENERATED_FILES ${OBJDIR}/helptext.cpp
@@ -153,8 +153,8 @@ endif()
draw_outputdev.cpp
draw.cpp
schematic.cpp
- #${OBJDIR}/helptext.cpp
- #helpdialog.cpp
+ helpdialog.cpp
+ ${OBJDIR}/helptext.cpp
maincontrols.cpp
ldmicro.cpp)
diff --git a/ldmicro/circuit.cpp b/ldmicro/circuit.cpp
index 72c59c7..0b95327 100644
--- a/ldmicro/circuit.cpp
+++ b/ldmicro/circuit.cpp
@@ -47,7 +47,7 @@ ElemSubcktParallel *AllocSubcktParallel(void)
{
return (ElemSubcktParallel *)CheckMalloc(sizeof(ElemSubcktParallel));
}
-/*
+
//-----------------------------------------------------------------------------
// Routine that does the actual work of adding a leaf element to the left/
// right of or above/below the selected element. If we are adding left/right
@@ -596,7 +596,7 @@ void DeleteSelectedFromProgram(void)
return;
}
}
-*/
+
//-----------------------------------------------------------------------------
// Free a circuit and all of its subcircuits. Calls self recursively to do
// so.
@@ -713,7 +713,7 @@ int RungContainingSelected(void)
//-----------------------------------------------------------------------------
// Delete the rung that contains the cursor.
//-----------------------------------------------------------------------------
-/*void DeleteSelectedRung(void)
+void DeleteSelectedRung(void)
{
if(Prog.numRungs == 1) {
Error(_("Cannot delete rung; program must have at least one rung."));
@@ -735,7 +735,7 @@ int RungContainingSelected(void)
if(foundCursor) MoveCursorNear(gx, gy);
WhatCanWeDoFromCursorAndTopology();
-}*/
+}
//-----------------------------------------------------------------------------
// Allocate a new `empty' rung, with only a single relay coil at the end. All
@@ -756,7 +756,7 @@ static ElemSubcktSeries *AllocEmptyRung(void)
//-----------------------------------------------------------------------------
// Insert a rung either before or after the rung that contains the cursor.
//-----------------------------------------------------------------------------
-/*void InsertRung(BOOL afterCursor)
+void InsertRung(BOOL afterCursor)
{
if(Prog.numRungs >= (MAX_RUNGS - 1)) {
Error(_("Too many rungs!"));
@@ -773,13 +773,13 @@ static ElemSubcktSeries *AllocEmptyRung(void)
(Prog.numRungs)++;
WhatCanWeDoFromCursorAndTopology();
-}*/
+}
//-----------------------------------------------------------------------------
// Swap the row containing the selected element with the one under it, or do
// nothing if the rung is the last in the program.
//-----------------------------------------------------------------------------
-/*void PushRungDown(void)
+void PushRungDown(void)
{
int i = RungContainingSelected();
if(i == (Prog.numRungs-1)) return;
@@ -790,13 +790,13 @@ static ElemSubcktSeries *AllocEmptyRung(void)
WhatCanWeDoFromCursorAndTopology();
ScrollSelectedIntoViewAfterNextPaint = TRUE;
-}*/
+}
//-----------------------------------------------------------------------------
// Swap the row containing the selected element with the one above it, or do
// nothing if the rung is the last in the program.
//-----------------------------------------------------------------------------
-/*void PushRungUp(void)
+void PushRungUp(void)
{
int i = RungContainingSelected();
if(i == 0) return;
@@ -807,7 +807,7 @@ static ElemSubcktSeries *AllocEmptyRung(void)
WhatCanWeDoFromCursorAndTopology();
ScrollSelectedIntoViewAfterNextPaint = TRUE;
-}*/
+}
//-----------------------------------------------------------------------------
// Start a new project. Give them one rung, with a coil (that they can
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index 1775104..d7ca7bd 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -121,6 +121,7 @@ BOOL BlinkCursor(BOOL kill = FALSE)
PREV_y = c.top();
PREV_w = c.width();
PREV_h = c.height();
+ // printf("Cursor: x:%d, y:%d\n",c.left(),c.top());
// MainWindowResized();
// PaintWindow(Hcr);
@@ -157,8 +158,8 @@ static void DrawCharsToScreen(HCRDC Hcr, int cx, int cy, const char *str)
BOOL inComment = FALSE;
int inBrace = 0;
for(; *str; str++, cx++) {
- int x = cx*FONT_WIDTH + X_PADDING;
- int y = cy*FONT_HEIGHT + Y_PADDING;
+ int x = cx * FONT_WIDTH + X_PADDING;
+ int y = cy * FONT_HEIGHT + Y_PADDING;
BOOL hiOk = !(InSimulationMode || ThisHighlighted);
@@ -358,14 +359,14 @@ void PaintWidget::paintEvent(QPaintEvent *event)
FillRect(Hcr, &r, InSimulationMode ? BusRightBus : BusBrush);
// InvalidateRect(DrawWindow, NULL, FALSE);
- // CursorDrawn = FALSE;
+ CursorDrawn = FALSE;
// BitBlt(paintDc, 0, 0, bw, bh, BackDc, ScrollXOffset, 0, SRCCOPY);
/*if(InSimulationMode) {
KillTimer(DrawWindow, TIMER_BLINK_CURSOR);
} else {
- SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 200, BlinkCursor);
+ CursorTimer = SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 500, CursorTimer);
}*/
ok();
diff --git a/ldmicro/helpdialog.cpp b/ldmicro/helpdialog.cpp
index 71cbd1a..ea4d23e 100644
--- a/ldmicro/helpdialog.cpp
+++ b/ldmicro/helpdialog.cpp
@@ -94,7 +94,7 @@ static char **Text[] = {
};
static HWID HelpDialog[2];
-static HWID RichEdit[2];
+static QPlainTextEdit* RichEdit[2];
static BOOL HelpWindowOpen[2];
@@ -155,33 +155,51 @@ static void MakeControls(int a)
// HMODULE re = LoadLibrary("RichEd20.dll");
// if(!re) oops();
- RichEdit[a] = gtk_scrolled_window_new (NULL, NULL);
- TextView = gtk_text_view_new ();
+ RichEdit[a] = new QPlainTextEdit();
+ RichEdit[a]->setReadOnly(TRUE);
+ QPalette pal = RichEdit[a]->palette();
+ pal.setColor(QPalette::Base, (*(HBRUSH)GetStockObject(BLACK_BRUSH)));
+ RichEdit[a]->setPalette(pal);
+ /*TextView = gtk_text_view_new ();
TextBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (TextView));
- gtk_text_view_set_editable (GTK_TEXT_VIEW (TextView), FALSE);
- SizeRichEdit(a);
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (TextView), GTK_WRAP_WORD);
- gtk_text_buffer_get_start_iter (TextBuffer, TextIter);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (TextView), FALSE);*/
+ // SizeRichEdit(a);
+ // gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (TextView), GTK_WRAP_WORD);
+ // gtk_text_buffer_get_start_iter (TextBuffer, TextIter);
// COLORREF color;
// gtk_text_buffer_create_tag (TextBuffer, "ForegroundColor1",
// "foreground", "blue");
int i;
BOOL nextSubHead = FALSE;
+ QTextCharFormat cf;
+ QFont qtfont = cf.font();
+ qtfont.setFamily(FixedWidthFont->lpszFace);
+ qtfont.setPixelSize(FixedWidthFont->nHeight - 3);
+ qtfont.setFixedPitch(TRUE);
+ qtfont.setStyle(FixedWidthFont->fdwItalic ? QFont::StyleItalic : QFont::StyleNormal);
+ qtfont.setWeight(FixedWidthFont->fnWeight == FW_BOLD ? QFont::Bold : QFont::Normal);
+ // hcr->setFont(qtfont);
for(i = 0; Text[a][i]; i++) {
char *s = Text[a][i];
- gtk_text_buffer_get_iter_at_offset (TextBuffer, TextIter, -1);
+ // f.setBold(TRUE);
+ cf.setFontWeight(cf.fontWeight()* 2);
+ cf.setFont(qtfont);
+ /*RichEdit[a]->appendPlainText("Welcome");
+ RichEdit[a]->setCurrentCharFormat(cf);
+ RichEdit[a]->appendPlainText("Thank you");*/
if((s[0] == '=') ||
(Text[a][i+1] && Text[a][i+1][0] == '='))
{
COLORREF color = RGB(255, 255, 110);
- // gtk_widget_override_color (TextView, GTK_STATE_FLAG_NORMAL, &color);
-
+ cf.setForeground(QBrush(color));
+ RichEdit[a]->setCurrentCharFormat(cf);
}
else if(s[3] == '|' && s[4] == '|') {
- // COLORREF color = RGB(255, 110, 255);
- // gtk_widget_override_color (TextView, GTK_STATE_FLAG_NORMAL, &color);
+ COLORREF color = RGB(255, 110, 255);
+ cf.setForeground(QBrush(color));
+ RichEdit[a]->setCurrentCharFormat(cf);
}
else if(s[0] == '>' || nextSubHead) {
// Need to make a copy because the strings we are passed aren't
@@ -198,10 +216,9 @@ static void MakeControls(int a)
BOOL justHeading = (copy[j] == '\0');
copy[j] = '\0';
COLORREF color = RGB(110, 255, 110);
- // gtk_widget_override_color (TextView, GTK_STATE_FLAG_NORMAL, &color);
- gtk_text_buffer_insert (TextBuffer, TextIter, copy, -1);
- gtk_text_buffer_get_iter_at_offset (TextBuffer, TextIter, -1);
-
+ cf.setForeground(QBrush(color));
+ RichEdit[a]->appendPlainText(QString::fromStdString((const char*)copy));
+ RichEdit[a]->setCurrentCharFormat(cf);
// Special case if there's nothing except title on the line
if(!justHeading) {
copy[j] = ' ';
@@ -213,20 +230,24 @@ static void MakeControls(int a)
}
else {
COLORREF color = RGB(255, 255, 255);
- gtk_widget_override_color (TextView, GTK_STATE_FLAG_NORMAL, &color);
+ cf.setForeground(QBrush(color));
+ RichEdit[a]->setCurrentCharFormat(cf);
+ // gtk_widget_override_color (TextView, GTK_STATE_FLAG_NORMAL, &color);
}
// gtk_text_buffer_insert_with_tags_by_name (TextBuffer, TextIter,
// s, -1, "ForegroundColor1", NULL);
- gtk_text_buffer_insert (TextBuffer, TextIter, s, -1);
+ // gtk_text_buffer_insert (TextBuffer, TextIter, s, -1);
+ RichEdit[a]->appendPlainText(QString::fromStdString((const char*)s));
if(Text[a][i+1]) {
- gtk_text_buffer_insert (TextBuffer, TextIter, "\n", -1);
+ // gtk_text_buffer_insert (TextBuffer, TextIter, "\n", -1);
+ // RichEdit[a]->appendPlainText("\n");
}
}
- gtk_widget_override_background_color (TextView, GTK_STATE_FLAG_NORMAL,
+ /*gtk_widget_override_background_color (TextView, GTK_STATE_FLAG_NORMAL,
((HBRUSH)GetStockObject(BLACK_BRUSH)));
- gtk_container_add (GTK_CONTAINER(RichEdit[a]), TextView);
+ gtk_container_add (GTK_CONTAINER(RichEdit[a]), TextView);*/
}
@@ -292,26 +313,27 @@ void ShowHelpDialog(BOOL about)
{
int a = about ? 1 : 0;
- MakeClass();
+ // MakeClass();
const char *s = about ? "About LDmicro" : "LDmicro Help";
MakeControls(a);
- PackBoxHelp = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(PackBoxHelp), RichEdit[a], FALSE, TRUE, 0);
-
- HelpDialog[a] = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(HelpDialog[a]), 650, 300+10*FONT_HEIGHT);
- gtk_window_set_title(GTK_WINDOW(HelpDialog[a]), s);
- gtk_container_add(GTK_CONTAINER(HelpDialog[a]), PackBoxHelp);
+ // PackBoxHelp = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ // gtk_box_pack_start(GTK_BOX(PackBoxHelp), RichEdit[a], FALSE, TRUE, 0);
+ QVBoxLayout* PackBoxHelp = new QVBoxLayout;
+ PackBoxHelp->addWidget(RichEdit[a]);
+ HelpDialog[a] = new QDialog(MainWindow);
+ HelpDialog[a]->resize(650, (300+10*FONT_HEIGHT));
+ HelpDialog[a]->setWindowTitle(s);
+ HelpDialog[a]->setLayout(PackBoxHelp);
- gtk_widget_show_all (HelpDialog[a]);
- gtk_widget_grab_focus (RichEdit[a]);
+ HelpDialog[a]->show();
- if(HelpWindowOpen[a]) {
+ /*if(HelpWindowOpen[a]) {
gtk_widget_grab_focus (HelpDialog[a]);
return;
- }
+ }*/
HelpWindowOpen[a] = TRUE;
+ RichEdit[a]->verticalScrollBar()->setValue(RichEdit[a]->verticalScrollBar()->minimum());
}
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 4372bfd..fa9ae53 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -295,10 +295,6 @@ extern HWID PinList;
#define MAX_COMMENT_LEN 384
#define MAX_LOOK_UP_TABLE_LEN 60
-// Timer IDs associated with the main window.
-extern int CursorTimer;
-extern int SimulateTimer;
-
typedef struct ElemSubckParallelTag ElemSubcktParallel;
typedef struct ElemCommentTag {
@@ -608,6 +604,14 @@ extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
void CheckHeap(char *file, int line);
#define ok() CheckHeap(__FILE__, __LINE__)
+class MyWidget : public QWidget
+{
+ public:
+ void keyPressEvent(QKeyEvent* event);
+ void mouseReleaseEvent(QMouseEvent* event);
+ void mouseDoubleClickEvent(QMouseEvent* event);
+};
+
// maincontrols.cpp
void MakeMainWindowControls(void);
HMENU MakeMainWindowMenus(void);
@@ -732,6 +736,7 @@ BOOL CanUndo(void);
// loadsave.cpp
BOOL LoadProjectFromFile(char *filename);
BOOL SaveProjectToFile(char *filename);
+void ManageLineEnding(char* line);
// iolist.cpp
int GenerateIoList(int prevSel);
diff --git a/ldmicro/iolist.cpp b/ldmicro/iolist.cpp
index 13061ae..8ac7268 100644
--- a/ldmicro/iolist.cpp
+++ b/ldmicro/iolist.cpp
@@ -353,6 +353,7 @@ BOOL LoadIoListFromFile(FILE *f)
char name[MAX_NAME_LEN];
int pin;
while(fgets(line, sizeof(line), f)) {
+ ManageLineEnding(line);
if(strcmp(line, "END\n")==0) {
return TRUE;
}
@@ -778,61 +779,54 @@ cant_use_this_io:;
g_signal_connect (CancelButton, "clicked", G_CALLBACK (IoDialogCancelProc), GINT_TO_POINTER(item));
g_signal_connect (OkButton, "clicked", G_CALLBACK (IoDialogOkProc), GINT_TO_POINTER(item));
}
-
+*/
//-----------------------------------------------------------------------------
// Called in response to a notify for the listview. Handles click, text-edit
// operations etc., but also gets called to find out what text to display
// where (LPSTR_TEXTCALLBACK); that way we don't have two parallel copies of
// the I/O list to keep in sync.
-//-----------------------------------------------------------------------------
+//---------------------------------------------------------------- -------------
void IoListProc(NMHDR *h)
{
+ QStringList StrL;
+ int item;
switch(h->code) {
case LVN_GETDISPINFO: {
- int item = h->item.iItem;
+ item = h->item.iItem;
/// Don't confuse people by displaying bogus pin assignments
/// for the C target.
-
char IO_value_holder[60];
+ QString val;
+ /// case LV_IO_NAME:
+ val = QString::fromStdString((const char*)Prog.io.assignment[item].name);
+ StrL.insert(0,val);
- GValue val = G_VALUE_INIT;
- g_value_init (&val, G_TYPE_STRING);
+ /// case LV_IO_TYPE:
+ val = QString::fromStdString(IoTypeToString(Prog.io.assignment[item].type));
+ StrL.insert(1,val);
+
+ /// case LV_IO_STATE:
+ if(InSimulationMode) {
+ char *name = Prog.io.assignment[item].name;
+ DescribeForIoList(name, IO_value_holder);
+ } else {
+ strcpy(IO_value_holder, "");
+ }
+ val = QString::fromStdString(IO_value_holder);
+ StrL.insert(2,val);
/// case LV_IO_PIN:
if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC ||
Prog.mcu->whichIsa == ISA_INTERPRETED) )
{
strcpy(IO_value_holder, "");
-
- g_value_set_string(&val, (const char*)&IO_value_holder);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_PIN, &val);
}
else
{
PinNumberForIo(IO_value_holder, &(Prog.io.assignment[item]));
- g_value_set_string(&val, (const char*)&IO_value_holder);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_PIN, &val);
}
-
- /// case LV_IO_STATE:
- if(InSimulationMode) {
- char *name = Prog.io.assignment[item].name;
- DescribeForIoList(name, IO_value_holder);
- } else {
- strcpy(IO_value_holder, "");
- }
-
- g_value_set_string(&val, (const char*)IO_value_holder);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_STATE, &val);
- /// case LV_IO_TYPE:
- char *s = IoTypeToString(Prog.io.assignment[item].type);
-
- g_value_set_string(&val, (const char*)s);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_TYPE, &val);
-
- /// case LV_IO_NAME:
- g_value_set_string(&val, (const char*)Prog.io.assignment[item].name);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_NAME, &val);
+ val = QString::fromStdString(IO_value_holder);
+ StrL.insert(3,val);
/// case LV_IO_PORT:
/// Don't confuse people by displaying bogus pin assignments
@@ -887,12 +881,11 @@ void IoListProc(NMHDR *h)
sprintf(IO_value_holder, _("<not an I/O!>"));
}
- g_value_set_string(&val, (const char*)IO_value_holder);
- gtk_list_store_set_value (GTK_LIST_STORE(h->hlistFrom), h->hlistIter, LV_IO_PORT, &val);
-
+ val = QString::fromStdString(IO_value_holder);
+ StrL.insert(4,val);
break;
}
- case LVN_ITEMACTIVATE: {
+ /*case LVN_ITEMACTIVATE: {
if(InSimulationMode) {
char *name = Prog.io.assignment[h->item.iItem].name;
if(name[0] == 'X') {
@@ -907,7 +900,7 @@ void IoListProc(NMHDR *h)
InvalidateRect(MainWindow, NULL, FALSE);
}
break;
- }
+ }*/
}
-}
-*/ \ No newline at end of file
+ h->hlistIter.insert(item,new QTreeWidgetItem(StrL));
+} \ No newline at end of file
diff --git a/ldmicro/ldinterpret.c b/ldmicro/ldinterpret.c
index a37ff09..da7a50e 100644
--- a/ldmicro/ldinterpret.c
+++ b/ldmicro/ldinterpret.c
@@ -107,6 +107,17 @@ int HexDigit(int c)
}
return 0;
}
+
+void ManageLineEnding(char* line)
+{
+ int charlen = strlen(line) - 2;
+ if(line[charlen] == '\r')
+ {
+ line[charlen++] = '\n';
+ line[charlen] = '\0';
+ }
+}
+
void LoadProgram(char *fileName)
{
int pc;
@@ -121,6 +132,7 @@ void LoadProgram(char *fileName)
}
if(!fgets(line, sizeof(line), f)) BadFormat();
+ ManageLineEnding(line);
if(strcmp(line, "$$LDcode\n")!=0) BadFormat();
for(pc = 0; ; pc++) {
@@ -128,6 +140,7 @@ void LoadProgram(char *fileName)
BYTE *b;
if(!fgets(line, sizeof(line), f)) BadFormat();
+ ManageLineEnding(line);
if(strcmp(line, "$$bits\n")==0) break;
if(strlen(line) != sizeof(BinOp)*2 + 1) BadFormat();
@@ -143,6 +156,7 @@ void LoadProgram(char *fileName)
SpecialAddrForA = -1;
SpecialAddrForXosc = -1;
while(fgets(line, sizeof(line), f)) {
+ ManageLineEnding(line);
if(memcmp(line, "a,", 2)==0) {
SpecialAddrForA = atoi(line+2);
}
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 95074a7..7fa64ee 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -53,6 +53,8 @@ static int MouseY;
int CursorTimer;
int SimulateTimer;
+ProgramSlots MenuHandle;
+
// For the open/save dialog boxes
#define LDMICRO_PATTERN "LDmicro Ladder Logic Programs (*.ld)\0*.ld\0" \
"All files\0*\0\0"
@@ -161,7 +163,7 @@ static void CompileProgram(BOOL compileAs)
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
- ofn.parentWindow = &MainWindow;
+ ofn.parentWindow = MainWindow;
ofn.lpstrTitle = _("Compile To");
if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) {
ofn.lpstrFilter = C_PATTERN;
@@ -219,7 +221,7 @@ static void CompileProgram(BOOL compileAs)
// or to cancel the operation they are performing. Return TRUE if they want
// to cancel.
//-----------------------------------------------------------------------------
-/*BOOL CheckSaveUserCancels(void)
+BOOL CheckSaveUserCancels(void)
{
if(!ProgramChangedNotSaved) {
// no problem
@@ -229,13 +231,13 @@ static void CompileProgram(BOOL compileAs)
int r = MessageBox(MainWindow,
_("The program has changed since it was last saved.\r\n\r\n"
"Do you want to save the changes?"), "LDmicro",
- MB_YESNOCANCEL | MB_ICONWARNING);
+ MB_YESNOCANCEL , MB_ICONWARNING);
switch(r) {
case IDYES:
- if(SaveProgram())
+ // if(SaveProgram())
return FALSE;
- else
- return TRUE;
+ // else
+ // return TRUE;
case IDNO:
return FALSE;
@@ -280,12 +282,13 @@ static void OpenDialog(void)
strcpy(CurrentSaveFile, tempSaveFile);
UndoFlush();
}
+ DrawWindow->repaint();
GenerateIoListDontLoseSelection();
RefreshScrollbars();
UpdateMainWindowTitleBar();
}
-*/
+
//-----------------------------------------------------------------------------
// Housekeeping required when the program changes: mark the program as
// changed so that we ask if user wants to save before exiting, and update
@@ -340,271 +343,371 @@ void ProgramChanged(void)
//-----------------------------------------------------------------------------
// 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;
-// LD_WM_Close_call(NULL, NULL, NULL);
-// // PostQuitMessage(0);
-// break;
+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;
+ }
-// case MNU_INSERT_COMMENT:
-// CHANGING_PROGRAM(AddComment(_("--add comment here--")));
-// 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;
+ LD_WM_Close_call(NULL, NULL, NULL);
+ // 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_CONTACTS:
+ CHANGING_PROGRAM(AddContact());
+ break;
-// case MNU_INSERT_COIL:
-// CHANGING_PROGRAM(AddCoil());
-// break;
+ case MNU_INSERT_COIL:
+ CHANGING_PROGRAM(AddCoil());
+ break;
-// case MNU_INSERT_TON:
-// CHANGING_PROGRAM(AddTimer(ELEM_TON));
-// break;
+ case MNU_INSERT_TON:
+ CHANGING_PROGRAM(AddTimer(ELEM_TON));
+ break;
-// case MNU_INSERT_TOF:
-// CHANGING_PROGRAM(AddTimer(ELEM_TOF));
-// break;
+ case MNU_INSERT_TOF:
+ CHANGING_PROGRAM(AddTimer(ELEM_TOF));
+ break;
-// case MNU_INSERT_RTO:
-// CHANGING_PROGRAM(AddTimer(ELEM_RTO));
-// break;
+ case MNU_INSERT_RTO:
+ CHANGING_PROGRAM(AddTimer(ELEM_RTO));
+ break;
-// case MNU_INSERT_CTU:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTU));
-// break;
+ case MNU_INSERT_CTU:
+ CHANGING_PROGRAM(AddCounter(ELEM_CTU));
+ break;
-// case MNU_INSERT_CTD:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTD));
-// break;
+ case MNU_INSERT_CTD:
+ CHANGING_PROGRAM(AddCounter(ELEM_CTD));
+ break;
-// case MNU_INSERT_CTC:
-// CHANGING_PROGRAM(AddCounter(ELEM_CTC));
-// break;
+ case MNU_INSERT_CTC:
+ CHANGING_PROGRAM(AddCounter(ELEM_CTC));
+ break;
-// case MNU_INSERT_RES:
-// CHANGING_PROGRAM(AddReset());
-// break;
+ case MNU_INSERT_RES:
+ CHANGING_PROGRAM(AddReset());
+ break;
-// case MNU_INSERT_OPEN:
-// CHANGING_PROGRAM(AddEmpty(ELEM_OPEN));
-// break;
+ case MNU_INSERT_OPEN:
+ CHANGING_PROGRAM(AddEmpty(ELEM_OPEN));
+ break;
-// case MNU_INSERT_SHORT:
-// CHANGING_PROGRAM(AddEmpty(ELEM_SHORT));
-// break;
+ case MNU_INSERT_SHORT:
+ CHANGING_PROGRAM(AddEmpty(ELEM_SHORT));
+ break;
-// case MNU_INSERT_MASTER_RLY:
-// CHANGING_PROGRAM(AddMasterRelay());
-// break;
+ case MNU_INSERT_MASTER_RLY:
+ CHANGING_PROGRAM(AddMasterRelay());
+ break;
-// case MNU_INSERT_SHIFT_REG:
-// CHANGING_PROGRAM(AddShiftRegister());
-// break;
+ case MNU_INSERT_SHIFT_REG:
+ CHANGING_PROGRAM(AddShiftRegister());
+ break;
-// case MNU_INSERT_LUT:
-// CHANGING_PROGRAM(AddLookUpTable());
-// 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;
-// case MNU_INSERT_ADD: elem = ELEM_ADD; goto math;
-// case MNU_INSERT_SUB: elem = ELEM_SUB; goto math;
-// case MNU_INSERT_MUL: elem = ELEM_MUL; goto math;
-// case MNU_INSERT_DIV: elem = ELEM_DIV; goto math;
-// math:
-// CHANGING_PROGRAM(AddMath(elem));
-// break;
-// }
-
-// {
-// int elem;
-// case MNU_INSERT_EQU: elem = ELEM_EQU; goto cmp;
-// case MNU_INSERT_NEQ: elem = ELEM_NEQ; goto cmp;
-// case MNU_INSERT_GRT: elem = ELEM_GRT; goto cmp;
-// case MNU_INSERT_GEQ: elem = ELEM_GEQ; goto cmp;
-// case MNU_INSERT_LES: elem = ELEM_LES; goto cmp;
-// case MNU_INSERT_LEQ: elem = ELEM_LEQ; goto cmp;
-// cmp:
-// CHANGING_PROGRAM(AddCmp(elem));
-// break;
-// }
-
-// case MNU_MAKE_NORMAL:
-// CHANGING_PROGRAM(MakeNormalSelected());
-// break;
-
-// case MNU_NEGATE:
-// CHANGING_PROGRAM(NegateSelected());
-// break;
-
-// case MNU_MAKE_SET_ONLY:
-// CHANGING_PROGRAM(MakeSetOnlySelected());
-// break;
-
-// case MNU_MAKE_RESET_ONLY:
-// CHANGING_PROGRAM(MakeResetOnlySelected());
-// break;
-
-// case MNU_UNDO:
-// UndoUndo();
-// break;
-
-// case MNU_REDO:
-// UndoRedo();
-// break;
-
-// case MNU_INSERT_RUNG_BEFORE:
-// CHANGING_PROGRAM(InsertRung(FALSE));
-// break;
-
-// case MNU_INSERT_RUNG_AFTER:
-// CHANGING_PROGRAM(InsertRung(TRUE));
-// break;
-
-// case MNU_DELETE_RUNG:
-// CHANGING_PROGRAM(DeleteSelectedRung());
-// break;
-
-// case MNU_PUSH_RUNG_UP:
-// CHANGING_PROGRAM(PushRungUp());
-// break;
-
-// case MNU_PUSH_RUNG_DOWN:
-// CHANGING_PROGRAM(PushRungDown());
-// break;
+ {
+ int elem;
+ case MNU_INSERT_ADD: elem = ELEM_ADD; goto math;
+ case MNU_INSERT_SUB: elem = ELEM_SUB; goto math;
+ case MNU_INSERT_MUL: elem = ELEM_MUL; goto math;
+ case MNU_INSERT_DIV: elem = ELEM_DIV; goto math;
+math:
+ CHANGING_PROGRAM(AddMath(elem));
+ break;
+ }
-// case MNU_DELETE_ELEMENT:
-// CHANGING_PROGRAM(DeleteSelectedFromProgram());
-// break;
+ {
+ int elem;
+ case MNU_INSERT_EQU: elem = ELEM_EQU; goto cmp;
+ case MNU_INSERT_NEQ: elem = ELEM_NEQ; goto cmp;
+ case MNU_INSERT_GRT: elem = ELEM_GRT; goto cmp;
+ case MNU_INSERT_GEQ: elem = ELEM_GEQ; goto cmp;
+ case MNU_INSERT_LES: elem = ELEM_LES; goto cmp;
+ case MNU_INSERT_LEQ: elem = ELEM_LEQ; goto cmp;
+cmp:
+ CHANGING_PROGRAM(AddCmp(elem));
+ break;
+ }
+
+ case MNU_MAKE_NORMAL:
+ CHANGING_PROGRAM(MakeNormalSelected());
+ break;
+
+ case MNU_NEGATE:
+ CHANGING_PROGRAM(NegateSelected());
+ break;
+
+ case MNU_MAKE_SET_ONLY:
+ CHANGING_PROGRAM(MakeSetOnlySelected());
+ break;
+
+ case MNU_MAKE_RESET_ONLY:
+ CHANGING_PROGRAM(MakeResetOnlySelected());
+ break;
+
+ case MNU_UNDO:
+ UndoUndo();
+ break;
+
+ case MNU_REDO:
+ UndoRedo();
+ break;
+
+ case MNU_INSERT_RUNG_BEFORE:
+ CHANGING_PROGRAM(InsertRung(FALSE));
+ break;
+
+ case MNU_INSERT_RUNG_AFTER:
+ CHANGING_PROGRAM(InsertRung(TRUE));
+ break;
+
+ case MNU_DELETE_RUNG:
+ CHANGING_PROGRAM(DeleteSelectedRung());
+ break;
+
+ case MNU_PUSH_RUNG_UP:
+ CHANGING_PROGRAM(PushRungUp());
+ break;
+
+ case MNU_PUSH_RUNG_DOWN:
+ CHANGING_PROGRAM(PushRungDown());
+ break;
+
+ case MNU_DELETE_ELEMENT:
+ CHANGING_PROGRAM(DeleteSelectedFromProgram());
+ break;
+
+ /*case MNU_MCU_SETTINGS:
+ CHANGING_PROGRAM(ShowConfDialog());
+ break;*/
+
+ case MNU_SIMULATION_MODE:
+ ToggleSimulationMode();
+ break;
+
+ case MNU_START_SIMULATION:
+ StartSimulation();
+ break;
+
+ case MNU_STOP_SIMULATION:
+ StopSimulation();
+ break;
+
+ case MNU_SINGLE_CYCLE:
+ SimulateOneCycle(TRUE);
+ break;
+
+ case MNU_COMPILE:
+ CompileProgram(FALSE);
+ break;
+
+ case MNU_COMPILE_AS:
+ CompileProgram(TRUE);
+ break;
+
+ case MNU_MANUAL:
+ ShowHelpDialog(FALSE);
+ break;
+
+ case MNU_ABOUT:
+ ShowHelpDialog(TRUE);
+ break;
+ }
+ // gtk_widget_queue_draw(DrawWindow);
+ DrawWindow->repaint();
+}
-// case MNU_MCU_SETTINGS:
-// CHANGING_PROGRAM(ShowConfDialog());
-// break;
+// //-----------------------------------------------------------------------------
+// // WndProc functions for MainWindow.
+// //-----------------------------------------------------------------------------
-// case MNU_SIMULATION_MODE:
-// ToggleSimulationMode();
-// break;
+void MyWidget::keyPressEvent(QKeyEvent* event)
+{
+ // if(event->key() == )
+ int wParam = event->key();
-// case MNU_START_SIMULATION:
-// StartSimulation();
-// break;
+ /*if(wParam == VK_TAB) {
+ // SetFocus(IoList);
+ gtk_window_set_focus (GTK_WINDOW(MainWindow), view);
+ // BlinkCursor(0, 0, 0, 0);
+
+ }*/
-// case MNU_STOP_SIMULATION:
-// StopSimulation();
-// break;
+ if(InSimulationMode)
+ {
+ switch(wParam)
+ {
+ case VK_DOWN:
+ if(ScrollYOffset < ScrollYOffsetMax)
+ ScrollYOffset++;
+ RefreshScrollbars();
+ DrawWindow->repaint();
+ break;
+
+ case VK_UP:
+ if(ScrollYOffset > 0)
+ ScrollYOffset--;
+ RefreshScrollbars();
+ DrawWindow->repaint();
+ break;
+
+ case VK_LEFT:
+ ScrollXOffset -= FONT_WIDTH;
+ if(ScrollXOffset < 0)
+ ScrollXOffset = 0;
+ RefreshScrollbars();
+ DrawWindow->repaint();
+ break;
+
+ case VK_RIGHT:
+ ScrollXOffset += FONT_WIDTH;
+ if(ScrollXOffset >= ScrollXOffsetMax)
+ ScrollXOffset = ScrollXOffsetMax;
+ RefreshScrollbars();
+ DrawWindow->repaint();
+ break;
+
+ case VK_RETURN:
+ case VK_ESCAPE:
+ ToggleSimulationMode();
+ break;
+ }
+ }
-// case MNU_SINGLE_CYCLE:
-// SimulateOneCycle(TRUE);
-// break;
+ switch(wParam)
+ {
+ case VK_UP:
+ if(event->modifiers() & Qt::ShiftModifier)
+ {
+ CHANGING_PROGRAM(PushRungUp());
+ }
+ else
+ {
+ MoveCursorKeyboard(wParam);
+ }
+
+ DrawWindow->repaint();
+ break;
+
+ case VK_DOWN:
+ if(event->modifiers() & Qt::ShiftModifier)
+ {
+ CHANGING_PROGRAM(PushRungDown());
+ }
+ else
+ {
+ MoveCursorKeyboard(wParam);
+ }
-// case MNU_COMPILE:
-// CompileProgram(FALSE);
-// break;
+ DrawWindow->repaint();
+ break;
-// case MNU_COMPILE_AS:
-// CompileProgram(TRUE);
-// break;
+ case VK_RIGHT:
+ case VK_LEFT:
+ MoveCursorKeyboard(wParam);
+ DrawWindow->repaint();
+ break;
-// case MNU_MANUAL:
-// ShowHelpDialog(FALSE);
-// break;
+ case VK_RETURN:
+ CHANGING_PROGRAM(EditSelectedElement());
+ DrawWindow->repaint();
+ break;
-// case MNU_ABOUT:
-// ShowHelpDialog(TRUE);
-// break;
-// }
-// gtk_widget_queue_draw(DrawWindow);
-// }
+ default:
+ break;
+ }
-// //-----------------------------------------------------------------------------
-// // WndProc functions for MainWindow.
-// //-----------------------------------------------------------------------------
+ return;
+}
// gboolean LD_WM_KeyDown_call(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
// {
// /* Handles:
@@ -783,6 +886,73 @@ void ProgramChanged(void)
// return FALSE;
// }
+void MyWidget :: mouseReleaseEvent(QMouseEvent* event)
+{
+ /* Handles:
+ * WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
+ */
+
+ QRect Rect;
+ Rect = DrawWindow->rect();
+ QPoint wy = DrawWindow->mapFrom(MainWindow, event->pos());
+ // printf("mouseReleaseEvent: x:%d,y:%d",wy.x(),wy.y());
+
+ if((wy.x() <= 0) || (wy.y() <= 0))
+ return;
+
+ //No need to identify if mouse is outside the scope as the function is not called
+
+ // GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(ScrollWindow));
+
+ switch(event->button())
+ {
+ case Qt::LeftButton:
+
+ GLOBAL_mouse_last_clicked_x = event->x();
+ GLOBAL_mouse_last_clicked_y = event->y();
+
+ /*int x = event->button.x;
+ int y = event->button.y - 30 + gtk_adjustment_get_value(adjustment);*/
+
+ if(!InSimulationMode) MoveCursorMouseClick(wy.x(), wy.y());
+
+ // gtk_widget_queue_draw(DrawWindow);
+ DrawWindow->repaint();
+
+ break;
+ // return FALSE;
+}
+}
+void MyWidget :: mouseDoubleClickEvent(QMouseEvent* event)
+{
+ QRect Rect;
+ Rect = DrawWindow->rect();
+ QPoint wy = DrawWindow->mapFrom(MainWindow, event->pos());
+
+ if((wy.x() <= 0) || (wy.y() <= 0))
+ return;
+ switch (event->button())
+ {
+ case Qt::LeftButton:
+ GLOBAL_mouse_last_clicked_x = event->x();
+ GLOBAL_mouse_last_clicked_y = event->y();
+
+ /*int x = event->button.x;
+ int y = event->button.y - 30 + gtk_adjustment_get_value(adjustment);*/
+
+ if(InSimulationMode) {
+ EditElementMouseDoubleclick(wy.x(), wy.y());
+ } else {
+ CHANGING_PROGRAM(EditElementMouseDoubleclick(wy.x(), wy.y()));
+ }
+ // gtk_widget_queue_draw(DrawWindow);
+ DrawWindow->repaint();
+ break;
+
+ }
+
+}
+
// gboolean LD_GTK_mouse_scroll_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
// {
// /* Handles:
@@ -914,22 +1084,10 @@ void ProgramChanged(void)
// return FALSE;
// }
-// gboolean LD_WM_Command_call(GtkMenuItem* men, gpointer gpcode)
-// {
-// int tempcode = GPOINTER_TO_INT(gpcode);
-// ProcessMenu (tempcode);
-
-// return FALSE;
-// }
-
-// void ProcessorCall(GtkCheckMenuItem* men, gpointer gpcode)
-// {
-// int tempcode = GPOINTER_TO_INT(gpcode);
-// if(gtk_check_menu_item_get_active(men))
-// {
-// ProcessMenu (tempcode);
-// }
-// }
+void ProgramSlots :: LD_WM_Command_call(int CommandCode)
+{
+ ProcessMenu(CommandCode);
+}
// gboolean LD_WM_SetFocus_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
// {
@@ -994,7 +1152,203 @@ void ProgramChanged(void)
inline void MenuHandler ()
{
- QObject::connect(ExitMenu, SIGNAL(triggered()), LDmicroApp, SLOT(quit()));
+ QSignalMapper* CommandMapper = new QSignalMapper (&MenuHandle);
+
+ //Create mappings for each menu item
+ CommandMapper->setMapping(NewMenu, MNU_NEW);
+ CommandMapper->setMapping(OpenMenu, MNU_OPEN);
+ CommandMapper->setMapping(SaveMenu, MNU_SAVE);
+ CommandMapper->setMapping(SaveAsMenu, MNU_SAVE_AS);
+ CommandMapper->setMapping(ExportMenu, MNU_EXPORT);
+ CommandMapper->setMapping(ExitMenu, MNU_EXIT);
+ CommandMapper->setMapping(InsertCommentMenu, MNU_INSERT_COMMENT);
+ CommandMapper->setMapping(InsertContactsMenu, MNU_INSERT_CONTACTS);
+ CommandMapper->setMapping(InsertCoilMenu, MNU_INSERT_COIL);
+ CommandMapper->setMapping(InsertTonMenu, MNU_INSERT_TON);
+ CommandMapper->setMapping(InsertTofMenu, MNU_INSERT_TOF);
+ CommandMapper->setMapping(InsertRtoMenu, MNU_INSERT_RTO);
+ CommandMapper->setMapping(InsertCtuMenu, MNU_INSERT_CTU);
+ CommandMapper->setMapping(InsertCtdMenu, MNU_INSERT_CTD);
+ CommandMapper->setMapping(InsertCtcMenu, MNU_INSERT_CTC);
+ CommandMapper->setMapping(InsertResMenu, MNU_INSERT_RES);
+ CommandMapper->setMapping(InsertOpenMenu, MNU_INSERT_OPEN);
+ CommandMapper->setMapping(InsertShortMenu, MNU_INSERT_SHORT);
+ CommandMapper->setMapping(InsertMasterRlyMenu, MNU_INSERT_MASTER_RLY);
+ CommandMapper->setMapping(InsertShiftRegMenu, MNU_INSERT_SHIFT_REG);
+ CommandMapper->setMapping(InsertLutMenu, MNU_INSERT_LUT);
+ CommandMapper->setMapping(InsertPwlMenu, MNU_INSERT_PWL);
+ CommandMapper->setMapping(InsertFmtdStrMenu, MNU_INSERT_FMTD_STR);
+ CommandMapper->setMapping(InsertOsrMenu, MNU_INSERT_OSR);
+ CommandMapper->setMapping(InsertOsfMenu, MNU_INSERT_OSF);
+ CommandMapper->setMapping(InsertMovMenu, MNU_INSERT_MOV);
+ CommandMapper->setMapping(InsertSetPwmMenu, MNU_INSERT_SET_PWM);
+ CommandMapper->setMapping(InsertReadAdcMenu, MNU_INSERT_READ_ADC);
+ CommandMapper->setMapping(InsertUartSendMenu, MNU_INSERT_UART_SEND);
+ CommandMapper->setMapping(InsertUartRecvMenu, MNU_INSERT_UART_RECV);
+ CommandMapper->setMapping(InsertPersistMenu, MNU_INSERT_PERSIST);
+ CommandMapper->setMapping(InsertAddMenu, MNU_INSERT_ADD);
+ CommandMapper->setMapping(InsertSubMenu, MNU_INSERT_SUB);
+ CommandMapper->setMapping(InsertMulMenu, MNU_INSERT_MUL);
+ CommandMapper->setMapping(InsertDivMenu, MNU_INSERT_DIV);
+ CommandMapper->setMapping(InsertEquMenu, MNU_INSERT_EQU);
+ CommandMapper->setMapping(InsertNeqMenu, MNU_INSERT_NEQ);
+ CommandMapper->setMapping(InsertGrtMenu, MNU_INSERT_GRT);
+ CommandMapper->setMapping(InsertGeqMenu, MNU_INSERT_GEQ);
+ CommandMapper->setMapping(InsertLesMenu, MNU_INSERT_LES);
+ CommandMapper->setMapping(InsertLeqMenu, MNU_INSERT_LEQ);
+ CommandMapper->setMapping(MakeNormalMenu, MNU_MAKE_NORMAL);
+ CommandMapper->setMapping(NegateMenu, MNU_NEGATE);
+ CommandMapper->setMapping(MakeSetOnlyMenu, MNU_MAKE_SET_ONLY);
+ CommandMapper->setMapping(MakeResetOnlyMenu, MNU_MAKE_RESET_ONLY);
+ CommandMapper->setMapping(UndoMenu, MNU_UNDO);
+ CommandMapper->setMapping(RedoMenu, MNU_REDO);
+ CommandMapper->setMapping(InsertRungBeforeMenu, MNU_INSERT_RUNG_BEFORE);
+ CommandMapper->setMapping(InsertRungAfterMenu, MNU_INSERT_RUNG_AFTER);
+ CommandMapper->setMapping(DeleteRungMenu, MNU_DELETE_RUNG);
+ CommandMapper->setMapping(PushRungUpMenu, MNU_PUSH_RUNG_UP);
+ CommandMapper->setMapping(PushRungDownMenu, MNU_PUSH_RUNG_DOWN);
+ CommandMapper->setMapping(DeleteElementMenu, MNU_DELETE_ELEMENT);
+ CommandMapper->setMapping(McuSettingsMenu, MNU_MCU_SETTINGS);
+ CommandMapper->setMapping(SimulationModeMenu, MNU_SIMULATION_MODE);
+ CommandMapper->setMapping(StartSimulationMenu, MNU_START_SIMULATION);
+ CommandMapper->setMapping(StopSimulationMenu, MNU_STOP_SIMULATION);
+ CommandMapper->setMapping(SingleCycleMenu, MNU_SINGLE_CYCLE);
+ CommandMapper->setMapping(CompileMenu, MNU_COMPILE);
+ CommandMapper->setMapping(CompileAsMenu, MNU_COMPILE_AS);
+ CommandMapper->setMapping(ManualMenu, MNU_MANUAL);
+ CommandMapper->setMapping(AboutMenu, MNU_ABOUT);
+
+ QObject::connect(NewMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(OpenMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(SaveMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(SaveAsMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(ExportMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(ExitMenu, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+
+ // QObject::connect(ExitMenu, SIGNAL(triggered()), LDmicroApp, SLOT(quit()));
+ QObject::connect(InsertCommentMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertContactsMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertCoilMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertTonMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertTofMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertRtoMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertCtuMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertCtdMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertCtcMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertResMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertOpenMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertShortMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertMasterRlyMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertShiftRegMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertLutMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertPwlMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertFmtdStrMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertOsrMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertOsfMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertMovMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertSetPwmMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertReadAdcMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertUartSendMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertUartRecvMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertPersistMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertAddMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertSubMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertMulMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertDivMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertEquMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertNeqMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertGrtMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertGeqMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertLesMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertLeqMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(MakeNormalMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(NegateMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(MakeSetOnlyMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(MakeResetOnlyMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(UndoMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(RedoMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertRungBeforeMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(InsertRungAfterMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(DeleteRungMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(PushRungUpMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(PushRungDownMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(DeleteElementMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(McuSettingsMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(SimulationModeMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(StartSimulationMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(StopSimulationMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(SingleCycleMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(CompileMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(CompileAsMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(ManualMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ QObject::connect(AboutMenu, SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+
+ // Connect microcontroller signals automatically
+ for(int i = 0; i < NUM_SUPPORTED_MCUS; i++)
+ {
+ CommandMapper->setMapping(ProcessorMenuItems[i], (MNU_PROCESSOR_0 + i));
+ QObject::connect(ProcessorMenuItems[i], SIGNAL(triggered()),
+ CommandMapper, SLOT(map()));
+ }
+
+ //Connect map to combined function call
+ QObject::connect (CommandMapper, SIGNAL(mapped(int)), &MenuHandle, SLOT(LD_WM_Command_call(int))) ;
// QObject::connect(ExitMenu, SIGNAL(changed()), LDmicroApp, SLOT(aboutQt()));
// g_signal_connect(G_OBJECT(NewMenu), "activate",
// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_NEW));
@@ -1014,173 +1368,6 @@ inline void MenuHandler ()
// g_signal_connect(G_OBJECT(ExitMenu), "activate",
// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_EXIT));
-// g_signal_connect(G_OBJECT(InsertCommentMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_COMMENT));
-
-// g_signal_connect(G_OBJECT(InsertContactsMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_CONTACTS));
-
-// g_signal_connect(G_OBJECT(InsertCoilMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_COIL));
-
-// g_signal_connect(G_OBJECT(InsertTonMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_TON));
-
-// g_signal_connect(G_OBJECT(InsertTofMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_TOF));
-
-// g_signal_connect(G_OBJECT(InsertRtoMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_RTO));
-
-// g_signal_connect(G_OBJECT(InsertCtuMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_CTU));
-
-// g_signal_connect(G_OBJECT(InsertCtdMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_CTD));
-
-// g_signal_connect(G_OBJECT(InsertCtcMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_CTC));
-
-// g_signal_connect(G_OBJECT(InsertResMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_RES));
-
-// g_signal_connect(G_OBJECT(InsertOpenMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_OPEN));
-
-// g_signal_connect(G_OBJECT(InsertShortMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_SHORT));
-
-// g_signal_connect(G_OBJECT(InsertMasterRlyMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_MASTER_RLY));
-
-// g_signal_connect(G_OBJECT(InsertShiftRegMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_SHIFT_REG));
-
-// g_signal_connect(G_OBJECT(InsertLutMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_LUT));
-
-// g_signal_connect(G_OBJECT(InsertPwlMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_PWL));
-
-// g_signal_connect(G_OBJECT(InsertFmtdStrMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_FMTD_STR));
-
-// g_signal_connect(G_OBJECT(InsertOsrMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_OSR));
-
-// g_signal_connect(G_OBJECT(InsertOsfMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_OSF));
-
-// g_signal_connect(G_OBJECT(InsertMovMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_MOV));
-
-// g_signal_connect(G_OBJECT(InsertSetPwmMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_SET_PWM));
-
-// g_signal_connect(G_OBJECT(InsertReadAdcMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_READ_ADC));
-
-// g_signal_connect(G_OBJECT(InsertUartSendMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_UART_SEND));
-
-// g_signal_connect(G_OBJECT(InsertUartRecvMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_UART_RECV));
-
-// g_signal_connect(G_OBJECT(InsertPersistMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_PERSIST));
-
-// g_signal_connect(G_OBJECT(InsertAddMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_ADD));
-
-// g_signal_connect(G_OBJECT(InsertSubMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_SUB));
-
-// g_signal_connect(G_OBJECT(InsertMulMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_MUL));
-
-// g_signal_connect(G_OBJECT(InsertDivMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_DIV));
-
-// g_signal_connect(G_OBJECT(InsertEquMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_EQU));
-
-// g_signal_connect(G_OBJECT(InsertNeqMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_NEQ));
-
-// g_signal_connect(G_OBJECT(InsertGrtMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_GRT));
-
-// g_signal_connect(G_OBJECT(InsertGeqMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_GEQ));
-
-// g_signal_connect(G_OBJECT(InsertLesMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_LES));
-
-// g_signal_connect(G_OBJECT(InsertLeqMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_LEQ));
-
-// g_signal_connect(G_OBJECT(MakeNormalMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_MAKE_NORMAL));
-
-// g_signal_connect(G_OBJECT(NegateMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_NEGATE));
-
-// g_signal_connect(G_OBJECT(MakeSetOnlyMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_MAKE_SET_ONLY));
-
-// g_signal_connect(G_OBJECT(MakeResetOnlyMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_MAKE_RESET_ONLY));
-
-// g_signal_connect(G_OBJECT(UndoMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_UNDO));
-
-// g_signal_connect(G_OBJECT(RedoMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_REDO));
-
-// g_signal_connect(G_OBJECT(InsertRungBeforeMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_RUNG_BEFORE));
-
-// g_signal_connect(G_OBJECT(InsertRungAfterMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_INSERT_RUNG_AFTER));
-
-// g_signal_connect(G_OBJECT(DeleteRungMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_DELETE_RUNG));
-
-// g_signal_connect(G_OBJECT(PushRungUpMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_PUSH_RUNG_UP));
-
-// g_signal_connect(G_OBJECT(PushRungDownMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_PUSH_RUNG_DOWN));
-
-// g_signal_connect(G_OBJECT(DeleteElementMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_DELETE_ELEMENT));
-
-// g_signal_connect(G_OBJECT(McuSettingsMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_MCU_SETTINGS));
-
-// g_signal_connect(G_OBJECT(SimulationModeMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_SIMULATION_MODE));
-
-// g_signal_connect(G_OBJECT(StartSimulationMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_START_SIMULATION));
-
-// g_signal_connect(G_OBJECT(StopSimulationMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_STOP_SIMULATION));
-
-// g_signal_connect(G_OBJECT(SingleCycleMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_SINGLE_CYCLE));
-
-// g_signal_connect(G_OBJECT(CompileMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_COMPILE));
-
-// g_signal_connect(G_OBJECT(CompileAsMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_COMPILE_AS));
-
-// g_signal_connect(G_OBJECT(ManualMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_MANUAL));
-
-// g_signal_connect(G_OBJECT(AboutMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_ABOUT));
// // Connect microcontroller signals automatically
// for(int i = 0; i < NUM_SUPPORTED_MCUS; i++)
// {
@@ -1258,7 +1445,7 @@ int main(int argc, char** argv)
QSize MwSize(800,600);
// Make main window
- MainWindow = new QWidget();
+ MainWindow = new MyWidget();
MWIcon = new QIcon(LDMICRO_ICON);
MainMenu = new QMenuBar(MainWindow);
@@ -1299,6 +1486,9 @@ int main(int argc, char** argv)
CursorTimer = SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 500, CursorTimer);
GenerateIoListDontLoseSelection();
+
+ // RefreshScrollbars();
+ UpdateMainWindowTitleBar();
// MakeDialogBoxClass();
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 470c7cc..edaead8 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -74,14 +74,15 @@ typedef GtkApplication* HAPP;
typedef GtkTreeViewColumn* HTVC;
typedef GdkRectangle* GDRECT;
typedef QTreeWidget* HLIST;
-typedef GtkTreeIter ITLIST;
+typedef QList<QTreeWidgetItem *> ITLIST;
typedef GDRECT* PGDRECT;
typedef QMenu* HMENU;
-typedef ITLIST* HITLIST;
+typedef ITLIST HITLIST;
typedef QPainter* HCRDC;
typedef QWidget* HWID;
typedef QWidget* HWND;
typedef GdkPixbuf* HICON;
+typedef QScrollArea* WM_SCROLL;
/// Check if system is x64 or x86
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index 3f8896c..b17edf7 100644
--- a/ldmicro/lib/linuxUI/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -49,56 +49,10 @@ COLORREF RGB(int red, int green, int blue)
return col;
}
-int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags)
+int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags, UINT iFlags)
{
-/* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
- GtkMessageType mType;
-
- if ((mFlags & MB_ICONERROR) == MB_ICONERROR)
- mType = GTK_MESSAGE_ERROR;
- else if ((mFlags & MB_ICONQUESTION) == MB_ICONQUESTION)
- mType = GTK_MESSAGE_QUESTION;
- else if ((mFlags & MB_ICONWARNING) == MB_ICONWARNING)
- mType = GTK_MESSAGE_WARNING;
- else if ((mFlags & MB_ICONINFORMATION) == MB_ICONINFORMATION)
- mType = GTK_MESSAGE_INFO;
- else
- mType = GTK_MESSAGE_OTHER;
-
- mType = GTK_MESSAGE_ERROR;
- HWID dialog = gtk_message_dialog_new (GTK_WINDOW(pWindow),
- flags,
- mType,
- GTK_BUTTONS_NONE,
- message);
-
- if ((mFlags & MB_OKCANCEL) == MB_OKCANCEL)
- {
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_OK", IDOK);
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL);
- }
- else if ((mFlags & MB_YESNO) == MB_YESNO)
- {
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES);
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO);
- }
- else if ((mFlags & MB_YESNOCANCEL) == MB_YESNOCANCEL)
- {
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES);
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO);
- gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL);
- }
- else
- gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", IDOK);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog),
- title);
- gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), message);
- int result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-*/
- // return result;
- return TRUE;
+ QMessageBox msg((QMessageBox::Icon)iFlags, title, message, (QMessageBox::StandardButton)mFlags, pWindow);
+ return msg.exec();
}
@@ -175,63 +129,39 @@ BOOL GetSaveFileName(OPENFILENAME *ofn)
BOOL GetOpenFileName(OPENFILENAME *ofn)
{
-/* GtkWidget *dialog;
- GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
-
- dialog = gtk_file_chooser_dialog_new (ofn->lpstrTitle,
- GTK_WINDOW(ofn->parentWindow),
- action,
- "_Cancel",
- GTK_RESPONSE_CANCEL,
- "_Open",
- GTK_RESPONSE_ACCEPT,
- NULL);
-
- GtkFileFilter *filter = gtk_file_filter_new ();
- char* strFilter = new char[strlen(ofn->lpstrFilter)];
+ std::string strFilter;
DWORD strFilterLen = 0;
BOOL filterResetFlag = FALSE;
-
- for (int i = 0; !(ofn->lpstrFilter[i] == '\0' && ofn->lpstrFilter[i-1] == '\0'); ++i)
+ while(!((ofn->lpstrFilter[strFilterLen] == '\0') &&
+ (ofn->lpstrFilter[strFilterLen + 1] == '\0')))
{
- memcpy (strFilter + strFilterLen, &ofn->lpstrFilter[i], 1 );
- ++strFilterLen;
- if (ofn->lpstrFilter[i] == '\0')
- if (filterResetFlag)
- {
- gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(dialog), filter);
- filter = gtk_file_filter_new ();
- strFilterLen = 0;
- filterResetFlag = FALSE;
- }
- else
- {
- gtk_file_filter_set_name (GTK_FILE_FILTER(filter), strFilter);
- strFilterLen = 0;
- filterResetFlag = TRUE;
- }
+ if(filterResetFlag)
+ {
+ strFilter = strFilter + "(";
+ strFilter.append(&ofn->lpstrFilter[strFilterLen]);
+ strFilter = strFilter + ");;";
+ filterResetFlag = FALSE;
+ }
+ else
+ {
+ strFilter.append(&ofn->lpstrFilter[strFilterLen]);
+ filterResetFlag = TRUE;
+ }
+ strFilterLen = strFilterLen + strlen(&ofn->lpstrFilter[strFilterLen]) +1;
}
-
- sprintf(strFilter, "*.%s", ofn->lpstrDefExt);
- gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
- //gtk_file_filter_set_name (filter, "int files");
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog), filter);
-
- delete strFilter;
-
- BOOL exitStatus = gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
- if (exitStatus)
+ // printf("patterns:%s\n",strFilter.c_str() );
+ QString filename = QFileDialog::getOpenFileName(ofn->parentWindow, ofn->lpstrTitle,
+ QStandardPaths::locate(QStandardPaths::HomeLocation,".",
+ QStandardPaths::LocateDirectory),
+ strFilter.c_str());
+ if(filename == NULL)
{
- char* str;
- str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
- strcpy(ofn->lpstrFile, str);
- g_free(str);
+ return FALSE;
}
- gtk_widget_destroy (dialog);
+ strcpy(ofn->lpstrFile,filename.toStdString().c_str());
+ // printf("FileName:%s",ofn->lpstrFile);
- return exitStatus;*/
return TRUE;
}
@@ -538,7 +468,7 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID)
pal.setColor(QPalette::Background, Qt::white);
CursorObject->setAutoFillBackground(true);
CursorObject->setPalette(pal);
- // CursorObject->setGeometry(100,100,2,20);
+ CursorObject->setGeometry(0,0,2,20);
}
// if(hWid!=NULL)
// CursorObject->setVisible(TRUE);
@@ -560,14 +490,18 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID)
BOOL KillTimer(HWID hWid, UINT uIDEvent)
{
- auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; });
+ /*auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; });
if (record_it == timerRecords.end())
return FALSE;
record_it->pfun(TRUE);
g_source_remove (record_it->utID);
- timerRecords.erase(record_it);
+ timerRecords.erase(record_it);*/
+ if(uIDEvent == TIMER_BLINK_CURSOR)
+ {
+ hWid->killTimer(CursorTimer);
+ }
return TRUE;
}
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 7054b61..ed2a961 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -11,6 +11,14 @@
#include <QLabel>
#include <QPainter>
#include <QGroupBox>
+#include <QSignalMapper>
+#include <QKeyEvent>
+#include <QScrollArea>
+#include <QScrollBar>
+#include <QMessageBox>
+#include <QFileDialog>
+#include <QStandardPaths>
+#include <QPlainTextEdit>
// #include <QtGui>
// #include <QSize>
// #include "freezeLD.h"
@@ -34,20 +42,20 @@
/// Flags
/// message box
-#define MB_OK 0x00000001L
-#define MB_OKCANCEL 0x00000002L
-#define MB_YESNO 0x00000004L
-#define MB_YESNOCANCEL 0x00000008L
+#define MB_OK QMessageBox::Ok
+#define MB_OKCANCEL QMessageBox::Ok | QMessageBox::Cancel
+#define MB_YESNO QMessageBox::Yes | QMessageBox::No
+#define MB_YESNOCANCEL QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel
-#define IDOK 1
-#define IDCANCEL 2
-#define IDYES 3
-#define IDNO 4
+#define IDOK QMessageBox::Ok
+#define IDCANCEL QMessageBox::Cancel
+#define IDYES QMessageBox::Yes
+#define IDNO QMessageBox::No
-#define MB_ICONERROR 0x00000010L
-#define MB_ICONQUESTION 0x00000020L
-#define MB_ICONWARNING 0x00000040L
-#define MB_ICONINFORMATION 0x00000080L
+#define MB_ICONERROR QMessageBox::Critical
+#define MB_ICONQUESTION QMessageBox::Question
+#define MB_ICONWARNING QMessageBox::Warning
+#define MB_ICONINFORMATION QMessageBox::Information
/// Scroll
#define SB_LINEUP 0x00000001
@@ -77,34 +85,34 @@
#define PATINVERT 0x00000100L
/// Key masks
-#define VK_TAB GDK_KEY_Tab
+#define VK_TAB Qt::Key_Tab
-#define VK_DOWN 65364
-#define VK_UP 65362
-#define VK_LEFT 65361
-#define VK_RIGHT 65363
+#define VK_DOWN Qt::Key_Down
+#define VK_UP Qt::Key_Up
+#define VK_LEFT Qt::Key_Left
+#define VK_RIGHT Qt::Key_Right
-#define VK_NP_DOWN 65433
-#define VK_NP_UP 65431
-#define VK_NP_LEFT 65430
-#define VK_NP_RIGHT 65432
+#define VK_NP_DOWN Qt::Key_Down
+#define VK_NP_UP Qt::Key_Up
+#define VK_NP_LEFT Qt::Key_Left
+#define VK_NP_RIGHT Qt::Key_Right
-#define VK_RETURN GDK_KEY_Return
-#define VK_ESCAPE GDK_KEY_Escape
-#define VK_F5 GDK_KEY_F5
-#define VK_F1 GDK_KEY_F1
+#define VK_RETURN Qt::Key_Return
+#define VK_ESCAPE Qt::Key_Escape
+#define VK_F5 Qt::Key_F5
+#define VK_F1 Qt::Key_F1
-#define VK_OEM_PLUS GDK_KEY_plus
-#define VK_OEM_MINUS GDK_KEY_minus
-#define VK_OEM_PERIOD GDK_KEY_period
-#define VK_OEM_COMMA GDK_KEY_comma
+#define VK_OEM_PLUS Qt::Key_Plus
+#define VK_OEM_MINUS Qt::Key_Minus
+#define VK_OEM_PERIOD Qt::Key_Period
+#define VK_OEM_COMMA Qt::Key_Comma
-#define VK_DELETE GDK_KEY_Delete
-#define VK_NP_DELETE GDK_KEY_KP_Delete
+#define VK_DELETE Qt::Key_Delete
+#define VK_NP_DELETE Qt::Key_Delete
-// #define VK_OEM_1 GDK_KEY_colon // GDK_KEY_semicolon
-// #define VK_OEM_2 GDK_KEY_question // GDK_KEY_slash
-// #define VK_OEM_5 GDK_KEY_backslash // GDK_KEY_bar
+#define VK_OEM_1 Qt::Key_Colon // GDK_KEY_semicolon
+#define VK_OEM_2 Qt::Key_Question // GDK_KEY_slash
+#define VK_OEM_5 Qt::Key_Backslash // GDK_KEY_bar
/// Window brushes
#define BS_SOLID 0x00000001L
@@ -140,10 +148,14 @@ extern QGroupBox* CursorObject;
extern HWID view;
extern HTVC column;
+// Timer IDs associated with the main window.
+extern int CursorTimer;
+extern int SimulateTimer;
+
/// Structures
typedef struct OpenFileInfoData {
DWORD lStructSize;
- HWID *parentWindow;
+ HWID parentWindow;
LPTSTR lpstrFile;
LPCTSTR lpstrFilter;
DWORD nMaxFile;
@@ -158,11 +170,25 @@ typedef struct TimerRecordTag {
UINT utID;
} TimerRecord;
+/******************************************************************
+Class to create slots for signals
+
+*******************************************************************/
+class ProgramSlots : public QObject
+{
+ Q_OBJECT
+ public:
+ signals:
+ public slots:
+ void LD_WM_Command_call(int CommandCode);
+};
+
/// Variables
extern COLORREF HdcCurrentTextColor;
extern std::vector<TimerRecord> timerRecords;
extern int GLOBAL_mouse_last_clicked_x;
extern int GLOBAL_mouse_last_clicked_y;
+extern ProgramSlots MenuHandle;
/// functions
BOOL GetFocus(HWID window);
@@ -175,7 +201,8 @@ int MessageBox(
HWID pWindow,
char* message,
char* title,
- UINT mFlags);
+ UINT mFlags,
+ UINT iFlags);
BOOL GetSaveFileName(OPENFILENAME *ofn);
@@ -283,6 +310,8 @@ class PaintWidget : public QWidget
Q_OBJECT
public:
// MyWidget();
+ // PaintWidget(QWidget* parent): QWidget(parent)
+ // {}
protected:
void paintEvent(QPaintEvent *event);
diff --git a/ldmicro/loadsave.cpp b/ldmicro/loadsave.cpp
index a1895a5..b07ec4b 100644
--- a/ldmicro/loadsave.cpp
+++ b/ldmicro/loadsave.cpp
@@ -235,6 +235,7 @@ static ElemSubcktParallel *LoadParallelFromFile(FILE *f)
for(;;) {
if(!fgets(line, sizeof(line), f)) return NULL;
+ ManageLineEnding(line);
char *s = line;
while(isspace(*s)) s++;
@@ -275,6 +276,7 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f)
for(;;) {
if(!fgets(line, sizeof(line), f)) return NULL;
+ ManageLineEnding(line);
char *s = line;
@@ -305,6 +307,16 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f)
}
}
+void ManageLineEnding(char* line)
+{
+ int charlen = strlen(line) - 2;
+ if(line[charlen] == '\r')
+ {
+ line[charlen++] = '\n';
+ line[charlen] = '\0';
+ }
+}
+
//-----------------------------------------------------------------------------
// Load a project from a saved project description files. This describes the
// program, the target processor, plus certain configuration settings (cycle
@@ -323,6 +335,7 @@ BOOL LoadProjectFromFile(char *filename)
int crystal, cycle, baud;
while(fgets(line, sizeof(line), f)) {
+ ManageLineEnding(line);
if(strcmp(line, "IO LIST\n")==0) {
if(!LoadIoListFromFile(f)) {
fclose(f);
@@ -359,6 +372,7 @@ BOOL LoadProjectFromFile(char *filename)
int rung;
for(rung = 0;;) {
if(!fgets(line, sizeof(line), f)) break;
+ ManageLineEnding(line);
if(strcmp(line, "RUNG\n")!=0) goto failed;
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index fa45cdd..be15552 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -537,6 +537,7 @@ void MakeMainWindowControls(void)
PackBoxMenu->setMenuBar(MainMenu);
IoList = new QTreeWidget();
IoList->setColumnCount(IO_COLUMN_COUNT);
+ IoList->setSelectionMode(QAbstractItemView::SingleSelection);
QStringList ColumnNames = {"Name",
"Type",
"State",
@@ -552,8 +553,10 @@ void MakeMainWindowControls(void)
DWSize.setHeight(MainWindow->height() - IoListHeight);
DWSize.setWidth(MainWindow->width());
DrawWindow->setMinimumHeight(100);
- splitter->addWidget(DrawWindow);
DrawWindow->resize(DWSize);
+ WM_SCROLL scrollbar = new QScrollArea();
+ scrollbar->setWidget(DrawWindow);
+ splitter->addWidget(scrollbar);
/*QPalette pal = QPalette();
pal.setColor(QPalette::Background, Qt::black);
DrawWindow->setAutoFillBackground(true);
@@ -841,7 +844,7 @@ void HscrollProc(int wParam)
// InvalidateRect(MainWindow, NULL, FALSE);
// }
}
-
+*/
//-----------------------------------------------------------------------------
// Set up the title bar text for the main window; indicate whether we are in
// simulation or editing mode, and indicate the filename.
@@ -864,9 +867,10 @@ void UpdateMainWindowTitleBar(void)
strcat(line, " - (not yet saved)");
}
- gtk_window_set_title (GTK_WINDOW (MainWindow), line);
+ // gtk_window_set_title (GTK_WINDOW (MainWindow), line);
+ MainWindow->setWindowTitle(line);
}
-*/
+
//-----------------------------------------------------------------------------
// Set the enabled state of the logic menu items to reflect where we are on
// the schematic (e.g. can't insert two coils in series).
@@ -1015,58 +1019,37 @@ void ToggleSimulationMode(void)
//-----------------------------------------------------------------------------
void RefreshControlsToSettings(void)
{
- /*GtkTreeIter iter;
- BOOL path_not_empty = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(IoList), &iter);
- // g_print("path e = %i\n", path_not_empty);
-
- int * ip;
- int i = 0;
-
-
+ /*QList<QTreeWidgetItem *> items;
+ // sl.add()
+ QStringList sl;
+ sl.insert(0,"Item1");
+ sl.insert(3,"Item11");
+ items.append(new QTreeWidgetItem(sl));
+ items.append(new QTreeWidgetItem(QStringList(QString("Item2"))));
+ items.append(new QTreeWidgetItem(QStringList(QString("Item3"))));
+ IoList->insertTopLevelItems(0, items);*/
+ QTreeWidgetItem iter;
+ QTreeWidgetItem* selection;
if(!IoListOutOfSync) {
- IoListSelectionPoint = -1;
-
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-
- GtkTreeModel *IoModelPtr;
- if(gtk_tree_selection_get_selected (selection, &IoModelPtr, &iter))
- {
- GtkTreePath *path = gtk_tree_model_get_path ( IoModelPtr, &iter ) ;
- ip = gtk_tree_path_get_indices ( path ) ;
- i = ip[0];
- IoListSelectionPoint = i;
- }
+ selection = IoList->currentItem();
+ IoListSelectionPoint =IoList->indexOfTopLevelItem(selection);
}
-
- gtk_list_store_clear (GTK_LIST_STORE(IoList));
-
- /// Fill IO List
NMHDR h;
h.code = LVN_GETDISPINFO;
h.hlistFrom = IoList;
-
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL(IoList), &iter);
- for(i = 0; i < Prog.io.count; i++) {
- gtk_list_store_append (GTK_LIST_STORE(IoList), &iter);
+ // printf("ioCount:%d\n",Prog.io.count);
+ IoList->clear();
+ h.hlistIter.clear();
+ for(int i = 0; i < Prog.io.count; i++) {
h.item.iItem = i;
- h.hlistIter = &iter;
IoListProc(&h);
}
-
- if(IoListSelectionPoint >= 0) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-
- gtk_tree_selection_unselect_all (selection);
- GtkTreePath *path = gtk_tree_path_new_from_indices ( IoListSelectionPoint, -1);
- gtk_tree_selection_select_path (selection, path);
-
- // ListView_EnsureVisible(IoList, IoListSelectionPoint, FALSE);
+ IoList->insertTopLevelItems(0, h.hlistIter);
+ if(IoListSelectionPoint >= 0)
+ {
+ IoList->setCurrentItem(IoList->topLevelItem(IoListSelectionPoint));
}
- IoListOutOfSync = FALSE;
-*/
if(Prog.mcu) {
StatusBar[0]->setText(Prog.mcu->mcuName);
}
@@ -1087,8 +1070,8 @@ void RefreshControlsToSettings(void)
}
StatusBar[2]->setText(buf);
-/*
- for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
+
+ for(int i = 0; i < NUM_SUPPORTED_MCUS; i++) {
if(&SupportedMcus[i] == Prog.mcu) {
CheckMenuItem(ProcessorMenu, ProcessorMenuItems[i], MF_CHECKED);
}
@@ -1102,7 +1085,7 @@ void RefreshControlsToSettings(void)
}
else {
CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_UNCHECKED);
- }*/
+ }
}
//-----------------------------------------------------------------------------
@@ -1111,42 +1094,14 @@ void RefreshControlsToSettings(void)
//-----------------------------------------------------------------------------
void GenerateIoListDontLoseSelection(void)
{
- /*GtkTreeIter iter;
- BOOL path_not_empty = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(IoList), &iter);
- // g_print("path e = %i\n", path_not_empty);
-
- int * i ;
- IoListSelectionPoint = -1;
-
- // GtkTreeSelection * tsel = gtk_tree_view_get_selection (tv);
- // GtkTreeModel * tm ;
- GtkTreePath * path ;
- GtkTreeModel *IoModelPtr;
-
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
- if(gtk_tree_selection_get_selected (selection, &IoModelPtr, &iter))
- {
- path = gtk_tree_model_get_path ( IoModelPtr , &iter ) ;
- i = gtk_tree_path_get_indices ( path ) ;
- IoListSelectionPoint = i[0];
- }*/
- // gtk_tree_model_iter_next (GTK_TREE_MODEL(IoList), iter);
- // BOOL iter_v = gtk_list_store_iter_is_valid(GTK_LIST_STORE(IoList), iter);
- // g_print("iter = %i\n", iter_v);
-
-
- // if ( gtk_tree_selection_get_selected ( tsel , &tm , &iter ) )
- // {
-
- // return i [ 0 ] ;
- // }
-
- /*IoListSelectionPoint = GenerateIoList(IoListSelectionPoint);
+ QTreeWidgetItem* selection;
+ selection = IoList->currentItem();
+ IoListSelectionPoint =IoList->indexOfTopLevelItem(selection);
+ IoListSelectionPoint = GenerateIoList(IoListSelectionPoint);
// can't just update the listview index; if I/O has been added then the
// new selection point might be out of range till we refill it
- IoListOutOfSync = TRUE;*/
+ IoListOutOfSync = TRUE;
RefreshControlsToSettings();
}
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index b2a61ec..a656183 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -514,7 +514,7 @@ void EditElementMouseDoubleclick(int x, int y)
gy += ScrollYOffset;
- /*if(InSimulationMode) {
+ if(InSimulationMode) {
ElemLeaf *l = DisplayMatrix[gx][gy];
if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) {
char *name = l->d.contacts.name;
@@ -522,13 +522,13 @@ void EditElementMouseDoubleclick(int x, int y)
SimulationToggleContact(name);
}
} else if(l && DisplayMatrixWhich[gx][gy] == ELEM_READ_ADC) {
- ShowAnalogSliderPopup(l->d.readAdc.name);
+ // ShowAnalogSliderPopup(l->d.readAdc.name);
}
} else {
if(DisplayMatrix[gx][gy] == Selected) {
EditSelectedElement();
}
- }*/
+ }
}
//-----------------------------------------------------------------------------
diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp
index 61c691c..3cd9212 100644
--- a/ldmicro/simulate.cpp
+++ b/ldmicro/simulate.cpp
@@ -125,6 +125,7 @@ static void SetSingleBit(char *name, BOOL state)
{
int i;
for(i = 0; i < SingleBitItemsCount; i++) {
+ // printf("%s,%d\n", name, SingleBitOn(name));
if(strcmp(SingleBitItems[i].name, name)==0) {
SingleBitItems[i].powered = state;
return;
@@ -801,6 +802,7 @@ void DescribeForIoList(char *name, char *out)
void SimulationToggleContact(char *name)
{
SetSingleBit(name, !SingleBitOn(name));
+ RefreshControlsToSettings();
// ListView_RedrawItems(IoList, 0, Prog.io.count - 1);
}
diff --git a/ldmicro/txt2c.pl b/ldmicro/txt2c.pl
index a2745dc..a2745dc 100644..100755
--- a/ldmicro/txt2c.pl
+++ b/ldmicro/txt2c.pl