summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatsuDrag92018-05-30 11:11:41 +0530
committerNatsuDrag92018-05-30 11:11:41 +0530
commitfdc0cc1d6db8a4297610071ab8d124b5586792c9 (patch)
treecbf5dac50252afae81a2bf36e9dcf843cfcbb693
parent3065f70943cb927bfe0a81c94c5d8acc151cb6be (diff)
parent05a927c0c42a1d2a24f344023aeaadf3a9a3f29b (diff)
downloadLDMicroGtk-fdc0cc1d6db8a4297610071ab8d124b5586792c9.tar.gz
LDMicroGtk-fdc0cc1d6db8a4297610071ab8d124b5586792c9.tar.bz2
LDMicroGtk-fdc0cc1d6db8a4297610071ab8d124b5586792c9.zip
Merge branch 'Rr42-GUI_port' into GUI_port
-rw-r--r--common/linux/freeze.cpp228
-rw-r--r--ldmicro/CMakeLists.txt82
-rw-r--r--ldmicro/draw_outputdev.cpp2
-rw-r--r--ldmicro/ldmicro.cpp4
-rw-r--r--ldmicro/lib/freezeLD/CMakeLists.txt4
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.cpp265
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.h (renamed from common/linux/freeze.h)16
-rw-r--r--ldmicro/lib/linuxUI/CMakeLists.txt3
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h (renamed from ldmicro/includes/linuxUI/linuxLD.h)3
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp (renamed from ldmicro/linuxUI.cpp)4
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h (renamed from ldmicro/includes/linuxUI/linuxUI.h)4
11 files changed, 333 insertions, 282 deletions
diff --git a/common/linux/freeze.cpp b/common/linux/freeze.cpp
deleted file mode 100644
index 0d27ca7..0000000
--- a/common/linux/freeze.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * A library for storing parameters in a key file
- *
- * This library is an analog to the windows freeze library
- * developed by Jonathan Westhues.
- *
- * R Ramana, 2018
- */
-#include "freeze.h"
-#include <linuxUI/linuxUI.h>
-#include <cstdlib>
-#include <fstream>
-#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)
-{
- if (-1 == system("mkdir -p /usr/share/ldmicro"))
- return;
-
- std::ofstream Register("binConf", std::ios::binary | std::ios::trunc);
- if (!Register.is_open())
- return;
-
- char *keyName = (char *)malloc(strlen(name) + 30);
- if(!keyName)
- return;
-
- Key newkey;
-
- int val;
-
- sprintf(keyName, "%s_width", name);
- gtk_window_get_size(GTK_WINDOW(hwnd), &val, NULL);
- newKey.name = keyName;
- newKey.type = 'i';
- newKey.val = val;
- Register.write((char*) &newKey, sizeof(newKey));
-
- sprintf(keyName, "%s_height", name);
- gtk_window_get_size(GTK_WINDOW(hwnd), NULL, &val);
- newKey.name = keyName;
- newKey.type = 'i';
- newKey.val = val;
- Register.write((char*) &newKey, sizeof(newKey));
-
-
- sprintf(keyName, "%s_posX", name);
- gtk_window_get_position(GTK_WINDOW(hwnd), &val, NULL);
- newKey.name = keyName;
- newKey.type = 'i';
- newKey.val = val;
- Register.write((char*) &newKey, sizeof(newKey));
-
- sprintf(keyName, "%s_posY", name);
- gtk_window_get_position(GTK_WINDOW(hwnd), NULL, &val);
- newKey.name = keyName;
- newKey.type = 'i';
- newKey.val = val;
- Register.write((char*) &newKey, sizeof(newKey));
-
- sprintf(keyName, "%s_maximized", name);
- newKey.name = keyName;
- newKey.type = 'b';
- newKey.val = gtk_window_is_maximized(GTK_WINDOW(hwnd));
- Register.write((char*) &newKey, sizeof(newKey));
-
- 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/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index e0b96a9..5486fec 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -7,9 +7,13 @@ IF(WIN32)
add_definitions(-D__WIN32__)
ENDIF(WIN32)
+IF (MSVC)
+ MESSAGE( FATAL_ERROR "Cannot build for MacOS, exiting" )
+ add_definitions(-D__MSVC__)
+ENDIF (MSVC)
+
IF(UNIX)
add_definitions(-D__UNIX__)
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../common/linux")
MESSAGE( STATUS "Performing system check.." )
MESSAGE( STATUS "Identifing bitness of the platform.." )
@@ -21,45 +25,45 @@ IF(UNIX)
MESSAGE( STATUS "Bitness of the platform: " 36)
endif()
MESSAGE( STATUS "Performing system check - done" )
-ENDIF(UNIX)
-
-IF (MSVC)
- MESSAGE( FATAL_ERROR "Cannot build for MacOS, exiting" )
- add_definitions(-D__MSVC__)
-ENDIF (MSVC)
-MESSAGE ( STATUS "Searching for GTK+3.0..." )
-find_package (PkgConfig REQUIRED)
-pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
+ MESSAGE ( STATUS "Searching for GTK+3.0..." )
+ find_package (PkgConfig REQUIRED)
+ pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
-# Version control
-set (LDMicro_VERSION_MAJOR 1)
-set (LDMicro_VERSION_MINOR 0)
+ # Version control
+ set (LDMicro_VERSION_MAJOR 1)
+ set (LDMicro_VERSION_MINOR 0)
-# configure a header file to pass some of the CMake settings
-# to the source code
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/includes")
-set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/includes")
-CONFIGURE_FILE (
- "${PROJECT_INCLUDE_DIR}/ldmicroVC.h.in"
- "${PROJECT_INCLUDE_DIR}/ldmicroVC.h"
-)
-MESSAGE ( STATUS " PROJECT_INCLUDE_DIR: " ${PROJECT_INCLUDE_DIR} )
+ # configure a header file to pass some of the CMake settings
+ # to the source code
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/linuxUI")
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/freezeLD")
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/includes")
+ set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/includes")
+ CONFIGURE_FILE (
+ "${PROJECT_INCLUDE_DIR}/ldmicroVC.h.in"
+ "${PROJECT_INCLUDE_DIR}/ldmicroVC.h"
+ )
+ MESSAGE ( STATUS " PROJECT_INCLUDE_DIR: " ${PROJECT_INCLUDE_DIR} )
-
-# Add GTK3 include files if GTK3 is found
-IF ( GTK3_FOUND )
- include_directories (${GTK3_INCLUDE_DIRS})
- link_directories (${GTK3_LIBRARY_DIRS})
- add_definitions (${GTK3_CFLAGS_OTHER})
- link_libraries (${GTK3_LIBRARIES})
- MESSAGE ( STATUS " GTK3_INCLUDE_DIR: " ${GTK3_INCLUDE_DIRS} )
- MESSAGE ( STATUS " GTK3_LIBRARIES: " ${GTK3_LIBRARIES} )
-ENDIF ( GTK3_FOUND)
-
-## Dummy compile and install to test linuxUI
-## to compile LDmicro uncomment the below 2 lines
-#add_executable (LDMicro ldmicro.cpp)# miscutil.cpp draw_outputdev.cpp)
-# install (TARGETS LDMicro DESTINATION bin)
-add_executable (linuxUI linuxUI.cpp testMain.cpp)
-install (TARGETS linuxUI DESTINATION bin)
+ # Add GTK3 include files if GTK3 is found
+ IF ( GTK3_FOUND )
+ include_directories (${GTK3_INCLUDE_DIRS})
+ link_directories (${GTK3_LIBRARY_DIRS})
+ add_definitions (${GTK3_CFLAGS_OTHER})
+ link_libraries (${GTK3_LIBRARIES})
+ MESSAGE ( STATUS " GTK3_INCLUDE_DIR: " ${GTK3_INCLUDE_DIRS} )
+ MESSAGE ( STATUS " GTK3_LIBRARIES: " ${GTK3_LIBRARIES} )
+ ENDIF ( GTK3_FOUND )
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/lib/linuxUI")
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/lib/freezeLD")
+
+ ## Dummy compile and install to test linuxUI
+ ## to compile LDmicro uncomment the below 2 line2
+ #add_executable (LDMicro ldmicro.cpp)# miscutil.cpp draw_outputdev.cpp)
+ # install (TARGETS LDMicro DESTINATION bin)
+ add_executable (testMain testMain.cpp)
+ target_link_libraries (testMain LinuxUI)
+ target_link_libraries (testMain FreezeLD)
+ install (TARGETS testMain DESTINATION bin)
+ENDIF(UNIX)
diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp
index bc4a7ef..0d6f3cd 100644
--- a/ldmicro/draw_outputdev.cpp
+++ b/ldmicro/draw_outputdev.cpp
@@ -25,7 +25,7 @@
// Ported to linus by: R Ramana, 2018
//-----------------------------------------------------------------------------
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index e7e3f17..cc0a525 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -24,7 +24,7 @@
// most of the UI logic relating to the main window.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
#include <stdio.h>
#include <stdlib.h>
@@ -36,7 +36,7 @@
HINSTANCE Instance;
-HWND MainWindow;
+HWID MainWindow;
HDC Hdc;
// parameters used to capture the mouse when implementing our totally non-
diff --git a/ldmicro/lib/freezeLD/CMakeLists.txt b/ldmicro/lib/freezeLD/CMakeLists.txt
new file mode 100644
index 0000000..761f348
--- /dev/null
+++ b/ldmicro/lib/freezeLD/CMakeLists.txt
@@ -0,0 +1,4 @@
+project( FreezeLD )
+
+add_library(FreezeLD freezeLD.cpp)
+target_link_libraries(FreezeLD LinuxUI)
diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp
new file mode 100644
index 0000000..5241af1
--- /dev/null
+++ b/ldmicro/lib/freezeLD/freezeLD.cpp
@@ -0,0 +1,265 @@
+/*
+ * A library for storing parameters in a key file
+ *
+ * This library is an analog to the windows freeze library
+ * developed by Jonathan Westhues.
+ *
+ * R Ramana, 2018
+ */
+#include "linuxUI.h"
+#include "freezeLD.h"
+#include <cstdlib>
+#include <fstream>
+#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(HWID hwid, char *subKey, char *name)
+{
+ g_print("freezing");
+ char* moveToKeyLocatin = (char *)malloc(strlen(subKey) + 35);
+ if(!moveToKeyLocatin)
+ return;
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s", LDMICRO_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return;
+ free(moveToKeyLocatin);
+
+ char *keyName = (char *)malloc(strlen(name) + 30);
+ if(!keyName)
+ return;
+
+ Key newKey;
+
+ int val;
+ g_print("get width");
+ sprintf(keyName, "%s_width", name);
+ std::ofstream Register(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ return;
+ gtk_window_get_size(GTK_WINDOW(hwid), &val, NULL);
+ newKey.type = 'i';
+ newKey.val.i = val;
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ g_print("get height");
+ sprintf(keyName, "%s_height", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ return;
+ gtk_window_get_size(GTK_WINDOW(hwid), NULL, &val);
+ newKey.type = 'i';
+ newKey.val.i = val;
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ g_print("get posX");
+ sprintf(keyName, "%s_posX", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ return;
+ gtk_window_get_position(GTK_WINDOW(hwid), &val, NULL);
+ newKey.type = 'i';
+ newKey.val.i = val;
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ g_print("get posY");
+ sprintf(keyName, "%s_posY", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ return;
+ gtk_window_get_position(GTK_WINDOW(hwid), NULL, &val);
+ newKey.type = 'i';
+ newKey.val.i = val;
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ g_print("get max");
+ sprintf(keyName, "%s_maximized", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ return;
+ newKey.type = 'b';
+ newKey.val.b = gtk_window_is_maximized(GTK_WINDOW(hwid));
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ free(keyName);
+ g_print("freezed");
+}
+
+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(HWID hwid, char *subKey, char *name)
+{
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ if(!moveToKeyLocatin)
+ return;
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return;
+ free(moveToKeyLocatin);
+
+ char *keyName = (char *)malloc(strlen(name) + 30);
+ if(!keyName)
+ return;
+
+ Key newKey1, newKey2;
+
+ /// set size
+ sprintf(keyName, "%s_width", name);
+ std::ifstream Register(keyName, std::ios::binary);
+ if (!Register.is_open())
+ return;
+ Register.read((char*) &newKey1, sizeof(newKey1));
+ Register.close();
+
+ sprintf(keyName, "%s_height", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ return;
+ Register.read((char*) &newKey2, sizeof(newKey2));
+ Register.close();
+ if (newKey1.type == 'i' && newKey2.type == 'i')
+ gtk_window_resize(GTK_WINDOW(hwid), newKey1.val.i, newKey2.val.i);
+
+
+ /// set position
+ sprintf(keyName, "%s_posX", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ return;
+ Register.read((char*) &newKey1, sizeof(newKey1));
+ Register.close();
+
+ sprintf(keyName, "%s_posY", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ return;
+ Register.read((char*) &newKey2, sizeof(newKey2));
+ Register.close();
+ if (newKey1.type == 'i' && newKey2.type == 'i')
+ gtk_window_move(GTK_WINDOW(hwid), newKey1.val.i, newKey2.val.i);
+
+
+ sprintf(keyName, "%s_maximized", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ return;
+ Register.read((char*) &newKey1, sizeof(newKey1));
+ Register.close();
+ if (newKey1.type == 'b')
+ if (newKey1.val.b)
+ gtk_window_maximize(GTK_WINDOW(hwid));
+
+
+ /// gtk_window_move handles off-screen window placement
+
+ free(keyName);
+}
+
+/*
+ * store a DWORD setting in the registry
+ */
+void FreezeDWORDF(DWORD val, char *subKey, char *name)
+{
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ if(!moveToKeyLocatin)
+ return;
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s", LDMICRO_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return;
+ free(moveToKeyLocatin);
+
+ Key newKey;
+ newKey.type = 'D';
+ newKey.val.D = val;
+ std::ofstream Register(name, std::ios::binary | std::ios::trunc);
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+}
+
+/*
+ * retrieve a DWORD setting, or return the default if that setting is unavailable
+ */
+DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
+{
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ if(!moveToKeyLocatin)
+ return val;
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return val;
+ free(moveToKeyLocatin);
+
+ Key newKey;
+
+ std::ifstream Register(name, std::ios::binary);
+ Register.read((char*) &newKey, sizeof(newKey));
+ Register.close();
+ if(Register.bad())
+ return val;
+
+ if(newKey.type == 'D')
+ return newKey.val.D;
+ else
+ return val;
+}
+
+/*
+ * store a string setting in the registry
+ */
+void FreezeStringF(char *val, char *subKey, char *name)
+{
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ if(!moveToKeyLocatin)
+ return;
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s", LDMICRO_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return;
+ free(moveToKeyLocatin);
+
+ std::ofstream Register(name, std::ios::trunc);
+ Register << strlen(val)+1 << "\n";
+ Register << val;
+ Register.close();
+}
+
+/*
+ * retrieve a string setting, or return the default if that setting is unavailable
+ */
+void ThawStringF(char *val, int max, char *subKey, char *name)
+{
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + 30);
+ if(!moveToKeyLocatin)
+ return;
+ sprintf(moveToKeyLocatin, "cd %s/%s", LDMICRO_REGISTER, subKey);
+ if (-1 == system(moveToKeyLocatin))
+ return;
+ free(moveToKeyLocatin);
+
+ std::ifstream Register(name);
+ int l;
+ Register >> l;
+ if (l >= max)
+ return;
+ Register >> val;
+}
+
diff --git a/common/linux/freeze.h b/ldmicro/lib/freezeLD/freezeLD.h
index 0827f6e..f14ef07 100644
--- a/common/linux/freeze.h
+++ b/ldmicro/lib/freezeLD/freezeLD.h
@@ -10,15 +10,19 @@
#ifndef __FREEZE_H
#define __FREEZE_H
-#ifndef FREEZE_SUBKEY
-#error must define FREEZE_SUBKEY to a string uniquely identifying the app
-#endif
+#define LDMICRO_REGISTER "/usr/share/ldmicro"
+
+#define FREEZE_SUBKEY "LDMicro"
+
+// #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);
+void FreezeWindowPosF(HWID hWid, char *subKey, char *name);
#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
-void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
+void ThawWindowPosF(HWID hWid, char *subKey, char *name);
#define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
void FreezeDWORDF(DWORD val, char *subKey, char *name);
@@ -35,14 +39,12 @@ void ThawStringF(char *val, int max, char *subKey, char *name);
typedef union regKeyVal{
int i;
float f;
- double d;
bool b;
DWORD D;
} KeyVal;
typedef struct regKeys{
- char name[15];
char type;
KeyVal val;
} Key;
diff --git a/ldmicro/lib/linuxUI/CMakeLists.txt b/ldmicro/lib/linuxUI/CMakeLists.txt
new file mode 100644
index 0000000..16226dc
--- /dev/null
+++ b/ldmicro/lib/linuxUI/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(LinuxUI)
+
+add_library(LinuxUI linuxUI.cpp)
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 53194e1..9aba23d 100644
--- a/ldmicro/includes/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_LD__
#define __LINUX_LD__
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
/// common windows referances for linux
@@ -15,6 +15,7 @@
typedef bool BOOL;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
+typedef long LONG;
/// all handles will hold a GtkWindow* type
typedef void* PVOID;
diff --git a/ldmicro/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
index 9cad93c..13af88b 100644
--- a/ldmicro/linuxUI.cpp
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -1,4 +1,4 @@
-#include "linuxUI/linuxUI.h"
+#include "linuxUI.h"
/// Menu Variables
HWID window;
@@ -39,7 +39,7 @@ int ScrollHeight; // Height of scroll
HWID IoList; // Window for list view
/// Wraper function for gtk_window_has_toplevel_focus
-BOOL isFocus(HWND window)
+BOOL isFocus(HWID window)
{
return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window));
}
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 01b7af2..3e49de0 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -6,14 +6,14 @@
#include <linux/limits.h>
#include <stdio.h>
#include <inttypes.h>
-#include "linuxUI/linuxLD.h"
+#include "linuxLD.h"
/// version control
#define LDMicro_VERSION_MAJOR 1
#define LDMicro_VERSION_MINOR 0
/// functions
-BOOL isFocus(HWND);
+BOOL isFocus(HWID);
COLORREF RGB(int, int, int);
#endif \ No newline at end of file