diff options
author | Rr42 | 2018-05-30 16:57:42 +0530 |
---|---|---|
committer | Rr42 | 2018-05-30 16:57:42 +0530 |
commit | 8f1f63ff88e62cb47cad286481033275e8490650 (patch) | |
tree | 5e5711fb6434e39e0932076438b73b46f098d52b /ldmicro | |
parent | eb8f6932fe45f550bc2b77c1b3e578884ed60d91 (diff) | |
download | LDMicroGtk-8f1f63ff88e62cb47cad286481033275e8490650.tar.gz LDMicroGtk-8f1f63ff88e62cb47cad286481033275e8490650.tar.bz2 LDMicroGtk-8f1f63ff88e62cb47cad286481033275e8490650.zip |
ported GetSaveFileName function from windows.h
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/ldmicro.cpp | 2 | ||||
-rw-r--r-- | ldmicro/lib/freezeLD/freezeLD.cpp | 2 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 17 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 51 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 20 | ||||
-rw-r--r-- | ldmicro/miscutil.cpp | 5 |
6 files changed, 91 insertions, 6 deletions
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index ca86246..984ffbb 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -148,7 +148,7 @@ static void CompileProgram(BOOL compileAs) memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); - ofn.hInstance = Instance; + ofn.parentWindow = parentWindow; ofn.lpstrTitle = _("Compile To"); if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { ofn.lpstrFilter = C_PATTERN; diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp index 6a52575..0bbd33f 100644 --- a/ldmicro/lib/freezeLD/freezeLD.cpp +++ b/ldmicro/lib/freezeLD/freezeLD.cpp @@ -18,7 +18,7 @@ */ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) { - g_print("freezing"); + //g_print("freezing"); char* moveToKeyLocatin = (char *)malloc(strlen(subKey) + 35); if(!moveToKeyLocatin) return; diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index d2ce90f..c1b0829 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -9,13 +9,28 @@ #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; diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index ffaf023..74269d9 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -54,4 +54,53 @@ void MessageBox(HWID pWindow, char* message, char* title, UINT mFlags) gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - }
\ No newline at end of file + } + +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 f6105bc..920dcce 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -13,6 +13,7 @@ #define LDMicro_VERSION_MINOR 0 /// Flags +/// message box #define MB_OK 0x00000000L #define MB_OKCANCEL 0x00000001L #define MB_YESNO 0x00000004L @@ -22,9 +23,28 @@ #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 diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp index defa1fa..428e5f6 100644 --- a/ldmicro/miscutil.cpp +++ b/ldmicro/miscutil.cpp @@ -89,8 +89,9 @@ void Error(char *str, ...) va_start(f, str); vsprintf(buf, str, f); if(RunningInBatchMode) { - AttachConsoleDynamic(ATTACH_PARENT_PROCESS); - + /* Only required for windows + * AttachConsoleDynamic(ATTACH_PARENT_PROCESS); + */ // Indicate that it's an error, plus the output filename printf("compile error ('%s'): ", CurrentCompileFile); // The error message itself |