MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / processString

Method processString

src/ui/alert.cpp:130–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void 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;

Callers 2

createMethod · 0.80
showMethod · 0.80

Calls 13

guiscaleFunction · 0.85
setMinSizeMethod · 0.80
setExpansiveMethod · 0.80
addChildMethod · 0.80
addChildInCellMethod · 0.80
setFocusMagnetMethod · 0.80
setAlignMethod · 0.45
sizeMethod · 0.45
setIdMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected