| 128 | } |
| 129 | |
| 130 | void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<Widget*>& buttons) |
| 131 | { |
| 132 | Box* box1, *box2, *box3, *box4, *box5; |
| 133 | Grid* grid; |
| 134 | bool title = true; |
| 135 | bool label = false; |
| 136 | bool separator = false; |
| 137 | bool button = false; |
| 138 | int align = 0; |
| 139 | char *beg; |
| 140 | int c, chr; |
| 141 | |
| 142 | // Process buffer |
| 143 | c = 0; |
| 144 | beg = buf; |
| 145 | for (; ; c++) { |
| 146 | if ((!buf[c]) || |
| 147 | ((buf[c] == buf[c+1]) && |
| 148 | ((buf[c] == '<') || |
| 149 | (buf[c] == '=') || |
| 150 | (buf[c] == '>') || |
| 151 | (buf[c] == '-') || |
| 152 | (buf[c] == '|')))) { |
| 153 | if (title || label || separator || button) { |
| 154 | chr = buf[c]; |
| 155 | buf[c] = 0; |
| 156 | |
| 157 | if (title) { |
| 158 | setText(beg); |
| 159 | } |
| 160 | else if (label) { |
| 161 | Label* label = new Label(beg); |
| 162 | label->setAlign(align); |
| 163 | labels.push_back(label); |
| 164 | } |
| 165 | else if (separator) { |
| 166 | labels.push_back(new Separator("", HORIZONTAL)); |
| 167 | } |
| 168 | else if (button) { |
| 169 | char buttonId[256]; |
| 170 | Button* button_widget = new Button(beg); |
| 171 | button_widget->setMinSize(gfx::Size(60*guiscale(), 0)); |
| 172 | buttons.push_back(button_widget); |
| 173 | |
| 174 | snprintf(buttonId, sizeof(buttonId), "button-%lu", buttons.size()); |
| 175 | button_widget->setId(buttonId); |
| 176 | button_widget->Click.connect(base::Bind<void>(&Window::closeWindow, this, button_widget)); |
| 177 | } |
| 178 | |
| 179 | buf[c] = chr; |
| 180 | } |
| 181 | |
| 182 | /* done */ |
| 183 | if (!buf[c]) |
| 184 | break; |
| 185 | /* next widget */ |
| 186 | else { |
| 187 | title = label = separator = button = false; |
no test coverage detected