summaryrefslogtreecommitdiff
path: root/ldmicro
diff options
context:
space:
mode:
authorakshay-c2019-05-07 10:50:36 +0530
committerakshay-c2019-05-07 10:50:36 +0530
commitf6250bab468eadfc020922040966d6ba75edd341 (patch)
tree7facc6d3fd89c0c23bce197ca9eb67fd2b20a185 /ldmicro
parent46fbe3ae31bb5687f31b17acac4c449699876f2f (diff)
downloadLDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.tar.gz
LDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.tar.bz2
LDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.zip
Uncommented Titlebar Update Calls at places; Code beautification and code cleaning
Diffstat (limited to 'ldmicro')
-rw-r--r--ldmicro/CMakeLists.txt2
-rw-r--r--ldmicro/arduino.cpp45
-rw-r--r--ldmicro/commentdialog.cpp13
-rw-r--r--ldmicro/confdialog.cpp114
-rw-r--r--ldmicro/contactsdialog.cpp19
-rw-r--r--ldmicro/draw.cpp43
-rw-r--r--ldmicro/draw_outputdev.cpp86
-rw-r--r--ldmicro/helpdialog.cpp17
-rw-r--r--ldmicro/includes/ldmicro.h3
-rw-r--r--ldmicro/iolist.cpp296
-rw-r--r--ldmicro/ldmicro.cpp574
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.cpp28
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp90
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h22
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp113
-rw-r--r--ldmicro/loadsave.cpp43
-rw-r--r--ldmicro/lutdialog.cpp13
-rw-r--r--ldmicro/maincontrols.cpp492
-rw-r--r--ldmicro/miscutil.cpp71
-rw-r--r--ldmicro/resetdialog.cpp31
-rw-r--r--ldmicro/simpledialog.cpp2
-rw-r--r--ldmicro/simulate.cpp102
-rw-r--r--ldmicro/undoredo.cpp4
23 files changed, 184 insertions, 2039 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index 6ee451d..66cd49c 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -168,7 +168,7 @@ endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "2")
- set(CPACK_PACKAGE_VERSION_PATCH "4")
+ set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_PACKAGE_DESCRIPTION "Ladder Logic editor, simulator and compiler for 8 bit microcontrollers")
diff --git a/ldmicro/arduino.cpp b/ldmicro/arduino.cpp
index af8090b..41b31b1 100644
--- a/ldmicro/arduino.cpp
+++ b/ldmicro/arduino.cpp
@@ -97,34 +97,29 @@ static int EepromHighByteWaitingBit;
// Some useful registers, unfortunately many of which are in different places
// on different AVRs! I consider this a terrible design choice by Atmel.
-static DWORD REG_TIMSK1; //====Need to come back to
-//static DWORD REG_TIFR0; //====Need to come back to
-static DWORD REG_TIFR1; //====Need to come back to
-//static DWORD REG_TIFR2; //====Need to come back to
+static DWORD REG_TIMSK1;
+static DWORD REG_TIFR1;
#define REG_OCR1AH 0x89
#define REG_OCR1AL 0x88
#define REG_TCCR1A 0x80
#define REG_TCCR1B 0x81
-#define REG_TCCR1C 0x82 //====Newly added. Need to check working
+#define REG_TCCR1C 0x82
#define REG_SPH 0x5e
#define REG_SPL 0x5d
#define REG_ADMUX 0x7C
#define REG_ADCSRA 0x7A
-//#define REG_ADCSRB 0x7B //====Newly added. Need to check if needed
#define REG_ADCL 0x78
#define REG_ADCH 0x79
-static DWORD REG_UBRRH; //====Need to come back to
-static DWORD REG_UBRRL; //====Need to come back to
-//static DWORD REG_UCSRC; //====Need to come back to
-static DWORD REG_UCSRB; //====Need to come back to
-static DWORD REG_UCSRA; //====Need to come back to
-static DWORD REG_UDR; //====Need to come back to ---------------------------------------------------------------->3:39 PM 4/10/2015
+static DWORD REG_UBRRH;
+static DWORD REG_UBRRL;
+static DWORD REG_UCSRB;
+static DWORD REG_UCSRA;
+static DWORD REG_UDR;
#define REG_OCR2A 0xB3
-//#define REG_OCR2B 0xB4 //====Newly added. Need to check if needed and use
#define REG_TCCR2A 0xB0
-#define REG_TCCR2B 0xB1 //====Newly added. Need to check if needed
+#define REG_TCCR2B 0xB1
#define REG_EEARH 0x42
#define REG_EEARL 0x41
@@ -427,7 +422,10 @@ static void WriteHexFile(FILE *f)
DWORD i;
for(i = 0; i < ArduinoProgWriteP; i++) {
- DWORD w = Assemble(i, ArduinoProg[i].op, ArduinoProg[i].arg1, ArduinoProg[i].arg2);
+ DWORD w = Assemble(i,
+ ArduinoProg[i].op,
+ ArduinoProg[i].arg1,
+ ArduinoProg[i].arg2);
if(soFarCount == 0) soFarStart = i;
soFar[soFarCount++] = (BYTE)(w & 0xff);
@@ -660,7 +658,7 @@ static void WriteRuntime(void)
WriteMemory(REG_UBRRH, divisor >> 8);
WriteMemory(REG_UBRRL, divisor & 0xff);
- WriteMemory(REG_UCSRB, (1 << 4) | (1 << 3)); // RXEN, TXEN ===>may need to change later on ucsr0b is the registername here
+ WriteMemory(REG_UCSRB, (1 << 4) | (1 << 3));
for(i = 0; i < Prog.mcu->pinCount; i++) {
if(Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.txPin) {
@@ -753,8 +751,6 @@ static void CallSubroutine(DWORD addr)
}
}
-//==================================================================================>>4:24 PM 3/31/2015
-
//-----------------------------------------------------------------------------
// Compile the intermediate code to AVR native code.
//-----------------------------------------------------------------------------
@@ -1023,8 +1019,7 @@ static void CompileFromIntermediate(void)
case 1024: cs = 5; break;
default: oops(); break;
}
-
- // fast PWM mode, non-inverted operation, given prescale ==================================================12:27 PM 4/1/2015
+
WriteMemory(REG_TCCR2A, (1 << 7) | (1 << 1) | (1 << 0));
WriteMemory(REG_TCCR2B, cs);
@@ -1327,18 +1322,13 @@ void CompileArduino(char *outFile)
// Here we must set up the addresses of some registers that for some
// stupid reason move around from AVR to AVR.
- //REG_TIMSK0 = 0x6E;
REG_TIMSK1 = 0x6F;
- //REG_TIMSK2 = 0x70;
- //REG_TIFR0 = 0x35;
REG_TIFR1 = 0x36;
- //REG_TIFR2 = 0x37;
REG_UBRRH = 0xC5;
REG_UBRRL = 0xC4;
- //REG_UCSRC = 0xC2;
REG_UCSRB = 0xC1;
REG_UCSRA = 0xC0;
- REG_UDR = 0xC6; //---------------------------------------------------------------------------->12:19 PM 4/10/2015
+ REG_UDR = 0xC6;
WipeMemory();
MultiplyUsed = FALSE;
@@ -1377,5 +1367,4 @@ void CompileArduino(char *outFile)
"Remember to set the processor configuration (fuses) correctly. "
"This does not happen automatically."), outFile);
CompileSuccessfulMessage(str);
-}
-//====================================================================================================================>4:34 PM 4/1/2015 \ No newline at end of file
+} \ No newline at end of file
diff --git a/ldmicro/commentdialog.cpp b/ldmicro/commentdialog.cpp
index 66832ef..1b7bffe 100644
--- a/ldmicro/commentdialog.cpp
+++ b/ldmicro/commentdialog.cpp
@@ -42,8 +42,14 @@ static void MakeControls(void)
CommentTextbox = new QLineEdit();
CommentGrid->addWidget(CommentTextbox, 0, 0);
CommentGrid->addWidget(ButtonBox, 0, 1);
- QObject::connect(ButtonBox, SIGNAL(accepted()), CommentDialog, SLOT(accept()));
- QObject::connect(ButtonBox, SIGNAL(rejected()), CommentDialog, SLOT(reject()));
+ QObject::connect(ButtonBox,
+ SIGNAL(accepted()),
+ CommentDialog,
+ SLOT(accept()));
+ QObject::connect(ButtonBox,
+ SIGNAL(rejected()),
+ CommentDialog,
+ SLOT(reject()));
FixedFont(CommentTextbox);
}
@@ -66,7 +72,8 @@ void ShowCommentDialog(char *comment)
{
case QDialog::Accepted:
{
- strncpy(comment, CommentTextbox->text().toStdString().c_str(),
+ strncpy(comment,
+ CommentTextbox->text().toStdString().c_str(),
MAX_COMMENT_LEN -1);
}
diff --git a/ldmicro/confdialog.cpp b/ldmicro/confdialog.cpp
index d7eee19..7bf0844 100644
--- a/ldmicro/confdialog.cpp
+++ b/ldmicro/confdialog.cpp
@@ -104,7 +104,8 @@ static void MakeControls(void)
}
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") );
+ "are in use; add one to program before setting baud rate.\r\n\r\n")
+ );
}
strcat(explanation,
@@ -136,93 +137,11 @@ static void MakeControls(void)
Qt::AlignJustify);
NiceFont(ConfDialog);
CycleTextbox->setFocus();
- // int height = textLabel4->pos().y();
- // printf("Height:%d\n", height);
- // ConfDialog->setSize(ConfGrid->sizeHint());
ConfDialog->adjustSize();
QObject::connect(ButtonBox, SIGNAL(accepted()), ConfDialog, SLOT(accept()));
QObject::connect(ButtonBox, SIGNAL(rejected()), ConfDialog, SLOT(reject()));
-// PrevCycleProc = SetWindowLongPtr(CycleTextbox, GWLP_WNDPROC,
-// (LONG_PTR)MyNumberProc);
-
-// PrevCrystalProc = SetWindowLongPtr(CrystalTextbox, GWLP_WNDPROC,
-// (LONG_PTR)MyNumberProc);
-
-// PrevBaudProc = SetWindowLongPtr(BaudTextbox, GWLP_WNDPROC,
-// (LONG_PTR)MyNumberProc);
-}
-/*
-//-----------------------------------------------------------------------------
-// Don't allow any characters other than 0-9. in the text boxes.
-//-----------------------------------------------------------------------------
-
-void ConfDialogMyNumberProc (GtkEditable *editable, gchar *NewText, gint length,
- gint *position, gpointer data){
- gtk_widget_set_sensitive (MainWindow, TRUE);
- for (int i = 0; i < length; i++){
- if (!(isdigit (NewText[i]) || NewText[i] == '.' || NewText[i] == '\b')){
- g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
- return;
- }
- }
-}
-
-// Gets data from the text boxes
-void ConfDialogGetData (GtkWidget* widget, gpointer data){
- 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);
- DestroyWindow (ConfDialog);
- ProgramChanged();
-}
-
-// Checks for the required key press
-gboolean ConfDialogKeyPress (GtkWidget* widget, GdkEventKey* event, gpointer data){
- if (event -> keyval == GDK_KEY_Return){
- ConfDialogGetData(NULL, NULL);
- }
- else if (event -> keyval == GDK_KEY_Escape){
- DestroyWindow (ConfDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
- }
- return FALSE;
-}
-
-void ConfCallDestroyWindow (HWID widget, gpointer data){
- DestroyWindow (ConfDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
}
-// Consists of all the signal calls
-void ConfDialogSignalCall () {
- g_signal_connect (G_OBJECT(CycleTextbox), "insert-text",
- G_CALLBACK(ConfDialogMyNumberProc), NULL);
- g_signal_connect (G_OBJECT(CrystalTextbox), "insert-text",
- G_CALLBACK(ConfDialogMyNumberProc), NULL);
- g_signal_connect (G_OBJECT(BaudTextbox), "insert-text",
- G_CALLBACK(ConfDialogMyNumberProc), NULL);
- g_signal_connect (G_OBJECT (ConfDialog), "key-press-event",
- G_CALLBACK(ConfDialogKeyPress), NULL);
- g_signal_connect (G_OBJECT (OkButton), "clicked",
- G_CALLBACK(ConfDialogGetData), NULL);
- g_signal_connect (G_OBJECT (CancelButton), "clicked",
- G_CALLBACK(ConfCallDestroyWindow), NULL);
- g_signal_connect (ConfDialog, "delete_event", G_CALLBACK (ConfCallDestroyWindow), NULL);
-}
-*/
void ShowConfDialog(void)
{
// The window's height will be resized later, to fit the explanation text.
@@ -262,34 +181,5 @@ void ShowConfDialog(void)
case QDialog::Rejected:
break;
}
- // DestroyWindow();
-/* GdkEventKey* event;
-
- 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), ConfPackingBox);
- gtk_widget_add_events (ConfDialog, GDK_KEY_PRESS_MASK);
- gtk_widget_add_events (ConfDialog, GDK_BUTTON_PRESS_MASK);
-
- 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, FALSE);
- gtk_widget_grab_focus (OkButton);
- gtk_widget_set_state_flags (CycleTextbox, GTK_STATE_FLAG_FOCUSED, TRUE);
- gtk_widget_grab_focus (CycleTextbox);
- gtk_widget_show_all (ConfDialog);
-
- ConfDialogSignalCall();
- return;*/
} \ No newline at end of file
diff --git a/ldmicro/contactsdialog.cpp b/ldmicro/contactsdialog.cpp
index 35c1c65..40d8055 100644
--- a/ldmicro/contactsdialog.cpp
+++ b/ldmicro/contactsdialog.cpp
@@ -53,9 +53,12 @@ static void MakeControls(void)
ContactsGrid->setSpacing(3);
SourceGrid->setSpacing(3);
- SourceInternalRelayRadio = new QRadioButton(_("Internal Relay"), ContactsDialog);
- SourceInputPinRadio = new QRadioButton(_("Input pin"), ContactsDialog);
- SourceOutputPinRadio = new QRadioButton(_("Output pin"), ContactsDialog);
+ SourceInternalRelayRadio = new QRadioButton(_("Internal Relay"),
+ ContactsDialog);
+ SourceInputPinRadio = new QRadioButton(_("Input pin"),
+ ContactsDialog);
+ SourceOutputPinRadio = new QRadioButton(_("Output pin"),
+ ContactsDialog);
SourceGrid->addWidget(SourceInternalRelayRadio,0,0);
SourceGrid->addWidget(SourceInputPinRadio,1,0);
SourceGrid->addWidget(SourceOutputPinRadio,2,0);
@@ -74,8 +77,14 @@ static void MakeControls(void)
ContactsGrid->addWidget(grouper,0,0);
ContactsGrid->addLayout(NameGrid,0,1);
ContactsGrid->addWidget(ButtonBox,0,2);
- QObject::connect(ButtonBox, SIGNAL(accepted()), ContactsDialog, SLOT(accept()));
- QObject::connect(ButtonBox, SIGNAL(rejected()), ContactsDialog, SLOT(reject()));
+ QObject::connect(ButtonBox,
+ SIGNAL(accepted()),
+ ContactsDialog,
+ SLOT(accept()));
+ QObject::connect(ButtonBox,
+ SIGNAL(rejected()),
+ ContactsDialog,
+ SLOT(reject()));
}
static inline void DestroyWindow (){
diff --git a/ldmicro/draw.cpp b/ldmicro/draw.cpp
index fd16b97..0adba74 100644
--- a/ldmicro/draw.cpp
+++ b/ldmicro/draw.cpp
@@ -336,8 +336,8 @@ static void CenterWithSpaces(HCRDC Hcr, int cx, int cy, char *str, BOOL powered,
// Like CenterWithWires, but for an arbitrary width position (e.g. for ADD
// and SUB, which are double-width).
//-----------------------------------------------------------------------------
-static void CenterWithWiresWidth(HCRDC Hcr, int cx, int cy,const char *str, BOOL before,
- BOOL after, int totalWidth)
+static void CenterWithWiresWidth(HCRDC Hcr, int cx, int cy,const char *str,
+ BOOL before, BOOL after, int totalWidth)
{
int extra = totalWidth - FormattedStrlen(str);
@@ -360,7 +360,8 @@ static void CenterWithWiresWidth(HCRDC Hcr, int cx, int cy,const char *str, BOOL
// the left and right coloured according to the powered state. Draws on the
// middle line.
//-----------------------------------------------------------------------------
-static void CenterWithWires(HCRDC Hcr, int cx, int cy, const char *str, BOOL before, BOOL after)
+static void CenterWithWires(HCRDC Hcr, int cx, int cy, const char *str,
+ BOOL before, BOOL after)
{
CenterWithWiresWidth(Hcr, cx, cy, str, before, after, POS_WIDTH);
}
@@ -369,8 +370,8 @@ static void CenterWithWires(HCRDC Hcr, int cx, int cy, const char *str, BOOL bef
// Draw an end of line element (coil, RES, MOV, etc.). Special things about
// an end of line element: we must right-justify it.
//-----------------------------------------------------------------------------
-static BOOL DrawEndOfLine(HCRDC Hcr, int which, ElemLeaf *leaf, int *cx, int *cy,
- BOOL poweredBefore)
+static BOOL DrawEndOfLine(HCRDC Hcr, int which, ElemLeaf *leaf,
+ int *cx, int *cy, BOOL poweredBefore)
{
int cx0 = *cx, cy0 = *cy;
@@ -460,8 +461,10 @@ static BOOL DrawEndOfLine(HCRDC Hcr, int which, ElemLeaf *leaf, int *cx, int *cy
break;
}
case ELEM_PERSIST:
- CenterWithSpaces(Hcr, *cx, *cy, leaf->d.persist.var, poweredAfter, TRUE);
- CenterWithWires(Hcr, *cx, *cy, "{PERSIST}", poweredBefore, poweredAfter);
+ CenterWithSpaces(Hcr, *cx, *cy, leaf->d.persist.var,
+ poweredAfter, TRUE);
+ CenterWithWires(Hcr, *cx, *cy, "{PERSIST}", poweredBefore,
+ poweredAfter);
break;
case ELEM_MOVE: {
@@ -611,8 +614,8 @@ static BOOL DrawEndOfLine(HCRDC Hcr, int which, ElemLeaf *leaf, int *cx, int *cy
int extra = 2*POS_WIDTH - FormattedStrlen(top);
PoweredText(Hcr, poweredAfter);
DrawChars(Hcr, *cx + (extra/2), *cy + (POS_HEIGHT/2) - 1, top);
- CenterWithWiresWidth(Hcr, *cx, *cy, bot, poweredBefore, poweredAfter,
- 2*POS_WIDTH);
+ CenterWithWiresWidth(Hcr, *cx, *cy, bot, poweredBefore,
+ poweredAfter, 2*POS_WIDTH);
*cx += POS_WIDTH;
@@ -725,12 +728,14 @@ cmp:
break;
}
case ELEM_OPEN:
- CenterWithWires(Hcr, *cx, *cy, "+ +", poweredBefore, poweredAfter);
+ CenterWithWires(Hcr, *cx, *cy, "+ +", poweredBefore,
+ poweredAfter);
*cx += POS_WIDTH;
break;
case ELEM_SHORT:
- CenterWithWires(Hcr, *cx, *cy, "+------+", poweredBefore, poweredAfter);
+ CenterWithWires(Hcr, *cx, *cy, "+------+", poweredBefore,
+ poweredAfter);
*cx += POS_WIDTH;
break;
@@ -803,7 +808,8 @@ cmp:
char str[POS_WIDTH*2];
memset(str, 0, sizeof(str));
char *srcStr = leaf->d.fmtdStr.string;
- memcpy(str, srcStr, std::min<size_t>(strlen(srcStr), (size_t)(POS_WIDTH*2 - 7) ));
+ memcpy(str, srcStr, std::min<size_t>(strlen(srcStr),
+ (size_t)(POS_WIDTH*2 - 7) ));
char bot[100];
sprintf(bot, "{\"%s\"}", str);
@@ -815,8 +821,8 @@ cmp:
leaf->d.fmtdStr.var);
BodyText(Hcr);
- CenterWithWiresWidth(Hcr, *cx, *cy, bot, poweredBefore, poweredAfter,
- 2*POS_WIDTH);
+ CenterWithWiresWidth(Hcr, *cx, *cy, bot, poweredBefore,
+ poweredAfter, 2*POS_WIDTH);
*cx += 2*POS_WIDTH;
break;
}
@@ -825,12 +831,14 @@ cmp:
CenterWithWires(Hcr, *cx, *cy,
(which == ELEM_UART_RECV) ? "{UART RECV}" : "{UART SEND}",
poweredBefore, poweredAfter);
- CenterWithSpaces(Hcr, *cx, *cy, leaf->d.uart.name, poweredAfter, TRUE);
+ CenterWithSpaces(Hcr, *cx, *cy, leaf->d.uart.name,
+ poweredAfter, TRUE);
*cx += POS_WIDTH;
break;
default:
- poweredAfter = DrawEndOfLine(Hcr, which, leaf, cx, cy, poweredBefore);
+ poweredAfter = DrawEndOfLine(Hcr, which, leaf,
+ cx, cy, poweredBefore);
break;
}
@@ -926,7 +934,8 @@ cmp:
// element, else FALSE. This is needed to colour all the wires correctly,
// since the colouring indicates whether a wire is energized.
//-----------------------------------------------------------------------------
-BOOL DrawElement(HCRDC Hcr, int which, void *elem, int *cx, int *cy, BOOL poweredBefore)
+BOOL DrawElement(HCRDC Hcr, int which, void *elem,
+ int *cx, int *cy, BOOL poweredBefore)
{
BOOL poweredAfter;
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index c37dc27..1b3921d 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -95,20 +95,11 @@ BOOL BlinkCursor(BOOL kill = FALSE)
QRect c;
c = Cursor;
- c.setTop(c.top() - /*ScrollYOffset**/POS_HEIGHT*FONT_HEIGHT);
- c.setLeft(c.left() /*- ScrollXOffset*/);
- // if(c.top() >= IoListTop) return TRUE;
-
- /*if(c.top() + c.height() >= IoListTop) {
- c.setHeight(IoListTop - c.top() - 3);
- }*/
+ c.setTop(c.top() - POS_HEIGHT*FONT_HEIGHT);
+ c.setLeft(c.left());
if(DrawWindow == NULL)
return FALSE;
- // if(!GDK_IS_DRAWING_CONTEXT(Hdc))
- // return FALSE;
-
- // HCRDC Hcr = gdk_cairo_create(gtk_widget_get_window(DrawWindow));
HWID Hcr = DrawWindow;
static int PREV_x = c.left();
@@ -116,7 +107,8 @@ BOOL BlinkCursor(BOOL kill = FALSE)
static int PREV_w = c.width();
static int PREV_h = c.height();
- if (PREV_x != c.left() || PREV_y != c.top() || PREV_w != c.width() || PREV_h != c.height())
+ if (PREV_x != c.left() || PREV_y != c.top() ||
+ PREV_w != c.width() || PREV_h != c.height())
{
CursorObject->setGeometry(c);
CursorObject->setVisible(TRUE);
@@ -124,22 +116,14 @@ 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);
- // gtk_widget_queue_draw(DrawWindow);
}
CursorObject->setGeometry(Cursor);
if (CursorObject->isVisible())
CursorObject->setVisible(FALSE);
else
- // PatBlt(Hcr, c.left(), c.top(), c.width(), c.height(), PATINVERT, (HBRUSH)GetStockObject(BLACK_BRUSH));
CursorObject->setVisible(TRUE);
InvalidateRect(DrawWindow, NULL, FALSE);
- // cairo_destroy(Hcr);
- // CursorDrawn = !CursorDrawn;
return !kill;
}
@@ -150,10 +134,7 @@ BOOL BlinkCursor(BOOL kill = FALSE)
//-----------------------------------------------------------------------------
static void DrawCharsToScreen(HCRDC Hcr, int cx, int cy, const char *str)
{
- // cy -= ScrollYOffset*POS_HEIGHT;
if(cy < -2) return;
- // if(cy*FONT_HEIGHT + Y_PADDING > IoListTop) return;
- // IoListTop not initialized.
COLORREF prev;
BOOL firstTime = TRUE;
@@ -387,14 +368,6 @@ void PaintWidget::paintEvent(QPaintEvent *event)
CursorDrawn = FALSE;
- // BitBlt(paintDc, 0, 0, bw, bh, BackDc, ScrollXOffset, 0, SRCCOPY);
-
- /*if(InSimulationMode) {
- KillTimer(DrawWindow, TIMER_BLINK_CURSOR);
- } else {
- CursorTimer = SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 500, CursorTimer);
- }*/
-
ok();
}
@@ -594,54 +567,3 @@ void ExportDrawingAsText(char *file)
// we may have trashed the grid tables a bit; a repaint will fix that
InvalidateRect(MainWindow, NULL, FALSE);
}
-
-//-----------------------------------------------------------------------------
-// Determine the settings of the vertical and (if needed) horizontal
-// scrollbars used to scroll our view of the program.
-//-----------------------------------------------------------------------------
-void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert)
-{
-/* int totalHeight = 0;
- int i;
- for(i = 0; i < Prog.numRungs; i++) {
- totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
- totalHeight++;
- }
- totalHeight += 1; // for the end rung
-
- int totalWidth = ProgCountWidestRow();
-
- if(totalWidth <= ScreenColsAvailable()) {
- *horizShown = FALSE;
- ScrollXOffset = 0;
- ScrollXOffsetMax = 0;
- } else {
- *horizShown = TRUE;
- memset(horiz, 0, sizeof(*horiz));
- horiz->cbSize = sizeof(*horiz);
- // horiz->fMask = SIF_DISABLENOSCROLL | SIF_ALL;
- horiz->nMin = 0;
- horiz->nMax = X_PADDING + totalWidth*POS_WIDTH*FONT_WIDTH;
- RECT r;
- GetClientRect(DrawWindow, &r);
- horiz->nPage = r.right - X_PADDING;
- horiz->nPos = ScrollXOffset;
-
- ScrollXOffsetMax = horiz->nMax - horiz->nPage + 1;
- if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax;
- if(ScrollXOffset < 0) ScrollXOffset = 0;
- }
-
- vert->cbSize = sizeof(*vert);
- // vert->fMask = SIF_DISABLENOSCROLL | SIF_ALL;
- vert->nMin = 0;
- vert->nMax = totalHeight - 1;
- // vert->nPos = ScrollYOffset;
- vert->nPos = 0;
- vert->nPage = ScreenRowsAvailable();
-*/
- // ScrollYOffsetMax = vert->nMax - vert->nPage + 1;
-
- // if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax;
- // if(ScrollYOffset < 0) ScrollYOffset = 0;
-}
diff --git a/ldmicro/helpdialog.cpp b/ldmicro/helpdialog.cpp
index baf1389..3df325d 100644
--- a/ldmicro/helpdialog.cpp
+++ b/ldmicro/helpdialog.cpp
@@ -119,18 +119,15 @@ static void MakeControls(int a)
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);
+ qtfont.setStyle(FixedWidthFont->fdwItalic ?
+ QFont::StyleItalic : QFont::StyleNormal);
+ qtfont.setWeight(FixedWidthFont->fnWeight == FW_BOLD ?
+ QFont::Bold : QFont::Normal);
for(i = 0; Text[a][i]; i++) {
char *s = Text[a][i];
- // 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] == '='))
{
@@ -193,8 +190,6 @@ void ShowHelpDialog(BOOL about)
MakeControls(a);
- // 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);
@@ -206,9 +201,5 @@ void ShowHelpDialog(BOOL about)
RichEdit[a]->verticalScrollBar()->setValue(
RichEdit[a]->verticalScrollBar()->minimum());
- /*if(HelpWindowOpen[a]) {
- gtk_widget_grab_focus (HelpDialog[a]);
- return;
- }*/
HelpWindowOpen[a] = TRUE;
}
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 29583a2..a31c742 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -586,7 +586,7 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
BOOL canPushRungDown, BOOL canPushRungUp, BOOL canInsertComment);
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled);
-void RefreshScrollbars(void);
+// void RefreshScrollbars(void);
extern HINSTANCE Instance;
extern QApplication* LDmicroApp;
extern HWID MainWindow;
@@ -647,7 +647,6 @@ BOOL BlinkCursor(BOOL kill);
void PaintWindow();
void ExportDrawingAsText(char *file);
void InitForDrawing(void);
-void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert);
int ScreenRowsAvailable(void);
int ScreenColsAvailable(void);
extern HFONT FixedWidthFont;
diff --git a/ldmicro/iolist.cpp b/ldmicro/iolist.cpp
index dd66277..5d2f2d5 100644
--- a/ldmicro/iolist.cpp
+++ b/ldmicro/iolist.cpp
@@ -403,55 +403,6 @@ void SaveIoListToFile(FILE *f)
}
//-----------------------------------------------------------------------------
-// Dialog proc for the popup that lets you set the value of an analog input for
-// simulation.
-//-----------------------------------------------------------------------------
-/*static gboolean AnalogSliderDialogKeyboardProc(GtkWidget* widget, GdkEventKey* event, gpointer name)
-{
- SWORD v = (SWORD)gtk_range_get_value(GTK_RANGE(AnalogSliderTrackbar));
- SetAdcShadow((char*)name, v);
- if (AnalogSliderDone == TRUE || AnalogSliderCancel == TRUE)
- {
- DestroyWindow (AnalogSliderMain);
- ProgramChanged();
- return FALSE;
- }
-
- if (event->keyval == GDK_KEY_Return){
- DestroyWindow (AnalogSliderMain);
- ProgramChanged();
- AnalogSliderDone = TRUE;
- }
- else if (event->keyval == GDK_KEY_Escape){
- DestroyWindow (AnalogSliderMain);
- ProgramChanged();
- AnalogSliderDone = TRUE;
- AnalogSliderCancel = TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean AnalogSliderDialogMouseProc(GtkWidget *widget, GdkEventButton *event, gpointer name)
-{
- SWORD v = (SWORD)gtk_range_get_value(GTK_RANGE(AnalogSliderTrackbar));
- SetAdcShadow((char*)name, v);
- if (event->button == 1 && event->type == GDK_BUTTON_RELEASE){
- DestroyWindow (AnalogSliderMain);
- ProgramChanged();
- AnalogSliderDone = TRUE;
- }
-
- return FALSE;
-}
-
-void AnalogSliderUpdateProc (GtkRange *range, GtkScrollType step, gpointer name)
-{
- SWORD v = (SWORD)gtk_range_get_value(GTK_RANGE(AnalogSliderTrackbar));
- SetAdcShadow((char*)name, v);
-}
-*/
-//-----------------------------------------------------------------------------
// A little toolbar-style window that pops up to allow the user to set the
// simulated value of an ADC pin.
//-----------------------------------------------------------------------------
@@ -514,7 +465,6 @@ void ShowAnalogSliderPopup(char *name)
std::bind( &Receiver::updateValue, receiver, "senderValue", std::placeholders::_1 )
);*/
AnalogSliderMain->show();
- // ListView_RedrawItems(IoList, 0, Prog.io.count - 1);
}
void AnalogSliderRelProc(char* name)
@@ -522,11 +472,7 @@ void AnalogSliderRelProc(char* name)
SWORD v = AnalogSliderTrackbar->value();
AnalogSliderMain->hide();
SetAdcShadow(name, v);
- /*delete AnalogSliderLabel;
- delete AnalogSliderTrackbar;*/
- // delete AnalogSliderMain;
SimulateOneCycle(TRUE);
- // printf("Slider done:%s, %d\n", name, v);
}
void ListView_RedrawItems(HLIST list, int min, int max)
@@ -539,7 +485,6 @@ void ListView_RedrawItems(HLIST list, int min, int max)
NMHDR h;
h.code = LVN_GETDISPINFO;
h.hlistFrom = list;
- // printf("ioCount:%d\n",Prog.io.count);
list->clear();
h.hlistIter.clear();
for(int i = 0; i < Prog.io.count; i++) {
@@ -558,138 +503,12 @@ void AnalogSliderProc(int Value)
char str[5];
sprintf(str, "%d", Value);
AnalogSliderLabel->setText(str);
- /*const char* buf;
- buf = text.toStdString().c_str();
- if(atoi(buf) != ControlCount && !asString) {
- ControlCount = atoi(buf);
- if(ControlCount < 0 || ControlCount > 32) {
- ControlCount = 0;
- CountTextbox->setText("");
- }
- DestroyLutControls();
- MakeLutControls(asString, ControlCount, FALSE);
- }*/
-}
-/*
-//-----------------------------------------------------------------------------
-// Window proc for the contacts dialog box
-//-----------------------------------------------------------------------------
-static void IoDialogProc(BOOL DialogDone, int item)
-{
- if(DialogDone)
- {
- char pin[16];
- ITLIST iter;
-
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(PinList));
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-
- if(gtk_tree_selection_get_selected (selection, NULL, &iter))
- {
- GValue valproc = G_VALUE_INIT;
-
- gtk_tree_model_get_value (gtk_tree_view_get_model (GTK_TREE_VIEW(PinList)),
- &iter, 0, &valproc);
- gchar* str = (char*)g_value_get_string(&valproc);
- strcpy(pin, str);
- g_free(str);
- }
- else
- strcpy(pin, _("(no pin)"));
-
- if(strcmp(pin, _("(no pin)"))==0)
- {
- int i;
- for(i = 0; i < IoSeenPreviouslyCount; i++) {
- if(strcmp(IoSeenPreviously[i].name,
- Prog.io.assignment[item].name)==0)
- {
- IoSeenPreviously[i].pin = NO_PIN_ASSIGNED;
- }
- }
- Prog.io.assignment[item].pin = NO_PIN_ASSIGNED;
- }
- else
- {
- Prog.io.assignment[item].pin = atoi(pin);
- // Only one name can be bound to each pin; make sure that there's
- // not another entry for this pin in the IoSeenPreviously list,
- // that might get used if the user creates a new pin with that
- // name.
- int i;
- for(i = 0; i < IoSeenPreviouslyCount; i++) {
- if(IoSeenPreviously[i].pin == atoi(pin)) {
- IoSeenPreviously[i].pin = NO_PIN_ASSIGNED;
- }
- }
- }
- RefreshControlsToSettings();
- }
-
- DestroyWindow(IoDialog);
- ProgramChanged();
}
-void IoDialogRowActivateProc(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
-{
- IoDialogProc(TRUE, GPOINTER_TO_INT(user_data));
-}
-
-void IoDialogCancelProc(HWID widget, gpointer data)
-{
- IoDialogProc(FALSE, GPOINTER_TO_INT(data));
-}
-
-void IoDialogOkProc(HWID widget, gpointer data)
-{
- IoDialogProc(TRUE, GPOINTER_TO_INT(data));
-}
-
-static gboolean IoDialogKeyPressProc(HWID widget, GdkEventKey* event, gpointer data)
-{
- if (event -> keyval == GDK_KEY_Return)
- {
- IoDialogProc(TRUE, GPOINTER_TO_INT(data));
- }
- else if (event -> keyval == GDK_KEY_Escape)
- {
- IoDialogProc(FALSE, GPOINTER_TO_INT(data));
- }
-
- return FALSE;
-}
-
-//-----------------------------------------------------------------------------
-// Create our window class; nothing exciting.
-//-----------------------------------------------------------------------------
-// static BOOL MakeWindowClass()
-// {
-// WNDCLASSEX wc;
-// memset(&wc, 0, sizeof(wc));
-// wc.cbSize = sizeof(wc);
-
-// wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC |
-// CS_DBLCLKS;
-// wc.lpfnWndProc = (WNDPROC)IoDialogProc;
-// wc.hInstance = Instance;
-// wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
-// wc.lpszClassName = "LDmicroIo";
-// wc.lpszMenuName = NULL;
-// wc.hCursor = LoadCursor(NULL, IDC_ARROW);
-// wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
-// IMAGE_ICON, 32, 32, 0);
-// wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
-// IMAGE_ICON, 16, 16, 0);
-
-// return RegisterClassEx(&wc);
-// }
-*/
static void MakeControls()
{
QVBoxLayout* IoLayout = new QVBoxLayout(IoDialog);
- // QLabel* textLabel = new QLabel(_("Assign:"));
NiceFont(IoDialog);
- // HLIST IoPinList = (GtkTreeModel*)gtk_list_store_new (1, G_TYPE_STRING);
PinList = new QTreeWidget();
PinList->setHeaderLabel(_("Assign:"));
@@ -697,45 +516,13 @@ static void MakeControls()
PinList->setFixedSize(125, 320);
ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel, Qt::Vertical);
- // IoLayout->addWidget(textLabel);
+
IoLayout->addWidget(PinList);
IoLayout->addWidget(ButtonBox);
QObject::connect(PinList, &QTreeWidget::itemActivated,
IoDialog, &QDialog::accept);
QObject::connect(ButtonBox, SIGNAL(accepted()), IoDialog, SLOT(accept()));
QObject::connect(ButtonBox, SIGNAL(rejected()), IoDialog, SLOT(reject()));
- /*HLIST IoPinList = (GtkTreeModel*)gtk_list_store_new (1, G_TYPE_STRING);
-
- PinList = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoPinList));
- HTVC column = gtk_tree_view_column_new_with_attributes(_("Assign:"),
- gtk_cell_renderer_text_new(),
- "text", 0,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(PinList), column);
- FixedFont(PinList);
-
- OkButton = gtk_button_new_with_label (_("OK"));
- NiceFont(OkButton);
-
- CancelButton = gtk_button_new_with_label (_("Cancel"));
- NiceFont(CancelButton);
-
- /// Add list to scrolled window to enable scrolling
- HWID PinScroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (PinScroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
- gtk_widget_set_hexpand(GTK_WIDGET(PinScroll), TRUE);
- gtk_widget_set_vexpand(GTK_WIDGET(PinScroll), TRUE);
-
- gtk_container_add (GTK_CONTAINER(PinScroll), PinList);
-
- /// Pack all the widgets into main window
- HWID PinBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(PinBox), PinScroll, FALSE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(PinBox), OkButton, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(PinBox), CancelButton, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(Dialog), PinBox);*/
}
void ShowIoDialog(int item)
{
@@ -847,12 +634,9 @@ void ShowIoDialog(int item)
{
case QDialog::Accepted:
{
- // int sel = PinList->indexOfTopLevelItem(PinList->currentItem());
char pin[16];
- // SendMessage(PinList, LB_GETTEXT, (WPARAM)sel, (LPARAM)pin);
strncpy(pin,
PinList->currentItem()->text(0).toStdString().c_str(), 16);
- // printf("Accepted:%s\n", pin);
if(strcmp(pin, _("(no pin)"))==0) {
int i;
for(i = 0; i < IoSeenPreviouslyCount; i++) {
@@ -863,7 +647,6 @@ void ShowIoDialog(int item)
}
}
Prog.io.assignment[item].pin = NO_PIN_ASSIGNED;
- // printf("Count:%d\n", count);
} else {
Prog.io.assignment[item].pin = atoi(pin);
// Only one name can be bound to each pin; make sure that there's
@@ -883,76 +666,7 @@ void ShowIoDialog(int item)
break;
}
DestroyWindow();
- /* ITLIST iter;
- GValue val = G_VALUE_INIT;
- g_value_init (&val, G_TYPE_STRING);
-
- HLIST model = gtk_tree_view_get_model (GTK_TREE_VIEW(PinList));
-
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL(model), &iter);
-
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
-
- g_value_set_string(&val, _("(no pin)"));
- gtk_list_store_set_value (GTK_LIST_STORE(model), &iter, 0, &val);
-
- int i;
- for(i = 0; i < Prog.mcu->pinCount; i++) {
- int j;
- for(j = 0; j < Prog.io.count; j++) {
- if(j == item) continue;
- if(Prog.io.assignment[j].pin == Prog.mcu->pinInfo[i].pin) {
- goto cant_use_this_io;
- }
- }
-
- if(UartFunctionUsed() && Prog.mcu &&
- ((Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.rxPin) ||
- (Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.txPin)))
- {
- goto cant_use_this_io;
- }
-
- if(PwmFunctionUsed() &&
- Prog.mcu->pinInfo[i].pin == Prog.mcu->pwmNeedsPin)
- {
- goto cant_use_this_io;
- }
-
- if(Prog.io.assignment[item].name[0] == 'A') {
- for(j = 0; j < Prog.mcu->adcCount; j++) {
- if(Prog.mcu->adcInfo[j].pin == Prog.mcu->pinInfo[i].pin) {
- // okay; we know how to connect it up to the ADC
- break;
- }
- }
- if(j == Prog.mcu->adcCount) {
- goto cant_use_this_io;
- }
- }
-
- char buf[40];
- if(Prog.mcu->pinCount <= 21) {
- sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin,
- Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port,
- Prog.mcu->pinInfo[i].bit);
- } else {
- sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin,
- Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port,
- Prog.mcu->pinInfo[i].bit);
- }
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
- g_value_set_string(&val, buf);
- gtk_list_store_set_value (GTK_LIST_STORE(model), &iter, 0, &val);
-cant_use_this_io:;
- }
-
- gtk_widget_show_all(IoDialog);
-
- g_signal_connect (PinList, "row_activated", G_CALLBACK (IoDialogRowActivateProc), GINT_TO_POINTER(item));
- g_signal_connect (IoDialog, "key_press_event", G_CALLBACK (IoDialogKeyPressProc), GINT_TO_POINTER(item));
- 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
@@ -972,11 +686,13 @@ void IoListProc(NMHDR *h)
char IO_value_holder[60];
QString val;
/// case LV_IO_NAME:
- val = QString::fromStdString((const char*)Prog.io.assignment[item].name);
+ val = QString::fromStdString(
+ (const char*)Prog.io.assignment[item].name);
StrL.insert(0,val);
/// case LV_IO_TYPE:
- val = QString::fromStdString(IoTypeToString(Prog.io.assignment[item].type));
+ val = QString::fromStdString(
+ IoTypeToString(Prog.io.assignment[item].type));
StrL.insert(1,val);
/// case LV_IO_STATE:
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e0bf5f3..6269fcd 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -43,9 +43,7 @@ QMenuBar* MainMenu;
QGroupBox* CursorObject;
HWID DrawWindow;
WM_SCROLL scrollbar;
-// parameters used to capture the mouse when implementing our totally non-
-// general splitter control
-//static HHOOK MouseHookHandle;
+
static int MouseY;
int CursorTimer;
int SimulateTimer;
@@ -279,7 +277,7 @@ static void OpenDialog(void)
DrawWindow->repaint();
GenerateIoListDontLoseSelection();
- RefreshScrollbars();
+ // RefreshScrollbars();
UpdateMainWindowTitleBar();
}
@@ -292,8 +290,9 @@ void ProgramChanged(void)
{
ProgramChangedNotSaved = TRUE;
GenerateIoListDontLoseSelection();
- RefreshScrollbars();
+ // RefreshScrollbars();
}
+
#define CHANGING_PROGRAM(x) { \
UndoRemember(); \
x; \
@@ -301,40 +300,6 @@ void ProgramChanged(void)
}
//-----------------------------------------------------------------------------
-// Hook that we install when the user starts dragging the `splitter,' in case
-// they drag it out of the narrow area of the drawn splitter bar. Resize
-// the listview in response to mouse move, and unhook ourselves when they
-// release the mouse button.
-//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK MouseHook(int code, WPARAM wParam, LPARAM lParam)
-// {
-// switch(code) {
-// case HC_ACTION: {
-// MSLLHOOKSTRUCT *mhs = (MSLLHOOKSTRUCT *)lParam;
-
-// switch(wParam) {
-// case WM_MOUSEMOVE: {
-// int dy = MouseY - mhs->pt.y;
-
-// IoListHeight += dy;
-// if(IoListHeight < 50) IoListHeight = 50;
-// MouseY = mhs->pt.y;
-// MainWindowResized();
-
-// break;
-// }
-
-// case WM_LBUTTONUP:
-// UnhookWindowsHookEx(MouseHookHandle);
-// break;
-// }
-// break;
-// }
-// }
-// return CallNextHookEx(MouseHookHandle, code, wParam, lParam);
-// }
-
-//-----------------------------------------------------------------------------
// Handle a selection from the menu bar of the main window.
//-----------------------------------------------------------------------------
static void ProcessMenu(int code)
@@ -360,7 +325,7 @@ static void ProcessMenu(int code)
strcpy(CurrentSaveFile, "");
strcpy(CurrentCompileFile, "");
GenerateIoListDontLoseSelection();
- RefreshScrollbars();
+ // RefreshScrollbars();
UpdateMainWindowTitleBar();
break;
@@ -607,47 +572,27 @@ cmp:
void PaintWidget::keyPressEvent(QKeyEvent* event)
{
- // if(event->key() == )
int wParam = event->key();
- /*if(wParam == VK_TAB) {
- // SetFocus(IoList);
- gtk_window_set_focus (GTK_WINDOW(MainWindow), view);
- // BlinkCursor(0, 0, 0, 0);
-
- }*/
-
if(InSimulationMode)
{
switch(wParam)
{
case VK_DOWN:
- /*if(ScrollYOffset < ScrollYOffsetMax)
- ScrollYOffset++;*/
- RefreshScrollbars();
+ // RefreshScrollbars();
DrawWindow->repaint();
break;
case VK_UP:
- /*if(ScrollYOffset > 0)
- ScrollYOffset--;*/
- RefreshScrollbars();
+ // 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;
@@ -720,190 +665,7 @@ void MyWidget::closeEvent(QCloseEvent* event)
IoListHeight = IoList->height();
FreezeDWORD(IoListHeight);
}
-
- /*GdkRectangle allocation;
- gtk_widget_get_allocation(GTK_WIDGET(view), &allocation);
- IoListHeight = allocation.height;
- FreezeWindowPos(MainWindow);
- FreezeDWORD(IoListHeight);*/
}
-// gboolean LD_WM_KeyDown_call(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_KEYDOWN
-// */
-
-// UINT wParam = event->keyval;
-
-// if(wParam == VK_TAB) {
-// // SetFocus(IoList);
-// gtk_window_set_focus (GTK_WINDOW(MainWindow), view);
-// // BlinkCursor(0, 0, 0, 0);
-
-// }
-
-// if(InSimulationMode)
-// {
-// switch(wParam)
-// {
-// case VK_DOWN:
-// if(ScrollYOffset < ScrollYOffsetMax)
-// ScrollYOffset++;
-// RefreshScrollbars();
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_UP:
-// if(ScrollYOffset > 0)
-// ScrollYOffset--;
-// RefreshScrollbars();
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_LEFT:
-// ScrollXOffset -= FONT_WIDTH;
-// if(ScrollXOffset < 0)
-// ScrollXOffset = 0;
-// RefreshScrollbars();
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_RIGHT:
-// ScrollXOffset += FONT_WIDTH;
-// if(ScrollXOffset >= ScrollXOffsetMax)
-// ScrollXOffset = ScrollXOffsetMax;
-// RefreshScrollbars();
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_RETURN:
-// case VK_ESCAPE:
-// ToggleSimulationMode();
-// break;
-// }
-// }
-
-// switch(wParam)
-// {
-// case VK_UP:
-// if(event->state & GDK_SHIFT_MASK)
-// {
-// CHANGING_PROGRAM(PushRungUp());
-// }
-// else
-// {
-// MoveCursorKeyboard(wParam);
-// }
-
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_DOWN:
-// if(event->state & GDK_SHIFT_MASK)
-// {
-// CHANGING_PROGRAM(PushRungDown());
-// }
-// else
-// {
-// MoveCursorKeyboard(wParam);
-// }
-
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_RIGHT:
-// case VK_LEFT:
-// MoveCursorKeyboard(wParam);
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// case VK_RETURN:
-// CHANGING_PROGRAM(EditSelectedElement());
-// gtk_widget_queue_draw(DrawWindow);
-// break;
-
-// default:
-// break;
-// }
-
-// return FALSE;
-// }
-
-// gboolean LD_WM_Close_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_CLOSE
-// */
-
-// if(CheckSaveUserCancels())
-// return TRUE;
-// GdkRectangle allocation;
-// gtk_widget_get_allocation(GTK_WIDGET(view), &allocation);
-// IoListHeight = allocation.height;
-// FreezeWindowPos(MainWindow);
-// FreezeDWORD(IoListHeight);
-// g_print("List Height close: %d\n",IoListHeight);
-
-// gtk_main_quit();
-// gdk_threads_leave();
-// }
-
-// gboolean LD_GTK_mouse_click_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
-// */
-
-// RECT Rect;
-// GetWindowRect(ScrollWindow, &Rect);
-// int wy;
-// gtk_window_get_position(GTK_WINDOW(MainWindow), NULL, &wy);
-
-// // g_print("net: %i\n", wy + 30 + Rect.bottom);
-
-// /// Identify if mouse is clicked outside drawing area
-// if (wy + 30 + Rect.bottom < event->button.y_root)
-// return FALSE;
-
-// GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(ScrollWindow));
-
-// switch(event->button.type)
-// {
-// case GDK_BUTTON_PRESS:
-// if (event->button.button == 1) /// left click
-// {
-// GLOBAL_mouse_last_clicked_x = event->button.x_root;
-// GLOBAL_mouse_last_clicked_y = event->button.y_root;
-
-// int x = event->button.x;
-// int y = event->button.y - 30 + gtk_adjustment_get_value(adjustment);
-
-// if(!InSimulationMode) MoveCursorMouseClick(x, y);
-
-// gtk_widget_queue_draw(DrawWindow);
-// }
-// break;
-// case GDK_2BUTTON_PRESS:
-// if (event->button.button == 1) /// left click
-// {
-// GLOBAL_mouse_last_clicked_x = event->button.x_root;
-// GLOBAL_mouse_last_clicked_y = event->button.y_root;
-
-// int x = event->button.x;
-// int y = event->button.y - 30 + gtk_adjustment_get_value(adjustment);
-
-// if(InSimulationMode) {
-// EditElementMouseDoubleclick(x, y);
-// } else {
-// CHANGING_PROGRAM(EditElementMouseDoubleclick(x, y));
-// }
-// gtk_widget_queue_draw(DrawWindow);
-// }
-// break;
-
-// }
-// return FALSE;
-// }
void PaintWidget :: mouseReleaseEvent(QMouseEvent* event)
{
@@ -914,14 +676,12 @@ void PaintWidget :: mouseReleaseEvent(QMouseEvent* event)
QRect Rect;
Rect = DrawWindow->rect();
QPoint wy = 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));
+ //No need to identify if mouse is outside the scope since
+ //the function is not called
switch(event->button())
{
@@ -930,16 +690,11 @@ void PaintWidget :: mouseReleaseEvent(QMouseEvent* event)
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 PaintWidget :: mouseDoubleClickEvent(QMouseEvent* event)
@@ -955,16 +710,12 @@ void PaintWidget :: mouseDoubleClickEvent(QMouseEvent* event)
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;
@@ -972,203 +723,11 @@ void PaintWidget :: mouseDoubleClickEvent(QMouseEvent* event)
}
-// gboolean LD_GTK_mouse_scroll_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_VSCROLL, WM_HSCROLL, WM_MOUSEWHEEL
-// */
-
-// GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(ScrollWindow));
-
-// switch(event->scroll.direction)
-// {
-// case GDK_SCROLL_UP:
-// if (gtk_adjustment_get_value(adjustment) == gtk_adjustment_get_lower(adjustment))
-// VscrollProc(SB_TOP);
-// else
-// VscrollProc(SB_LINEUP);
-// break;
-// case GDK_SCROLL_DOWN:
-// if (gtk_adjustment_get_value(adjustment) == gtk_adjustment_get_upper(adjustment) - gtk_widget_get_allocated_height (ScrollWindow))
-// VscrollProc(SB_BOTTOM);
-// else
-// VscrollProc(SB_LINEDOWN);
-// break;
-// case GDK_SCROLL_LEFT:
-// HscrollProc(SB_LINEUP);
-// break;
-// case GDK_SCROLL_RIGHT:
-// HscrollProc(SB_LINEDOWN);
-// break;
-// case GDK_SCROLL_SMOOTH:
-// double d_x, d_y;
-// gdk_event_get_scroll_deltas (event, &d_x, &d_y);
-// if(d_y > 0) {
-// VscrollProc(SB_LINEUP);
-// } else {
-// VscrollProc(SB_LINEDOWN);
-// }
-// break;
-
-// }
-
-// gtk_widget_queue_draw(DrawWindow);
-// return FALSE;
-// }
-
-// gboolean LD_WM_MouseMove_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_MOUSEMOVE
-// */
-
-// // int x = LOWORD(lParam);
-// // int y = HIWORD(lParam);
-
-// // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
-// // SetCursor(LoadCursor(NULL, IDC_SIZENS));
-// // } else {
-// // SetCursor(LoadCursor(NULL, IDC_ARROW));
-// // }
-
-// // int dy = MouseY - mhs->pt.y;
-
-// // int dy = MouseY - mhs->pt.y;
-
-// // IoListHeight += dy;
-// // if(IoListHeight < 50) IoListHeight = 50;
-// // MouseY = mhs->pt.y;
-// // MainWindowResized();
-
-// return FALSE;
-// }
-
-// gboolean LD_WM_Paint_call(HWID widget, HCRDC cr, gpointer data)
-// {
-// /* Handles:
-// * WM_PAINT
-// */
-
-// static BOOL Paint_call_first = TRUE;
-
-// if (Paint_call_first)
-// {
-// gtk_widget_override_background_color(GTK_WIDGET(widget),
-// GTK_STATE_FLAG_NORMAL, (HBRUSH)GetStockObject(BLACK_BRUSH));
-
-// gint width = gtk_widget_get_allocated_width (widget);
-// gint height = gtk_widget_get_allocated_height (widget);
-
-// gtk_widget_set_size_request(widget, width, height + 1);
-
-// gdk_cairo_set_source_rgba (cr, (HBRUSH)GetStockObject(BLACK_BRUSH));
-
-// cairo_rectangle(cr, 0, 0, width, height);
-// cairo_stroke_preserve(cr);
-
-// cairo_fill (cr);
-
-// Paint_call_first = FALSE;
-// }
-
-// /// This draws the schematic.
-// MainWindowResized();
-// PaintWindow(cr);
-
-// return FALSE;
-// }
-
-// gboolean LD_WM_Destroy_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_DESTROY
-// */
-
-// if(CheckSaveUserCancels())
-// return TRUE;
-
-// FreezeWindowPos(MainWindow);
-// FreezeDWORD(IoListHeight);
-
-// gtk_main_quit();
-// gdk_threads_leave();
-// }
-
-// gboolean LD_WM_Size_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_SIZE
-// */
-// MainWindowResized();
-// return FALSE;
-// }
-
void ProgramSlots :: LD_WM_Command_call(int CommandCode)
{
ProcessMenu(CommandCode);
}
-// gboolean LD_WM_SetFocus_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-// {
-// /* Handles:
-// * WM_SETFOCUS
-// */
-
-// InvalidateRect(DrawWindow, NULL, FALSE);
-
-// return FALSE;
-// }
-
-// void LD_WM_Notify_Row_Activate_call(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
-// {
-// /* Handles:
-// * WM_NOTIFY
-// */
-
-// // g_print("Row activated!\n");
-
-// int *ip = gtk_tree_path_get_indices ( path );
-
-// NMHDR h;
-// h.code = LVN_ITEMACTIVATE;
-// h.item.iItem = ip[0];
-// h.hlistFrom = IoList;
-
-// IoListProc(&h);
-// }
-
-// void LD_WM_Notify_Cursor_Change_call(GtkTreeView *tree_view, gpointer user_data)
-// {
-// /* Handles:
-// * WM_NOTIFY
-// */
-
-// ITLIST iter;
-
-// // BOOL empty = !gtk_tree_model_get_iter_first (IoList, &iter);
-// // g_print("empty = %i\n", (empty == TRUE) );
-
-// HLIST pTreeModel;
-// int *ip;
-// 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, &pTreeModel, &iter))
-// {
-// GtkTreePath *path = gtk_tree_model_get_path ( pTreeModel , &iter ) ;
-// ip = gtk_tree_path_get_indices ( path );
-// }
-// else
-// if(!gtk_tree_model_get_iter_first (IoList, &iter))
-// return;
-
-// NMHDR h;
-// h.code = LVN_GETDISPINFO;
-// h.item.iItem = (ip == NULL) ? 0 : ip[0];
-// h.hlistFrom = IoList;
-// h.hlistIter = &iter;
-// IoListProc(&h);
-// }
-
inline void MenuHandler ()
{
QSignalMapper* CommandMapper = new QSignalMapper (&MenuHandle);
@@ -1368,31 +927,6 @@ inline void MenuHandler ()
//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));
-
-// g_signal_connect(G_OBJECT(OpenMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_OPEN));
-
-// g_signal_connect(G_OBJECT(SaveMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_SAVE));
-
-// g_signal_connect(G_OBJECT(SaveAsMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_SAVE_AS));
-
-// g_signal_connect(G_OBJECT(ExportMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_EXPORT));
-
-// g_signal_connect(G_OBJECT(ExitMenu), "activate",
-// G_CALLBACK(LD_WM_Command_call), GINT_TO_POINTER(MNU_EXIT));
-
-// // Connect microcontroller signals automatically
-// for(int i = 0; i < NUM_SUPPORTED_MCUS; i++)
-// {
-// g_signal_connect(G_OBJECT(ProcessorMenuItems[i]), "toggled",
-// G_CALLBACK(ProcessorCall), GINT_TO_POINTER((MNU_PROCESSOR_0 + i)));
-// }
}
void ActivateItem(QTreeWidgetItem* item, int column)
{
@@ -1479,16 +1013,11 @@ int main(int argc, char** argv)
// Initialize cursor and set color
CursorObject = new QGroupBox(DrawWindow);
- // CursorObject->setColor();
- // QMenu TopMenu("Top Menu", MainWindow);
- // MainMenu->addMenu(&TopMenu);
- // MainWindow->layout()->setMenuBar(MainMenu);
MainWindow->setWindowTitle("LDmicro");
MainWindow->resize(MwSize);
MainWindow->move( 10, 10);
- // MainWindow->setStyleSheet("background-color: black;");
- //Default Icon for entire app
+
app.setWindowIcon(*MWIcon);
//Icon for main window
MainWindow->setWindowIcon(*MWIcon);
@@ -1515,92 +1044,9 @@ int main(int argc, char** argv)
GenerateIoListDontLoseSelection();
- // RefreshScrollbars();
UpdateMainWindowTitleBar();
QObject::connect(IoList, &QTreeWidget::itemActivated, ActivateItem);
- // MakeDialogBoxClass();
-
-
- /*ThawWindowPos(MainWindow);
- ThawDWORD(IoListHeight);
- g_print("IoListHeight start: %d\n", IoListHeight);
- MakeMainWindowControls(); /// takes care of MakeMainWindowMenus()
- MainWindowResized();
-
- /// Keyboard and mouse hooks equivalent to MainWndProc
- g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LD_WM_Close_call), NULL);
- g_signal_connect (MainWindow, "key_press_event", G_CALLBACK (LD_WM_KeyDown_call), NULL);
- g_signal_connect (MainWindow, "button_press_event", G_CALLBACK (LD_GTK_mouse_click_hook), NULL);
- g_signal_connect (MainWindow, "scroll_event", G_CALLBACK (LD_GTK_mouse_scroll_hook), NULL);
- g_signal_connect (MainWindow, "motion_notify_event", G_CALLBACK (LD_WM_MouseMove_call), NULL);
- g_signal_connect (DrawWindow, "draw", G_CALLBACK (LD_WM_Paint_call), NULL);
- g_signal_connect (MainWindow, "destroy_event", G_CALLBACK (LD_WM_Destroy_call), NULL);
- g_signal_connect (MainWindow, "configure_event", G_CALLBACK (LD_WM_Size_call), NULL);
- g_signal_connect (MainWindow, "focus_in_event", G_CALLBACK (LD_WM_SetFocus_call), NULL);
- g_signal_connect (view, "row_activated", G_CALLBACK (LD_WM_Notify_Row_Activate_call), NULL);
- g_signal_connect (view, "cursor_changed", G_CALLBACK (LD_WM_Notify_Cursor_Change_call), NULL);
- MenuHandler();
- /// Keyboard and mouse hooks equivalent to MainWndProc - end
-
- NewProgram();
- strcpy(CurrentSaveFile, "");
-
- /// We are running interactively, or we would already have exited. We
- /// can therefore show the window now, and otherwise set up the GUI.
-
- /// Displaying the window
- gtk_widget_show_all(MainWindow);
- /// Blink cursor
- SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 200, BlinkCursor);
- // SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor);
- */
- /*if(argc >= 2) {
- char line[MAX_PATH];
- if(*argv[1] == '"') {
- strcpy(line, argv[1]+1);
- } else {
- strcpy(line, argv[1]);
- }
- if(strchr(line, '"')) *strchr(line, '"') = '\0';
-
- realpath(line, CurrentSaveFile);
- if(!LoadProjectFromFile(CurrentSaveFile)) {
- NewProgram();
- Error(_("Couldn't open '%s'."), CurrentSaveFile);
- CurrentSaveFile[0] = '\0';
- }
- UndoFlush();
- }*/
-
- /*GenerateIoListDontLoseSelection();
- RefreshScrollbars();
- UpdateMainWindowTitleBar();
-*/
- // MSG msg;
- // DWORD ret;
- // while(ret = GetMessage(&msg, NULL, 0, 0)) {
- // if(msg.hwnd == IoList && msg.message == WM_KEYDOWN) {
- // if(msg.wParam == VK_TAB) {
- // SetFocus(MainWindow);
- // continue;
- // }
- // }
- // if(msg.message == WM_KEYDOWN && msg.wParam != VK_UP &&
- // msg.wParam != VK_DOWN && msg.wParam != VK_RETURN && msg.wParam
- // != VK_SHIFT)
- // {
- // if(msg.hwnd == IoList) {
- // msg.hwnd = MainWindow;
- // SetFocus(MainWindow);
- // }
- // }
- // TranslateMessage(&msg);
- // DispatchMessage(&msg);
- // }
-
-/* gtk_main();
- return EXIT_SUCCESS;*/
return app.exec();
delete MainWindow;
delete MWIcon;
diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp
index 25843fc..b2cdf24 100644
--- a/ldmicro/lib/freezeLD/freezeLD.cpp
+++ b/ldmicro/lib/freezeLD/freezeLD.cpp
@@ -15,7 +15,8 @@
#include <stdio.h>
/*
- * store a window's position in the registry, or fail silently if the registry calls don't work
+ * store a window's position in the registry, or fail silently
+ * if the registry calls don't work
*/
void FreezeWindowPosF(HWID hwid, char *subKey, char *name)
{
@@ -31,9 +32,11 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name)
return;
}
- sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
system(moveToKeyLocatin);
- sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -61,7 +64,6 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name)
free(keyName);
return;
}
- // gtk_window_get_size(GTK_WINDOW(hwid), &val, NULL);
val = hwid->size();
Register.write((char*)&val, sizeof(val));
Register.close();
@@ -107,7 +109,8 @@ static void Clamp(LONG *v, LONG min, LONG max)
}
/*
- * retrieve a window's position from the registry, or do nothing if there is no info saved
+ * retrieve a window's position from the registry,
+ * or do nothing if there is no info saved
*/
void ThawWindowPosF(HWID hwid, char *subKey, char *name)
{
@@ -124,7 +127,8 @@ void ThawWindowPosF(HWID hwid, char *subKey, char *name)
return;
}
- sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -216,9 +220,11 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name)
return;
}
- sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
system(moveToKeyLocatin);
- sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
@@ -237,7 +243,8 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name)
}
/*
- * retrieve a DWORD setting, or return the default if that setting is unavailable
+ * retrieve a DWORD setting,
+ * or return the default if that setting is unavailable
*/
DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
{
@@ -254,7 +261,8 @@ DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
return val;
}
- sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"),
+ FREEZE_REGISTER, subKey);
if (-1 == chdir(moveToKeyLocatin))
{
free(Ld_CWD);
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp
index 9fa63c9..e43ed70 100644
--- a/ldmicro/lib/linuxUI/linuxLD.cpp
+++ b/ldmicro/lib/linuxUI/linuxLD.cpp
@@ -32,111 +32,21 @@ size_t max(size_t A, size_t B)
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
{
- // if (hHeap == NULL)
- // {
- // printf("Alloc**********NULL HEAP***************\n");
LPVOID p = malloc(dwBytes);
return p;
- // }
-
- // auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; });
-
- // if (it == HeapRecords.end())
- // return NULL;
-
- // if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize)
- // {
- // if ((*it).dwMaximumSize != 0)
- // if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize)
- // return NULL;
-
- // (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes);
- // hHeap = (*it).hHeap;
- // }
-
- // /// HEAP_ZERO_MEMORY is set by default
- // DWORD flags = MAP_ANONYMOUS;
-
- // // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) )
- // // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED;
-
- // /* Use for setting a meamory chunck with some value
- // * void * memset ( void * ptr, int value, size_t num );
- // */
- // LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0);
-
- // if (p == NULL)
- // return NULL;
-
- // (*it).dwAllocatedSizeOffset += dwBytes;
- // HEAPCHUNCK chunck;
- // chunck.Chunck = p;
- // chunck.dwSize = dwBytes;
- // (*it).Element.push_back(chunck);
-
- // return p;
}
BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
{
- /// if NULL free()
- // if (hHeap == NULL)
- // {
- // printf("free*********NULL HEAP***************\n");
free(lpMem);
return TRUE;
- // }
- // auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; });
-
- // if (heap_it == HeapRecords.end())
- // return FALSE;
-
- // auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; });
-
- // if (chunck_it == (*heap_it).Element.end())
- // return FALSE;
-
- // int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize);
-
- // if (result == 0)
- // {
- // (*heap_it).Element.erase(chunck_it);
- // return TRUE;
- // }
- // else
- // return FALSE;
-
}
-/*HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired,
- int cyDesired, UINT fuLoad)
-{
- HICON pixbuf;
- GError *error = NULL;
- pixbuf = gdk_pixbuf_new_from_file(lpszName, &error);
-
- if(!pixbuf) {
- fprintf(stderr, "%s\n", error->message);
- g_error_free(error);
- }
-
- return pixbuf;
-}*/
-
-
void OutputDebugString(char* str)
{
}
-/*double GetTickCount(void)
-{
-// timespec now;
-// clock_gettime()
-// if (clock_gettime(CLOCK_MONOTONIC, &now))
-// return 0;
- return 10.2;//now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0;
-}*/
double GetTickCount(void)
{
timespec now;
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 46eb523..8b19538 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -28,16 +28,6 @@
#define IMAGE_ICON 1
#define LDMICRO_ICON "../ldmicro.ico"
-/// Macro functions
-// #define max(_A, _B) std::max(_A, _B)
-
-/*#define max(_A, _B) { \
- if((_A) > (_B)) \
- return (_A); \
- else \
- return (_B); \
- }*/
-
/// Typedefs
//typedef int64_t __int64;
typedef bool BOOL;
@@ -160,18 +150,7 @@ typedef struct {
UINT mask;
int iItem;
int iSubItem;
-// UINT state;
-// UINT stateMask;
LPTSTR pszText;
-// int cchTextMax;
-// int iImage;
-// LPARAM lParam;
-// int iIndent;
-// int iGroupId;
-// UINT cColumns;
-// PUINT puColumns;
-// int *piColFmt;
-// int iGroup;
} LVITEM, *LPLVITEM;
typedef struct tagNMHDR {
@@ -193,7 +172,6 @@ typedef struct FontTag {
typedef struct tagLOGBRUSH {
UINT lbStyle;
COLORREF lbColor;
-// ULONG_PTR lbHatch;
} LOGBRUSH, *PLOGBRUSH;
typedef struct _RECT {
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index e9ae716..5d2c78f 100644
--- a/ldmicro/lib/linuxUI/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -29,17 +29,12 @@ HWID view;
/// Wraper function for gtk_window_has_toplevel_focus
BOOL GetFocus(HWID window)
{
- // return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window));
return TRUE;
}
COLORREF RGB(int red, int green, int blue)
{
COLORREF col(red, green, blue);
- // col.red = red/255.0;
- // col.green = green/255.0;
- // col.blue = blue/255.0;
- // col.alpha = 1.0;
return col;
}
@@ -138,11 +133,9 @@ void EnableMenuItem(HMENU MenuName, QAction* MenuItem, UINT CheckEnabledItem)
switch (CheckEnabledItem){
case MF_ENABLED :
MenuItem->setEnabled(true);
- // MenuItem->blockSignals(false);
break;
case MF_GRAYED :
MenuItem->setEnabled(false);
- // MenuItem->blockSignals(true);
break;
}
}
@@ -279,92 +272,20 @@ void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, i
int height = hWid->height();
BOOL resize_flag = FALSE;
QFont newFont= hcr->font();
- // newFont
- /*if(nYStart+(extents.height/2.0) >= height)
- {
- height += extents.height + 50;
- resize_flag = TRUE;
- }
-
- if (nXStart+(extents.width/2.0) >= width)
- {
- width += extents.width;
- resize_flag = TRUE;
- }*/
char* text = (char*)malloc(cchString);
strncpy(text, lpString, cchString);
text[cchString] = '\0';
hcr->drawText(nXStart, nYStart, (QString)text);
- // cairo_move_to(hcr, nXStart, nYStart);
- // cairo_show_text(hcr, text);
-
- // cairo_fill (hcr);
-
- /*if (resize_flag) // To do later
- hcr->setWindow();*/
- /*if (hcr == NULL)
- return;
-
- nYStart += 30;
-
- cairo_text_extents_t extents;
- cairo_text_extents (hcr, lpString, &extents);
- int width = gtk_widget_get_allocated_width (hWid);
- int height= gtk_widget_get_allocated_height (hWid);
- BOOL resize_flag = FALSE;
-
- if(nYStart+(extents.height/2.0) >= height)
- {
- height += extents.height + 50;
- resize_flag = TRUE;
- }
-
- if (nXStart+(extents.width/2.0) >= width)
- {
- width += extents.width;
- resize_flag = TRUE;
- }
-
- if (resize_flag)
- gtk_widget_set_size_request(hWid, width, height);
-
- char* text = (char*)malloc(cchString);
- strncpy(text, lpString, cchString);
- text[cchString] = '\0';
-
- cairo_move_to(hcr, nXStart, nYStart);
- cairo_show_text(hcr, text);
-
- cairo_fill (hcr);*/
}
COLORREF GetTextColor(HCRDC Hdc)
{
- // COLORREF col;
- // gtk_style_context_get_color (Hdc,
- // gtk_style_context_get_state (Hdc),
- // &col);
-
return HdcCurrentTextColor;
}
BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase)
{
- /*if(!GDK_IS_WINDOW(hWid))
- return FALSE;
-
- if (lpRect == NULL)
- {
- gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE);
- return TRUE;
- }
-
- GDRECT Gdrect;
- RECT_to_GDRECT(lpRect, &Gdrect);
- // gtk_widget_queue_draw(hWid);
- gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE);
- */
hWid->repaint();
return TRUE;
}
@@ -377,16 +298,7 @@ int FillRect(HCRDC hDC, const QRect *lprc, HBRUSH hbr)
curbrush.setColor(*hbr);
curbrush.setStyle(Qt::SolidPattern);
hDC->setBrush(curbrush);
- hDC->drawRect(*lprc);
- /*
- GDRECT gdrc;
- RECT_to_GDRECT(lprc, &gdrc);
-
- cairo_set_source_rgb(hDC, hbr->red, hbr->green, hbr->blue);
- cairo_rectangle(hDC, gdrc.x, gdrc.y, gdrc.width, gdrc.height);
- cairo_stroke_preserve(hDC);
- cairo_fill(hDC);*/
-
+ hDC->drawRect(*lprc);
return 0;
}
@@ -414,35 +326,12 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID)
}
break;
}
- // if(hWid!=NULL)
- // CursorObject->setVisible(TRUE);
return TimerID;
- // auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; });
-
- // if (record_it != timerRecords.end())
- // return 0;
-
- // TimerRecord tr;
- // tr.pfun = lpTimerFunc;
- // tr.ufID = nIDEvent;
- // tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE);
-
- // timerRecords.push_back(tr);
- // return tr.utID;
}
BOOL KillTimer(HWID hWid, UINT 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);*/
- // printf("KillTimer\n");
switch(uIDEvent)
{
case TIMER_BLINK_CURSOR:
diff --git a/ldmicro/loadsave.cpp b/ldmicro/loadsave.cpp
index b07ec4b..bd8aa04 100644
--- a/ldmicro/loadsave.cpp
+++ b/ldmicro/loadsave.cpp
@@ -62,10 +62,13 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which)
}
l->d.comment.str[i++] = '\0';
*which = ELEM_COMMENT;
- } else if(sscanf(line, "CONTACTS %s %d", l->d.contacts.name, &l->d.contacts.negated)==2)
+ } else if(sscanf(line, "CONTACTS %s %d",
+ l->d.contacts.name, &l->d.contacts.negated)==2)
{
*which = ELEM_CONTACTS;
- } else if(sscanf(line, "COIL %s %d %d %d", l->d.coil.name, &l->d.coil.negated, &l->d.coil.setOnly, &l->d.coil.resetOnly)==4)
+ } else if(sscanf(line, "COIL %s %d %d %d",
+ l->d.coil.name, &l->d.coil.negated, &l->d.coil.setOnly,
+ &l->d.coil.resetOnly)==4)
{
*which = ELEM_COIL;
} else if(memcmp(line, "PLACEHOLDER", 11)==0) {
@@ -76,45 +79,56 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which)
*which = ELEM_OPEN;
} else if(memcmp(line, "MASTER_RELAY", 12)==0) {
*which = ELEM_MASTER_RELAY;
- } else if(sscanf(line, "SHIFT_REGISTER %s %d", l->d.shiftRegister.name, &(l->d.shiftRegister.stages))==2)
+ } else if(sscanf(line, "SHIFT_REGISTER %s %d",
+ l->d.shiftRegister.name, &(l->d.shiftRegister.stages))==2)
{
*which = ELEM_SHIFT_REGISTER;
} else if(memcmp(line, "OSR", 3)==0) {
*which = ELEM_ONE_SHOT_RISING;
} else if(memcmp(line, "OSF", 3)==0) {
*which = ELEM_ONE_SHOT_FALLING;
- } else if((sscanf(line, "TON %s %d", l->d.timer.name, &l->d.timer.delay)==2))
+ } else if((sscanf(line, "TON %s %d",
+ l->d.timer.name, &l->d.timer.delay)==2))
{
*which = ELEM_TON;
- } else if((sscanf(line, "TOF %s %d", l->d.timer.name, &l->d.timer.delay)==2))
+ } else if((sscanf(line, "TOF %s %d",
+ l->d.timer.name, &l->d.timer.delay)==2))
{
*which = ELEM_TOF;
- } else if((sscanf(line, "RTO %s %d", l->d.timer.name, &l->d.timer.delay)==2))
+ } else if((sscanf(line, "RTO %s %d", l->d.timer.name,
+ &l->d.timer.delay)==2))
{
*which = ELEM_RTO;
- } else if((sscanf(line, "CTD %s %d", l->d.counter.name, &l->d.counter.max)==2))
+ } else if((sscanf(line, "CTD %s %d", l->d.counter.name,
+ &l->d.counter.max)==2))
{
*which = ELEM_CTD;
- } else if((sscanf(line, "CTU %s %d", l->d.counter.name, &l->d.counter.max)==2))
+ } else if((sscanf(line, "CTU %s %d", l->d.counter.name,
+ &l->d.counter.max)==2))
{
*which = ELEM_CTU;
- } else if((sscanf(line, "CTC %s %d", l->d.counter.name, &l->d.counter.max)==2))
+ } else if((sscanf(line, "CTC %s %d", l->d.counter.name,
+ &l->d.counter.max)==2))
{
*which = ELEM_CTC;
} else if(sscanf(line, "RES %s", l->d.reset.name)==1) {
*which = ELEM_RES;
} else if(sscanf(line, "MOVE %s %s", l->d.move.dest, l->d.move.src)==2) {
*which = ELEM_MOVE;
- } else if(sscanf(line, "ADD %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3)
+ } else if(sscanf(line, "ADD %s %s %s", l->d.math.dest,
+ l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_ADD;
- } else if(sscanf(line, "SUB %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3)
+ } else if(sscanf(line, "SUB %s %s %s", l->d.math.dest,
+ l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_SUB;
- } else if(sscanf(line, "MUL %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3)
+ } else if(sscanf(line, "MUL %s %s %s", l->d.math.dest,
+ l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_MUL;
- } else if(sscanf(line, "DIV %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3)
+ } else if(sscanf(line, "DIV %s %s %s", l->d.math.dest,
+ l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_DIV;
} else if(sscanf(line, "EQU %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
@@ -131,7 +145,8 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which)
*which = ELEM_LES;
} else if(sscanf(line, "READ_ADC %s", l->d.readAdc.name)==1) {
*which = ELEM_READ_ADC;
- } else if(sscanf(line, "SET_PWM %s %d", l->d.setPwm.name, &(l->d.setPwm.targetFreq))==2)
+ } else if(sscanf(line, "SET_PWM %s %d", l->d.setPwm.name,
+ &(l->d.setPwm.targetFreq))==2)
{
*which = ELEM_SET_PWM;
} else if(sscanf(line, "UART_RECV %s", l->d.uart.name)==1) {
diff --git a/ldmicro/lutdialog.cpp b/ldmicro/lutdialog.cpp
index 17e6e5b..b6e3433 100644
--- a/ldmicro/lutdialog.cpp
+++ b/ldmicro/lutdialog.cpp
@@ -144,7 +144,8 @@ static void MakeFixedControls(BOOL forPwl)
LutGrid->addWidget(ButtonBox,0,1);
QObject::connect(ButtonBox, SIGNAL(accepted()), LutDialog, SLOT(accept()));
QObject::connect(ButtonBox, SIGNAL(rejected()), LutDialog, SLOT(reject()));
- QObject::connect(AsStringCheckbox, &QCheckBox::stateChanged,CheckBoxFunction);
+ QObject::connect(AsStringCheckbox,
+ &QCheckBox::stateChanged, CheckBoxFunction);
QObject::connect(CountTextbox, &QLineEdit::textChanged,CountFunction);
}
@@ -172,12 +173,6 @@ static void DestroyLutControls(BOOL destroyFlag = TRUE)
}
delete LutControlGrid;
}
-
- // int i;
- /*for(i = 0; i < MAX_LOOK_UP_TABLE_LEN; i++) {
- delete ValuesTextbox[i];
- delete ValuesLabel[i];
- }*/
}
@@ -276,12 +271,8 @@ static void MakeLutControls(BOOL asString, int counts, BOOL forPwl)
FixedFont(ValuesLabel[i]);
LutControlGrid->addWidget(ValuesLabel[i], x , y);
}
- // if(counts > 16)
FixedControlGrid->addLayout(LutControlGrid, 4, 0, 1, 0,
Qt::AlignTop);
- // else
- // FixedControlGrid->addLayout(LutControlGrid, 4, 0, 1, 0,
- // Qt::AlignTop);
CountTextbox->setReadOnly(FALSE);
}
}
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 4ae1f5b..8bd128f 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -139,127 +139,16 @@ int IoListTop;
// 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,
- (GdkModifierType)0, 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,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertContactsMenu, "activate", AccelGroup, GDK_KEY_C,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertOsrMenu, "activate", AccelGroup, GDK_KEY_backslash,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertOsfMenu, "activate", AccelGroup, GDK_KEY_slash,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertTonMenu, "activate", AccelGroup, GDK_KEY_O,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertTofMenu, "activate", AccelGroup, GDK_KEY_F,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertRtoMenu, "activate", AccelGroup, GDK_KEY_T,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertCtuMenu, "activate", AccelGroup, GDK_KEY_U,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertCtdMenu, "activate", AccelGroup, GDK_KEY_I,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertCtcMenu, "activate", AccelGroup, GDK_KEY_J,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertEquMenu, "activate", AccelGroup, GDK_KEY_equal,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertGrtMenu, "activate", AccelGroup, GDK_KEY_greater,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertGeqMenu, "activate", AccelGroup, GDK_KEY_Stop,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertLesMenu, "activate", AccelGroup, GDK_KEY_less,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertLeqMenu, "activate", AccelGroup, GDK_KEY_comma,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertCoilMenu, "activate", AccelGroup, GDK_KEY_L,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertResMenu, "activate", AccelGroup, GDK_KEY_E,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertMovMenu, "activate", AccelGroup, GDK_KEY_M,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertAddMenu, "activate", AccelGroup, GDK_KEY_plus,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertSubMenu, "activate", AccelGroup, GDK_KEY_minus,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertMulMenu, "activate", AccelGroup, GDK_KEY_multiply,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertDivMenu, "activate", AccelGroup, GDK_KEY_D,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (InsertReadAdcMenu, "activate", AccelGroup, GDK_KEY_P,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MakeNormalMenu, "activate", AccelGroup, GDK_KEY_A,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (NegateMenu, "activate", AccelGroup, GDK_KEY_N,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MakeSetOnlyMenu, "activate", AccelGroup, GDK_KEY_S,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
- gtk_widget_add_accelerator (MakeResetOnlyMenu, "activate", AccelGroup, GDK_KEY_R,
- (GdkModifierType)0, 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,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
-
- // Creating keyboard shortcuts for Compile menu
- gtk_widget_add_accelerator (CompileMenu, "activate", AccelGroup, GDK_KEY_F5,
- (GdkModifierType)0, GTK_ACCEL_VISIBLE);
-
- // Creating keyboard shortcuts for Help menu
- gtk_widget_add_accelerator (ManualMenu, "activate", AccelGroup, GDK_KEY_F1,
- (GdkModifierType)0, 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.
//-----------------------------------------------------------------------------
HMENU MakeMainWindowMenus(void)
{
- HMENU FileMenuSeparator; // File menu separator
- HMENU EditMenuSeparator; // Edit menu separator
- HMENU InstructionMenuSeparator; // Instruction menu separator
- HMENU SimulateMenuSeparator; // Simulate menu separator
+ HMENU FileMenuSeparator;
+ HMENU EditMenuSeparator;
+ HMENU InstructionMenuSeparator;
+ HMENU SimulateMenuSeparator;
int i;
@@ -343,17 +232,11 @@ HMENU MakeMainWindowMenus(void)
ProcessorMenuItems[i]->setCheckable(true);
ProcessorMenuItems[i]->setActionGroup(ProcessorMenuGroup);
MicroControllerMenu->addAction(ProcessorMenuItems[i]);
- /*mcuList = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (ProcessorMenuItems[i]));
- gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems[i]);*/
}
ProcessorMenuItems[i] = new QAction("(no microcontroller)", NULL);
ProcessorMenuItems[i]->setCheckable(true);
ProcessorMenuItems[i]->setActionGroup(ProcessorMenuGroup);
MicroControllerMenu->addAction(ProcessorMenuItems[i]);
- /*ProcessorMenuItems[NUM_SUPPORTED_MCUS] = gtk_radio_menu_item_new_with_label (mcuList, "(no microcontroller)");
- mcuList = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (ProcessorMenuItems[NUM_SUPPORTED_MCUS]));
- 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
InsertCommentMenu = new QAction("&Insert Comment", MainWindow);
@@ -368,7 +251,8 @@ HMENU MakeMainWindowMenus(void)
InsertTonMenu->setShortcut(QKeySequence(Qt::Key_O));
InsertTofMenu = new QAction("&Insert TOF (Delayed Turn Off)", MainWindow);
InsertTofMenu->setShortcut(QKeySequence(Qt::Key_F));
- InsertRtoMenu = new QAction("&Insert RTO (Retentive Delayed Turn On)", MainWindow);
+ InsertRtoMenu = new QAction("&Insert RTO (Retentive Delayed Turn On)",
+ MainWindow);
InsertRtoMenu->setShortcut(QKeySequence(Qt::Key_T));
InsertCtuMenu = new QAction("&Insert CTU (Count Up)", MainWindow);
InsertCtuMenu->setShortcut(QKeySequence(Qt::Key_U));
@@ -378,18 +262,24 @@ HMENU MakeMainWindowMenus(void)
InsertCtcMenu->setShortcut(QKeySequence(Qt::Key_J));
InsertEquMenu = new QAction("&Insert EQU (Compare for Equals)", MainWindow);
InsertEquMenu->setShortcut(QKeySequence(Qt::Key_Equal));
- InsertNeqMenu = new QAction("&Insert NEQ (Compare for Not Equals)", MainWindow);
- InsertGrtMenu = new QAction("&Insert GRT (Compare for Greater Than)", MainWindow);
+ InsertNeqMenu = new QAction("&Insert NEQ (Compare for Not Equals)",
+ MainWindow);
+ InsertGrtMenu = new QAction("&Insert GRT (Compare for Greater Than)",
+ MainWindow);
InsertGrtMenu->setShortcut(QKeySequence(Qt::Key_Greater));
- InsertGeqMenu = new QAction("&Insert GEQ (Compare for Greater Than or Equal)", MainWindow);
+ InsertGeqMenu = new QAction(
+ "&Insert GEQ (Compare for Greater Than or Equal)", MainWindow);
InsertGeqMenu->setShortcut(QKeySequence(Qt::Key_Period));
- InsertLesMenu = new QAction("&Insert LES (Compare for Less Than)", MainWindow);
+ InsertLesMenu = new QAction(
+ "&Insert LES (Compare for Less Than)", MainWindow);
InsertLesMenu->setShortcut(QKeySequence(Qt::Key_Less));
- InsertLeqMenu = new QAction("&Insert LEQ (Compare for Less Than or Equal)", MainWindow);
+ InsertLeqMenu = new QAction(
+ "&Insert LEQ (Compare for Less Than or Equal)", MainWindow);
InsertLeqMenu->setShortcut(QKeySequence(Qt::Key_Comma));
InsertOpenMenu = new QAction("&Insert Open Circuit", MainWindow);
InsertShortMenu = new QAction("&Insert Short Circuit", MainWindow);
- InsertMasterRlyMenu = new QAction("&Insert Master Control Relay", MainWindow);
+ InsertMasterRlyMenu = new QAction(
+ "&Insert Master Control Relay", MainWindow);
InsertCoilMenu = new QAction("&Insert Coil", MainWindow);
InsertCoilMenu->setShortcut(QKeySequence(Qt::Key_L));
InsertResMenu = new QAction("&Insert RES (Counter/RTO Reset)", MainWindow);
@@ -398,16 +288,20 @@ HMENU MakeMainWindowMenus(void)
InsertMovMenu->setShortcut(QKeySequence(Qt::Key_M));
InsertAddMenu = new QAction("&Insert ADD (16-bit Integer Ad)", MainWindow);
InsertAddMenu->setShortcut(QKeySequence(Qt::Key_Plus));
- InsertSubMenu = new QAction("&Insert SUB (16-bit Integer Subtract)", MainWindow);
+ InsertSubMenu = new QAction(
+ "&Insert SUB (16-bit Integer Subtract)", MainWindow);
InsertSubMenu->setShortcut(QKeySequence(Qt::Key_Minus));
- InsertMulMenu = new QAction("&Insert MUL (16-bit Integer Multiply)", MainWindow);
+ InsertMulMenu = new QAction(
+ "&Insert MUL (16-bit Integer Multiply)", MainWindow);
InsertMulMenu->setShortcut(QKeySequence(Qt::Key_Asterisk));
- InsertDivMenu = new QAction("&Insert DIV (16-bit Integer Division)", MainWindow);
+ InsertDivMenu = new QAction(
+ "&Insert DIV (16-bit Integer Division)", MainWindow);
InsertDivMenu->setShortcut(QKeySequence(Qt::Key_D));
InsertShiftRegMenu = new QAction("&Insert Shift Register", MainWindow);
InsertLutMenu = new QAction("&Insert Look-Up Table", MainWindow);
InsertPwlMenu = new QAction("&Insert Piecewise Linear", MainWindow);
- InsertFmtdStrMenu = new QAction("&Insert Formatted String Over UART", MainWindow);
+ InsertFmtdStrMenu = new QAction(
+ "&Insert Formatted String Over UART", MainWindow);
InsertUartSendMenu = new QAction("&Insert UART Send", MainWindow);
InsertUartRecvMenu = new QAction("&Insert UART Receive", MainWindow);
InsertSetPwmMenu = new QAction("&Insert Set PWM Output", MainWindow);
@@ -518,10 +412,6 @@ HMENU MakeMainWindowMenus(void)
MainMenu->addMenu(Compile);
MainMenu->addMenu(Help);
- // Packing the menu bar into the box for alignment
- // MainMenu->addMenu(TopMenu);
- // AddMenuAccelerators ();
-
return FileMenu;
}
@@ -544,9 +434,6 @@ void MakeMainWindowControls(void)
"Pin on Processor",
"MCU Port"};
IoList->setHeaderLabels(ColumnNames);
- /*QList<QTreeWidgetItem *> items;
- items.append(new QTreeWidgetItem(QStringList(QString("Item1"))));
- IoList->insertTopLevelItems(0, items);*/
DrawWindow->setAutoFillBackground(true);
QSize DWSize;
scrollbar = new QScrollArea();
@@ -556,169 +443,24 @@ void MakeMainWindowControls(void)
DWSize.setHeight(MainWindow->height() - IoListHeight);
DWSize.setWidth(MainWindow->width());
DrawWindow->setMinimumHeight(100);
- // scrollbar->setWidgetResizable(TRUE);
scrollbar->resize(DWSize);
- // DrawWindow->resize(scrollbar->viewportSizeHint());
scrollbar->setWidget(DrawWindow);
splitter->addWidget(scrollbar);
DWSize.setWidth(MainWindow->width() -
(scrollbar->sizeHint().width()+ MainWindow->sizeHint().width()));
DrawWindow->resize(DWSize);
- /*QPalette pal = QPalette();
- pal.setColor(QPalette::Background, Qt::black);
- DrawWindow->setAutoFillBackground(true);
- DrawWindow->setPalette(pal);*/
- // DrawWindow->setGeometry(0, 0, 500, 500);
DWSize.setHeight(IoListHeight);
IoList->resize(DWSize);
splitter->addWidget(IoList);
QStatusBar* StatusGrid = new QStatusBar(MainWindow);
- // QHBoxLayout* StatusLayout = new QHBoxLayout(StatusGrid);
- /*QFrame* StatusSplit = new QFrame(MainWindow);
- StatusSplit->setFrameShape(QFrame::HLine);*/
- // StatusGrid->showMessage("Ready");
PackBoxMenu->addWidget(splitter);
- // PackBoxMenu->addWidget(StatusSplit);
for(int i = 0; i<3;i++)
{
StatusBar[i] = new QLabel(StatusGrid);
StatusBar[i]->setText("LDMicro Started");
StatusGrid->addPermanentWidget(StatusBar[i], 1);
}
- // StatusGrid->setLayout(StatusLayout);
PackBoxMenu->addWidget(StatusGrid);
- // HWID grid = gtk_grid_new();
- /// Pane to separate Scrolled Window and other widgets
- /*HWID pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
-
- IoList = (GtkTreeModel*)gtk_list_store_new (5,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- int typeWidth = 85;
- int pinWidth = 100;
- int portWidth = 90;
-
- /// Creating a list
- view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoList));
- gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (IoList));
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
-
- column = gtk_tree_view_column_new_with_attributes("Name",
- gtk_cell_renderer_text_new(),
- "text", LV_IO_NAME,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_min_width (column, 250);
-
- column = gtk_tree_view_column_new_with_attributes("Type",
- gtk_cell_renderer_spin_new(),
- "text", LV_IO_TYPE,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_min_width (column, typeWidth);
-
- column = gtk_tree_view_column_new_with_attributes("State",
- gtk_cell_renderer_text_new(),
- "text", LV_IO_STATE,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_min_width (column, 100);
-
- column = gtk_tree_view_column_new_with_attributes("Pin on Processor",
- gtk_cell_renderer_text_new(),
- "text", LV_IO_PIN,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_min_width (column, pinWidth);
-
- column = gtk_tree_view_column_new_with_attributes("MCU Port",
- gtk_cell_renderer_text_new(),
- "text", LV_IO_PORT,
- NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- gtk_tree_view_column_set_min_width (column, portWidth);
-
- /// Appending Menus to grid
- gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1);
-
- /// Creating Scrolled Window
- ScrollWindow = gtk_scrolled_window_new (NULL, NULL);
- HWID ViewPortMenu = gtk_viewport_new (NULL,NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
- gtk_widget_set_hexpand(GTK_WIDGET(ScrollWindow), TRUE);
- gtk_widget_set_vexpand(GTK_WIDGET(ScrollWindow), TRUE);
-
- /// Adding DrawWindow to pane
- gtk_container_add (GTK_CONTAINER(ViewPortMenu), DrawWindow);
- gtk_container_add (GTK_CONTAINER(ScrollWindow), ViewPortMenu);
- gtk_paned_pack1 (GTK_PANED (pane), ScrollWindow, TRUE, TRUE);
- gtk_paned_set_position (GTK_PANED (pane), 0);
-
- /// Appending tree view to scrolled window
- HWID ViewScroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ViewScroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
- gtk_widget_set_hexpand(GTK_WIDGET(ViewScroll), TRUE);
- gtk_widget_set_vexpand(GTK_WIDGET(ViewScroll), TRUE);
-
- gtk_container_add (GTK_CONTAINER(ViewScroll), view);
-
- /// Appending tree view to pane and pane to grid
- gtk_paned_pack2 (GTK_PANED(pane), ViewScroll, FALSE, FALSE);
- gtk_paned_set_position (GTK_PANED (pane), 400);
- gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1);
-
- gtk_box_pack_start(GTK_BOX(PackBoxMenu), grid, FALSE, TRUE, 0);
-
- /// Grid for status bars
- HWID StatusGrid = gtk_grid_new();
-
- // Change background color to grey
- gtk_widget_override_background_color(GTK_WIDGET(StatusGrid),
- GTK_STATE_FLAG_NORMAL, ((HBRUSH)GetStockObject(DKGRAY_BRUSH)));
-
- /// Creating Status Bar 1 and attaching to grid
- StatusBar[0] = gtk_statusbar_new();
-
- gtk_statusbar_push (GTK_STATUSBAR (StatusBar[0]),
- gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar[0]),
- "Introduction"), "LDMicro Started");
-
- /// Appneding Status Bar 1 to the status grid
- gtk_grid_attach (GTK_GRID (StatusGrid), StatusBar[0], 0, 0, 1, 1);
-
- /// Creating Status Bar 2 and attaching to grid
- StatusBar[1] = gtk_statusbar_new();
-
- gtk_statusbar_push (GTK_STATUSBAR (StatusBar[1]),
- gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar[1]),
- "Introduction"), "LDMicro Started");
-
- /// Appneding Status Bar 2 to the status box
- gtk_grid_attach (GTK_GRID (StatusGrid), StatusBar[1], 1, 0, 1, 1);
-
- /// Creating Status Bar 3 and attaching to grid
- StatusBar[2] = gtk_statusbar_new();
-
- gtk_statusbar_push (GTK_STATUSBAR (StatusBar[2]),
- gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar[2]),
- "Introduction"), "LDMicro Started");
-
- /// Appneding Status Bar 3 to the status box
- gtk_grid_attach (GTK_GRID (StatusGrid), StatusBar[2], 2, 0, 1, 1);
-
- /// Attach status grid to box
- gtk_box_pack_start(GTK_BOX(PackBoxMenu), StatusGrid, FALSE, FALSE, 0);
-
- /// Adding box to Main Window
- gtk_container_add(GTK_CONTAINER(MainWindow), PackBoxMenu);*/
}
//-----------------------------------------------------------------------------
@@ -726,132 +468,10 @@ void MakeMainWindowControls(void)
// to a change in the size of the program or a change in the size of the
// window.
//-----------------------------------------------------------------------------
-void RefreshScrollbars(void)
+/*void RefreshScrollbars(void)
{
- // SCROLLINFO vert, horiz;
- // SetUpScrollbars(&NeedHoriz, &horiz, &vert);
-
- // SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE);
- // SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE);
+}*/
- // RECT main;
- // GetClientRect(MainWindow, &main);
-
- // if(NeedHoriz) {
- // MoveWindow(HorizScrollBar, 0, IoListTop - ScrollHeight - 2,
- // main.right - ScrollWidth - 2, ScrollHeight, TRUE);
- // ShowWindow(HorizScrollBar, SW_SHOW);
- // EnableWindow(HorizScrollBar, TRUE);
- // } else {
- // ShowWindow(HorizScrollBar, SW_HIDE);
- // }
- // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth,
- // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE);
-
- // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth,
- // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE);
-
- // InvalidateRect(DrawWindow, NULL, FALSE);
-}
-/*
-//-----------------------------------------------------------------------------
-// Respond to a WM_VSCROLL sent to the main window, presumably by the one and
-// only vertical scrollbar that it has as a child.
-//-----------------------------------------------------------------------------
-void VscrollProc(int wParam)
-{
- int prevY = ScrollYOffset;
- switch(wParam) {
- case SB_LINEUP:
- case SB_PAGEUP:
- if(ScrollYOffset > 0) {
- ScrollYOffset--;
- }
- break;
-
- case SB_LINEDOWN:
- case SB_PAGEDOWN:
- if(ScrollYOffset < ScrollYOffsetMax) {
- ScrollYOffset++;
- }
- break;
-
- case SB_TOP:
- ScrollYOffset = 0;
- break;
-
- case SB_BOTTOM:
- ScrollYOffset = ScrollYOffsetMax;
- break;
-
- // case SB_THUMBTRACK:
- // case SB_THUMBPOSITION:
- // ScrollYOffset = HIWORD(wParam);
- // break;
- }
- // if(prevY != ScrollYOffset) {
- // SCROLLINFO si;
- // si.cbSize = sizeof(si);
- // si.fMask = SIF_POS;
- // si.nPos = ScrollYOffset;
- // SetScrollInfo(VertScrollBar, SB_CTL, &si, TRUE);
-
- // InvalidateRect(MainWindow, NULL, FALSE);
- // }
-}
-
-//-----------------------------------------------------------------------------
-// Respond to a WM_HSCROLL sent to the main window, presumably by the one and
-// only horizontal scrollbar that it has as a child.
-//-----------------------------------------------------------------------------
-void HscrollProc(int wParam)
-{
- int prevX = ScrollXOffset;
- switch(wParam) {
- case SB_LINEUP:
- ScrollXOffset -= FONT_WIDTH;
- break;
-
- case SB_PAGEUP:
- ScrollXOffset -= POS_WIDTH*FONT_WIDTH;
- break;
-
- case SB_LINEDOWN:
- ScrollXOffset += FONT_WIDTH;
- break;
-
- case SB_PAGEDOWN:
- ScrollXOffset += POS_WIDTH*FONT_WIDTH;
- break;
-
- case SB_TOP:
- ScrollXOffset = 0;
- break;
-
- case SB_BOTTOM:
- ScrollXOffset = ScrollXOffsetMax;
- break;
-
- // case SB_THUMBTRACK:
- // case SB_THUMBPOSITION:
- // ScrollXOffset = HIWORD(wParam);
- // break;
- }
-
- if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax;
- if(ScrollXOffset < 0) ScrollXOffset = 0;
-
- // if(prevX != ScrollXOffset) {
- // SCROLLINFO si;
- // si.cbSize = sizeof(si);
- // si.fMask = SIF_POS;
- // si.nPos = ScrollXOffset;
- // SetScrollInfo(HorizScrollBar, SB_CTL, &si, TRUE);
-
- // 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.
@@ -953,8 +573,8 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
//-----------------------------------------------------------------------------
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
{
- // EnableMenuItem(EditMenu, UndoMenu, undoEnabled ? MF_ENABLED : MF_GRAYED);
- // EnableMenuItem(EditMenu, RedoMenu, redoEnabled ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(EditMenu, UndoMenu, undoEnabled ? MF_ENABLED : MF_GRAYED);
+ EnableMenuItem(EditMenu, RedoMenu, redoEnabled ? MF_ENABLED : MF_GRAYED);
}
//-----------------------------------------------------------------------------
@@ -1015,7 +635,7 @@ void ToggleSimulationMode(void)
}
}
- // UpdateMainWindowTitleBar();
+ UpdateMainWindowTitleBar();
RefreshControlsToSettings();
}
@@ -1027,16 +647,6 @@ void ToggleSimulationMode(void)
//-----------------------------------------------------------------------------
void RefreshControlsToSettings(void)
{
- /*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);*/
- // DrawWindow->repaint();
QTreeWidgetItem iter;
QTreeWidgetItem* selection;
if(!IoListOutOfSync) {
@@ -1046,7 +656,6 @@ void RefreshControlsToSettings(void)
NMHDR h;
h.code = LVN_GETDISPINFO;
h.hlistFrom = IoList;
- // printf("ioCount:%d\n",Prog.io.count);
IoList->clear();
h.hlistIter.clear();
for(int i = 0; i < Prog.io.count; i++) {
@@ -1090,10 +699,12 @@ void RefreshControlsToSettings(void)
}
// `(no microcontroller)' setting
if (!Prog.mcu){
- CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_CHECKED);
+ CheckMenuItem(ProcessorMenu,
+ ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_CHECKED);
}
else {
- CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_UNCHECKED);
+ CheckMenuItem(ProcessorMenu,
+ ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_UNCHECKED);
}
}
@@ -1121,35 +732,6 @@ void GenerateIoListDontLoseSelection(void)
void MainWindowResized(void)
{
IoListTop = DrawWindow->height();
- //PaintWindow();
- /*RECT main;
- //GetClientRect(DrawWindow, &main);
-
- RECT status;
- // GetWindowRect(StatusBar, &status);
- // int statusHeight = status.bottom - status.top;
-
- // MoveWindow(StatusBar, 0, main.bottom - statusHeight, main.right,
- // statusHeight, TRUE);
-
- // Make sure that the I/O list can't disappear entirely.
- if(IoListHeight < 30) {
- IoListHeight = 30;
- }
- //IoListTop = main.bottom ;//- IoListHeight - statusHeight;
-
- // Make sure that we can't drag the top of the I/O list above the
- // bottom of the menu bar, because it then becomes inaccessible.
- if(IoListTop < 5) {
- IoListHeight = main.bottom - 5;//- statusHeight - 5;
- IoListTop = main.bottom - IoListHeight;// - statusHeight;
- }*/
- // DrawWindow->resize(MainWindow->width(),MainWindow->height() - IoListHeight);
- // MoveWindow(IoList, 0, IoListTop, main.right, IoListHeight, TRUE);
-
- // RefreshScrollbars();
-
- // InvalidateRect(DrawWindow, NULL, FALSE);
}
@@ -1163,7 +745,7 @@ void StartSimulation(void)
EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED);
EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_ENABLED);
StartSimulationTimer();
- // UpdateMainWindowTitleBar();
+ UpdateMainWindowTitleBar();
}
//-----------------------------------------------------------------------------
@@ -1178,5 +760,5 @@ void StopSimulation(void)
EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED);
KillTimer(DrawWindow, TIMER_SIMULATE);
- // UpdateMainWindowTitleBar();
+ UpdateMainWindowTitleBar();
} \ No newline at end of file
diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp
index 41eda28..77b2791 100644
--- a/ldmicro/miscutil.cpp
+++ b/ldmicro/miscutil.cpp
@@ -208,55 +208,10 @@ QDialog* CreateWindowClient(char *windowName,
QDialog* h = new QDialog(parent);
h->resize(width, height);
h->setWindowTitle(windowName);
- // HWND h = CreateWindowEx(exStyle, className, windowName, style, x, y,
- // width, height, parent, menu, instance, param);
-
- // RECT r;
- // GetClientRect(h, &r);
- // width = width - (r.right - width);
- // height = height - (r.bottom - height);
-
- // SetWindowPos(h, HWND_TOP, x, y, width, height, 0);
return h;
}
-//-----------------------------------------------------------------------------
-// Window proc for the dialog boxes. This Ok/Cancel stuff is common to a lot
-// of places, and there are no other callbacks from the children.
-//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam,
-// LPARAM lParam)
-// {
- // switch (msg) {
- // case WM_NOTIFY:
- // break;
-
- // case WM_COMMAND: {
- // HWND h = (HWND)lParam;
- // if(h == OkButton && wParam == BN_CLICKED) {
- // DialogDone = TRUE;
- // } else if(h == CancelButton && wParam == BN_CLICKED) {
- // DialogDone = TRUE;
- // DialogCancel = TRUE;
- // }
- // break;
- // }
-
- // case WM_CLOSE:
- // case WM_DESTROY:
- // DialogDone = TRUE;
- // DialogCancel = TRUE;
- // break;
-
- // default:
- // return DefWindowProc(hwnd, msg, wParam, lParam);
- // }
-
-// return 1;
-// }
-
-
//-----------------------------------------------------------------------------
// Set the font of a control to a pretty proportional font (typ. Tahoma).
@@ -299,7 +254,6 @@ void SetFont(HWID h, HFONT f)
qtfont.setStyle(f->fdwItalic ? QFont::StyleItalic : QFont::StyleNormal);
qtfont.setWeight(f->fnWeight == FW_BOLD ? QFont::Bold : QFont::Normal);
h->setFont(qtfont);
- // SendMessage(h, WM_SETFONT, (WPARAM)MyFixedFont, TRUE);
}
//-----------------------------------------------------------------------------
@@ -307,34 +261,9 @@ void SetFont(HWID h, HFONT f)
//-----------------------------------------------------------------------------
void MakeDialogBoxClass(void)
{
- // WNDCLASSEX wc;
- // memset(&wc, 0, sizeof(wc));
- // wc.cbSize = sizeof(wc);
-
- // wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC |
- // CS_DBLCLKS;
- // wc.lpfnWndProc = (WNDPROC)DialogProc;
- // wc.hInstance = Instance;
- // wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
- // wc.lpszClassName = "LDmicroDialog";
- // wc.lpszMenuName = NULL;
- // wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- // wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
- // IMAGE_ICON, 32, 32, 0);
- // wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
- // IMAGE_ICON, 16, 16, 0);
-
- // RegisterClassEx(&wc);
-
MyNiceFont = CreateFont(16, 0, 0, FW_REGULAR, FALSE, "Tahoma");
- // if(!MyNiceFont)
- // MyNiceFont = (HFONT)GetStockObject(SYSTEM_FONT);
-
MyFixedFont = CreateFont(14, 0, 0, FW_REGULAR, FALSE, "Lucida Console");
-
- // if(!MyFixedFont)
- // MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT);
}
//-----------------------------------------------------------------------------
diff --git a/ldmicro/resetdialog.cpp b/ldmicro/resetdialog.cpp
index 54df78c..0d155b8 100644
--- a/ldmicro/resetdialog.cpp
+++ b/ldmicro/resetdialog.cpp
@@ -118,35 +118,4 @@ void ShowResetDialog(char *name)
break;
}
DestroyWindow();
- /*ResetGrid = gtk_grid_new();
- ResetPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-
- ResetDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(ResetDialog), "Reset");
- gtk_window_set_default_size(GTK_WINDOW(ResetDialog), 100, 50);
- gtk_window_set_resizable (GTK_WINDOW (ResetDialog), FALSE);
- gtk_container_add(GTK_CONTAINER(ResetDialog), ResetPackingBox);
- gtk_widget_add_events (ResetDialog, GDK_KEY_PRESS_MASK);
- gtk_widget_add_events (ResetDialog, GDK_BUTTON_PRESS_MASK);
-
- MakeControls();
-
- if(name[0] == 'T') {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (TypeTimerRadio), TRUE);
- }
- else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (TypeCounterRadio), TRUE);
- }
- gtk_entry_set_text (GTK_ENTRY (NameTextbox), name+1);
-
- gtk_widget_set_sensitive (MainWindow, FALSE);
- gtk_widget_show_all (ResetDialog);
- gtk_widget_grab_focus (NameTextbox);
-
- g_signal_connect (G_OBJECT (ResetDialog), "key-press-event",
- G_CALLBACK(ResetDialogKeyPress), (gpointer)name);
- g_signal_connect (G_OBJECT (OkButton), "clicked",
- G_CALLBACK(ResetDialogMouseClick), (gpointer)name);
- g_signal_connect (G_OBJECT (CancelButton), "clicked",
- G_CALLBACK(ResetCallDestroyWindow), NULL);*/
}
diff --git a/ldmicro/simpledialog.cpp b/ldmicro/simpledialog.cpp
index 6256ef8..c9a9e77 100644
--- a/ldmicro/simpledialog.cpp
+++ b/ldmicro/simpledialog.cpp
@@ -145,8 +145,6 @@ BOOL ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask,
new QRegExpValidator(QRegExp("-?[0-9]+[.]?[0-9]+")));
}
if(alnumOnlyMask & (1 << i)) {
- /*PrevAlnumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
- (LONG_PTR)MyAlnumOnlyProc);*/
Textboxes[i]->setValidator(
new QRegExpValidator(
QRegExp("[a-zA-Z0-9_'-]+")));
diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp
index 6c25e49..7211e96 100644
--- a/ldmicro/simulate.cpp
+++ b/ldmicro/simulate.cpp
@@ -815,43 +815,6 @@ void SimulationToggleContact(char *name)
// ListView_RedrawItems(IoList, 0, Prog.io.count - 1);
}
-//-----------------------------------------------------------------------------
-// Dialog proc for the popup that lets you interact with the UART stuff.
-//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK UartSimulationProc(HWND hwnd, UINT msg,
-// WPARAM wParam, LPARAM lParam)
-// {
-// switch (msg) {
-// case WM_DESTROY:
-// DestroyUartSimulationWindow();
-// break;
-
-// case WM_CLOSE:
-// break;
-
-// case WM_SIZE:
-// MoveWindow(UartSimulationTextControl, 0, 0, LOWORD(lParam),
-// HIWORD(lParam), TRUE);
-// break;
-
-// case WM_ACTIVATE:
-// if(wParam != WA_INACTIVE) {
-// SetFocus(UartSimulationTextControl);
-// }
-// break;
-
-// default:
-// return DefWindowProc(hwnd, msg, wParam, lParam);
-// }
-// return 1;
-// }
-
-//-----------------------------------------------------------------------------
-// Intercept WM_CHAR messages that to the terminal simulation window so that
-// we can redirect them to the PLC program.
-//
-// Ported: Read and write text fron the text view widget.
-//-----------------------------------------------------------------------------
static void UartSimulationTextProc(/*HWID hwid, UINT umsg, char *text, UINT uszbuf*/)
{
char text = UartSimulationTextControl->toPlainText().toStdString().back();
@@ -865,48 +828,6 @@ static void UartSimulationTextProc(/*HWID hwid, UINT umsg, char *text, UINT uszb
return;
}
QueuedUartCharacter = (BYTE)(text);
-
- /*switch(umsg)
- {
- case WM_SETTEXT:
- {
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(hwid));
- gtk_text_buffer_set_text (buffer, text, -1);
- gtk_text_view_set_buffer (GTK_TEXT_VIEW(hwid), buffer);
-
- GtkTextIter end;
- gtk_text_buffer_get_end_iter (buffer, &end);
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW(hwid), &end, 0.2, FALSE, 1, 1);
- break;
- }
- case WM_SETTEXT_END:
- {
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(hwid));
- gtk_text_buffer_insert_at_cursor (buffer, text, -1);
- gtk_text_view_set_buffer (GTK_TEXT_VIEW(hwid), buffer);
-
- GtkTextIter end;
- gtk_text_buffer_get_end_iter (buffer, &end);
- gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW(hwid), &end, 0.2, FALSE, 1, 1);
- break;
- }
- case WM_GETTEXT:
- {
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(hwid));
- GtkTextIter start, end;
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
-
- char *txtBuf = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
-
- strcpy(text, txtBuf);
- strcat(text, "\0");
- g_free(txtBuf);
- break;
- }
- default:
- break;
- }*/
}
//-----------------------------------------------------------------------------
@@ -954,29 +875,6 @@ void ShowUartSimulationWindow(void)
UartSimulationWindow->show();
MainWindow->setFocus();
UARTWindowInitialized = TRUE;
- // UartSimulationTextControl->document()->setModified(false);
- // UartSimulationTextControl->setPlainText("H");
-
- /*UartSimulationTextControl = gtk_text_view_new();
-
- gtk_widget_override_font(GTK_WIDGET(UartSimulationTextControl), pango_font_description_from_string("Lucida Console"));
-
- /// Add text view into a scrolled window to enable scrolling functionality
- HWID TextViewScroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (TextViewScroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_hexpand(GTK_WIDGET(TextViewScroll), TRUE);
- gtk_widget_set_vexpand(GTK_WIDGET(TextViewScroll), TRUE);
-
- gtk_container_add (GTK_CONTAINER(TextViewScroll), UartSimulationTextControl);
- gtk_container_add (GTK_CONTAINER(UartSimulationWindow), TextViewScroll);
-
- gtk_widget_show_all(UartSimulationWindow);
-
- gtk_window_set_keep_above (GTK_WINDOW(MainWindow), TRUE);
- gtk_window_set_focus_visible (GTK_WINDOW(MainWindow), TRUE);
- gtk_window_set_keep_above (GTK_WINDOW(MainWindow), FALSE);*/
}
//-----------------------------------------------------------------------------
diff --git a/ldmicro/undoredo.cpp b/ldmicro/undoredo.cpp
index 3f9407a..40ea231 100644
--- a/ldmicro/undoredo.cpp
+++ b/ldmicro/undoredo.cpp
@@ -200,7 +200,7 @@ void UndoUndo(void)
SetUndoEnabled(FALSE, TRUE);
}
RefreshControlsToSettings();
- RefreshScrollbars();
+ // RefreshScrollbars();
InvalidateRect(MainWindow, NULL, FALSE);
}
@@ -223,7 +223,7 @@ void UndoRedo(void)
SetUndoEnabled(TRUE, FALSE);
}
RefreshControlsToSettings();
- RefreshScrollbars();
+ // RefreshScrollbars();
InvalidateRect(MainWindow, NULL, FALSE);
}