| 1 | = !HideItem = |
| 2 | |
| 3 | {{{ |
| 4 | CFormItem* CForm::HideItem(const char* name, bool updateDisplay = true) |
| 5 | }}} |
| 6 | |
| 7 | == Parameters == |
| 8 | |
| 9 | * name = The button title or input prompt text |
| 10 | * updateDisplay = (optional parameter, true if not included) true to update the display, false do not update the display |
| 11 | |
| 12 | == Return Value == |
| 13 | |
| 14 | The !ShowItem function returns a pointer to the CFormItem found based on the provided name value; NULL is returned if no item is found with a matching name value. |
| 15 | |
| 16 | == Remarks == |
| 17 | |
| 18 | ShowItem is a wrapper for EnableItem to simply code. It is equivalent to EnableItem(name, false, updateDisplay) |
| 19 | |
| 20 | == Example == |
| 21 | |
| 22 | {{{ |
| 23 | void UpdateLocalRemoteForm(CForm *pForm) |
| 24 | { |
| 25 | int mode = 0; |
| 26 | int type = 0; |
| 27 | |
| 28 | CFormInput *pMode = (CFormInput*)pForm->FindName(LANG(STR_LOCREM_MODE_PROMPT)); |
| 29 | if(pMode != NULL) |
| 30 | { |
| 31 | mode = pMode->GetSelItem(); |
| 32 | } |
| 33 | CFormInput *pType = (CFormInput*)pForm->FindName(LANG(STR_LOCREM_COMMTYPE_PROMPT)); |
| 34 | if(pType != NULL) |
| 35 | { |
| 36 | type = pType->GetSelItem(); |
| 37 | } |
| 38 | |
| 39 | // Must do hide items first to allow for conditional items to be at the same place |
| 40 | // in the form otherwise we might show a condition item and then blank it out |
| 41 | |
| 42 | if(mode == MODE_OFF) |
| 43 | { |
| 44 | pForm->HideItem(LANG(STR_LOCREM_COMMTYPE_PROMPT)); |
| 45 | pForm->HideItem(LANG(STR_LOCREM_PORT_PROMPT)); |
| 46 | pForm->HideItem(LANG(STR_LOCREM_IPADDR_PROMPT)); |
| 47 | pForm->HideItem(LANG(STR_LOCREM_COMMPORT_PROMPT)); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | if(type == SERIAL) |
| 52 | { |
| 53 | pForm->HideItem(LANG(STR_LOCREM_IPADDR_PROMPT)); |
| 54 | pForm->HideItem(LANG(STR_LOCREM_PORT_PROMPT)); |
| 55 | |
| 56 | pForm->ShowItem(LANG(STR_LOCREM_COMMPORT_PROMPT)); |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | pForm->HideItem(LANG(STR_LOCREM_COMMPORT_PROMPT)); |
| 61 | |
| 62 | if(mode == MODE_REMOTE || mode == MODE_REMOTE_SMA) |
| 63 | { |
| 64 | pForm->ShowItem(LANG(STR_LOCREM_IPADDR_PROMPT)); |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | pForm->HideItem(LANG(STR_LOCREM_IPADDR_PROMPT)); |
| 69 | } |
| 70 | pForm->ShowItem(LANG(STR_LOCREM_PORT_PROMPT)); |
| 71 | } |
| 72 | pForm->ShowItem(LANG(STR_LOCREM_COMMTYPE_PROMPT)); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | int CLocalRemote::Config(void) |
| 77 | { |
| 78 | |
| 79 | Shutdown(); |
| 80 | |
| 81 | uint8 byMode = (uint8) GetMode(); |
| 82 | commType = (uint8) GetCommType(); |
| 83 | commPort = (uint8) GetCommPort(); |
| 84 | FORM_INIT(CfgLR, EventLocalRemoteShow, NULL, NULL, NULL, nFormFlgShowHelp); |
| 85 | |
| 86 | FORM_ADD_INPUT(CfgLR, Mode, FONT_WIDTH * 0, FONT_HEIGHT * 2, LANG(STR_LOCREM_MODE_PROMPT), 10, 0, 2, EventModeOrTypeChg, &byMode, FORM_UINT8_SEL, LANG(STR_LOCREM_MODE_CHOICES), LANG(STR_LOCREM_MODE_HELP)); |
| 87 | FORM_ADD_INPUT(CfgLR, Type, FONT_WIDTH * 0, FONT_HEIGHT * 4, LANG(STR_LOCREM_COMMTYPE_PROMPT), 10, 0, 1, EventModeOrTypeChg, &commType, FORM_UINT8_SEL | FORM_FLAG_DISABLE, LANG(STR_LOCREM_TYPE_CHOICES), LANG(STR_LOCREM_COMMTYPE_HELP)); |
| 88 | FORM_ADD_INPUT(CfgLR, ComP, 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) ); |
| 89 | 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)); |
| 90 | 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)); |
| 91 | |
| 92 | FORM_SHOW(CfgLR); |
| 93 | |
| 94 | UpdateLocalRemoteForm(&formCfgLR); |
| 95 | |
| 96 | int result = FORM_RUN(CfgLR); |
| 97 | FORM_HIDE(CfgLR); |
| 98 | |
| 99 | if (result != FORM_RESULT_ESC) |
| 100 | { |
| 101 | SetMode((LocalRemoteMode) byMode); |
| 102 | SetComType((LocalRemoteComm) commType); |
| 103 | SetComPort((LocalRemotePort) commPort); |
| 104 | |
| 105 | appCfg.Write(); |
| 106 | } |
| 107 | |
| 108 | Startup(); |
| 109 | |
| 110 | return result; |
| 111 | } |
| 112 | |
| 113 | EVENT(ModeOrTypeChg) |
| 114 | { |
| 115 | UpdateLocalRemoteForm(pForm); |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | EVENT(LocalRemoteShow) |
| 120 | { |
| 121 | ClearLCD(); |
| 122 | SetCurColor(COLOR_ATTENTION); |
| 123 | DisplayText(0, 0, LANG(STR_LOCREM_TITLE)); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | }}} |
| 129 | |
| 130 | |
| 131 | === See Also === |
| 132 | |
| 133 | * [wiki:ShowItem ShowItem] |
| 134 | * [wiki:EnableItem EnableItem] |
| 135 | |
| 136 | |