if(parent.IsExpanded())
{
DataRow search;
- int index;
+ int ix;
if(value)
{
}
}
- index = this.index+1;
+ ix = index+1;
for(search = GetNextRow(); search; search = search.GetNextRow())
- search.index = index++;
- listBox.rowCount = index;
+ search.index = ix++;
+ listBox.rowCount = ix;
listBox.HideEditBox(false, false, true);
if(this)
{
ListBoxCell cell = listBox.GetCell(&this, &field);
- if(cell && cell.isSet && cell.data)
+ if(cell && cell.isSet)
{
if((field.dataType.type == normalClass || field.dataType.type == noHeadClass))
return cell.data[0];
}
else
{
+ int size = (field.dataType && field.dataType.typeSize) ?
+ (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
// Free old data first
((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data);
+ FillBytes(cell.data, 0, size - (uint)(uintptr)&((ListBoxCell)0).data);
}
}
cell.isSet = false;
if(sortField.dataType.type == normalClass || sortField.dataType.type == noHeadClass)
{
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);
+ cell1.isSet ? cell1.data[0] : null,
+ cell2.isSet ? cell2.data[0] : null);
}
else
{
{
DataRow search;
- int index = this.index;
+ int ix = index;
for(search = this; search; search = search.GetNextRow())
- search.index = index++;
+ search.index = ix++;
}
if(scrollToCurrent)
{
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index++;
- this.rowCount++;
+ rowCount++;
row.cells.Clear();
firstRowShown = row;
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index++;
- this.rowCount++;
+ rowCount++;
row.cells.Clear();
for(c = 0; c<fields.count; c++)
{
{
for(search = row.GetNextRow(); search; search = search.GetNextRow())
search.index--;
- this.rowCount--;
+ rowCount--;
}
HideEditBox(false, false, true);
//HideEditBox(false, false, true);
SetScrollArea(
- this.width,
- (this.rowCount * rowHeight) +
+ width,
+ (rowCount * rowHeight) +
((style.header) ? rowHeight : 0) -
((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
currentRow.Edit(currentField);
- this.rowCount = 0;
+ rowCount = 0;
SetScrollArea(
- this.width,
- (this.rowCount * rowHeight) +
+ width,
+ (rowCount * rowHeight) +
((style.header) ? rowHeight : 0) -
((rowHeight && !((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
Update(null);
}
}
+#ifdef _DEBUG
+ static bool DebugFindRow(DataRow parent, DataRow row)
+ {
+ bool found = false;
+ DataRow r;
+ for(r = parent.subRows.first; r; r = r.next)
+ {
+ if(r == row)
+ {
+ found = true;
+ break;
+ }
+ if(DebugFindRow(r, row))
+ {
+ found = true;
+ break;
+ }
+ }
+ return found;
+ }
+#endif
+
void SetCurrentRow(DataRow row, bool notify)
{
+#if _DEBUG
+ if(this && row)
+ {
+ bool found = false;
+ DataRow r;
+ for(r = rows.first; r; r = r.next)
+ {
+ if(r == row)
+ {
+ found = true;
+ break;
+ }
+ if(DebugFindRow(r, row))
+ {
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ PrintLn("ERROR: Setting currentRow to a row not found in ListBox!!");
+ }
+#endif
if(this && (currentRow != row || (currentRow && currentRow.selectedFlag == unselected)))
{
int headerSize = ((style.header) ? rowHeight : 0);
Font font = fontObject;
Font boldFont = this.boldFont.font;
-
// Draw gray grid
if(style.alwaysEdit && style.fullRowSelect)
{
break;
}
if(firstRowShown) surface.Clip(null);
- if(this.dragRow && this.dropIndex != -1)
+ if(dragRow && dropIndex != -1)
{
- int dropIndex = this.dropIndex;
+ int ix = dropIndex;
int y;
- if(!style.multiSelect && currentRow.index < this.dropIndex)
- dropIndex++;
+ if(!style.multiSelect && currentRow.index < dropIndex)
+ ix++;
surface.DrawingChar(223);
y = style.header ? rowHeight : 0;
- y += dropIndex * rowHeight - scroll.y;
+ y += ix * rowHeight - scroll.y;
surface.SetForeground(Color { 85, 85, 255 });
surface.HLine(0, clientSize.w-1, y);
void OnDrawOverChildren(Surface surface)
{
- if(draggingField && this.dropField)
+ if(draggingField && dropField)
{
- int position = this.dropField.x;
+ int position = dropField.x;
if(draggingField.x < position)
- position += this.dropField.width + EXTRA_SPACE;
+ position += dropField.width + EXTRA_SPACE;
surface.SetForeground(Color { 85, 85, 255 });
surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
if(field.fixed) return false;
resizingField = field;
- this.resizeX = x + control.position.x;
- this.startWidth = field.width;
- this.oldX = x - scroll.x;
+ resizeX = x + control.position.x;
+ startWidth = field.width;
+ oldX = x - scroll.x;
return false;
}
else if(field)
x += control.position.x;
// Tweak to prevent shrinking field if we're actually moving right
- if(x - scroll.x > this.oldX &&
- this.startWidth + x - this.resizeX < field.width)
+ if(x - scroll.x > oldX &&
+ startWidth + x - resizeX < field.width)
{
- this.oldX = x - scroll.x;
+ oldX = x - scroll.x;
return true;
}
- this.oldX = x - scroll.x;
+ oldX = x - scroll.x;
- field.width = this.startWidth + x - this.resizeX;
+ field.width = startWidth + x - resizeX;
field.width = Max(field.width, - EXTRA_SPACE);
AdaptToFieldWidth(field, true);
SetScrollPosition(field.x, scroll.y);
field = null;
}
- if(this.dropField != field)
+ if(dropField != field)
{
- this.dropField = field;
+ dropField = field;
if(field)
{
int position = field.x;
SetScrollPosition(position, scroll.y);
}
- this.movingFields = true;
+ movingFields = true;
}
Update(null);
}
break;
}
}
- if(switchField && draggingField != switchField && this.dropField)
+ if(switchField && draggingField != switchField && dropField)
{
for(field = fields.first; field; field = field.next)
{
bool HeaderClicked(Button control, int x, int y, Modifiers mods)
{
- if(style.header && !this.dropField && style.sortable)
+ if(style.header && !dropField && style.sortable)
{
DataField field = (DataField)(intptr)control.id;
if(sortField == field)
}
if(!*h)
{
- *h = Min(this.maxShown, this.rowCount) * rowHeight;
+ *h = Min(maxShown, rowCount) * rowHeight;
}
}
else
{
// Resize left
DataField field = resizingField;
- field.width = this.startWidth + x - this.resizeX;
+ field.width = startWidth + x - resizeX;
field.width = Max(field.width, - EXTRA_SPACE);
AdaptToFieldWidth(field, true);
if(x == MAXINT && y == MAXINT)
{
- x = this.mouseX;
- y = this.mouseY;
+ x = mouseX;
+ y = mouseY;
isTimer = true;
}
// This must be done after the scrolling took place
rowIndex = firstRowShown ? firstRowShown.index : -1;
y = Max(y, 0);
- y = Min(y, clientSize.h-rowHeight-1);
+ y = Min(y, clientSize.h - ((dragRow && style.moveRows) ? rowHeight : 0)-1);
for(row = firstRowShown; row; row = nextRow, rowIndex ++)
{
nextRow = row.GetNextRow();
if(row && currentRow != row)
{
- if(this.dragRow && style.moveRows)
+ if(dragRow && style.moveRows)
{
if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
rowIndex = -1;
if(thisRow != row)
rowIndex++;
}
- if(this.dropIndex != rowIndex)
+ if(dropIndex != rowIndex)
{
- this.dropIndex = rowIndex;
- this.editRow = null;
+ dropIndex = rowIndex;
+ editRow = null;
Update(null);
- this.movedRow = true;
+ movedRow = true;
}
}
- else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || rolledOver))
+ else if((style.freeSelect || dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || rolledOver))
{
if(!(style.multiSelect))
{
if(Abs(x - vx) < 2)
{
resizingField = field.prev;
- this.resizeX = x;
- this.startWidth = resizingField.width;
+ resizeX = x;
+ startWidth = resizingField.width;
Capture();
SetMouseRangeToClient();
break;
for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
selRow.selectedFlag = unselected;
clickedRow = row;
- //this.clickedRowIndex = rowIndex;
+ //clickedRowIndex = rowIndex;
}
else if(style.moveRows && !(mods.shift) &&
(row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
row.selectedFlag = selected;
}
clickedRow = row;
- //this.clickedRowIndex = rowIndex;
+ //clickedRowIndex = rowIndex;
}
else
{
else
row.selectedFlag = tempSelected;
clickedRow = row;
- //this.clickedRowIndex = rowIndex;
+ //clickedRowIndex = rowIndex;
}
}
}
{
if(style.moveRows)
{
- this.dragRow = currentRow;
- this.dropIndex = -1;
- this.movedRow = false;
+ dragRow = currentRow;
+ dropIndex = -1;
+ movedRow = false;
Capture();
}
}
}
else if(!(mods.ctrl) && numSelected <= 1)
- this.editRow = currentRow;
+ editRow = currentRow;
if(style.noDragging && newCurrentRow)
NotifyReclick(master, this, newCurrentRow, mods);
}
else
{
- this.dragging = false;
+ dragging = false;
OnLeftButtonUp(x, y, mods);
}
return result;
break;
}
}
- if(this.editRow == switchRow && y >= 0)
+ if(editRow == switchRow && y >= 0)
{
// Find which field
DataField field;
}
else if(style.moveRows && switchRow)
{
- if(this.dragRow == switchRow && this.movedRow == false)
+ if(dragRow == switchRow && movedRow == false)
{
- DataRow row = this.dragRow;
+ DataRow row = dragRow;
DataRow selRow;
if(!(mods.ctrl))
{
{
for(row = rows.first; row; row = row.GetNextRow())
{
- if(row == switchRow || row == this.dragRow)
+ if(row == switchRow || row == dragRow)
break;
}
looped = true;
}
typingTimer.Stop();
- if(this.typingTimeOut && !keyHit)
+ if(typingTimeOut && !keyHit)
typingTimer.Start();
- if(!result || !this.typingTimeOut || keyHit)
+ if(!result || !typingTimeOut || keyHit)
typedString[len-1] = '\0';
}
if(!checkNextField || result) break;
}
else if(key == escape)
{
- if(resizingField || this.movingFields || (editData && editData.visible) || dragRow)
+ if(resizingField || movingFields || (editData && editData.visible) || dragRow)
{
if(editData && editData.visible && style.alwaysEdit && !editData.active)
return true;
HideEditBox(false, false, false);
if(resizingField)
{
- resizingField.width = this.startWidth;
+ resizingField.width = startWidth;
AdaptToFieldWidth(resizingField, true);
resizingField = null;
ReleaseCapture();
ReleaseCapture();
}
- this.movingFields = false;
+ movingFields = false;
draggingField = null;
Update(null);
return false;
int rowCount;
int rowHeight;
int fontH;
- double typingTimeOut;
+ public double typingTimeOut;
char * typedString;
int mouseX, mouseY;