1 namespace gui::controls;
5 static define branchesColor = Color { 85, 85, 85 };
6 static define headerCollapseForeground = Color { 135, 135, 135 };
7 static define dataBoxBackground = Color { 67, 134, 198 };
8 static define dataBoxForeground = lightYellow;
10 #define SNAPDOWN(x, d) \
13 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
18 static class ListBoxCell : struct
20 ListBoxCell prev, next;
26 #define RESIZE_BORDER 5
32 bool header:1, freeSelect:1 /*Exclusive to ELS_MULTISELECT*/, fullRowSelect:1, multiSelect:1, autoScroll:1, alwaysHL : 1, moveRows:1, resizable:1;
33 bool moveFields:1, clearHeader:1, alwaysEdit:1, collapse:1, treeBranch:1, rootCollapse:1, heightSet:1;
34 bool sortable:1, noDragging:1, fillLastField:1, expandOnAdd:1;
37 public class DataDisplayFlags
39 public bool selected:1, fullRow:1, current:1, active:1, dropBox:1, header:1, firstField:1;
42 enum SelectedFlag { unselected, selected, tempSelected, tempUnselected };
45 extern int __ecereVMethodID_class_OnEdit;
46 extern int __ecereVMethodID_class_OnDisplay;
47 extern int __ecereVMethodID_class_OnGetString;
48 extern int __ecereVMethodID_class_OnFree;
49 extern int __ecereVMethodID_class_OnCompare;
50 extern int __ecereVMethodID_class_OnCopy;
51 extern int __ecereVMethodID_class_OnSaveEdit;
55 public class DataField
58 property Class dataType
60 set { dataType = value; if(value) { alignment = (Alignment)value.defaultAlignment; } } // NOTE: Class::defaultAlignment does not seem to be used anywhere
61 get { return dataType; }
63 property bool editable { set { editable = value; } };
64 property bool fixed { set { fixed = value; } get { return fixed; } };
65 property Alignment alignment
70 if(headButton) headButton.alignment = value;
71 if(listBox) listBox.Update(null);
73 get { return alignment; }
79 width = Max(value, -EXTRA_SPACE);
81 listBox.AdaptToFieldWidth(this, false);
85 property int index { get { return this ? index : 0; } };
94 for(field = listBox.fields.first; field; field = field.next)
96 if(index == value - 2)
109 for(field = listBox.fields.first; field; field = field.next)
121 property int sortOrder { get { return this ? sortOrder : 0; } };
122 property char * header
128 headButton.text = header;
131 property void * userData
139 return this ? userData : null;
142 property bool freeData
144 set { freeData = value; } get { return freeData; }
146 property DataField prev { get { return prev; } };
147 property DataField next { get { return next; } };
149 void Move(DataField after)
156 listBox.fields.Move(this, after);
159 listBox.OnResize(listBox.clientSize.w, listBox.clientSize.h);
160 listBox.Update(null);
166 if(listBox && dataType)
168 Display display = listBox.display;
169 Font boldFont = listBox.boldFont.font;
170 Font font = listBox.fontObject;
174 display.FontExtent(boldFont, header, strlen(header), &width, null);
175 width += EXTRA_SPACE;
176 for(row = listBox.firstRow; row; row = row.GetNextRow())
180 for(i = 0, cell = row.cells.first; i != index; i++, cell = cell.next);
181 if(cell && cell.isSet && dataType)
183 static char tempString[4096];
186 if(dataType.type == normalClass || dataType.type == noHeadClass)
187 string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, cell.data[0], tempString, userData, null);
189 string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, cell.data, tempString, userData, null);
191 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, null);
193 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, null);
194 if(tw > width) width = tw;
198 property::width = width;
205 // property::dataType = "String";
206 property::dataType = "char *";
218 headButton.Destroy(0);
223 listBox.fields.Remove(this);
224 for(field = listBox.fields.first; field; field = field.next)
226 if(field.index >= index)
229 if(listBox.currentField == this)
230 listBox.currentField = null;
232 listBox.OnResize(listBox.clientSize.w, listBox.clientSize.h);
237 DataField prev, next;
261 property int64 tag { set { tag = value; } get { return tag; } };
262 property DataRow previous { get { return prev; } };
263 property DataRow next { get { return next; } };
264 property int index { get { return (this && (!parent || parent.IsExpanded())) ? index : -1; } };
265 property char * string
267 set { SetData(listBox.fields.first, value); }
268 get { return GetData(listBox.fields.first); }
270 property bool isHeader { set { header = value; } get { return this ? header : false; } };
271 property BitmapResource icon { set { icon = value; } get { return icon; } };
272 property bool collapsed
276 if(collapsed != value)
279 if(parent.IsExpanded())
286 for(search = subRows.first; search; search = search.next)
287 search.selectedFlag = 0;
289 if(listBox.clickedRow && !listBox.clickedRow.parent.IsExpanded())
291 listBox.clickedRow = GetNextRow();
292 if(!listBox.clickedRow)
293 listBox.clickedRow = this;
295 if(listBox.currentRow && !listBox.currentRow.parent.IsExpanded())
297 listBox.SetCurrentRow(this, true);
299 if(listBox.firstRowShown && !listBox.firstRowShown.parent.IsExpanded())
301 listBox.firstRowShown = GetPrevRow();
302 if(!listBox.firstRowShown)
303 listBox.firstRowShown = this;
307 index = this.index+1;
308 for(search = GetNextRow(); search; search = search.GetNextRow())
309 search.index = index++;
310 listBox.rowCount = index;
312 listBox.HideEditBox(false, false, true);
314 listBox.SetScrollArea(
316 (listBox.rowCount * listBox.rowHeight) +
317 ((listBox.style.header) ? listBox.rowHeight : 0) -
318 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
319 listBox.Update(null);
320 listBox.NotifyCollapse(listBox.master, listBox, this, value);
325 listBox.CheckConsistency();
328 get { return this ? collapsed : false; }
330 property bool selected
336 selectedFlag = value ? selected : unselected;
337 listBox.Update(null);
340 get { return selectedFlag == selected || selectedFlag == tempSelected; }
342 property DataRow parent
346 if(this && (value != this))
349 DataRow after = value ? value.subRows.last : listBox.rows.last;
350 int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
351 if(parent.IsExpanded())
353 for(search = GetNextRow(); search; search = search.GetNextRow())
354 search.index -= ixCount;
355 listBox.rowCount -= ixCount;
358 listBox.HideEditBox(false, false, true);
361 if(this == listBox.clickedRow)
363 listBox.clickedRow = GetNextRow();
364 if(!listBox.clickedRow)
365 listBox.clickedRow = GetPrevRow();
368 if(this == listBox.currentRow)
370 DataRow newCurrentRow = GetNextRow();
371 if(!listBox.newCurrentRow)
372 listBox.newCurrentRow = GetPrevRow();
373 listBox.SetCurrentRow(newCurrentRow, true);
376 if(this == listBox.firstRowShown)
378 listBox.firstRowShown = GetPrevRow();
379 if(!listBox.firstRowShown)
380 listBox.firstRowShown = GetNextRow();
384 (parent ? parent.subRows : listBox.rows).Remove(this);
387 value.subRows.Insert(after, this);
389 listBox.rows.Insert(after, this);
393 if(value && listBox.style.expandOnAdd)
396 value.skipCheck = true;
398 value.collapsed = false;
400 value.skipCheck = false;
404 if(value.IsExpanded())
408 if(after && after.subRows.first && !after.collapsed)
410 search = after.GetLastRow();
411 index = search.index + 1;
414 index = after ? (after.index + 1) : (index + 1);
416 listBox.rowCount += ixCount;
420 for(search = GetNextRow(); search; search = search.GetNextRow())
424 listBox.SetScrollArea(
426 (listBox.rowCount * listBox.rowHeight) +
427 ((listBox.style.header) ? listBox.rowHeight : 0) -
428 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
429 if(listBox.style.autoScroll)
430 listBox.SetScrollPosition(0, MAXINT - listBox.rowHeight);
432 // TESTING THIS HERE...
434 listBox.Sort(listBox.sortField, listBox.sortField.sortOrder);
437 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
438 int height = listBox.clientSize.h + 1 - headerSize;
439 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
440 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
441 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
443 int line = listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0;
444 listBox.SetScrollPosition(listBox.scroll.x, line);
447 listBox.OnVScroll(0, listBox.scroll.y, 0);
449 listBox.Update(null);
457 property DataRow lastRow { get { return this ? subRows.last : null; } };
458 property DataRow firstRow { get { return this ? subRows.first : null; } };
460 void Edit(DataField field)
466 if(!field || !field.editable)
468 for(field = listBox.fields.first; field; field = field.next)
469 if(field.editable) break;
471 if(field && field.editable)
473 listBox.SetCurrentRow(this, true);
474 listBox.PopupEditBox(field, false);
480 // NOTE: This does not support reparenting (Use row.parent = first)
481 void Move(DataRow after)
486 if(listBox && prev != after)
490 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
491 int height = listBox.clientSize.h + 1 - headerSize;
492 int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
494 if(!after || after.index < index)
496 if(after == listBox.firstRowShown.prev)
497 listBox.firstRowShown = this;
499 // All rows between AFTER (exclusive) and ROW (exclusive) are incremented by one
500 // ROW is equal to AFTER's index + 1
502 for(search = after ? after.next : listBox.rows.first; search && search != this; search = search.GetNextRow())
503 search.index += ixCount;
505 if(after && after.subRows.first && !after.collapsed)
507 search = after.GetLastRow();
508 index = search.index + 1;
511 index = after ? (after.index + 1) : 0;
513 // Fix indices of sub rows
517 for(c = 1, search = GetNextRow(); search && c < ixCount; c++, search = search.GetNextRow())
523 DataRow nextRow = GetNextRow();
524 if(this == listBox.firstRowShown)
525 listBox.firstRowShown = nextRow;
528 // All rows between ROW (exclusive) and AFTER (inclusive) are decremented by one
529 // ROW is equal to AFTER's index
531 for(search = nextRow; search; search = search.GetNextRow())
533 search.index -= ixCount;
534 if(search == after) break;
537 listBox.rows.Move(this, after);
540 listBox.CheckConsistency();
543 listBox.HideEditBox(true, false, true);
546 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
547 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
548 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
550 int line = listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0;
551 //SNAPUP(line, listBox.rowHeight);
552 listBox.SetScrollPosition(listBox.scroll.x, line);
555 listBox.OnVScroll(0, listBox.scroll.y, 0);
557 listBox.modifiedDocument = true;
559 listBox.Update(null);
566 any_object GetData(DataField field)
570 ListBoxCell cell = listBox.GetCell(&this, &field);
571 if(cell && cell.isSet && cell.data)
573 if((field.dataType.type == normalClass || field.dataType.type == noHeadClass))
576 return (void *)cell.data; // Cast for MemoryGuard
582 void * SetData(DataField field, any_object newData)
586 ListBoxCell cell = listBox.GetCell(&this, &field);
589 Class dataType = field.dataType;
593 if(dataType.type == normalClass || dataType.type == noHeadClass)
595 if(cell.data[0] && field.freeData)
596 ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data[0]);
598 if(eClass_IsDerived(dataType, class(char *)) && field.freeData)
599 ((void (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCopy])(dataType, cell.data, newData);
601 cell.data[0] = (void *)newData;
605 // Free old data first
606 ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data);
607 ((void (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCopy])(dataType, cell.data, newData);
611 listBox.modifiedDocument = true;
612 listBox.Update(null);
613 if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
614 return (void *)cell.data; // Cast for MemoryGuard
622 void UnsetData(DataField field)
626 ListBoxCell cell = listBox.GetCell(&this, &field);
629 Class dataType = field.dataType;
633 if(dataType.type == normalClass || dataType.type == noHeadClass)
635 if(cell.data[0] && field.freeData)
636 ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data[0]);
641 // Free old data first
642 ((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, cell.data);
646 listBox.Update(null);
651 DataRow FindRow(int64 tag)
654 for(row = subRows.first; row; row = row.next)
656 if(!row.noneRow && row.tag == tag)
662 DataRow FindSubRow(int64 tag)
665 for(row = subRows.first; row; row = row.next)
667 if(!row.noneRow && row.tag == tag)
669 if(row.subRows.first)
671 DataRow subRow = row.FindSubRow(tag);
679 DataRow AddRowAfter(DataRow after)
689 subRows.Insert(after, row);
690 row.listBox = listBox;
694 for(c = 0; c<listBox.fields.count; c++)
696 for(field = listBox.fields.first; field; field = field.next)
697 if((int)field.index == c)
701 int size = (field.dataType && field.dataType.typeSize) ?
702 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
703 ListBoxCell cell = (ListBoxCell)new0 byte[size];
705 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
714 if(after && after.subRows.first && !after.collapsed)
716 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
717 search = search.subRows.last;
718 row.index = search.index + 1;
721 row.index = after ? (after.index + 1) : (index + 1);
725 for(search = row.GetNextRow(); search; search = search.GetNextRow())
728 listBox.SetScrollArea(
730 (listBox.rowCount * listBox.rowHeight) +
731 ((listBox.style.header) ? listBox.rowHeight : 0) -
732 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
733 if(listBox.style.autoScroll)
734 listBox.SetScrollPosition(0, MAXINT - listBox.rowHeight);
737 listBox.modifiedDocument = true;
740 listBox.CheckConsistency();
750 return AddRowAfter(subRows.last);
754 DataRow AddStringf(char * format, ...)
759 char string[MAX_F_STRING];
761 va_start(args, format);
762 vsnprintf(string, sizeof(string), format, args);
763 string[sizeof(string)-1] = 0;
767 row.SetData(null, string);
773 DataRow AddString(char * string)
779 row.SetData(listBox.fields.first, string);
789 subRows.offset = (uint)&((DataRow)0).prev;
794 ListBoxCell cell, next;
799 while((subRow = subRows.first))
801 subRows.Remove(subRow);
805 for(cell = cells.first; cell; cell = next, cellIndex++)
810 for(field = listBox.fields.first; field && field.index != cellIndex; field = field.next);
811 if(field && field.dataType)
813 // TOCHECK: Is this check good? Will need incref/decref sometime?
814 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
816 if(cell.data[0] && field.freeData)
817 ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data[0]);
820 ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data);
830 return !this || (!collapsed && (!parent || parent.IsExpanded()));
833 int Compare(DataRow b, DataField sortField)
836 ListBoxCell cell1, cell2;
838 for(index = 0, cell1 = cells.first, cell2 = b.cells.first;
839 index != sortField.index;
840 index++, cell1 = cell1.next, cell2 = cell2.next);
842 if(!cell1.isSet && !cell2.isSet)
844 else if(!cell1.isSet)
846 else if(!cell2.isSet)
849 if(noneRow && !b.noneRow) return -1;
850 else if(!noneRow && b.noneRow) return 1;
851 else if(noneRow && b.noneRow) return 0;
853 if(sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])
855 if(sortField.dataType.type == normalClass || sortField.dataType.type == noHeadClass)
857 result = ((int (*)(void *, void *, void *))(void *)sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])(sortField.dataType,
858 (cell1.isSet && cell1.data) ? cell1.data[0] : null,
859 (cell2.isSet && cell2.data) ? cell2.data[0] : null);
863 result = ((int (*)(void *, void *, void *))(void *)sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])(sortField.dataType,
864 cell1.isSet ? cell1.data : null,
865 cell2.isSet ? cell2.data : null);
868 return sortField.sortOrder * result;
871 void _SortSubRows(DataField field, int order)
874 for(search = subRows.first; search; search = search.next)
875 search._SortSubRows(field, order);
876 subRows.Sort(Compare, field);
879 public void SortSubRows(bool scrollToCurrent)
881 if(this && listBox && listBox.sortField)
883 _SortSubRows(listBox.sortField, listBox.sortField.sortOrder);
887 int index = this.index;
888 for(search = this; search; search = search.GetNextRow())
889 search.index = index++;
893 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
894 int height = listBox.clientSize.h + 1 - headerSize;
895 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
896 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
897 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
898 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0);
899 listBox.OnVScroll(0, listBox.scroll.y, 0);
904 public DataRow GetPrevRow()
910 for(row = prev; row && !row.collapsed && row.subRows.last; row = row.subRows.last);
917 public DataRow GetNextRow()
921 if(subRows.first && !collapsed)
925 for(row = this; row; row = row.parent)
927 if(row.next) { row = row.next; break; }
933 private DataRow GetLastRow()
936 while(row && !row.collapsed && row.subRows.last)
937 row = row.subRows.last;
944 SelectedFlag selectedFlag;
955 public class ListBox : CommonControl
957 hasVertScroll = true;
958 // background = white;
960 snapVertScroll = true;
962 class_property(icon) = "<:ecere>controls/listBox.png";
966 property bool freeSelect { property_category $"Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } };
967 property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } };
968 property DataField currentField
970 get { return currentField; }
971 // TODO: Document what this does
974 currentField = value;
975 HideEditBox(true, true, false);
976 if(value && value.editable)
977 PopupEditBox(currentField, false);
981 property int rowHeight
983 property_category $"Appearance"
984 isset { return style.heightSet; }
989 style.heightSet = true;
991 SetScrollLineStep(8, value);
995 style.heightSet = false;
1000 get { return rowHeight; }
1002 property Seconds typingTimeout
1004 property_category $"Behavior"
1007 typedString[0] = '\0';
1008 typingTimer.delay = value;
1009 typingTimeOut = value;
1011 get { return typingTimeOut; }
1013 property bool moveRows { property_category $"Behavior" set { style.moveRows = value; } get { return style.moveRows; } };
1014 property bool moveFields { property_category $"Behavior" set { style.moveFields = value; } get { return style.moveFields; } };
1015 property bool resizable { property_category $"Behavior" set { style.resizable = value; } get { return style.resizable; } };
1016 property bool autoScroll { property_category $"Behavior" set { style.autoScroll = value; } get { return style.autoScroll; } };
1017 property bool alwaysHighLight { property_category $"Appearance" set { style.alwaysHL = value; } get { return style.alwaysHL; } };
1018 property bool hasClearHeader { property_category $"Appearance" set { style.clearHeader = value; if(value) property::hasHeader = true; } get { return style.clearHeader; } };
1019 property bool hasHeader
1021 property_category $"Appearance"
1024 if(value && !style.header)
1030 bevel = !guiApp.textMode && !style.clearHeader;
1031 dontScrollVert = true;
1034 NotifyPushed = HeaderPushed;
1035 NotifyClicked = HeaderClicked;
1036 NotifyDoubleClick = HeaderDoubleClicked;
1037 NotifyReleased = HeaderReleased;
1038 NotifyMouseMove = HeaderMouseMove;
1042 endBevel.visible = false;
1044 style.header = value;
1046 get { return style.header; }
1048 property bool multiSelect { property_category $"Behavior" set { style.multiSelect = value; } get { return style.multiSelect; } };
1049 property bool alwaysEdit { property_category $"Behavior" set { style.alwaysEdit = value; } get { return style.alwaysEdit; } };
1050 property bool fullRowSelect { property_category $"Appearance" set { style.fullRowSelect = value; } get { return style.fullRowSelect; } };
1051 property bool collapseControl { property_category $"Appearance" set { style.collapse = value; } get { return style.collapse; } };
1052 property bool treeBranches { property_category $"Appearance" set { style.treeBranch = value; } get { return style.treeBranch; } };
1053 property bool rootCollapseButton { property_category $"Appearance" set { style.rootCollapse = value; } get { return style.rootCollapse; } };
1054 property bool sortable { property_category $"Behavior" set { style.sortable = value; } get { return style.sortable; } };
1055 property bool noDragging { property_category $"Behavior" set { style.noDragging = value; } get { return style.noDragging; } };
1056 property bool fillLastField
1058 property_category $"Behavior"
1061 style.fillLastField = value;
1063 get { return style.fillLastField; }
1065 property int numSelections
1069 int numSelections = 0;
1070 if(this && style.multiSelect)
1073 for(row = rows.first; row; row = row.GetNextRow())
1074 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1077 return numSelections;
1080 property int currentIndex
1082 get { return currentRow ? currentRow.index : -1; }
1084 property DataRow lastRow { get { return this ? rows.last : null; } };
1085 property DataRow firstRow { get { return this ? rows.first : null; } };
1086 property int rowCount { get { return rowCount; } };
1087 property DataField firstField { get { return this ? fields.first : null; } };
1088 property Color selectionColor { set { selectionColor = value; } get { return selectionColor; } isset { return selectionColor ? true : false; } };
1089 property Color selectionText { set { selectionText = value; } get { return selectionText; } isset { return selectionText ? true : false; } };
1090 property Color stippleColor { set { stippleColor = value; } get { return stippleColor; } };
1091 property bool expandOnAdd { set { style.expandOnAdd = value; } get { return style.expandOnAdd; } };
1094 virtual bool Window::NotifySelect(ListBox listBox, DataRow row, Modifiers mods);
1095 virtual bool Window::NotifyHighlight(ListBox listBox, DataRow row, Modifiers mods);
1096 virtual bool Window::NotifyReclick(ListBox listBox, DataRow row, Modifiers mods);
1097 virtual bool Window::NotifySort(ListBox listBox, DataField field, Modifiers mods);
1098 virtual bool Window::NotifyChanged(ListBox listBox, DataRow row);
1099 virtual bool Window::NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch);
1100 virtual bool Window::NotifyEdited(ListBox listBox, DataRow row);
1101 virtual bool Window::NotifyEditDone(ListBox listBox, DataRow row);
1102 virtual bool Window::NotifyMovedField(ListBox listBox, DataField field, Modifiers mods);
1103 virtual bool Window::NotifyMove(ListBox listBox, DataRow row, Modifiers mods);
1104 virtual bool Window::NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods);
1105 virtual bool Window::NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods);
1106 virtual bool Window::NotifyResized(ListBox listBox, DataField field, Modifiers mods);
1107 virtual bool Window::NotifyCollapse(ListBox listBox, DataRow row, bool collapsed);
1108 virtual bool Window::NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch);
1109 virtual bool Window::NotifyModified(ListBox listBox, DataRow row);
1110 virtual bool Window::NotifyEditing(ListBox listBox, DataRow row);
1113 private void CheckConsistency()
1118 for(r = rows.first; r; r = r.GetNextRow())
1120 if(r.index != index++)
1128 void AddField(DataField addedField)
1133 if(fields.first && ((DataField)fields.first).defaultField)
1135 DataField defaultField = fields.first;
1136 defaultField.Free();
1137 delete defaultField;
1141 addedField = DataField { };
1145 addedField.listBox = this;
1146 fields.Add(addedField);
1148 addedField.sortOrder = 1;
1149 addedField.index = numFields;
1153 addedField.headButton.Destroy(0);
1154 delete addedField.headButton;
1155 addedField.headButton = Button
1160 dontScrollVert = true;
1161 id = (uint64)addedField;
1162 text = addedField.header;
1163 bevel = (!guiApp.textMode && !style.clearHeader);
1165 alignment = addedField.alignment;
1166 NotifyPushed = HeaderPushed;
1167 NotifyClicked = HeaderClicked;
1168 NotifyDoubleClick = HeaderDoubleClicked;
1169 NotifyReleased = HeaderReleased;
1170 NotifyMouseMove = HeaderMouseMove;
1172 incref addedField.headButton;
1173 addedField.headButton.Create();
1176 addedField.headButton.background = Color { 0, 170, 0 };
1182 for(row = rows.first; row; )
1184 int size = (field.dataType && field.dataType.typeSize) ?
1185 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1186 ListBoxCell cell = (ListBoxCell)new0 byte[size];
1187 row.cells.Add(cell);
1188 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1191 if(row.subRows.first)
1192 row = row.subRows.first;
1195 for(; row; row = row.parent)
1197 if(row.next) { row = row.next; break; }
1202 OnResize(clientSize.w, clientSize.h);
1211 Clear(); // Ensure data is cleared first
1212 while((field = fields.first))
1217 endBevel.visible = false;
1222 void RemoveField(DataField field)
1228 int index = field.index;
1231 if(sortField == field)
1234 for(row = rows.first; row; )
1239 for(cell = row.cells.first, c = 0; c < index && cell; c++, cell = cell.next);
1240 if(cell && index == c)
1244 // TOCHECK: Is this check good? Will need incref/decref sometime?
1245 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
1247 if(cell.data[0] && field.freeData)
1248 ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data[0]);
1251 ((void (*)(void *, void *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnFree])(field.dataType, cell.data);
1254 row.cells.Remove(cell);
1258 if(row.subRows.first)
1259 row = row.subRows.first;
1262 for(; row; row = row.parent)
1264 if(row.next) { row = row.next; break; }
1273 endBevel.visible = false;
1277 DataRow AddRowNone()
1279 DataRow row { noneRow = true };
1288 rows.Insert(null, row);
1291 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1297 firstRowShown = row;
1301 (rowCount * rowHeight) +
1302 ((style.header) ? rowHeight : 0) -
1303 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1304 if(style.autoScroll)
1305 SetScrollPosition(0, MAXINT - rowHeight);
1306 modifiedDocument = true;
1325 // Find very last row
1328 for(lastRow = rows.last; lastRow && !lastRow.collapsed && lastRow.subRows.last; lastRow)
1329 lastRow = lastRow.subRows.last;
1330 row.index = lastRow ? (lastRow.index + 1) : 0;
1338 for(c = 0; c<fields.count; c++)
1340 for(field = fields.first; field; field = field.next)
1341 if((int)field.index == c)
1345 int size = (field.dataType && field.dataType.typeSize) ?
1346 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1347 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1348 row.cells.Add(cell);
1349 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1356 firstRowShown = row;
1362 (rowCount * rowHeight) +
1363 ((style.header) ? rowHeight : 0) -
1364 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1365 if(style.autoScroll)
1366 SetScrollPosition(0, MAXINT - rowHeight);
1367 modifiedDocument = true;
1378 DataRow AddRowAfter(DataRow after)
1390 if(after && after.subRows.first && !after.collapsed)
1392 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
1393 search = search.subRows.last;
1394 row.index = search.index + 1;
1397 row.index = after ? (after.index + 1) : 0;
1398 rows.Insert(after, row);
1401 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1406 for(c = 0; c<fields.count; c++)
1408 for(field = fields.first; field; field = field.next)
1409 if((int)field.index == c)
1413 int size = (field.dataType && field.dataType.typeSize) ?
1414 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1415 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1416 row.cells.Add(cell);
1417 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1421 if(!firstRowShown || !after)
1423 firstRowShown = row;
1428 (rowCount * rowHeight) +
1429 ((style.header) ? rowHeight : 0) -
1430 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1431 if(style.autoScroll)
1432 SetScrollPosition(0, MAXINT - rowHeight);
1433 modifiedDocument = true;
1443 DataRow AddStringf(char * format, ...)
1449 char string[MAX_F_STRING];
1452 va_start(args, format);
1453 vsnprintf(string, sizeof(string), format ? format : "", args);
1454 string[sizeof(string)-1] = 0;
1458 row.SetData(fields.first, string);
1464 DataRow AddString(char * string)
1470 row.SetData(fields.first, string);
1476 void SelectRow(DataRow row)
1478 SetCurrentRow(row, true);
1481 void DeleteRow(DataRow row)
1483 if(!row) row = currentRow;
1486 DataRow sub, next, search;
1487 // Trying to move this here (Messed up deleting watches)
1488 //HideEditBox(false, false, true);
1491 for(sub = row.subRows.first; sub; sub = next)
1497 if(row.parent.IsExpanded())
1499 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1504 HideEditBox(false, false, true);
1506 if(row == clickedRow)
1508 clickedRow = row.GetNextRow();
1510 clickedRow = row.GetPrevRow();
1513 if(row == currentRow)
1515 DataRow newCurrentRow = row.GetNextRow();
1517 newCurrentRow = row.GetPrevRow();
1518 SetCurrentRow(newCurrentRow, true);
1521 if(row == firstRowShown)
1523 firstRowShown = row.GetPrevRow();
1525 firstRowShown = row.GetNextRow();
1528 (row.parent ? row.parent.subRows: rows).Remove(row);
1531 //HideEditBox(false, false, true);
1535 (this.rowCount * rowHeight) +
1536 ((style.header) ? rowHeight : 0) -
1537 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1539 modifiedDocument = true;
1548 DataRow FindRow(int64 tag)
1553 for(row = rows.first; row; row = row.next)
1555 if(!row.noneRow && row.tag == tag)
1563 DataRow FindString(char * searchedString)
1566 bool checkNextField = true;
1567 int len = searchedString ? strlen(searchedString) : 0;
1569 for(field = fields.first; field; field = field.next)
1571 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1574 for(row = rows.first; row; row = row.GetNextRow())
1578 void * data = row.GetData(field);
1579 char tempString[1024] = "";
1580 bool needClass = false;
1581 char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
1583 if(string && string[0])
1584 checkNextField = false;
1585 if(string && string[0] && !strcmp(string, searchedString))
1590 if(!checkNextField) break;
1595 DataRow FindSubString(char * subString)
1598 bool checkNextField = true;
1599 int len = subString ? strlen(subString) : 0;
1603 for(field = fields.first; field; field = field.next)
1605 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1608 for(row = rows.first; row; row = row.GetNextRow())
1612 void * data = row.GetData(field);
1613 char tempString[1024] = "";
1614 bool needClass = false;
1615 char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
1617 if(string && string[0])
1618 checkNextField = false;
1619 if(string && string[0] && !strncmp(string, subString, len))
1624 if(!checkNextField) break;
1630 DataRow FindSubStringi(char * subString)
1633 bool checkNextField = true;
1634 int len = subString ? strlen(subString) : 0;
1635 DataRow result = null;
1636 char * bestResult = null;
1641 for(field = fields.first; field; field = field.next)
1643 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1646 for(row = rows.first; row; row = row.GetNextRow())
1650 void * data = row.GetData(field);
1651 char tempString[1024] = "";
1652 bool needClass = false;
1653 char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
1655 if(string && string[0])
1656 checkNextField = false;
1657 if(string && string[0])
1659 int stringLen = strlen(string);
1661 if(!strnicmp(string, subString, Min(len, stringLen)))
1663 if(bestLen < Min(len, stringLen))
1665 if(!bestResult || strcmpi(string, bestResult) < 0)
1667 bestLen = Min(len, stringLen);
1668 bestResult = string;
1676 if(!checkNextField) break;
1682 DataRow FindSubStringAfter(DataRow after, char * subString)
1685 bool checkNextField = true;
1686 int len = subString ? strlen(subString) : 0;
1690 for(field = fields.first; field; field = field.next)
1692 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1695 for(row = after.GetNextRow(); row && row != after; row = row.GetNextRow(), (!row) ? (row = rows.first) : null)
1699 void * data = row.GetData(field);
1700 char tempString[1024] = "";
1701 bool needClass = false;
1702 char * string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass);
1704 if(string && string[0])
1705 checkNextField = false;
1706 if(string && string[0] && !strncmp(string, subString, len))
1711 if(!checkNextField) break;
1717 DataRow FindSubRow(int64 tag)
1723 for(row = rows.first; row; row = row.next)
1725 if(!row.noneRow && row.tag == tag)
1727 if(!row.noneRow && row.subRows.first)
1729 DataRow subRow = row.FindSubRow(tag);
1743 Window master = this.master;
1745 HideEditBox(false, true, false);
1746 editData.Destroy(0);
1748 firstRowShown = currentRow = null;
1753 if(style.freeSelect)
1754 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
1756 NotifySelect(master, this, currentRow ? currentRow : null, 0);
1759 if(style.alwaysEdit && currentRow)
1760 currentRow.Edit(currentField);
1767 (this.rowCount * rowHeight) +
1768 ((style.header) ? rowHeight : 0) -
1769 ((rowHeight && !((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1774 void Sort(DataField field, int order)
1779 int headerSize = ((style.header) ? rowHeight : 0);
1780 int height = clientSize.h + 1 - headerSize;
1782 if(!field) field = fields.first;
1784 field.sortOrder = order ? order : 1;
1785 rows.Sort(DataRow::Compare, field);
1787 for(search = rows.first; search; search = search.next)
1788 search._SortSubRows(field, order);
1792 for(search = rows.first; search; search = search.GetNextRow())
1793 search.index = index++;
1796 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1797 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
1798 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1799 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
1801 OnVScroll(0, scroll.y, 0);
1803 // SetScrollPosition(0, scroll.y);
1808 void StopEditing(bool save)
1810 HideEditBox(save, false, true);
1813 void GetMultiSelection(OldList list)
1816 if(this && style.multiSelect)
1820 for(row = rows.first; row; row = row.GetNextRow())
1822 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1824 list.Add(OldLink { data = row });
1830 // Convenience Current Row Methods
1831 void * SetData(DataField field, any_object data)
1833 return currentRow.SetData(field, data);
1836 any_object GetData(DataField field)
1838 return (void *)currentRow.GetData(field);
1843 return currentRow ? currentRow.tag : 0;
1849 DataField defaultField { };
1850 rows.offset = (uint)&((DataRow)0).prev;
1851 fields.offset = (uint)&((DataField)0).prev;
1852 style.fullRowSelect = true;
1853 style.fillLastField = true;
1854 style.expandOnAdd = true;
1855 typingTimeOut = 0.5;
1856 rowHeight = 16; // Stuff depending on creation and default property checking
1859 defaultField.defaultField = true;
1861 AddField(defaultField);
1863 typedString = new char[1];
1864 typedString[0] = '\0';
1879 while((field = fields.first))
1881 // fields.Remove(field);
1891 while((row = rows.first))
1898 ListBoxCell GetCell(DataRow * row, DataField * field)
1900 ListBoxCell cell = null;
1901 if(!*row) *row = currentRow;
1904 if(!*field) *field = this ? currentField : null;
1907 for(*field = fields.first; (*field).index != 0; *field = (*field).next);
1912 if(field->listBox == this)
1914 for(index = 0, cell = (*row).cells.first; cell && index != (*field).index; index++, cell = cell.next);
1921 void HideEditBox(bool save, bool alwaysStopEdit, bool repositionOnly)
1923 if(editData && editData.visible)
1925 Class dataType = currentField.dataType;
1927 editData.SaveData();
1929 editData.visible = false;
1930 NotifyEditDone(master, this, currentRow);
1932 // ENSURE DATA BOX IS NOT VISIBLE
1933 editData.visible = false;
1935 if(style.alwaysEdit && !alwaysStopEdit)
1938 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
1939 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
1940 int x = currentField.x;
1941 int width = (!currentField.next && style.fillLastField && (!hasHorzScroll || clientSize.w - currentField.x > currentField.width + EXTRA_SPACE)) ?
1942 clientSize.w - currentField.x : (currentField.width + EXTRA_SPACE);
1944 if(!style.alwaysEdit)
1946 editData.position = { x, y };
1947 editData.size = { width, height };
1951 editData.position = { x, y - editData.clientStart.y };
1952 editData.size = { width, height + editData.clientStart.y * 2 };
1954 editData.visible = true;
1955 if(style.alwaysEdit)
1956 editData.Deactivate();
1958 PopupEditBox(currentField, repositionOnly);
1964 currentField = null;*/
1968 void SetCurrentRow(DataRow row, bool notify)
1970 if(currentRow != row || (currentRow && currentRow.selectedFlag == unselected))
1972 int headerSize = ((style.header) ? rowHeight : 0);
1973 int height = clientSize.h + 1 - headerSize;
1975 // true: destroy edit box
1976 HideEditBox(true, true, false);
1978 if(!(style.multiSelect) && currentRow)
1979 currentRow.selectedFlag = unselected;
1983 if(style.multiSelect)
1987 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
1988 selRow.selectedFlag = unselected;
1990 currentRow.selectedFlag = selected;
1995 currentRow.selectedFlag = selected;
1997 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1998 SetScrollPosition(scroll.x,
1999 currentRow.index * rowHeight - height + rowHeight);
2000 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
2002 int line = currentRow ? currentRow.index * rowHeight : 0;
2003 //SNAPUP(line, rowHeight);
2004 SetScrollPosition(scroll.x, line);
2009 Window master = this.master;
2012 if(style.freeSelect && visible)
2013 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
2015 NotifySelect(master, this, currentRow ? currentRow : null, 0);
2016 if(style.alwaysEdit && currentRow)
2017 currentRow.Edit(currentField);
2025 void PopupEditBox(DataField whichField, bool repositionOnly)
2027 if((!editData || !editData.visible || currentField != whichField) && currentRow)
2029 // true: destroy edit box
2030 HideEditBox(true, true, false);
2033 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
2035 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
2037 //void * data = currentRow.GetData(whichField);
2042 if(style.collapse && !(style.treeBranch))
2045 for(field = fields.first; field; field = field.next)
2047 width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2048 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2049 if(field == whichField) break;
2053 currentField = whichField;
2054 cell = GetCell(&row, ¤tField);
2061 background = dataBoxBackground;
2062 foreground = dataBoxForeground;
2064 bool NotifyChanged(bool closingDropDown)
2067 DataField field = null;
2068 ListBoxCell cell = GetCell(&row, &field);
2072 modifiedDocument = true;
2074 NotifyChanged(master, this, currentRow);
2079 bool NotifyModified()
2081 //DataRow row = null;
2082 //DataField field = null;
2083 //ListBoxCell cell = GetCell(&row, &field);
2084 //cell.isSet = true;
2085 modifiedDocument = true;
2087 NotifyModified(master, this, currentRow);
2091 bool OnKeyDown(Key key, unichar ch)
2093 bool result = DataBox::OnKeyDown(key, ch);
2094 if(visible && active) // Added this check here, because we will not use enter/escape otherwise, and lose DataBox's result
2096 if((SmartKey)key == enter || (SmartKey)key == escape)
2105 editData.Destroy(0);
2106 editData.type = whichField.dataType;
2107 editData.fieldData = whichField.userData;
2108 editData.borderStyle = style.alwaysEdit ? 0 : deep;
2109 editData.data = cell ? cell.data : null;
2112 // Might not really need this anymore...
2113 NotifyEditing(master, this, currentRow);
2116 if(!style.alwaysEdit)
2118 editData.position = { x, y - editData.clientStart.y };
2119 editData.size = { width, height + editData.clientStart.y * 2 };
2123 editData.position = { x, y };
2124 editData.size = { width, height };
2128 editData.visible = true;
2130 if(style.alwaysEdit)
2131 editData.Deactivate();
2133 // MOVED THIS HIGHER FOR DATALIST EDITOR
2135 // Might not really need this anymore...
2136 NotifyEdited(master, this, currentRow);
2141 void OnRedraw(Surface surface)
2144 int y = (style.header) ? rowHeight : 0;
2145 bool isActive = active;
2146 Font font = fontObject;
2147 Font boldFont = this.boldFont.font;
2151 if(style.alwaysEdit && style.fullRowSelect)
2154 int y = (style.header) ? rowHeight : 0;
2155 int x = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
2156 int w = clientSize.w;
2157 int h = clientSize.h;
2161 // Fill out indent column
2162 if(style.collapse && !(style.treeBranch) && rows.first)
2165 surface.SetBackground(formColor);
2166 surface.Area(-scroll.x, 0, x, clientSize.h);
2169 surface.SetForeground(formColor);
2170 for(row = firstRowShown; row; row = row.GetNextRow())
2173 surface.HLine(x + 1, w-1, y-1);
2179 for(field = fields.first; field; field = field.next)
2181 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2182 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2183 if(field.prev && y > 0)
2184 surface.VLine(0, y-1, x);
2189 surface.foreground = this.foreground;
2190 surface.TextOpacity(false);
2192 // Draw the tree branches
2193 if(style.treeBranch)
2195 int y = -scroll.y + ((style.header) ? rowHeight : 0);
2196 surface.LineStipple(0x5555);
2197 surface.SetForeground(branchesColor);
2198 for(row = rows.first; row; row = row.GetNextRow() )
2200 int x = -scroll.x + EXTRA_SPACE / 2-1;
2201 int rowStart = -scroll.x;
2206 for(parent = row.parent; parent; parent = parent.parent)
2207 if(!parent.header) indent += 20;
2208 if(style.rootCollapse) indent += 20;
2210 plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2215 if(row.subRows.first)
2218 int y1 = y + PLUSY + 4;
2222 for(child = row.collapsed ? null : row.subRows.first; child && child != row; )
2225 if(child.subRows.first && !child.collapsed && child != row.subRows.last)
2226 child = child.subRows.first;
2231 for(; child && child != row; child = child.parent)
2241 y2 = y + numRows * rowHeight + PLUSY + 4;
2242 surface.VLine(y1, y2, rowStart + plusIndent + 7 + 20);
2244 surface.HLine(rowStart + plusIndent + 7, rowStart + indent, y + PLUSY + 4);
2247 if(y >= clientSize.h)
2250 // Root Vertical Lines
2251 if(style.rootCollapse && rows.first)
2256 y = -scroll.y + ((style.header) ? rowHeight : 0);
2258 for(child = rows.first; child && child != rows.last; )
2261 if(child.subRows.first && !child.collapsed && child != rows.last)
2262 child = child.subRows.first;
2267 for(; child; child = child.parent)
2277 y2 = y + numRows * rowHeight + PLUSY + 4;
2278 surface.VLine(y1, y2, -scroll.x + 11);
2280 surface.LineStipple(0);
2283 for(row = firstRowShown; row; row = row.GetNextRow() )
2285 int x = -scroll.x + EXTRA_SPACE / 2-1;
2288 Color foreground = this.foreground /*black*/, background = this.background /*white*/;
2289 DataDisplayFlags dataDisplayFlags = 0;
2290 int rowStart = -scroll.x;
2293 Bitmap icon = row.icon ? row.icon.bitmap : null;
2294 int collapseRowStart;
2295 bool lastWasHeader = row.header;
2297 for(parent = row.parent; parent; parent = parent.parent)
2299 if(!parent.header || lastWasHeader)
2301 if(style.treeBranch)
2307 if(style.rootCollapse) indent += 20;
2310 dataDisplayFlags.fullRow = style.fullRowSelect;
2311 dataDisplayFlags.active = isActive;
2312 dataDisplayFlags.header = row.header;
2317 collapseRowStart = rowStart;
2319 if(!(style.treeBranch))
2326 if(style.multiSelect)
2328 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2329 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2333 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2334 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2336 if(row == currentRow)
2338 dataDisplayFlags.current = true;
2339 dataDisplayFlags.selectedFlag = true;
2341 else if(!currentRow && row == firstRowShown)
2343 dataDisplayFlags.current = true;
2347 surface.TextOpacity(true);
2349 background = this.background;
2350 foreground = this.foreground;
2352 // Draw the current row background
2355 Color colors[] = { formColor, azure, mistyRose, linen, floralWhite, lavender, lavenderBlush, lemonChiffon };
2358 while(p = p.parent) level++;
2359 background = colors[(level % (sizeof(colors)/sizeof(colors[0]))];
2360 surface.SetBackground(background);
2361 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
2362 foreground = branchesColor;
2364 else if(dataDisplayFlags.selected)
2366 if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
2368 if(!isActive && style.alwaysEdit)
2369 background = formColor;
2371 background = selectionColor ? selectionColor : SELECTION_COLOR;
2372 if(style.fullRowSelect)
2374 int offset = (style.alwaysEdit) ? 2 : 1;
2375 surface.SetBackground(background);
2376 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - offset);
2378 if(isActive || !(style.alwaysEdit))
2379 foreground = selectionText ? selectionText : SELECTION_TEXT;
2381 foreground = branchesColor;
2387 surface.Blit(icon, x + (20 - icon.width) /2,y + 2,0,0, icon.width, icon.height);
2393 int width = clientSize.w;
2395 dataDisplayFlags.firstField = true;
2396 clip.left = x - EXTRA_SPACE / 2+1;
2398 clip.right = x + width - EXTRA_SPACE/2 - 0;
2399 clip.bottom = y + rowHeight - 1;
2400 surface.Clip(&clip);
2402 surface.TextFont(font);
2404 surface.SetForeground(foreground);
2405 surface.SetBackground(background);
2407 ((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);
2411 if(!opacity) surface.TextOpacity(false);
2413 for(field = fields.first; field; field = field.next)
2416 int width = ((!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) || row.header) ?
2417 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2419 // Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
2422 //width -= EXTRA_SPACE;
2424 if(!field.prev) width -= indent;
2427 dataDisplayFlags.firstField = field.prev ? false : true;
2429 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2431 background = this.background;
2432 foreground = this.foreground;
2435 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
2438 surface.SetBackground(background);
2439 surface.Area(x-3, y, x+width-1, y + rowHeight-2);
2442 clip.left = x - EXTRA_SPACE / 2+1;
2444 clip.right = x + width - EXTRA_SPACE/2 - 0;
2445 clip.bottom = y + rowHeight - 1;
2446 surface.Clip(&clip);
2448 for(index = 0, cell = row.cells.first; cell && index != field.index; index++, cell = cell.next);
2449 // Should always be as many cells in the row as fields in the listbox
2450 if(cell && cell.isSet && field.dataType)
2453 surface.TextFont(boldFont);
2455 surface.TextFont(font);
2457 surface.SetForeground(foreground);
2458 surface.SetBackground(background);
2460 if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
2461 ((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);
2463 ((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);
2466 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
2467 background = formColor;
2469 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2471 background = formColor;
2472 foreground = this.background;
2475 x += width;// + EXTRA_SPACE;
2477 if(row.header) break;
2483 int plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2485 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)))
2487 surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
2488 surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
2490 surface.SetBackground(row.header ? (formColor) : (this.background)); //white
2491 surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
2493 surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
2495 surface.VLine(y + PLUSY + 2, y + PLUSY + 6, collapseRowStart + 7 + plusIndent);
2500 // Draw the current row stipple
2501 if(style.fullRowSelect && !(style.alwaysEdit) && (dataDisplayFlags.current) && isActive)
2506 surface.LineStipple(0x5555);
2507 if(dataDisplayFlags.selected)
2508 surface.SetForeground(stippleColor);
2510 surface.SetForeground(this.foreground);
2513 surface.SetForeground(selectionColor ? selectionColor : SELECTION_COLOR);
2514 surface.Rectangle(0, y, clientSize.w-1, (y + rowHeight) - 1);
2515 surface.LineStipple(0);
2519 if(y >= clientSize.h)
2522 if(firstRowShown) surface.Clip(null);
2523 if(this.dragRow && this.dropIndex != -1)
2525 int dropIndex = this.dropIndex;
2528 if(!style.multiSelect && currentRow.index < this.dropIndex)
2530 surface.DrawingChar(223);
2532 y = style.header ? rowHeight : 0;
2533 y += dropIndex * rowHeight - scroll.y;
2535 surface.SetForeground(Color { 85, 85, 255 });
2536 surface.HLine(0, clientSize.w-1, y);
2537 surface.HLine(0, clientSize.w-1, y + 1);
2541 void OnDrawOverChildren(Surface surface)
2543 if(draggingField && this.dropField)
2545 int position = this.dropField.x;
2546 if(draggingField.x < position)
2547 position += this.dropField.width + EXTRA_SPACE;
2549 surface.SetForeground(Color { 85, 85, 255 });
2550 surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
2551 surface.VLine(0, rowHeight - 1, position - scroll.x);
2553 if(sortField && !style.clearHeader && style.header)
2555 DataField field = sortField;
2556 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2557 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2560 surface.TextExtent(field.header, strlen(field.header), &tw, &th);
2561 if(tw < width - EXTRA_SPACE)
2563 bool up = field.sortOrder == 1;
2567 field.x + 2 - scroll.x, 0,
2568 field.x + width + EXTRA_SPACE - 1 - scroll.x, rowHeight
2570 surface.Clip(&clip);
2571 if(field.alignment == left || field.alignment == center)
2573 if(field.alignment == center)
2574 x = field.x + (width + EXTRA_SPACE - tw) / 2 + tw + EXTRA_SPACE + 4;
2576 x = field.x + tw + EXTRA_SPACE + 4;
2578 x = Min(x, field.x + width - 4);
2580 else if(field.alignment == right)
2582 x = field.x + width - tw - 2*EXTRA_SPACE - 4;
2583 x = Max(x, field.x + 2);
2589 // surface.SetForeground((wmenu.selectedFlag == item) ? white : black);
2590 // surface.WriteText(clientSize.w-8, y+(wmenu.rh - 8)/2, "\020", 1);
2596 surface.SetForeground(Color { 128,128,128 } );
2597 surface.DrawLine(x + 3, y, x, y + 5);
2598 surface.PutPixel(x + 1, y + 5);
2599 surface.PutPixel(x + 1, y + 3);
2600 surface.PutPixel(x + 2, y + 1);
2602 surface.SetForeground(white);
2603 surface.DrawLine(x + 4, y, x + 7, y + 5);
2604 surface.PutPixel(x + 6, y + 5);
2605 surface.PutPixel(x + 6, y + 3);
2606 surface.PutPixel(x + 5, y + 1);
2608 surface.DrawLine(x, y + 6, x + 7, y + 6);
2612 surface.SetForeground(Color { 128,128,128 });
2613 surface.DrawLine(x + 3, y+6, x, y+1);
2614 surface.PutPixel(x + 1, y+1);
2615 surface.PutPixel(x + 1, y+3);
2616 surface.PutPixel(x + 2, y+5);
2618 surface.SetForeground(white);
2619 surface.DrawLine(x + 4, y+6, x + 7, y+1);
2620 surface.PutPixel(x + 6, y+1);
2621 surface.PutPixel(x + 6, y+3);
2622 surface.PutPixel(x + 5, y+5);
2624 surface.DrawLine(x, y, x + 7, y);
2633 void OnResize(int w, int h)
2636 bool showEndBevel = false;
2638 if(style.collapse && !style.treeBranch)
2640 for(field = fields.first; field; field = field.next)
2642 int width = field.width + EXTRA_SPACE;
2650 (rowCount * rowHeight) +
2651 ((style.header) ? rowHeight : 0) -
2652 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
2654 for(field = fields.first; field; field = field.next)
2656 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2657 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2658 if(style.header && field.headButton)
2660 showEndBevel = true;
2663 field.headButton.position = { field.x, 0 };
2664 field.headButton.size = { width, rowHeight };
2665 field.headButton.visible = true;
2668 field.headButton.visible = false;
2672 if(!style.fillLastField && showEndBevel && endBevel)
2674 endBevel.position = { x, 0 };
2675 endBevel.size = { clientSize.w + 2 - x, rowHeight };
2676 endBevel.visible = true;
2679 endBevel.visible = false;
2681 if(style.alwaysEdit && editData && editData.visible)
2683 HideEditBox(true, false, true);
2687 void AdaptToFieldWidth(DataField field, bool doScroll)
2689 OnResize(clientSize.w, clientSize.h);
2691 // Scroll appropriately
2694 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2695 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2697 SetScrollPosition(field.x + field.width + EXTRA_SPACE - clientSize.w, scroll.y);
2699 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2701 SetScrollPosition(field.x, scroll.y);
2706 bool HeaderPushed(Button control, int x, int y, Modifiers mods)
2708 DataField field = (DataField)control.id;
2709 // false: dont destroy edit box
2710 HideEditBox(true, false, true);
2711 if(style.resizable && ((!field && x < RESIZE_BORDER && fields.last) ||
2712 (field && x < RESIZE_BORDER && field.prev) ||
2713 (field && x >= control.clientSize.w - RESIZE_BORDER)))
2716 field = fields.last;
2717 else if(x < RESIZE_BORDER && field.prev)
2720 if(field.fixed) return false;
2721 resizingField = field;
2722 this.resizeX = x + control.position.x;
2723 this.startWidth = field.width;
2724 this.oldX = x - scroll.x;
2729 if(field.fixed) return false;
2730 draggingField = field;
2731 if(style.moveFields)
2732 field.headButton.stayDown = true;
2733 else if(!style.sortable)
2741 bool HeaderMouseMove(Button control, int x, int y, Modifiers mods)
2746 DataField field = resizingField;
2748 x += control.position.x;
2750 // Tweak to prevent shrinking field if we're actually moving right
2751 if(x - scroll.x > this.oldX &&
2752 this.startWidth + x - this.resizeX < field.width)
2754 this.oldX = x - scroll.x;
2757 this.oldX = x - scroll.x;
2759 field.width = this.startWidth + x - this.resizeX;
2760 field.width = Max(field.width, - EXTRA_SPACE);
2762 AdaptToFieldWidth(field, true);
2764 else if(draggingField)
2766 x += control.position.x;
2767 if(style.moveFields)
2769 DataField field = fields.last;
2771 for(field = fields.first; field; field = field.next)
2773 fieldX += ((field.width || style.resizable) ?
2774 field.width : clientSize.w) + EXTRA_SPACE;
2778 if(draggingField == field)
2780 // Reset scroll position
2781 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2782 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2785 field.x + field.width + EXTRA_SPACE - clientSize.w,
2788 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2790 SetScrollPosition(field.x, scroll.y);
2793 if(this.dropField != field)
2795 this.dropField = field;
2798 int position = field.x;
2800 if(draggingField.x < position)
2802 position += field.width + EXTRA_SPACE - clientSize.w;
2803 if(position > scroll.x)
2804 SetScrollPosition(position, scroll.y);
2809 if(position < scroll.x)
2810 SetScrollPosition(position, scroll.y);
2813 this.movingFields = true;
2819 else if(style.resizable)
2821 DataField field = (DataField)control.id;
2824 if(x < RESIZE_BORDER && field.prev)
2826 if(!field.prev.fixed)
2827 control.cursor = guiApp.GetCursor(sizeWE);
2829 else if(x >= control.clientSize.w - RESIZE_BORDER)
2830 control.cursor = guiApp.GetCursor(sizeWE);
2832 control.cursor = null;
2836 if(x < RESIZE_BORDER && fields.last)
2837 control.cursor = guiApp.GetCursor(sizeWE);
2839 control.cursor = null;
2845 bool HeaderReleased(Button control, int x, int y, Modifiers mods)
2849 NotifyResized(master, this, resizingField, mods);
2850 resizingField = null;
2857 if(style.moveFields)
2862 DataField switchField = fields.last;
2866 x += draggingField.x;
2867 for(field = fields.first; field; field = field.next)
2869 fieldX += ((field.width || style.resizable) ?
2870 field.width : clientSize.w) + EXTRA_SPACE;
2873 switchField = field;
2877 if(switchField && draggingField != switchField && this.dropField)
2879 for(field = fields.first; field; field = field.next)
2881 if(field == switchField || field == draggingField)
2885 // Switch field first: move before
2886 if(field == switchField)
2887 draggingField.Move(switchField.prev);
2888 // Dragged field first: move after
2890 draggingField.Move(switchField);
2892 NotifyMovedField(master, this, draggingField, mods);
2894 draggingField.headButton.stayDown = false;
2899 movingFields = false;
2901 draggingField = null;
2907 bool HeaderClicked(Button control, int x, int y, Modifiers mods)
2909 if(style.header && !this.dropField && style.sortable)
2911 DataField field = (DataField)control.id;
2912 if(sortField == field)
2913 field.sortOrder *= -1;
2918 Sort(sortField, field.sortOrder);
2919 NotifySort(master, this, field, mods);
2925 bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
2929 DataField field = (DataField)control.id;
2932 if(x < RESIZE_BORDER && field.prev)
2934 else if(x >= control.clientSize.w - RESIZE_BORDER);
2940 if(x < RESIZE_BORDER && fields.last)
2941 field = fields.last;
2953 if(style.freeSelect)
2958 this.rolledOver = this.dragging = false;
2965 bool OnLoadGraphics()
2967 display.FontExtent(fontObject, "W", 1, null, &fontH);
2968 if(!style.heightSet)
2970 rowHeight = Max(fontH + 2, 16) + (style.alwaysEdit ? 1 : 0);
2971 SetScrollLineStep(8, rowHeight);
2976 void OnApplyGraphics()
2978 SetScrollLineStep(8, rowHeight);
2982 for(field = fields.first; field; field = field.next)
2984 if(field.headButton)
2986 field.headButton.bevel = (!guiApp.textMode && !style.clearHeader);
2988 field.headButton.background = Color { 0, 170, 0 };
2992 OnResize(clientSize.w, clientSize.h);
2995 bool OnResizing(int *w, int *h)
2999 if(!initSize.w && (!anchor.left.type || !anchor.right.type) && !*w)
3004 Font font = fontObject;
3005 Font boldFont = this.boldFont.font;
3006 Display display = this.display;
3008 for(row = rows.first; row; row = row.GetNextRow())
3010 Bitmap icon = row.icon ? row.icon.bitmap : null;
3011 int x = -scroll.x + EXTRA_SPACE / 2-1;
3015 for(parent = row.parent; parent; parent = parent.parent)
3019 if(style.treeBranch)
3025 if(style.rootCollapse) indent += 20;
3027 if(style.collapse && !(style.treeBranch)) x += 15;
3031 // Compute the rows size
3032 for(field = fields.first; field; field = field.next)
3034 if(((style.resizable && (!(style.alwaysEdit) || field.next)) || field.width) && !row.header)
3035 x += field.width - (field.prev ? 0 : indent);
3040 for(index = 0, cell = row.cells.first; index != field.index; index++, cell = cell.next);
3042 // Should always be as many cells in the row as fields in the listbox
3043 if(cell && cell.isSet && field.dataType)
3045 static char tempString[4096];
3048 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
3049 string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, cell.data[0], tempString, field.userData, null);
3051 string = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, cell.data, tempString, field.userData, null);
3053 if(!string) string = "";
3054 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3057 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3059 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, &th);
3062 if(row.header) break;
3066 maxWidth = Max(maxWidth, x);
3072 *h = Min(this.maxShown, this.rowCount) * rowHeight;
3077 if(!*w) *w = rowHeight * 5;
3078 if(!*h) *h = rowHeight * 5;
3085 FontResource font = this.font;
3086 FontResource boldFont
3088 faceName = font.faceName, size = font.size, bold = true
3090 AddResource(boldFont);
3091 RemoveResource(this.boldFont);
3092 this.boldFont = boldFont;
3096 SetInitSize(initSize);
3099 bool OnMouseMove(int x, int y, Modifiers mods)
3101 bool isTimer = false;
3102 int realX = x, realY = y;
3104 if(insideNotifySelect) return true;
3106 if(style.alwaysEdit && style.resizable &&
3107 resizingField && !(mods.isSideEffect))
3110 DataField field = resizingField;
3111 field.width = this.startWidth + x - this.resizeX;
3112 field.width = Max(field.width, - EXTRA_SPACE);
3114 AdaptToFieldWidth(field, true);
3118 if(style.alwaysEdit && style.resizable)
3120 int vx = -scroll.x - 1;
3123 if(style.collapse && !(style.treeBranch))
3126 for(field = fields.first; field; field = field.next)
3128 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3129 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3135 cursor = guiApp.GetCursor(sizeWE);
3139 vx += width + EXTRA_SPACE;
3143 if((editData && editData.visible) || (style.alwaysEdit))
3146 if(x == MAXINT && y == MAXINT)
3153 // ADDED THIS CHECK FOR FieldDropBox LEAKS
3154 if(/*!mods.isSideEffect && */(this.rolledOver || !this.dragging))
3156 int rowY = (style.header) ? rowHeight : 0;
3164 ((vertScroll && vertScroll.visible &&
3165 (y < 0 || y >= clientSize.h)) ||
3166 (horzScroll && horzScroll.visible &&
3167 (x < 0 || x >= clientSize.w))))
3172 if(vertScroll && vertScroll.visible &&
3173 (y < 0 || y >= clientSize.h))
3174 vertScroll.Action((y<0)?up:down, 0, 0);
3175 if(horzScroll && horzScroll.visible &&
3176 (x < 0 || x >= clientSize.w))
3177 horzScroll.Action((x<0)?up:down, 0, 0);
3183 // This must be done after the scrolling took place
3184 rowIndex = firstRowShown ? firstRowShown.index : -1;
3186 y = Min(y, clientSize.h-1);
3187 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3196 if(row && currentRow != row)
3198 if(this.dragRow && style.moveRows)
3200 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3202 else if(style.multiSelect)
3205 for(thisRow = rows.first; thisRow; thisRow = thisRow.GetNextRow())
3206 if((thisRow.selectedFlag == selected || thisRow.selectedFlag == tempSelected) ||
3212 if(this.dropIndex != rowIndex)
3214 this.dropIndex = rowIndex;
3215 this.editRow = null;
3217 this.movedRow = true;
3220 else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || this.rolledOver))
3222 if(!(style.multiSelect))
3224 if(currentRow)currentRow.selectedFlag = unselected;
3225 if(row)row.selectedFlag = selected;
3229 if(style.multiSelect)
3233 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3235 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3236 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3239 if(rowIndex >= clickedRow.index)
3241 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3243 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3250 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3252 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3253 if(selRow == clickedRow)
3259 if(style.freeSelect)
3260 NotifyHighlight(master, this, currentRow, mods);
3263 insideNotifySelect = true;
3264 NotifySelect(master, this, currentRow, mods);
3265 insideNotifySelect = false;
3268 if(style.alwaysEdit && currentRow)
3269 currentRow.Edit(currentField);
3276 bool OnMouseOver(int x, int y, Modifiers mods)
3279 this.rolledOver = true;
3283 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
3285 // TOCHECK: WAS THIS MISSING ? CHECK FOR SLOWDOWN
3286 if(!active) Update(null);
3288 if(!active && (!swap || !swap.isModal))
3290 // true: destroy edit box
3291 HideEditBox(true, true, false);
3293 else if(!swap || !swap.isModal)
3295 // Bring back edit box
3296 if(currentRow && style.alwaysEdit)
3298 currentRow.Edit(currentField ? currentField : null);
3302 return true; //NotifyActivate(master, this, active, swap, 0);
3306 bool OnButtonDown(int x, int y, Modifiers mods, bool right)
3309 // Check to see if we're dragging the vertical divider
3310 if(style.alwaysEdit && style.resizable && !right)
3312 int vx = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
3315 if(style.collapse && !(style.treeBranch))
3318 for(field = fields.first; field; field = field.next)
3320 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3321 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3327 resizingField = field.prev;
3329 this.startWidth = resizingField.width;
3331 SetMouseRangeToClient();
3335 vx += width + EXTRA_SPACE;
3339 if(!(style.freeSelect))
3341 int rowY = (style.header) ? rowHeight : 0;
3343 int rowIndex = firstRowShown ? firstRowShown.index : -1;
3344 DataRow previousRow = currentRow;
3345 DataRow newCurrentRow = null;
3346 DataField newCurrentField = null;
3347 bool moveMultiple = false;
3348 int numSelected = 0;
3349 int rowStart = -scroll.x;
3351 if(style.multiSelect)
3358 for(row = rows.first; row; row = row.GetNextRow())
3360 if(row.selectedFlag == tempSelected)
3361 row.selectedFlag = selected;
3362 else if(row.selectedFlag == tempUnselected)
3363 row.selectedFlag = unselected;
3364 if(row.selectedFlag == selected)
3371 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3374 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3377 if(style.treeBranch)
3380 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3386 /* THIS WAS TOO STRICT:
3387 if(style.collapse && row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) &&
3388 (x >= rowStart + 3 + plusIndent && y >= rowY - rowHeight + PLUSY && x <= rowStart + 11 + plusIndent && y <= rowY - rowHeight + PLUSY + 8))
3390 if(style.collapse &&
3391 (x >= rowStart && y >= rowY - rowHeight && x <= rowStart + 18 + plusIndent && y <= rowY + rowHeight-1))
3393 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) && x >= plusIndent)
3394 row.collapsed = !row.collapsed;
3401 newCurrentRow = row;
3403 if(style.multiSelect)
3405 // Deselect everything if user didn't clicked on a row
3409 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3410 selRow.selectedFlag = unselected;
3412 //this.clickedRowIndex = rowIndex;
3414 else if(style.moveRows && !(mods.shift) &&
3415 (row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
3416 !right && !(mods.isActivate))
3417 moveMultiple = true;
3423 if(row.selectedFlag == tempUnselected || row.selectedFlag == unselected)
3425 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3426 selRow.selectedFlag = unselected;
3427 row.selectedFlag = selected;
3430 //this.clickedRowIndex = rowIndex;
3436 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3437 selRow.selectedFlag = unselected;
3441 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3443 if(selRow != clickedRow)
3445 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3446 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3453 if(rowIndex >= clickedRow.index)
3455 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3459 if(selRow != clickedRow)
3461 if(selRow.selectedFlag)
3462 selRow.selectedFlag = tempUnselected;
3464 selRow.selectedFlag = tempSelected;
3468 selRow.selectedFlag = selected;
3475 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3479 if(selRow != clickedRow)
3481 if(selRow.selectedFlag)
3482 selRow.selectedFlag = tempUnselected;
3484 selRow.selectedFlag = tempSelected;
3488 selRow.selectedFlag = selected;
3489 if(selRow == clickedRow)
3498 if(row.selectedFlag)
3499 row.selectedFlag = tempUnselected;
3500 else row.selectedFlag = tempSelected;
3503 row.selectedFlag = tempSelected;
3505 //this.clickedRowIndex = rowIndex;
3515 // true: destroy edit box
3518 incref newCurrentRow;
3521 if(currentRow != newCurrentRow)
3522 HideEditBox(true, true, false);
3526 if(newCurrentRow._refCount <= 1)
3527 delete newCurrentRow;
3529 newCurrentRow._refCount--;
3534 if(!(style.multiSelect))
3536 if(currentRow) currentRow.selectedFlag = unselected;
3537 if(newCurrentRow) newCurrentRow.selectedFlag = selected;
3541 if(currentRow != newCurrentRow)
3544 // true: destroy edit box
3547 //incref newCurrentRow;
3548 incref newCurrentRow;
3551 HideEditBox(true, true, false);
3556 int headerSize = ((style.header) ? rowHeight : 0);
3557 int height = clientSize.h + 1 - headerSize;
3559 /*if(newCurrentRow._refCount <= 1)
3560 delete newCurrentRow;
3563 newCurrentRow._refCount--;
3564 //newCurrentRow._refCount--;
3567 currentRow = newCurrentRow;
3569 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
3570 SetScrollPosition(scroll.x,
3571 currentRow.index * rowHeight - height + rowHeight);
3572 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
3574 int line = currentRow ? currentRow.index * rowHeight : 0;
3575 //SNAPUP(line, rowHeight);
3576 SetScrollPosition(scroll.x, line);
3579 // GO THROUGH SetCurrentRow eventually?
3580 // SetCurrentRow(newCurrentRow, true);
3584 if(style.freeSelect)
3585 NotifyHighlight(master, this, currentRow, mods);
3586 else if((moveMultiple || (!(style.multiSelect) && previousRow == currentRow)) &&
3587 newCurrentRow && !(mods.shift))
3591 if(!(mods.isActivate))
3595 this.dragRow = currentRow;
3596 this.dropIndex = -1;
3597 this.movedRow = false;
3599 if(editData && editData.visible && style.alwaysEdit)
3606 if(style.collapse && !style.treeBranch)
3609 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3611 indent += (style.treeBranch) ? 20 : 15;
3614 for(field = fields.first; field; field = field.next)
3616 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3617 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3619 if(!field.prev) width -= indent;
3620 if(x >= sx && x < sx + width)
3624 if(field == currentField)
3625 editData.Deactivate();
3628 currentRow.Edit(field);
3629 editData.Activate();
3632 else if(!(mods.ctrl) && numSelected <= 1)
3633 this.editRow = currentRow;
3635 if(style.noDragging && newCurrentRow)
3636 NotifyReclick(master, this, newCurrentRow, mods);
3640 // If the user clicked exactly on the edited field,
3642 if(editData && editData.visible && newCurrentRow)
3644 DataField field, whichField;
3648 if(style.collapse && !(style.treeBranch))
3651 whichField = currentField;
3655 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3657 indent += (style.treeBranch) ? 20 : 15;
3661 for(field = fields.first; field; field = field.next)
3663 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3664 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3665 if(!field.prev) width -= indent;
3666 if(x >= sx && x < sx + width && newCurrentRow)
3671 if(field) //x >= sx && x < sx + width && newCurrentRow)
3673 if(field == currentField)
3674 editData.Activate();
3676 newCurrentRow.Edit(currentField);*/
3678 else if(style.noDragging && newCurrentRow)
3679 NotifyReclick(master, this, newCurrentRow, mods);
3681 else if(style.noDragging && newCurrentRow)
3682 NotifyReclick(master, this, newCurrentRow, mods);
3688 result = NotifySelect(master, this,
3689 currentRow ? currentRow : null, mods);
3690 if(result && style.alwaysEdit && currentRow)
3694 DataField field = null;
3699 if(style.collapse && !style.treeBranch)
3702 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3704 indent += (style.treeBranch) ? 20 : 15;
3707 for(field = fields.first; field; field = field.next)
3709 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3710 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3712 if(!field.prev) width -= indent;
3713 if(x >= sx && x < sx + width)
3715 currentField = field;
3721 currentRow.Edit(currentField);
3723 // If the user clicked exactly on the edited field,
3725 if(editData && editData.visible && newCurrentRow)
3729 editData.Activate();
3731 else if(style.noDragging && newCurrentRow)
3732 NotifyReclick(master, this, newCurrentRow, mods);
3735 else if(style.noDragging && newCurrentRow)
3736 NotifyReclick(master, this, newCurrentRow, mods);
3740 For drop box to capture...
3743 if(x < 0 || y < 0 || x >= clientSize.w || y >= clientSize.h)
3746 master.parent.Activate();
3755 if(!style.noDragging)
3757 this.dragging = true;
3760 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h)
3761 this.rolledOver = true;
3766 this.dragging = false;
3767 OnLeftButtonUp(x, y, mods);
3772 bool OnLeftButtonDown(int x, int y, Modifiers mods)
3774 return OnButtonDown(x,y, mods, false);
3777 bool OnLeftButtonUp(int x, int y, Modifiers mods)
3779 if(resizingField && style.alwaysEdit)
3781 Window::FreeMouseRange();
3783 resizingField = null;
3786 if(dragRow || editRow)
3788 DataRow row, switchRow = rows.last;
3789 int rowY = (style.header) ? rowHeight : 0;
3790 for(row = firstRowShown; row; row = row.GetNextRow())
3799 if(this.editRow == switchRow && y >= 0)
3804 for(field = fields.first; field; field = field.next)
3806 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3807 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3810 if(fieldX > x + scroll.x)
3814 if(field && field.editable)
3816 // true: destroy edit box
3817 HideEditBox(true, true, false);
3818 PopupEditBox(field, false);
3820 else if(!style.noDragging)
3821 NotifyReclick(master, this, currentRow, mods);
3823 else if(style.moveRows && switchRow)
3825 if(this.dragRow == switchRow && this.movedRow == false)
3827 DataRow row = this.dragRow;
3831 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3832 selRow.selectedFlag = unselected;
3836 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3838 if(selRow != clickedRow)
3840 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3841 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3847 if(row.selectedFlag)
3848 row.selectedFlag = tempUnselected;
3849 else row.selectedFlag = tempSelected;
3852 row.selectedFlag = tempSelected;
3857 if(style.multiSelect)
3859 if(!switchRow.selectedFlag)
3861 bool foundSwitch = false;
3864 DataRow afterRow = switchRow.prev;
3865 for(row = rows.first; row; row = next)
3867 next = row.GetNextRow();
3868 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3870 if(!foundSwitch && !after)
3873 afterRow = switchRow;
3875 if(!after || !(row.selectedFlag == selected || row.selectedFlag == tempSelected) ||
3882 else if(row == switchRow)
3889 for(row = rows.first; row; row = row.GetNextRow())
3891 if(row == switchRow || row == this.dragRow)
3895 // Switch row first: move before
3896 if(row == switchRow)
3898 if(NotifyMove(master, this, switchRow.prev, mods))
3899 dragRow.Move(switchRow.prev);
3901 // Dragged row first: move after
3904 if(NotifyMove(master, this, switchRow, mods))
3905 dragRow.Move(switchRow);
3918 if(this.dragging || style.freeSelect)
3922 this.rolledOver = this.dragging = false;
3924 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h && currentRow && style.freeSelect)
3928 result = NotifySelect(master, this, currentRow, mods);
3929 if(style.alwaysEdit)
3930 currentRow.Edit(currentField);
3934 // if(!(style.freeSelect))
3940 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
3942 int rowStart = -scroll.x;
3944 int rowY = (style.header) ? rowHeight : 0;
3947 OnLeftButtonUp(x,y,mods);
3948 if(style.alwaysEdit)
3950 if(!(style.collapse) || x > 15)
3951 if(editData && editData.visible)
3953 editData.Activate();
3954 NotifyDoubleClick(master, this, x, y, mods);
3958 for(row = firstRowShown; row; row = row.GetNextRow())
3961 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3963 if(style.treeBranch)
3966 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3975 if((row && style.collapse && (x >= rowStart && x <= rowStart + 18 + plusIndent)) ||
3976 NotifyDoubleClick(master, this, x, y, mods))
3980 if(row && row.subRows.first)
3982 row.collapsed = !row.collapsed;
3986 // We need to return true here so that OnLeftButtonDown can popup the DataBox Editors
3992 bool OnRightButtonDown(int x, int y, Modifiers mods)
3994 return OnButtonDown(x,y, mods, true);
3997 bool OnRightButtonUp(int x, int y, Modifiers mods)
3999 OnLeftButtonUp(x,y,mods);
4000 return NotifyRightClick(master, this, x, y, mods);
4003 bool GoToLetter(unichar ch, bool keyHit)
4005 bool result = false;
4007 bool checkNextField = true;
4008 int len = keyHit ? 0 : strlen(typedString);
4010 typedString = renew typedString char[len + 2];
4011 typedString[len++] = (char)tolower(ch); // TODO: FIX UNICODE
4012 typedString[len] = '\0';
4014 for(field = fields.first; field; field = field.next)
4016 DataRow startRow = currentRow ? currentRow : rows.first;
4018 if(startRow && field.dataType && field.dataType._vTbl[__ecereVMethodID_class_OnGetString] && ch)
4021 bool looped = false;
4022 if(len == 1 && currentRow)
4023 startRow = (next = startRow.GetNextRow(), (next ? next : rows.first));
4025 for(row = startRow; row != startRow || !looped; next = row.GetNextRow(), row = next ? next : rows.first)
4027 void * data = row.GetData(field);
4028 char tempString[1024] = "";
4029 bool needClass = false;
4030 char * string = data ? ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString])(field.dataType, data, tempString, null, &needClass) : null;
4032 if(string && string[0])
4033 checkNextField = false;
4034 if(string && string[0] && !strnicmp(string, typedString, len))
4036 if(style.multiSelect)
4039 bool foundRow = false;
4041 //this.clickedRowIndex = 0;
4043 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4045 if(selRow == row) foundRow = true;
4046 selRow.selectedFlag = unselected;
4047 //if(!foundRow) this.clickedRowIndex++;
4049 row.selectedFlag = selected;
4051 SetCurrentRow(row, true);
4058 if(this.typingTimeOut && !keyHit)
4059 typingTimer.Start();
4060 if(!result || !this.typingTimeOut || keyHit)
4061 typedString[len-1] = '\0';
4063 if(!checkNextField || result) break;
4068 bool OnKeyDown(Key key, unichar ch)
4072 if(key == enter || key == keyPadEnter)
4074 if(editData && editData.visible && editData.active)
4076 HideEditBox(true, false, false);
4080 else if(key == escape)
4082 if(resizingField || this.movingFields || (editData && editData.visible) || this.dragRow)
4084 if(editData && editData.visible && style.alwaysEdit && !editData.active)
4086 // false: dont destroy edit box
4087 HideEditBox(false, false, false);
4090 resizingField.width = this.startWidth;
4091 AdaptToFieldWidth(resizingField, true);
4092 resizingField = null;
4095 this.dragRow = null;
4098 this.dragging = false;
4102 this.movingFields = false;
4103 draggingField = null;
4109 if(!currentField || !currentField.editable)
4110 for(field = fields.first; field; field = field.next)
4114 currentField = field;
4118 if(key == f2 && currentField && currentField.editable)
4120 PopupEditBox(currentField, false);
4121 if(editData && editData.visible)
4123 if(style.alwaysEdit)
4125 editData.Activate();
4126 // For Installer to pop up file dialog
4127 NotifyKeyDown(master, this, currentRow, key, ch);
4133 if(!NotifyKeyDown(master, this, currentRow, key, ch))
4136 // Editable fields...
4139 if(style.alwaysEdit && editData && editData.visible)
4140 return editData.OnKeyDown(key, ch);
4141 return true; // We want to pick up the OnKeyHit to replace contents, but skip GoToLetter
4144 if(ch >=32 && ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, false))
4146 /*if(inactive && window.state != Hidden)
4147 NotifyHighlight(master, this, currentRow, 0);
4150 NotifySelect(master, this, currentRow, 0);
4157 bool OnKeyHit(Key key, unichar ch)
4159 if(!ch && !key.alt && !key.ctrl)
4161 key.code = (SmartKey)key.code;
4163 if(ch >= 32 && !key.alt && !key.ctrl && ch != 128)
4166 if(!currentField || !currentField.editable)
4167 for(field = fields.first; field; field = field.next)
4171 currentField = field;
4175 if(currentField && currentField.editable)
4177 if((!editData || !editData.visible) || !editData.active)
4179 PopupEditBox(currentField, false);
4180 if(editData && editData.visible)
4182 editData.Activate();
4183 editData.OnKeyHit(key, ch);
4190 if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
4193 if(!key.alt && (style.multiSelect || !key.ctrl))
4198 if(style.alwaysEdit)
4203 for(field = currentField.prev; field; field = field.prev)
4207 currentField = field;
4208 HideEditBox(true, true, false);
4209 PopupEditBox(currentField, false);
4215 if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
4217 if(currentRow.subRows.first && !currentRow.collapsed)
4219 currentRow.collapsed = true;
4221 else if(currentRow.parent)
4222 SetCurrentRow(currentRow.parent, true);
4227 if(style.collapse && currentRow && currentRow.subRows.first)
4229 if(currentRow.collapsed)
4230 currentRow.collapsed = false;
4232 SetCurrentRow(currentRow.subRows.first, true);
4235 else if(style.alwaysEdit)
4240 for(field = currentField.next; field; field = field.next)
4244 currentField = field;
4245 HideEditBox(true, true, false);
4246 PopupEditBox(currentField, false);
4254 case pageDown: case pageUp:
4255 case end: case home:
4257 int headerSize = ((style.header) ? rowHeight : 0);
4258 int height = clientSize.h + 1 - headerSize;
4261 // true: destroy edit box
4262 // !!! TESTING true HERE !!!
4263 HideEditBox(true, true, false);
4264 // HideEditBox(false, true, false);
4266 oldRow = currentRow;
4268 SNAPDOWN(height, rowHeight);
4269 if((!currentRow || key.code == home) && key.code != end)
4271 currentRow = rows.first;
4279 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4282 next = currentRow.GetNextRow();
4289 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4292 next = currentRow.GetPrevRow();
4300 currentRow = lastRow.GetLastRow();
4306 currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
4307 c++, currentRow = next);
4314 currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
4315 c++, currentRow = next);
4320 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
4321 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
4322 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
4323 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
4325 if(style.multiSelect)
4329 if(!(key.shift) && (key.ctrl))
4332 for(row = rows.first; row; row = row.GetNextRow())
4334 if(row.selectedFlag == tempSelected)
4335 row.selectedFlag = selected;
4336 else if(row.selectedFlag == tempUnselected)
4337 row.selectedFlag = unselected;
4343 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4344 selRow.selectedFlag = unselected;
4348 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4350 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
4351 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
4357 if(currentRow.index >= clickedRow.index)
4359 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
4363 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4366 selRow.selectedFlag = selected;
4367 if(selRow == currentRow)
4373 for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
4377 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4380 selRow.selectedFlag = selected;
4381 if(selRow == clickedRow)
4388 if(!(key.ctrl) && currentRow)
4390 currentRow.selectedFlag = selected;
4393 clickedRow = currentRow;
4398 if(oldRow) oldRow.selectedFlag = unselected;
4399 if(currentRow) currentRow.selectedFlag = selected;
4404 if(style.freeSelect)
4405 NotifyHighlight(master, this, currentRow, 0);
4407 NotifySelect(master, this, currentRow, 0);
4409 if(style.alwaysEdit && currentRow)
4410 currentRow.Edit(currentField /*null*/);
4417 if(style.multiSelect && currentRow)
4419 if(currentRow.selectedFlag)
4422 currentRow.selectedFlag = unselected;
4425 currentRow.selectedFlag = selected;
4428 if(style.freeSelect)
4429 NotifyHighlight(master, this, currentRow, 0);
4431 NotifySelect(master, this, currentRow, 0);
4438 if(!NotifyKeyHit(master, this, currentRow, key, ch))
4441 if(ch >=32 && ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, true))
4443 /*if(inactive && window.state != Hidden)
4444 return NotifyHighlight(master, this, currentRow, 0);
4447 return NotifySelect(master, this, currentRow, 0);
4454 void OnHScroll(ScrollBarAction action, int position, Key key)
4459 void OnVScroll(ScrollBarAction action, int position, Key key)
4464 for(firstRowShown = rows.first; firstRowShown; firstRowShown = next)
4466 next = firstRowShown.GetNextRow();
4467 if(y >= position || !next) break;
4477 DataRow firstRowShown;
4481 DataField sortField;
4485 double typingTimeOut;
4498 if(guiApp.GetKeyState(shift)) mods.shift = true;
4499 if(guiApp.GetKeyState(alt)) mods.alt = true;
4500 if(guiApp.GetKeyState(control)) mods.ctrl = true;
4501 OnMouseMove(MAXINT, MAXINT, mods);
4509 delay = 0.5; // typingTimeOut
4514 typedString[0] = '\0';
4516 // The next line was commented... Why? When commented typing words stops working ( only first character jumps )
4522 bool dragging, rolledOver;
4531 // For editing fields
4533 DataField currentField;
4536 // For moving fields
4537 DataField draggingField, dropField;
4540 // For resizing fields
4541 DataField resizingField;
4542 int resizeX, oldX, startWidth;
4545 FontResource boldFont;
4548 // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
4549 bool insideNotifySelect;
4550 Color selectionColor, selectionText, stippleColor;
4551 stippleColor = 0xFFFFFF80;