1 #ifdef BUILDING_ECERE_COM
2 namespace gui::controls;
7 public import static "ecere"
13 public class NamedString : struct
16 property String name { set { delete name; name = CopyString(value); } get { return name; } }
17 property String string { set { delete string; string = CopyString(value); } get { return string; } }
29 public class StringsBox : CommonControl
33 watch(foreground) { list.foreground = foreground; };
34 watch(background) { list.background = background; };
37 property Array<String> strings
46 char temp[MAX_LOCATION];
51 list.currentRow = list.firstRow;
52 list.modifiedDocument = false;
56 Array<String> array { };
58 for(row = list.firstRow; row; row = row.next)
60 String string = row.string;
61 if(string && string[0])
62 array.Add(CopyUnixPath(string));
68 virtual bool Window::NotifyModified(StringsBox dirsBox);
70 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
74 list.StopEditing(true);
75 if(list.modifiedDocument)
77 NotifyModified(master, this);
78 list.modifiedDocument = false;
79 modifiedDocument = true;
87 parent = this, bevelOver = true, inactive = true;
88 position = { 265, 0 }, size = { 22, 22 };
89 anchor = { top = 0, right = 77 };
90 hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
91 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
93 list.StopEditing(true);
94 list.lastRow.Edit(null);
95 //list.modifiedDocument = true;
101 parent = this, bevelOver = true, inactive = true;
102 position = { 290, 0 }, size = { 22, 22 };
103 anchor = { top = 0, right = 54 };
104 hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
105 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
107 list.StopEditing(true);
108 if(list.currentRow != list.lastRow)
110 list.DeleteRow(null);
111 //list.modifiedDocument = true;
118 parent = this, bevelOver = true, inactive = true;
119 position = { 315, 0 }, size = { 22, 22 };
120 anchor = { top = 0, right = 31 };
121 hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
122 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
124 if(list.currentRow != list.lastRow)
126 DataRow current = list.currentRow, row;
129 row = current.previous;
134 //list.modifiedDocument = true;
143 parent = this, bevelOver = true, inactive = true;
144 position = { 340, 0 }, size = { 22, 22 };
145 anchor = { top = 0, right = 8 };
146 hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
147 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
149 DataRow current = list.currentRow, row;
153 if(row && row != list.lastRow)
161 this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
162 borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
163 anchor = { left = 0, top = 22, right = 0, bottom = 0 };
165 bool OnRightButtonDown(int x, int y, Modifiers mods)
167 return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
170 bool NotifyChanged(ListBox listBox, DataRow row)
172 char * string = listBox.GetData(null);
173 if(string && string[0])
175 if(listBox.currentRow == listBox.lastRow)
177 DataRow r = listBox.lastRow;
179 listBox.currentRow = listBox.AddString("");
182 else if(listBox.currentRow != listBox.lastRow)
183 listBox.DeleteRow(null);
184 //listBox.modifiedDocument = true;
188 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
192 listBox.StopEditing(true);
193 if(listBox.currentRow != listBox.lastRow)
194 listBox.DeleteRow(null);
200 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
202 if(listBox.currentRow == listBox.lastRow)
204 else if(row == listBox.lastRow)
206 listBox.currentRow.Move(row.previous);
212 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
218 DataField stringField { dataType = class(char *), editable = true };
221 list.AddField(stringField);
223 list.modifiedDocument = false;
227 class NamedStringsBox : CommonControl
231 watch(foreground) { list.foreground = foreground; };
232 watch(background) { list.background = background; };
234 property Array<NamedString> namedStrings
244 char temp[MAX_LOCATION];
246 row.SetData(nameField, s.name);
247 row.SetData(stringField, s.string);
251 //row.SetData(nameField, null);
252 //row.SetData(stringField, null);
253 list.currentRow = list.firstRow;
254 list.modifiedDocument = false;
258 Array<NamedString> array { };
260 for(row = list.firstRow; row; row = row.next)
262 // NamedString is a class:struct, need to instantiate!!
263 String name = row.GetData(nameField);
264 String string = row.GetData(stringField);
265 if(name && name[0] && string && string[0])
266 array.Add({ name, string });
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)
371 String name = row.GetData(nameField);
372 String string = row.GetData(stringField);
373 if((name && name[0]) || (string && string[0]))
375 if(listBox.currentRow == listBox.lastRow)
377 DataRow r = listBox.lastRow;
379 listBox.currentRow = list.AddRow();
380 //row.SetData(nameField, null);
381 //row.SetData(stringField, null);
384 else if(listBox.currentRow != listBox.lastRow)
385 listBox.DeleteRow(null);
386 listBox.modifiedDocument = true;
390 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
394 listBox.StopEditing(true);
395 if(listBox.currentRow != listBox.lastRow)
396 listBox.DeleteRow(null);
402 bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
404 if(listBox.currentRow == listBox.lastRow)
406 else if(row == listBox.lastRow)
408 listBox.currentRow.Move(row.previous);
414 bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
420 DataField nameField { dataType = class(char *), editable = true, freeData = false, width = 120 };
421 DataField stringField { dataType = class(char *), editable = true, freeData = false };
426 list.AddField(nameField);
427 list.AddField(stringField);
428 /*row = */list.AddRow();
429 //row.SetData(nameField, null);
430 //row.SetData(stringField, null);
431 list.modifiedDocument = false;