From 51184db35fe7c9b1f81b50473cb46f4b017088f9 Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Wed, 6 Jun 2018 16:26:02 +0530 Subject: Updated ListStore --- LDMicro-linux-Workspace.code-workspace | 15 ++ ldmicro/includes/ldmicro.h | 5 +- ldmicro/ldmicro.cpp | 250 +++++++++++++++++---------------- ldmicro/lib/linuxUI/linuxLD.h | 1 + ldmicro/lib/linuxUI/linuxUI.cpp | 3 - ldmicro/maincontrols.cpp | 208 +-------------------------- 6 files changed, 153 insertions(+), 329 deletions(-) create mode 100644 LDMicro-linux-Workspace.code-workspace diff --git a/LDMicro-linux-Workspace.code-workspace b/LDMicro-linux-Workspace.code-workspace new file mode 100644 index 0000000..df7de52 --- /dev/null +++ b/LDMicro-linux-Workspace.code-workspace @@ -0,0 +1,15 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "/home/rohit/Rohit/Personal/Internships/Fossee/LDMicro-linux-1" + } + ], + "settings": { + "files.associations": { + "hash_map": "cpp" + } + } +} \ No newline at end of file diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index e434b82..0f165bc 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -526,7 +526,7 @@ extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS]; // heap used for all the program storage is not yet corrupt, and oops() if // it is void CheckHeap(char *file, int line); -#define ok() CheckHeap(__FILE__, __LINE__) +#define ok() CheckHeap(__FILE__, __LINE__)*/ // maincontrols.cpp void MakeMainWindowControls(void); @@ -543,10 +543,11 @@ void UpdateMainWindowTitleBar(void); extern int ScrollWidth; extern int ScrollHeight; extern BOOL NeedHoriz; -extern HWND IoList; +extern HLIST IoList; extern int IoListTop; extern int IoListHeight; +/* // draw.cpp int ProgCountWidestRow(void); int CountHeightOfElement(int which, void *elem); diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 8add732..19f825c 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -1048,126 +1048,140 @@ static BOOL MakeWindowClass() return RegisterClassEx(&wc); } -//----------------------------------------------------------------------------- -// Entry point into the program. -//----------------------------------------------------------------------------- -int main(int argc, char** argv) +int main (int argc, char *argv[]) { - // Check if we're running in non-interactive mode; in that case we should - // load the file, compile, and exit. - if(argc >= 2) { - RunningInBatchMode = TRUE; + GtkApplication *app; + int status; + + app = gtk_application_new ("org.gtk.new", G_APPLICATION_FLAGS_NONE); + g_signal_connect (app, "activate", G_CALLBACK (Activate_App), NULL); + status = g_application_run (G_APPLICATION (app), argc, argv); - char *err = - "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; + g_object_unref (app); - char *source = lpCmdLine + 2; - while(isspace(*source)) { - source++; - } - if(*source == '\0') { Error(err); exit(-1); } - char *dest = source; - while(!isspace(*dest) && *dest) { - dest++; - } - if(*dest == '\0') { Error(err); exit(-1); } - *dest = '\0'; dest++; - while(isspace(*dest)) { - dest++; - } - if(*dest == '\0') { Error(err); exit(-1); } - if(!LoadProjectFromFile(source)) { - Error("Couldn't open '%s', running non-interactively.", source); - exit(-1); - } - strcpy(CurrentCompileFile, dest); - GenerateIoList(-1); - CompileProgram(FALSE); /// Requires an open dialog to get file name - exit(0); - } + return status; +} - 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. - - ShowWindow(MainWindow, SW_SHOW); - SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); +//----------------------------------------------------------------------------- +// Entry point into the program. +//----------------------------------------------------------------------------- +// int main(int argc, char** argv) +// { +// // Check if we're running in non-interactive mode; in that case we should +// // load the file, compile, and exit. +// if(argc >= 2) { +// RunningInBatchMode = TRUE; + +// char *err = +// "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; + +// char *source = lpCmdLine + 2; +// while(isspace(*source)) { +// source++; +// } +// if(*source == '\0') { Error(err); exit(-1); } +// char *dest = source; +// while(!isspace(*dest) && *dest) { +// dest++; +// } +// if(*dest == '\0') { Error(err); exit(-1); } +// *dest = '\0'; dest++; +// while(isspace(*dest)) { +// dest++; +// } +// if(*dest == '\0') { Error(err); exit(-1); } +// if(!LoadProjectFromFile(source)) { +// Error("Couldn't open '%s', running non-interactively.", source); +// exit(-1); +// } +// strcpy(CurrentCompileFile, dest); +// GenerateIoList(-1); +// 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. + +// ShowWindow(MainWindow, SW_SHOW); +// SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); - if(strlen(lpCmdLine) > 0) { - char line[MAX_PATH]; - if(*lpCmdLine == '"') { - strcpy(line, lpCmdLine+1); - } else { - strcpy(line, lpCmdLine); - } - if(strchr(line, '"')) *strchr(line, '"') = '\0'; - - char *s; - GetFullPathName(line, sizeof(CurrentSaveFile), CurrentSaveFile, &s); - if(!LoadProjectFromFile(CurrentSaveFile)) { - NewProgram(); - Error(_("Couldn't open '%s'."), CurrentSaveFile); - CurrentSaveFile[0] = '\0'; - } - UndoFlush(); - } - - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - UpdateMainWindowTitleBar(); - - MSG msg; - DWORD ret; - while(ret = GetMessage(&msg, NULL, 0, 0)) { - if(msg.hwnd == IoList && msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_TAB) { - SetFocus(MainWindow); - continue; - } - } - if(msg.message == WM_KEYDOWN && msg.wParam != VK_UP && - msg.wParam != VK_DOWN && msg.wParam != VK_RETURN && msg.wParam - != VK_SHIFT) - { - if(msg.hwnd == IoList) { - msg.hwnd = MainWindow; - SetFocus(MainWindow); - } - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - FreezeWindowPos(MainWindow); - FreezeDWORD(IoListHeight); - - return 0; -} +// if(strlen(lpCmdLine) > 0) { +// char line[MAX_PATH]; +// if(*lpCmdLine == '"') { +// strcpy(line, lpCmdLine+1); +// } else { +// strcpy(line, lpCmdLine); +// } +// if(strchr(line, '"')) *strchr(line, '"') = '\0'; + +// char *s; +// GetFullPathName(line, sizeof(CurrentSaveFile), CurrentSaveFile, &s); +// if(!LoadProjectFromFile(CurrentSaveFile)) { +// NewProgram(); +// Error(_("Couldn't open '%s'."), CurrentSaveFile); +// CurrentSaveFile[0] = '\0'; +// } +// UndoFlush(); +// } + +// GenerateIoListDontLoseSelection(); +// RefreshScrollbars(); +// UpdateMainWindowTitleBar(); + +// MSG msg; +// DWORD ret; +// while(ret = GetMessage(&msg, NULL, 0, 0)) { +// if(msg.hwnd == IoList && msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_TAB) { +// SetFocus(MainWindow); +// continue; +// } +// } +// if(msg.message == WM_KEYDOWN && msg.wParam != VK_UP && +// msg.wParam != VK_DOWN && msg.wParam != VK_RETURN && msg.wParam +// != VK_SHIFT) +// { +// if(msg.hwnd == IoList) { +// msg.hwnd = MainWindow; +// SetFocus(MainWindow); +// } +// } +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } +// FreezeWindowPos(MainWindow); +// FreezeDWORD(IoListHeight); + +// return 0; +// } diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 0e4f682..c6079d5 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -45,6 +45,7 @@ typedef HANDLE HDC; typedef GtkWidget* HWID; typedef GtkWidget* HMENU; typedef GtkWindow* HWND; +typedef GtkListStore* HLIST; typedef GtkApplication* HAPP; /// Check if system is x64 or x86 diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index fea10b5..1cf45f4 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -1,8 +1,5 @@ #include "linuxUI.h" -/// Menu Variables - HWID window; - /// EnableMenuItem Variables const UINT MF_ENABLED = 0; const UINT MF_GRAYED = 1; diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 38c9b9f..b029322 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -30,7 +30,7 @@ #include "ldmicro.h" // Menu IDs - HMENU MNU_NEW; +HMENU MNU_NEW; HMENU MNU_OPEN; HMENU MNU_SAVE; HMENU MNU_SAVE_AS; @@ -122,7 +122,7 @@ static HMENU TopMenu; // listview used to maintain the list of I/O pins with symbolic names, plus // the internal relay too -HWND IoList; +HLIST IoList; static int IoListSelectionPoint; static BOOL IoListOutOfSync; int IoListHeight; @@ -346,14 +346,7 @@ HMENU MakeMainWindowMenus(void) HWID CompileLabel; // Compile menu label HWID HelpLabel; // Help menu label HWID SimulateLabel; // Simulate menu label - // HMENU file_menu_items; // File menu item - // HMENU edit_menu_items; // Edit menu item - // HMENU instruction_menu_items; // Instruction menu item - // HMENU settings_menu_items; // Settings menu item HMENU ProcessorMenuItems; // Processor menu items - // HMENU compile_menu_items; // Compile menu item - // HMENU help_menu_items; // Help menu item - // HMENU simulate_menu_items; // Simulate menu item HMENU FileMenuSeparator; // File menu separator HMENU EditMenuSeparator; // Edit menu separator HMENU InstructionMenuSeparator; // Instruction menu separator @@ -638,104 +631,6 @@ void RefreshScrollbars(void) InvalidateRect(MainWindow, NULL, FALSE); } -//----------------------------------------------------------------------------- -// Respond to a WM_VSCROLL sent to the main window, presumably by the one and -// only vertical scrollbar that it has as a child. -//----------------------------------------------------------------------------- -void VscrollProc(WPARAM wParam) -{ - int prevY = ScrollYOffset; - switch(LOWORD(wParam)) { - case SB_LINEUP: - case SB_PAGEUP: - if(ScrollYOffset > 0) { - ScrollYOffset--; - } - break; - - case SB_LINEDOWN: - case SB_PAGEDOWN: - if(ScrollYOffset < ScrollYOffsetMax) { - ScrollYOffset++; - } - break; - - case SB_TOP: - ScrollYOffset = 0; - break; - - case SB_BOTTOM: - ScrollYOffset = ScrollYOffsetMax; - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - ScrollYOffset = HIWORD(wParam); - break; - } - if(prevY != ScrollYOffset) { - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = ScrollYOffset; - SetScrollInfo(VertScrollBar, SB_CTL, &si, TRUE); - - InvalidateRect(MainWindow, NULL, FALSE); - } -} - -//----------------------------------------------------------------------------- -// Respond to a WM_HSCROLL sent to the main window, presumably by the one and -// only horizontal scrollbar that it has as a child. -//----------------------------------------------------------------------------- -void HscrollProc(WPARAM wParam) -{ - int prevX = ScrollXOffset; - switch(LOWORD(wParam)) { - case SB_LINEUP: - ScrollXOffset -= FONT_WIDTH; - break; - - case SB_PAGEUP: - ScrollXOffset -= POS_WIDTH*FONT_WIDTH; - break; - - case SB_LINEDOWN: - ScrollXOffset += FONT_WIDTH; - break; - - case SB_PAGEDOWN: - ScrollXOffset += POS_WIDTH*FONT_WIDTH; - break; - - case SB_TOP: - ScrollXOffset = 0; - break; - - case SB_BOTTOM: - ScrollXOffset = ScrollXOffsetMax; - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - ScrollXOffset = HIWORD(wParam); - break; - } - - if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; - if(ScrollXOffset < 0) ScrollXOffset = 0; - - if(prevX != ScrollXOffset) { - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = ScrollXOffset; - SetScrollInfo(HorizScrollBar, SB_CTL, &si, TRUE); - - InvalidateRect(MainWindow, NULL, FALSE); - } -} - //----------------------------------------------------------------------------- // Cause the status bar and the list view to be in sync with the actual data // structures describing the settings and the I/O configuration. Listview @@ -744,72 +639,7 @@ void HscrollProc(WPARAM wParam) //----------------------------------------------------------------------------- void RefreshControlsToSettings(void) { - int i; - - if(!IoListOutOfSync) { - IoListSelectionPoint = -1; - for(i = 0; i < Prog.io.count; i++) { - if(ListView_GetItemState(IoList, i, LVIS_SELECTED)) { - IoListSelectionPoint = i; - break; - } - } - } - - ListView_DeleteAllItems(IoList); - for(i = 0; i < Prog.io.count; i++) { - LVITEM lvi; - lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; - lvi.state = lvi.stateMask = 0; - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = LPSTR_TEXTCALLBACK; - lvi.lParam = i; - - if(ListView_InsertItem(IoList, &lvi) < 0) oops(); - } - if(IoListSelectionPoint >= 0) { - for(i = 0; i < Prog.io.count; i++) { - ListView_SetItemState(IoList, i, 0, LVIS_SELECTED); - } - ListView_SetItemState(IoList, IoListSelectionPoint, LVIS_SELECTED, - LVIS_SELECTED); - ListView_EnsureVisible(IoList, IoListSelectionPoint, FALSE); - } - IoListOutOfSync = FALSE; - if(Prog.mcu) { - SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)Prog.mcu->mcuName); - } else { - SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)_("no MCU selected")); - } - char buf[256]; - sprintf(buf, _("cycle time %.2f ms"), (double)Prog.cycleTime/1000.0); - SendMessage(StatusBar, SB_SETTEXT, 1, (LPARAM)buf); - - if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || - Prog.mcu->whichIsa == ISA_INTERPRETED)) - { - strcpy(buf, ""); - } else { - sprintf(buf, _("processor clock %.4f MHz"), - (double)Prog.mcuClock/1000000.0); - } - SendMessage(StatusBar, SB_SETTEXT, 2, (LPARAM)buf); - - for(i = 0; i < NUM_SUPPORTED_MCUS; i++) { - if(&SupportedMcus[i] == Prog.mcu) { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); - } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); - } - } - // `(no microcontroller)' setting - if(!Prog.mcu) { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); - } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); - } } //----------------------------------------------------------------------------- @@ -838,40 +668,6 @@ void GenerateIoListDontLoseSelection(void) RefreshControlsToSettings(); } -//----------------------------------------------------------------------------- -// Called when the main window has been resized. Adjust the size of the -// status bar and the listview to reflect the new window size. -//----------------------------------------------------------------------------- -void MainWindowResized(void) -{ - RECT main; - GetClientRect(MainWindow, &main); - - RECT status; - GetWindowRect(StatusBar, &status); - int statusHeight = status.bottom - status.top; - - MoveWindow(StatusBar, 0, main.bottom - statusHeight, main.right, - statusHeight, TRUE); - - // Make sure that the I/O list can't disappear entirely. - if(IoListHeight < 30) { - IoListHeight = 30; - } - IoListTop = main.bottom - IoListHeight - statusHeight; - // Make sure that we can't drag the top of the I/O list above the - // bottom of the menu bar, because it then becomes inaccessible. - if(IoListTop < 5) { - IoListHeight = main.bottom - statusHeight - 5; - IoListTop = main.bottom - IoListHeight - statusHeight; - } - MoveWindow(IoList, 0, IoListTop, main.right, IoListHeight, TRUE); - - RefreshScrollbars(); - - InvalidateRect(MainWindow, NULL, FALSE); -} - //----------------------------------------------------------------------------- // Toggle whether we are in simulation mode. A lot of options are only // available in one mode or the other. -- cgit From 01eab6425e46a235ec0345b3316bdba33581fdd4 Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Fri, 8 Jun 2018 10:31:50 +0530 Subject: Builds and runs from ldmicro.cpp. No further testing is required. --- ldmicro/CMakeLists.txt | 35 +- ldmicro/includes/ldmicro.h | 13 +- ldmicro/ldmicro.cpp | 253 +++++----- ldmicro/lib/linuxUI/linuxUI.h | 2 +- ldmicro/maincontrols.cpp | 1097 +++++++++++++++++++++-------------------- ldmicro/simulate.cpp | 14 +- 6 files changed, 735 insertions(+), 679 deletions(-) diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt index 8c568fa..90354c8 100644 --- a/ldmicro/CMakeLists.txt +++ b/ldmicro/CMakeLists.txt @@ -61,16 +61,16 @@ IF(UNIX) ## Dummy compile and install to test linuxUI ## to compile LDmicro uncomment the below 2 line2 set (COMPILE_CPP_SOURCES #naminglist.cpp - arduino.cpp - avr.cpp - pic16.cpp - interpreted.cpp - ansic.cpp - compilecommon.cpp - intcode.cpp - lang.cpp - miscutil.cpp - iolist.cpp + #arduino.cpp + #avr.cpp + #pic16.cpp + #interpreted.cpp + #ansic.cpp + #compilecommon.cpp + #intcode.cpp + #lang.cpp + #miscutil.cpp + #iolist.cpp #confdialog.cpp #lutdialog.cpp #resetdialog.cpp @@ -78,13 +78,13 @@ IF(UNIX) #coildialog.cpp #contactsdialog.cpp #commentdialog.cpp - #simulate.cpp - loadsave.cpp - undoredo.cpp - circuit.cpp - draw_outputdev.cpp + simulate.cpp + #loadsave.cpp + #undoredo.cpp + #circuit.cpp + #draw_outputdev.cpp #draw.cpp - schematic.cpp + #schematic.cpp #helpdialog.cpp maincontrols.cpp ldmicro.cpp) @@ -95,4 +95,7 @@ IF(UNIX) target_link_libraries (LDMicro FreezeLD) #add_executable (testMain testMain.cpp) #install (TARGETS testMain DESTINATION bin) + #target_link_libraries (testMain LinuxUI) + #target_link_libraries (testMain FreezeLD) + ENDIF(UNIX) diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index 01b0160..1484261 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -48,6 +48,8 @@ typedef signed long SDWORD; // Constants for the GUI. We have drop-down menus, a listview for the I/Os, // etc. +#define NUM_SUPPORTED_MCUS 16 + // Menu IDs extern HMENU MNU_NEW; extern HMENU MNU_OPEN; @@ -106,7 +108,8 @@ extern HMENU MNU_MAKE_RESET_ONLY; extern HMENU MNU_INSERT_PWL; extern HMENU MNU_MCU_SETTINGS; -extern HMENU MNU_PROCESSOR_0; +extern HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1]; +extern HMENU MNU_MICRO_CONTROLLER; extern HMENU MNU_SIMULATION_MODE; extern HMENU MNU_START_SIMULATION; @@ -499,8 +502,6 @@ typedef struct McuIoInfoTag { DWORD configurationWord; } McuIoInfo; -#define NUM_SUPPORTED_MCUS 16 - //----------------------------------------------- // Function prototypes @@ -525,7 +526,7 @@ extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS]; // heap used for all the program storage is not yet corrupt, and oops() if // it is void CheckHeap(char *file, int line); -#define ok() CheckHeap(__FILE__, __LINE__)*/ +#define ok() CheckHeap(__FILE__, __LINE__) // maincontrols.cpp void MakeMainWindowControls(void); @@ -727,6 +728,7 @@ extern BOOL DialogCancel; // lang.cpp char *_(char *in); +*/ // simulate.cpp void SimulateOneCycle(BOOL forceRefresh); @@ -742,6 +744,7 @@ SWORD GetAdcShadow(char *name); void DestroyUartSimulationWindow(void); void ShowUartSimulationWindow(void); extern BOOL InSimulationMode; +/* extern BOOL SimulateRedrawAfterNextCycle; // compilecommon.cpp @@ -770,6 +773,6 @@ void CompileAnsiC(char *outFile); // interpreted.c void CompileInterpreted(char *outFile); //Arduino.cpp -void CompileArduino(char *outFile); +void CompileArduino(char *outFile);*/ #endif diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 955b23b..e3d152e 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -139,64 +139,64 @@ PlcProgram Prog; // Compile the program to a hex file for the target micro. Get the output // file name if necessary, then call the micro-specific compile routines. //----------------------------------------------------------------------------- -static void CompileProgram(BOOL compileAs) -{ - if(compileAs || strlen(CurrentCompileFile)==0) { - OPENFILENAME ofn; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.parentWindow = NULL; - ofn.lpstrTitle = _("Compile To"); - if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { - ofn.lpstrFilter = C_PATTERN; - ofn.lpstrDefExt = "c"; - } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { - ofn.lpstrFilter = INTERPRETED_PATTERN; - ofn.lpstrDefExt = "int"; - } else { - ofn.lpstrFilter = HEX_PATTERN; - ofn.lpstrDefExt = "hex"; - } - ofn.lpstrFile = CurrentCompileFile; - ofn.nMaxFile = sizeof(CurrentCompileFile); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - if(!GetSaveFileName(&ofn)) - return; - - // hex output filename is stored in the .ld file - ProgramChangedNotSaved = TRUE; - } - - if(!GenerateIntermediateCode()) return; - - if(Prog.mcu == NULL) { - Error(_("Must choose a target microcontroller before compiling.")); - return; - } - - if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { - Error(_("UART function used but not supported for this micro.")); - return; - } +// static void CompileProgram(BOOL compileAs) +// { +// if(compileAs || strlen(CurrentCompileFile)==0) { +// OPENFILENAME ofn; + +// memset(&ofn, 0, sizeof(ofn)); +// ofn.lStructSize = sizeof(ofn); +// ofn.parentWindow = NULL; +// ofn.lpstrTitle = _("Compile To"); +// if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { +// ofn.lpstrFilter = C_PATTERN; +// ofn.lpstrDefExt = "c"; +// } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { +// ofn.lpstrFilter = INTERPRETED_PATTERN; +// ofn.lpstrDefExt = "int"; +// } else { +// ofn.lpstrFilter = HEX_PATTERN; +// ofn.lpstrDefExt = "hex"; +// } +// ofn.lpstrFile = CurrentCompileFile; +// ofn.nMaxFile = sizeof(CurrentCompileFile); +// ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + +// if(!GetSaveFileName(&ofn)) +// return; + +// // hex output filename is stored in the .ld file +// ProgramChangedNotSaved = TRUE; +// } + +// if(!GenerateIntermediateCode()) return; + +// if(Prog.mcu == NULL) { +// Error(_("Must choose a target microcontroller before compiling.")); +// return; +// } + +// if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { +// Error(_("UART function used but not supported for this micro.")); +// return; +// } - if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { - Error(_("PWM function used but not supported for this micro.")); - return; - } +// if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { +// Error(_("PWM function used but not supported for this micro.")); +// return; +// } - switch(Prog.mcu->whichIsa) { - case ISA_AVR: CompileAvr(CurrentCompileFile); break; - case ISA_PIC16: CompilePic16(CurrentCompileFile); break; - case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; - case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; - case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; - - default: oops(); - } -// IntDumpListing("t.pl"); -} +// switch(Prog.mcu->whichIsa) { +// case ISA_AVR: CompileAvr(CurrentCompileFile); break; +// case ISA_PIC16: CompilePic16(CurrentCompileFile); break; +// case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; +// case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; +// case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; + +// default: oops(); +// } +// // IntDumpListing("t.pl"); +// } //----------------------------------------------------------------------------- // If the program has been modified then give the user the option to save it @@ -1027,6 +1027,31 @@ static void CompileProgram(BOOL compileAs) // return RegisterClassEx(&wc); // } +void Activate_App (GtkApplication* app, gpointer user_data){ + MainWindow = gtk_application_window_new (app); + gtk_window_set_default_size (GTK_WINDOW (MainWindow), 600, 400); + + // Title bar + UpdateMainWindowTitleBar(); + + // Splitting the window + MakeMainWindowControls(); + + // Calling the Simulation functions + + StartSimulation(); + SetMenusEnabled(true, true, false, + true, false, false, false, + true, true, true); + // ToggleSimulationMode(); + // GenerateIoListDontLoseSelection(); + StopSimulation(); + + // Displaying the window + gtk_widget_show_all(MainWindow); + +} + //----------------------------------------------------------------------------- // Entry point into the program. //----------------------------------------------------------------------------- @@ -1035,64 +1060,64 @@ int main(int argc, char** argv) /// Check if we're running in non-interactive mode; in that case we should /// load the file, compile, and exit. - if(argc >= 2) { - RunningInBatchMode = TRUE; - - char *err = - "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; - - if (argc < 4) - { - printf("throwing error...\n"); - Error(err); - exit(-1); - } - - char *source = (char*)malloc(strlen(argv[2]) + strlen(argv[3]) + 2); - sprintf(source, "%s %s", argv[2], argv[3]); - - while(isspace(*source)) { - source++; - } - if(*source == '\0') - { - Error(err); - free(source); - exit(-1); - } - - char *dest = source; - while(!isspace(*dest) && *dest) { - dest++; - } - if(*dest == '\0') - { - Error(err); - free(source); - exit(-1); - } - *dest = '\0'; dest++; - while(isspace(*dest)) { - dest++; - } - - if(*dest == '\0') - { - Error(err); - free(source); - exit(-1); - } - - if(!LoadProjectFromFile(source)) { - Error("Couldn't open '%s', running non-interactively.\n", source); - free(source); - exit(-1); - } - strcpy(CurrentCompileFile, dest); - GenerateIoList(-1); - CompileProgram(FALSE); - exit(0); - } + // if(argc >= 2) { + // RunningInBatchMode = TRUE; + + // char *err = + // "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; + + // if (argc < 4) + // { + // printf("throwing error...\n"); + // Error(err); + // exit(-1); + // } + + // char *source = (char*)malloc(strlen(argv[2]) + strlen(argv[3]) + 2); + // sprintf(source, "%s %s", argv[2], argv[3]); + + // while(isspace(*source)) { + // source++; + // } + // if(*source == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + + // char *dest = source; + // while(!isspace(*dest) && *dest) { + // dest++; + // } + // if(*dest == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + // *dest = '\0'; dest++; + // while(isspace(*dest)) { + // dest++; + // } + + // if(*dest == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + + // if(!LoadProjectFromFile(source)) { + // Error("Couldn't open '%s', running non-interactively.\n", source); + // free(source); + // exit(-1); + // } + // strcpy(CurrentCompileFile, dest); + // GenerateIoList(-1); + // CompileProgram(FALSE); + // exit(0); + // } GtkApplication *app; int status; diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index c6bb1ac..5bdfc82 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -43,7 +43,7 @@ extern const UINT MF_UNCHECKED; /// ListStore extern GtkWidget* view; -extern GtkTreeViewColumn* column; +extern GtkTreeViewColumn *column; /// data types typedef struct OpenFileInfoData { diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index da454a9..3e92e52 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -23,11 +23,15 @@ // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- #include "linuxUI.h" +#include //#include //#include #include #include #include "ldmicro.h" +#include + +using namespace std; // Menu IDs HMENU MNU_NEW; @@ -87,7 +91,8 @@ HMENU MNU_MAKE_RESET_ONLY; HMENU MNU_INSERT_PWL; HMENU MNU_MCU_SETTINGS; -HMENU MNU_PROCESSOR_0; +HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1]; +HMENU MNU_MICRO_CONTROLLER; // Item for Microcontroller HMENU MNU_SIMULATION_MODE; HMENU MNU_START_SIMULATION; @@ -103,20 +108,23 @@ HMENU MNU_ABOUT; // scrollbars for the ladder logic area // static HWND HorizScrollBar; // static HWND VertScrollBar; -int ScrollWidth; -int ScrollHeight; -BOOL NeedHoriz; +// int ScrollWidth; +// int ScrollHeight; +// BOOL NeedHoriz; // status bar at the bottom of the screen, to display settings -// static HWND StatusBar; +static HMENU StatusBar; // have to get back to the menus to gray/ungray, check/uncheck things -// static HMENU FileMenu; -// static HMENU EditMenu; -// static HMENU InstructionMenu; -// static HMENU ProcessorMenu; -// static HMENU SimulateMenu; -// static HMENU TopMenu; +static HMENU FileMenu; +static HMENU EditMenu; +static HMENU InstructionMenu; +static HMENU ProcessorMenu; +static HMENU SimulateMenu; +static HMENU TopMenu; // Menu Bar +static HMENU settings; +static HMENU compile; +static HMENU help; // listview used to maintain the list of I/O pins with symbolic names, plus // the internal relay too @@ -125,216 +133,21 @@ static int IoListSelectionPoint; static BOOL IoListOutOfSync; int IoListHeight; int IoListTop; +GtkTreeIter* iter = new GtkTreeIter; +GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList); // whether the simulation is running in real time static BOOL RealTimeSimulationRunning; -//----------------------------------------------------------------------------- -// Create the standard Windows controls used in the main window: a Listview -// for the I/O list, and a status bar for settings. -//----------------------------------------------------------------------------- -void MakeMainWindowControls(void) -{ - // GtkWidget* PackBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - // GtkWidget* grid = gtk_grid_new(); - // GtkWidget* pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL); - // GtkListStore* IoList = gtk_list_store_new (5, - // G_TYPE_STRING, - // G_TYPE_STRING, - // G_TYPE_STRING, - // G_TYPE_STRING, - // G_TYPE_STRING); - // GtkWidget* view; - // GtkTreeViewColumn* column; - - // int typeWidth = 85; - // int pinWidth = 100; - // int portWidth = 90; - - // // Creating a list - // view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoList)); - // gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (IoList)); - - // column = gtk_tree_view_column_new_with_attributes("Name", - // gtk_cell_renderer_text_new(), - // "text", LV_IO_NAME, - // NULL); - // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - // gtk_tree_view_column_set_min_width (column, 250); - - // column = gtk_tree_view_column_new_with_attributes("Type", - // gtk_cell_renderer_spin_new(), - // "text", LV_IO_TYPE, - // NULL); - // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - // gtk_tree_view_column_set_min_width (column, typeWidth); - - // column = gtk_tree_view_column_new_with_attributes("State", - // gtk_cell_renderer_text_new(), - // "text", LV_IO_STATE, - // NULL); - // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - // gtk_tree_view_column_set_min_width (column, 100); - - // column = gtk_tree_view_column_new_with_attributes("Pin on Processor", - // gtk_cell_renderer_text_new(), - // "text", LV_IO_PIN, - // NULL); - // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - // gtk_tree_view_column_set_min_width (column, pinWidth); - - // column = gtk_tree_view_column_new_with_attributes("MCU Port", - // gtk_cell_renderer_text_new(), - // "text", LV_IO_PORT, - // NULL); - // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - // gtk_tree_view_column_set_min_width (column, portWidth); - - // // Appending Menus to grid - // gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1); - - // // Creating Scrolled Window - // GtkWidget* ScrollWindow = gtk_scrolled_window_new (NULL, NULL); - // gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow), - // GTK_POLICY_AUTOMATIC, - // GTK_POLICY_ALWAYS); - - // // Creating a pane to separate Scrolled Window and other widgets - // gtk_paned_add1 (GTK_PANED (pane), ScrollWindow); - // gtk_paned_set_position (GTK_PANED (pane), 0); - // gtk_widget_set_vexpand (ScrollWindow, TRUE); - // gtk_widget_set_hexpand (ScrollWindow, TRUE); - - // // Appending tree view to pane and pane to grid - // gtk_paned_add2 (GTK_PANED(pane), view); - // gtk_paned_set_position (GTK_PANED (pane), 250); - // gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); - - // // Creating Status Bar and attaching to grid - // StatusBar = gtk_statusbar_new(); - // gtk_statusbar_push (GTK_STATUSBAR (StatusBar), - // gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "Introduction"), - // "LDMicro Started"); - - // // Appneding Status Bar to box which is then added to Main Window - // gtk_box_pack_start(GTK_BOX(PackBox), grid, TRUE, TRUE, 0); - // gtk_box_pack_start(GTK_BOX(PackBox), StatusBar, FALSE, FALSE, 0); - // gtk_container_add(GTK_CONTAINER(MainWindow), PackBox); -} - -//----------------------------------------------------------------------------- -// Set up the title bar text for the main window; indicate whether we are in -// simulation or editing mode, and indicate the filename. -//----------------------------------------------------------------------------- -void UpdateMainWindowTitleBar(void) -{ -// char line[PATH_MAX+100]; -// if(InSimulationMode) { -// if(RealTimeSimulationRunning) { -// strcpy(line, "LDmicro - Simulation (Running)"); -// } else { -// strcpy(line, "LDmicro - Simulation (Stopped)"); -// } -// } else { -// strcpy(line, "LDmicro - Program Editor"); -// } -// if(strlen(CurrentSaveFile) > 0) { -// sprintf(line+strlen(line), " - %s", CurrentSaveFile); -// } else { -// strcat(line, " - (not yet saved)"); -// } - -// gtk_window_set_title (GTK_WINDOW (window), line); -} - -//----------------------------------------------------------------------------- -// Set the enabled state of the logic menu items to reflect where we are on -// the schematic (e.g. can't insert two coils in series). -//----------------------------------------------------------------------------- -void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, - BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther, - BOOL canPushDown, BOOL canPushUp, BOOL canInsertComment) -{ - // EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP, - // canPushUp ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN, - // canPushDown ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(EditMenu, MNU_DELETE_RUNG, - // (Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED); - - // EnableMenuItem(InstructionMenu, MNU_NEGATE, - // canNegate ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL, - // canNormal ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY, - // canResetOnly ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY, - // canSetOnly ? MF_ENABLED : MF_GRAYED); - - // EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT, - // canInsertComment ? MF_ENABLED : MF_GRAYED); - - // EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT, - // canDelete ? MF_ENABLED : MF_GRAYED); - - // int t; - // t = canInsertEnd ? MF_ENABLED : MF_GRAYED; - // EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t); - - // t = canInsertOther ? MF_ENABLED : MF_GRAYED; - // EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t); - // EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t); -} - -//----------------------------------------------------------------------------- -// Set the enabled state of the undo/redo menus. -//----------------------------------------------------------------------------- -void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled) -{ - // EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED); -} - //----------------------------------------------------------------------------- // Create the top-level menu bar for the main window. Mostly static, but we // create the "select processor" menu from the list in mcutable.h dynamically. //----------------------------------------------------------------------------- HMENU MakeMainWindowMenus(void) { - HMENU MenuBox; // Box for alignment - HMENU PackedMenuBox; // Stores the packed box - HMENU TopMenu; // Menu Bar + HMENU MenuBox; // Box for alignment + HMENU PackedMenuBox; // Stores the packed box + HMENU TopMenu; // Menu Bar HWID FileLabel; // File menu label HWID EditLabel; // Edit menu label HWID InstructionLabel; // Instruction menu label @@ -382,283 +195,412 @@ HMENU MakeMainWindowMenus(void) MNU_EXPORT = gtk_menu_item_new_with_label("Export As Text"); MNU_EXIT = gtk_menu_item_new_with_label("Exit"); - // // Appending menu items (labels) to File menu and adding separators - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS); - // FileMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT); - // FileMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT); - - // // Creating labels for Edit Menu - // MNU_UNDO = gtk_menu_item_new_with_label("Undo"); - // MNU_REDO = gtk_menu_item_new_with_label("Redo"); - // MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_label("Insert rung Before"); - // MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_label("Insert Rung After"); - // MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_label("Move Selected Rung Up"); - // MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_label("Move Selected Rung Down"); - // MNU_DELETE_ELEMENT = gtk_menu_item_new_with_label("Delete Selected Element"); - // MNU_DELETE_RUNG = gtk_menu_item_new_with_label("Delete Rung"); - - // // Appending menu items to Edit menu and adding separators - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO); - // EditMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN); - // EditMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT); - // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG); - - // // Creating labels for Settings Menu - // MNU_MCU_SETTINGS = gtk_menu_item_new_with_label ("MCU Parameters..."); - // MNU_PROCESSOR_0 = gtk_menu_item_new_with_label ("Microcontroller"); - - // // Appending menu items to Settings menu - // gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS); - // gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_PROCESSOR_0); - - // for (i = 0; i < NUM_SUPPORTED_MCUS; i++){ - // ProcessorMenuItems = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); - // gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); - // } - - // ProcessorMenuItems = gtk_check_menu_item_new_with_label ("(no microcontroller)"); - // gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_PROCESSOR_0), ProcessorMenu); - - // // Creating labels for Instruction Menu and adding separators - // MNU_INSERT_COMMENT = gtk_menu_item_new_with_label("Insert Comment"); - // MNU_INSERT_CONTACTS = gtk_menu_item_new_with_label("Insert Contacts"); - // MNU_INSERT_OSR = gtk_menu_item_new_with_label("Insert OSR (One Shot Rising)"); - // MNU_INSERT_OSF = gtk_menu_item_new_with_label("Insert OSF (One Shot Falling)"); - // MNU_INSERT_TON = gtk_menu_item_new_with_label("Insert TON (Delayed Turn On)"); - // MNU_INSERT_TOF = gtk_menu_item_new_with_label("Insert TOF (Delayed Turn Off)"); - // MNU_INSERT_RTO = gtk_menu_item_new_with_label("Insert RTO (Retentive Delayed Turn On)"); - // MNU_INSERT_CTU = gtk_menu_item_new_with_label("Insert CTU (Count Up)"); - // MNU_INSERT_CTD = gtk_menu_item_new_with_label("Insert CTD (Count Down)"); - // MNU_INSERT_CTC = gtk_menu_item_new_with_label("Insert CTC (Count Circular)"); - // MNU_INSERT_EQU = gtk_menu_item_new_with_label("Insert EQU (Compare for Equals)"); - // MNU_INSERT_NEQ = gtk_menu_item_new_with_label("Insert NEQ (Compare for Not Equals)"); - // MNU_INSERT_GRT = gtk_menu_item_new_with_label("Insert GRT (Compare for Greater Than)"); - // MNU_INSERT_GEQ = gtk_menu_item_new_with_label("Insert GEQ (Compare for Greater Than or Equal)"); - // MNU_INSERT_LES = gtk_menu_item_new_with_label("Insert LES (Compare for Less Than)"); - // MNU_INSERT_LEQ = gtk_menu_item_new_with_label("Insert LEQ (Compare for Less Than or Equal)"); - // MNU_INSERT_OPEN = gtk_menu_item_new_with_label("Insert Open Circuit"); - // MNU_INSERT_SHORT = gtk_menu_item_new_with_label("Insert Short Circuit"); - // MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_label("Insert Master Control Relay"); - // MNU_INSERT_COIL = gtk_menu_item_new_with_label("Insert Coil"); - // MNU_INSERT_RES = gtk_menu_item_new_with_label("Insert RES (Counter/RTO Reset)"); - // MNU_INSERT_MOV = gtk_menu_item_new_with_label("Insert MOV (Move)"); - // MNU_INSERT_ADD = gtk_menu_item_new_with_label("Insert ADD (16-bit Integer Ad)"); - // MNU_INSERT_SUB = gtk_menu_item_new_with_label("Insert SUB (16-bit Integer Subtract)"); - // MNU_INSERT_MUL = gtk_menu_item_new_with_label("Insert MUL (16-bit Integer Multiply)"); - // MNU_INSERT_DIV = gtk_menu_item_new_with_label("Insert DIV (16-bit Integer Division)"); - // MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_label("Insert Shift Register"); - // MNU_INSERT_LUT = gtk_menu_item_new_with_label("Insert Look-Up Table"); - // MNU_INSERT_PWL = gtk_menu_item_new_with_label("Insert Piecewise Linear"); - // MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_label("Insert Formatted String Over UART"); - // MNU_INSERT_UART_SEND = gtk_menu_item_new_with_label("Insert UART Send"); - // MNU_INSERT_UART_RECV = gtk_menu_item_new_with_label("Insert UART Receive"); - // MNU_INSERT_SET_PWM = gtk_menu_item_new_with_label("Insert Set PWM Output"); - // MNU_INSERT_READ_ADC = gtk_menu_item_new_with_label("Insert A/D Converter Read"); - // MNU_INSERT_PERSIST = gtk_menu_item_new_with_label("Insert Make Persistent"); - // MNU_MAKE_NORMAL = gtk_menu_item_new_with_label("Make Normal"); - // MNU_NEGATE = gtk_menu_item_new_with_label("Make Negated"); - // MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_label("Make Set-Only"); - // MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_label("Make Reset-Only"); - - // // Appending menu items to Instruction menu and adding separators - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST); - // InstructionMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY); - // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY); - - // // Creating labels for Simulation Menu - // MNU_COMPILE = gtk_menu_item_new_with_label("Compile"); - // MNU_COMPILE_AS = gtk_menu_item_new_with_label("Compile As..."); - - // // Appending menu items to Compile menu - // gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE); - // gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS); - - // // Creating labels for Simulation Menu - // MNU_MANUAL = gtk_menu_item_new_with_label("Manual..."); - // MNU_ABOUT = gtk_menu_item_new_with_label("About..."); - - // // Appending menu items to Help menu - // gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL); - // gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT); - - // // Creating labels for Simulation Menu - // MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_label("Simulation Mode"); - // MNU_START_SIMULATION = gtk_menu_item_new_with_label("Start Real-Time Simulation"); - // MNU_STOP_SIMULATION = gtk_menu_item_new_with_label("Halt Simulation"); - // MNU_SINGLE_CYCLE = gtk_menu_item_new_with_label("Single Cycle"); - - // // Appending menu items to Simulate menu and adding separators - // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE); - // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION); - // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION); - // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE); - // SimulateMenuSeparator = gtk_separator_menu_item_new(); - // gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator); - - // // Creating submenus for each menu - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile); - // gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help); - - // // Appending the menu item to the menu bar - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), EditLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SettingsLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), InstructionLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SimulateLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), CompileLabel); - // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), HelpLabel); - - // // Packing the menu bar into the box for alignment - // gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0); - - // return MenuBox; + // Appending menu items (labels) to File menu and adding separators + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS); + FileMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT); + FileMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT); + + // Creating labels for Edit Menu + MNU_UNDO = gtk_menu_item_new_with_label("Undo"); + MNU_REDO = gtk_menu_item_new_with_label("Redo"); + MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_label("Insert rung Before"); + MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_label("Insert Rung After"); + MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_label("Move Selected Rung Up"); + MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_label("Move Selected Rung Down"); + MNU_DELETE_ELEMENT = gtk_menu_item_new_with_label("Delete Selected Element"); + MNU_DELETE_RUNG = gtk_menu_item_new_with_label("Delete Rung"); + + // Appending menu items to Edit menu and adding separators + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO); + EditMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN); + EditMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG); + + // Creating labels for Settings Menu + MNU_MCU_SETTINGS = gtk_menu_item_new_with_label ("MCU Parameters..."); + MNU_MICRO_CONTROLLER = gtk_menu_item_new_with_label ("Microcontroller"); + + // Appending menu items to Settings menu + gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS); + gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MICRO_CONTROLLER); + + // Appending the microcontroller names to "Microcontroller" item + for (i = 0; i < NUM_SUPPORTED_MCUS; i++){ + MNU_PROCESSOR[i] = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); + gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[i]); + } + + MNU_PROCESSOR[NUM_SUPPORTED_MCUS] = gtk_check_menu_item_new_with_label ("(no microcontroller)"); + gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[NUM_SUPPORTED_MCUS]); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_MICRO_CONTROLLER), ProcessorMenu); + + // Creating labels for Instruction Menu and adding separators + MNU_INSERT_COMMENT = gtk_menu_item_new_with_label("Insert Comment"); + MNU_INSERT_CONTACTS = gtk_menu_item_new_with_label("Insert Contacts"); + MNU_INSERT_OSR = gtk_menu_item_new_with_label("Insert OSR (One Shot Rising)"); + MNU_INSERT_OSF = gtk_menu_item_new_with_label("Insert OSF (One Shot Falling)"); + MNU_INSERT_TON = gtk_menu_item_new_with_label("Insert TON (Delayed Turn On)"); + MNU_INSERT_TOF = gtk_menu_item_new_with_label("Insert TOF (Delayed Turn Off)"); + MNU_INSERT_RTO = gtk_menu_item_new_with_label("Insert RTO (Retentive Delayed Turn On)"); + MNU_INSERT_CTU = gtk_menu_item_new_with_label("Insert CTU (Count Up)"); + MNU_INSERT_CTD = gtk_menu_item_new_with_label("Insert CTD (Count Down)"); + MNU_INSERT_CTC = gtk_menu_item_new_with_label("Insert CTC (Count Circular)"); + MNU_INSERT_EQU = gtk_menu_item_new_with_label("Insert EQU (Compare for Equals)"); + MNU_INSERT_NEQ = gtk_menu_item_new_with_label("Insert NEQ (Compare for Not Equals)"); + MNU_INSERT_GRT = gtk_menu_item_new_with_label("Insert GRT (Compare for Greater Than)"); + MNU_INSERT_GEQ = gtk_menu_item_new_with_label("Insert GEQ (Compare for Greater Than or Equal)"); + MNU_INSERT_LES = gtk_menu_item_new_with_label("Insert LES (Compare for Less Than)"); + MNU_INSERT_LEQ = gtk_menu_item_new_with_label("Insert LEQ (Compare for Less Than or Equal)"); + MNU_INSERT_OPEN = gtk_menu_item_new_with_label("Insert Open Circuit"); + MNU_INSERT_SHORT = gtk_menu_item_new_with_label("Insert Short Circuit"); + MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_label("Insert Master Control Relay"); + MNU_INSERT_COIL = gtk_menu_item_new_with_label("Insert Coil"); + MNU_INSERT_RES = gtk_menu_item_new_with_label("Insert RES (Counter/RTO Reset)"); + MNU_INSERT_MOV = gtk_menu_item_new_with_label("Insert MOV (Move)"); + MNU_INSERT_ADD = gtk_menu_item_new_with_label("Insert ADD (16-bit Integer Ad)"); + MNU_INSERT_SUB = gtk_menu_item_new_with_label("Insert SUB (16-bit Integer Subtract)"); + MNU_INSERT_MUL = gtk_menu_item_new_with_label("Insert MUL (16-bit Integer Multiply)"); + MNU_INSERT_DIV = gtk_menu_item_new_with_label("Insert DIV (16-bit Integer Division)"); + MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_label("Insert Shift Register"); + MNU_INSERT_LUT = gtk_menu_item_new_with_label("Insert Look-Up Table"); + MNU_INSERT_PWL = gtk_menu_item_new_with_label("Insert Piecewise Linear"); + MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_label("Insert Formatted String Over UART"); + MNU_INSERT_UART_SEND = gtk_menu_item_new_with_label("Insert UART Send"); + MNU_INSERT_UART_RECV = gtk_menu_item_new_with_label("Insert UART Receive"); + MNU_INSERT_SET_PWM = gtk_menu_item_new_with_label("Insert Set PWM Output"); + MNU_INSERT_READ_ADC = gtk_menu_item_new_with_label("Insert A/D Converter Read"); + MNU_INSERT_PERSIST = gtk_menu_item_new_with_label("Insert Make Persistent"); + MNU_MAKE_NORMAL = gtk_menu_item_new_with_label("Make Normal"); + MNU_NEGATE = gtk_menu_item_new_with_label("Make Negated"); + MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_label("Make Set-Only"); + MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_label("Make Reset-Only"); + + // Appending menu items to Instruction menu and adding separators + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST); + InstructionMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY); + + // Creating labels for Simulation Menu + MNU_COMPILE = gtk_menu_item_new_with_label("Compile"); + MNU_COMPILE_AS = gtk_menu_item_new_with_label("Compile As..."); + + // Appending menu items to Compile menu + gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE); + gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS); + + // Creating labels for Simulation Menu + MNU_MANUAL = gtk_menu_item_new_with_label("Manual..."); + MNU_ABOUT = gtk_menu_item_new_with_label("About..."); + + // Appending menu items to Help menu + gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL); + gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT); + + // Creating labels for Simulation Menu + MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_label("Simulation Mode"); + MNU_START_SIMULATION = gtk_menu_item_new_with_label("Start Real-Time Simulation"); + MNU_STOP_SIMULATION = gtk_menu_item_new_with_label("Halt Simulation"); + MNU_SINGLE_CYCLE = gtk_menu_item_new_with_label("Single Cycle"); + + // Appending menu items to Simulate menu and adding separators + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE); + SimulateMenuSeparator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator); + + // Creating submenus for each menu + gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help); + + // Appending the menu item to the menu bar + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), EditLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SettingsLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), InstructionLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SimulateLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), CompileLabel); + gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), HelpLabel); + + // Packing the menu bar into the box for alignment + gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0); + + return MenuBox; } //----------------------------------------------------------------------------- -// Adjust the size and visibility of the scrollbars as necessary, either due -// to a change in the size of the program or a change in the size of the -// window. +// Create the standard Windows controls used in the main window: a Listview +// for the I/O list, and a status bar for settings. //----------------------------------------------------------------------------- -void RefreshScrollbars(void) +void MakeMainWindowControls(void) { - // SCROLLINFO vert, horiz; - // SetUpScrollbars(&NeedHoriz, &horiz, &vert); - // SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE); - // SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE); - - // RECT main; - // GetClientRect(MainWindow, &main); - - // if(NeedHoriz) { - // MoveWindow(HorizScrollBar, 0, IoListTop - ScrollHeight - 2, - // main.right - ScrollWidth - 2, ScrollHeight, TRUE); - // ShowWindow(HorizScrollBar, SW_SHOW); - // EnableWindow(HorizScrollBar, TRUE); - // } else { - // ShowWindow(HorizScrollBar, SW_HIDE); - // } - // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - // InvalidateRect(MainWindow, NULL, FALSE); + GtkWidget* PackBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + GtkWidget* grid = gtk_grid_new(); + GtkWidget* pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL); + + IoList = gtk_list_store_new (5, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + + int typeWidth = 85; + int pinWidth = 100; + int portWidth = 90; + + // Creating a list + view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoList)); + gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (IoList)); + + column = gtk_tree_view_column_new_with_attributes("Name", + gtk_cell_renderer_text_new(), + "text", LV_IO_NAME, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + gtk_tree_view_column_set_min_width (column, 250); + + column = gtk_tree_view_column_new_with_attributes("Type", + gtk_cell_renderer_spin_new(), + "text", LV_IO_TYPE, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + gtk_tree_view_column_set_min_width (column, typeWidth); + + column = gtk_tree_view_column_new_with_attributes("State", + gtk_cell_renderer_text_new(), + "text", LV_IO_STATE, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + gtk_tree_view_column_set_min_width (column, 100); + + column = gtk_tree_view_column_new_with_attributes("Pin on Processor", + gtk_cell_renderer_text_new(), + "text", LV_IO_PIN, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + gtk_tree_view_column_set_min_width (column, pinWidth); + + column = gtk_tree_view_column_new_with_attributes("MCU Port", + gtk_cell_renderer_text_new(), + "text", LV_IO_PORT, + NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + gtk_tree_view_column_set_min_width (column, portWidth); + + // Appending Menus to grid + gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1); + + // Creating Scrolled Window + GtkWidget* ScrollWindow = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_ALWAYS); + + // Creating a pane to separate Scrolled Window and other widgets + gtk_paned_add1 (GTK_PANED (pane), ScrollWindow); + gtk_paned_set_position (GTK_PANED (pane), 0); + gtk_widget_set_vexpand (ScrollWindow, TRUE); + gtk_widget_set_hexpand (ScrollWindow, TRUE); + + // Appending tree view to pane and pane to grid + gtk_paned_add2 (GTK_PANED(pane), view); + gtk_paned_set_position (GTK_PANED (pane), 250); + gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); + + // Creating Status Bar and attaching to grid + StatusBar = gtk_statusbar_new(); + gtk_statusbar_push (GTK_STATUSBAR (StatusBar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "Introduction"), + "LDMicro Started"); + + // Appneding Status Bar to box which is then added to Main Window + gtk_box_pack_start(GTK_BOX(PackBox), grid, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(PackBox), StatusBar, FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(MainWindow), PackBox); } //----------------------------------------------------------------------------- -// Cause the status bar and the list view to be in sync with the actual data -// structures describing the settings and the I/O configuration. Listview -// does callbacks to get the strings it displays, so it just needs to know -// how many elements to populate. +// Set up the title bar text for the main window; indicate whether we are in +// simulation or editing mode, and indicate the filename. //----------------------------------------------------------------------------- -void RefreshControlsToSettings(void) +void UpdateMainWindowTitleBar(void) { + char line[PATH_MAX+100]; + if(InSimulationMode) { + if(RealTimeSimulationRunning) { + strcpy(line, "LDmicro - Simulation (Running)"); + } else { + strcpy(line, "LDmicro - Simulation (Stopped)"); + } + } else { + strcpy(line, "LDmicro - Program Editor"); + } + if(strlen(CurrentSaveFile) > 0) { + sprintf(line+strlen(line), " - %s", CurrentSaveFile); + } else { + strcat(line, " - (not yet saved)"); + } + + gtk_window_set_title (GTK_WINDOW (MainWindow), line); } //----------------------------------------------------------------------------- -// Regenerate the I/O list, keeping the selection in the same place if -// possible. +// Set the enabled state of the logic menu items to reflect where we are on +// the schematic (e.g. can't insert two coils in series). //----------------------------------------------------------------------------- -void GenerateIoListDontLoseSelection(void) +void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, + BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther, + BOOL canPushDown, BOOL canPushUp, BOOL canInsertComment) { - // int i; - // GtkTreeIter* iter; - // GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList); - // gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), - // GTK_SELECTION_SINGLE); - // IoListSelectionPoint = -1; - // for(i = 0; i < Prog.io.count; i++) { - // if(gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), - // IoListPtr, iter)) { - // IoListSelectionPoint = i; - // break; - // } - // } - // IoListSelectionPoint = GenerateIoList(IoListSelectionPoint); - // // can't just update the listview index; if I/O has been added then the - // // new selection point might be out of range till we refill it - // IoListOutOfSync = TRUE; - // RefreshControlsToSettings(); + EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP, + canPushUp ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN, + canPushDown ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(EditMenu, MNU_DELETE_RUNG, + (Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED); + + EnableMenuItem(InstructionMenu, MNU_NEGATE, + canNegate ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL, + canNormal ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY, + canResetOnly ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY, + canSetOnly ? MF_ENABLED : MF_GRAYED); + + EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT, + canInsertComment ? MF_ENABLED : MF_GRAYED); + + EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT, + canDelete ? MF_ENABLED : MF_GRAYED); + + int t; + t = canInsertEnd ? MF_ENABLED : MF_GRAYED; + EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t); + + t = canInsertOther ? MF_ENABLED : MF_GRAYED; + EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t); + EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t); +} + +//----------------------------------------------------------------------------- +// Set the enabled state of the undo/redo menus. +//----------------------------------------------------------------------------- +void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled) +{ + // EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED); } //----------------------------------------------------------------------------- @@ -667,75 +609,156 @@ void GenerateIoListDontLoseSelection(void) //----------------------------------------------------------------------------- void ToggleSimulationMode(void) { - // InSimulationMode = !InSimulationMode; - - // if(InSimulationMode) { - // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - // EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED); - - // EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED); - // EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED); - // EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED); - // EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED); - // EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED); - - // EnableMenuItem(TopMenu, 1, MF_GRAYED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 2, MF_GRAYED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 3, MF_GRAYED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 5, MF_GRAYED | MF_BYPOSITION); + InSimulationMode = !InSimulationMode; + if(InSimulationMode) { + EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); + EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED); + + EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED); + EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED); + EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED); + EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED); + EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED); + + EnableMenuItem(TopMenu, EditMenu, MF_GRAYED); + EnableMenuItem(TopMenu, settings, MF_GRAYED); + EnableMenuItem(TopMenu, InstructionMenu, MF_GRAYED); + EnableMenuItem(TopMenu, compile, MF_GRAYED); + + CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED); + + // ClearSimulationData(); // simulation.cpp, ldmicro.h + // Recheck InSimulationMode, because there could have been a compile + // error, which would have kicked us out of simulation mode. + // if(UartFunctionUsed() && InSimulationMode) { + // ShowUartSimulationWindow(); // simulate.cpp + // } + } + else { + RealTimeSimulationRunning = FALSE; + // KillTimer(MainWindow, TIMER_SIMULATE); + + EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); + EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); + EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED); + + EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED); + EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED); + EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED); + EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED); + EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED); + + EnableMenuItem(TopMenu, EditMenu, MF_ENABLED); + EnableMenuItem(TopMenu, settings, MF_ENABLED); + EnableMenuItem(TopMenu, InstructionMenu, MF_ENABLED); + EnableMenuItem(TopMenu, compile, MF_ENABLED); + + CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED); + + // if(UartFunctionUsed()) { + // DestroyUartSimulationWindow(); + // } + } + + UpdateMainWindowTitleBar(); +} + +//----------------------------------------------------------------------------- +// Cause the status bar and the list view to be in sync with the actual data +// structures describing the settings and the I/O configuration. Listview +// does callbacks to get the strings it displays, so it just needs to know +// how many elements to populate. +//----------------------------------------------------------------------------- +void RefreshControlsToSettings(void) +{ + int i; + gtk_tree_model_get_iter_first (GTK_TREE_MODEL(IoList), iter); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + GTK_SELECTION_SINGLE); + if(!IoListOutOfSync) { + IoListSelectionPoint = -1; + for(i = 0; i < Prog.io.count; i++) { + gtk_tree_model_iter_next (GTK_TREE_MODEL(IoList), iter); + if(gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + IoListPtr, iter)) { + IoListSelectionPoint = i; + break; + } + } + } + gtk_list_store_clear (IoList); + IoListOutOfSync = FALSE; + + if(Prog.mcu) { + gtk_statusbar_push (GTK_STATUSBAR (StatusBar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "MCU Name"), + (gchar*)Prog.mcu->mcuName); + // SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)Prog.mcu->mcuName); + } + else { + // SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)_("no MCU selected")); + gtk_statusbar_push (GTK_STATUSBAR (StatusBar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "MCU Name"), + "no MCU selected"); + } + for(i = 0; i < NUM_SUPPORTED_MCUS; i++) { + if(&SupportedMcus[i] == Prog.mcu) { + CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_CHECKED); + } + else { + CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_UNCHECKED); + } + } + // `(no microcontroller)' setting + if (!Prog.mcu){ + CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_CHECKED); + } + else { + CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_UNCHECKED); + } +} + +//----------------------------------------------------------------------------- +// Regenerate the I/O list, keeping the selection in the same place if +// possible. +//----------------------------------------------------------------------------- +void GenerateIoListDontLoseSelection(void) +{ + int i; + gtk_tree_model_get_iter_first (GTK_TREE_MODEL(IoList), iter); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + GTK_SELECTION_SINGLE); + IoListSelectionPoint = -1; + for(i = 0; i < Prog.io.count; i++) { + gtk_tree_model_iter_next (GTK_TREE_MODEL (IoList), iter); + if(gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + IoListPtr, iter)) { + IoListSelectionPoint = i; + break; + } + } + // IoListSelectionPoint = GenerateIoList(IoListSelectionPoint); + + // can't just update the listview index; if I/O has been added then the + // new selection point might be out of range till we refill it - // CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED); - - // ClearSimulationData(); - // // Recheck InSimulationMode, because there could have been a compile - // // error, which would have kicked us out of simulation mode. - // if(UartFunctionUsed() && InSimulationMode) { - // ShowUartSimulationWindow(); - // } - // } else { - // RealTimeSimulationRunning = FALSE; - // KillTimer(MainWindow, TIMER_SIMULATE); - - // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); - // EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED); - - // EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED); - // EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED); - // EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED); - // EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED); - // EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED); - - // EnableMenuItem(TopMenu, 1, MF_ENABLED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 2, MF_ENABLED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 3, MF_ENABLED | MF_BYPOSITION); - // EnableMenuItem(TopMenu, 5, MF_ENABLED | MF_BYPOSITION); - - // CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED); - - // if(UartFunctionUsed()) { - // DestroyUartSimulationWindow(); - // } - // } - - // UpdateMainWindowTitleBar(); - - // DrawMenuBar(MainWindow); - // InvalidateRect(MainWindow, NULL, FALSE); - // ListView_RedrawItems(IoList, 0, Prog.io.count - 1); + IoListOutOfSync = TRUE; + RefreshControlsToSettings(); } + + //----------------------------------------------------------------------------- // Start real-time simulation. Have to update the controls grayed status // to reflect this. //----------------------------------------------------------------------------- void StartSimulation(void) { - // RealTimeSimulationRunning = TRUE; - // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED); + RealTimeSimulationRunning = TRUE; + EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); + EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED); // StartSimulationTimer(); - // UpdateMainWindowTitleBar(); + UpdateMainWindowTitleBar(); } //----------------------------------------------------------------------------- @@ -744,11 +767,11 @@ void StartSimulation(void) //----------------------------------------------------------------------------- void StopSimulation(void) { - // RealTimeSimulationRunning = FALSE; + RealTimeSimulationRunning = FALSE; - // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); + EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); + EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); // KillTimer(MainWindow, TIMER_SIMULATE); - // UpdateMainWindowTitleBar(); -} + UpdateMainWindowTitleBar(); +} \ No newline at end of file diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp index 57da046..cf23731 100644 --- a/ldmicro/simulate.cpp +++ b/ldmicro/simulate.cpp @@ -31,9 +31,9 @@ #include #include "ldmicro.h" -#include "simulate.h" +// #include "simulate.h" #include "intcode.h" -#include "freeze.h" +// #include "freeze.h" static struct { char name[MAX_NAME_LEN]; @@ -107,6 +107,7 @@ static char *MarkUsedVariable(char *name, DWORD flag); // Looks in the SingleBitItems list; if an item is not present then it is // FALSE by default. //----------------------------------------------------------------------------- +/* static BOOL SingleBitOn(char *name) { int i; @@ -130,10 +131,10 @@ static void SetSingleBit(char *name, BOOL state) if((name[0] == 'Y') && (SingleBitItems[i].powered != state)) { TranslateState(name, state); - /*char Debug[256]; - sprintf_s(Debug, "SetSingleBit: \tname: %s \t state: %d\n", - name, state); - OutputDebugString(Debug);*/ + // char Debug[256]; + // sprintf_s(Debug, "SetSingleBit: \tname: %s \t state: %d\n", + // name, state); + // OutputDebugString(Debug); } SingleBitItems[i].powered = state; return; @@ -999,3 +1000,4 @@ static void AppendToUartSimulationTextControl(BYTE b) SendMessage(UartSimulationTextControl, WM_SETTEXT, 0, (LPARAM)buf); SendMessage(UartSimulationTextControl, EM_LINESCROLL, 0, (LPARAM)INT_MAX); } +*/ \ No newline at end of file -- cgit From 8ff08be6a0a927cacfac2c8a860af741f1b9412d Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Fri, 8 Jun 2018 11:01:48 +0530 Subject: Removed iostream header and std namespace from maincontrols.cpp --- ldmicro/maincontrols.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 3e92e52..543ec53 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -29,9 +29,6 @@ #include #include #include "ldmicro.h" -#include - -using namespace std; // Menu IDs HMENU MNU_NEW; -- cgit From f3279da9e036419bbe70e946e31a8961ea331877 Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Fri, 8 Jun 2018 12:12:32 +0530 Subject: Set gtk_quit function and fixed window resizing bugs. --- ldmicro/includes/ldmicro.h | 8 +-- ldmicro/ldmicro.cpp | 124 ++++++++++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index 1484261..02f850d 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -547,7 +547,7 @@ extern HLIST IoList; extern int IoListTop; extern int IoListHeight; -/* + // draw.cpp int ProgCountWidestRow(void); int CountHeightOfElement(int which, void *elem); @@ -728,7 +728,7 @@ extern BOOL DialogCancel; // lang.cpp char *_(char *in); -*/ + // simulate.cpp void SimulateOneCycle(BOOL forceRefresh); @@ -744,7 +744,7 @@ SWORD GetAdcShadow(char *name); void DestroyUartSimulationWindow(void); void ShowUartSimulationWindow(void); extern BOOL InSimulationMode; -/* + extern BOOL SimulateRedrawAfterNextCycle; // compilecommon.cpp @@ -773,6 +773,6 @@ void CompileAnsiC(char *outFile); // interpreted.c void CompileInterpreted(char *outFile); //Arduino.cpp -void CompileArduino(char *outFile);*/ +void CompileArduino(char *outFile); #endif diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index ddc1f76..81ca49f 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -139,64 +139,64 @@ PlcProgram Prog; // Compile the program to a hex file for the target micro. Get the output // file name if necessary, then call the micro-specific compile routines. //----------------------------------------------------------------------------- -// static void CompileProgram(BOOL compileAs) -// { -// if(compileAs || strlen(CurrentCompileFile)==0) { -// OPENFILENAME ofn; - -// memset(&ofn, 0, sizeof(ofn)); -// ofn.lStructSize = sizeof(ofn); -// ofn.parentWindow = NULL; -// ofn.lpstrTitle = _("Compile To"); -// if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { -// ofn.lpstrFilter = C_PATTERN; -// ofn.lpstrDefExt = "c"; -// } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { -// ofn.lpstrFilter = INTERPRETED_PATTERN; -// ofn.lpstrDefExt = "int"; -// } else { -// ofn.lpstrFilter = HEX_PATTERN; -// ofn.lpstrDefExt = "hex"; -// } -// ofn.lpstrFile = CurrentCompileFile; -// ofn.nMaxFile = sizeof(CurrentCompileFile); -// ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; +static void CompileProgram(BOOL compileAs) +{ + if(compileAs || strlen(CurrentCompileFile)==0) { + OPENFILENAME ofn; + + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.parentWindow = NULL; + ofn.lpstrTitle = _("Compile To"); + if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { + ofn.lpstrFilter = C_PATTERN; + ofn.lpstrDefExt = "c"; + } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { + ofn.lpstrFilter = INTERPRETED_PATTERN; + ofn.lpstrDefExt = "int"; + } else { + ofn.lpstrFilter = HEX_PATTERN; + ofn.lpstrDefExt = "hex"; + } + ofn.lpstrFile = CurrentCompileFile; + ofn.nMaxFile = sizeof(CurrentCompileFile); + ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; -// if(!GetSaveFileName(&ofn)) -// return; + if(!GetSaveFileName(&ofn)) + return; -// // hex output filename is stored in the .ld file -// ProgramChangedNotSaved = TRUE; -// } + // hex output filename is stored in the .ld file + ProgramChangedNotSaved = TRUE; + } -// if(!GenerateIntermediateCode()) return; + if(!GenerateIntermediateCode()) return; -// if(Prog.mcu == NULL) { -// Error(_("Must choose a target microcontroller before compiling.")); -// return; -// } + if(Prog.mcu == NULL) { + Error(_("Must choose a target microcontroller before compiling.")); + return; + } -// if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { -// Error(_("UART function used but not supported for this micro.")); -// return; -// } + if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { + Error(_("UART function used but not supported for this micro.")); + return; + } -// if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { -// Error(_("PWM function used but not supported for this micro.")); -// return; -// } + if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { + Error(_("PWM function used but not supported for this micro.")); + return; + } -// switch(Prog.mcu->whichIsa) { -// case ISA_AVR: CompileAvr(CurrentCompileFile); break; -// case ISA_PIC16: CompilePic16(CurrentCompileFile); break; -// case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; -// case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; -// case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; - -// default: oops(); -// } -// // IntDumpListing("t.pl"); -// } + switch(Prog.mcu->whichIsa) { + case ISA_AVR: CompileAvr(CurrentCompileFile); break; + case ISA_PIC16: CompilePic16(CurrentCompileFile); break; + case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; + case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; + case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; + + default: oops(); + } + IntDumpListing("t.pl"); +} //----------------------------------------------------------------------------- // If the program has been modified then give the user the option to save it @@ -1026,7 +1026,13 @@ PlcProgram Prog; // return RegisterClassEx(&wc); // } +void LDMicro_close(HWND window) +{ + FreezeWindowPos(MainWindow); + FreezeDWORD(IoListHeight); + gtk_main_quit(); +} //----------------------------------------------------------------------------- // Entry point into the program. //----------------------------------------------------------------------------- @@ -1098,10 +1104,15 @@ int main(int argc, char** argv) MainWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(MainWindow), "LDMicro"); - gtk_widget_show(MainWindow); - + g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LDMicro_close), NULL); gtk_window_set_default_size (GTK_WINDOW (MainWindow), 600, 400); - + gtk_window_resize (GTK_WINDOW (MainWindow), 600, 400); + + ThawWindowPos(MainWindow); + ThawDWORD(IoListHeight); + + gtk_widget_show(MainWindow); + // Title bar UpdateMainWindowTitleBar(); @@ -1202,8 +1213,7 @@ int main(int argc, char** argv) // TranslateMessage(&msg); // DispatchMessage(&msg); // } - // FreezeWindowPos(MainWindow); - // FreezeDWORD(IoListHeight); + - return status; + return EXIT_SUCCESS; } \ No newline at end of file -- cgit From 615a572781721256ab3098f8916fac96c880f87e Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Mon, 11 Jun 2018 10:03:03 +0530 Subject: Drawing Area is resized on resizing Main Window. --- ldmicro/includes/ldmicro.h | 1 - ldmicro/ldmicro.cpp | 3 +-- ldmicro/maincontrols.cpp | 17 ++++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index 02f850d..8dd8127 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -547,7 +547,6 @@ extern HLIST IoList; extern int IoListTop; extern int IoListHeight; - // draw.cpp int ProgCountWidestRow(void); int CountHeightOfElement(int which, void *elem); diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 81ca49f..6bb39d2 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -1213,7 +1213,6 @@ int main(int argc, char** argv) // TranslateMessage(&msg); // DispatchMessage(&msg); // } - - + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 543ec53..330d5e1 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -122,6 +122,7 @@ static HMENU TopMenu; // Menu static HMENU settings; static HMENU compile; static HMENU help; +static HMENU ScrollWindow; // listview used to maintain the list of I/O pins with symbolic names, plus // the internal relay too @@ -468,7 +469,7 @@ void MakeMainWindowControls(void) gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1); // Creating Scrolled Window - GtkWidget* ScrollWindow = gtk_scrolled_window_new (NULL, NULL); + ScrollWindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); @@ -480,7 +481,7 @@ void MakeMainWindowControls(void) gtk_widget_set_hexpand (ScrollWindow, TRUE); // Appending tree view to pane and pane to grid - gtk_paned_add2 (GTK_PANED(pane), view); + gtk_paned_pack2 (GTK_PANED(pane), view, FALSE, FALSE); gtk_paned_set_position (GTK_PANED (pane), 250); gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); @@ -743,7 +744,17 @@ void GenerateIoListDontLoseSelection(void) RefreshControlsToSettings(); } - +//----------------------------------------------------------------------------- +// Called when the main window has been resized. Adjust the size of the +// status bar and the listview to reflect the new window size. +//----------------------------------------------------------------------------- +void MainWindowResized(void) +{ + // Make sure that the I/O list can't disappear entirely. + if(IoListHeight < 30) { + IoListHeight = 30; + } +} //----------------------------------------------------------------------------- // Start real-time simulation. Have to update the controls grayed status -- cgit