= CForm = C++ class the provides form features. Most applications may use the helper macros FORM_INIT, FORM_ADD_INPUT, FORM_ADD_BUTTON, FORM_SHOW, FORM_RUN, FORM_HIDE, and EVENT to prevent having to work with CForm items directly. == Methods == === EnableItem === CFormItem* EnableItem(const char* pszName, bool enable, bool show) ==== Remarks ==== Allows conditionally showing or items items on a form. ==== Example ==== {{{ void UpdateLocalRemoteForm(CForm *pForm) { int mode = 0; int type = 0; vector hideItems; vector showItems; CFormInput *pMode = (CFormInput*)pForm->FindName(LANG(STR_LOCREM_MODE_PROMPT)); if(pMode != NULL) { mode = pMode->GetSelItem(); } CFormInput *pType = (CFormInput*)pForm->FindName(LANG(STR_LOCREM_COMMTYPE_PROMPT)); if(pType != NULL) { type = pType->GetSelItem(); } if(mode == MODE_OFF) { hideItems.push_back(LANG(STR_LOCREM_COMMTYPE_PROMPT)); hideItems.push_back(LANG(STR_LOCREM_PORT_PROMPT)); hideItems.push_back(LANG(STR_LOCREM_IPADDR_PROMPT)); hideItems.push_back(LANG(STR_LOCREM_COMMPORT_PROMPT)); } else { showItems.push_back(LANG(STR_LOCREM_COMMTYPE_PROMPT)); if(type == SERIAL) { showItems.push_back(LANG(STR_LOCREM_COMMPORT_PROMPT)); hideItems.push_back(LANG(STR_LOCREM_IPADDR_PROMPT)); hideItems.push_back(LANG(STR_LOCREM_PORT_PROMPT)); } else { hideItems.push_back(LANG(STR_LOCREM_COMMPORT_PROMPT)); showItems.push_back(LANG(STR_LOCREM_PORT_PROMPT)); if(mode == MODE_REMOTE) { showItems.push_back(LANG(STR_LOCREM_IPADDR_PROMPT)); } else { hideItems.push_back(LANG(STR_LOCREM_IPADDR_PROMPT)); } } } // Hide items first to allow for conditional items to be at the same place in the form // Otherwise we might show a condition item and then blank it out size_t n; for(n = 0; n < hideItems.size(); n++) { pForm->EnableItem(hideItems[n], false, true); } for(n = 0; n < showItems.size(); n++) { pForm->EnableItem(showItems[n], true, true); } } int CLocalRemote::Config(void) { Shutdown(); uint8 byMode = (uint8) GetMode(); commType = (uint8) GetCommType(); commPort = (uint8) GetCommPort(); FORM_INIT(CfgLR, EventLocalRemoteShow, NULL, NULL, NULL, nFormFlgShowHelp); FORM_ADD_INPUT(CfgLR, Mode, FONT_WIDTH * 0, FONT_HEIGHT * 2, LANG(STR_LOCREM_MODE_PROMPT), 10, 0, 2, EventModeChanged, &byMode, FORM_UINT8_SEL, LANG(STR_LOCREM_MODE_CHOICES), LANG(STR_LOCREM_MODE_HELP)); FORM_ADD_INPUT(CfgLR, Comm, FONT_WIDTH * 0, FONT_HEIGHT * 4, LANG(STR_LOCREM_COMMTYPE_PROMPT), 10, 0, 1, EventModeChanged, &commType, FORM_UINT8_SEL | FORM_FLAG_DISABLE, LANG(STR_LOCREM_TYPE_CHOICES), LANG(STR_LOCREM_COMMTYPE_HELP)); FORM_ADD_INPUT(CfgLR, PortSerialMobile, FONT_WIDTH * 0, FONT_HEIGHT * 6, LANG(STR_LOCREM_COMMPORT_PROMPT), 10, 0, 1, NULL, &commPort, FORM_UINT8_SEL | FORM_FLAG_DISABLE, LANG(STR_LOCREM_COMPORT_CHOICES), LANG(STR_LOCREM_COMPORT_HELP) ); FORM_ADD_INPUT(CfgLR, Port, FONT_WIDTH * 0, FONT_HEIGHT * 6, LANG(STR_LOCREM_PORT_PROMPT), 6, 0, 65535, NULL, &GetPort(), FORM_UINT32 | FORM_FLAG_DISABLE, NULL, LANG(STR_LOCREM_PORT_HELP)); FORM_ADD_INPUT(CfgLR, IP, FONT_WIDTH * 0, FONT_HEIGHT * 8, LANG(STR_LOCREM_IPADDR_PROMPT) , 18, 0, 0, NULL, GetIP(), FORM_STR | FORM_FLAG_DISABLE, NULL, LANG(STR_LOCREM_IP_HELP)); FORM_SHOW(CfgLR); UpdateLocalRemoteForm(&formCfgLR); int result = FORM_RUN(CfgLR); FORM_HIDE(CfgLR); if (result != FORM_RESULT_ESC) { SetMode((LocalRemoteMode) byMode); SetComType((LocalRemoteComm) commType); SetComPort((LocalRemotePort) commPort); appCfg.Write(); } Startup(); return result; } EVENT(ModeChanged) { UpdateLocalRemoteForm(pForm); return 0; } EVENT(LocalRemoteShow) { ClearLCD(); SetCurColor(COLOR_ATTENTION); DisplayText(0, 0, LANG(STR_LOCREM_TITLE)); return 0; } }}}