public:
property Class dataType
{
- set { dataType = value; if(value) alignment = value.defaultAlignment; }
+ set { dataType = value; if(value) { alignment = (Alignment)value.defaultAlignment; } } // NOTE: Class::defaultAlignment does not seem to be used anywhere
get { return dataType; }
}
property bool editable { set { editable = value; } };
+ property bool fixed { set { fixed = value; } get { return fixed; } };
property Alignment alignment
{
set
if(headButton) headButton.alignment = value;
if(listBox) listBox.Update(null);
}
+ get { return alignment; }
};
property int width
{
}
}
+ void AutoSize()
+ {
+ if(listBox && dataType)
+ {
+ Display display = listBox.display;
+ Font boldFont = listBox.boldFont.font;
+ Font font = listBox.fontObject;
+ DataRow row;
+ int width = 0;
+ if(header)
+ display.FontExtent(boldFont, header, strlen(header), &width, null);
+ width += EXTRA_SPACE;
+ for(row = listBox.firstRow; row; row = row.GetNextRow())
+ {
+ ListBoxCell cell;
+ uint i;
+ for(i = 0, cell = row.cells.first; i != index; i++, cell = cell.next);
+ if(cell && cell.isSet && dataType)
+ {
+ static char tempString[4096];
+ String string;
+ int tw = 0;
+ if(dataType.type == normalClass || dataType.type == noHeadClass)
+ string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, cell.data[0], tempString, userData, null);
+ else
+ string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, cell.data, tempString, userData, null);
+ if(string)
+ display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, null);
+ else
+ display.FontExtent(row.header ? boldFont : font, "", 0, &tw, null);
+ if(tw > width) width = tw;
+ }
+ }
+ if(width)
+ property::width = width;
+ }
+ }
+
private:
DataField()
{
int x;
Button headButton;
int sortOrder;
- int alignment;
+ Alignment alignment;
bool editable;
ListBox listBox;
bool defaultField;
void * userData;
bool freeData;
+ bool fixed;
};
public class DataRow
{
class_no_expansion
+#ifdef _DEBUG
+ bool skipCheck;
+#endif
public:
- property int tag { set { tag = value; } get { return tag; } };
+ property int64 tag { set { tag = value; } get { return tag; } };
property DataRow previous { get { return prev; } };
property DataRow next { get { return next; } };
property int index { get { return (this && (!parent || parent.IsExpanded())) ? index : -1; } };
}
}
- // TODO: FIX row indices
index = this.index+1;
for(search = GetNextRow(); search; search = search.GetNextRow())
search.index = index++;
listBox.NotifyCollapse(listBox.master, listBox, this, value);
}
}
+#ifdef _DEBUG
+ if(!skipCheck)
+ listBox.CheckConsistency();
+#endif
}
get { return this ? collapsed : false; }
};
{
DataRow search;
DataRow after = value ? value.subRows.last : listBox.rows.last;
+ int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
if(parent.IsExpanded())
{
for(search = GetNextRow(); search; search = search.GetNextRow())
- search.index--;
- listBox.rowCount--;
+ search.index -= ixCount;
+ listBox.rowCount -= ixCount;
}
listBox.HideEditBox(false, false, true);
parent = value;
if(value && listBox.style.expandOnAdd)
+ {
+#ifdef _DEBUG
+ value.skipCheck = true;
+#endif
value.collapsed = false;
+#ifdef _DEBUG
+ value.skipCheck = false;
+#endif
+ }
- if(value.IsExpanded(this))
+ if(value.IsExpanded())
{
DataRow search;
if(after && after.subRows.first && !after.collapsed)
{
- for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
- search = search.subRows.last;
+ search = after.GetLastRow();
index = search.index + 1;
}
else
index = after ? (after.index + 1) : (index + 1);
- listBox.rowCount++;
+ listBox.rowCount += ixCount;
- for(search = GetNextRow(); search; search = search.GetNextRow())
- search.index++;
+ {
+ int ix = index+1;
+ for(search = GetNextRow(); search; search = search.GetNextRow())
+ search.index = ix++;
+ }
listBox.SetScrollArea(
listBox.width,
}
}
+ // NOTE: This does not support reparenting (Use row.parent = first)
void Move(DataRow after)
{
if(this)
int afterIndex = -1;
int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
int height = listBox.clientSize.h + 1 - headerSize;
+ int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
if(!after || after.index < index)
{
// All rows between AFTER (exclusive) and ROW (exclusive) are incremented by one
// ROW is equal to AFTER's index + 1
- // TODO: Fix indices
for(search = after ? after.next : listBox.rows.first; search && search != this; search = search.GetNextRow())
- search.index++;
+ search.index += ixCount;
if(after && after.subRows.first && !after.collapsed)
{
- for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
- search = search.subRows.last;
+ search = after.GetLastRow();
index = search.index + 1;
}
else
index = after ? (after.index + 1) : 0;
+
+ // Fix indices of sub rows
+ if(!collapsed)
+ {
+ int c, ix = index+1;
+ for(c = 1, search = GetNextRow(); search && c < ixCount; c++, search = search.GetNextRow())
+ search.index = ix++;
+ }
}
else
{
+ DataRow nextRow = GetNextRow();
if(this == listBox.firstRowShown)
- {
- listBox.firstRowShown = GetNextRow();
- }
+ listBox.firstRowShown = nextRow;
+ index = after.index;
// All rows between ROW (exclusive) and AFTER (inclusive) are decremented by one
// ROW is equal to AFTER's index
- // TODO: Fix indices
- for(search = GetNextRow(); search; search = search.GetNextRow())
+ for(search = nextRow; search; search = search.GetNextRow())
{
- search.index--;
+ search.index -= ixCount;
if(search == after) break;
}
- index = after ? (after.index + 1) : 0;
}
listBox.rows.Move(this, after);
+#ifdef _DEBUG
+ listBox.CheckConsistency();
+#endif
+
listBox.HideEditBox(true, false, true);
if(listBox)
{
if(dataType.type == normalClass || dataType.type == noHeadClass)
{
if(cell.data[0] && field.freeData)
- dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
+ ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data[0]);
if(eClass_IsDerived(dataType, class(char *)) && field.freeData)
- dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
+ ((void (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCopy])(dataType, cell.data, newData);
else
cell.data[0] = (void *)newData;
}
else
{
// Free old data first
- dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
- dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
+ ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data);
+ ((void (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCopy])(dataType, cell.data, newData);
}
}
cell.isSet = true;
if(dataType.type == normalClass || dataType.type == noHeadClass)
{
if(cell.data[0] && field.freeData)
- dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
+ ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data[0]);
cell.data[0] = null;
}
else
{
// Free old data first
- dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
+ ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data);
}
}
cell.isSet = false;
}
}
- DataRow FindRow(int tag)
+ DataRow FindRow(int64 tag)
{
DataRow row = null;
for(row = subRows.first; row; row = row.next)
return row;
}
- DataRow FindSubRow(int tag)
+ DataRow FindSubRow(int64 tag)
{
DataRow row = null;
for(row = subRows.first; row; row = row.next)
}
}
- if(IsExpanded(this))
+ if(IsExpanded())
{
DataRow search;
listBox.rowCount++;
- // TODO: Fix indices
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index++;
listBox.modifiedDocument = true;
}
+#ifdef _DEBUG
+ listBox.CheckConsistency();
+#endif
return row;
}
return null;
DataRow row;
char string[MAX_F_STRING];
va_list args;
-
va_start(args, format);
- vsprintf(string, format, args);
+ vsnprintf(string, sizeof(string), format, args);
+ string[sizeof(string)-1] = 0;
va_end(args);
row = AddRow();
if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
{
if(cell.data[0] && field.freeData)
- field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
+ ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data[0]);
}
else
- field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
+ ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data);
}
}
next = cell.next;
{
if(sortField.dataType.type == normalClass || sortField.dataType.type == noHeadClass)
{
- result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
+ result = ((int (*)(void *, void *, void *))(void *)sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])(sortField.dataType,
(cell1.isSet && cell1.data) ? cell1.data[0] : null,
(cell2.isSet && cell2.data) ? cell2.data[0] : null);
}
else
{
- result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
+ result = ((int (*)(void *, void *, void *))(void *)sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])(sortField.dataType,
cell1.isSet ? cell1.data : null,
cell2.isSet ? cell2.data : null);
}
{
_SortSubRows(listBox.sortField, listBox.sortField.sortOrder);
- // TODO: Recompute row indices
{
DataRow search;
int index = this.index;
return row;
}
+ private DataRow GetLastRow()
+ {
+ DataRow row = this;
+ while(row && !row.collapsed && row.subRows.last)
+ row = row.subRows.last;
+ return row;
+ }
+
DataRow prev, next;
OldList cells;
- int tag;
+ int64 tag;
SelectedFlag selectedFlag;
ListBox listBox;
bool header;
public:
// Properties
- property bool freeSelect { property_category "Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } };
- property DataRow currentRow { property_category "Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } };
+ property bool freeSelect { property_category $"Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } };
+ property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } };
property DataField currentField
{
get { return currentField; }
- // TODO: Needs definition of what this is, testing
+ // TODO: Document what this does
set
{
currentField = value;
property int rowHeight
{
- property_category "Appearance"
+ property_category $"Appearance"
isset { return style.heightSet; }
set
{
};
property Seconds typingTimeout
{
- property_category "Behavior"
+ property_category $"Behavior"
set
{
typedString[0] = '\0';
}
get { return typingTimeOut; }
};
- property bool moveRows { property_category "Behavior" set { style.moveRows = value; } get { return style.moveRows; } };
- property bool moveFields { property_category "Behavior" set { style.moveFields = value; } get { return style.moveFields; } };
- property bool resizable { property_category "Behavior" set { style.resizable = value; } get { return style.resizable; } };
- property bool autoScroll { property_category "Behavior" set { style.autoScroll = value; } get { return style.autoScroll; } };
- property bool alwaysHighLight { property_category "Appearance" set { style.alwaysHL = value; } get { return style.alwaysHL; } };
- property bool hasClearHeader { property_category "Appearance" set { style.clearHeader = value; if(value) property::hasHeader = true; } get { return style.clearHeader; } };
+ property bool moveRows { property_category $"Behavior" set { style.moveRows = value; } get { return style.moveRows; } };
+ property bool moveFields { property_category $"Behavior" set { style.moveFields = value; } get { return style.moveFields; } };
+ property bool resizable { property_category $"Behavior" set { style.resizable = value; } get { return style.resizable; } };
+ property bool autoScroll { property_category $"Behavior" set { style.autoScroll = value; } get { return style.autoScroll; } };
+ property bool alwaysHighLight { property_category $"Appearance" set { style.alwaysHL = value; } get { return style.alwaysHL; } };
+ property bool hasClearHeader { property_category $"Appearance" set { style.clearHeader = value; if(value) property::hasHeader = true; } get { return style.clearHeader; } };
property bool hasHeader
{
- property_category "Appearance"
+ property_category $"Appearance"
set
{
if(value && !style.header)
size.h = rowHeight;
NotifyPushed = HeaderPushed;
NotifyClicked = HeaderClicked;
+ NotifyDoubleClick = HeaderDoubleClicked;
NotifyReleased = HeaderReleased;
NotifyMouseMove = HeaderMouseMove;
};
}
get { return style.header; }
};
- property bool multiSelect { property_category "Behavior" set { style.multiSelect = value; } get { return style.multiSelect; } };
- property bool alwaysEdit { property_category "Behavior" set { style.alwaysEdit = value; } get { return style.alwaysEdit; } };
- property bool fullRowSelect { property_category "Appearance" set { style.fullRowSelect = value; } get { return style.fullRowSelect; } };
- property bool collapseControl { property_category "Appearance" set { style.collapse = value; } get { return style.collapse; } };
- property bool treeBranches { property_category "Appearance" set { style.treeBranch = value; } get { return style.treeBranch; } };
- property bool rootCollapseButton { property_category "Appearance" set { style.rootCollapse = value; } get { return style.rootCollapse; } };
- property bool sortable { property_category "Behavior" set { style.sortable = value; } get { return style.sortable; } };
- property bool noDragging { property_category "Behavior" set { style.noDragging = value; } get { return style.noDragging; } };
+ property bool multiSelect { property_category $"Behavior" set { style.multiSelect = value; } get { return style.multiSelect; } };
+ property bool alwaysEdit { property_category $"Behavior" set { style.alwaysEdit = value; } get { return style.alwaysEdit; } };
+ property bool fullRowSelect { property_category $"Appearance" set { style.fullRowSelect = value; } get { return style.fullRowSelect; } };
+ property bool collapseControl { property_category $"Appearance" set { style.collapse = value; } get { return style.collapse; } };
+ property bool treeBranches { property_category $"Appearance" set { style.treeBranch = value; } get { return style.treeBranch; } };
+ property bool rootCollapseButton { property_category $"Appearance" set { style.rootCollapse = value; } get { return style.rootCollapse; } };
+ property bool sortable { property_category $"Behavior" set { style.sortable = value; } get { return style.sortable; } };
+ property bool noDragging { property_category $"Behavior" set { style.noDragging = value; } get { return style.noDragging; } };
property bool fillLastField
{
- property_category "Behavior"
+ property_category $"Behavior"
set
{
style.fillLastField = value;
virtual bool Window::NotifyModified(ListBox listBox, DataRow row);
virtual bool Window::NotifyEditing(ListBox listBox, DataRow row);
+#ifdef _DEBUG
+ private void CheckConsistency()
+ {
+#if 0
+ DataRow r;
+ int index = 0;
+ for(r = rows.first; r; r = r.GetNextRow())
+ {
+ if(r.index != index++)
+ PrintLn("bug");
+ }
+#endif
+ }
+#endif
+
// Methods
void AddField(DataField addedField)
{
if(fields.first && ((DataField)fields.first).defaultField)
{
DataField defaultField = fields.first;
- // TODO:
defaultField.Free();
delete defaultField;
}
stayOnTop = true;
inactive = true;
dontScrollVert = true;
- id = (uint)addedField;
+ id = (uint64)addedField;
text = addedField.header;
bevel = (!guiApp.textMode && !style.clearHeader);
ellipsis = true;
alignment = addedField.alignment;
NotifyPushed = HeaderPushed;
NotifyClicked = HeaderClicked;
+ NotifyDoubleClick = HeaderDoubleClicked;
NotifyReleased = HeaderReleased;
NotifyMouseMove = HeaderMouseMove;
};
int index = field.index;
DataRow row;
+ if(sortField == field)
+ sortField = null;
+
for(row = rows.first; row; )
{
int c;
if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
{
if(cell.data[0] && field.freeData)
- field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
+ ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data[0]);
}
else
- field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
+ ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data);
}
row.cells.Remove(cell);
SetScrollPosition(0, MAXINT - rowHeight);
modifiedDocument = true;
}
+#ifdef _DEBUG
+ CheckConsistency();
+#endif
return row;
}
}
rows.Insert(after, row);
row.listBox = this;
- // TODO: FIX row indices
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index++;
if(style.autoScroll)
SetScrollPosition(0, MAXINT - rowHeight);
modifiedDocument = true;
+#ifdef _DEBUG
+ CheckConsistency();
+#endif
return row;
}
}
va_list args;
va_start(args, format);
- vsprintf(string, format ? format : "", args);
+ vsnprintf(string, sizeof(string), format ? format : "", args);
+ string[sizeof(string)-1] = 0;
va_end(args);
row = AddRow();
if(row.parent.IsExpanded())
{
- // TODO: FIX row indices
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index--;
this.rowCount--;
modifiedDocument = true;
Update(null);
+#ifdef _DEBUG
+ CheckConsistency();
+#endif
}
}
- DataRow FindRow(int tag)
+ DataRow FindRow(int64 tag)
{
if(this)
{
void * data = row.GetData(field);
char tempString[1024] = "";
bool needClass = false;
- char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
+ char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
if(string && string[0])
checkNextField = false;
void * data = row.GetData(field);
char tempString[1024] = "";
bool needClass = false;
- char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
+ char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
if(string && string[0])
checkNextField = false;
void * data = row.GetData(field);
char tempString[1024] = "";
bool needClass = false;
- char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
+ char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
if(string && string[0])
checkNextField = false;
void * data = row.GetData(field);
char tempString[1024] = "";
bool needClass = false;
- char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
+ char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
if(string && string[0])
checkNextField = false;
return null;
}
- DataRow FindSubRow(int tag)
+ DataRow FindSubRow(int64 tag)
{
if(this)
{
for(search = rows.first; search; search = search.next)
search._SortSubRows(field, order);
- // TODO: Recompute row indices
{
int index = 0;
for(search = rows.first; search; search = search.GetNextRow())
return (void *)currentRow.GetData(field);
}
- int GetTag()
+ int64 GetTag()
{
return currentRow ? currentRow.tag : 0;
}
Font font = fontObject;
Font boldFont = this.boldFont.font;
+
// Draw gray grid
if(style.alwaysEdit && style.fullRowSelect)
{
if(style.collapse && !(style.treeBranch) && rows.first)
{
x += 15;
- surface.SetBackground(activeBorder);
+ surface.SetBackground(formColor);
surface.Area(-scroll.x, 0, x, clientSize.h);
}
- surface.SetForeground(activeBorder);
+ surface.SetForeground(formColor);
for(row = firstRowShown; row; row = row.GetNextRow())
{
y += rowHeight;
DataRow parent;
Bitmap icon = row.icon ? row.icon.bitmap : null;
int collapseRowStart;
+ bool lastWasHeader = row.header;
for(parent = row.parent; parent; parent = parent.parent)
{
- if(!parent.header)
+ if(!parent.header || lastWasHeader)
{
if(style.treeBranch)
indent += 20;
// Draw the current row background
if(row.header)
{
- background = activeBorder;
- surface.SetBackground(activeBorder);
+ Color colors[] = { formColor, azure, mistyRose, linen, floralWhite, lavender, lavenderBlush, lemonChiffon };
+ int level = 0;
+ DataRow p = row;
+ while(p = p.parent) level++;
+ background = colors[(level % (sizeof(colors)/sizeof(colors[0]))];
+ surface.SetBackground(background);
surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
foreground = branchesColor;
}
if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
{
if(!isActive && style.alwaysEdit)
- background = activeBorder;
+ background = formColor;
else
background = selectionColor ? selectionColor : SELECTION_COLOR;
if(style.fullRowSelect)
surface.SetForeground(foreground);
surface.SetBackground(background);
- class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
+ ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)class(String)._vTbl[__ecereVMethodID_class_OnDisplay])(class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
}
else
{
+ if(!opacity) surface.TextOpacity(false);
// Draw the rows
for(field = fields.first; field; field = field.next)
{
uint index;
- int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
+ int width = ((!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) || row.header) ?
clientSize.w - field.x : (field.width + EXTRA_SPACE);
// Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
foreground = this.foreground;
}
- if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
+ if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
{
surface.Clip(null);
surface.SetBackground(background);
surface.SetBackground(background);
if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
- field.dataType._vTbl[__ecereVMethodID_class_OnDisplay](field.dataType, cell.data[0], surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, field.userData, field.alignment, dataDisplayFlags);
+ ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnDisplay])(field.dataType, cell.data[0], surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, field.userData, field.alignment, dataDisplayFlags);
else
- field.dataType._vTbl[__ecereVMethodID_class_OnDisplay](field.dataType, cell.data, surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, field.userData, field.alignment, dataDisplayFlags);
+ ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnDisplay])(field.dataType, cell.data, surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, field.userData, field.alignment, dataDisplayFlags);
}
if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
- background = activeBorder;
+ background = formColor;
if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
{
- background = activeBorder;
+ background = formColor;
foreground = this.background;
}
surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
- surface.SetBackground(row.header ? (activeBorder) : (this.background)); //white
+ surface.SetBackground(row.header ? (formColor) : (this.background)); //white
surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
}
else if(field.alignment == right)
{
- x = field.x + width - tw - EXTRA_SPACE - 4;
+ x = field.x + width - tw - 2*EXTRA_SPACE - 4;
x = Max(x, field.x + 2);
}
x -= scroll.x;
else if(x < RESIZE_BORDER && field.prev)
field = field.prev;
+ if(field.fixed) return false;
resizingField = field;
this.resizeX = x + control.position.x;
this.startWidth = field.width;
}
else if(field)
{
+ if(field.fixed) return false;
draggingField = field;
if(style.moveFields)
field.headButton.stayDown = true;
if(field)
{
if(x < RESIZE_BORDER && field.prev)
- control.cursor = guiApp.GetCursor(sizeWE);
+ {
+ if(!field.prev.fixed)
+ control.cursor = guiApp.GetCursor(sizeWE);
+ }
else if(x >= control.clientSize.w - RESIZE_BORDER)
control.cursor = guiApp.GetCursor(sizeWE);
else
return true;
}
+ bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
+ {
+ if(style.resizable)
+ {
+ DataField field = (DataField)control.id;
+ if(field)
+ {
+ if(x < RESIZE_BORDER && field.prev)
+ field = field.prev;
+ else if(x >= control.clientSize.w - RESIZE_BORDER);
+ else
+ field = null;
+ }
+ else
+ {
+ if(x < RESIZE_BORDER && fields.last)
+ field = fields.last;
+ else
+ field = null;
+ }
+ if(field)
+ field.AutoSize();
+ }
+ return false;
+ }
+
watch(visible)
{
if(style.freeSelect)
// Should always be as many cells in the row as fields in the listbox
if(cell && cell.isSet && field.dataType)
{
- Bitmap icon = null;
- char tempString[1024];
+ static char tempString[4096];
char * string;
int tw, th;
- if(field.dataType.type == 0 normalClass || field.dataType.type == noHeadClass)
- string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data[0], tempString, field.userData, null);
+ if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
+ string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, cell.data[0], tempString, field.userData, null);
else
- string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data, tempString, field.userData, null);
+ string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, cell.data, tempString, field.userData, null);
/* GCC-4.4 Bug!
if(!string) string = "";
display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
void * data = row.GetData(field);
char tempString[1024] = "";
bool needClass = false;
- char * string = data ? (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass) : null;
+ char * string = data ? ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass) : null;
if(string && string[0])
checkNextField = false;
bool OnKeyHit(Key key, unichar ch)
{
- if(key.code == up && key.alt == true && key.ctrl == false && key.shift == false)
- return true;
-
if(!ch && !key.alt && !key.ctrl)
{
key.code = (SmartKey)key.code;
}
}
- if(!(style.multiSelect) && (key.ctrl))
- return true;
-
if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
return false;
- switch(key.code)
+ if(!key.alt && (style.multiSelect || !key.ctrl))
{
- case left:
- if(style.alwaysEdit)
- {
- if(currentField)
+ switch(key.code)
+ {
+ case left:
+ if(style.alwaysEdit)
{
- DataField field;
- for(field = currentField.prev; field; field = field.prev)
+ if(currentField)
{
- if(field.editable)
+ DataField field;
+ for(field = currentField.prev; field; field = field.prev)
{
- currentField = field;
- HideEditBox(true, true, false);
- PopupEditBox(currentField, false);
- return false;
- }
+ if(field.editable)
+ {
+ currentField = field;
+ HideEditBox(true, true, false);
+ PopupEditBox(currentField, false);
+ return false;
+ }
+ }
}
}
- }
- if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
- {
- if(currentRow.subRows.first && !currentRow.collapsed)
+ if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
{
- currentRow.collapsed = true;
+ if(currentRow.subRows.first && !currentRow.collapsed)
+ {
+ currentRow.collapsed = true;
+ }
+ else if(currentRow.parent)
+ SetCurrentRow(currentRow.parent, true);
+ return false;
}
- else if(currentRow.parent)
- SetCurrentRow(currentRow.parent, true);
- return false;
- }
- break;
- case right:
- if(style.collapse && currentRow && currentRow.subRows.first)
- {
- if(currentRow.collapsed)
- currentRow.collapsed = false;
- else
- SetCurrentRow(currentRow.subRows.first, true);
- return false;
- }
- else if(style.alwaysEdit)
- {
- if(currentField)
+ break;
+ case right:
+ if(style.collapse && currentRow && currentRow.subRows.first)
+ {
+ if(currentRow.collapsed)
+ currentRow.collapsed = false;
+ else
+ SetCurrentRow(currentRow.subRows.first, true);
+ return false;
+ }
+ else if(style.alwaysEdit)
{
- DataField field;
- for(field = currentField.next; field; field = field.next)
+ if(currentField)
{
- if(field.editable)
+ DataField field;
+ for(field = currentField.next; field; field = field.next)
{
- currentField = field;
- HideEditBox(true, true, false);
- PopupEditBox(currentField, false);
- break;
- }
+ if(field.editable)
+ {
+ currentField = field;
+ HideEditBox(true, true, false);
+ PopupEditBox(currentField, false);
+ break;
+ }
+ }
}
}
- }
- break;
- case down: case up:
- case pageDown: case pageUp:
- case end: case home:
- {
- int headerSize = ((style.header) ? rowHeight : 0);
- int height = clientSize.h + 1 - headerSize;
- DataRow oldRow;
+ break;
+ case down: case up:
+ case pageDown: case pageUp:
+ case end: case home:
+ {
+ int headerSize = ((style.header) ? rowHeight : 0);
+ int height = clientSize.h + 1 - headerSize;
+ DataRow oldRow;
- // true: destroy edit box
- // !!! TESTING true HERE !!!
- HideEditBox(true, true, false);
- // HideEditBox(false, true, false);
-
- oldRow = currentRow;
+ // true: destroy edit box
+ // !!! TESTING true HERE !!!
+ HideEditBox(true, true, false);
+ // HideEditBox(false, true, false);
- SNAPDOWN(height, rowHeight);
- if((!currentRow || key.code == home) && key.code != end)
- {
- currentRow = rows.first;
- }
- else
- {
- DataRow next;
- switch(key.code)
+ oldRow = currentRow;
+
+ SNAPDOWN(height, rowHeight);
+ if((!currentRow || key.code == home) && key.code != end)
{
- case down:
- if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
- next = currentRow;
- else
- next = currentRow.GetNextRow();
- if(next)
+ currentRow = rows.first;
+ }
+ else
+ {
+ DataRow next;
+ switch(key.code)
+ {
+ case down:
+ if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
+ next = currentRow;
+ else
+ next = currentRow.GetNextRow();
+ if(next)
+ {
+ currentRow = next;
+ }
+ break;
+ case up:
+ if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
+ next = currentRow;
+ else
+ next = currentRow.GetPrevRow();
+
+ if(next)
+ {
+ currentRow = next;
+ }
+ break;
+ case end:
+ currentRow = lastRow.GetLastRow();
+ break;
+ case pageUp:
{
- currentRow = next;
+ int c;
+ for(c = 0;
+ currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
+ c++, currentRow = next);
+ break;
}
- break;
- case up:
- if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
- next = currentRow;
- else
- next = currentRow.GetPrevRow();
-
- if(next)
+ case pageDown:
{
- currentRow = next;
+ int c;
+ for(c = 0;
+ currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
+ c++, currentRow = next);
+ break;
}
- break;
- case end:
- // TODO: Find very last row
- for(currentRow = rows.last; currentRow && !currentRow.collapsed && currentRow.subRows.last;)
- currentRow = currentRow.subRows.last;
- break;
- case pageUp:
- {
- int c;
- for(c = 0;
- currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
- c++, currentRow = next);
- break;
- }
- case pageDown:
- {
- int c;
- for(c = 0;
- currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
- c++, currentRow = next);
- break;
}
}
- }
- if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
- SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
- else if(!currentRow || currentRow.index * rowHeight < scroll.y)
- SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
-
- if(style.multiSelect)
- {
- DataRow selRow;
+ if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
+ SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
+ else if(!currentRow || currentRow.index * rowHeight < scroll.y)
+ SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
- if(!(key.shift) && (key.ctrl))
+ if(style.multiSelect)
{
- DataRow row;
- for(row = rows.first; row; row = row.GetNextRow())
+ DataRow selRow;
+
+ if(!(key.shift) && (key.ctrl))
{
- if(row.selectedFlag == tempSelected)
- row.selectedFlag = selected;
- else if(row.selectedFlag == tempUnselected)
- row.selectedFlag = unselected;
+ DataRow row;
+ for(row = rows.first; row; row = row.GetNextRow())
+ {
+ if(row.selectedFlag == tempSelected)
+ row.selectedFlag = selected;
+ else if(row.selectedFlag == tempUnselected)
+ row.selectedFlag = unselected;
+ }
}
- }
- if(!(key.ctrl))
- {
- for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
- selRow.selectedFlag = unselected;
- }
- else
- {
- for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
+ if(!(key.ctrl))
{
- if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
- else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
+ for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
+ selRow.selectedFlag = unselected;
+ }
+ else
+ {
+ for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
+ {
+ if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
+ else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
+ }
}
- }
- if(key.shift)
- {
- if(currentRow.index >= clickedRow.index)
+ if(key.shift)
{
- for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
+ if(currentRow.index >= clickedRow.index)
{
- if(key.ctrl)
+ for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
{
- if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
+ if(key.ctrl)
+ {
+ if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
+ }
+ else
+ selRow.selectedFlag = selected;
+ if(selRow == currentRow)
+ break;
+ }
+ }
+ else
+ {
+ for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
+ {
+ if(key.ctrl)
+ {
+ if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
+ }
+ else
+ selRow.selectedFlag = selected;
+ if(selRow == clickedRow)
+ break;
}
- else
- selRow.selectedFlag = selected;
- if(selRow == currentRow)
- break;
}
}
else
{
- for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
+ if(!(key.ctrl) && currentRow)
{
- if(key.ctrl)
- {
- if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
- }
- else
- selRow.selectedFlag = selected;
- if(selRow == clickedRow)
- break;
+ currentRow.selectedFlag = selected;
}
+
+ clickedRow = currentRow;
}
}
else
{
- if(!(key.ctrl) && currentRow)
- {
- currentRow.selectedFlag = selected;
- }
-
- clickedRow = currentRow;
+ if(oldRow) oldRow.selectedFlag = unselected;
+ if(currentRow) currentRow.selectedFlag = selected;
}
- }
- else
- {
- if(oldRow) oldRow.selectedFlag = unselected;
- if(currentRow) currentRow.selectedFlag = selected;
- }
- if(currentRow)
- {
- if(style.freeSelect)
- NotifyHighlight(master, this, currentRow, 0);
- else
- NotifySelect(master, this, currentRow, 0);
+ if(currentRow)
+ {
+ if(style.freeSelect)
+ NotifyHighlight(master, this, currentRow, 0);
+ else
+ NotifySelect(master, this, currentRow, 0);
- if(style.alwaysEdit && currentRow)
- currentRow.Edit(currentField /*null*/);
+ if(style.alwaysEdit && currentRow)
+ currentRow.Edit(currentField /*null*/);
+ }
+ Update(null);
+ return false;
}
- Update(null);
- return false;
- }
- case space:
- {
- if(style.multiSelect && currentRow)
+ case space:
{
- if(currentRow.selectedFlag)
+ if(style.multiSelect && currentRow)
{
- if(key.ctrl)
- currentRow.selectedFlag = unselected;
- }
- else
- currentRow.selectedFlag = selected;
- Update(null);
+ if(currentRow.selectedFlag)
+ {
+ if(key.ctrl)
+ currentRow.selectedFlag = unselected;
+ }
+ else
+ currentRow.selectedFlag = selected;
+ Update(null);
- if(style.freeSelect)
- NotifyHighlight(master, this, currentRow, 0);
- else
- NotifySelect(master, this, currentRow, 0);
+ if(style.freeSelect)
+ NotifyHighlight(master, this, currentRow, 0);
+ else
+ NotifySelect(master, this, currentRow, 0);
+ }
+ break;
}
- break;
}
}
-
+
if(!NotifyKeyHit(master, this, currentRow, key, ch))
return false;
return true;
}
-
void OnHScroll(ScrollBarAction action, int position, Key key)
{
Update(null);