diff options
-rw-r--r-- | ldmicro/includes/ldmicro.h | 8 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 71 | ||||
-rw-r--r-- | ldmicro/lib/freezeLD/freezeLD.cpp | 12 | ||||
-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 | 9 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 41 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 11 | ||||
-rw-r--r-- | ldmicro/miscutil.cpp | 10 |
9 files changed, 106 insertions, 60 deletions
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index 2c6f720..579d3a7 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -31,8 +31,8 @@ typedef signed long SDWORD; //----------------------------------------------- // `Configuration options.' -// The library that I use to do registry stuff. -#define FREEZE_SUBKEY "LDMicro" +// The library that I use to do registry stuff. decleared in freezeLD.h due to build issues +// #define FREEZE_SUBKEY "LDMicro" // Size of the font that we will use to draw the ladder diagrams, in pixels #define FONT_WIDTH 7 @@ -501,7 +501,7 @@ typedef struct McuIoInfoTag { #define NUM_SUPPORTED_MCUS 16 - +/* //----------------------------------------------- // Function prototypes @@ -777,5 +777,5 @@ void CompileAnsiC(char *outFile); void CompileInterpreted(char *outFile); //Arduino.cpp void CompileArduino(char *outFile); - +*/ #endif diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index cc0a525..ca86246 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -30,7 +30,7 @@ #include <stdlib.h> #include "ldmicro.h" -#include "freeze.h" +#include "freezeLD.h" #include "mcutable.h" #include "advanceddialog.h" @@ -1051,44 +1051,11 @@ static BOOL MakeWindowClass() //----------------------------------------------------------------------------- // Entry point into the program. //----------------------------------------------------------------------------- -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, INT nCmdShow) +int main(int argc, char** argv) { - Instance = hInstance; - - MainHeap = HeapCreate(0, 1024*64, 0); - - MakeWindowClass(); - MakeDialogBoxClass(); - MakeAdvancedDialogClass(); - MakeAdvancedWorkspaceClass(); - MakeComponentListClass(); - MakeSmplDialogClass(); - MakeNamingListClass(); - HMENU top = MakeMainWindowMenus(); - - MainWindow = CreateWindowEx(0, "LDmicro", "", - WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | - WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX, - 10, 10, 800, 600, NULL, top, Instance, NULL); - ThawWindowPos(MainWindow); - IoListHeight = 100; - ThawDWORD(IoListHeight); - - InitCommonControls(); - InitForDrawing(); - - MakeMainWindowControls(); - MainWindowResized(); - NewProgram(); - strcpy(CurrentSaveFile, ""); - // Check if we're running in non-interactive mode; in that case we should // load the file, compile, and exit. - while(isspace(*lpCmdLine)) { - lpCmdLine++; - } - if(memcmp(lpCmdLine, "/c", 2)==0) { + if(argc >= 2) { RunningInBatchMode = TRUE; char *err = @@ -1115,10 +1082,40 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, } strcpy(CurrentCompileFile, dest); GenerateIoList(-1); - CompileProgram(FALSE); + CompileProgram(FALSE); /// Requires an open dialog to get file name exit(0); } + Instance = hInstance; + + MainHeap = HeapCreate(0, 1024*64, 0); + + // MakeWindowClass(); + // MakeDialogBoxClass(); + // MakeAdvancedDialogClass(); + // MakeAdvancedWorkspaceClass(); + // MakeComponentListClass(); + // MakeSmplDialogClass(); + // MakeNamingListClass(); + HMENU top = MakeMainWindowMenus(); + + /// Make main window + // MainWindow = CreateWindowEx(0, "LDmicro", "", + // WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | + // WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX, + // 10, 10, 800, 600, NULL, top, Instance, NULL); + ThawWindowPos(MainWindow); + IoListHeight = 100; + ThawDWORD(IoListHeight); + + InitCommonControls(); + InitForDrawing(); + + MakeMainWindowControls(); + MainWindowResized(); + NewProgram(); + strcpy(CurrentSaveFile, ""); + // We are running interactively, or we would already have exited. We // can therefore show the window now, and otherwise set up the GUI. diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp index 5241af1..6a52575 100644 --- a/ldmicro/lib/freezeLD/freezeLD.cpp +++ b/ldmicro/lib/freezeLD/freezeLD.cpp @@ -36,7 +36,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Key newKey; int val; - g_print("get width"); + //g_print("get width"); sprintf(keyName, "%s_width", name); std::ofstream Register(keyName, std::ios::binary | std::ios::trunc); if (!Register.is_open()) @@ -47,7 +47,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Register.write((char*) &newKey, sizeof(newKey)); Register.close(); - g_print("get height"); + //g_print("get height"); sprintf(keyName, "%s_height", name); Register.open(keyName, std::ios::binary | std::ios::trunc); if (!Register.is_open()) @@ -58,7 +58,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Register.write((char*) &newKey, sizeof(newKey)); Register.close(); - g_print("get posX"); + //g_print("get posX"); sprintf(keyName, "%s_posX", name); Register.open(keyName, std::ios::binary | std::ios::trunc); if (!Register.is_open()) @@ -69,7 +69,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Register.write((char*) &newKey, sizeof(newKey)); Register.close(); - g_print("get posY"); + //g_print("get posY"); sprintf(keyName, "%s_posY", name); Register.open(keyName, std::ios::binary | std::ios::trunc); if (!Register.is_open()) @@ -80,7 +80,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Register.write((char*) &newKey, sizeof(newKey)); Register.close(); - g_print("get max"); + //g_print("get max"); sprintf(keyName, "%s_maximized", name); Register.open(keyName, std::ios::binary | std::ios::trunc); if (!Register.is_open()) @@ -91,7 +91,7 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) Register.close(); free(keyName); - g_print("freezed"); + //g_print("freezed"); } static void Clamp(LONG *v, LONG min, LONG max) 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..d2ce90f 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -19,14 +19,13 @@ typedef long LONG; /// 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 +57,6 @@ class COLORREF : public GdkRGBA{ } }; +/// functions + #endif diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 8237d7d..ffaf023 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -15,4 +15,43 @@ COLORREF RGB(int red, int green, int blue) col.alpha = 1.0; return col; -}
\ No newline at end of file +} + +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); + }
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 3e49de0..f6105bc 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -12,8 +12,19 @@ #define LDMicro_VERSION_MAJOR 1 #define LDMicro_VERSION_MINOR 0 +/// Flags +#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 + /// functions BOOL isFocus(HWID); COLORREF RGB(int, int, int); +void MessageBox(HWID, char*, char*, UINT); #endif
\ No newline at end of file diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp index 116d584..defa1fa 100644 --- a/ldmicro/miscutil.cpp +++ b/ldmicro/miscutil.cpp @@ -90,18 +90,14 @@ void Error(char *str, ...) vsprintf(buf, str, f); if(RunningInBatchMode) { AttachConsoleDynamic(ATTACH_PARENT_PROCESS); - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD written; // Indicate that it's an error, plus the output filename - char str[MAX_PATH+100]; - sprintf(str, "compile error ('%s'): ", CurrentCompileFile); - WriteFile(h, str, strlen(str), &written, NULL); + printf("compile error ('%s'): ", CurrentCompileFile); // The error message itself - WriteFile(h, buf, strlen(buf), &written, NULL); + printf(buf); // And an extra newline to be safe. strcpy(str, "\n"); - WriteFile(h, str, strlen(str), &written, NULL); + printf(str); } else { HWND h = GetForegroundWindow(); MessageBox(h, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR); |