1 #ifdef BUILDING_ECERE_COM
2 namespace gui::controls;
7 public import static "ecere"
15 public class NamedString : struct
18 property String name { set { delete name; name = CopyString(value); } get { return name; } }
19 property String string { set { delete string; string = CopyString(value); } get { return string; } }
31 public class StringsBox : CommonControl
35 watch(foreground) { list.foreground = foreground; };
36 watch(background) { list.background = background; };
39 property Array<String> strings
48 char temp[MAX_LOCATION];
53 list.currentRow = list.firstRow;
54 list.modifiedDocument = false;
58 Array<String> array { };
60 for(row = list.firstRow; row; row = row.next)
62 String string = row.string;
63 if(string && string[0])
64 array.Add(CopyUnixPath(string));
70 virtual bool Window::NotifyModified(StringsBox dirsBox);
72 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
76 list.StopEditing(true);
77 if(list.modifiedDocument)
79 NotifyModified(master, this);
80 list.modifiedDocument = false;
81 modifiedDocument = true;
89 parent = this, bevelOver = true, inactive = true;
90 position = { 265, 0 }, size = { 22, 22 };
91 anchor = { top = 0, right = 77 };
92 hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
93 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
95 list.StopEditing(true);
96 list.lastRow.Edit(null);
97 //list.modifiedDocument = true;
103 parent = this, bevelOver = true, inactive = true;
104 position = { 290, 0 }, size = { 22, 22 };
105 anchor = { top = 0, right = 54 };
106 hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
107 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
109 list.StopEditing(true);
110 if(list.currentRow != list.lastRow)
112 list.DeleteRow(null);
113 //list.modifiedDocument = true;
120 parent = this, bevelOver = true, inactive = true;
121 position = { 315, 0 }, size = { 22, 22 };
122 anchor = { top = 0, right = 31 };
123 hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
124 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
126 if(list.currentRow != list.lastRow)
128 DataRow current = list.currentRow, row;
131 row = current.previous;
136 //list.modifiedDocument = true;
145 parent = this, bevelOver = true, inactive = true;
146 position = { 340, 0 }, size = { 22, 22 };
147 anchor = { top = 0, right = 8 };
148 hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
149 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
151 DataRow current = list.currentRow, row;
155 if(row && row != list.lastRow)
163 this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
164 borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
165 anchor = { left = 0, top = 22, right = 0, bottom = 0 };
167 bool OnRightButtonDown(int x, int y, Modifiers mods)
169 return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
172 bool NotifyChanged(ListBox listBox, DataRow row)
174 char * string = listBox.GetData(null);
175 if(string && string[0])
177 if(listBox.currentRow == listBox.lastRow)
179 DataRow r = listBox.lastRow;
181 listBox.currentRow = listBox.AddString("");
184 else if(listBox.currentRow != listBox.lastRow)
185 listBox.DeleteRow(null);
186 //listBox.modifiedDocument = true;
190 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
194 listBox.StopEditing(true);
195 if(listBox.currentRow != listBox.lastRow)
196 listBox.DeleteRow(null);
202 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
204 if(listBox.currentRow == listBox.lastRow)
206 else if(row == listBox.lastRow)
208 listBox.currentRow.Move(row.previous);
214 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
220 DataField stringField { dataType = class(char *), editable = true };
223 list.AddField(stringField);
225 list.modifiedDocument = false;
229 class NamedStringsBox : CommonControl
233 watch(foreground) { list.foreground = foreground; };
234 watch(background) { list.background = background; };
236 property Array<NamedString> namedStrings
246 char temp[MAX_LOCATION];
248 row.SetData(nameField, s.name);
249 row.SetData(stringField, s.string);
253 //row.SetData(nameField, null);
254 //row.SetData(stringField, null);
255 list.currentRow = list.firstRow;
256 list.modifiedDocument = false;
260 Array<NamedString> array { };
262 for(row = list.firstRow; row; row = row.next)
264 // NamedString is a class:struct, need to instantiate!!
265 String name = row.GetData(nameField);
266 String string = row.GetData(stringField);
267 if(name && name[0] && string && string[0])
268 array.Add({ name, string });
274 virtual bool Window::NotifyModified(NamedStringsBox stringsBox);
276 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
280 list.StopEditing(true);
281 if(list.modifiedDocument)
283 NotifyModified(master, this);
284 list.modifiedDocument = false;
285 modifiedDocument = true;
293 parent = this, bevelOver = true, inactive = true;
294 position = { 265, 0 }, size = { 22, 22 };
295 anchor = { top = 0, right = 77 };
296 hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
297 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
299 list.StopEditing(true);
300 list.lastRow.Edit(null);
306 parent = this, bevelOver = true, inactive = true;
307 position = { 290, 0 }, size = { 22, 22 };
308 anchor = { top = 0, right = 54 };
309 hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
310 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
312 list.StopEditing(true);
313 if(list.currentRow != list.lastRow)
314 list.DeleteRow(null);
320 parent = this, bevelOver = true, inactive = true;
321 position = { 315, 0 }, size = { 22, 22 };
322 anchor = { top = 0, right = 31 };
323 hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
324 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
326 if(list.currentRow != list.lastRow)
328 DataRow current = list.currentRow, row;
331 row = current.previous;
344 parent = this, bevelOver = true, inactive = true;
345 position = { 340, 0 }, size = { 22, 22 };
346 anchor = { top = 0, right = 8 };
347 hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
348 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
350 DataRow current = list.currentRow, row;
354 if(row && row != list.lastRow)
362 this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
363 borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
364 anchor = { left = 0, top = 22, right = 0, bottom = 0 };
366 bool OnRightButtonDown(int x, int y, Modifiers mods)
368 return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
371 bool NotifyChanged(ListBox listBox, DataRow row)
373 String name = row.GetData(nameField);
374 String string = row.GetData(stringField);
375 if((name && name[0]) || (string && string[0]))
377 if(listBox.currentRow == listBox.lastRow)
379 DataRow r = listBox.lastRow;
381 listBox.currentRow = list.AddRow();
382 //row.SetData(nameField, null);
383 //row.SetData(stringField, null);
386 else if(listBox.currentRow != listBox.lastRow)
387 listBox.DeleteRow(null);
388 listBox.modifiedDocument = true;
392 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
396 listBox.StopEditing(true);
397 if(listBox.currentRow != listBox.lastRow)
398 listBox.DeleteRow(null);
404 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
406 if(listBox.currentRow == listBox.lastRow)
408 else if(row == listBox.lastRow)
410 listBox.currentRow.Move(row.previous);
416 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
422 DataField nameField { dataType = class(char *), editable = true, freeData = false, width = 120 };
423 DataField stringField { dataType = class(char *), editable = true, freeData = false };
428 list.AddField(nameField);
429 list.AddField(stringField);
430 /*row = */list.AddRow();
431 //row.SetData(nameField, null);
432 //row.SetData(stringField, null);
433 list.modifiedDocument = false;