diff options
author | Rr42 | 2018-06-11 15:05:21 +0530 |
---|---|---|
committer | Rr42 | 2018-06-11 15:05:21 +0530 |
commit | 9be96591b989efd41fa0d8a55a600ad6bab78922 (patch) | |
tree | 0f89b4309814e3a688fa8b6ad42c5eb573496a03 /ldmicro/lib/linuxUI | |
parent | 1b313fc77603c7b4ce51487ec5f144f835a0a945 (diff) | |
download | LDMicroGtk-9be96591b989efd41fa0d8a55a600ad6bab78922.tar.gz LDMicroGtk-9be96591b989efd41fa0d8a55a600ad6bab78922.tar.bz2 LDMicroGtk-9be96591b989efd41fa0d8a55a600ad6bab78922.zip |
Added CreateWindowEx funftion from windows.h (Partial port)
Diffstat (limited to 'ldmicro/lib/linuxUI')
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 24 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 57 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 55 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 21 |
4 files changed, 138 insertions, 19 deletions
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index cd53da1..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) { @@ -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 831a7c5..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 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 3bebf6d..907cb35 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -7,8 +7,8 @@ const UINT MF_CHECKED = 2; const UINT MF_UNCHECKED = 3; /// ListStore -GtkWidget* view; -GtkTreeViewColumn* column; +HWID view; +HTVC column; /// Wraper function for gtk_window_has_toplevel_focus BOOL isFocus(HWID window) @@ -18,15 +18,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; @@ -152,7 +165,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); @@ -163,7 +177,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); @@ -172,4 +187,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 7cb4d55..4bd6e71 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; @@ -65,5 +70,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 |