| 5209 | |
| 5210 | |
| 5211 | ResultType GuiType::ControlParseOptions(LPTSTR aOptions, GuiControlOptionsType &aOpt, GuiControlType &aControl |
| 5212 | , GuiIndexType aControlIndex) |
| 5213 | // Caller must have already initialized aOpt with zeroes or any other desired starting values. |
| 5214 | // Caller must ensure that aOptions is a modifiable string, since this method temporarily alters it. |
| 5215 | { |
| 5216 | // If control type uses aControl's union for something other than color, communicate the chosen color |
| 5217 | // back through a means that doesn't corrupt the union: |
| 5218 | LPTSTR next_option, option_end; |
| 5219 | LPTSTR error_message; // Used by "return_error:" when aControl.hwnd == NULL. |
| 5220 | TCHAR orig_char; |
| 5221 | bool adding; // Whether this option is being added (+) or removed (-). |
| 5222 | GuiControlType *tab_control; |
| 5223 | RECT rect; |
| 5224 | POINT pt; |
| 5225 | bool do_invalidate_rect = false; // Set default. |
| 5226 | |
| 5227 | for (next_option = aOptions; *next_option; next_option = omit_leading_whitespace(option_end)) |
| 5228 | { |
| 5229 | if (*next_option == '-') |
| 5230 | { |
| 5231 | adding = false; |
| 5232 | // omit_leading_whitespace() is not called, which enforces the fact that the option word must |
| 5233 | // immediately follow the +/- sign. This is done to allow the flexibility to have options |
| 5234 | // omit the plus/minus sign, and also to reserve more flexibility for future option formats. |
| 5235 | ++next_option; // Point it to the option word itself. |
| 5236 | } |
| 5237 | else |
| 5238 | { |
| 5239 | // Assume option is being added in the absence of either sign. However, when we were |
| 5240 | // called by GuiControl(), the first option in the list must begin with +/- otherwise the cmd |
| 5241 | // would never have been properly detected as GUICONTROL_CMD_OPTIONS in the first place. |
| 5242 | adding = true; |
| 5243 | if (*next_option == '+') |
| 5244 | ++next_option; // Point it to the option word itself. |
| 5245 | //else do not increment, under the assumption that the plus has been omitted from a valid |
| 5246 | // option word and is thus an implicit plus. |
| 5247 | } |
| 5248 | |
| 5249 | if (!*next_option) // In case the entire option string ends in a naked + or -. |
| 5250 | break; |
| 5251 | // Find the end of this option item: |
| 5252 | if ( !(option_end = StrChrAny(next_option, _T(" \t"))) ) // Space or tab. |
| 5253 | option_end = next_option + _tcslen(next_option); // Set to position of zero terminator instead. |
| 5254 | if (option_end == next_option) |
| 5255 | continue; // i.e. the string contains a + or - with a space or tab after it, which is intentionally ignored. |
| 5256 | |
| 5257 | // Temporarily terminate to help eliminate ambiguity for words contained inside other words, |
| 5258 | // such as "Checked" inside of "CheckedGray": |
| 5259 | orig_char = *option_end; |
| 5260 | *option_end = '\0'; |
| 5261 | |
| 5262 | // Attributes: |
| 5263 | if (!_tcsicmp(next_option, _T("Section"))) // Adding and removing are treated the same in this case. |
| 5264 | aOpt.start_new_section = true; // Ignored by caller when control already exists. |
| 5265 | else if (!_tcsicmp(next_option, _T("AltSubmit")) && aControl.type != GUI_CONTROL_EDIT) |
| 5266 | { |
| 5267 | // v1.0.44: Don't allow control's AltSubmit bit to be set unless it's valid option for |
| 5268 | // that type. This protects the GUI_CONTROL_ATTRIB_ALTSUBMIT bit from being corrupted |
no test coverage detected