diff options
author | NatsuDrag9 | 2018-05-31 09:50:49 +0530 |
---|---|---|
committer | GitHub | 2018-05-31 09:50:49 +0530 |
commit | 82da829c02377db4c160ef7da06deea992989809 (patch) | |
tree | 73fb60bcada20a58c3e2a1b3aa30b49a7f8c86d8 /ldmicro/lib/linuxUI | |
parent | fdc0cc1d6db8a4297610071ab8d124b5586792c9 (diff) | |
parent | 7ddc1d90221f8300c7717c0e5dd86e7bcc59e4a7 (diff) | |
download | LDMicroGtk-82da829c02377db4c160ef7da06deea992989809.tar.gz LDMicroGtk-82da829c02377db4c160ef7da06deea992989809.tar.bz2 LDMicroGtk-82da829c02377db4c160ef7da06deea992989809.zip |
Merge pull request #6 from Rr42/GUI_port
Gui port
Diffstat (limited to 'ldmicro/lib/linuxUI')
-rw-r--r-- | ldmicro/lib/linuxUI/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 2 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 26 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 88 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 31 |
5 files changed, 143 insertions, 6 deletions
diff --git a/ldmicro/lib/linuxUI/CMakeLists.txt b/ldmicro/lib/linuxUI/CMakeLists.txt index 16226dc..25ba6b2 100644 --- a/ldmicro/lib/linuxUI/CMakeLists.txt +++ b/ldmicro/lib/linuxUI/CMakeLists.txt @@ -1,3 +1,3 @@ project(LinuxUI) -add_library(LinuxUI linuxUI.cpp) +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..69c5f6e --- /dev/null +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -0,0 +1,2 @@ +#include "linuxUI.h" + diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 9aba23d..c1b0829 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -9,24 +9,38 @@ #define MAX_PATH PATH_MAX /// CALLBACK or __stdcall os defined empty #define CALLBACK - +#define CONST const /// typedefs //typedef int64_t __int64; typedef bool BOOL; typedef unsigned char BYTE; typedef unsigned int DWORD; typedef long LONG; +typedef wchar_t WCHAR; +typedef char CHAR; +typedef CONST WCHAR *LPCWSTR; +typedef CONST CHAR *LPCSTR; /// should be __nullterminated +#ifdef UNICODE + typedef LPCWSTR LPCTSTR; +#else + typedef LPCSTR LPCTSTR; +#endif + +#ifdef UNICODE + typedef LPWSTR LPTSTR; +#else + typedef LPSTR LPTSTR; +#endif /// all handles will hold a GtkWindow* type typedef void* PVOID; -typedef GtkWidget* HANDLE; +typedef PVOID HANDLE; typedef HANDLE HINSTANCE; -typedef HANDLE HWID; typedef HANDLE HDC; -typedef HANDLE HMENU; +typedef GtkWidget* HWID; +typedef GtkWidget* HMENU; typedef GtkWindow* HWND; - typedef GtkApplication* HAPP; /// Check if system is x64 or x86 @@ -58,4 +72,6 @@ class COLORREF : public GdkRGBA{ } }; +/// functions + #endif diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 13af88b..6dabd80 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -53,4 +53,92 @@ COLORREF RGB(int red, int green, int blue) col.alpha = 1.0; return col; +} + +void MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) + { + GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; + GtkMessageType mType; + GtkButtonsType mButtons; + + if (mFlags & MB_OK == MB_OK) + mButtons = GTK_BUTTONS_OK; + else if (mFlags & MB_OKCANCEL == MB_OKCANCEL) + mButtons = GTK_BUTTONS_OK_CANCEL; + else if (mFlags & MB_YESNO == MB_YESNO) + mButtons = GTK_BUTTONS_YES_NO; + else + mButtons = GTK_BUTTONS_CLOSE; + + 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, + mButtons, + message); + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog), + title); + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), message); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + +BOOL GetSaveFileName(OPENFILENAME ofn) +{ + GtkWidget *dialog; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; + + dialog = gtk_file_chooser_dialog_new ("Open File", + GTK_WINDOW(window), + action, + "_Cancel", + GTK_RESPONSE_CANCEL, + "_Open", + GTK_RESPONSE_ACCEPT, + NULL); + + GtkFileFilter *filter = gtk_file_filter_new (); + gtk_file_filter_add_pattern (filter, "*"); + gtk_file_filter_set_name (filter, "All files"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_add_pattern (filter, "*.c"); + gtk_file_filter_add_pattern (filter, "*.cpp"); + gtk_file_filter_set_name (filter, "C source files"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_add_pattern (filter, "*.h"); + gtk_file_filter_set_name (filter, "C hedder files"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_add_pattern (filter, "*.hex"); + gtk_file_filter_set_name (filter, "hex files"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_add_pattern (filter, "*.int"); + gtk_file_filter_set_name (filter, "int files"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter); + + BOOL exitStatus = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT; + if (exitStatus) + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gtk_widget_destroy (dialog); + + return exitStatus; }
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 3e49de0..920dcce 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -12,8 +12,39 @@ #define LDMicro_VERSION_MAJOR 1 #define LDMicro_VERSION_MINOR 0 +/// Flags +/// message box +#define MB_OK 0x00000000L +#define MB_OKCANCEL 0x00000001L +#define MB_YESNO 0x00000004L + +#define MB_ICONERROR 0x00000010L +#define MB_ICONQUESTION 0x00000020L +#define MB_ICONWARNING 0x00000030L +#define MB_ICONINFORMATION 0x00000040L + +/// open/save file +#define OFN_PATHMUSTEXIST 0x00000800 +#define OFN_HIDEREADONLY 0x00000004 +#define OFN_OVERWRITEPROMPT 0x00000002 + + +/// data types +typedef struct OpenFileInfoData { + DWORD lStructSize; + HWID parentWindow; + LPCTSTR lpstrFilter; + LPTSTR lpstrFile; + DWORD nMaxFile; + LPCTSTR lpstrTitle; + DWORD Flags; + LPCTSTR lpstrDefExt; +} OPENFILENAME; + /// functions BOOL isFocus(HWID); COLORREF RGB(int, int, int); +void MessageBox(HWID, char*, char*, UINT); +BOOL GetSaveFileName(HWID, char*); #endif
\ No newline at end of file |