📄 maincontrols.cpp
字号:
AppendMenu(EditMenu, MF_STRING, MNU_INSERT_RUNG_AFTER,
_("Insert Rung &After\tShift+V"));
AppendMenu(EditMenu, MF_STRING, MNU_PUSH_RUNG_UP,
_("Move Selected Rung &Up\tShift+Up"));
AppendMenu(EditMenu, MF_STRING, MNU_PUSH_RUNG_DOWN,
_("Move Selected Rung &Down\tShift+Down"));
AppendMenu(EditMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(EditMenu, MF_STRING, MNU_DELETE_ELEMENT,
_("&Delete Selected Element\tDel"));
AppendMenu(EditMenu, MF_STRING, MNU_DELETE_RUNG,
_("D&elete Rung\tShift+Del"));
InstructionMenu = CreatePopupMenu();
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_COMMENT,
_("Insert Co&mment\t;"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CONTACTS,
_("Insert &Contacts\tC"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OSR,
_("Insert OSR (One Shot Rising)\t&/"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OSF,
_("Insert OSF (One Shot Falling)\t&\\"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_TON,
_("Insert T&ON (Delayed Turn On)\tO"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_TOF,
_("Insert TO&F (Delayed Turn Off)\tF"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_RTO,
_("Insert R&TO (Retentive Delayed Turn On)\tT"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTU,
_("Insert CT&U (Count Up)\tU"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTD,
_("Insert CT&D (Count Down)\tI"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTC,
_("Insert CT&C (Count Circular)\tJ"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_EQU,
_("Insert EQU (Compare for Equals)\t="));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_NEQ,
_("Insert NEQ (Compare for Not Equals)"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_GRT,
_("Insert GRT (Compare for Greater Than)\t>"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_GEQ,
_("Insert GEQ (Compare for Greater Than or Equal)\t."));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LES,
_("Insert LES (Compare for Less Than)\t<"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LEQ,
_("Insert LEQ (Compare for Less Than or Equal)\t,"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OPEN,
_("Insert Open-Circuit"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SHORT,
_("Insert Short-Circuit"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MASTER_RLY,
_("Insert Master Control Relay"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_COIL,
_("Insert Coi&l\tL"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_RES,
_("Insert R&ES (Counter/RTO Reset)\tE"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MOV,
_("Insert MOV (Move)\tM"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_ADD,
_("Insert ADD (16-bit Integer Add)\t+"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SUB,
_("Insert SUB (16-bit Integer Subtract)\t-"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MUL,
_("Insert MUL (16-bit Integer Multiply)\t*"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_DIV,
_("Insert DIV (16-bit Integer Divide)\tD"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SHIFT_REG,
_("Insert Shift Register"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LUT,
_("Insert Look-Up Table"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_PWL,
_("Insert Piecewise Linear"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_FMTD_STR,
_("Insert Formatted String Over UART"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_UART_SEND,
_("Insert &UART Send"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_UART_RECV,
_("Insert &UART Receive"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SET_PWM,
_("Insert Set PWM Output"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_READ_ADC,
_("Insert A/D Converter Read\tP"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_PERSIST,
_("Insert Make Persistent"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_NORMAL,
_("Make Norm&al\tA"));
AppendMenu(InstructionMenu, MF_STRING, MNU_NEGATE,
_("Make &Negated\tN"));
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_SET_ONLY,
_("Make &Set-Only\tS"));
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_RESET_ONLY,
_("Make &Reset-Only\tR"));
settings = CreatePopupMenu();
AppendMenu(settings, MF_STRING, MNU_MCU_SETTINGS, _("&MCU Parameters..."));
ProcessorMenu = CreatePopupMenu();
for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
AppendMenu(ProcessorMenu, MF_STRING, MNU_PROCESSOR_0+i,
SupportedMcus[i].mcuName);
}
AppendMenu(ProcessorMenu, MF_STRING, MNU_PROCESSOR_0+i,
_("(no microcontroller)"));
AppendMenu(settings, MF_STRING | MF_POPUP, (UINT_PTR)ProcessorMenu,
_("&Microcontroller"));
SimulateMenu = CreatePopupMenu();
AppendMenu(SimulateMenu, MF_STRING, MNU_SIMULATION_MODE,
_("Si&mulation Mode\tCtrl+M"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_START_SIMULATION,
_("Start &Real-Time Simulation\tCtrl+R"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_STOP_SIMULATION,
_("&Halt Simulation\tCtrl+H"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_SINGLE_CYCLE,
_("Single &Cycle\tSpace"));
compile = CreatePopupMenu();
AppendMenu(compile, MF_STRING, MNU_COMPILE, _("&Compile\tF5"));
AppendMenu(compile, MF_STRING, MNU_COMPILE_AS, _("Compile &As..."));
help = CreatePopupMenu();
AppendMenu(help, MF_STRING, MNU_MANUAL, _("&Manual...\tF1"));
AppendMenu(help, MF_STRING, MNU_ABOUT, _("&About..."));
TopMenu = CreateMenu();
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)FileMenu, _("&File"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)EditMenu, _("&Edit"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)settings,
_("&Settings"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)InstructionMenu,
_("&Instruction"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)SimulateMenu,
_("Si&mulate"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)compile,
_("&Compile"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)help, _("&Help"));
return TopMenu;
}
//-----------------------------------------------------------------------------
// 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -