default:
extern int __ecereVMethodID_class_OnFree;
+extern int __ecereVMethodID_class_OnGetString;
private:
char * defaultNameField = "Name";
tabCycle = true;
//inactive = true; // TOFIX causes problems...
- public Label title { this, font = { $"Arial", 10, bold = true }, position = { 16, 2 } };
+public:
+ Label title { this, font = { $"Arial", 10, bold = true }, position = { 16, 2 } };
bool OnCreate()
{
{
Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
{
- if(this || !this) { // FIXME
Button button = dataBox.keepEditor ? (Button)obsolete : null;
if(!button)
{
{
dataBox, borderStyle = 0, text = dataBox.text, anchor = { 0, 0, 0, 0 },
// size = { 100, 22 };
- modifyVirtualArea = false, isCheckbox = true;
+ modifyVirtualArea = false, isCheckbox = true;
bool DataBox::NotifyClicked(Button control, int x, int y, Modifiers mods)
{
bool checked = control.checked;
- SetData(&checked, false);
+ if(readOnly)
+ control.checked = !checked;
+ else
+ SetData(&checked, false);
return true;
}
};
button.checked = this;
button.Create();
return button;
+ }
+}
+
+String GetNameString(Row r, Field nameField)
+{
+ String s = null;
+ if(nameField.type != class(String) && nameField.type != class(char *))
+ {
+ char tempString[4096];
+ Class type = nameField.type;
+ int64 data = 0;
+ if(type.type == structClass)
+ data = (int64)new0 byte[type.structSize];
+ ((bool (*)())(void *)r.GetData)(r, nameField, type, (type.type == structClass) ? (void *)data : &data);
+ s = CopyString(((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, (void *)data, tempString, null, null));
+ ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
+ if(type.type == structClass)
+ {
+ void * _data = (void *)data;
+ delete _data;
}
- return null;
}
+ else
+ r.GetData(nameField, s);
+ return s;
}
public class TableDropBox : DropBox
anchor = { left = 130, top = 180, right = shadowS + sgs * 2 };
borderStyle = deep;
- public uint filter;
- public bool filtered;
- public Field nameField;
- public uint exclusion;
- public Table table;
- public Field filterField;
+public:
+ uint filter;
+ bool filtered;
+ Field nameField;
+ uint exclusion;
+ Table table;
+ Field filterField;
- public property uint filter
+ property uint filter
{
set
{
}
get { return filter; }
}
- public property Field nameField { set { nameField = value; } }
- public property uint exclusion { set { exclusion = value; } }
- public property Table table { set { table = value; if(!nameField && value) nameField = value.FindField(defaultNameField); } }
+ property Field nameField { set { nameField = value; } }
+ property uint exclusion { set { exclusion = value; } }
+ property Table table { set { table = value; if(!nameField && value) nameField = value.FindField(defaultNameField); } }
- public virtual void Refill()
+ virtual void Refill()
{
Clear();
if(table)
tbl.GenerateIndex(1, indexedFields, false);
r = Row { tbl };
-
+
for(r.Find(filterField, middle, nil, filter); !r.nil; r.Next()) //while(r.Next())
{
Id id;
break;
if(!exclusion || id != exclusion)
{
- String s;
- r.GetData(nameField, s);
+ String s = GetNameString(r, nameField);
AddString(s).tag = id;
delete s;
}
r.GetData(fldId, id);
if(idList && idList.Includes(filter) && (!exclusion || !idList.Includes(exclusion)))
{
- String s;
- r.GetData(nameField, s);
+ String s = GetNameString(r, nameField);
AddString(s).tag = id;
delete s;
}
r.GetData(fldId, id);
if(id != exclusion)
{
- String s;
- r.GetData(nameField, s);
+ String s = GetNameString(r, nameField);
AddString(s).tag = id;
delete s;
}
while(r.Next())
{
Id id;
- String s;
+ String s = GetNameString(r, nameField);
r.GetData(fldId, id);
- r.GetData(nameField, s);
AddString(s).tag = id;
delete s;
}
Sort(null, 1);
}
- public property Field filterField { set { filterField = value; } }
+ property Field filterField { set { filterField = value; } }
bool OnKeyHit(Key key, unichar ch)
{
}
else if((SmartKey)key == enter)
parent.CycleChildren(true, false, false, true);
-
+
return DropBox::OnKeyHit(key, ch);
}
return true;
}
- public void EditNotifyCharsAdded()
+ void EditNotifyCharsAdded()
{
if(!editBox.NotifyUpdate || editBox.NotifyUpdate == EditBox::NotifyUpdate)
editBox.NotifyUpdate = EditNotifyUpdate;
}
- public void EditNotifyUpdate(EditBox editBox)
+ void EditNotifyUpdate(EditBox editBox)
{
DataRow row;
char * contents = editBox.contents;
size.h = 24;
keepEditor = true;
borderStyle = deep;
-
- Field nameField;
- Field filterField;
- uint exclusion;
- uint filter;
- bool filtered;
- bool showNone;
showNone = false; //true;
- public property uint filter { set { filtered = true; filter = value; } get { return filter; } }
- public property bool filtered { set { filtered = value; } }
- public property uint exclusion { set { exclusion = value; } }
- public property Field filterField { set { filterField = value; } }
- public property Field nameField { set { nameField = value; } }
- public virtual void TableDropBox::RefillFunction();
- public property bool showNone { set { showNone = value; } }
+public:
+
+ property uint filter { set { filtered = true; filter = value; } get { return filter; } }
+ property bool filtered { set { filtered = value; } }
+ property uint exclusion { set { exclusion = value; } }
+ property Field filterField { set { filterField = value; } }
+ property Field nameField { set { nameField = value; } }
+ virtual void TableDropBox::RefillFunction();
+ property bool showNone { set { showNone = value; } }
- public void Refill()
+ void Refill()
{
if(editor)
{
dropBox.filter = filter;
else
dropBox.filtered = false;
-
+
dropBox.exclusion = exclusion;
dropBox.showNone = showNone;
}
+
+private:
+ Field nameField;
+ Field filterField;
+ uint exclusion;
+ uint filter;
+ bool filtered;
+ bool showNone;
}
public class EditDropDataBox : DropDataBox
anchor = { left = 110, right = shadowS + sgs * 2 };
borderStyle = deep;
- Field field;
- int64 dataHolder; // THERE SEEMS TO BE A BUG WHEN ACCESSING row ACROSS .so
- Row row;
-
- public property Row row
+public:
+ property Row row
{
set { row = value; }
get { return row; }
}
- public property EditSection editor
+ property EditSection editor
{
set
{
}
};
- public property Field field
+ property Field field
{
set
{
if(dataHolder)
{
- type._vTbl[__ecereVMethodID_class_OnFree](type, dataHolder);
+ ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)dataHolder);
if(type.type == structClass)
{
void * dataPtr = (void *)dataHolder;
}
}
- public void Clear()
+ void Clear()
{
- if(visible)
- {
- if(data)
- SetData(null, false);
-
- if(type && (type.type == noHeadClass || type.type == normalClass))
- {
- if(eClass_IsDerived(type, class(String)))
- dataHolder = (int64)CopyString("");
- else
- dataHolder = (int64)eInstance_New(type);
- data = (void *)&dataHolder;
- }
+ if(data)
+ SetData(null, false);
- if(created)
- Refresh();
+ if(type && (type.type == noHeadClass || type.type == normalClass))
+ {
+ if(eClass_IsDerived(type, class(String)))
+ dataHolder = (int64)CopyString("");
+ else
+ dataHolder = (int64)eInstance_New(type);
+ data = (void *)&dataHolder;
}
+
+ if(created)
+ Refresh();
}
- public void Load()
+ void Load()
{
- if(visible && field && row)
+ if(field && row)
{
SetData(null, false);
master.modifiedDocument = false;
}
}
- public virtual void Save()
+ virtual void Save()
{
bool result;
- if(visible && field && row)
+ if(field && row)
{
Class type = field.type;
if(!DataBox::SaveData())
Refresh();
- ((bool (*)())(void *)Row::SetData)(row, field, type,
+ ((bool (*)())(void *)Row::SetData)(row, field, type,
(type.type == noHeadClass || type.type == normalClass) ? *(void **)data : data);
}
}
- public void Init()
+ void Init()
{
- if(visible && created)
+ if(created)
Refresh();
}
{
if((SmartKey)key == enter)
parent.CycleChildren(true, false, false, true);
-
+
return DataBox::OnKeyHit(key, ch);
}
- public bool Window::NotifyChanged(bool closingDropDown)
+ bool Window::NotifyChanged(DataBox dataBox, bool closingDropDown)
{
modifiedDocument = true;
return true;
}
- public bool Window::NotifyModified()
+ bool Window::NotifyModified()
{
modifiedDocument = true;
return true;
if(dataHolder)
{
- type._vTbl[__ecereVMethodID_class_OnFree](type, dataHolder);
+ ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)dataHolder);
if(type.type == structClass)
{
void * dataPtr = (void *)dataHolder;
dataHolder = 0;
}
}
+
+private:
+ Field field;
+ int64 dataHolder; // THERE SEEMS(ED?) TO BE A BUG WHEN ACCESSING row ACROSS .so
+ Row row;
}
public class FieldCheckButton : FieldDataBox
{
size.h = 24;
keepEditor = true;
-
- Field nameField;
- Field filterField;
- uint exclusion;
- uint filter;
- bool filtered;
- bool showNone;
showNone = true;
- public property uint filter { set { filtered = true; filter = value; } get { return filter; } }
- public property bool filtered { set { filtered = value; } }
- public property uint exclusion { set { exclusion = value; } }
- public property Field filterField { set { filterField = value; } }
- public property Field nameField { set { nameField = value; } }
- public virtual void TableDropBox::RefillFunction();
- public property bool showNone { set { showNone = value; } }
-
- public void Refill()
+public:
+ property uint filter { set { filtered = true; filter = value; } get { return filter; } }
+ property bool filtered { set { filtered = value; } }
+ property uint exclusion { set { exclusion = value; } }
+ property Field filterField { set { filterField = value; } }
+ property Field nameField { set { nameField = value; } }
+ virtual void TableDropBox::RefillFunction();
+ property bool showNone { set { showNone = value; } }
+
+ void Refill()
{
if(editor)
{
dropBox.exclusion = exclusion;
dropBox.showNone = showNone;
}
+
+private:
+ Field nameField;
+ Field filterField;
+ uint exclusion;
+ uint filter;
+ bool filtered;
+ bool showNone;
}
public class EditFieldDropDataBox : FieldDropDataBox
{
// showNone = false;
-
+public:
void OnConfigure(TableDropBox dropBox)
{
FieldDropDataBox::OnConfigure(dropBox);
void Save()
{
TableDropBox dropBox = (TableDropBox) editor;
-
+
if(!dropBox.currentRow && dropBox.contents[0])
{
Row row { dropBox.table };
FieldDataBox::Save();
}
- public virtual bool OnAddTextEntry(Row row, TableDropBox dropBox, char * entry)
+ virtual bool OnAddTextEntry(Row row, TableDropBox dropBox, char * entry)
{
row.Add();
row.SetData(dropBox.nameField, entry);
text = $"List";
size = { 710, 287 };
anchor = { left = sgs, top = 32 + sgs * 3, bottom = 55 + sgs * 3 };
-
- EditSection editor;
-
- public property EditSection editor
+public:
+ property EditSection editor
{
set
{
}
}
- public property Table table
+ property Table table
{
set
{
if(table)
{
FieldIndex indexedFields[1];
-
+
if(!fldId) fldId = table.FindField(defaultIdField);
if(!fldName) fldName = table.FindField(defaultNameField);
if(!fldActive) fldActive = table.FindField(defaultActiveField);
-
+
indexedFields[0] = { fldId };
table.Index(1, indexedFields);
-
+
editor.editRow.tbl = table;
-
+
RefillList();
}
}
}
}
- Table table;
- public Field fldId, fldName, fldActive;
+ Field fldId, fldName, fldActive;
- public virtual DialogResult Window::NotifySaveConfirmation(ListSection listSection)
+ virtual DialogResult Window::NotifySaveConfirmation(ListSection listSection)
{
return MessageBox { master = this, type = yesNoCancel, text = $"List Editor", contents = $"You have modified this entry. Would you like to save it before proceeding?" }.Modal();
}
-
+
bool OnClose(bool parentClosing)
{
if(editor && editor.modifiedDocument)
return true;
}
- public void RefillList()
+ void RefillList()
{
list.Clear();
//if(fldId && fldName)
editor.modifiedDocument = false;
}
- public virtual void Window::NotifyRefillList(ListSection listSection, Row r)
+ virtual void Window::NotifyRefillList(ListSection listSection, Row r)
{
if(listSection.fldId && listSection.fldName)
{
}
}
- public virtual bool Window::NotifyNew(ListSection listSection, Row r);
+ virtual bool Window::NotifyNew(ListSection listSection, Row r);
- public ButtonStyle btnNew
+ ButtonStyle btnNew
{
this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altW, text = $"New";
list.NotifySelect(this, list, null, 0);
if(!editor.modifiedDocument)
{
- uint id; // = table.rowsCount + 1; // this is bad with deleted rows, won't work, how to have unique id?
+ uint id; // = table.rowsCount + 1; // this is bad with deleted rows, won't work, how to have unique id?
Row r { table };
-
+
if(r.Last()) // this will reuse ids in cases where the item(s) with the last id have been deleted
{
r.GetData(fldId, id);
}
else
id = 1;
-
+
editor.EditClear();
{
bool active = true;
r.SetData(fldActive, active);
if(NotifyNew(master, this, r))
- list.currentRow = list.AddString("$[New]");
+ list.currentRow = list.AddString($"[New]");
delete r;
}
}
};
- public virtual bool Window::NotifyDeleteConfirmation(ListSection listSection)
+ virtual bool Window::NotifyDeleteConfirmation(ListSection listSection)
{
- return MessageBox { master = this, type = yesNo, text = $"List Editor",
+ return MessageBox { master = this, type = yesNo, text = $"List Editor",
contents = $"You are about to delete an entry.\n"
"Do you wish to continue?"
}.Modal() == yes;
}
- public virtual void Window::NotifyDeleting(ListSection listSection);
- public virtual void Window::NotifyDeleted(ListSection listSection);
+ virtual void Window::NotifyDeleting(ListSection listSection);
+ virtual void Window::NotifyDeleted(ListSection listSection);
- public ButtonStyle btnDelete
+ ButtonStyle btnDelete
{
this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altD, text = $"Delete";
}
};
- public bool FilterNotifyChanged(bool closeDropDown)
+ bool FilterNotifyChanged(DataBox dataBox, bool closeDropDown)
{
editor.EditClear();
RefillList();
return true;
}
- DataRow lastRow;
- public ListBox list
+ ListBox list
{
this, anchor = { left = sgs * 2, top = 22 + 22 + sgs * 4, right = shadowS + sgs * 2, bottom = shadowS + sgs * 2 };
alwaysHighLight = true;
-
+
bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
{
bool result = true;
}
};
- public virtual void Window::NotifySelectListRow(ListSection listSection, uint id);
-
- public void SelectListRow(DataRow row)
+ virtual void Window::NotifySelectListRow(ListSection listSection, uint64 id);
+
+ void SelectListRow(DataRow row)
{
// Time startTime = GetTime();
if(row)
{
- uint id = row.tag;
+ uint64 id = row.tag;
lastRow = row;
if(list.currentRow != row)
// Logf("SelectListRow took %f seconds\n", GetTime() - startTime);
}
- public void SelectFirst()
+ void SelectFirst()
{
if(list.firstRow)
SelectListRow(list.firstRow);
RefreshState();
}
- public void RefreshState()
+ void RefreshState()
{
if(editor)
{
editor.disabled = !(bool)list.firstRow;
}
}
-
+
void OnResize(int width, int height)
{
int x = width - btnDelete.size.w - 20;
return Window::OnPostCreate();
}
+private:
+ EditSection editor;
+ Table table;
+ DataRow lastRow;
}
public class EditSection : Group
DataRow listRow;
OldList editBoxes { };
- public Window editArea { this, borderStyle = deep, tabCycle = true, anchor = { left = 8, top = 54, right = 10, bottom = 10 }, hasVertScroll = true, dontHideScroll = true };
-
- public ButtonStyle btnSave
+ Window editArea { this, borderStyle = deep, tabCycle = true, anchor = { left = 8, top = 54, right = 10, bottom = 10 }, hasVertScroll = true, dontHideScroll = true };
+
+ ButtonStyle btnSave
{
this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altV, text = $"Save";
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- EditSave(editRow);
+ EditSave();
return true;
}
};
- public ButtonStyle btnReload
+ ButtonStyle btnReload
{
this, anchor = { left = 10, top = 24 }, hotKey = altV, text = $"Revert";
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- EditLoad(editRow);
+ EditLoad();
return true;
}
};
}
virtual void Window::NotifyInitFields(EditSection editSection);
-
+
void InitFields()
{
OldLink link;
void EditNew()
{
-
modifiedDocument = false;
}
{
edit.listRow.string = name;
}
-
+
void EditSave()
{
bool stringName = !strcmp(list.fldName.type.dataTypeString, "char *");