summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/win32/freeze.cpp208
-rw-r--r--common/win32/freeze.h33
-rw-r--r--ldmicro/CMakeLists.txt9
-rw-r--r--ldmicro/Makefile111
-rw-r--r--ldmicro/draw_outputdev.cpp4
-rw-r--r--ldmicro/includes/linuxUI/linuxUI.h12
-rw-r--r--ldmicro/ldmicro.cpp6
-rw-r--r--ldmicro/linuxUI.cpp7
8 files changed, 18 insertions, 372 deletions
diff --git a/common/win32/freeze.cpp b/common/win32/freeze.cpp
deleted file mode 100644
index 753f5d7..0000000
--- a/common/win32/freeze.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * A library for storing parameters in the registry.
- *
- * Jonathan Westhues, 2002
- */
-#include <windows.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/*
- * store a window's position in the registry, or fail silently if the registry calls don't work
- */
-void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
-{
- RECT r;
- GetWindowRect(hwnd, &r);
-
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return;
-
- char *keyName = (char *)malloc(strlen(name) + 30);
- if(!keyName)
- return;
-
- HKEY sub;
- if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_left", name);
- if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.left), sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_right", name);
- if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.right), sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_top", name);
- if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.top), sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_bottom", name);
- if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.bottom), sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_maximized", name);
- DWORD v = IsZoomed(hwnd);
- if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(v), sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-
- free(keyName);
-}
-
-static void Clamp(LONG *v, LONG min, LONG max)
-{
- if(*v < min) *v = min;
- if(*v > max) *v = max;
-}
-
-/*
- * retrieve a window's position from the registry, or do nothing if there is no info saved
- */
-void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
-{
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return;
-
- HKEY sub;
- if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
- return;
-
- char *keyName = (char *)malloc(strlen(name) + 30);
- if(!keyName)
- return;
-
- DWORD l;
- RECT r;
-
- sprintf(keyName, "%s_left", name);
- l = sizeof(DWORD);
- if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.left), &l) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_right", name);
- l = sizeof(DWORD);
- if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.right), &l) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_top", name);
- l = sizeof(DWORD);
- if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.top), &l) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_bottom", name);
- l = sizeof(DWORD);
- if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.bottom), &l) != ERROR_SUCCESS)
- return;
-
- sprintf(keyName, "%s_maximized", name);
- DWORD v;
- l = sizeof(DWORD);
- if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
- return;
- if(v)
- ShowWindow(hwnd, SW_MAXIMIZE);
-
- RECT dr;
- GetWindowRect(GetDesktopWindow(), &dr);
-
- // If it somehow ended up off-screen, then put it back.
- Clamp(&(r.left), dr.left, dr.right);
- Clamp(&(r.right), dr.left, dr.right);
- Clamp(&(r.top), dr.top, dr.bottom);
- Clamp(&(r.bottom), dr.top, dr.bottom);
- if(r.right - r.left < 100) {
- r.left -= 300; r.right += 300;
- }
- if(r.bottom - r.top < 100) {
- r.top -= 300; r.bottom += 300;
- }
- Clamp(&(r.left), dr.left, dr.right);
- Clamp(&(r.right), dr.left, dr.right);
- Clamp(&(r.top), dr.top, dr.bottom);
- Clamp(&(r.bottom), dr.top, dr.bottom);
-
- MoveWindow(hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE);
-
- free(keyName);
-}
-
-/*
- * store a DWORD setting in the registry
- */
-void FreezeDWORDF(DWORD val, char *subKey, char *name)
-{
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return;
-
- HKEY sub;
- if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
- return;
-
- if(RegSetValueEx(sub, name, 0, REG_DWORD, (BYTE *)&val, sizeof(DWORD)) != ERROR_SUCCESS)
- return;
-}
-
-/*
- * retrieve a DWORD setting, or return the default if that setting is unavailable
- */
-DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
-{
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return val;
-
- HKEY sub;
- if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
- return val;
-
- DWORD l = sizeof(DWORD);
- DWORD v;
- if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
- return val;
-
- return v;
-}
-
-/*
- * store a string setting in the registry
- */
-void FreezeStringF(char *val, char *subKey, char *name)
-{
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return;
-
- HKEY sub;
- if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
- return;
-
- if(RegSetValueEx(sub, name, 0, REG_SZ, (BYTE *)val, strlen(val)+1) != ERROR_SUCCESS)
- return;
-}
-
-/*
- * retrieve a string setting, or return the default if that setting is unavailable
- */
-void ThawStringF(char *val, int max, char *subKey, char *name)
-{
- HKEY software;
- if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
- return;
-
- HKEY sub;
- if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
- return;
-
- DWORD l = max;
- if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)val, &l) != ERROR_SUCCESS)
- return;
- if(l >= (DWORD)max) return;
-
- val[l] = '\0';
- return;
-}
-
diff --git a/common/win32/freeze.h b/common/win32/freeze.h
deleted file mode 100644
index 9570898..0000000
--- a/common/win32/freeze.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * A library for storing parameters in the registry.
- *
- * Jonathan Westhues, 2002
- */
-
-#ifndef __FREEZE_H
-#define __FREEZE_H
-
-#ifndef FREEZE_SUBKEY
-#error must define FREEZE_SUBKEY to a string uniquely identifying the app
-#endif
-
-#define FreezeWindowPos(hwnd) FreezeWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
-void FreezeWindowPosF(HWND hWnd, char *subKey, char *name);
-
-#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
-void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
-
-#define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
-void FreezeDWORDF(DWORD val, char *subKey, char *name);
-
-#define ThawDWORD(val) val = ThawDWORDF(val, FREEZE_SUBKEY, #val)
-DWORD ThawDWORDF(DWORD val, char *subKey, char *name);
-
-#define FreezeString(val) FreezeStringF(val, FREEZE_SUBKEY, #val)
-void FreezeStringF(char *val, char *subKey, char *name);
-
-#define ThawString(val, max) ThawStringF(val, max, FREEZE_SUBKEY, #val)
-void ThawStringF(char *val, int max, char *subKey, char *name);
-
-
-#endif
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index 8cb7563..2e20552 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -3,14 +3,8 @@ cmake_minimum_required(VERSION 2.6)
project(LDMicro)
IF(WIN32)
- MESSAGE( STATUS "Building for Windows.." )
+ MESSAGE( FATAL_ERROR "Cannot build for windows, exiting" )
add_definitions(-D__WIN32__)
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../common/win32")
- MESSAGE( STATUS "Setting path" )
- add_definitions(__WINDOWS_SYSTEM__)
- set(PKG_CONFIG_PATH "C:/path/to/gtk/lib/pkgconfig")
- set(PATH "C:/path/to/gtk/bin;%PATH%")
- MESSAGE( STATUS "Setting path - done" )
ENDIF(WIN32)
IF(UNIX)
@@ -30,6 +24,7 @@ IF(UNIX)
ENDIF(UNIX)
IF (MSVC)
+ MESSAGE( FATAL_ERROR "Cannot build for MacOS, exiting" )
add_definitions(-D__MSVC__)
ENDIF (MSVC)
diff --git a/ldmicro/Makefile b/ldmicro/Makefile
deleted file mode 100644
index 3bc6257..0000000
--- a/ldmicro/Makefile
+++ /dev/null
@@ -1,111 +0,0 @@
-DEFINES = /D_WIN32_WINNT=0x400 /DISOLATION_AWARE_ENABLED /D_WIN32_IE=0x400 /DWIN32_LEAN_AND_MEAN /DWIN32 /D$(D)
-CFLAGS = /W3 /nologo -I..\common\win32 /O2 /D_CRT_SECURE_NO_WARNINGS /D_DEBUG /Zi
-
-HEADERS = ..\common\win32\freeze.h ldmicro.h mcutable.h intcode.h
-
-OBJDIR = obj
-
-COMPDIR = components
-
-FREEZE = $(OBJDIR)\freeze.obj
-
-LDOBJS = $(OBJDIR)\ldmicro.obj \
- $(OBJDIR)\maincontrols.obj \
- $(OBJDIR)\helpdialog.obj \
- $(OBJDIR)\schematic.obj \
- $(OBJDIR)\draw.obj \
- $(OBJDIR)\draw_outputdev.obj \
- $(OBJDIR)\circuit.obj \
- $(OBJDIR)\undoredo.obj \
- $(OBJDIR)\loadsave.obj \
- $(OBJDIR)\simulate.obj \
- $(OBJDIR)\commentdialog.obj \
- $(OBJDIR)\contactsdialog.obj \
- $(OBJDIR)\coildialog.obj \
- $(OBJDIR)\simpledialog.obj \
- $(OBJDIR)\resetdialog.obj \
- $(OBJDIR)\lutdialog.obj \
- $(OBJDIR)\confdialog.obj \
- $(OBJDIR)\iolist.obj \
- $(OBJDIR)\miscutil.obj \
- $(OBJDIR)\lang.obj \
- $(OBJDIR)\intcode.obj \
- $(OBJDIR)\compilecommon.obj \
- $(OBJDIR)\ansic.obj \
- $(OBJDIR)\interpreted.obj \
- $(OBJDIR)\pic16.obj \
- $(OBJDIR)\avr.obj \
- $(OBJDIR)\arduino.obj \
- $(OBJDIR)\advanceddialog.obj \
- $(OBJDIR)\componentlist.obj \
- $(OBJDIR)\componentimages.obj \
- $(OBJDIR)\naminglist.obj
-
-
-COMPOBJS = $(OBJDIR)\components.obj \
- $(OBJDIR)\switch.obj \
- $(OBJDIR)\relay.obj \
- $(OBJDIR)\spdt.obj \
- $(OBJDIR)\dpst.obj \
- $(OBJDIR)\dpdt.obj
-
-HELPOBJ = $(OBJDIR)\helptext.obj
-
-CLEANOBJ = $(OBJDIR)\helptext.cpp \
- $(OBJDIR)\helptext.obj \
- $(OBJDIR)\lang-tables.h \
- $(OBJDIR)\ldmicro.exe \
- $(OBJDIR)\ldmicro.obj \
- $(OBJDIR)\ldmicro.res \
- $(OBJDIR)\freeze.obj \
- $(OBJDIR)\ldinterpret.exe \
- $(OBJDIR)\ldmicro.ilk \
- $(OBJDIR)\ldmicro.pdb \
- ldinterpret.exe \
- ldinterpret.obj \
- ldmicro.exe \
- vc100.pdb \
- reg\results
-
-LIBS = user32.lib gdi32.lib comctl32.lib advapi32.lib windowscodecs.lib ole32.lib
-
-all: $(OBJDIR)/ldmicro.exe $(OBJDIR)/ldinterpret.exe
- @cp $(OBJDIR)/ldmicro.exe .
- @cp $(OBJDIR)/ldinterpret.exe .
- @cd reg
- @go.bat
- @cd ..
-
-clean:
- rm -rf $(LDOBJS) $(COMPOBJS) $(CLEANOBJ)
- rmdir reg\results
-
-lang.cpp: $(OBJDIR)/lang-tables.h
-
-$(OBJDIR)/lang-tables.h: lang*.txt
- perl lang-tables.pl > $(OBJDIR)/lang-tables.h
-
-$(OBJDIR)/ldinterpret.exe: ldinterpret.c
- @$(CC) -Fe$(OBJDIR)/ldinterpret.exe $(LIBS) ldinterpret.c
-
-$(OBJDIR)/ldmicro.exe: $(LDOBJS) $(COMPOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res
- @$(CC) $(DEFINES) $(CFLAGS) -Fe$(OBJDIR)/ldmicro.exe $(LDOBJS) $(COMPOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res $(LIBS)
-
-$(OBJDIR)/ldmicro.res: ldmicro.rc ldmicro.ico
- @rc ldmicro.rc
- @mv ldmicro.res $(OBJDIR)
-
-$(LDOBJS): $(@B).cpp $(HEADERS)
- @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj $(@B).cpp
-
-$(COMPOBJS): $(COMPDIR)/$(@B).cpp $(HEADERS)
- @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj $(COMPDIR)/$(@B).cpp
-
-$(FREEZE): ..\common\win32\$(@B).cpp $(HEADERS)
- @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj ..\common\win32\$(@B).cpp
-
-$(HELPOBJ): $(OBJDIR)/helptext.cpp
- @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/helptext.obj $(OBJDIR)/helptext.cpp
-
-$(OBJDIR)/helptext.cpp: manual.txt manual-*.txt
- perl txt2c.pl > $(OBJDIR)/helptext.cpp
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index 2173bb5..7df670c 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -21,6 +21,8 @@
// stuff to write to a file, or all the routines concerned with drawing to
// the screen.
// Jonathan Westhues, Dec 2004
+//
+// Ported to linus by: R Ramana, 2018
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
@@ -80,7 +82,7 @@ SyntaxHighlightingColours HighlightColours;
//-----------------------------------------------------------------------------
void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time)
{
- if(GetFocus() != MainWindow && !CursorDrawn) return;
+ if(!isFocus(MainWindow) && !CursorDrawn) return;
if(Cursor.left == 0) return;
PlcCursor c;
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index e084e73..02691b5 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -20,8 +20,10 @@ typedef bool BOOL;
typedef GdkRGBA COLORREF;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
+
+/// all handles will hold a GtkWindow* type
typedef void* PVOID;
-typedef PVOID HANDLE;
+typedef GtkWindow* HANDLE;
typedef HANDLE HINSTANCE;
typedef HANDLE HWND;
typedef HANDLE HDC;
@@ -47,4 +49,10 @@ typedef uint64_t UINT_PTR;
typedef unsigned int UINT_PTR;
#endif
-typedef UINT_PTR WPARAM; \ No newline at end of file
+typedef UINT_PTR WPARAM;
+typedef unsigned int UINT;
+
+/// common windows referances for linux - end
+
+/// functions
+BOOL isFocus(HWND); \ No newline at end of file
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e1a55a6..e7e3f17 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -24,13 +24,7 @@
// most of the UI logic relating to the main window.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
-#ifdef __UNIX__
#include "linuxUI/linuxUI.h"
-#elif defined(__WIN32__)
-#include <windows.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
diff --git a/ldmicro/linuxUI.cpp b/ldmicro/linuxUI.cpp
index b7fa4aa..2722101 100644
--- a/ldmicro/linuxUI.cpp
+++ b/ldmicro/linuxUI.cpp
@@ -1,8 +1,7 @@
#include "linuxUI/linuxUI.h"
-int main (int argc, char**argv)
+/// Wraper function for gtk_window_has_toplevel_focus
+BOOL isFocus(HWND window)
{
- int status = 0;
-
- return status;
+ return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window));
} \ No newline at end of file