summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/CMakeLists.txt7
-rw-r--r--ldmicro/circuit.cpp16
-rw-r--r--ldmicro/draw.cpp46
-rw-r--r--ldmicro/draw_outputdev.cpp130
-rw-r--r--ldmicro/includes/ldmicro.h20
-rw-r--r--ldmicro/ldmicro.cpp16
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp8
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h25
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp161
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h35
-rw-r--r--ldmicro/maincontrols.cpp40
-rw-r--r--ldmicro/schematic.cpp17
-rw-r--r--ldmicro/simulate.cpp12
-rw-r--r--ldmicro/undoredo.cpp12
14 files changed, 316 insertions, 229 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index 42ec750..8e60465 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -104,12 +104,16 @@ IF(UNIX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Widgets CONFIG REQUIRED)
find_package(Qt5Core CONFIG REQUIRED)
+ find_package(Qt5Gui CONFIG REQUIRED)
get_target_property(Qt5Widgets_INCLUDES Qt5::Widgets INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(Qt5Core_INCLUDES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(Qt5Gui_INCLUDES Qt5::Gui INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${Qt5Widgets_INCLUDES})
include_directories(${Qt5Core_INCLUDES})
+ include_directories(${Qt5Gui_INCLUDES})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5Core_DEFINITIONS})
+ include_directories(${Qt5Gui_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
#get_target_property(CMAKE_CXX_FLAGS Qt5::Core LINK_FLAGS)
MESSAGE ( STATUS " Qt INCLUDEs: " ${Qt5Core_INCLUDES} )
@@ -142,7 +146,7 @@ endif()
#coildialog.cpp
#contactsdialog.cpp
#commentdialog.cpp
- # simulate.cpp
+ simulate.cpp
loadsave.cpp
undoredo.cpp
circuit.cpp
@@ -166,6 +170,7 @@ endif()
target_link_libraries (LDMicro FreezeLD)
target_link_libraries(LDMicro ${Qt5Widgets_LIBRARIES})
target_link_libraries(LDMicro ${Qt5Core_LIBRARIES})
+ target_link_libraries(LDMicro ${Qt5Gui_LIBRARIES})
## Add tests
MESSAGE( STATUS "Adding tests.." )
diff --git a/ldmicro/circuit.cpp b/ldmicro/circuit.cpp
index c04059c..72c59c7 100644
--- a/ldmicro/circuit.cpp
+++ b/ldmicro/circuit.cpp
@@ -657,7 +657,7 @@ void FreeEntireProgram(void)
//-----------------------------------------------------------------------------
// Returns true if the given subcircuit contains the given leaf.
//-----------------------------------------------------------------------------
-/*static BOOL ContainsElem(int which, void *any, ElemLeaf *seek)
+static BOOL ContainsElem(int which, void *any, ElemLeaf *seek)
{
switch(which) {
case ELEM_SERIES_SUBCKT: {
@@ -693,12 +693,12 @@ void FreeEntireProgram(void)
oops();
}
return FALSE;
-}*/
+}
//-----------------------------------------------------------------------------
// Use ContainsElem to find the rung containing the cursor.
//-----------------------------------------------------------------------------
-/*int RungContainingSelected(void)
+int RungContainingSelected(void)
{
int i;
for(i = 0; i < Prog.numRungs; i++) {
@@ -708,7 +708,7 @@ void FreeEntireProgram(void)
}
return -1;
-}*/
+}
//-----------------------------------------------------------------------------
// Delete the rung that contains the cursor.
@@ -829,7 +829,7 @@ void NewProgram(void)
// position of a series subcircuit that may be in a parallel subcircuit that
// etc.)
//-----------------------------------------------------------------------------
-/*static void LastInCircuit(int which, void *any, ElemLeaf *seek,
+static void LastInCircuit(int which, void *any, ElemLeaf *seek,
BOOL *found, BOOL *andItemAfter)
{
switch(which) {
@@ -854,7 +854,7 @@ void NewProgram(void)
if(any == seek) *found = TRUE;
break;
}
-}*/
+}
//-----------------------------------------------------------------------------
// Is an item the last one in the circuit (i.e. does one of its terminals go
@@ -862,7 +862,7 @@ void NewProgram(void)
// circumstance in which it is okay to insert a coil, RES, etc. after
// something
//-----------------------------------------------------------------------------
-/*BOOL ItemIsLastInCircuit(ElemLeaf *item)
+BOOL ItemIsLastInCircuit(ElemLeaf *item)
{
int i = RungContainingSelected();
if(i < 0) return FALSE;
@@ -875,7 +875,7 @@ void NewProgram(void)
if(found) return !andItemAfter;
return FALSE;
-}*/
+}
//-----------------------------------------------------------------------------
// Returns TRUE if the subcircuit contains any of the given instruction
diff --git a/ldmicro/draw.cpp b/ldmicro/draw.cpp
index dc5bf8d..d2feca2 100644
--- a/ldmicro/draw.cpp
+++ b/ldmicro/draw.cpp
@@ -48,7 +48,7 @@ BOOL ThisHighlighted;
if((gx) >= DISPLAY_MATRIX_X_SIZE || (gx) < 0) oops(); \
if((gy) >= DISPLAY_MATRIX_Y_SIZE || (gy) < 0) oops(); \
}
-/*
+
//-----------------------------------------------------------------------------
// The display code is the only part of the program that knows how wide a
// rung will be when it's displayed; so this is the only convenient place to
@@ -68,7 +68,7 @@ static BOOL CheckBoundsUndoIfFails(int gx, int gy)
}
return FALSE;
}
-*/
+
//-----------------------------------------------------------------------------
// Determine the width, in leaf element units, of a particular subcircuit.
// The width of a leaf is 1, the width of a series circuit is the sum of
@@ -180,7 +180,7 @@ static int CountWidthOfElement(int which, void *elem, int soFar)
oops();
}
}
-/*
+
//-----------------------------------------------------------------------------
// Determine the height, in leaf element units, of a particular subcircuit.
// The height of a leaf is 1, the height of a parallel circuit is the sum of
@@ -225,7 +225,7 @@ int CountHeightOfElement(int which, void *elem)
oops();
}
}
-*/
+
//-----------------------------------------------------------------------------
// Determine the width, in leaf element units, of the widest row of the PLC
// program (i.e. loop over all the rungs and find the widest).
@@ -250,7 +250,7 @@ int ProgCountWidestRow(void)
// Draw a vertical wire one leaf element unit high up from (cx, cy), where cx
// and cy are in charcter units.
//-----------------------------------------------------------------------------
-/*static void VerticalWire(HCRDC Hcr, int cx, int cy)
+static void VerticalWire(HCRDC Hcr, int cx, int cy)
{
int j;
for(j = 1; j < POS_HEIGHT; j++) {
@@ -881,32 +881,32 @@ cmp:
}
switch(leaf->selectedState) {
case SELECTED_LEFT:
- Cursor.left = x0 + FONT_WIDTH - 4 - xadj;
- Cursor.top = y0 - FONT_HEIGHT/2;
- Cursor.width = 2;
- Cursor.height = POS_HEIGHT*FONT_HEIGHT;
+ Cursor.setLeft(x0 + FONT_WIDTH - 4 - xadj);
+ Cursor.setTop(y0 - FONT_HEIGHT/2);
+ Cursor.setWidth(2);
+ Cursor.setHeight(POS_HEIGHT*FONT_HEIGHT);
break;
case SELECTED_RIGHT:
- Cursor.left = x0 + (POS_WIDTH-1)*FONT_WIDTH - 5;
- Cursor.top = y0 - FONT_HEIGHT/2;
- Cursor.width = 2;
- Cursor.height = POS_HEIGHT*FONT_HEIGHT;
+ Cursor.setLeft(x0 + (POS_WIDTH-1)*FONT_WIDTH - 5);
+ Cursor.setTop(y0 - FONT_HEIGHT/2);
+ Cursor.setWidth(2);
+ Cursor.setHeight(POS_HEIGHT*FONT_HEIGHT);
break;
case SELECTED_ABOVE:
- Cursor.left = x0 + FONT_WIDTH/2 - xadj;
- Cursor.top = y0 - 2;
- Cursor.width = (POS_WIDTH-2)*FONT_WIDTH + xadj;
- Cursor.height = 2;
+ Cursor.setLeft(x0 + FONT_WIDTH/2 - xadj);
+ Cursor.setTop(y0 - 2);
+ Cursor.setWidth((POS_WIDTH-2)*FONT_WIDTH + xadj);
+ Cursor.setHeight(2);
break;
case SELECTED_BELOW:
- Cursor.left = x0 + FONT_WIDTH/2 - xadj;
- Cursor.top = y0 + (POS_HEIGHT-1)*FONT_HEIGHT +
- FONT_HEIGHT/2 - 2;
- Cursor.width = (POS_WIDTH-2)*(FONT_WIDTH) + xadj;
- Cursor.height = 2;
+ Cursor.setLeft(x0 + FONT_WIDTH/2 - xadj);
+ Cursor.setTop(y0 + (POS_HEIGHT-1)*FONT_HEIGHT +
+ FONT_HEIGHT/2 - 2);
+ Cursor.setWidth((POS_WIDTH-2)*(FONT_WIDTH) + xadj);
+ Cursor.setHeight(2);
break;
default:
@@ -915,7 +915,6 @@ cmp:
return poweredAfter;
}
-
//-----------------------------------------------------------------------------
// Draw a particular subcircuit with its top left corner at *cx and *cy (in
// characters). If it is a leaf element then just print it and return; else
@@ -1067,4 +1066,3 @@ void DrawEndRung(HCRDC Hcr, int cx, int cy)
DrawChars(Hcr, cx + i, cy + (POS_HEIGHT/2), "-");
}
}
-*/
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index 12dcb87..1775104 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -31,7 +31,6 @@
#include "ldmicro.h"
-BOOL InSimulationMode; //Temporary
void (*DrawChars)(HCRDC Hcr, int, int, const char *);
@@ -75,7 +74,7 @@ static BOOL CursorDrawn;
SyntaxHighlightingColours HighlightColours;
#define X_RIGHT_PADDING 30
-/*
+
//-----------------------------------------------------------------------------
// Blink the cursor on the schematic; called by a Windows timer. We XOR
// draw it so just draw the same rectangle every time to show/erase the
@@ -87,50 +86,56 @@ BOOL BlinkCursor(BOOL kill = FALSE)
{
// if(GetFocus(MainWindow) != !CursorDrawn) return TRUE;
- if(Cursor.left == 0) return TRUE;
+ if(Cursor.left() == 0) return TRUE;
- PlcCursor c;
+ QRect c;
memcpy(&c, &Cursor, sizeof(c));
- c.top -= ScrollYOffset*POS_HEIGHT*FONT_HEIGHT;
- c.left -= ScrollXOffset;
+ c.setTop(c.top() - ScrollYOffset*POS_HEIGHT*FONT_HEIGHT);
+ c.setLeft(c.left() - ScrollXOffset);
- if(c.top >= IoListTop) return TRUE;
+ if(c.top() >= IoListTop) return TRUE;
- if(c.top + c.height >= IoListTop) {
- c.height = IoListTop - c.top - 3;
+ if(c.top() + c.height() >= IoListTop) {
+ c.setHeight(IoListTop - c.top() - 3);
}
+ if(DrawWindow == NULL)
+ return FALSE;
// if(!GDK_IS_DRAWING_CONTEXT(Hdc))
// return FALSE;
- HCRDC Hcr = gdk_cairo_create(gtk_widget_get_window(DrawWindow));
+ // HCRDC Hcr = gdk_cairo_create(gtk_widget_get_window(DrawWindow));
+ HWID Hcr = DrawWindow;
- static int PREV_x = c.left;
- static int PREV_y = c.top;
- static int PREV_w = c.width;
- static int PREV_h = c.height;
+ static int PREV_x = c.left();
+ static int PREV_y = c.top();
+ 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())
{
- PatBlt(Hcr, PREV_x, PREV_y, PREV_w, PREV_h, PATINVERT, (HBRUSH)GetStockObject(BLACK_BRUSH));
- PREV_x = c.left;
- PREV_y = c.top;
- PREV_w = c.width;
- PREV_h = c.height;
+ CursorObject->setGeometry(c);
+ CursorObject->setVisible(TRUE);
+ PREV_x = c.left();
+ PREV_y = c.top();
+ PREV_w = c.width();
+ PREV_h = c.height();
// MainWindowResized();
// PaintWindow(Hcr);
- gtk_widget_queue_draw(DrawWindow);
+ // gtk_widget_queue_draw(DrawWindow);
}
+ CursorObject->setGeometry(c);
- if (CursorDrawn)
- PatBlt(Hcr, c.left, c.top, c.width, c.height, PATINVERT, (HBRUSH)GetStockObject(WHITE_BRUSH));
+ if (CursorObject->isVisible())
+ CursorObject->setVisible(FALSE);
else
- PatBlt(Hcr, c.left, c.top, c.width, c.height, PATINVERT, (HBRUSH)GetStockObject(BLACK_BRUSH));
+ // 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;
+ // cairo_destroy(Hcr);
+ // CursorDrawn = !CursorDrawn;
return !kill;
}
@@ -144,6 +149,7 @@ 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;
@@ -213,7 +219,7 @@ static void DrawCharsToScreen(HCRDC Hcr, int cx, int cy, const char *str)
firstTime = FALSE;
}
}
-*/
+
//-----------------------------------------------------------------------------
// Total number of columns that we can display in the given amount of
// window area. Need to leave some slop on the right for the scrollbar, of
@@ -225,7 +231,7 @@ int ScreenColsAvailable(void)
return (rw - (X_PADDING + X_RIGHT_PADDING)) / (POS_WIDTH*FONT_WIDTH);
}
-/*
+
//-----------------------------------------------------------------------------
// Total number of columns that we can display in the given amount of
// window area. Need to leave some slop on the right for the scrollbar, of
@@ -242,29 +248,29 @@ int ScreenRowsAvailable(void)
}
return (IoListTop - Y_PADDING - adj) / (POS_HEIGHT*FONT_HEIGHT);
}
-*/
+
+void PaintWidget::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == CursorTimer)
+ BlinkCursor();
+}
+
//-----------------------------------------------------------------------------
// Paint the ladder logic program to the screen. Also figure out where the
// cursor should go and fill in coordinates for BlinkCursor. Not allowed to
// draw deeper than IoListTop, as we would run in to the I/O listbox.
//-----------------------------------------------------------------------------
-void PaintWindow()
+void PaintWidget::paintEvent(QPaintEvent *event)
{
- ok();
- // DrawWindow->setStyleSheet("background-color:black;");
+ QPainter painter(this);
+ painter.setClipping(true);
+ painter.setRenderHint(QPainter::TextAntialiasing);
+ HCRDC Hcr = &painter;
- static QPalette pal = QPalette(InSimulationMode ?
- SimBgBrush->rgb() : BgBrush->rgb());
- DrawWindow->setPalette(pal);
-
- /// now figure out how we should draw the ladder logic
- ColsAvailable = ProgCountWidestRow();
- if(ColsAvailable < ScreenColsAvailable()) {
- ColsAvailable = ScreenColsAvailable();
- }
+ ok();
- /*int bw = gtk_widget_get_allocated_width (DrawWindow);// = r.right;
- int bh = IoListTop;
+ int bw = this->width();// = r.right;
+ int bh = this->height();
/// now figure out how we should draw the ladder logic
ColsAvailable = ProgCountWidestRow();
@@ -280,6 +286,7 @@ void PaintWindow()
int i;
int cy = 0;
int rowsAvailable = ScreenRowsAvailable();
+
for(i = 0; i < Prog.numRungs; i++) {
int thisHeight = POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT,
Prog.rungs[i]);
@@ -311,7 +318,7 @@ void PaintWindow()
int cx = 0;
DrawElement(Hcr, ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy,
- Prog.rungPowered[i]);
+ Prog.rungPowered[i]);
}
cy += thisHeight;
@@ -322,46 +329,46 @@ void PaintWindow()
if(SelectedGxAfterNextPaint >= 0) {
MoveCursorNear(SelectedGxAfterNextPaint, SelectedGyAfterNextPaint);
- InvalidateRect(DrawWindow, NULL, FALSE);
+ // InvalidateRect(DrawWindow, NULL, FALSE);
SelectedGxAfterNextPaint = -1;
SelectedGyAfterNextPaint = -1;
} else if(ScrollSelectedIntoViewAfterNextPaint && Selected) {
SelectElement(-1, -1, Selected->selectedState);
ScrollSelectedIntoViewAfterNextPaint = FALSE;
- InvalidateRect(DrawWindow, NULL, FALSE);
+ // InvalidateRect(DrawWindow, NULL, FALSE);
} else {
if(!SelectionActive) {
if(Prog.numRungs > 0) {
if(MoveCursorTopLeft()) {
- InvalidateRect(DrawWindow, NULL, FALSE);
+ // InvalidateRect(DrawWindow, NULL, FALSE);
}
}
}
}
/// draw the `buses' at either side of the screen
- RECT r;
- r.left = X_PADDING - FONT_WIDTH;
- r.top = 0;
- r.right = r.left + 4;
- r.bottom = IoListTop;
+ QRect r;
+ r.setLeft(X_PADDING - FONT_WIDTH);
+ r.setTop(0);
+ r.setRight(r.left() + 4);
+ r.setBottom(IoListTop);
FillRect(Hcr, &r, InSimulationMode ? BusLeftBrush : BusBrush);
- r.left += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2;
- r.right += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2;
+ r.setLeft(POS_WIDTH*FONT_WIDTH*ColsAvailable + 32);
+ r.setRight(POS_WIDTH*FONT_WIDTH*ColsAvailable + 32);
FillRect(Hcr, &r, InSimulationMode ? BusRightBus : BusBrush);
- InvalidateRect(DrawWindow, NULL, FALSE);
+ // InvalidateRect(DrawWindow, NULL, FALSE);
- CursorDrawn = FALSE;
+ // CursorDrawn = FALSE;
// BitBlt(paintDc, 0, 0, bw, bh, BackDc, ScrollXOffset, 0, SRCCOPY);
- if(InSimulationMode) {
+ /*if(InSimulationMode) {
KillTimer(DrawWindow, TIMER_BLINK_CURSOR);
} else {
SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 200, BlinkCursor);
- }
+ }*/
- ok();*/
+ ok();
}
//-----------------------------------------------------------------------------
@@ -403,7 +410,7 @@ static void SetSyntaxHighlightingColours(void)
//-----------------------------------------------------------------------------
void InitForDrawing(void)
{
- DrawWindow = new QWidget;
+ DrawWindow = new PaintWidget();
SetSyntaxHighlightingColours();
FixedWidthFont = CreateFont(
@@ -442,7 +449,7 @@ void InitForDrawing(void)
// DrawChars function, for drawing to the export buffer instead of to the
// screen.
//-----------------------------------------------------------------------------
-/*static void DrawCharsToExportBuffer(HCRDC Hcr, int cx, int cy, const char *str)
+static void DrawCharsToExportBuffer(HCRDC Hcr, int cx, int cy, const char *str)
{
while(*str) {
if(*str >= 10) {
@@ -609,4 +616,3 @@ void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert)
if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax;
if(ScrollYOffset < 0) ScrollYOffset = 0;
}
-*/ \ No newline at end of file
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index c5db57f..4372bfd 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -38,11 +38,7 @@ typedef signed long SDWORD;
// Size of the font that we will use to draw the ladder diagrams, in pixels
#define FONT_WIDTH 7
-#define FONT_HEIGHT 13
-
-// Timer IDs associated with the main window.
-#define TIMER_BLINK_CURSOR 1
-#define TIMER_SIMULATE 2
+#define FONT_HEIGHT 14
//-----------------------------------------------
// Constants for the GUI. We have drop-down menus, a listview for the I/Os,
@@ -299,6 +295,10 @@ extern HWID PinList;
#define MAX_COMMENT_LEN 384
#define MAX_LOOK_UP_TABLE_LEN 60
+// Timer IDs associated with the main window.
+extern int CursorTimer;
+extern int SimulateTimer;
+
typedef struct ElemSubckParallelTag ElemSubcktParallel;
typedef struct ElemCommentTag {
@@ -495,7 +495,7 @@ typedef struct PlcProgramTag {
#define X_PADDING 35
#define Y_PADDING 14
-typedef struct PlcCursorTag {
+typedef class PlcCursorTag{
int left;
int top;
int width;
@@ -683,7 +683,7 @@ extern ElemLeaf DisplayMatrixFiller;
extern ElemLeaf *Selected;
extern int SelectedWhich;
-extern PlcCursor Cursor;
+extern QRect Cursor;
extern BOOL CanInsertEnd;
extern BOOL CanInsertOther;
extern BOOL CanInsertComment;
@@ -711,7 +711,7 @@ void AddFormattedString(void);
void DeleteSelectedFromProgram(void);
void DeleteSelectedRung(void);
void InsertRung(BOOL afterCursor);
-int RungContainingSelected(void);
+int RungContainingSelected(void);
BOOL ItemIsLastInCircuit(ElemLeaf *item);
BOOL UartFunctionUsed(void);
BOOL PwmFunctionUsed(void);
@@ -734,7 +734,7 @@ BOOL LoadProjectFromFile(char *filename);
BOOL SaveProjectToFile(char *filename);
// iolist.cpp
-int GenerateIoList(int prevSel);
+int GenerateIoList(int prevSel);
void SaveIoListToFile(FILE *f);
BOOL LoadIoListFromFile(FILE *f);
void ShowIoDialog(int item);
@@ -749,7 +749,7 @@ void ShowContactsDialog(BOOL *negated, char *name);
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name);
//naminglist.cpp
-void MakeSmplDialogClass(void);
+void MakeSmplDialogClass(void);
// simpledialog.cpp
void ShowTimerDialog(int which, int *delay, char *name);
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 2b27ce5..95074a7 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -44,11 +44,14 @@ QApplication* LDmicroApp;
HWID MainWindow;
QIcon* MWIcon;
QMenuBar* MainMenu;
+QGroupBox* CursorObject;
HWID DrawWindow;
// parameters used to capture the mouse when implementing our totally non-
// general splitter control
//static HHOOK MouseHookHandle;
static int MouseY;
+int CursorTimer;
+int SimulateTimer;
// For the open/save dialog boxes
#define LDMICRO_PATTERN "LDmicro Ladder Logic Programs (*.ld)\0*.ld\0" \
@@ -282,7 +285,7 @@ static void OpenDialog(void)
RefreshScrollbars();
UpdateMainWindowTitleBar();
}
-
+*/
//-----------------------------------------------------------------------------
// Housekeeping required when the program changes: mark the program as
// changed so that we ask if user wants to save before exiting, and update
@@ -298,7 +301,7 @@ void ProgramChanged(void)
UndoRemember(); \
x; \
ProgramChanged();\
- }*/
+ }
//-----------------------------------------------------------------------------
// Hook that we install when the user starts dragging the `splitter,' in case
@@ -1255,9 +1258,13 @@ int main(int argc, char** argv)
QSize MwSize(800,600);
// Make main window
- MainWindow = new QWidget;
+ MainWindow = new QWidget();
MWIcon = new QIcon(LDMICRO_ICON);
MainMenu = new QMenuBar(MainWindow);
+
+ // Initialize cursor and set color
+ CursorObject = new QGroupBox(DrawWindow);
+ // CursorObject->setColor();
// QMenu TopMenu("Top Menu", MainWindow);
// MainMenu->addMenu(&TopMenu);
@@ -1288,6 +1295,9 @@ int main(int argc, char** argv)
MainWindow->show();
+ /// Blink cursor
+ CursorTimer = SetTimer(DrawWindow, TIMER_BLINK_CURSOR, 500, CursorTimer);
+
GenerateIoListDontLoseSelection();
// MakeDialogBoxClass();
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp
index a83d15e..d43fd0e 100644
--- a/ldmicro/lib/linuxUI/linuxLD.cpp
+++ b/ldmicro/lib/linuxUI/linuxLD.cpp
@@ -119,10 +119,10 @@ HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired,
void RECT_to_GDRECT(const RECT *rc, GDRECT *gdrc)
{
- gdrc->x = rc->left;
- gdrc->y = rc->top;
- gdrc->width = rc->right - rc->left;
- gdrc->height = rc->bottom - rc->top;
+ // gdrc->x = rc->left;
+ // gdrc->y = rc->top;
+ // gdrc->width = rc->right - rc->left;
+ // gdrc->height = rc->bottom - rc->top;
}
void OutputDebugString(char* str)
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index f1abbaf..470c7cc 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -70,18 +70,19 @@ typedef PVOID HANDLE;
typedef HANDLE HINSTANCE;
typedef HANDLE HGDIOBJ;
-typedef cairo_t *HCRDC;
-typedef QWidget* HWID;
-typedef QWidget* HWND;
-typedef QTreeWidget *HLIST;
-typedef GtkTreeIter ITLIST;
-typedef GtkApplication *HAPP;
-typedef GtkTreeViewColumn *HTVC;
-typedef GdkPixbuf *HICON;
-typedef GdkRectangle GDRECT;
-typedef GDRECT *PGDRECT;
-typedef QMenu* HMENU;
-typedef ITLIST *HITLIST;
+typedef GtkApplication* HAPP;
+typedef GtkTreeViewColumn* HTVC;
+typedef GdkRectangle* GDRECT;
+typedef QTreeWidget* HLIST;
+typedef GtkTreeIter ITLIST;
+typedef GDRECT* PGDRECT;
+typedef QMenu* HMENU;
+typedef ITLIST* HITLIST;
+typedef QPainter* HCRDC;
+typedef QWidget* HWID;
+typedef QWidget* HWND;
+typedef GdkPixbuf* HICON;
+
/// Check if system is x64 or x86
#if defined(__UNIX64)
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index e8a8ab5..3f8896c 100644
--- a/ldmicro/lib/linuxUI/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -236,28 +236,40 @@ BOOL GetOpenFileName(OPENFILENAME *ofn)
}
+void EnableMenuItem(HMENU MenuName, QAction* MenuItem, UINT CheckEnabledItem)
+{
+ switch (CheckEnabledItem){
+ case MF_ENABLED :
+ MenuItem->setEnabled(true);
+ break;
+ case MF_GRAYED :
+ MenuItem->setEnabled(false);
+ break;
+ }
+}
+
void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem)
{
- /*switch (CheckEnabledItem){
+ switch (CheckEnabledItem){
case MF_ENABLED :
- gtk_widget_set_sensitive (MenuItem, true);
+ MenuItem->setEnabled(true);
break;
case MF_GRAYED :
- gtk_widget_set_sensitive (MenuItem, false);
+ MenuItem->setEnabled(false);
break;
- }*/
+ }
}
-void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check)
+void CheckMenuItem(HMENU MenuName, QAction* MenuItem, UINT Check)
{
- /*switch (Check){
+ switch (Check){
case MF_CHECKED :
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), true);
+ MenuItem->setChecked(true);
break;
case MF_UNCHECKED :
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), false);
+ MenuItem->setChecked(false);
break;
- }*/
+ }
}
HANDLE GetStockObject(int fnObject)
@@ -288,22 +300,13 @@ void SelectObject(HCRDC hcr, HFONT hfont)
{
if (hcr ==NULL)
return;
-
- cairo_select_font_face(hcr, hfont->lpszFace,
- hfont->fdwItalic ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
- hfont->fnWeight == FW_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);
-
- cairo_rotate(hcr, hfont->nOrientation);
- // cairo_text_extents_t extents;
- // cairo_text_extents (hcr, "Z", &extents);
- // cairo_matrix_t matrix;
- // cairo_matrix_init_scale (&matrix,
- // (double)hfont->nWidth,
- // (double)hfont->nHeight);
-
- // cairo_set_font_matrix (hcr, &matrix);
-
- cairo_set_font_size(hcr, 10);
+ QFont qtfont = hcr->font();
+ qtfont.setFamily(hfont->lpszFace);
+ qtfont.setPixelSize(hfont->nHeight - 3);
+ qtfont.setFixedPitch(TRUE);
+ qtfont.setStyle(hfont->fdwItalic ? QFont::StyleItalic : QFont::StyleNormal);
+ qtfont.setWeight(hfont->fnWeight == FW_BOLD ? QFont::Bold : QFont::Normal);
+ hcr->setFont(qtfont);
}
HBRUSH CreateBrushIndirect(PLOGBRUSH plb)
@@ -334,41 +337,54 @@ HFONT CreateFont(int nHeight, int nWidth, int nOrientation, int fnWeight,
void SetBkColor(HWID widget, HCRDC hcr, COLORREF bkCol)
{
-/* if (hcr == NULL)
- return;
-
- gtk_widget_override_background_color(GTK_WIDGET(widget),
- GTK_STATE_FLAG_NORMAL, &bkCol);
-
- gint width = gtk_widget_get_allocated_width (widget);
- gint height = gtk_widget_get_allocated_height (widget);
-
- // COLORREF col;
- // GtkStyleContext *context;
-
- // context = gtk_widget_get_style_context (widget);
-
- // gtk_style_context_get_color (context,
- // gtk_style_context_get_state (context),
- // &col);
- gdk_cairo_set_source_rgba (hcr, &bkCol);
- // cairo_rectangle(hcr, 0, 0, width, height);
- // cairo_stroke_preserve(hcr);
-
- cairo_fill (hcr);*/
+ QPalette pal = widget->palette();
+ pal.setColor(QPalette::Background, bkCol);
+ widget->setPalette(pal);
}
void SetTextColor(HCRDC hcr, COLORREF color)
{
if (hcr == NULL)
return;
-
+ QPen qtpen = hcr->pen();
+ qtpen.setColor(color);
+ hcr->setPen(qtpen);
HdcCurrentTextColor = color;
// gdk_cairo_set_source_rgba (hcr, &color);
}
void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, int cchString)
{
+ if (hcr == NULL)
+ return;
+ int width = hWid->width();
+ 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;
@@ -431,13 +447,19 @@ BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase)
// gtk_widget_queue_draw(hWid);
gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE);
*/
+ hWid->repaint();
return TRUE;
}
-int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr)
+int FillRect(HCRDC hDC, const QRect *lprc, HBRUSH hbr)
{
if (hDC == NULL)
return -1;
+ QBrush curbrush = hDC->brush();
+ curbrush.setColor(*hbr);
+ curbrush.setStyle(Qt::SolidPattern);
+ hDC->setBrush(curbrush);
+ hDC->drawRect(*lprc);
/*
GDRECT gdrc;
RECT_to_GDRECT(lprc, &gdrc);
@@ -450,7 +472,7 @@ int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr)
return 0;
}
-BOOL PatBlt(HCRDC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD dwRop, HBRUSH hbr)
+BOOL PatBlt(HWID hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD dwRop, HBRUSH hbr)
{
if (hdc == NULL)
return FALSE;
@@ -503,20 +525,37 @@ BOOL GetWindowRect(HWID hWid, PRECT pRect)
}
-UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, BOOL (*lpTimerFunc)(BOOL) )
+UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID)
{
- auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; });
+ if(TimerID != NULL)
+ return nIDEvent;
+ if(nIDEvent == TIMER_BLINK_CURSOR)
+ {
+ TimerID = hWid->startTimer(uElapse);
+ CursorObject = new QGroupBox(hWid);
+
+ QPalette pal = CursorObject->palette();
+ pal.setColor(QPalette::Background, Qt::white);
+ CursorObject->setAutoFillBackground(true);
+ CursorObject->setPalette(pal);
+ // CursorObject->setGeometry(100,100,2,20);
+ }
+ // if(hWid!=NULL)
+ // CursorObject->setVisible(TRUE);
- if (record_it != timerRecords.end())
- return 0;
+ return TimerID;
+ // auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; });
- TimerRecord tr;
- tr.pfun = lpTimerFunc;
- tr.ufID = nIDEvent;
- tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE);
+ // if (record_it != timerRecords.end())
+ // return 0;
- timerRecords.push_back(tr);
- return tr.utID;
+ // 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)
@@ -540,3 +579,5 @@ void DestroyWindow (HWID widget)
gtk_widget_destroy (widget);
}*/
}
+
+
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index e482051..7054b61 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -9,6 +9,9 @@
#include <QMenuBar>
#include <QVBoxLayout>
#include <QLabel>
+#include <QPainter>
+#include <QGroupBox>
+// #include <QtGui>
// #include <QSize>
// #include "freezeLD.h"
// #include "linuxLD.h"
@@ -25,6 +28,10 @@
#define LDMicro_VERSION_MAJOR 1
#define LDMicro_VERSION_MINOR 0
+// Timer IDs associated with the main window.
+#define TIMER_BLINK_CURSOR 1
+#define TIMER_SIMULATE 2
+
/// Flags
/// message box
#define MB_OK 0x00000001L
@@ -127,6 +134,7 @@ extern const UINT MF_UNCHECKED;
/// Accelerators (keyboard shortcuts)
extern GtkAccelGroup* AccelGroup;
extern GClosure* closure;
+extern QGroupBox* CursorObject;
/// ListStore
extern HWID view;
@@ -175,12 +183,17 @@ BOOL GetOpenFileName(OPENFILENAME *ofn);
void EnableMenuItem(
HMENU MenuName,
+ QAction* MenuItem,
+ UINT CheckEnabledItem);
+
+void EnableMenuItem(
+ HMENU MenuName,
HMENU MenuItem,
UINT CheckEnabledItem);
void CheckMenuItem(
HMENU MenuName,
- HMENU MenuItem,
+ QAction* MenuItem,
UINT Check);
HANDLE GetStockObject(int fnObject);
@@ -225,11 +238,11 @@ BOOL InvalidateRect(
int FillRect(
HCRDC hDC,
- const RECT *lprc,
+ const QRect *lprc,
HBRUSH hbr);
BOOL PatBlt(
- HCRDC hdc,
+ HWID hdc,
int nXLeft,
int nYLeft,
int nWidth,
@@ -257,7 +270,7 @@ UINT SetTimer(
HWID hWid,
UINT nIDEvent,
UINT uElapse,
- BOOL (*lpTimerFunc)(BOOL));
+ UINT TimerID);
BOOL KillTimer(
HWID hWid,
@@ -265,6 +278,18 @@ BOOL KillTimer(
void DestroyWindow (HWID widget);
-
+class PaintWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ // MyWidget();
+
+protected:
+ void paintEvent(QPaintEvent *event);
+ void timerEvent(QTimerEvent *event);
+signals:
+
+public slots:
+};
#endif \ No newline at end of file
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 976688b..fa45cdd 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -710,7 +710,7 @@ void MakeMainWindowControls(void)
/// Adding box to Main Window
gtk_container_add(GTK_CONTAINER(MainWindow), PackBoxMenu);*/
}
-/*
+
//-----------------------------------------------------------------------------
// Adjust the size and visibility of the scrollbars as necessary, either due
// to a change in the size of the program or a change in the size of the
@@ -718,8 +718,8 @@ void MakeMainWindowControls(void)
//-----------------------------------------------------------------------------
void RefreshScrollbars(void)
{
- SCROLLINFO vert, horiz;
- SetUpScrollbars(&NeedHoriz, &horiz, &vert);
+ // SCROLLINFO vert, horiz;
+ // SetUpScrollbars(&NeedHoriz, &horiz, &vert);
// SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE);
// SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE);
@@ -741,9 +741,9 @@ void RefreshScrollbars(void)
// MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth,
// NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE);
- InvalidateRect(DrawWindow, NULL, FALSE);
+ // 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.
@@ -866,7 +866,7 @@ void UpdateMainWindowTitleBar(void)
gtk_window_set_title (GTK_WINDOW (MainWindow), line);
}
-
+*/
//-----------------------------------------------------------------------------
// Set the enabled state of the logic menu items to reflect where we are on
// the schematic (e.g. can't insert two coils in series).
@@ -935,7 +935,7 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
EnableMenuItem(InstructionMenu, InsertUartSendMenu, t);
EnableMenuItem(InstructionMenu, InsertUartRecvMenu, t);
EnableMenuItem(InstructionMenu, InsertFmtdStrMenu, t);
-}*/
+}
//-----------------------------------------------------------------------------
// Set the enabled state of the undo/redo menus.
@@ -950,7 +950,7 @@ void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
// Toggle whether we are in simulation mode. A lot of options are only
// available in one mode or the other.
//-----------------------------------------------------------------------------
-/*void ToggleSimulationMode(void)
+void ToggleSimulationMode(void)
{
InSimulationMode = !InSimulationMode;
if(InSimulationMode) {
@@ -973,13 +973,13 @@ void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
ClearSimulationData(); // simulation.cpp, ldmicro.h
// Recheck InSimulationMode, because there could have been a Compile
// error, which would have kicked us out of simulation mode.
- if(UartFunctionUsed() && InSimulationMode) {
+ /*if(UartFunctionUsed() && InSimulationMode) {
ShowUartSimulationWindow(); // simulate.cpp
- }
+ }*/
}
else {
RealTimeSimulationRunning = FALSE;
- KillTimer(MainWindow, TIMER_SIMULATE);
+ // KillTimer(MainWindow, TIMER_SIMULATE);
EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED);
EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED);
@@ -1003,10 +1003,10 @@ void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
}
}
- UpdateMainWindowTitleBar();
+ // UpdateMainWindowTitleBar();
RefreshControlsToSettings();
}
-*/
+
//-----------------------------------------------------------------------------
// Cause the status bar and the list view to be in sync with the actual data
// structures describing the settings and the I/O configuration. Listview
@@ -1156,7 +1156,8 @@ void GenerateIoListDontLoseSelection(void)
//-----------------------------------------------------------------------------
void MainWindowResized(void)
{
- PaintWindow();
+ IoListTop = DrawWindow->height();
+ //PaintWindow();
/*RECT main;
//GetClientRect(DrawWindow, &main);
@@ -1185,8 +1186,9 @@ void MainWindowResized(void)
// RefreshScrollbars();
// InvalidateRect(DrawWindow, NULL, FALSE);
+
}
-/*
+
//-----------------------------------------------------------------------------
// Start real-time simulation. Have to update the controls grayed status
// to reflect this.
@@ -1197,7 +1199,7 @@ void StartSimulation(void)
EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED);
EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_ENABLED);
StartSimulationTimer();
- UpdateMainWindowTitleBar();
+ // UpdateMainWindowTitleBar();
}
//-----------------------------------------------------------------------------
@@ -1210,7 +1212,7 @@ void StopSimulation(void)
EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_ENABLED);
EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED);
- KillTimer(MainWindow, TIMER_SIMULATE);
+ // KillTimer(MainWindow, TIMER_SIMULATE);
- UpdateMainWindowTitleBar();
-}*/ \ No newline at end of file
+ // UpdateMainWindowTitleBar();
+} \ No newline at end of file
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index 9c5e9b3..b2a61ec 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -52,13 +52,13 @@ ElemLeaf DisplayMatrixFiller;
// where the cursor should go and calculate the coordinates (in pixels)
// of the rectangle that describes it; then BlinkCursor just has to XOR
// the requested rectangle at periodic intervals.
-PlcCursor Cursor;
+QRect Cursor;
//-----------------------------------------------------------------------------
// Find the address in the DisplayMatrix of the selected leaf element. Set
// *gx and *gy if we succeed and return TRUE, else return FALSE.
//-----------------------------------------------------------------------------
-/*BOOL FindSelected(int *gx, int *gy)
+BOOL FindSelected(int *gx, int *gy)
{
if(!Selected) return FALSE;
@@ -213,7 +213,7 @@ void WhatCanWeDoFromCursorAndTopology(void)
SetMenusEnabled(canNegate, canNormal, canResetOnly, canSetOnly, canDelete,
CanInsertEnd, CanInsertOther, canPushDown, canPushUp, CanInsertComment);
}
-*/
+
//-----------------------------------------------------------------------------
// Rub out freed element from the DisplayMatrix, just so we don't confuse
// ourselves too much (or access freed memory)...
@@ -250,7 +250,7 @@ void ForgetEverything(void)
// to do so, FALSE if not. The latter occurs given a completely empty
// program.
//-----------------------------------------------------------------------------
-/*BOOL MoveCursorTopLeft(void)
+BOOL MoveCursorTopLeft(void)
{
int i, j;
// Let us first try to place it somewhere on-screen, so start at the
@@ -402,7 +402,7 @@ void EditSelectedElement(void)
{
if(!Selected || Selected->selectedState == SELECTED_NONE) return;
- switch(SelectedWhich) {
+ /*switch(SelectedWhich) {
case ELEM_COMMENT:
ShowCommentDialog(Selected->d.comment.str);
break;
@@ -493,7 +493,7 @@ void EditSelectedElement(void)
case ELEM_LOOK_UP_TABLE:
ShowLookUpTableDialog(Selected);
break;
- }
+ }*/
}
//-----------------------------------------------------------------------------
@@ -514,7 +514,7 @@ void EditElementMouseDoubleclick(int x, int y)
gy += ScrollYOffset;
- if(InSimulationMode) {
+ /*if(InSimulationMode) {
ElemLeaf *l = DisplayMatrix[gx][gy];
if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) {
char *name = l->d.contacts.name;
@@ -528,7 +528,7 @@ void EditElementMouseDoubleclick(int x, int y)
if(DisplayMatrix[gx][gy] == Selected) {
EditSelectedElement();
}
- }
+ }*/
}
//-----------------------------------------------------------------------------
@@ -726,4 +726,3 @@ void MakeResetOnlySelected(void)
c->setOnly = FALSE;
c->negated = FALSE;
}
-*/ \ No newline at end of file
diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp
index 59e7b6e..61c691c 100644
--- a/ldmicro/simulate.cpp
+++ b/ldmicro/simulate.cpp
@@ -693,7 +693,7 @@ void SimulateOneCycle(BOOL forceRefresh)
// event loop, and there is risk that we would go recursive. So let
// us fix that. (Note that there are no concurrency issues; we really
// would get called recursively, not just reentrantly.)
- static BOOL Simulating = FALSE;
+/* static BOOL Simulating = FALSE;
if(Simulating) return;
Simulating = TRUE;
@@ -719,7 +719,7 @@ void SimulateOneCycle(BOOL forceRefresh)
SimulateRedrawAfterNextCycle = FALSE;
if(NeedRedraw) SimulateRedrawAfterNextCycle = TRUE;
- Simulating = FALSE;
+ Simulating = FALSE;*/
}
//-----------------------------------------------------------------------------
@@ -730,14 +730,14 @@ void SimulateOneCycle(BOOL forceRefresh)
//-----------------------------------------------------------------------------
void StartSimulationTimer(void)
{
- int p = Prog.cycleTime/1000;
+ /* int p = Prog.cycleTime/1000;
if(p < 5) {
SetTimer(MainWindow, TIMER_SIMULATE, 10, PlcCycleTimer);
CyclesPerTimerTick = 10000 / Prog.cycleTime;
} else {
SetTimer(MainWindow, TIMER_SIMULATE, p, PlcCycleTimer);
CyclesPerTimerTick = 1;
- }
+ }*/
}
//-----------------------------------------------------------------------------
@@ -891,7 +891,7 @@ static void UartSimulationTextProc(HWID hwid, UINT umsg, char *text, UINT uszbuf
// characters that you type go into UART RECV instruction and whatever
// the program puts into UART SEND shows up as text.
//-----------------------------------------------------------------------------
-void ShowUartSimulationWindow(void)
+/*void ShowUartSimulationWindow(void)
{
DWORD TerminalX = 200, TerminalY = 200, TerminalW = 300, TerminalH = 150;
@@ -928,7 +928,7 @@ void ShowUartSimulationWindow(void)
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);
-}
+}*/
//-----------------------------------------------------------------------------
// Get rid of the UART simulation terminal-type window.
diff --git a/ldmicro/undoredo.cpp b/ldmicro/undoredo.cpp
index 915aaa4..8bcfcc8 100644
--- a/ldmicro/undoredo.cpp
+++ b/ldmicro/undoredo.cpp
@@ -55,7 +55,7 @@ static struct {
// whenever we change it, for undo purposes. Fast enough that we shouldn't
// need to be smart.
//-----------------------------------------------------------------------------
-/*static void *DeepCopy(int which, void *any)
+static void *DeepCopy(int which, void *any)
{
switch(which) {
CASE_LEAF {
@@ -93,7 +93,7 @@ static struct {
break;
}
}
-*/
+
//-----------------------------------------------------------------------------
// Empty out a ProgramStack data structure, either .undo or .redo: set the
// count to zero and free all the program copies in it.
@@ -112,7 +112,7 @@ static void EmptyProgramStack(ProgramStack *ps)
}
}
}
-/*
+
//-----------------------------------------------------------------------------
// Push the current program onto a program stack. Can either make a deep or
// a shallow copy of the linked data structures.
@@ -228,7 +228,7 @@ void UndoRedo(void)
RefreshScrollbars();
InvalidateRect(MainWindow, NULL, FALSE);
}
-*/
+
//-----------------------------------------------------------------------------
// Empty out our undo history entirely, as when loading a new file.
//-----------------------------------------------------------------------------
@@ -245,8 +245,8 @@ void UndoFlush(void)
// notices that easily is the display code, which will respond by undoing
// the last operation, presumably the one that added the long line.
//-----------------------------------------------------------------------------
-/*BOOL CanUndo(void)
+BOOL CanUndo(void)
{
return (Undo.undo.count > 0);
-}*/
+}