1 #ifdef BUILDING_ECERE_COM
2 namespace gui::controls;
7 public import static "ecere"
15 public class NamedString : struct
28 public class StringsBox : CommonControl
32 watch(foreground) { list.foreground = foreground; };
33 watch(background) { list.background = background; };
36 property Array<String> strings
45 char temp[MAX_LOCATION];
50 list.currentRow = list.firstRow;
51 list.modifiedDocument = false;
55 Array<String> array { };
57 for(row = list.firstRow; row; row = row.next)
59 String string = row.string;
60 if(string && string[0])
61 array.Add(CopyUnixPath(string));
67 virtual bool Window::NotifyModified(StringsBox dirsBox);
69 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
73 list.StopEditing(true);
74 if(list.modifiedDocument)
76 NotifyModified(master, this);
77 list.modifiedDocument = false;
78 modifiedDocument = true;
86 parent = this, bevelOver = true, inactive = true;
87 position = { 265, 0 }, size = { 22, 22 };
88 anchor = { top = 0, right = 77 };
89 hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
90 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
92 list.StopEditing(true);
93 list.lastRow.Edit(null);
94 //list.modifiedDocument = true;
100 parent = this, bevelOver = true, inactive = true;
101 position = { 290, 0 }, size = { 22, 22 };
102 anchor = { top = 0, right = 54 };
103 hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
104 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
106 list.StopEditing(true);
107 if(list.currentRow != list.lastRow)
109 list.DeleteRow(null);
110 //list.modifiedDocument = true;
117 parent = this, bevelOver = true, inactive = true;
118 position = { 315, 0 }, size = { 22, 22 };
119 anchor = { top = 0, right = 31 };
120 hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
121 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
123 if(list.currentRow != list.lastRow)
125 DataRow current = list.currentRow, row;
128 row = current.previous;
133 //list.modifiedDocument = true;
142 parent = this, bevelOver = true, inactive = true;
143 position = { 340, 0 }, size = { 22, 22 };
144 anchor = { top = 0, right = 8 };
145 hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
146 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
148 DataRow current = list.currentRow, row;
152 if(row && row != list.lastRow)
160 this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
161 borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
162 anchor = { left = 0, top = 22, right = 0, bottom = 0 };
164 bool OnRightButtonDown(int x, int y, Modifiers mods)
166 return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
169 bool NotifyChanged(ListBox listBox, DataRow row)
171 char * string = listBox.GetData(null);
172 if(string && string[0])
174 if(listBox.currentRow == listBox.lastRow)
176 DataRow r = listBox.lastRow;
178 listBox.currentRow = listBox.AddString("");
181 else if(listBox.currentRow != listBox.lastRow)
182 listBox.DeleteRow(null);
183 //listBox.modifiedDocument = true;
187 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
191 listBox.StopEditing(true);
192 if(listBox.currentRow != listBox.lastRow)
193 listBox.DeleteRow(null);
199 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
201 if(listBox.currentRow == listBox.lastRow)
203 else if(row == listBox.lastRow)
205 listBox.currentRow.Move(row.previous);
211 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
217 DataField stringField { dataType = class(char *), editable = true };
220 list.AddField(stringField);
222 list.modifiedDocument = false;
226 class NamedStringsBox : CommonControl
230 watch(foreground) { list.foreground = foreground; };
231 watch(background) { list.background = background; };
233 property Array<NamedString> namedStrings
243 char temp[MAX_LOCATION];
245 row.SetData(nameField, s.name);
246 row.SetData(stringField, s.string);
250 //row.SetData(nameField, null);
251 //row.SetData(stringField, null);
252 list.currentRow = list.firstRow;
253 list.modifiedDocument = false;
257 Array<NamedString> array { };
260 for(row = list.firstRow; row; row = row.next)
262 //String string = row.string;
263 s.name = row.GetData(nameField);
264 s.string = row.GetData(stringField);
265 if(s.name && s.name[0] && s.string && s.string[0])
272 virtual bool Window::NotifyModified(NamedStringsBox stringsBox);
274 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
278 list.StopEditing(true);
279 if(list.modifiedDocument)
281 NotifyModified(master, this);
282 list.modifiedDocument = false;
283 modifiedDocument = true;
291 parent = this, bevelOver = true, inactive = true;
292 position = { 265, 0 }, size = { 22, 22 };
293 anchor = { top = 0, right = 77 };
294 hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
295 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
297 list.StopEditing(true);
298 list.lastRow.Edit(null);
304 parent = this, bevelOver = true, inactive = true;
305 position = { 290, 0 }, size = { 22, 22 };
306 anchor = { top = 0, right = 54 };
307 hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
308 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
310 list.StopEditing(true);
311 if(list.currentRow != list.lastRow)
312 list.DeleteRow(null);
318 parent = this, bevelOver = true, inactive = true;
319 position = { 315, 0 }, size = { 22, 22 };
320 anchor = { top = 0, right = 31 };
321 hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
322 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
324 if(list.currentRow != list.lastRow)
326 DataRow current = list.currentRow, row;
329 row = current.previous;
342 parent = this, bevelOver = true, inactive = true;
343 position = { 340, 0 }, size = { 22, 22 };
344 anchor = { top = 0, right = 8 };
345 hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
346 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
348 DataRow current = list.currentRow, row;
352 if(row && row != list.lastRow)
360 this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
361 borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
362 anchor = { left = 0, top = 22, right = 0, bottom = 0 };
364 bool OnRightButtonDown(int x, int y, Modifiers mods)
366 return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
369 bool NotifyChanged(ListBox listBox, DataRow row)
372 s.name = row.GetData(nameField);
373 s.string = row.GetData(stringField);
374 if((s.name && s.name[0]) || (s.string && s.string[0]))
376 if(listBox.currentRow == listBox.lastRow)
378 DataRow r = listBox.lastRow;
380 listBox.currentRow = list.AddRow();
381 //row.SetData(nameField, null);
382 //row.SetData(stringField, null);
385 else if((!s.name || s.name[0]) && (!s.string || !s.string[0]) && listBox.currentRow != listBox.lastRow)
386 listBox.DeleteRow(null);
387 listBox.modifiedDocument = true;
391 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
395 listBox.StopEditing(true);
396 if(listBox.currentRow != listBox.lastRow)
397 listBox.DeleteRow(null);
403 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
405 if(listBox.currentRow == listBox.lastRow)
407 else if(row == listBox.lastRow)
409 listBox.currentRow.Move(row.previous);
415 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
421 DataField nameField { dataType = class(char *), editable = true, freeData = false, width = 120 };
422 DataField stringField { dataType = class(char *), editable = true, freeData = false };
427 list.AddField(nameField);
428 list.AddField(stringField);
429 /*row = */list.AddRow();
430 //row.SetData(nameField, null);
431 //row.SetData(stringField, null);
432 list.modifiedDocument = false;