diff options
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/includes/ldmicro.h | 5 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 195 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 1 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 3 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 208 |
5 files changed, 142 insertions, 270 deletions
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 8785753..d11a7b2 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -1048,19 +1048,95 @@ 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); +<<<<<<< HEAD + return status; +} + +//----------------------------------------------------------------------------- +// 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); +======= char *source = lpCmdLine + 2; while(isspace(*source)) { source++; @@ -1122,53 +1198,54 @@ int main(int argc, char** argv) ShowWindow(MainWindow, SW_SHOW); SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); +>>>>>>> 42f0b6abf37b6afc278a218b8301b7d4f1f6b2cc - 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 349408f..3bebf6d 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 @@ -639,104 +632,6 @@ void RefreshScrollbars(void) } //----------------------------------------------------------------------------- -// 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 // does callbacks to get the strings it displays, so it just needs to know @@ -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); - } } //----------------------------------------------------------------------------- @@ -839,40 +669,6 @@ void GenerateIoListDontLoseSelection(void) } //----------------------------------------------------------------------------- -// 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. //----------------------------------------------------------------------------- |