void CFilterConditionsDialog::EditFilter(const CFilter& filter) { DestroyControls(); // Create new controls m_currentFilter = filter; if (m_currentFilter.filters.empty()) m_currentFilter.filters.push_back(CFilterCondition()); for (unsigned int i = 0; i < m_currentFilter.filters.size(); i++) { const CFilterCondition& cond = m_currentFilter.filters[i]; MakeControls(cond); } // Get correct coordinates wxSize client_size = m_pListCtrl->GetClientSize(); wxPoint pos; m_pListCtrl->CalcScrolledPosition(client_size.GetWidth() - 5 - m_button_size.x, (m_choiceBoxHeight + 6) * m_filterControls.size() + 3, &pos.x, &pos.y); if (!m_pAdd) m_pAdd = new wxButton(m_pListCtrl, wxID_ANY, _T("+"), pos, m_button_size); else m_pAdd->SetPosition(pos); m_pListCtrl->SetLineCount(m_filterControls.size() + 1); UpdateConditionsClientSize(); XRCCTRL(*this, "ID_MATCHTYPE", wxChoice)->SetSelection(filter.matchType); SetFilterCtrlState(false); }
void ShowHelpDialog(BOOL about) { int a = about ? 1 : 0; if(HelpWindowOpen[a]) { SetForegroundWindow(HelpDialog[a]); return; } MakeClass(); char *s = about ? "About LDmicro" : "LDmicro Help"; HelpDialog[a] = CreateWindowEx(0, "LDmicroHelp", s, WS_OVERLAPPED | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_SIZEBOX, 100, 100, 650, 300+10*FONT_HEIGHT, NULL, NULL, Instance, NULL); MakeControls(a); ShowWindow(HelpDialog[a], TRUE); SetFocus(RichEdit[a]); HelpWindowOpen[a] = TRUE; RECT r; GetClientRect(HelpDialog[a], &r); TitleHeight = 300 - r.bottom; GetWindowRect(HelpDialog[a], &r); Resizing(&r, WMSZ_TOP); SetWindowPos(HelpDialog[a], HWND_TOP, r.left, r.top, r.right - r.left, r.bottom - r.top, 0); }
void CFilterConditionsDialog::OnFilterTypeChange(wxCommandEvent& event) { int item; for (item = 0; item < (int)m_filterControls.size(); item++) { if (!m_filterControls[item].pType || m_filterControls[item].pType->GetId() != event.GetId()) continue; break; } if (item == (int)m_filterControls.size()) return; CFilterCondition& filter = m_currentFilter.filters[item]; t_filterType type = GetTypeFromTypeSelection(event.GetSelection()); if (type == filter.type) return; filter.type = type; if (filter.type == filter_size && filter.condition > 3) filter.condition = 0; else if (filter.type == filter_date && filter.condition > 3) filter.condition = 0; delete m_filterControls[item].pCondition; m_filterControls[item].pCondition = 0; MakeControls(filter, item); }
void CFilterConditionsDialog::OnMore() { wxPoint pos = m_pAdd->GetPosition(); pos.y += m_choiceBoxHeight + 6; m_pAdd->SetPosition(pos); CFilterCondition cond; m_currentFilter.filters.push_back(cond); MakeControls(cond); m_pListCtrl->SetLineCount(m_filterControls.size() + 1); UpdateConditionsClientSize(); }
void ShowCommentDialog(char *comment) { RECT r; GetClientRect(MainWindow, &r); CommentDialog = CreateWindowClient(0, "LDmicroDialog", _("Comment"), WS_OVERLAPPED | WS_SYSMENU, r.left+20, 100, r.right-r.left-40, 65, NULL, NULL, Instance, NULL); MakeControls(r); SendMessage(CommentTextbox, WM_SETTEXT, 0, (LPARAM)comment); EnableWindow(MainWindow, FALSE); ShowWindow(CommentDialog, TRUE); SetFocus(CommentTextbox); SendMessage(CommentTextbox, EM_SETSEL, 0, -1); MSG msg; DWORD ret; DialogDone = FALSE; DialogCancel = FALSE; while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { if(msg.message == WM_KEYDOWN) { if(msg.wParam == VK_TAB && GetFocus() == CommentTextbox) { SetFocus(OkButton); continue; } else if(msg.wParam == VK_ESCAPE) { DialogDone = TRUE; DialogCancel = TRUE; break; } } if(IsDialogMessage(CommentDialog, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(!DialogCancel) { SendMessage(CommentTextbox, WM_GETTEXT, (WPARAM)(MAX_COMMENT_LEN-1), (LPARAM)comment); } EnableWindow(MainWindow, TRUE); DestroyWindow(CommentDialog); return; }
void CFilterConditionsDialog::OnMore() { wxPoint pos = m_pAdd->GetPosition(); pos.y += m_choiceBoxHeight + 6; m_pAdd->SetPosition(pos); CFilterCondition cond; m_currentFilter.filters.push_back(cond); MakeControls(cond); CFilterControls& controls = m_filterControls.back(); m_pAdd->MoveAfterInTabOrder(controls.pSet ? (wxWindow*)controls.pSet : (wxWindow*)controls.pValue); m_pListCtrl->SetLineCount(m_filterControls.size() + 1); UpdateConditionsClientSize(); }
void ShowIoDialog(int item) { if(!Prog.mcu) { MessageBox(MainWindow, _("No microcontroller has been selected. You must select a " "microcontroller before you can assign I/O pins.\r\n\r\n" "Select a microcontroller under the Settings menu and try " "again."), _("I/O Pin Assignment"), MB_OK | MB_ICONWARNING); return; } if(Prog.mcu->whichIsa == ISA_ANSIC) { Error(_("Can't specify I/O assignment for ANSI C target; compile and " "see comments in generated source code.")); return; } if(Prog.mcu->whichIsa == ISA_INTERPRETED) { Error(_("Can't specify I/O assignment for interpretable target; see " "comments in reference implementation of interpreter.")); return; } if(Prog.io.assignment[item].name[0] != 'X' && Prog.io.assignment[item].name[0] != 'Y' && Prog.io.assignment[item].name[0] != 'A') { Error(_("Can only assign pin number to input/output pins (Xname or " "Yname or Aname).")); return; } if(Prog.io.assignment[item].name[0] == 'A' && Prog.mcu->adcCount == 0) { Error(_("No ADC or ADC not supported for this micro.")); return; } if(strcmp(Prog.io.assignment[item].name+1, "new")==0) { Error(_("Rename I/O from default name ('%s') before assigning " "MCU pin."), Prog.io.assignment[item].name); return; } MakeWindowClass(); // We need the TOOLWINDOW style, or else the window will be forced to // a minimum width greater than our current width. And without the // APPWINDOW style, it becomes impossible to get the window back (by // Alt+Tab or taskbar). IoDialog = CreateWindowClient(WS_EX_TOOLWINDOW | WS_EX_APPWINDOW, "LDmicroIo", _("I/O Pin"), WS_OVERLAPPED | WS_SYSMENU, 100, 100, 107, 387, NULL, NULL, Instance, NULL); MakeControls(); SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)_("(no pin)")); int i; for(i = 0; i < Prog.mcu->pinCount; i++) { int j; for(j = 0; j < Prog.io.count; j++) { if(j == item) continue; if(Prog.io.assignment[j].pin == Prog.mcu->pinInfo[i].pin) { goto cant_use_this_io; } } if(UartFunctionUsed() && Prog.mcu && ((Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.rxPin) || (Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.txPin))) { goto cant_use_this_io; } if(PwmFunctionUsed() && Prog.mcu->pinInfo[i].pin == Prog.mcu->pwmNeedsPin) { goto cant_use_this_io; } if(Prog.io.assignment[item].name[0] == 'A') { for(j = 0; j < Prog.mcu->adcCount; j++) { if(Prog.mcu->adcInfo[j].pin == Prog.mcu->pinInfo[i].pin) { // okay; we know how to connect it up to the ADC break; } } if(j == Prog.mcu->adcCount) { goto cant_use_this_io; } } char buf[40]; if(Prog.mcu->pinCount <= 21) { sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, Prog.mcu->pinInfo[i].bit); } else { sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, Prog.mcu->pinInfo[i].bit); } SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)buf); cant_use_this_io:; } EnableWindow(MainWindow, FALSE); ShowWindow(IoDialog, TRUE); SetFocus(PinList); MSG msg; DWORD ret; DialogDone = FALSE; DialogCancel = FALSE; while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { if(msg.message == WM_KEYDOWN) { if(msg.wParam == VK_RETURN) { DialogDone = TRUE; break; } else if(msg.wParam == VK_ESCAPE) { DialogDone = TRUE; DialogCancel = TRUE; break; } } if(IsDialogMessage(IoDialog, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(!DialogCancel) { int sel = SendMessage(PinList, LB_GETCURSEL, 0, 0); char pin[16]; SendMessage(PinList, LB_GETTEXT, (WPARAM)sel, (LPARAM)pin); if(strcmp(pin, _("(no pin)"))==0) { int i; for(i = 0; i < IoSeenPreviouslyCount; i++) { if(strcmp(IoSeenPreviously[i].name, Prog.io.assignment[item].name)==0) { IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; } } Prog.io.assignment[item].pin = NO_PIN_ASSIGNED; } else { Prog.io.assignment[item].pin = atoi(pin); // Only one name can be bound to each pin; make sure that there's // not another entry for this pin in the IoSeenPreviously list, // that might get used if the user creates a new pin with that // name. int i; for(i = 0; i < IoSeenPreviouslyCount; i++) { if(IoSeenPreviously[i].pin == atoi(pin)) { IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; } } } } EnableWindow(MainWindow, TRUE); DestroyWindow(IoDialog); return; }
BOOL ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask, DWORD alnumOnlyMask, DWORD fixedFontMask, char **dests) { BOOL didCancel; if(boxes > MAX_BOXES) oops(); SimpleDialog = CreateWindowClient(0, "LDmicroDialog", title, WS_OVERLAPPED | WS_SYSMENU, 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), NULL, NULL, Instance, NULL); MakeControls(boxes, labels, fixedFontMask); int i; for(i = 0; i < boxes; i++) { SendMessage(Textboxes[i], WM_SETTEXT, 0, (LPARAM)dests[i]); if(numOnlyMask & (1 << i)) { PrevNumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC, (LONG_PTR)MyNumOnlyProc); } if(alnumOnlyMask & (1 << i)) { PrevAlnumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC, (LONG_PTR)MyAlnumOnlyProc); } } EnableWindow(MainWindow, FALSE); ShowWindow(SimpleDialog, TRUE); SetFocus(Textboxes[0]); SendMessage(Textboxes[0], EM_SETSEL, 0, -1); MSG msg; DWORD ret; DialogDone = FALSE; DialogCancel = FALSE; while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { if(msg.message == WM_KEYDOWN) { if(msg.wParam == VK_RETURN) { DialogDone = TRUE; break; } else if(msg.wParam == VK_ESCAPE) { DialogDone = TRUE; DialogCancel = TRUE; break; } } if(IsDialogMessage(SimpleDialog, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } didCancel = DialogCancel; if(!didCancel) { for(i = 0; i < boxes; i++) { if(NoCheckingOnBox[i]) { char get[64]; SendMessage(Textboxes[i], WM_GETTEXT, 60, (LPARAM)get); strcpy(dests[i], get); } else { char get[20]; SendMessage(Textboxes[i], WM_GETTEXT, 15, (LPARAM)get); if( (!strchr(get, '\'')) || (get[0] == '\'' && get[2] == '\'' && strlen(get)==3) ) { if(strlen(get) == 0) { Error(_("Empty textbox; not permitted.")); } else { strcpy(dests[i], get); } } else { Error(_("Bad use of quotes: <%s>"), get); } } } } EnableWindow(MainWindow, TRUE); DestroyWindow(SimpleDialog); return !didCancel; }
void CGoodsDetailsHook::MakeGUI() { FetchWithBinary(); MakeNames(); MakeControls(); }
void ShowConfDialog(void) { // The window's height will be resized later, to fit the explanation text. ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"), WS_OVERLAPPED | WS_SYSMENU, 100, 100, 0, 0, NULL, NULL, Instance, NULL); MakeControls(); char buf[16]; sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0)); SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf); sprintf(buf, "%.6f", Prog.mcuClock / 1e6); SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf); sprintf(buf, "%d", Prog.baudRate); SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf); EnableWindow(MainWindow, FALSE); ShowWindow(ConfDialog, TRUE); SetFocus(CycleTextbox); MSG msg; DWORD ret; DialogDone = FALSE; DialogCancel = FALSE; while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { if(msg.message == WM_KEYDOWN) { if(msg.wParam == VK_RETURN) { DialogDone = TRUE; break; } else if(msg.wParam == VK_ESCAPE) { DialogDone = TRUE; DialogCancel = TRUE; break; } } if(IsDialogMessage(ConfDialog, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(!DialogCancel) { char buf[16]; SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), (LPARAM)(buf)); Prog.cycleTime = (int)(1000*atof(buf) + 0.5); if(Prog.cycleTime == 0) { Error(_("Zero cycle time not valid; resetting to 10 ms.")); Prog.cycleTime = 10000; } SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), (LPARAM)(buf)); Prog.mcuClock = (int)(1e6*atof(buf) + 0.5); SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), (LPARAM)(buf)); Prog.baudRate = atoi(buf); } EnableWindow(MainWindow, TRUE); DestroyWindow(ConfDialog); return; }
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, BOOL *ttrigger, char *name) { char nameSave[MAX_NAME_LEN]; strcpy(nameSave, name); CoilDialog = CreateWindowClient(0, "LDmicroDialog", _("Coil"), WS_OVERLAPPED | WS_SYSMENU, 100, 100, 375, 135, NULL, NULL, Instance, NULL); RECT r; GetClientRect(CoilDialog, &r); MakeControls(); switch (name[0]) { case 'R': SendMessage(SourceInternalRelayRadio, BM_SETCHECK, BST_CHECKED, 0); break; case 'Y': SendMessage(SourceMcuPinRadio, BM_SETCHECK, BST_CHECKED, 0); break; case 'M': SendMessage(SourceModbusRadio, BM_SETCHECK, BST_CHECKED, 0); break; default: oops(); break; } SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1)); if(*negated) { SendMessage(NegatedRadio, BM_SETCHECK, BST_CHECKED, 0); } else if(*setOnly) { SendMessage(SetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0); } else if(*resetOnly) { SendMessage(ResetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0); } else if(*ttrigger) { SendMessage(TtriggerRadio, BM_SETCHECK, BST_CHECKED, 0); } else { SendMessage(NormalRadio, BM_SETCHECK, BST_CHECKED, 0); } EnableWindow(MainWindow, FALSE); ShowWindow(CoilDialog, TRUE); SetFocus(NameTextbox); SendMessage(NameTextbox, EM_SETSEL, 0, -1); MSG msg; DWORD ret; DialogDone = FALSE; DialogCancel = FALSE; while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { if(msg.message == WM_KEYDOWN) { if(msg.wParam == VK_RETURN) { DialogDone = TRUE; break; } else if(msg.wParam == VK_ESCAPE) { DialogDone = TRUE; DialogCancel = TRUE; break; } } if(IsDialogMessage(CoilDialog, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(!DialogCancel) { if(SendMessage(SourceInternalRelayRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { name[0] = 'R'; } else if (SendMessage(SourceModbusRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { name[0] = 'M'; } else { name[0] = 'Y'; } SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)(MAX_NAME_LEN-1), (LPARAM)(name+1)); if(SendMessage(NormalRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { *negated = FALSE; *setOnly = FALSE; *resetOnly = FALSE; *ttrigger = FALSE; } else if(SendMessage(NegatedRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { *negated = TRUE; *setOnly = FALSE; *resetOnly = FALSE; *ttrigger = FALSE; } else if(SendMessage(SetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { *negated = FALSE; *setOnly = TRUE; *resetOnly = FALSE; *ttrigger = FALSE; } else if(SendMessage(ResetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { *negated = FALSE; *setOnly = FALSE; *resetOnly = TRUE; *ttrigger = FALSE; } else if(SendMessage(TtriggerRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) { *negated = FALSE; *setOnly = FALSE; *resetOnly = FALSE; *ttrigger = TRUE; } if(strcmp(name, nameSave)) { int n = CountWhich(ELEM_CONTACTS, ELEM_COIL, nameSave); if(n >= 1) { BOOL rename = FALSE; char str[1000]; sprintf(str, _("Rename the ALL other %d coils/contacts named '%s' to '%s' ?"), n, nameSave, name); rename = IDYES == MessageBox(MainWindow, str, "LDmicro", MB_YESNO | MB_ICONQUESTION); if(rename) RenameSet1(ELEM_COIL, nameSave, name, FALSE); // rename and reset } } } EnableWindow(MainWindow, TRUE); DestroyWindow(CoilDialog); return; }