summaryrefslogtreecommitdiff
path: root/ldmicro
diff options
context:
space:
mode:
authorRr422018-06-13 13:07:55 +0530
committerRr422018-06-13 13:07:55 +0530
commitb85091137742e69ccce0d4d27a2fffb696ec38fa (patch)
tree5747da138aa8153fe96bc47dd8cd12a390779edc /ldmicro
parentaa68900f045799ad72ff6edea71a5407ca421d34 (diff)
downloadLDMicroGtk-b85091137742e69ccce0d4d27a2fffb696ec38fa.tar.gz
LDMicroGtk-b85091137742e69ccce0d4d27a2fffb696ec38fa.tar.bz2
LDMicroGtk-b85091137742e69ccce0d4d27a2fffb696ec38fa.zip
Keyboard & mouse hooks, callbacks for events handled by MainWindowProc
Diffstat (limited to 'ldmicro')
-rw-r--r--ldmicro/ldmicro.cpp769
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.cpp6
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h2
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h15
-rw-r--r--ldmicro/maincontrols.cpp130
-rw-r--r--ldmicro/miscutil.cpp3
6 files changed, 556 insertions, 369 deletions
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 93da8e9..b1a4c0e 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -592,423 +592,490 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
// break;
// case WM_SETFOCUS:
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
// case WM_PAINT: {
- // PAINTSTRUCT ps;
- // Hdc = BeginPaint(hwnd, &ps);
-
- // // This draws the schematic.
- // PaintWindow();
-
- // RECT r;
- // // Fill around the scroll bars
- // if(NeedHoriz) {
- // r.top = IoListTop - ScrollHeight - 2;
- // r.bottom = IoListTop - 2;
- // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
- // }
- // GetClientRect(MainWindow, &r);
- // r.left = r.right - ScrollWidth - 2;
- // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
-
- // // Draw the splitter thing to grab to resize the I/O listview.
- // GetClientRect(MainWindow, &r);
- // r.top = IoListTop - 2;
- // r.bottom = IoListTop;
- // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
- // r.top = IoListTop - 2;
- // r.bottom = IoListTop - 1;
- // FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
- // r.top = IoListTop;
- // r.bottom = IoListTop + 1;
- // FillRect(Hdc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
-
- // EndPaint(hwnd, &ps);
- // return 1;
// }
// case WM_KEYDOWN: {
- // if(wParam == 'M') {
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // ToggleSimulationMode();
- // break;
- // }
- // } else if(wParam == VK_TAB) {
- // SetFocus(IoList);
- // BlinkCursor(0, 0, 0, 0);
- // break;
- // } else if(wParam == VK_F1) {
- // ShowHelpDialog(FALSE);
- // break;
+ // }
+
+ // case WM_LBUTTONDBLCLK: {
+ // }
+
+ // case WM_LBUTTONDOWN: {
+ // }
+ // case WM_MOUSEMOVE: {
+ // }
+ // case WM_MOUSEWHEEL: {
+ // }
+
+ // case WM_SIZE:
+
+ // case WM_NOTIFY: {
+ // NMHDR *h = (NMHDR *)lParam;
+ // if(h->hwndFrom == IoList) {
+ // IoListProc(h);
// }
+ // return 0;
+ // }
+ // case WM_VSCROLL:
- // if(InSimulationMode) {
- // switch(wParam) {
- // case ' ':
- // SimulateOneCycle(TRUE);
- // break;
-
- // case 'R':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
- // StartSimulation();
- // break;
-
- // case 'H':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
- // StopSimulation();
- // break;
-
- // case VK_DOWN:
- // if(ScrollYOffset < ScrollYOffsetMax)
- // ScrollYOffset++;
- // RefreshScrollbars();
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
-
- // case VK_UP:
- // if(ScrollYOffset > 0)
- // ScrollYOffset--;
- // RefreshScrollbars();
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
-
- // case VK_LEFT:
- // ScrollXOffset -= FONT_WIDTH;
- // if(ScrollXOffset < 0) ScrollXOffset = 0;
- // RefreshScrollbars();
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
-
- // case VK_RIGHT:
- // ScrollXOffset += FONT_WIDTH;
- // if(ScrollXOffset >= ScrollXOffsetMax)
- // ScrollXOffset = ScrollXOffsetMax;
- // RefreshScrollbars();
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
-
- // case VK_RETURN:
- // case VK_ESCAPE:
- // ToggleSimulationMode();
- // break;
- // }
+ // case WM_HSCROLL:
+
+ // case WM_COMMAND:
+ // ProcessMenu(LOWORD(wParam));
+ // InvalidateRect(MainWindow, NULL, FALSE);
+ // break;
+
+ // case WM_CLOSE:
+ // case WM_DESTROY:
+
+ // default:
+ // return DefWindowProc(hwnd, msg, wParam, lParam);
+ // }
+
+ return 1;
+}
+
+void LD_GTK_delete_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)//(HWND window)
+{
+ FreezeWindowPos(MainWindow);
+ FreezeDWORD(IoListHeight);
+
+ gtk_main_quit();
+}
+
+gboolean LD_GTK_keybord_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ switch(event->key.state)
+ {
+ case GDK_SHIFT_MASK:
+ g_print("SHIFT+");
+ break;
+ case GDK_CONTROL_MASK:
+ g_print("CONTROL+");
+ break;
+ }
+
+ g_print("%c\n", (char)gdk_keyval_to_unicode(event->key.keyval));
+
+ // if(wParam == 'M') {
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // ToggleSimulationMode();
// break;
// }
+ // } else if(wParam == VK_TAB) {
+ // SetFocus(IoList);
+ // BlinkCursor(0, 0, 0, 0);
+ // break;
+ // } else if(wParam == VK_F1) {
+ // ShowHelpDialog(FALSE);
+ // break;
+ // }
-
+ // if(InSimulationMode) {
// switch(wParam) {
- // case VK_F5:
- // CompileProgram(FALSE);
- // break;
-
- // case VK_UP:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(PushRungUp());
- // } else {
- // MoveCursorKeyboard(wParam);
- // }
+ // case ' ':
+ // SimulateOneCycle(TRUE);
// break;
- // case VK_DOWN:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(PushRungDown());
- // } else {
- // MoveCursorKeyboard(wParam);
- // }
+ // case 'R':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
+ // StartSimulation();
// break;
- // case VK_RIGHT:
- // case VK_LEFT:
- // MoveCursorKeyboard(wParam);
+ // case 'H':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
+ // StopSimulation();
// break;
- // case VK_RETURN:
- // CHANGING_PROGRAM(EditSelectedElement());
+ // case VK_DOWN:
+ // if(ScrollYOffset < ScrollYOffsetMax)
+ // ScrollYOffset++;
+ // RefreshScrollbars();
+ // InvalidateRect(MainWindow, NULL, FALSE);
// break;
- // case VK_DELETE:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(DeleteSelectedRung());
- // } else {
- // CHANGING_PROGRAM(DeleteSelectedFromProgram());
- // }
+ // case VK_UP:
+ // if(ScrollYOffset > 0)
+ // ScrollYOffset--;
+ // RefreshScrollbars();
+ // InvalidateRect(MainWindow, NULL, FALSE);
// break;
- // case VK_OEM_1:
- // CHANGING_PROGRAM(AddComment(_("--add comment here--")));
+ // case VK_LEFT:
+ // ScrollXOffset -= FONT_WIDTH;
+ // if(ScrollXOffset < 0) ScrollXOffset = 0;
+ // RefreshScrollbars();
+ // InvalidateRect(MainWindow, NULL, FALSE);
// break;
- // case 'C':
- // CHANGING_PROGRAM(AddContact());
+ // case VK_RIGHT:
+ // ScrollXOffset += FONT_WIDTH;
+ // if(ScrollXOffset >= ScrollXOffsetMax)
+ // ScrollXOffset = ScrollXOffsetMax;
+ // RefreshScrollbars();
+ // InvalidateRect(MainWindow, NULL, FALSE);
// break;
- // // TODO: rather country-specific here
- // case VK_OEM_2:
- // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING));
+ // case VK_RETURN:
+ // case VK_ESCAPE:
+ // ToggleSimulationMode();
// break;
+ // }
+ // break;
+ // }
- // case VK_OEM_5:
- // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING));
- // break;
- // case 'L':
- // CHANGING_PROGRAM(AddCoil());
- // break;
+ // switch(wParam) {
+ // case VK_F5:
+ // CompileProgram(FALSE);
+ // break;
- // case 'R':
- // CHANGING_PROGRAM(MakeResetOnlySelected());
- // break;
+ // case VK_UP:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(PushRungUp());
+ // } else {
+ // MoveCursorKeyboard(wParam);
+ // }
+ // break;
- // case 'E':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // ExportDialog();
- // } else {
- // CHANGING_PROGRAM(AddReset());
- // }
- // break;
+ // case VK_DOWN:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(PushRungDown());
+ // } else {
+ // MoveCursorKeyboard(wParam);
+ // }
+ // break;
- // case 'S':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // SaveProgram();
- // UpdateMainWindowTitleBar();
- // } else {
- // CHANGING_PROGRAM(MakeSetOnlySelected());
- // }
- // break;
+ // case VK_RIGHT:
+ // case VK_LEFT:
+ // MoveCursorKeyboard(wParam);
+ // break;
- // case 'N':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // if(CheckSaveUserCancels()) break;
- // if(!ProgramChangedNotSaved) {
- // int r = MessageBox(MainWindow,
- // _("Start new program?"),
- // "LDmicro", MB_YESNO | MB_DEFBUTTON2 |
- // MB_ICONQUESTION);
- // if(r == IDNO) break;
- // }
- // NewProgram();
- // strcpy(CurrentSaveFile, "");
- // strcpy(CurrentCompileFile, "");
- // GenerateIoListDontLoseSelection();
- // RefreshScrollbars();
- // UpdateMainWindowTitleBar();
- // } else {
- // CHANGING_PROGRAM(NegateSelected());
- // }
- // break;
+ // case VK_RETURN:
+ // CHANGING_PROGRAM(EditSelectedElement());
+ // break;
- // case 'A':
- // CHANGING_PROGRAM(MakeNormalSelected());
- // break;
+ // case VK_DELETE:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(DeleteSelectedRung());
+ // } else {
+ // CHANGING_PROGRAM(DeleteSelectedFromProgram());
+ // }
+ // break;
- // case 'T':
- // CHANGING_PROGRAM(AddTimer(ELEM_RTO));
- // break;
+ // case VK_OEM_1:
+ // CHANGING_PROGRAM(AddComment(_("--add comment here--")));
+ // break;
- // case 'O':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // if(CheckSaveUserCancels()) break;
- // OpenDialog();
- // } else {
- // CHANGING_PROGRAM(AddTimer(ELEM_TON));
- // }
- // break;
+ // case 'C':
+ // CHANGING_PROGRAM(AddContact());
+ // break;
- // case 'F':
- // CHANGING_PROGRAM(AddTimer(ELEM_TOF));
- // break;
+ // // TODO: rather country-specific here
+ // case VK_OEM_2:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING));
+ // break;
- // case 'U':
- // CHANGING_PROGRAM(AddCounter(ELEM_CTU));
- // break;
+ // case VK_OEM_5:
+ // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING));
+ // break;
- // case 'I':
- // CHANGING_PROGRAM(AddCounter(ELEM_CTD));
- // break;
+ // case 'L':
+ // CHANGING_PROGRAM(AddCoil());
+ // break;
- // case 'J':
- // CHANGING_PROGRAM(AddCounter(ELEM_CTC));
- // break;
+ // case 'R':
+ // CHANGING_PROGRAM(MakeResetOnlySelected());
+ // break;
- // case 'M':
- // CHANGING_PROGRAM(AddMove());
- // break;
+ // case 'E':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // ExportDialog();
+ // } else {
+ // CHANGING_PROGRAM(AddReset());
+ // }
+ // break;
- // case 'P':
- // CHANGING_PROGRAM(AddReadAdc());
- // break;
+ // case 'S':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // SaveProgram();
+ // UpdateMainWindowTitleBar();
+ // } else {
+ // CHANGING_PROGRAM(MakeSetOnlySelected());
+ // }
+ // break;
- // case VK_OEM_PLUS:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(AddMath(ELEM_ADD));
- // } else {
- // CHANGING_PROGRAM(AddCmp(ELEM_EQU));
+ // case 'N':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // if(CheckSaveUserCancels()) break;
+ // if(!ProgramChangedNotSaved) {
+ // int r = MessageBox(MainWindow,
+ // _("Start new program?"),
+ // "LDmicro", MB_YESNO | MB_DEFBUTTON2 |
+ // MB_ICONQUESTION);
+ // if(r == IDNO) break;
// }
- // break;
+ // NewProgram();
+ // strcpy(CurrentSaveFile, "");
+ // strcpy(CurrentCompileFile, "");
+ // GenerateIoListDontLoseSelection();
+ // RefreshScrollbars();
+ // UpdateMainWindowTitleBar();
+ // } else {
+ // CHANGING_PROGRAM(NegateSelected());
+ // }
+ // break;
- // case VK_OEM_MINUS:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // } else {
- // CHANGING_PROGRAM(AddMath(ELEM_SUB));
- // }
- // break;
+ // case 'A':
+ // CHANGING_PROGRAM(MakeNormalSelected());
+ // break;
- // case '8':
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(AddMath(ELEM_MUL));
- // }
- // break;
+ // case 'T':
+ // CHANGING_PROGRAM(AddTimer(ELEM_RTO));
+ // break;
- // case 'D':
- // CHANGING_PROGRAM(AddMath(ELEM_DIV));
- // break;
+ // case 'O':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // if(CheckSaveUserCancels()) break;
+ // OpenDialog();
+ // } else {
+ // CHANGING_PROGRAM(AddTimer(ELEM_TON));
+ // }
+ // break;
- // case VK_OEM_PERIOD:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(AddCmp(ELEM_GRT));
- // } else {
- // CHANGING_PROGRAM(AddCmp(ELEM_GEQ));
- // }
- // break;
+ // case 'F':
+ // CHANGING_PROGRAM(AddTimer(ELEM_TOF));
+ // break;
- // case VK_OEM_COMMA:
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(AddCmp(ELEM_LES));
- // } else {
- // CHANGING_PROGRAM(AddCmp(ELEM_LEQ));
- // }
- // break;
+ // case 'U':
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTU));
+ // break;
- // case 'V':
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(InsertRung(TRUE));
- // }
- // break;
+ // case 'I':
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTD));
+ // break;
- // case '6':
- // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
- // CHANGING_PROGRAM(InsertRung(FALSE));
- // }
- // break;
+ // case 'J':
+ // CHANGING_PROGRAM(AddCounter(ELEM_CTC));
+ // break;
- // case 'Z':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // UndoUndo();
- // }
- // break;
+ // case 'M':
+ // CHANGING_PROGRAM(AddMove());
+ // break;
- // case 'Y':
- // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
- // UndoRedo();
- // }
- // break;
+ // case 'P':
+ // CHANGING_PROGRAM(AddReadAdc());
+ // break;
- // default:
- // break;
- // }
- // if(wParam != VK_SHIFT && wParam != VK_CONTROL) {
- // InvalidateRect(MainWindow, NULL, FALSE);
- // }
- // break;
- // }
+ // case VK_OEM_PLUS:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(AddMath(ELEM_ADD));
+ // } else {
+ // CHANGING_PROGRAM(AddCmp(ELEM_EQU));
+ // }
+ // break;
- // case WM_LBUTTONDBLCLK: {
- // int x = LOWORD(lParam);
- // int y = HIWORD(lParam);
- // if(InSimulationMode) {
- // EditElementMouseDoubleclick(x, y);
- // } else {
- // CHANGING_PROGRAM(EditElementMouseDoubleclick(x, y));
- // }
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
- // }
+ // case VK_OEM_MINUS:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // } else {
+ // CHANGING_PROGRAM(AddMath(ELEM_SUB));
+ // }
+ // break;
- // case WM_LBUTTONDOWN: {
- // int x = LOWORD(lParam);
- // int y = HIWORD(lParam);
- // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
- // POINT pt;
- // pt.x = x; pt.y = y;
- // ClientToScreen(MainWindow, &pt);
- // MouseY = pt.y;
- // MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL,
- // (HOOKPROC)MouseHook, Instance, 0);
- // }
- // if(!InSimulationMode) MoveCursorMouseClick(x, y);
+ // case '8':
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(AddMath(ELEM_MUL));
+ // }
+ // break;
- // SetFocus(MainWindow);
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
- // }
- // case WM_MOUSEMOVE: {
- // int x = LOWORD(lParam);
- // int y = HIWORD(lParam);
+ // case 'D':
+ // CHANGING_PROGRAM(AddMath(ELEM_DIV));
+ // break;
- // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
- // SetCursor(LoadCursor(NULL, IDC_SIZENS));
- // } else {
- // SetCursor(LoadCursor(NULL, IDC_ARROW));
- // }
-
- // break;
+ // case VK_OEM_PERIOD:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(AddCmp(ELEM_GRT));
+ // } else {
+ // CHANGING_PROGRAM(AddCmp(ELEM_GEQ));
+ // }
+ // break;
+
+ // case VK_OEM_COMMA:
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(AddCmp(ELEM_LES));
+ // } else {
+ // CHANGING_PROGRAM(AddCmp(ELEM_LEQ));
+ // }
+ // break;
+
+ // case 'V':
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(InsertRung(TRUE));
+ // }
+ // break;
+
+ // case '6':
+ // if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+ // CHANGING_PROGRAM(InsertRung(FALSE));
+ // }
+ // break;
+
+ // case 'Z':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // UndoUndo();
+ // }
+ // break;
+
+ // case 'Y':
+ // if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+ // UndoRedo();
+ // }
+ // break;
+
+ // default:
+ // break;
// }
- // case WM_MOUSEWHEEL: {
- // if((GET_WHEEL_DELTA_WPARAM(wParam)) > 0) {
- // VscrollProc(SB_LINEUP);
- // } else {
- // VscrollProc(SB_LINEDOWN);
- // }
- // break;
+ // if(wParam != VK_SHIFT && wParam != VK_CONTROL) {
+ // InvalidateRect(MainWindow, NULL, FALSE);
// }
+ // break;
- // case WM_SIZE:
- // MainWindowResized();
- // break;
+}
- // case WM_NOTIFY: {
- // NMHDR *h = (NMHDR *)lParam;
- // if(h->hwndFrom == IoList) {
- // IoListProc(h);
- // }
- // return 0;
- // }
- // case WM_VSCROLL:
- // VscrollProc(wParam);
- // break;
+gboolean LD_GTK_mouse_click_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ g_print("x = %f\n", event->button.x_root);
+ g_print("y = %f\n", event->button.y_root);
+ switch(event->button.type)
+ {
+ case GDK_BUTTON_PRESS:
+ // int x = LOWORD(lParam);
+ // int y = HIWORD(lParam);
+ // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
+ // POINT pt;
+ // pt.x = x; pt.y = y;
+ // ClientToScreen(MainWindow, &pt);
+ // MouseY = pt.y;
+ // MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL,
+ // (HOOKPROC)MouseHook, Instance, 0);
+ // }
+ // if(!InSimulationMode) MoveCursorMouseClick(x, y);
+
+ // SetFocus(MainWindow);
+ // InvalidateRect(MainWindow, NULL, FALSE);
+ break;
+ case GDK_2BUTTON_PRESS:
+ // int x = LOWORD(lParam);
+ // int y = HIWORD(lParam);
+ // if(InSimulationMode) {
+ // EditElementMouseDoubleclick(x, y);
+ // } else {
+ // CHANGING_PROGRAM(EditElementMouseDoubleclick(x, y));
+ // }
+ // InvalidateRect(MainWindow, NULL, FALSE);
+ break;
- // case WM_HSCROLL:
- // HscrollProc(wParam);
- // break;
+ }
+}
- // case WM_COMMAND:
- // ProcessMenu(LOWORD(wParam));
- // InvalidateRect(MainWindow, NULL, FALSE);
- // break;
+gboolean LD_GTK_mouse_scroll_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ switch(event->scroll.direction)
+ {
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_DOWN:
+ // VscrollProc(wParam);
+ break;
+ case GDK_SCROLL_LEFT:
+ case GDK_SCROLL_RIGHT:
+ // HscrollProc(wParam);
+ break;
+ case GDK_SCROLL_SMOOTH:
+ // if((GET_WHEEL_DELTA_WPARAM(wParam)) > 0) {
+ // VscrollProc(SB_LINEUP);
+ // } else {
+ // VscrollProc(SB_LINEDOWN);
+ // }
+ // gdk_event_get_scroll_deltas (const GdkEvent *event, gdouble *delta_x, gdouble *delta_y);
+ break;
- // case WM_CLOSE:
- // case WM_DESTROY:
- // if(CheckSaveUserCancels()) break;
+ }
+}
- // PostQuitMessage(0);
- // return 1;
+gboolean LD_GTK_mouse_move_hook(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ g_print("x = %f\n", event->button.x_root);
+ g_print("y = %f\n", event->button.y_root);
+ // int x = LOWORD(lParam);
+ // int y = HIWORD(lParam);
+
+ // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
+ // SetCursor(LoadCursor(NULL, IDC_SIZENS));
+ // } else {
+ // SetCursor(LoadCursor(NULL, IDC_ARROW));
+ // }
+
+ // break;
+}
- // default:
- // return DefWindowProc(hwnd, msg, wParam, lParam);
+gboolean LD_GTK_paint_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ g_print("draw called\n");
+ // PAINTSTRUCT ps;
+ // Hdc = BeginPaint(hwnd, &ps);
+
+ // // This draws the schematic.
+ // PaintWindow();
+
+ // RECT r;
+ // // Fill around the scroll bars
+ // if(NeedHoriz) {
+ // r.top = IoListTop - ScrollHeight - 2;
+ // r.bottom = IoListTop - 2;
+ // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
// }
+ // GetClientRect(MainWindow, &r);
+ // r.left = r.right - ScrollWidth - 2;
+ // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
+
+ // // Draw the splitter thing to grab to resize the I/O listview.
+ // GetClientRect(MainWindow, &r);
+ // r.top = IoListTop - 2;
+ // r.bottom = IoListTop;
+ // FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
+ // r.top = IoListTop - 2;
+ // r.bottom = IoListTop - 1;
+ // FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
+ // r.top = IoListTop;
+ // r.bottom = IoListTop + 1;
+ // FillRect(Hdc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
+
+ // EndPaint(hwnd, &ps);
+ // return 1;
+}
- return 1;
+gboolean LD_GTK_destroy_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ // if(CheckSaveUserCancels()) break;
+
+ // PostQuitMessage(0);
+ // return 1;
}
-void LDMicro_close(HWND window)
+gboolean LD_GTK_size_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
- FreezeWindowPos(MainWindow);
- FreezeDWORD(IoListHeight);
+ // MainWindowResized();
+ // break;
+}
- gtk_main_quit();
+gboolean LD_GTK_set_focus_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ // InvalidateRect(MainWindow, NULL, FALSE);
+ // break;
}
+
//-----------------------------------------------------------------------------
// Entry point into the program.
//-----------------------------------------------------------------------------
@@ -1126,8 +1193,18 @@ int main(int argc, char** argv)
IMAGE_ICON, 32, 32, 0));
gtk_window_set_icon(GTK_WINDOW(MainWindow), LoadImage(Instance, LDMICRO_ICON,
IMAGE_ICON, 32, 32, 0));
+
+ /// Keyboard and mouse hooks equivalent to MainWndProc
+ g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LD_GTK_delete_call), NULL);
+ g_signal_connect (MainWindow, "key_press_event", G_CALLBACK (LD_GTK_keybord_hook), NULL);
+ g_signal_connect (MainWindow, "button_press_event", G_CALLBACK (LD_GTK_mouse_click_hook), NULL);
+ g_signal_connect (MainWindow, "scroll_event", G_CALLBACK (LD_GTK_mouse_scroll_hook), NULL);
+ g_signal_connect (MainWindow, "motion_notify_event", G_CALLBACK (LD_GTK_mouse_move_hook), NULL);
+ // g_signal_connect (DrawWindow, "draw", G_CALLBACK (LD_GTK_paint_call), NULL);
+ g_signal_connect (MainWindow, "destroy_event", G_CALLBACK (LD_GTK_destroy_call), NULL);
+ g_signal_connect (MainWindow, "configure_event", G_CALLBACK (LD_GTK_size_call), NULL);
+ g_signal_connect (MainWindow, "focus_in_event", G_CALLBACK (LD_GTK_set_focus_call), NULL);
- g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LDMicro_close), NULL);
ThawWindowPos(MainWindow);
IoListHeight = 100;
@@ -1135,6 +1212,8 @@ int main(int argc, char** argv)
InitForDrawing();
+
+
MakeMainWindowControls(); /// takes care of MakeMainWindowMenus()
MainWindowResized();
// NewProgram();
diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp
index dd5f906..cdeb190 100644
--- a/ldmicro/lib/linuxUI/linuxLD.cpp
+++ b/ldmicro/lib/linuxUI/linuxLD.cpp
@@ -99,12 +99,6 @@ BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
}
-BOOL RegisterClassEx(const WNDCLASSEX *lpwcx)
-{
- WindClassRecord.push_back(*lpwcx);
- return TRUE;
-}
-
HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired,
int cyDesired, UINT fuLoad)
{
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 035543b..6f1e4f0 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -162,8 +162,6 @@ BOOL HeapFree(
DWORD dwFlags,
LPVOID lpMem);
-BOOL RegisterClassEx(const WNDCLASSEX *lpwcx);
-
HICON LoadImage(
HINSTANCE hinst,
LPCTSTR lpszName,
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index c2d923b..7e2ea84 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -72,19 +72,4 @@ void EnableMenuItem(HMENU, HMENU, UINT);
void CheckMenuItem(HMENU, HMENU, UINT);
HBRUSH GetStockObject(int fnObject);
-// HWID CreateWindowEx(
-// DWORD dwExStyle,
-// LPCTSTR lpClassName,
-// LPCTSTR lpWindowName,
-// DWORD dwStyle,
-// int x,
-// int y,
-// int nWidth,
-// int nHeight,
-// HWND hWndParent,
-// HMENU hMenu,
-// HINSTANCE hInstance,
-// LPVOID lpParam
-// );
-
#endif \ No newline at end of file
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 20cc906..2d2716b 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -498,6 +498,136 @@ void MakeMainWindowControls(void)
}
//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+void RefreshScrollbars(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);
+}
+
+//-----------------------------------------------------------------------------
+// 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);
+ // }
+}
+
+//-----------------------------------------------------------------------------
// Set up the title bar text for the main window; indicate whether we are in
// simulation or editing mode, and indicate the filename.
//-----------------------------------------------------------------------------
diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp
index 4fddcf4..092f606 100644
--- a/ldmicro/miscutil.cpp
+++ b/ldmicro/miscutil.cpp
@@ -259,8 +259,9 @@ static LRESULT CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam,
//-----------------------------------------------------------------------------
// Set the font of a control to a pretty proportional font (typ. Tahoma).
//-----------------------------------------------------------------------------
-void NiceFont(HWND h)
+void NiceFont(HWID h)
{
+ // gtk_widget_override_font(GTK_WIDGET(h), pango_font_description_from_string("Times New Roman"));
// SendMessage(h, WM_SETFONT, (WPARAM)MyNiceFont, TRUE);
}