summaryrefslogtreecommitdiff
path: root/ldmicro/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ldmicro/lib')
-rw-r--r--ldmicro/lib/freezeLD/CMakeLists.txt4
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.cpp409
-rw-r--r--ldmicro/lib/freezeLD/freezeLD.h52
-rw-r--r--ldmicro/lib/linuxUI/CMakeLists.txt3
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp140
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h248
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.cpp542
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h270
8 files changed, 1668 insertions, 0 deletions
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..aad4be7
--- /dev/null
+++ b/ldmicro/lib/freezeLD/freezeLD.cpp
@@ -0,0 +1,409 @@
+/*
+ * 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)
+{
+ /*char* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return;
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(moveToKeyLocatin);
+ return;
+ }
+ free(moveToKeyLocatin);
+
+ char *keyName = (char *)malloc(strlen(name) + 30);
+ if(!keyName)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ Key newKey;
+
+ int val;
+
+ sprintf(keyName, "%s_width", name);
+ std::ofstream Register(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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();
+
+ sprintf(keyName, "%s_height", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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();
+
+ sprintf(keyName, "%s_posX", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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();
+
+ sprintf(keyName, "%s_posY", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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();
+
+ sprintf(keyName, "%s_maximized", name);
+ Register.open(keyName, std::ios::binary | std::ios::trunc);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ return;
+ }
+ newKey.type = 'b';
+ newKey.val.b = gtk_window_is_maximized(GTK_WINDOW(hwid));
+ Register.write((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ free(keyName);
+ chdir(Ld_CWD);
+ free(Ld_CWD);*/
+}
+
+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* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return;
+
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(moveToKeyLocatin);
+ return;
+ }
+ free(moveToKeyLocatin);
+
+ char *keyName = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!keyName)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ Key newKey1, newKey2;
+
+ /// set size
+ sprintf(keyName, "%s_width", name);
+ std::ifstream Register(keyName, std::ios::binary);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ return;
+ }
+ Register.read((char*) &newKey1, sizeof(newKey1));
+ Register.close();
+
+ sprintf(keyName, "%s_height", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ return;
+ }
+ Register.read((char*) &newKey1, sizeof(newKey1));
+ Register.close();
+
+ sprintf(keyName, "%s_posY", name);
+ Register.open(keyName, std::ios::binary);
+ if (!Register.is_open())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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())
+ {
+ free(Ld_CWD);
+ free(keyName);
+ 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);
+ chdir(Ld_CWD);
+ free(Ld_CWD);*/
+}
+
+/*
+ * store a DWORD setting in the registry
+ */
+void FreezeDWORDF(DWORD val, char *subKey, char *name)
+{
+ char* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return;
+
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(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();
+
+ chdir(Ld_CWD);
+ free(Ld_CWD);
+}
+
+/*
+ * retrieve a DWORD setting, or return the default if that setting is unavailable
+ */
+DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
+{
+ char* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return val;
+
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return val;
+ }
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(moveToKeyLocatin);
+ return val;
+ }
+ free(moveToKeyLocatin);
+
+ Key newKey;
+
+ std::ifstream Register(name, std::ios::binary);
+ Register.read((char*) &newKey, sizeof(newKey));
+ Register.close();
+
+ chdir(Ld_CWD);
+ free(Ld_CWD);
+
+ 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* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return;
+
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ system(moveToKeyLocatin);
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(moveToKeyLocatin);
+ return;
+ }
+ free(moveToKeyLocatin);
+
+ std::ofstream Register(name, std::ios::trunc);
+ Register << strlen(val)+1 << "\n";
+ Register << val;
+ Register.close();
+
+ chdir(Ld_CWD);
+ free(Ld_CWD);
+}
+
+/*
+ * retrieve a string setting, or return the default if that setting is unavailable
+ */
+void ThawStringF(char *val, int max, char *subKey, char *name)
+{
+ char* Ld_CWD = (char *)malloc(MAX_PATH);
+ getcwd(Ld_CWD, MAX_PATH);
+
+ if (!Ld_CWD)
+ return;
+
+ char* moveToKeyLocatin = (char *)malloc(strlen(name) + MAX_PATH);
+ if(!moveToKeyLocatin)
+ {
+ free(Ld_CWD);
+ return;
+ }
+
+ sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey);
+ if (-1 == chdir(moveToKeyLocatin))
+ {
+ free(Ld_CWD);
+ free(moveToKeyLocatin);
+ return;
+ }
+ free(moveToKeyLocatin);
+
+ std::ifstream Register(name);
+ int l;
+ Register >> l;
+ if (l >= max)
+ {
+ free(Ld_CWD);
+ return;
+ }
+ Register >> val;
+
+ chdir(Ld_CWD);
+ free(Ld_CWD);
+}
+
diff --git a/ldmicro/lib/freezeLD/freezeLD.h b/ldmicro/lib/freezeLD/freezeLD.h
new file mode 100644
index 0000000..581466d
--- /dev/null
+++ b/ldmicro/lib/freezeLD/freezeLD.h
@@ -0,0 +1,52 @@
+/*
+ * 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
+ */
+
+#ifndef __FREEZE_H
+#define __FREEZE_H
+
+#define FREEZE_REGISTER ".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(HWID hWid, char *subKey, char *name);
+
+#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
+void ThawWindowPosF(HWID hWid, 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);
+
+typedef union regKeyVal{
+ int i;
+ float f;
+ bool b;
+ DWORD D;
+} KeyVal;
+
+
+typedef struct regKeys{
+ char type;
+ KeyVal val;
+} Key;
+
+#endif
diff --git a/ldmicro/lib/linuxUI/CMakeLists.txt b/ldmicro/lib/linuxUI/CMakeLists.txt
new file mode 100644
index 0000000..25ba6b2
--- /dev/null
+++ b/ldmicro/lib/linuxUI/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(LinuxUI)
+
+add_library(LinuxUI linuxUI.cpp linuxLD.cpp)
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp
new file mode 100644
index 0000000..a83d15e
--- /dev/null
+++ b/ldmicro/lib/linuxUI/linuxLD.cpp
@@ -0,0 +1,140 @@
+#include "linuxUI.h"
+#include <iostream>
+
+using namespace std;
+
+std::vector<HEAPRECORD> HeapRecords;
+
+HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
+{
+ HANDLE hHeap = NULL;
+ HEAPRECORD hHeapRecord;
+ hHeapRecord.dwMaximumSize = dwMaximumSize;
+ // hHeap = malloc(dwInitialSize);
+
+ if (hHeap == NULL)
+ return NULL;
+
+ hHeapRecord.dwSize = dwInitialSize;
+ hHeapRecord.hHeap = hHeap;
+ hHeapRecord.dwAllocatedSizeOffset = 0;
+ hHeapRecord.HeapID = HeapRecords.size()+1;
+ HeapRecords.push_back(hHeapRecord);
+
+ return hHeap;
+}
+
+LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
+{
+ // if (hHeap == NULL)
+ // {
+ // printf("Alloc**********NULL HEAP***************\n");
+ LPVOID p = malloc(dwBytes);
+ return p;
+ // }
+
+ // auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; });
+
+ // if (it == HeapRecords.end())
+ // return NULL;
+
+ // if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize)
+ // {
+ // if ((*it).dwMaximumSize != 0)
+ // if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize)
+ // return NULL;
+
+ // (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes);
+ // hHeap = (*it).hHeap;
+ // }
+
+ // /// HEAP_ZERO_MEMORY is set by default
+ // DWORD flags = MAP_ANONYMOUS;
+
+ // // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) )
+ // // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED;
+
+ // /* Use for setting a meamory chunck with some value
+ // * void * memset ( void * ptr, int value, size_t num );
+ // */
+ // LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0);
+
+ // if (p == NULL)
+ // return NULL;
+
+ // (*it).dwAllocatedSizeOffset += dwBytes;
+ // HEAPCHUNCK chunck;
+ // chunck.Chunck = p;
+ // chunck.dwSize = dwBytes;
+ // (*it).Element.push_back(chunck);
+
+ // return p;
+}
+
+BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
+{
+ /// if NULL free()
+ // if (hHeap == NULL)
+ // {
+ // printf("free*********NULL HEAP***************\n");
+ free(lpMem);
+ return TRUE;
+ // }
+ // auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; });
+
+ // if (heap_it == HeapRecords.end())
+ // return FALSE;
+
+ // auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; });
+
+ // if (chunck_it == (*heap_it).Element.end())
+ // return FALSE;
+
+ // int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize);
+
+ // if (result == 0)
+ // {
+ // (*heap_it).Element.erase(chunck_it);
+ // return TRUE;
+ // }
+ // else
+ // return FALSE;
+
+}
+
+HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired,
+ int cyDesired, UINT fuLoad)
+{
+ HICON pixbuf;
+ GError *error = NULL;
+ pixbuf = gdk_pixbuf_new_from_file(lpszName, &error);
+
+ if(!pixbuf) {
+ fprintf(stderr, "%s\n", error->message);
+ g_error_free(error);
+ }
+
+ return pixbuf;
+}
+
+void 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;
+}
+
+void OutputDebugString(char* str)
+{
+
+}
+
+double GetTickCount(void)
+{
+// timespec now;
+// clock_gettime()
+// if (clock_gettime(CLOCK_MONOTONIC, &now))
+// return 0;
+ return 10.2;//now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0;
+}
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
new file mode 100644
index 0000000..f1abbaf
--- /dev/null
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -0,0 +1,248 @@
+#ifndef __LINUX_LD__
+#define __LINUX_LD__
+
+#include "linuxUI.h"
+#include <ctype.h>
+#include <vector>
+#include <math.h>
+#include <algorithm>
+#include <QAction>
+#include <QTreeWidget>
+#include <QSplitter>
+#include <Qt>
+#include <sys/mman.h>
+
+/// common windows referances for linux
+
+/// definitions
+#define MAX_PATH PATH_MAX
+/// CALLBACK or __stdcall os defined empty
+#define CALLBACK
+#define CONST const
+
+/// Meamory flags
+#define HEAP_ZERO_MEMORY 0x00000008
+
+/// Image loading flags
+#define IMAGE_ICON 1
+#define LDMICRO_ICON "../ldmicro.ico"
+
+/// Macro functions
+#define max(_A, _B) std::max(_A, _B)
+
+/// Typedefs
+//typedef int64_t __int64;
+typedef bool BOOL;
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+typedef unsigned int DWORD;
+typedef unsigned int UINT;
+typedef size_t SIZE_T;
+typedef long LONG;
+typedef wchar_t WCHAR;
+typedef char CHAR;
+
+typedef CONST WCHAR *LPCWSTR;
+typedef CONST CHAR *LPCSTR; /// should be __nullterminated
+typedef WORD ATOM;
+
+#ifdef UNICODE
+ typedef LPCWSTR LPCTSTR;
+#else
+ typedef LPCSTR LPCTSTR;
+#endif
+
+typedef WCHAR *LPWSTR;
+typedef CHAR *LPSTR;
+
+#ifdef UNICODE
+ typedef LPWSTR LPTSTR;
+#else
+ typedef LPSTR LPTSTR;
+#endif
+
+typedef void *PVOID;
+typedef void *LPVOID;
+typedef PVOID HMODULE;
+typedef PVOID HHOOK;
+
+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;
+
+/// Check if system is x64 or x86
+#if defined(__UNIX64)
+typedef uint64_t UINT_PTR;
+#else
+typedef unsigned int UINT_PTR;
+#endif
+
+typedef UINT_PTR WPARAM;
+
+#if defined(__UNIX64)
+ typedef __int64_t LONG_PTR;
+#else
+ typedef long LONG_PTR;
+#endif
+
+typedef LONG_PTR LPARAM;
+typedef LONG_PTR LRESULT;
+
+/// Classes
+typedef class tagColorReferance: public QColor{
+ public:
+ tagColorReferance()
+ {
+ this->setRgb(0,0,0);
+ }
+
+ tagColorReferance(int r, int g, int b)
+ {
+ this->setRgb(r,g,b);
+ }
+
+ bool operator== (tagColorReferance& arg1)
+ {
+ if( (arg1.red() == this->red()) &&
+ (arg1.green() == this->green()) &&
+ (arg1.blue() == this->blue()) )
+ return true;
+ else
+ return false;
+ }
+
+} COLORREF, *HBRUSH;
+
+/// Structures
+typedef struct HeapRecordChunckTag{
+ PVOID Chunck;
+ SIZE_T dwSize;
+} HEAPCHUNCK;
+
+typedef struct HeapRecordTag{
+ PVOID hHeap;
+ DWORD HeapID;
+ std::vector<HEAPCHUNCK> Element;
+ SIZE_T dwMaximumSize;
+ SIZE_T dwSize;
+ SIZE_T dwAllocatedSizeOffset;
+} HEAPRECORD;
+
+typedef struct tagSCROLLINFO {
+ UINT cbSize;
+ UINT fMask;
+ int nMin;
+ int nMax;
+ UINT nPage;
+ int nPos;
+ int nTrackPos;
+} SCROLLINFO, *LPCSCROLLINFO;
+
+typedef struct {
+ UINT mask;
+ int iItem;
+ int iSubItem;
+// UINT state;
+// UINT stateMask;
+ LPTSTR pszText;
+// int cchTextMax;
+// int iImage;
+// LPARAM lParam;
+// int iIndent;
+// int iGroupId;
+// UINT cColumns;
+// PUINT puColumns;
+// int *piColFmt;
+// int iGroup;
+} LVITEM, *LPLVITEM;
+
+typedef struct tagNMHDR {
+ HLIST hlistFrom;
+ HITLIST hlistIter;
+ UINT code;
+ LVITEM item;
+} NMHDR;
+
+typedef struct FontTag {
+ int nHeight;
+ int nWidth;
+ int nOrientation;
+ int fnWeight;
+ DWORD fdwItalic;
+ LPTSTR lpszFace;
+} *HFONT, FONT;
+
+typedef struct tagLOGBRUSH {
+ UINT lbStyle;
+ COLORREF lbColor;
+// ULONG_PTR lbHatch;
+} LOGBRUSH, *PLOGBRUSH;
+
+typedef struct _RECT {
+ LONG left;
+ LONG top;
+ LONG right;
+ LONG bottom;
+} RECT, *PRECT;
+
+typedef struct SimpleDialogDataTag {
+ UINT uflag;
+ int boxes;
+ char **dests;
+ char *str1;
+ char *str2;
+ char *str3;
+ int *num1;
+ int *num2;
+} SimpleDialogData;
+
+/// Variables
+extern std::vector<HEAPRECORD> HeapRecord;
+
+/// Functions
+HANDLE HeapCreate(
+ DWORD flOptions,
+ SIZE_T dwInitialSize,
+ SIZE_T dwMaximumSize);
+
+LPVOID HeapAlloc(
+ HANDLE hHeap,
+ DWORD dwFlags,
+ SIZE_T dwBytes);
+
+BOOL HeapFree(
+ HANDLE hHeap,
+ DWORD dwFlags,
+ LPVOID lpMem);
+
+HICON LoadImage(
+ HINSTANCE hinst,
+ LPCTSTR lpszName,
+ UINT uType,
+ int cxDesired,
+ int cyDesired,
+ UINT fuLoad
+);
+
+void RECT_to_GDRECT(
+ const RECT *rc,
+ GDRECT *gdrc);
+
+/// functions to be ported
+void OutputDebugString(char*);
+double GetTickCount(void);
+
+#endif \ No newline at end of file
diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp
new file mode 100644
index 0000000..e8a8ab5
--- /dev/null
+++ b/ldmicro/lib/linuxUI/linuxUI.cpp
@@ -0,0 +1,542 @@
+#include "linuxUI.h"
+
+/// Global variables to hole mouse click positions
+int GLOBAL_mouse_last_clicked_x;
+int GLOBAL_mouse_last_clicked_y;
+
+/// Brushes
+const COLORREF BLACK_BR(0, 0, 0);
+const COLORREF WHITE_BR(255, 255, 255);
+const COLORREF GRAY_BR(128, 128, 128);
+const COLORREF LTGRAY_BR(211, 211, 211);
+const COLORREF DKGRAY_BR(169, 169, 169);
+
+/// Variable to current text color
+COLORREF HdcCurrentTextColor;
+
+/// Variable to hold timers
+std::vector<TimerRecord> timerRecords;
+
+/// EnableMenuItem Variables
+const UINT MF_ENABLED = 0;
+const UINT MF_GRAYED = 1;
+const UINT MF_CHECKED = 2;
+const UINT MF_UNCHECKED = 3;
+
+/// Accelerators (keyboard shortcuts)
+GtkAccelGroup* AccelGroup;
+GClosure* closure;
+
+/// ListStore
+HWID view;
+HTVC column;
+
+/// Wraper function for gtk_window_has_toplevel_focus
+BOOL GetFocus(HWID window)
+{
+ // return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window));
+ return TRUE;
+}
+
+COLORREF RGB(int red, int green, int blue)
+{
+ COLORREF col(red, green, blue);
+ // col.red = red/255.0;
+ // col.green = green/255.0;
+ // col.blue = blue/255.0;
+ // col.alpha = 1.0;
+
+ return col;
+}
+
+int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags)
+ {
+/* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
+ GtkMessageType mType;
+
+ if ((mFlags & MB_ICONERROR) == MB_ICONERROR)
+ mType = GTK_MESSAGE_ERROR;
+ else if ((mFlags & MB_ICONQUESTION) == MB_ICONQUESTION)
+ mType = GTK_MESSAGE_QUESTION;
+ else if ((mFlags & MB_ICONWARNING) == MB_ICONWARNING)
+ mType = GTK_MESSAGE_WARNING;
+ else if ((mFlags & MB_ICONINFORMATION) == MB_ICONINFORMATION)
+ mType = GTK_MESSAGE_INFO;
+ else
+ mType = GTK_MESSAGE_OTHER;
+
+ mType = GTK_MESSAGE_ERROR;
+ HWID dialog = gtk_message_dialog_new (GTK_WINDOW(pWindow),
+ flags,
+ mType,
+ GTK_BUTTONS_NONE,
+ message);
+
+ if ((mFlags & MB_OKCANCEL) == MB_OKCANCEL)
+ {
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_OK", IDOK);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL);
+ }
+ else if ((mFlags & MB_YESNO) == MB_YESNO)
+ {
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO);
+ }
+ else if ((mFlags & MB_YESNOCANCEL) == MB_YESNOCANCEL)
+ {
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_YES", IDYES);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_NO", IDNO);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "_CANCEL", IDCANCEL);
+ }
+ else
+ gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", IDOK);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog),
+ title);
+ gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), message);
+ int result = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+*/
+ // return result;
+ return TRUE;
+ }
+
+
+BOOL GetSaveFileName(OPENFILENAME *ofn)
+{
+ /*GtkWidget *dialog;
+ GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
+
+ dialog = gtk_file_chooser_dialog_new (ofn->lpstrTitle,
+ GTK_WINDOW(ofn->parentWindow),
+ action,
+ "_Cancel",
+ GTK_RESPONSE_CANCEL,
+ "_Save",
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+ char filename[15] = "Untitled";
+
+ if (ofn->lpstrDefExt != NULL)
+ sprintf(filename, "Untitled.%s", ofn->lpstrDefExt);
+
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), filename);
+
+ if (ofn->Flags & OFN_OVERWRITEPROMPT)
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
+
+ GtkFileFilter *filter = gtk_file_filter_new ();
+ char* strFilter = new char[strlen(ofn->lpstrFilter)];
+ DWORD strFilterLen = 0;
+ BOOL filterResetFlag = FALSE;
+
+ for (int i = 0; !(ofn->lpstrFilter[i] == '\0' && ofn->lpstrFilter[i-1] == '\0'); ++i)
+ {
+ memcpy (strFilter + strFilterLen, &ofn->lpstrFilter[i], 1 );
+ ++strFilterLen;
+ if (ofn->lpstrFilter[i] == '\0')
+ if (filterResetFlag)
+ {
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(dialog), filter);
+ filter = gtk_file_filter_new ();
+ strFilterLen = 0;
+ filterResetFlag = FALSE;
+ }
+ else
+ {
+ gtk_file_filter_set_name (GTK_FILE_FILTER(filter), strFilter);
+ strFilterLen = 0;
+ filterResetFlag = TRUE;
+ }
+ }
+
+ sprintf(strFilter, "*.%s", ofn->lpstrDefExt);
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog), filter);
+
+ delete strFilter;
+
+ BOOL exitStatus = gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
+ if (exitStatus)
+ {
+ char* str;
+ str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
+
+ strcpy(ofn->lpstrFile, str);
+ g_free(str);
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return exitStatus;*/
+ return TRUE;
+}
+
+BOOL GetOpenFileName(OPENFILENAME *ofn)
+{
+/* GtkWidget *dialog;
+ GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
+
+ dialog = gtk_file_chooser_dialog_new (ofn->lpstrTitle,
+ GTK_WINDOW(ofn->parentWindow),
+ action,
+ "_Cancel",
+ GTK_RESPONSE_CANCEL,
+ "_Open",
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ GtkFileFilter *filter = gtk_file_filter_new ();
+ char* strFilter = new char[strlen(ofn->lpstrFilter)];
+ DWORD strFilterLen = 0;
+ BOOL filterResetFlag = FALSE;
+
+ for (int i = 0; !(ofn->lpstrFilter[i] == '\0' && ofn->lpstrFilter[i-1] == '\0'); ++i)
+ {
+ memcpy (strFilter + strFilterLen, &ofn->lpstrFilter[i], 1 );
+ ++strFilterLen;
+ if (ofn->lpstrFilter[i] == '\0')
+ if (filterResetFlag)
+ {
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(dialog), filter);
+ filter = gtk_file_filter_new ();
+ strFilterLen = 0;
+ filterResetFlag = FALSE;
+ }
+ else
+ {
+ gtk_file_filter_set_name (GTK_FILE_FILTER(filter), strFilter);
+ strFilterLen = 0;
+ filterResetFlag = TRUE;
+ }
+ }
+
+ sprintf(strFilter, "*.%s", ofn->lpstrDefExt);
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter), strFilter);
+ //gtk_file_filter_set_name (filter, "int files");
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog), filter);
+
+ delete strFilter;
+
+ BOOL exitStatus = gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
+ if (exitStatus)
+ {
+ char* str;
+ str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
+ strcpy(ofn->lpstrFile, str);
+ g_free(str);
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return exitStatus;*/
+ return TRUE;
+}
+
+
+void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem)
+{
+ /*switch (CheckEnabledItem){
+ case MF_ENABLED :
+ gtk_widget_set_sensitive (MenuItem, true);
+ break;
+ case MF_GRAYED :
+ gtk_widget_set_sensitive (MenuItem, false);
+ break;
+ }*/
+}
+
+void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check)
+{
+ /*switch (Check){
+ case MF_CHECKED :
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), true);
+ break;
+ case MF_UNCHECKED :
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), false);
+ break;
+ }*/
+}
+
+HANDLE GetStockObject(int fnObject)
+{
+ switch(fnObject)
+ {
+ case BLACK_BRUSH:
+ return (HANDLE)&BLACK_BR;
+ break;
+ case WHITE_BRUSH:
+ return (HANDLE)&WHITE_BR;
+ break;
+ case GRAY_BRUSH:
+ return (HANDLE)&GRAY_BR;
+ break;
+ case LTGRAY_BRUSH:
+ return (HANDLE)&LTGRAY_BR;
+ break;
+ case DKGRAY_BRUSH:
+ return (HANDLE)&DKGRAY_BR;
+ break;
+ default:
+ return (HANDLE)&WHITE_BR;
+ }
+}
+
+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);
+}
+
+HBRUSH CreateBrushIndirect(PLOGBRUSH plb)
+{
+ COLORREF* brush = new COLORREF;
+ brush->setRgb( plb->lbColor.red(),
+ plb->lbColor.green(),
+ plb->lbColor.blue(),
+ (plb->lbStyle == BS_SOLID) ? 255 : 51);
+
+ return brush;
+}
+
+HFONT CreateFont(int nHeight, int nWidth, int nOrientation, int fnWeight,
+ DWORD fdwItalic, LPCTSTR lpszFace)
+{
+ HFONT font = (HFONT)malloc(strlen(lpszFace) + 1 + sizeof(FONT));
+ font->nHeight = nHeight;
+ font->nWidth = nWidth;
+ font->nOrientation = nOrientation;
+ font->fnWeight = fnWeight;
+ font->fdwItalic = fdwItalic;
+ font->lpszFace = (char*)malloc(strlen(lpszFace)+1);
+ strcpy(font->lpszFace, lpszFace);
+
+ return font;
+}
+
+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);*/
+}
+
+void SetTextColor(HCRDC hcr, COLORREF color)
+{
+ if (hcr == NULL)
+ return;
+
+ 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;
+
+ nYStart += 30;
+
+ cairo_text_extents_t extents;
+ cairo_text_extents (hcr, lpString, &extents);
+ int width = gtk_widget_get_allocated_width (hWid);
+ int height= gtk_widget_get_allocated_height (hWid);
+ BOOL resize_flag = FALSE;
+
+ if(nYStart+(extents.height/2.0) >= height)
+ {
+ height += extents.height + 50;
+ resize_flag = TRUE;
+ }
+
+ if (nXStart+(extents.width/2.0) >= width)
+ {
+ width += extents.width;
+ resize_flag = TRUE;
+ }
+
+ if (resize_flag)
+ gtk_widget_set_size_request(hWid, width, height);
+
+ char* text = (char*)malloc(cchString);
+ strncpy(text, lpString, cchString);
+ text[cchString] = '\0';
+
+ cairo_move_to(hcr, nXStart, nYStart);
+ cairo_show_text(hcr, text);
+
+ cairo_fill (hcr);*/
+}
+
+COLORREF GetTextColor(HCRDC Hdc)
+{
+ // COLORREF col;
+ // gtk_style_context_get_color (Hdc,
+ // gtk_style_context_get_state (Hdc),
+ // &col);
+
+ return HdcCurrentTextColor;
+}
+
+BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase)
+{
+ /*if(!GDK_IS_WINDOW(hWid))
+ return FALSE;
+
+ if (lpRect == NULL)
+ {
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE);
+ return TRUE;
+ }
+
+ GDRECT Gdrect;
+ RECT_to_GDRECT(lpRect, &Gdrect);
+ // gtk_widget_queue_draw(hWid);
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE);
+ */
+ return TRUE;
+}
+
+int FillRect(HCRDC hDC, const RECT *lprc, HBRUSH hbr)
+{
+ if (hDC == NULL)
+ return -1;
+ /*
+ GDRECT gdrc;
+ RECT_to_GDRECT(lprc, &gdrc);
+
+ cairo_set_source_rgb(hDC, hbr->red, hbr->green, hbr->blue);
+ cairo_rectangle(hDC, gdrc.x, gdrc.y, gdrc.width, gdrc.height);
+ cairo_stroke_preserve(hDC);
+ cairo_fill(hDC);*/
+
+ return 0;
+}
+
+BOOL PatBlt(HCRDC hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, DWORD dwRop, HBRUSH hbr)
+{
+ if (hdc == NULL)
+ return FALSE;
+
+ //cairo_set_source_rgb(hdc, hbr->red, hbr->green, hbr->blue);
+ //cairo_rectangle(hdc, nXLeft, nYLeft + 20, nWidth, nHeight);
+ //cairo_stroke_preserve(hdc);
+
+ //cairo_fill(hdc);
+
+ return TRUE;
+}
+
+BOOL GetClientRect(HWID hWid, PRECT pRect)
+{
+ /* GtkAllocation allocation;
+ gtk_widget_get_allocation (hWid, &allocation);
+
+ pRect->top = allocation.x;
+ pRect->left = allocation.y;
+ pRect->right = allocation.width;
+ pRect->bottom = allocation.height;
+*/
+ return TRUE;
+}
+
+BOOL MoveWindow(HWID hWid, int X, int Y, int nWidth, int nHeight, BOOL bRepaint)
+{
+ /* gtk_window_move(GTK_WINDOW(hWid), X, Y);
+ gtk_window_resize(GTK_WINDOW(hWid), nWidth, nHeight);
+
+ if (bRepaint)
+ gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE);
+ */
+ return TRUE;
+}
+
+
+BOOL GetWindowRect(HWID hWid, PRECT pRect)
+{
+ /*GtkAllocation allocation;
+ gtk_widget_get_allocation (hWid, &allocation);
+
+ pRect->top = allocation.x;
+ pRect->left = allocation.y;
+ pRect->right = allocation.width;
+ pRect->bottom = allocation.height;
+*/
+ return TRUE;
+}
+
+
+UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, BOOL (*lpTimerFunc)(BOOL) )
+{
+ auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; });
+
+ if (record_it != timerRecords.end())
+ return 0;
+
+ TimerRecord tr;
+ tr.pfun = lpTimerFunc;
+ tr.ufID = nIDEvent;
+ tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE);
+
+ timerRecords.push_back(tr);
+ return tr.utID;
+}
+
+BOOL KillTimer(HWID hWid, UINT uIDEvent)
+{
+ auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; });
+
+ if (record_it == timerRecords.end())
+ return FALSE;
+
+ record_it->pfun(TRUE);
+ g_source_remove (record_it->utID);
+ timerRecords.erase(record_it);
+
+ return TRUE;
+}
+
+void DestroyWindow (HWID widget)
+{
+ /*if (GTK_IS_WIDGET(widget))
+ {
+ gtk_widget_destroy (widget);
+ }*/
+}
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
new file mode 100644
index 0000000..e482051
--- /dev/null
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -0,0 +1,270 @@
+#ifndef __LINUX_UI__
+#define __LINUX_UI__
+
+/// includes
+#include <gtk/gtk.h>
+#include <QApplication>
+#include <QWidget>
+#include <QMenu>
+#include <QMenuBar>
+#include <QVBoxLayout>
+#include <QLabel>
+// #include <QSize>
+// #include "freezeLD.h"
+// #include "linuxLD.h"
+#include <linux/limits.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <string.h>
+#include <stdlib.h>
+#include "linuxLD.h"
+
+// 4000 ICON "ldmicro.ico"
+
+/// version control
+#define LDMicro_VERSION_MAJOR 1
+#define LDMicro_VERSION_MINOR 0
+
+/// Flags
+/// message box
+#define MB_OK 0x00000001L
+#define MB_OKCANCEL 0x00000002L
+#define MB_YESNO 0x00000004L
+#define MB_YESNOCANCEL 0x00000008L
+
+#define IDOK 1
+#define IDCANCEL 2
+#define IDYES 3
+#define IDNO 4
+
+#define MB_ICONERROR 0x00000010L
+#define MB_ICONQUESTION 0x00000020L
+#define MB_ICONWARNING 0x00000040L
+#define MB_ICONINFORMATION 0x00000080L
+
+/// Scroll
+#define SB_LINEUP 0x00000001
+#define SB_PAGEUP 0x00000002
+#define SB_LINEDOWN 0x00000004
+#define SB_PAGEDOWN 0x00000008
+#define SB_TOP 0x00000010
+#define SB_BOTTOM 0x00000020
+#define SB_THUMBTRACK 0x00000040
+#define SB_THUMBPOSITION 0x00000080
+
+/// UART terminal flags
+#define WM_GETTEXT 0x00000001
+#define WM_SETTEXT 0x00000002
+#define WM_SETTEXT_END 0x00000004
+
+/// List view flags
+#define LVN_ITEMACTIVATE 0x00000001
+#define LVN_GETDISPINFO 0x00000002
+
+/// Open/save file
+#define OFN_PATHMUSTEXIST 0x00000001L
+#define OFN_HIDEREADONLY 0x00000002L
+#define OFN_OVERWRITEPROMPT 0x00000004L
+
+/// PatBlt paint flags
+#define PATINVERT 0x00000100L
+
+/// Key masks
+#define VK_TAB GDK_KEY_Tab
+
+#define VK_DOWN 65364
+#define VK_UP 65362
+#define VK_LEFT 65361
+#define VK_RIGHT 65363
+
+#define VK_NP_DOWN 65433
+#define VK_NP_UP 65431
+#define VK_NP_LEFT 65430
+#define VK_NP_RIGHT 65432
+
+#define VK_RETURN GDK_KEY_Return
+#define VK_ESCAPE GDK_KEY_Escape
+#define VK_F5 GDK_KEY_F5
+#define VK_F1 GDK_KEY_F1
+
+#define VK_OEM_PLUS GDK_KEY_plus
+#define VK_OEM_MINUS GDK_KEY_minus
+#define VK_OEM_PERIOD GDK_KEY_period
+#define VK_OEM_COMMA GDK_KEY_comma
+
+#define VK_DELETE GDK_KEY_Delete
+#define VK_NP_DELETE GDK_KEY_KP_Delete
+
+// #define VK_OEM_1 GDK_KEY_colon // GDK_KEY_semicolon
+// #define VK_OEM_2 GDK_KEY_question // GDK_KEY_slash
+// #define VK_OEM_5 GDK_KEY_backslash // GDK_KEY_bar
+
+/// Window brushes
+#define BS_SOLID 0x00000001L
+#define BS_HOLLOW 0x00000002L
+#define BLACK_BRUSH 0x00000004L
+#define WHITE_BRUSH 0x00000008L
+#define GRAY_BRUSH 0x00000010L
+#define LTGRAY_BRUSH 0x00000020L
+#define DKGRAY_BRUSH 0x00000040L
+
+extern const COLORREF BLACK_BR;
+extern const COLORREF WHITE_BR;
+extern const COLORREF GRAY_BR;
+extern const COLORREF LTGRAY_BR;
+extern const COLORREF DKGRAY_BR;
+
+/// Font flags
+#define FW_REGULAR 0x00000001L
+#define FW_BOLD 0x00000002L
+
+/// EnableMenuItem variables
+extern const UINT MF_ENABLED;
+extern const UINT MF_GRAYED;
+extern const UINT MF_CHECKED;
+extern const UINT MF_UNCHECKED;
+
+/// Accelerators (keyboard shortcuts)
+extern GtkAccelGroup* AccelGroup;
+extern GClosure* closure;
+
+/// ListStore
+extern HWID view;
+extern HTVC column;
+
+/// Structures
+typedef struct OpenFileInfoData {
+ DWORD lStructSize;
+ HWID *parentWindow;
+ LPTSTR lpstrFile;
+ LPCTSTR lpstrFilter;
+ DWORD nMaxFile;
+ LPCTSTR lpstrTitle;
+ DWORD Flags;
+ LPCTSTR lpstrDefExt;
+} OPENFILENAME;
+
+typedef struct TimerRecordTag {
+ BOOL (*pfun)(BOOL);
+ UINT ufID;
+ UINT utID;
+} TimerRecord;
+
+/// Variables
+extern COLORREF HdcCurrentTextColor;
+extern std::vector<TimerRecord> timerRecords;
+extern int GLOBAL_mouse_last_clicked_x;
+extern int GLOBAL_mouse_last_clicked_y;
+/// functions
+BOOL GetFocus(HWID window);
+
+COLORREF RGB(
+ int red,
+ int green,
+ int blue);
+
+int MessageBox(
+ HWID pWindow,
+ char* message,
+ char* title,
+ UINT mFlags);
+
+BOOL GetSaveFileName(OPENFILENAME *ofn);
+
+BOOL GetOpenFileName(OPENFILENAME *ofn);
+
+void EnableMenuItem(
+ HMENU MenuName,
+ HMENU MenuItem,
+ UINT CheckEnabledItem);
+
+void CheckMenuItem(
+ HMENU MenuName,
+ HMENU MenuItem,
+ UINT Check);
+
+HANDLE GetStockObject(int fnObject);
+
+void SelectObject(
+ HCRDC hcr,
+ HFONT hfont);
+
+HBRUSH CreateBrushIndirect(PLOGBRUSH plb);
+
+HFONT CreateFont(
+ int nHeight,
+ int nWidth,
+ int nOrientation,
+ int fnWeight,
+ DWORD fdwItalic,
+ LPCTSTR lpszFace);
+
+void SetBkColor(
+ HWID widget,
+ HCRDC hcr,
+ COLORREF bkCol);
+
+void SetTextColor(
+ HCRDC hcr,
+ COLORREF color);
+
+void TextOut(
+ HWID hWid,
+ HCRDC hcr,
+ int nXStart,
+ int nYStart,
+ LPCTSTR lpString,
+ int cchString);
+
+COLORREF GetTextColor(HCRDC Hdc);
+
+BOOL InvalidateRect(
+ HWID hWId,
+ const RECT *lpRect,
+ BOOL bErase);
+
+int FillRect(
+ HCRDC hDC,
+ const RECT *lprc,
+ HBRUSH hbr);
+
+BOOL PatBlt(
+ HCRDC hdc,
+ int nXLeft,
+ int nYLeft,
+ int nWidth,
+ int nHeight,
+ DWORD dwRop,
+ HBRUSH hbr);
+
+BOOL GetClientRect(
+ HWID hWid,
+ PRECT lpRect);
+
+BOOL MoveWindow(
+ HWID hWid,
+ int X,
+ int Y,
+ int nWidth,
+ int nHeight,
+ BOOL bRepaint);
+
+BOOL GetWindowRect(
+ HWID hWid,
+ PRECT pRect);
+
+UINT SetTimer(
+ HWID hWid,
+ UINT nIDEvent,
+ UINT uElapse,
+ BOOL (*lpTimerFunc)(BOOL));
+
+BOOL KillTimer(
+ HWID hWid,
+ UINT uIDEvent);
+
+void DestroyWindow (HWID widget);
+
+
+
+#endif \ No newline at end of file