summaryrefslogtreecommitdiff
path: root/ldmicro
diff options
context:
space:
mode:
authorNatsuDrag92018-06-27 15:42:41 +0530
committerNatsuDrag92018-06-27 15:42:41 +0530
commitdaa2a7810dedccf79355ecfeb31ce115a6508824 (patch)
treeadb97832b1919ff97aebf46853ce7556e2cc2f42 /ldmicro
parent6624f87436a53f707f4f9708d94bea53345dd924 (diff)
parentba30e0ab39e4bcad351f931e9e965d67d843d858 (diff)
downloadLDMicroGtk-daa2a7810dedccf79355ecfeb31ce115a6508824.tar.gz
LDMicroGtk-daa2a7810dedccf79355ecfeb31ce115a6508824.tar.bz2
LDMicroGtk-daa2a7810dedccf79355ecfeb31ce115a6508824.zip
Pulled and merged
Diffstat (limited to 'ldmicro')
-rw-r--r--ldmicro/ldmicro.cpp140
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h30
-rw-r--r--ldmicro/maincontrols.cpp3
-rw-r--r--ldmicro/schematic.cpp449
4 files changed, 355 insertions, 267 deletions
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index d2b54b5..be02fd5 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -595,51 +595,109 @@ cmp:
}
//-----------------------------------------------------------------------------
-// WndProc for MainWindow.
+// WndProc functions for MainWindow.
//-----------------------------------------------------------------------------
-// LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-// {
-// // switch (msg) {
-// // case WM_ERASEBKGND:
-// // break;
+gboolean LD_WM_KeyDown_call(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+ /* Handles:
+ * WM_KEYDOWN
+ */
-// // case WM_SETFOCUS:
+ UINT wParam = event->keyval;
+
+ if(wParam == VK_TAB) {
+ // SetFocus(IoList);
+ gtk_window_set_focus (GTK_WINDOW(MainWindow), view);
+ // BlinkCursor(0, 0, 0, 0);
+
+ }
+
+ if(InSimulationMode)
+ {
+ switch(wParam)
+ {
+ case VK_DOWN:
+ if(ScrollYOffset < ScrollYOffsetMax)
+ ScrollYOffset++;
+ RefreshScrollbars();
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_PAINT: {
-// // }
+ case VK_UP:
+ if(ScrollYOffset > 0)
+ ScrollYOffset--;
+ RefreshScrollbars();
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_KEYDOWN: {
-// // }
+ case VK_LEFT:
+ ScrollXOffset -= FONT_WIDTH;
+ if(ScrollXOffset < 0)
+ ScrollXOffset = 0;
+ RefreshScrollbars();
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_LBUTTONDBLCLK: {
-// // }
+ case VK_RIGHT:
+ ScrollXOffset += FONT_WIDTH;
+ if(ScrollXOffset >= ScrollXOffsetMax)
+ ScrollXOffset = ScrollXOffsetMax;
+ RefreshScrollbars();
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_LBUTTONDOWN: {
-// // }
-// // case WM_MOUSEMOVE: {
-// // }
-// // case WM_MOUSEWHEEL: {
-// // }
+ case VK_RETURN:
+ case VK_ESCAPE:
+ ToggleSimulationMode();
+ break;
+ }
+ }
-// // case WM_SIZE:
+ switch(wParam)
+ {
+ case VK_UP:
+ if(event->state & GDK_SHIFT_MASK)
+ {
+ CHANGING_PROGRAM(PushRungUp());
+ }
+ else
+ {
+ MoveCursorKeyboard(wParam);
+ }
-// // case WM_NOTIFY: {
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_VSCROLL:
+ case VK_DOWN:
+ if(event->state & GDK_SHIFT_MASK)
+ {
+ CHANGING_PROGRAM(PushRungDown());
+ }
+ else
+ {
+ MoveCursorKeyboard(wParam);
+ }
-// // case WM_HSCROLL:
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_COMMAND:
+ case VK_RIGHT:
+ case VK_LEFT:
+ MoveCursorKeyboard(wParam);
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // case WM_CLOSE:
-// // case WM_DESTROY:
+ case VK_RETURN:
+ CHANGING_PROGRAM(EditSelectedElement());
+ gtk_widget_queue_draw(DrawWindow);
+ break;
-// // default:
-// // return DefWindowProc(hwnd, msg, wParam, lParam);
-// // }
+ default:
+ break;
+ }
-// return 1;
-// }
+ return FALSE;
+}
void LD_WM_Close_call(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
@@ -674,17 +732,8 @@ gboolean LD_GTK_mouse_click_hook(GtkWidget *widget, GdkEvent *event, gpointer us
int x = event->button.x;
int y = event->button.y - 30 + gtk_adjustment_get_value(adjustment);
- // if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) {
- // // POINT pt;
- // // pt.x = x; pt.y = y;
- // // ClientToScreen(MainWindow, &pt);
- // MouseY = y; //pt.y;
- // // MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL,
- // // (HOOKPROC)MouseHook, Instance, 0);
- // }
if(!InSimulationMode) MoveCursorMouseClick(x, y);
- // SetFocus(MainWindow);
gtk_widget_queue_draw(DrawWindow);
}
break;
@@ -769,7 +818,15 @@ gboolean LD_WM_MouseMove_call(GtkWidget *widget, GdkEvent *event, gpointer user_
// SetCursor(LoadCursor(NULL, IDC_ARROW));
// }
- // break;
+ // int dy = MouseY - mhs->pt.y;
+
+ // int dy = MouseY - mhs->pt.y;
+
+ // IoListHeight += dy;
+ // if(IoListHeight < 50) IoListHeight = 50;
+ // MouseY = mhs->pt.y;
+ // MainWindowResized();
+
return FALSE;
}
@@ -1188,6 +1245,7 @@ int main(int argc, char** argv)
/// Keyboard and mouse hooks equivalent to MainWndProc
g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LD_WM_Close_call), NULL);
+ g_signal_connect (MainWindow, "key_press_event", G_CALLBACK (LD_WM_KeyDown_call), 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_WM_MouseMove_call), NULL);
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index b1a3d48..53040ec 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -60,6 +60,36 @@
/// PatBlt paint flags
#define PATINVERT 0x00000100L
+/// Key masks
+#define VK_TAB GDK_KEY_Tab
+
+#define VK_DOWN 65364
+#define VK_UP 65362
+#define VK_LEFT 65361
+#define VK_RIGHT 65363
+
+#define VK_NP_DOWN 65433
+#define VK_NP_UP 65431
+#define VK_NP_LEFT 65430
+#define VK_NP_RIGHT 65432
+
+#define VK_RETURN GDK_KEY_Return
+#define VK_ESCAPE GDK_KEY_Escape
+#define VK_F5 GDK_KEY_F5
+#define VK_F1 GDK_KEY_F1
+
+#define VK_OEM_PLUS GDK_KEY_plus
+#define VK_OEM_MINUS GDK_KEY_minus
+#define VK_OEM_PERIOD GDK_KEY_period
+#define VK_OEM_COMMA GDK_KEY_comma
+
+#define VK_DELETE GDK_KEY_Delete
+#define VK_NP_DELETE GDK_KEY_KP_Delete
+
+// #define VK_OEM_1 GDK_KEY_colon // GDK_KEY_semicolon
+// #define VK_OEM_2 GDK_KEY_question // GDK_KEY_slash
+// #define VK_OEM_5 GDK_KEY_backslash // GDK_KEY_bar
+
/// Window brushes
#define BS_SOLID 0x00000001L
#define BS_HOLLOW 0x00000002L
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index 0deaf73..14aa308 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -541,6 +541,7 @@ void MakeMainWindowControls(void)
/// 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));
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
column = gtk_tree_view_column_new_with_attributes("Name",
gtk_cell_renderer_text_new(),
@@ -908,7 +909,7 @@ void ToggleSimulationMode(void)
EnableMenuItem(TopMenu, Settings, MF_GRAYED);
EnableMenuItem(TopMenu, InstructionMenu, MF_GRAYED);
EnableMenuItem(TopMenu, Compile, MF_GRAYED);
-
+
CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_CHECKED);
ClearSimulationData(); // simulation.cpp, ldmicro.h
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index 5a3954e..f47a568 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -290,108 +290,108 @@ BOOL MoveCursorTopLeft(void)
//-----------------------------------------------------------------------------
void MoveCursorKeyboard(int keyCode)
{
- // if(!Selected || Selected->selectedState == SELECTED_NONE) {
- // MoveCursorTopLeft();
- // return;
- // }
-
- // switch(keyCode) {
- // case VK_LEFT: {
- // if(!Selected || Selected->selectedState == SELECTED_NONE) {
- // break;
- // }
- // if(Selected->selectedState != SELECTED_LEFT) {
- // SelectElement(-1, -1, SELECTED_LEFT);
- // break;
- // }
- // if(SelectedWhich == ELEM_COMMENT) break;
- // int i, j;
- // if(FindSelected(&i, &j)) {
- // i--;
- // while(i >= 0 && (!VALID_LEAF(DisplayMatrix[i][j]) ||
- // (DisplayMatrix[i][j] == Selected)))
- // {
- // i--;
- // }
- // if(i >= 0) {
- // SelectElement(i, j, SELECTED_RIGHT);
- // }
- // }
- // break;
- // }
- // case VK_RIGHT: {
- // if(!Selected || Selected->selectedState == SELECTED_NONE) {
- // break;
- // }
- // if(Selected->selectedState != SELECTED_RIGHT) {
- // SelectElement(-1, -1, SELECTED_RIGHT);
- // break;
- // }
- // if(SelectedWhich == ELEM_COMMENT) break;
- // int i, j;
- // if(FindSelected(&i, &j)) {
- // i++;
- // while(i < DISPLAY_MATRIX_X_SIZE &&
- // !VALID_LEAF(DisplayMatrix[i][j]))
- // {
- // i++;
- // }
- // if(i != DISPLAY_MATRIX_X_SIZE) {
- // SelectElement(i, j, SELECTED_LEFT);
- // }
- // }
- // break;
- // }
- // case VK_UP: {
- // if(!Selected || Selected->selectedState == SELECTED_NONE) {
- // break;
- // }
- // if(Selected->selectedState != SELECTED_ABOVE &&
- // SelectedWhich != ELEM_PLACEHOLDER)
- // {
- // SelectElement(-1, -1, SELECTED_ABOVE);
- // break;
- // }
- // int i, j;
- // if(FindSelected(&i, &j)) {
- // j--;
- // while(j >= 0 && !VALID_LEAF(DisplayMatrix[i][j]))
- // j--;
- // if(j >= 0) {
- // SelectElement(i, j, SELECTED_BELOW);
- // }
- // }
- // break;
- // }
- // case VK_DOWN: {
- // if(!Selected || Selected->selectedState == SELECTED_NONE) {
- // break;
- // }
- // if(Selected->selectedState != SELECTED_BELOW &&
- // SelectedWhich != ELEM_PLACEHOLDER)
- // {
- // SelectElement(-1, -1, SELECTED_BELOW);
- // break;
- // }
- // int i, j;
- // if(FindSelected(&i, &j)) {
- // j++;
- // while(j < DISPLAY_MATRIX_Y_SIZE &&
- // !VALID_LEAF(DisplayMatrix[i][j]))
- // {
- // j++;
- // }
- // if(j != DISPLAY_MATRIX_Y_SIZE) {
- // SelectElement(i, j, SELECTED_ABOVE);
- // } else if(ScrollYOffsetMax - ScrollYOffset < 3) {
- // // special case: scroll the end marker into view
- // ScrollYOffset = ScrollYOffsetMax;
- // RefreshScrollbars();
- // }
- // }
- // break;
- // }
- // }
+ if(!Selected || Selected->selectedState == SELECTED_NONE) {
+ MoveCursorTopLeft();
+ return;
+ }
+
+ switch(keyCode) {
+ case VK_LEFT: {
+ if(!Selected || Selected->selectedState == SELECTED_NONE) {
+ break;
+ }
+ if(Selected->selectedState != SELECTED_LEFT) {
+ SelectElement(-1, -1, SELECTED_LEFT);
+ break;
+ }
+ if(SelectedWhich == ELEM_COMMENT) break;
+ int i, j;
+ if(FindSelected(&i, &j)) {
+ i--;
+ while(i >= 0 && (!VALID_LEAF(DisplayMatrix[i][j]) ||
+ (DisplayMatrix[i][j] == Selected)))
+ {
+ i--;
+ }
+ if(i >= 0) {
+ SelectElement(i, j, SELECTED_RIGHT);
+ }
+ }
+ break;
+ }
+ case VK_RIGHT: {
+ if(!Selected || Selected->selectedState == SELECTED_NONE) {
+ break;
+ }
+ if(Selected->selectedState != SELECTED_RIGHT) {
+ SelectElement(-1, -1, SELECTED_RIGHT);
+ break;
+ }
+ if(SelectedWhich == ELEM_COMMENT) break;
+ int i, j;
+ if(FindSelected(&i, &j)) {
+ i++;
+ while(i < DISPLAY_MATRIX_X_SIZE &&
+ !VALID_LEAF(DisplayMatrix[i][j]))
+ {
+ i++;
+ }
+ if(i != DISPLAY_MATRIX_X_SIZE) {
+ SelectElement(i, j, SELECTED_LEFT);
+ }
+ }
+ break;
+ }
+ case VK_UP: {
+ if(!Selected || Selected->selectedState == SELECTED_NONE) {
+ break;
+ }
+ if(Selected->selectedState != SELECTED_ABOVE &&
+ SelectedWhich != ELEM_PLACEHOLDER)
+ {
+ SelectElement(-1, -1, SELECTED_ABOVE);
+ break;
+ }
+ int i, j;
+ if(FindSelected(&i, &j)) {
+ j--;
+ while(j >= 0 && !VALID_LEAF(DisplayMatrix[i][j]))
+ j--;
+ if(j >= 0) {
+ SelectElement(i, j, SELECTED_BELOW);
+ }
+ }
+ break;
+ }
+ case VK_DOWN: {
+ if(!Selected || Selected->selectedState == SELECTED_NONE) {
+ break;
+ }
+ if(Selected->selectedState != SELECTED_BELOW &&
+ SelectedWhich != ELEM_PLACEHOLDER)
+ {
+ SelectElement(-1, -1, SELECTED_BELOW);
+ break;
+ }
+ int i, j;
+ if(FindSelected(&i, &j)) {
+ j++;
+ while(j < DISPLAY_MATRIX_Y_SIZE &&
+ !VALID_LEAF(DisplayMatrix[i][j]))
+ {
+ j++;
+ }
+ if(j != DISPLAY_MATRIX_Y_SIZE) {
+ SelectElement(i, j, SELECTED_ABOVE);
+ } else if(ScrollYOffsetMax - ScrollYOffset < 3) {
+ // special case: scroll the end marker into view
+ ScrollYOffset = ScrollYOffsetMax;
+ RefreshScrollbars();
+ }
+ }
+ break;
+ }
+ }
}
//-----------------------------------------------------------------------------
@@ -400,104 +400,104 @@ void MoveCursorKeyboard(int keyCode)
//-----------------------------------------------------------------------------
void EditSelectedElement(void)
-{
- ShowLookUpTableDialog(Selected);
- // ShowCommentDialog(Selected->d.comment.str);
-
-// if(!Selected || Selected->selectedState == SELECTED_NONE) return;
-
-// switch(SelectedWhich) {
-// case ELEM_COMMENT:
-// ShowCommentDialog(Selected->d.comment.str);
-// break;
-
-// case ELEM_CONTACTS:
-// ShowContactsDialog(&(Selected->d.contacts.negated),
-// Selected->d.contacts.name);
-// break;
-
-// case ELEM_COIL:
-// ShowCoilDialog(&(Selected->d.coil.negated),
-// &(Selected->d.coil.setOnly), &(Selected->d.coil.resetOnly),
-// Selected->d.coil.name);
-// break;
-
-// case ELEM_TON:
-// case ELEM_TOF:
-// case ELEM_RTO:
-// ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay),
-// Selected->d.timer.name);
-// break;
-
-// case ELEM_CTU:
-// case ELEM_CTD:
-// case ELEM_CTC:
-// ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max),
-// Selected->d.counter.name);
-// break;
-
-// case ELEM_EQU:
-// case ELEM_NEQ:
-// case ELEM_GRT:
-// case ELEM_GEQ:
-// case ELEM_LES:
-// case ELEM_LEQ:
-// ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1,
-// Selected->d.cmp.op2);
-// break;
-
-// case ELEM_ADD:
-// case ELEM_SUB:
-// case ELEM_MUL:
-// case ELEM_DIV:
-// ShowMathDialog(SelectedWhich, Selected->d.math.dest,
-// Selected->d.math.op1, Selected->d.math.op2);
-// break;
-
-// case ELEM_RES:
-// ShowResetDialog(Selected->d.reset.name);
-// break;
-
-// case ELEM_MOVE:
-// ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src);
-// break;
-
-// case ELEM_SET_PWM:
-// ShowSetPwmDialog(Selected->d.setPwm.name,
-// &(Selected->d.setPwm.targetFreq));
-// break;
-
-// case ELEM_READ_ADC:
-// ShowReadAdcDialog(Selected->d.readAdc.name+1);
-// break;
-
-// case ELEM_UART_RECV:
-// case ELEM_UART_SEND:
-// ShowUartDialog(SelectedWhich, Selected->d.uart.name);
-// break;
-
-// case ELEM_PERSIST:
-// ShowPersistDialog(Selected->d.persist.var);
-// break;
-
-// case ELEM_SHIFT_REGISTER:
-// ShowShiftRegisterDialog(Selected->d.shiftRegister.name,
-// &(Selected->d.shiftRegister.stages));
-// break;
-
-// case ELEM_FORMATTED_STRING:
-// ShowFormattedStringDialog(Selected->d.fmtdStr.var,
-// Selected->d.fmtdStr.string);
-// break;
-
-// case ELEM_PIECEWISE_LINEAR:
-// ShowPiecewiseLinearDialog(Selected);
-// break;
-
-// case ELEM_LOOK_UP_TABLE:
-// ShowLookUpTableDialog(Selected);
-// break;
-// }
+{
+
+ ShowContactsDialog(&(Selected->d.contacts.negated),Selected->d.contacts.name);
+
+ if(!Selected || Selected->selectedState == SELECTED_NONE) return;
+
+ switch(SelectedWhich) {
+ case ELEM_COMMENT:
+ // ShowCommentDialog(Selected->d.comment.str);
+ break;
+
+ case ELEM_CONTACTS:
+ // ShowContactsDialog(&(Selected->d.contacts.negated),
+ // Selected->d.contacts.name);
+ break;
+
+ case ELEM_COIL:
+ // ShowCoilDialog(&(Selected->d.coil.negated),
+ // &(Selected->d.coil.setOnly), &(Selected->d.coil.resetOnly),
+ // Selected->d.coil.name);
+ break;
+
+ case ELEM_TON:
+ case ELEM_TOF:
+ case ELEM_RTO:
+ // ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay),
+ // Selected->d.timer.name);
+ break;
+
+ case ELEM_CTU:
+ case ELEM_CTD:
+ case ELEM_CTC:
+ // ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max),
+ // Selected->d.counter.name);
+ break;
+
+ case ELEM_EQU:
+ case ELEM_NEQ:
+ case ELEM_GRT:
+ case ELEM_GEQ:
+ case ELEM_LES:
+ case ELEM_LEQ:
+ // ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1,
+ // Selected->d.cmp.op2);
+ break;
+
+ case ELEM_ADD:
+ case ELEM_SUB:
+ case ELEM_MUL:
+ case ELEM_DIV:
+ // ShowMathDialog(SelectedWhich, Selected->d.math.dest,
+ // Selected->d.math.op1, Selected->d.math.op2);
+ break;
+
+ case ELEM_RES:
+ // ShowResetDialog(Selected->d.reset.name);
+ break;
+
+ case ELEM_MOVE:
+ // ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src);
+ break;
+
+ case ELEM_SET_PWM:
+ // ShowSetPwmDialog(Selected->d.setPwm.name,
+ // &(Selected->d.setPwm.targetFreq));
+ break;
+
+ case ELEM_READ_ADC:
+ // ShowReadAdcDialog(Selected->d.readAdc.name+1);
+ break;
+
+ case ELEM_UART_RECV:
+ case ELEM_UART_SEND:
+ // ShowUartDialog(SelectedWhich, Selected->d.uart.name);
+ break;
+
+ case ELEM_PERSIST:
+ // ShowPersistDialog(Selected->d.persist.var);
+ break;
+
+ case ELEM_SHIFT_REGISTER:
+ // ShowShiftRegisterDialog(Selected->d.shiftRegister.name,
+ // &(Selected->d.shiftRegister.stages));
+ break;
+
+ case ELEM_FORMATTED_STRING:
+ // ShowFormattedStringDialog(Selected->d.fmtdStr.var,
+ // Selected->d.fmtdStr.string);
+ break;
+
+ case ELEM_PIECEWISE_LINEAR:
+ // ShowPiecewiseLinearDialog(Selected);
+ break;
+
+ case ELEM_LOOK_UP_TABLE:
+ ShowLookUpTableDialog(Selected);
+ break;
+ }
}
//-----------------------------------------------------------------------------
@@ -509,31 +509,30 @@ void EditSelectedElement(void)
//-----------------------------------------------------------------------------
void EditElementMouseDoubleclick(int x, int y)
{
-// x += ScrollXOffset;
-
-// y += FONT_HEIGHT/2;
-
-// int gx = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH);
-// int gy = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT);
-
-// gy += ScrollYOffset;
-
-// if(InSimulationMode) {
-// ElemLeaf *l = DisplayMatrix[gx][gy];
-// if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) {
-// char *name = l->d.contacts.name;
-// if(name[0] == 'X') {
-// SimulationToggleContact(name);
-// }
-// } else if(l && DisplayMatrixWhich[gx][gy] == ELEM_READ_ADC) {
-// ShowAnalogSliderPopup(l->d.readAdc.name);
-// }
-// } else {
-// if(DisplayMatrix[gx][gy] == Selected) {
-// EditSelectedElement();
-// }
-// }
- EditSelectedElement();
+ x += ScrollXOffset;
+
+ y += FONT_HEIGHT/2;
+
+ int gx = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH);
+ int gy = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT);
+
+ gy += ScrollYOffset;
+
+ if(InSimulationMode) {
+ ElemLeaf *l = DisplayMatrix[gx][gy];
+ if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) {
+ char *name = l->d.contacts.name;
+ if(name[0] == 'X') {
+ SimulationToggleContact(name);
+ }
+ } else if(l && DisplayMatrixWhich[gx][gy] == ELEM_READ_ADC) {
+ ShowAnalogSliderPopup(l->d.readAdc.name);
+ }
+ } else {
+ if(DisplayMatrix[gx][gy] == Selected) {
+ EditSelectedElement();
+ }
+ }
}
//-----------------------------------------------------------------------------