diff options
Diffstat (limited to 'ldmicro')
-rw-r--r-- | ldmicro/includes/ldmicro.h | 5 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 13 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 9 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 305 |
4 files changed, 68 insertions, 264 deletions
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index caa154d..01b0160 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -525,7 +525,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); @@ -542,10 +542,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 e803bba..955b23b 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -1094,6 +1094,13 @@ int main(int argc, char** argv) exit(0); } + 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); + // /// ~~~ // Instance = hInstance; /// parent window @@ -1175,6 +1182,6 @@ int main(int argc, char** argv) // } // FreezeWindowPos(MainWindow); // FreezeDWORD(IoListHeight); - - return 0; -} + + return status; +}
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index e204c63..062bc49 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -58,10 +58,11 @@ typedef PVOID HANDLE; typedef HANDLE HINSTANCE; typedef HANDLE HDC; -typedef GtkWidget *HWID; -typedef GtkWidget *HMENU; -typedef GtkWindow *HWND; -typedef GtkApplication *HAPP; +typedef GtkWidget* HWID; +typedef GtkWidget* HMENU; +typedef GtkWindow* HWND; +typedef GtkListStore* HLIST; +typedef GtkApplication* HAPP; /// Check if system is x64 or x86 #if defined(__UNIX64) diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 06143ad..da454a9 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -120,7 +120,7 @@ BOOL NeedHoriz; // 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; @@ -332,62 +332,55 @@ void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled) //----------------------------------------------------------------------------- HMENU MakeMainWindowMenus(void) { - // 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 - // HWID SettingsLabel; // Settings menu label - // 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 - // HMENU SimulateMenuSeparator; // Simulate menu separator - - // int i; - // // Creating a box for desired orientation - // MenuBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - - // // Create new menu bar to hold menu and add it to window - // TopMenu = gtk_menu_bar_new(); - - // // Creating various menus - // FileMenu = gtk_menu_new(); - // EditMenu = gtk_menu_new(); - // settings = gtk_menu_new(); - // ProcessorMenu = gtk_menu_new(); - // InstructionMenu = gtk_menu_new(); - // SimulateMenu = gtk_menu_new(); - // compile = gtk_menu_new(); - // help = gtk_menu_new(); - - // // Creating labels for each menu - // FileLabel = gtk_menu_item_new_with_label("File"); - // EditLabel = gtk_menu_item_new_with_label("Edit"); - // SettingsLabel = gtk_menu_item_new_with_label("Settings"); - // InstructionLabel = gtk_menu_item_new_with_label("Instructions"); - // SimulateLabel = gtk_menu_item_new_with_label("Simulate"); - // CompileLabel = gtk_menu_item_new_with_label("Compile"); - // HelpLabel = gtk_menu_item_new_with_label("Help"); - - // // Creating labels for File Menu - // MNU_NEW = gtk_menu_item_new_with_label("New"); - // MNU_OPEN = gtk_menu_item_new_with_label("Open"); - // MNU_SAVE = gtk_menu_item_new_with_label("Save"); - // MNU_SAVE_AS = gtk_menu_item_new_with_label("Save As"); - // MNU_EXPORT = gtk_menu_item_new_with_label("Export As Text"); - // MNU_EXIT = gtk_menu_item_new_with_label("Exit"); + 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 + HWID SettingsLabel; // Settings menu label + HWID CompileLabel; // Compile menu label + HWID HelpLabel; // Help menu label + HWID SimulateLabel; // Simulate menu label + HMENU ProcessorMenuItems; // Processor menu items + HMENU FileMenuSeparator; // File menu separator + HMENU EditMenuSeparator; // Edit menu separator + HMENU InstructionMenuSeparator; // Instruction menu separator + HMENU SimulateMenuSeparator; // Simulate menu separator + + int i; + // Creating a box for desired orientation + MenuBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + // Create new menu bar to hold menu and add it to window + TopMenu = gtk_menu_bar_new(); + + // Creating various menus + FileMenu = gtk_menu_new(); + EditMenu = gtk_menu_new(); + settings = gtk_menu_new(); + ProcessorMenu = gtk_menu_new(); + InstructionMenu = gtk_menu_new(); + SimulateMenu = gtk_menu_new(); + compile = gtk_menu_new(); + help = gtk_menu_new(); + + // Creating labels for each menu + FileLabel = gtk_menu_item_new_with_label("File"); + EditLabel = gtk_menu_item_new_with_label("Edit"); + SettingsLabel = gtk_menu_item_new_with_label("Settings"); + InstructionLabel = gtk_menu_item_new_with_label("Instructions"); + SimulateLabel = gtk_menu_item_new_with_label("Simulate"); + CompileLabel = gtk_menu_item_new_with_label("Compile"); + HelpLabel = gtk_menu_item_new_with_label("Help"); + + // Creating labels for File Menu + MNU_NEW = gtk_menu_item_new_with_label("New"); + MNU_OPEN = gtk_menu_item_new_with_label("Open"); + MNU_SAVE = gtk_menu_item_new_with_label("Save"); + MNU_SAVE_AS = gtk_menu_item_new_with_label("Save As"); + 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 @@ -633,104 +626,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 @@ -738,72 +633,6 @@ 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); - // } } //----------------------------------------------------------------------------- @@ -833,40 +662,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. //----------------------------------------------------------------------------- |