summaryrefslogtreecommitdiff
path: root/ldmicro
diff options
context:
space:
mode:
authorakshay-c2019-05-02 11:24:18 +0530
committerakshay-c2019-05-02 11:24:18 +0530
commit52b93dc4228459bd7e1204f80d983a3b29b32f1d (patch)
tree6b79e74c00111566b1bf4563bcf225a8135b6ed1 /ldmicro
parent867ec787c39eec99385e605eb403b64569619b22 (diff)
downloadLDmicroQt-52b93dc4228459bd7e1204f80d983a3b29b32f1d.tar.gz
LDmicroQt-52b93dc4228459bd7e1204f80d983a3b29b32f1d.tar.bz2
LDmicroQt-52b93dc4228459bd7e1204f80d983a3b29b32f1d.zip
Solved DrawWindow's Focus, Cursor, RungDisplay(Scrolling) issues
Diffstat (limited to 'ldmicro')
-rw-r--r--ldmicro/CMakeLists.txt21
-rwxr-xr-xldmicro/LDMicro.desktop9
-rw-r--r--ldmicro/draw_outputdev.cpp67
-rw-r--r--ldmicro/includes/ldmicro.h11
-rw-r--r--ldmicro/includes/ldmicroVC.h4
-rw-r--r--ldmicro/ldmicro.cpp28
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h3
-rw-r--r--ldmicro/maincontrols.cpp1
-rw-r--r--ldmicro/schematic.cpp26
9 files changed, 102 insertions, 68 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index dced0da..2337bcb 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -73,8 +73,8 @@ IF(UNIX)
add_custom_target(LDMicro_SCRIPT_GENERATED_FILES DEPENDS ${SCRIPT_GENERATED_FILES})
## Version control
- set (LDMicro_VERSION_MAJOR 1)
- set (LDMicro_VERSION_MINOR 0)
+ set (LDMicro_VERSION_MAJOR 2)
+ set (LDMicro_VERSION_MINOR 2)
## configure a header file to pass some of the CMake settings
## to the source code
@@ -174,6 +174,23 @@ endif()
target_link_libraries(LDMicro ${Qt5Core_LIBRARIES})
target_link_libraries(LDMicro ${Qt5Gui_LIBRARIES})
+ INSTALL(TARGETS LDMicro DESTINATION /usr/local/bin/ldmicro)
+ INSTALL(FILES ldmicro.ico DESTINATION /usr/local/bin/ldmicro)
+ INSTALL(FILES LDMicro.desktop DESTINATION /usr/share/applications)
+
+ ##Debian package creation
+ set(CPACK_GENERATOR "DEB")
+ set(CPACK_PACKAGE_VERSION_MAJOR "2")
+ set(CPACK_PACKAGE_VERSION_MINOR "2")
+ set(CPACK_PACKAGE_VERSION_PATCH "4")
+
+ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
+ set(CPACK_PACKAGE_DESCRIPTION "Ladder Logic editor, simulator and compiler for 8 bit microcontrollers")
+ set(CPACK_PACKAGE_CONTACT "Akshay Chipkar akshaychipkar@yahoo.co.in")
+ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
+
+ include(CPack)
+
## Add tests
MESSAGE( STATUS "Adding tests.." )
add_custom_command(
diff --git a/ldmicro/LDMicro.desktop b/ldmicro/LDMicro.desktop
new file mode 100755
index 0000000..3d93818
--- /dev/null
+++ b/ldmicro/LDMicro.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Terminal=false
+Icon[en_IN]=/usr/local/bin/ldmicro/ldmicro.ico
+Name[en_IN]=LDMicro
+Exec=/usr/local/bin/ldmicro/LDMicro
+Name=LDMicro
+Icon=/usr/local/bin/ldmicro/ldmicro.ico
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index 7dd1723..c37dc27 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -62,10 +62,10 @@ static HBRUSH BgBrush;
static HBRUSH SimBgBrush;
// Parameters that determine our offset if we are scrolled
-int ScrollXOffset;
-int ScrollYOffset;
-int ScrollXOffsetMax;
-int ScrollYOffsetMax;
+// int ScrollXOffset;
+// int ScrollYOffset;
+// int ScrollXOffsetMax;
+// int ScrollYOffsetMax;
// Is the cursor currently drawn? We XOR it so this gets toggled.
static BOOL CursorDrawn;
@@ -93,16 +93,15 @@ BOOL BlinkCursor(BOOL kill = FALSE)
}
QRect c;
- memcpy(&c, &Cursor, sizeof(c));
+ c = Cursor;
- c.setTop(c.top() - ScrollYOffset*POS_HEIGHT*FONT_HEIGHT);
- c.setLeft(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) {
+ /*if(c.top() + c.height() >= IoListTop) {
c.setHeight(IoListTop - c.top() - 3);
- }
+ }*/
if(DrawWindow == NULL)
return FALSE;
@@ -131,7 +130,7 @@ BOOL BlinkCursor(BOOL kill = FALSE)
// PaintWindow(Hcr);
// gtk_widget_queue_draw(DrawWindow);
}
- CursorObject->setGeometry(c);
+ CursorObject->setGeometry(Cursor);
if (CursorObject->isVisible())
CursorObject->setVisible(FALSE);
@@ -151,9 +150,9 @@ BOOL BlinkCursor(BOOL kill = FALSE)
//-----------------------------------------------------------------------------
static void DrawCharsToScreen(HCRDC Hcr, int cx, int cy, const char *str)
{
- cy -= ScrollYOffset*POS_HEIGHT;
+ // cy -= ScrollYOffset*POS_HEIGHT;
if(cy < -2) return;
- if(cy*FONT_HEIGHT + Y_PADDING > IoListTop) return;
+ // if(cy*FONT_HEIGHT + Y_PADDING > IoListTop) return;
// IoListTop not initialized.
COLORREF prev;
@@ -246,11 +245,11 @@ int ScreenColsAvailable(void)
int ScreenRowsAvailable(void)
{
int adj;
- if(ScrollXOffsetMax == 0) {
+ /*if(ScrollXOffsetMax == 0) {
adj = 0;
- } else {
+ } else {*/
adj = 18;
- }
+ // }
return (IoListTop - Y_PADDING - adj) / (POS_HEIGHT*FONT_HEIGHT);
}
@@ -298,7 +297,8 @@ void PaintWidget::paintEvent(QPaintEvent *event)
int i;
int cy = 0;
- int rowsAvailable = ScreenRowsAvailable();
+ int cx = 0;
+ // int rowsAvailable = ScreenRowsAvailable();
for(i = 0; i < Prog.numRungs; i++) {
int thisHeight = POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT,
@@ -308,8 +308,8 @@ void PaintWidget::paintEvent(QPaintEvent *event)
// we still must draw a bit above and below so that the DisplayMatrix
// is filled in enough to make it possible to reselect using the
// cursor keys.
- if(((cy + thisHeight) >= (ScrollYOffset - 8)*POS_HEIGHT) &&
- (cy < (ScrollYOffset + rowsAvailable + 8)*POS_HEIGHT))
+ /*if(((cy + thisHeight) >= (ScrollYOffset - 8)*POS_HEIGHT) &&
+ (cy < (ScrollYOffset + rowsAvailable + 8)*POS_HEIGHT))*/
{
SetBkColor(DrawWindow, Hcr, InSimulationMode ? HighlightColours.simBg :
HighlightColours.bg);
@@ -318,8 +318,8 @@ void PaintWidget::paintEvent(QPaintEvent *event)
SelectObject(Hcr, FixedWidthFont);
int rung = i + 1;
int y = Y_PADDING + FONT_HEIGHT*cy;
- int yp = y + FONT_HEIGHT*(POS_HEIGHT/2) -
- POS_HEIGHT*FONT_HEIGHT*ScrollYOffset;
+ int yp = y; /*+ FONT_HEIGHT*(POS_HEIGHT/2) -
+ POS_HEIGHT*FONT_HEIGHT*ScrollYOffset;*/
if(rung < 10) {
char r[1] = { rung + '0' };
@@ -329,7 +329,7 @@ void PaintWidget::paintEvent(QPaintEvent *event)
TextOut(DrawWindow, Hcr, 8, yp, r, 2);
}
- int cx = 0;
+ cx = 0;
DrawElement(Hcr, ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy,
Prog.rungPowered[i]);
}
@@ -340,10 +340,15 @@ void PaintWidget::paintEvent(QPaintEvent *event)
// printf("Endrung:%d\n", cy);
QSize DWSize = this->size();
int newHeight = ((cy + (POS_HEIGHT/2)) * FONT_HEIGHT + Y_PADDING + 50);
- if(DWSize.height() < newHeight)
+ if(DWSize.height() + POS_HEIGHT < newHeight)
{
DWSize.setHeight(newHeight);
}
+ int newWidth = ((cx + (POS_WIDTH/2)) * FONT_WIDTH + X_PADDING);
+ if(DWSize.width() + POS_WIDTH < newWidth)
+ {
+ DWSize.setWidth(newWidth);
+ }
DrawWindow->resize(DWSize);
cy -= 2;
@@ -433,6 +438,7 @@ static void SetSyntaxHighlightingColours(void)
void InitForDrawing(void)
{
DrawWindow = new PaintWidget();
+ DrawWindow->setFocusPolicy(Qt::StrongFocus);
SetSyntaxHighlightingColours();
FixedWidthFont = CreateFont(
@@ -595,7 +601,7 @@ void ExportDrawingAsText(char *file)
//-----------------------------------------------------------------------------
void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert)
{
- int totalHeight = 0;
+/* int totalHeight = 0;
int i;
for(i = 0; i < Prog.numRungs; i++) {
totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
@@ -630,11 +636,12 @@ void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert)
// vert->fMask = SIF_DISABLENOSCROLL | SIF_ALL;
vert->nMin = 0;
vert->nMax = totalHeight - 1;
- vert->nPos = ScrollYOffset;
+ // vert->nPos = ScrollYOffset;
+ vert->nPos = 0;
vert->nPage = ScreenRowsAvailable();
+*/
+ // ScrollYOffsetMax = vert->nMax - vert->nPage + 1;
- ScrollYOffsetMax = vert->nMax - vert->nPage + 1;
-
- if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax;
- if(ScrollYOffset < 0) ScrollYOffset = 0;
+ // if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax;
+ // if(ScrollYOffset < 0) ScrollYOffset = 0;
}
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index ff3acd9..bff804f 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -607,9 +607,6 @@ void CheckHeap(char *file, int line);
class MyWidget : public QWidget
{
public:
- void keyPressEvent(QKeyEvent* event);
- void mouseReleaseEvent(QMouseEvent* event);
- void mouseDoubleClickEvent(QMouseEvent* event);
void closeEvent(QCloseEvent* event);
};
@@ -656,10 +653,10 @@ extern HFONT FixedWidthFontBold;
extern int SelectedGxAfterNextPaint;
extern int SelectedGyAfterNextPaint;
extern BOOL ScrollSelectedIntoViewAfterNextPaint;
-extern int ScrollXOffset;
-extern int ScrollYOffset;
-extern int ScrollXOffsetMax;
-extern int ScrollYOffsetMax;
+// extern int ScrollXOffset;
+// extern int ScrollYOffset;
+// extern int ScrollXOffsetMax;
+// extern int ScrollYOffsetMax;
// schematic.cpp
void SelectElement(int gx, int gy, int state);
diff --git a/ldmicro/includes/ldmicroVC.h b/ldmicro/includes/ldmicroVC.h
index 400bc42..67e0d9c 100644
--- a/ldmicro/includes/ldmicroVC.h
+++ b/ldmicro/includes/ldmicroVC.h
@@ -1,3 +1,3 @@
/// version control
-#define LDMicro_VERSION_MAJOR 1
-#define LDMicro_VERSION_MINOR 0
+#define LDMicro_VERSION_MAJOR 2
+#define LDMicro_VERSION_MINOR 2
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 4e6942b..ee11faa 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -609,7 +609,7 @@ cmp:
// // WndProc functions for MainWindow.
// //-----------------------------------------------------------------------------
-void MyWidget::keyPressEvent(QKeyEvent* event)
+void PaintWidget::keyPressEvent(QKeyEvent* event)
{
// if(event->key() == )
int wParam = event->key();
@@ -626,32 +626,32 @@ void MyWidget::keyPressEvent(QKeyEvent* event)
switch(wParam)
{
case VK_DOWN:
- if(ScrollYOffset < ScrollYOffsetMax)
- ScrollYOffset++;
+ /*if(ScrollYOffset < ScrollYOffsetMax)
+ ScrollYOffset++;*/
RefreshScrollbars();
DrawWindow->repaint();
break;
case VK_UP:
- if(ScrollYOffset > 0)
- ScrollYOffset--;
+ /*if(ScrollYOffset > 0)
+ ScrollYOffset--;*/
RefreshScrollbars();
DrawWindow->repaint();
break;
case VK_LEFT:
- ScrollXOffset -= FONT_WIDTH;
- if(ScrollXOffset < 0)
- ScrollXOffset = 0;
- RefreshScrollbars();
+ // ScrollXOffset -= FONT_WIDTH;
+ // if(ScrollXOffset < 0)
+ /* ScrollXOffset = 0;
+ RefreshScrollbars();*/
DrawWindow->repaint();
break;
case VK_RIGHT:
- ScrollXOffset += FONT_WIDTH;
+ /*ScrollXOffset += FONT_WIDTH;
if(ScrollXOffset >= ScrollXOffsetMax)
ScrollXOffset = ScrollXOffsetMax;
- RefreshScrollbars();
+ RefreshScrollbars();*/
DrawWindow->repaint();
break;
@@ -899,7 +899,7 @@ void MyWidget::closeEvent(QCloseEvent* event)
// return FALSE;
// }
-void MyWidget :: mouseReleaseEvent(QMouseEvent* event)
+void PaintWidget :: mouseReleaseEvent(QMouseEvent* event)
{
/* Handles:
* WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
@@ -907,7 +907,7 @@ void MyWidget :: mouseReleaseEvent(QMouseEvent* event)
QRect Rect;
Rect = DrawWindow->rect();
- QPoint wy = DrawWindow->mapFrom(MainWindow, event->pos());
+ QPoint wy = event->pos();
// printf("mouseReleaseEvent: x:%d,y:%d",wy.x(),wy.y());
if((wy.x() <= 0) || (wy.y() <= 0))
@@ -936,7 +936,7 @@ void MyWidget :: mouseReleaseEvent(QMouseEvent* event)
// return FALSE;
}
}
-void MyWidget :: mouseDoubleClickEvent(QMouseEvent* event)
+void PaintWidget :: mouseDoubleClickEvent(QMouseEvent* event)
{
QRect Rect;
Rect = DrawWindow->rect();
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index a0d2a00..136de4e 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -320,6 +320,9 @@ public:
// MyWidget();
// PaintWidget(QWidget* parent): QWidget(parent)
// {}
+ void keyPressEvent(QKeyEvent* event);
+ void mouseReleaseEvent(QMouseEvent* event);
+ void mouseDoubleClickEvent(QMouseEvent* event);
protected:
void paintEvent(QPaintEvent *event);
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 9ec30fe..0c520ae 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -551,6 +551,7 @@ void MakeMainWindowControls(void)
QSize DWSize;
WM_SCROLL scrollbar = new QScrollArea();
scrollbar->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ scrollbar->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollbar->setFocusPolicy(Qt::NoFocus);
DWSize.setHeight(MainWindow->height() - IoListHeight);
DWSize.setWidth(MainWindow->width());
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index 7bba676..d9a9217 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -101,22 +101,22 @@ void SelectElement(int gx, int gy, int state)
state = SELECTED_LEFT;
}
- if((gy - ScrollYOffset) >= ScreenRowsAvailable()) {
+ /*if((gy - ScrollYOffset) >= ScreenRowsAvailable()) {
ScrollYOffset = gy - ScreenRowsAvailable() + 1;
RefreshScrollbars();
}
if((gy - ScrollYOffset) < 0) {
- ScrollYOffset = gy;
+ ScrollYOffset = 0;
RefreshScrollbars();
- }
- if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) >= ScreenColsAvailable()) {
+ }*/
+ /*if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) >= ScreenColsAvailable()) {
ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH - ScreenColsAvailable();
RefreshScrollbars();
}
if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) < 0) {
ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH;
RefreshScrollbars();
- }
+ }*/
ok();
Selected->selectedState = state;
@@ -258,8 +258,8 @@ BOOL MoveCursorTopLeft(void)
// cursor in a position that would force us to scroll to put it in to
// view.)
for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) {
- for(j = ScrollYOffset;
- j < DISPLAY_MATRIX_Y_SIZE && j < (ScrollYOffset+16); j++)
+ for(j = 0;
+ j < DISPLAY_MATRIX_Y_SIZE /*&& j < (ScrollYOffset+16)*/; j++)
{
if(VALID_LEAF(DisplayMatrix[i][j])) {
SelectElement(i, j, SELECTED_LEFT);
@@ -382,11 +382,11 @@ void MoveCursorKeyboard(int keyCode)
}
if(j != DISPLAY_MATRIX_Y_SIZE) {
SelectElement(i, j, SELECTED_ABOVE);
- } else if(ScrollYOffsetMax - ScrollYOffset < 3) {
+ } /*else if(ScrollYOffsetMax - ScrollYOffset < 3) {
// special case: scroll the end marker into view
ScrollYOffset = ScrollYOffsetMax;
RefreshScrollbars();
- }
+ }*/
}
break;
}
@@ -505,14 +505,14 @@ void EditSelectedElement(void)
//-----------------------------------------------------------------------------
void EditElementMouseDoubleclick(int x, int y)
{
- x += ScrollXOffset;
+ /*x += ScrollXOffset;*/
y += FONT_HEIGHT/2;
int gx = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH);
int gy = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT);
- gy += ScrollYOffset;
+ // gy += ScrollYOffset;
if(InSimulationMode) {
ElemLeaf *l = DisplayMatrix[gx][gy];
@@ -539,7 +539,7 @@ void EditElementMouseDoubleclick(int x, int y)
//-----------------------------------------------------------------------------
void MoveCursorMouseClick(int x, int y)
{
- x += ScrollXOffset;
+ /*x += ScrollXOffset;*/
y += FONT_HEIGHT/2;
@@ -547,7 +547,7 @@ void MoveCursorMouseClick(int x, int y)
int gy0 = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT);
int gx = gx0;
- int gy = gy0 + ScrollYOffset;
+ int gy = gy0 /*+ ScrollYOffset*/;
if(VALID_LEAF(DisplayMatrix[gx][gy])) {
int i, j;