diff options
Diffstat (limited to 'ldmicro/lib/linuxUI')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 28 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 67 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 55 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 23 |
4 files changed, 146 insertions, 27 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index e4fd018..ce9899b 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -1,6 +1,7 @@ #include "linuxUI.h" std::vector<HEAPRECORD> HeapRecords; +std::vector<WNDCLASSEX> WindClassRecord; HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize) { @@ -25,7 +26,7 @@ LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) { if (hHeap == NULL) { - printf("Alloc**********NULL HEAP***************\n"); + // printf("Alloc**********NULL HEAP***************\n"); LPVOID p = malloc(dwBytes); return p; } @@ -73,7 +74,7 @@ BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) /// if NULL free() if (hHeap == NULL) { - printf("free*********NULL HEAP***************\n"); + // printf("free*********NULL HEAP***************\n"); free(lpMem); return TRUE; } @@ -99,6 +100,27 @@ BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) } +BOOL RegisterClassEx(const WNDCLASSEX *lpwcx) +{ + WindClassRecord.push_back(*lpwcx); + return TRUE; +} + +HANDLE 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 (HANDLE) pixbuf; +} + void OutputDebugString(char* str) { @@ -111,4 +133,4 @@ double GetTickCount(void) // if (clock_gettime(CLOCK_MONOTONIC, &now)) // return 0; return 10.2;//now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0; -}
\ No newline at end of file +} diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 062bc49..25d42bb 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -17,6 +17,10 @@ #define HEAP_ZERO_MEMORY 0x00000008 +/// Image loading flags +#define IMAGE_ICON 1 +#define LDMICRO_ICON "ldmicro.ico" + /// Typedefs //typedef int64_t __int64; typedef bool BOOL; @@ -31,6 +35,7 @@ typedef char CHAR; typedef CONST WCHAR *LPCWSTR; typedef CONST CHAR *LPCSTR; /// should be __nullterminated +typedef WORD ATOM; #ifdef UNICODE typedef LPCWSTR LPCTSTR; @@ -52,18 +57,18 @@ typedef void *LPVOID; typedef PVOID HFONT; typedef PVOID HMODULE; typedef PVOID HHOOK; -typedef PVOID HBRUSH; + typedef PVOID HFONT; typedef PVOID HANDLE; typedef HANDLE HINSTANCE; typedef HANDLE HDC; - -typedef GtkWidget* HWID; -typedef GtkWidget* HMENU; -typedef GtkWindow* HWND; -typedef GtkListStore* HLIST; -typedef GtkApplication* HAPP; - +typedef GtkWidget *HWID; +typedef GtkWidget *HMENU; +typedef GtkWindow *HWND; +typedef GtkListStore *HLIST; +typedef GtkApplication *HAPP; +typedef GtkTreeViewColumn *HTVC; +typedef GdkPixbuf *HICON; /// Check if system is x64 or x86 #if defined(__UNIX64) typedef uint64_t UINT_PTR; @@ -82,26 +87,32 @@ typedef UINT_PTR WPARAM; typedef LONG_PTR LPARAM; typedef LONG_PTR LRESULT; -/// Custom classes -class COLORREF : public GdkRGBA{ +/// Classes +typedef class tagColorReferance: public GdkRGBA{ public: - COLORREF() + tagColorReferance() { this->red = 0.0; this->green = 0.0; this->blue = 0.0; this->alpha = 1.0; } - COLORREF(int r, int g, int b) + + tagColorReferance(int r, int g, int b) { this->red = r/255.0; this->green = g/255.0; this->blue = b/255.0; this->alpha = 1.0; } -}; -/// Custom structures + GdkRGBA* getThis() + { + return this; + } +} COLORREF, *HBRUSH; + +/// Structures typedef struct HeapRecordChunckTag{ PVOID Chunck; SIZE_T dwSize; @@ -132,8 +143,25 @@ typedef struct tagNMHDR { UINT code; } NMHDR; +typedef struct tagWNDCLASSEX { + UINT cbSize; + UINT style; +// WNDPROC lpfnWndProc; + int cbClsExtra; + int cbWndExtra; + HINSTANCE hInstance; + HICON hIcon; +// HCURSOR hCursor; + HBRUSH hbrBackground; + LPCTSTR lpszMenuName; + LPCTSTR lpszClassName; + HICON hIconSm; +} WNDCLASSEX, *PWNDCLASSEX; + + /// Variables extern std::vector<HEAPRECORD> HeapRecord; +extern std::vector<WNDCLASSEX> WindClassRecord; /// Functions HANDLE HeapCreate( @@ -151,6 +179,17 @@ BOOL HeapFree( DWORD dwFlags, LPVOID lpMem); +BOOL RegisterClassEx(const WNDCLASSEX *lpwcx); + +HANDLE LoadImage( + HINSTANCE hinst, + LPCTSTR lpszName, + UINT uType, + int cxDesired, + int cyDesired, + UINT fuLoad +); + /// functions to be ported void OutputDebugString(char*); double GetTickCount(void); diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 1033f07..c20dec1 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -11,8 +11,8 @@ GtkAccelGroup* AccelGroup; GClosure* closure; /// ListStore -GtkWidget* view; -GtkTreeViewColumn* column; +HWID view; +HTVC column; /// Wraper function for gtk_window_has_toplevel_focus BOOL isFocus(HWID window) @@ -22,15 +22,28 @@ BOOL isFocus(HWID window) COLORREF RGB(int red, int green, int blue) { - COLORREF col; - col.red = red/255.0; - col.green = green/255.0; - col.blue = blue/255.0; - col.alpha = 1.0; + 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; } +HBRUSH GetStockObject(int fnObject) +{ + switch(fnObject) + { + case BLACK_BRUSH: + return new COLORREF(0, 0, 0); + break; + + default: + return new COLORREF(255, 255, 255); + } +} + int MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) { GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; @@ -156,7 +169,8 @@ BOOL GetSaveFileName(OPENFILENAME *ofn) return exitStatus; } -void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) { +void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) +{ switch (CheckEnabledItem){ case MF_ENABLED : gtk_widget_set_sensitive (MenuItem, true); @@ -167,7 +181,8 @@ void EnableMenuItem(HMENU MenuName, HMENU MenuItem, UINT CheckEnabledItem) { } } -void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check){ +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); @@ -176,4 +191,26 @@ void CheckMenuItem(HMENU MenuName, HMENU MenuItem, UINT Check){ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(MenuItem), false); break; } +} + +HWID CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, + DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, + HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) +{ + + auto WinClR_it = std::find_if(WindClassRecord.begin(), WindClassRecord.end(), [&lpClassName](WNDCLASSEX &Record) { return Record.lpszClassName == lpClassName; }); + + if (WinClR_it == WindClassRecord.end()) + return NULL; + + HWID window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), lpWindowName); + gtk_window_set_default_size (GTK_WINDOW(window), nWidth, nHeight); + gtk_window_resize (GTK_WINDOW(window), nWidth, nHeight); + gtk_window_move(GTK_WINDOW(window), x, y); + gtk_widget_override_background_color(GTK_WIDGET(window), GTK_STATE_FLAG_NORMAL, WinClR_it->hbrBackground->getThis()); + gtk_window_set_default_icon(WinClR_it->hIcon); + gtk_window_set_icon(GTK_WINDOW(window), WinClR_it->hIcon); + + return window; }
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index ff56863..4ddf164 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -10,6 +10,8 @@ #include <stdlib.h> #include "linuxLD.h" +// 4000 ICON "ldmicro.ico" + /// version control #define LDMicro_VERSION_MAJOR 1 #define LDMicro_VERSION_MINOR 0 @@ -36,6 +38,9 @@ #define OFN_HIDEREADONLY 0x00000200L #define OFN_OVERWRITEPROMPT 0x00000400L +/// window brushes +#define BLACK_BRUSH 0x00000401L + /// EnableMenuItem variables extern const UINT MF_ENABLED; extern const UINT MF_GRAYED; @@ -48,7 +53,7 @@ extern GClosure* closure; /// ListStore -extern GtkWidget* view; +extern GtkWidget *view; extern GtkTreeViewColumn *column; /// data types @@ -70,5 +75,21 @@ int MessageBox(HWID, char*, char*, UINT); BOOL GetSaveFileName(OPENFILENAME* ); void EnableMenuItem(HMENU, HMENU, UINT); void CheckMenuItem(HMENU, HMENU, UINT); +HBRUSH GetStockObject(int fnObject); + +HWID CreateWindowEx( + DWORD dwExStyle, + LPCTSTR lpClassName, + LPCTSTR lpWindowName, + DWORD dwStyle, + int x, + int y, + int nWidth, + int nHeight, + HWND hWndParent, + HMENU hMenu, + HINSTANCE hInstance, + LPVOID lpParam +); #endif
\ No newline at end of file |