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 *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, cell.data[0], tempString, userData, null);
189 string = (char *)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 int 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(this))
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)
526 listBox.firstRowShown = nextRow;
527 index = after ? (after.index + 1) : 0;
530 // All rows between ROW (exclusive) and AFTER (inclusive) are decremented by one
531 // ROW is equal to AFTER's index
533 for(search = nextRow; search; search = search.GetNextRow())
535 search.index -= ixCount;
536 if(search == after) break;
539 listBox.rows.Move(this, after);
542 listBox.CheckConsistency();
545 listBox.HideEditBox(true, false, true);
548 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
549 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
550 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
552 int line = listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0;
553 //SNAPUP(line, listBox.rowHeight);
554 listBox.SetScrollPosition(listBox.scroll.x, line);
557 listBox.OnVScroll(0, listBox.scroll.y, 0);
559 listBox.modifiedDocument = true;
561 listBox.Update(null);
568 any_object GetData(DataField field)
572 ListBoxCell cell = listBox.GetCell(&this, &field);
573 if(cell && cell.isSet && cell.data)
575 if((field.dataType.type == normalClass || field.dataType.type == noHeadClass))
578 return (void *)cell.data; // Cast for MemoryGuard
584 void * SetData(DataField field, any_object newData)
588 ListBoxCell cell = listBox.GetCell(&this, &field);
591 Class dataType = field.dataType;
595 if(dataType.type == normalClass || dataType.type == noHeadClass)
597 if(cell.data[0] && field.freeData)
598 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
600 if(eClass_IsDerived(dataType, class(char *)) && field.freeData)
601 dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
603 cell.data[0] = (void *)newData;
607 // Free old data first
608 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
609 dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
613 listBox.modifiedDocument = true;
614 listBox.Update(null);
615 if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
616 return (void *)cell.data; // Cast for MemoryGuard
624 void UnsetData(DataField field)
628 ListBoxCell cell = listBox.GetCell(&this, &field);
631 Class dataType = field.dataType;
635 if(dataType.type == normalClass || dataType.type == noHeadClass)
637 if(cell.data[0] && field.freeData)
638 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
643 // Free old data first
644 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
648 listBox.Update(null);
653 DataRow FindRow(int tag)
656 for(row = subRows.first; row; row = row.next)
658 if(!row.noneRow && row.tag == tag)
664 DataRow FindSubRow(int tag)
667 for(row = subRows.first; row; row = row.next)
669 if(!row.noneRow && row.tag == tag)
671 if(row.subRows.first)
673 DataRow subRow = row.FindSubRow(tag);
681 DataRow AddRowAfter(DataRow after)
691 subRows.Insert(after, row);
692 row.listBox = listBox;
696 for(c = 0; c<listBox.fields.count; c++)
698 for(field = listBox.fields.first; field; field = field.next)
699 if((int)field.index == c)
703 int size = (field.dataType && field.dataType.typeSize) ?
704 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
705 ListBoxCell cell = (ListBoxCell)new0 byte[size];
707 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
716 if(after && after.subRows.first && !after.collapsed)
718 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
719 search = search.subRows.last;
720 row.index = search.index + 1;
723 row.index = after ? (after.index + 1) : (index + 1);
727 for(search = row.GetNextRow(); search; search = search.GetNextRow())
730 listBox.SetScrollArea(
732 (listBox.rowCount * listBox.rowHeight) +
733 ((listBox.style.header) ? listBox.rowHeight : 0) -
734 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
735 if(listBox.style.autoScroll)
736 listBox.SetScrollPosition(0, MAXINT - listBox.rowHeight);
739 listBox.modifiedDocument = true;
742 listBox.CheckConsistency();
752 return AddRowAfter(subRows.last);
756 DataRow AddStringf(char * format, ...)
761 char string[MAX_F_STRING];
764 va_start(args, format);
765 vsprintf(string, format, args);
769 row.SetData(null, string);
775 DataRow AddString(char * string)
781 row.SetData(listBox.fields.first, string);
791 subRows.offset = (uint)&((DataRow)0).prev;
796 ListBoxCell cell, next;
801 while((subRow = subRows.first))
803 subRows.Remove(subRow);
807 for(cell = cells.first; cell; cell = next, cellIndex++)
812 for(field = listBox.fields.first; field && field.index != cellIndex; field = field.next);
815 // TOCHECK: Is this check good? Will need incref/decref sometime?
816 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
818 if(cell.data[0] && field.freeData)
819 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
822 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
832 return !this || (!collapsed && (!parent || parent.IsExpanded()));
835 int Compare(DataRow b, DataField sortField)
838 ListBoxCell cell1, cell2;
840 for(index = 0, cell1 = cells.first, cell2 = b.cells.first;
841 index != sortField.index;
842 index++, cell1 = cell1.next, cell2 = cell2.next);
844 if(!cell1.isSet && !cell2.isSet)
846 else if(!cell1.isSet)
848 else if(!cell2.isSet)
851 if(noneRow && !b.noneRow) return -1;
852 else if(!noneRow && b.noneRow) return 1;
853 else if(noneRow && b.noneRow) return 0;
855 if(sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])
857 if(sortField.dataType.type == normalClass || sortField.dataType.type == noHeadClass)
859 result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
860 (cell1.isSet && cell1.data) ? cell1.data[0] : null,
861 (cell2.isSet && cell2.data) ? cell2.data[0] : null);
865 result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
866 cell1.isSet ? cell1.data : null,
867 cell2.isSet ? cell2.data : null);
870 return sortField.sortOrder * result;
873 void _SortSubRows(DataField field, int order)
876 for(search = subRows.first; search; search = search.next)
877 search._SortSubRows(field, order);
878 subRows.Sort(Compare, field);
881 public void SortSubRows(bool scrollToCurrent)
883 if(this && listBox && listBox.sortField)
885 _SortSubRows(listBox.sortField, listBox.sortField.sortOrder);
889 int index = this.index;
890 for(search = this; search; search = search.GetNextRow())
891 search.index = index++;
895 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
896 int height = listBox.clientSize.h + 1 - headerSize;
897 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
898 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
899 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
900 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0);
901 listBox.OnVScroll(0, listBox.scroll.y, 0);
906 public DataRow GetPrevRow()
912 for(row = prev; row && !row.collapsed && row.subRows.last; row = row.subRows.last);
919 public DataRow GetNextRow()
923 if(subRows.first && !collapsed)
927 for(row = this; row; row = row.parent)
929 if(row.next) { row = row.next; break; }
935 private DataRow GetLastRow()
938 while(row && !row.collapsed && row.subRows.last)
939 row = row.subRows.last;
946 SelectedFlag selectedFlag;
957 public class ListBox : CommonControl
959 hasVertScroll = true;
960 // background = white;
962 snapVertScroll = true;
964 class_property(icon) = "<:ecere>controls/listBox.png";
968 property bool freeSelect { property_category $"Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } };
969 property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } };
970 property DataField currentField
972 get { return currentField; }
973 // TODO: Document what this does
976 currentField = value;
977 HideEditBox(true, true, false);
978 if(value && value.editable)
979 PopupEditBox(currentField, false);
983 property int rowHeight
985 property_category $"Appearance"
986 isset { return style.heightSet; }
991 style.heightSet = true;
993 SetScrollLineStep(8, value);
997 style.heightSet = false;
1002 get { return rowHeight; }
1004 property Seconds typingTimeout
1006 property_category $"Behavior"
1009 typedString[0] = '\0';
1010 typingTimer.delay = value;
1011 typingTimeOut = value;
1013 get { return typingTimeOut; }
1015 property bool moveRows { property_category $"Behavior" set { style.moveRows = value; } get { return style.moveRows; } };
1016 property bool moveFields { property_category $"Behavior" set { style.moveFields = value; } get { return style.moveFields; } };
1017 property bool resizable { property_category $"Behavior" set { style.resizable = value; } get { return style.resizable; } };
1018 property bool autoScroll { property_category $"Behavior" set { style.autoScroll = value; } get { return style.autoScroll; } };
1019 property bool alwaysHighLight { property_category $"Appearance" set { style.alwaysHL = value; } get { return style.alwaysHL; } };
1020 property bool hasClearHeader { property_category $"Appearance" set { style.clearHeader = value; if(value) property::hasHeader = true; } get { return style.clearHeader; } };
1021 property bool hasHeader
1023 property_category $"Appearance"
1026 if(value && !style.header)
1032 bevel = !guiApp.textMode && !style.clearHeader;
1033 dontScrollVert = true;
1036 NotifyPushed = HeaderPushed;
1037 NotifyClicked = HeaderClicked;
1038 NotifyDoubleClick = HeaderDoubleClicked;
1039 NotifyReleased = HeaderReleased;
1040 NotifyMouseMove = HeaderMouseMove;
1044 endBevel.visible = false;
1046 style.header = value;
1048 get { return style.header; }
1050 property bool multiSelect { property_category $"Behavior" set { style.multiSelect = value; } get { return style.multiSelect; } };
1051 property bool alwaysEdit { property_category $"Behavior" set { style.alwaysEdit = value; } get { return style.alwaysEdit; } };
1052 property bool fullRowSelect { property_category $"Appearance" set { style.fullRowSelect = value; } get { return style.fullRowSelect; } };
1053 property bool collapseControl { property_category $"Appearance" set { style.collapse = value; } get { return style.collapse; } };
1054 property bool treeBranches { property_category $"Appearance" set { style.treeBranch = value; } get { return style.treeBranch; } };
1055 property bool rootCollapseButton { property_category $"Appearance" set { style.rootCollapse = value; } get { return style.rootCollapse; } };
1056 property bool sortable { property_category $"Behavior" set { style.sortable = value; } get { return style.sortable; } };
1057 property bool noDragging { property_category $"Behavior" set { style.noDragging = value; } get { return style.noDragging; } };
1058 property bool fillLastField
1060 property_category $"Behavior"
1063 style.fillLastField = value;
1065 get { return style.fillLastField; }
1067 property int numSelections
1071 int numSelections = 0;
1072 if(this && style.multiSelect)
1075 for(row = rows.first; row; row = row.GetNextRow())
1076 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1079 return numSelections;
1082 property int currentIndex
1084 get { return currentRow ? currentRow.index : -1; }
1086 property DataRow lastRow { get { return this ? rows.last : null; } };
1087 property DataRow firstRow { get { return this ? rows.first : null; } };
1088 property int rowCount { get { return rowCount; } };
1089 property DataField firstField { get { return this ? fields.first : null; } };
1090 property Color selectionColor { set { selectionColor = value; } get { return selectionColor; } isset { return selectionColor ? true : false; } };
1091 property Color selectionText { set { selectionText = value; } get { return selectionText; } isset { return selectionText ? true : false; } };
1092 property Color stippleColor { set { stippleColor = value; } get { return stippleColor; } };
1093 property bool expandOnAdd { set { style.expandOnAdd = value; } get { return style.expandOnAdd; } };
1096 virtual bool Window::NotifySelect(ListBox listBox, DataRow row, Modifiers mods);
1097 virtual bool Window::NotifyHighlight(ListBox listBox, DataRow row, Modifiers mods);
1098 virtual bool Window::NotifyReclick(ListBox listBox, DataRow row, Modifiers mods);
1099 virtual bool Window::NotifySort(ListBox listBox, DataField field, Modifiers mods);
1100 virtual bool Window::NotifyChanged(ListBox listBox, DataRow row);
1101 virtual bool Window::NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch);
1102 virtual bool Window::NotifyEdited(ListBox listBox, DataRow row);
1103 virtual bool Window::NotifyEditDone(ListBox listBox, DataRow row);
1104 virtual bool Window::NotifyMovedField(ListBox listBox, DataField field, Modifiers mods);
1105 virtual bool Window::NotifyMove(ListBox listBox, DataRow row, Modifiers mods);
1106 virtual bool Window::NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods);
1107 virtual bool Window::NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods);
1108 virtual bool Window::NotifyResized(ListBox listBox, DataField field, Modifiers mods);
1109 virtual bool Window::NotifyCollapse(ListBox listBox, DataRow row, bool collapsed);
1110 virtual bool Window::NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch);
1111 virtual bool Window::NotifyModified(ListBox listBox, DataRow row);
1112 virtual bool Window::NotifyEditing(ListBox listBox, DataRow row);
1115 private void CheckConsistency()
1120 for(r = rows.first; r; r = r.GetNextRow())
1122 if(r.index != index++)
1130 void AddField(DataField addedField)
1135 if(fields.first && ((DataField)fields.first).defaultField)
1137 DataField defaultField = fields.first;
1138 defaultField.Free();
1139 delete defaultField;
1143 addedField = DataField { };
1147 addedField.listBox = this;
1148 fields.Add(addedField);
1150 addedField.sortOrder = 1;
1151 addedField.index = numFields;
1155 addedField.headButton.Destroy(0);
1156 delete addedField.headButton;
1157 addedField.headButton = Button
1162 dontScrollVert = true;
1163 id = (uint)addedField;
1164 text = addedField.header;
1165 bevel = (!guiApp.textMode && !style.clearHeader);
1167 alignment = addedField.alignment;
1168 NotifyPushed = HeaderPushed;
1169 NotifyClicked = HeaderClicked;
1170 NotifyDoubleClick = HeaderDoubleClicked;
1171 NotifyReleased = HeaderReleased;
1172 NotifyMouseMove = HeaderMouseMove;
1174 incref addedField.headButton;
1175 addedField.headButton.Create();
1178 addedField.headButton.background = Color { 0, 170, 0 };
1184 for(row = rows.first; row; )
1186 int size = (field.dataType && field.dataType.typeSize) ?
1187 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1188 ListBoxCell cell = (ListBoxCell)new0 byte[size];
1189 row.cells.Add(cell);
1190 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1193 if(row.subRows.first)
1194 row = row.subRows.first;
1197 for(; row; row = row.parent)
1199 if(row.next) { row = row.next; break; }
1204 OnResize(clientSize.w, clientSize.h);
1213 while((field = fields.first))
1219 endBevel.visible = false;
1224 void RemoveField(DataField field)
1230 int index = field.index;
1233 if(sortField == field)
1236 for(row = rows.first; row; )
1241 for(cell = row.cells.first, c = 0; c < index && cell; c++, cell = cell.next);
1242 if(cell && index == c)
1246 // TOCHECK: Is this check good? Will need incref/decref sometime?
1247 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
1249 if(cell.data[0] && field.freeData)
1250 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
1253 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
1256 row.cells.Remove(cell);
1260 if(row.subRows.first)
1261 row = row.subRows.first;
1264 for(; row; row = row.parent)
1266 if(row.next) { row = row.next; break; }
1275 endBevel.visible = false;
1279 DataRow AddRowNone()
1281 DataRow row { noneRow = true };
1290 rows.Insert(null, row);
1293 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1299 firstRowShown = row;
1303 (rowCount * rowHeight) +
1304 ((style.header) ? rowHeight : 0) -
1305 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1306 if(style.autoScroll)
1307 SetScrollPosition(0, MAXINT - rowHeight);
1308 modifiedDocument = true;
1327 // Find very last row
1330 for(lastRow = rows.last; lastRow && !lastRow.collapsed && lastRow.subRows.last; lastRow)
1331 lastRow = lastRow.subRows.last;
1332 row.index = lastRow ? (lastRow.index + 1) : 0;
1340 for(c = 0; c<fields.count; c++)
1342 for(field = fields.first; field; field = field.next)
1343 if((int)field.index == c)
1347 int size = (field.dataType && field.dataType.typeSize) ?
1348 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1349 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1350 row.cells.Add(cell);
1351 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1358 firstRowShown = row;
1364 (rowCount * rowHeight) +
1365 ((style.header) ? rowHeight : 0) -
1366 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1367 if(style.autoScroll)
1368 SetScrollPosition(0, MAXINT - rowHeight);
1369 modifiedDocument = true;
1380 DataRow AddRowAfter(DataRow after)
1392 if(after && after.subRows.first && !after.collapsed)
1394 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
1395 search = search.subRows.last;
1396 row.index = search.index + 1;
1399 row.index = after ? (after.index + 1) : 0;
1400 rows.Insert(after, row);
1403 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1408 for(c = 0; c<fields.count; c++)
1410 for(field = fields.first; field; field = field.next)
1411 if((int)field.index == c)
1415 int size = (field.dataType && field.dataType.typeSize) ?
1416 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1417 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1418 row.cells.Add(cell);
1419 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1423 if(!firstRowShown || !after)
1425 firstRowShown = row;
1430 (rowCount * rowHeight) +
1431 ((style.header) ? rowHeight : 0) -
1432 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1433 if(style.autoScroll)
1434 SetScrollPosition(0, MAXINT - rowHeight);
1435 modifiedDocument = true;
1445 DataRow AddStringf(char * format, ...)
1451 char string[MAX_F_STRING];
1454 va_start(args, format);
1455 vsprintf(string, format ? format : "", args);
1459 row.SetData(fields.first, string);
1465 DataRow AddString(char * string)
1471 row.SetData(fields.first, string);
1477 void SelectRow(DataRow row)
1479 SetCurrentRow(row, true);
1482 void DeleteRow(DataRow row)
1484 if(!row) row = currentRow;
1487 DataRow sub, next, search;
1488 // Trying to move this here (Messed up deleting watches)
1489 //HideEditBox(false, false, true);
1492 for(sub = row.subRows.first; sub; sub = next)
1498 if(row.parent.IsExpanded())
1500 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1505 HideEditBox(false, false, true);
1507 if(row == clickedRow)
1509 clickedRow = row.GetNextRow();
1511 clickedRow = row.GetPrevRow();
1514 if(row == currentRow)
1516 DataRow newCurrentRow = row.GetNextRow();
1518 newCurrentRow = row.GetPrevRow();
1519 SetCurrentRow(newCurrentRow, true);
1522 if(row == firstRowShown)
1524 firstRowShown = row.GetPrevRow();
1526 firstRowShown = row.GetNextRow();
1529 (row.parent ? row.parent.subRows: rows).Remove(row);
1532 //HideEditBox(false, false, true);
1536 (this.rowCount * rowHeight) +
1537 ((style.header) ? rowHeight : 0) -
1538 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1540 modifiedDocument = true;
1549 DataRow FindRow(int tag)
1554 for(row = rows.first; row; row = row.next)
1556 if(!row.noneRow && row.tag == tag)
1564 DataRow FindString(char * searchedString)
1567 bool checkNextField = true;
1568 int len = searchedString ? strlen(searchedString) : 0;
1570 for(field = fields.first; field; field = field.next)
1572 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1575 for(row = rows.first; row; row = row.GetNextRow())
1579 void * data = row.GetData(field);
1580 char tempString[1024] = "";
1581 bool needClass = false;
1582 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1584 if(string && string[0])
1585 checkNextField = false;
1586 if(string && string[0] && !strcmp(string, searchedString))
1591 if(!checkNextField) break;
1596 DataRow FindSubString(char * subString)
1599 bool checkNextField = true;
1600 int len = subString ? strlen(subString) : 0;
1604 for(field = fields.first; field; field = field.next)
1606 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1609 for(row = rows.first; row; row = row.GetNextRow())
1613 void * data = row.GetData(field);
1614 char tempString[1024] = "";
1615 bool needClass = false;
1616 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1618 if(string && string[0])
1619 checkNextField = false;
1620 if(string && string[0] && !strncmp(string, subString, len))
1625 if(!checkNextField) break;
1631 DataRow FindSubStringi(char * subString)
1634 bool checkNextField = true;
1635 int len = subString ? strlen(subString) : 0;
1636 DataRow result = null;
1637 char * bestResult = null;
1642 for(field = fields.first; field; field = field.next)
1644 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1647 for(row = rows.first; row; row = row.GetNextRow())
1651 void * data = row.GetData(field);
1652 char tempString[1024] = "";
1653 bool needClass = false;
1654 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1656 if(string && string[0])
1657 checkNextField = false;
1658 if(string && string[0])
1660 int stringLen = strlen(string);
1662 if(!strnicmp(string, subString, Min(len, stringLen)))
1664 if(bestLen < Min(len, stringLen))
1666 if(!bestResult || strcmpi(string, bestResult) < 0)
1668 bestLen = Min(len, stringLen);
1669 bestResult = string;
1677 if(!checkNextField) break;
1683 DataRow FindSubStringAfter(DataRow after, char * subString)
1686 bool checkNextField = true;
1687 int len = subString ? strlen(subString) : 0;
1691 for(field = fields.first; field; field = field.next)
1693 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1696 for(row = after.GetNextRow(); row && row != after; row = row.GetNextRow(), (!row) ? (row = rows.first) : null)
1700 void * data = row.GetData(field);
1701 char tempString[1024] = "";
1702 bool needClass = false;
1703 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1705 if(string && string[0])
1706 checkNextField = false;
1707 if(string && string[0] && !strncmp(string, subString, len))
1712 if(!checkNextField) break;
1718 DataRow FindSubRow(int tag)
1724 for(row = rows.first; row; row = row.next)
1726 if(!row.noneRow && row.tag == tag)
1728 if(!row.noneRow && row.subRows.first)
1730 DataRow subRow = row.FindSubRow(tag);
1744 Window master = this.master;
1746 HideEditBox(false, true, false);
1747 editData.Destroy(0);
1749 firstRowShown = currentRow = null;
1754 if(style.freeSelect)
1755 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
1757 NotifySelect(master, this, currentRow ? currentRow : null, 0);
1760 if(style.alwaysEdit && currentRow)
1761 currentRow.Edit(currentField);
1768 (this.rowCount * rowHeight) +
1769 ((style.header) ? rowHeight : 0) -
1770 ((rowHeight && !((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1775 void Sort(DataField field, int order)
1780 int headerSize = ((style.header) ? rowHeight : 0);
1781 int height = clientSize.h + 1 - headerSize;
1783 if(!field) field = fields.first;
1785 field.sortOrder = order ? order : 1;
1786 rows.Sort(DataRow::Compare, field);
1788 for(search = rows.first; search; search = search.next)
1789 search._SortSubRows(field, order);
1793 for(search = rows.first; search; search = search.GetNextRow())
1794 search.index = index++;
1797 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1798 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
1799 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1800 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
1802 OnVScroll(0, scroll.y, 0);
1804 // SetScrollPosition(0, scroll.y);
1809 void StopEditing(bool save)
1811 HideEditBox(save, false, true);
1814 void GetMultiSelection(OldList list)
1817 if(this && style.multiSelect)
1821 for(row = rows.first; row; row = row.GetNextRow())
1823 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1825 list.Add(OldLink { data = row });
1831 // Convenience Current Row Methods
1832 void * SetData(DataField field, any_object data)
1834 return currentRow.SetData(field, data);
1837 any_object GetData(DataField field)
1839 return (void *)currentRow.GetData(field);
1844 return currentRow ? currentRow.tag : 0;
1850 DataField defaultField { };
1851 rows.offset = (uint)&((DataRow)0).prev;
1852 fields.offset = (uint)&((DataField)0).prev;
1853 style.fullRowSelect = true;
1854 style.fillLastField = true;
1855 style.expandOnAdd = true;
1856 typingTimeOut = 0.5;
1857 rowHeight = 16; // Stuff depending on creation and default property checking
1860 defaultField.defaultField = true;
1862 AddField(defaultField);
1864 typedString = new char[1];
1865 typedString[0] = '\0';
1880 while((field = fields.first))
1882 // fields.Remove(field);
1892 while((row = rows.first))
1899 ListBoxCell GetCell(DataRow * row, DataField * field)
1901 ListBoxCell cell = null;
1902 if(!*row) *row = currentRow;
1905 if(!*field) *field = this ? currentField : null;
1908 for(*field = fields.first; (*field).index != 0; *field = (*field).next);
1913 if(field->listBox == this)
1915 for(index = 0, cell = (*row).cells.first; cell && index != (*field).index; index++, cell = cell.next);
1922 void HideEditBox(bool save, bool alwaysStopEdit, bool repositionOnly)
1924 if(editData && editData.visible)
1926 Class dataType = currentField.dataType;
1928 editData.SaveData();
1930 editData.visible = false;
1931 NotifyEditDone(master, this, currentRow);
1933 // ENSURE DATA BOX IS NOT VISIBLE
1934 editData.visible = false;
1936 if(style.alwaysEdit && !alwaysStopEdit)
1939 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
1940 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
1941 int x = currentField.x;
1942 int width = (!currentField.next && style.fillLastField && (!hasHorzScroll || clientSize.w - currentField.x > currentField.width + EXTRA_SPACE)) ?
1943 clientSize.w - currentField.x : (currentField.width + EXTRA_SPACE);
1945 if(!style.alwaysEdit)
1947 editData.position = { x, y };
1948 editData.size = { width, height };
1952 editData.position = { x, y - editData.clientStart.y };
1953 editData.size = { width, height + editData.clientStart.y * 2 };
1955 editData.visible = true;
1956 if(style.alwaysEdit)
1957 editData.Deactivate();
1959 PopupEditBox(currentField, repositionOnly);
1965 currentField = null;*/
1969 void SetCurrentRow(DataRow row, bool notify)
1971 if(currentRow != row || (currentRow && currentRow.selectedFlag == unselected))
1973 int headerSize = ((style.header) ? rowHeight : 0);
1974 int height = clientSize.h + 1 - headerSize;
1976 // true: destroy edit box
1977 HideEditBox(true, true, false);
1979 if(!(style.multiSelect) && currentRow)
1980 currentRow.selectedFlag = unselected;
1984 if(style.multiSelect)
1988 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
1989 selRow.selectedFlag = unselected;
1991 currentRow.selectedFlag = selected;
1996 currentRow.selectedFlag = selected;
1998 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1999 SetScrollPosition(scroll.x,
2000 currentRow.index * rowHeight - height + rowHeight);
2001 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
2003 int line = currentRow ? currentRow.index * rowHeight : 0;
2004 //SNAPUP(line, rowHeight);
2005 SetScrollPosition(scroll.x, line);
2010 Window master = this.master;
2013 if(style.freeSelect && visible)
2014 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
2016 NotifySelect(master, this, currentRow ? currentRow : null, 0);
2017 if(style.alwaysEdit && currentRow)
2018 currentRow.Edit(currentField);
2026 void PopupEditBox(DataField whichField, bool repositionOnly)
2028 if((!editData || !editData.visible || currentField != whichField) && currentRow)
2030 // true: destroy edit box
2031 HideEditBox(true, true, false);
2034 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
2036 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
2038 //void * data = currentRow.GetData(whichField);
2043 if(style.collapse && !(style.treeBranch))
2046 for(field = fields.first; field; field = field.next)
2048 width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2049 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2050 if(field == whichField) break;
2054 currentField = whichField;
2055 cell = GetCell(&row, ¤tField);
2062 background = dataBoxBackground;
2063 foreground = dataBoxForeground;
2065 bool NotifyChanged(bool closingDropDown)
2068 DataField field = null;
2069 ListBoxCell cell = GetCell(&row, &field);
2073 modifiedDocument = true;
2075 NotifyChanged(master, this, currentRow);
2080 bool NotifyModified()
2082 //DataRow row = null;
2083 //DataField field = null;
2084 //ListBoxCell cell = GetCell(&row, &field);
2085 //cell.isSet = true;
2086 modifiedDocument = true;
2088 NotifyModified(master, this, currentRow);
2092 bool OnKeyDown(Key key, unichar ch)
2094 bool result = DataBox::OnKeyDown(key, ch);
2095 if(visible && active) // Added this check here, because we will not use enter/escape otherwise, and lose DataBox's result
2097 if((SmartKey)key == enter || (SmartKey)key == escape)
2106 editData.Destroy(0);
2107 editData.type = whichField.dataType;
2108 editData.fieldData = whichField.userData;
2109 editData.borderStyle = style.alwaysEdit ? 0 : deep;
2110 editData.data = cell ? cell.data : null;
2113 // Might not really need this anymore...
2114 NotifyEditing(master, this, currentRow);
2117 if(!style.alwaysEdit)
2119 editData.position = { x, y - editData.clientStart.y };
2120 editData.size = { width, height + editData.clientStart.y * 2 };
2124 editData.position = { x, y };
2125 editData.size = { width, height };
2129 editData.visible = true;
2131 if(style.alwaysEdit)
2132 editData.Deactivate();
2134 // MOVED THIS HIGHER FOR DATALIST EDITOR
2136 // Might not really need this anymore...
2137 NotifyEdited(master, this, currentRow);
2142 void OnRedraw(Surface surface)
2145 int y = (style.header) ? rowHeight : 0;
2146 bool isActive = active;
2147 Font font = fontObject;
2148 Font boldFont = this.boldFont.font;
2152 if(style.alwaysEdit && style.fullRowSelect)
2155 int y = (style.header) ? rowHeight : 0;
2156 int x = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
2157 int w = clientSize.w;
2158 int h = clientSize.h;
2162 // Fill out indent column
2163 if(style.collapse && !(style.treeBranch) && rows.first)
2166 surface.SetBackground(formColor);
2167 surface.Area(-scroll.x, 0, x, clientSize.h);
2170 surface.SetForeground(formColor);
2171 for(row = firstRowShown; row; row = row.GetNextRow())
2174 surface.HLine(x + 1, w-1, y-1);
2180 for(field = fields.first; field; field = field.next)
2182 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2183 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2184 if(field.prev && y > 0)
2185 surface.VLine(0, y-1, x);
2190 surface.foreground = this.foreground;
2191 surface.TextOpacity(false);
2193 // Draw the tree branches
2194 if(style.treeBranch)
2196 int y = -scroll.y + ((style.header) ? rowHeight : 0);
2197 surface.LineStipple(0x5555);
2198 surface.SetForeground(branchesColor);
2199 for(row = rows.first; row; row = row.GetNextRow() )
2201 int x = -scroll.x + EXTRA_SPACE / 2-1;
2202 int rowStart = -scroll.x;
2207 for(parent = row.parent; parent; parent = parent.parent)
2208 if(!parent.header) indent += 20;
2209 if(style.rootCollapse) indent += 20;
2211 plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2216 if(row.subRows.first)
2219 int y1 = y + PLUSY + 4;
2223 for(child = row.collapsed ? null : row.subRows.first; child && child != row; )
2226 if(child.subRows.first && !child.collapsed && child != row.subRows.last)
2227 child = child.subRows.first;
2232 for(; child && child != row; child = child.parent)
2242 y2 = y + numRows * rowHeight + PLUSY + 4;
2243 surface.VLine(y1, y2, rowStart + plusIndent + 7 + 20);
2245 surface.HLine(rowStart + plusIndent + 7, rowStart + indent, y + PLUSY + 4);
2248 if(y >= clientSize.h)
2251 // Root Vertical Lines
2252 if(style.rootCollapse && rows.first)
2257 y = -scroll.y + ((style.header) ? rowHeight : 0);
2259 for(child = rows.first; child && child != rows.last; )
2262 if(child.subRows.first && !child.collapsed && child != rows.last)
2263 child = child.subRows.first;
2268 for(; child; child = child.parent)
2278 y2 = y + numRows * rowHeight + PLUSY + 4;
2279 surface.VLine(y1, y2, -scroll.x + 11);
2281 surface.LineStipple(0);
2284 for(row = firstRowShown; row; row = row.GetNextRow() )
2286 int x = -scroll.x + EXTRA_SPACE / 2-1;
2289 Color foreground = this.foreground /*black*/, background = this.background /*white*/;
2290 DataDisplayFlags dataDisplayFlags = 0;
2291 int rowStart = -scroll.x;
2294 Bitmap icon = row.icon ? row.icon.bitmap : null;
2295 int collapseRowStart;
2296 bool lastWasHeader = row.header;
2298 for(parent = row.parent; parent; parent = parent.parent)
2300 if(!parent.header || lastWasHeader)
2302 if(style.treeBranch)
2308 if(style.rootCollapse) indent += 20;
2311 dataDisplayFlags.fullRow = style.fullRowSelect;
2312 dataDisplayFlags.active = isActive;
2313 dataDisplayFlags.header = row.header;
2318 collapseRowStart = rowStart;
2320 if(!(style.treeBranch))
2327 if(style.multiSelect)
2329 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2330 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2334 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2335 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2337 if(row == currentRow)
2339 dataDisplayFlags.current = true;
2340 dataDisplayFlags.selectedFlag = true;
2342 else if(!currentRow && row == firstRowShown)
2344 dataDisplayFlags.current = true;
2348 surface.TextOpacity(true);
2350 background = this.background;
2351 foreground = this.foreground;
2353 // Draw the current row background
2356 Color colors[] = { formColor, azure, mistyRose, linen, floralWhite, lavender, lavenderBlush, lemonChiffon };
2359 while(p = p.parent) level++;
2360 background = colors[(level % (sizeof(colors)/sizeof(colors[0]))];
2361 surface.SetBackground(background);
2362 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
2363 foreground = branchesColor;
2365 else if(dataDisplayFlags.selected)
2367 if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
2369 if(!isActive && style.alwaysEdit)
2370 background = formColor;
2372 background = selectionColor ? selectionColor : SELECTION_COLOR;
2373 if(style.fullRowSelect)
2375 int offset = (style.alwaysEdit) ? 2 : 1;
2376 surface.SetBackground(background);
2377 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - offset);
2379 if(isActive || !(style.alwaysEdit))
2380 foreground = selectionText ? selectionText : SELECTION_TEXT;
2382 foreground = branchesColor;
2388 surface.Blit(icon, x + (20 - icon.width) /2,y + 2,0,0, icon.width, icon.height);
2394 int width = clientSize.w;
2396 dataDisplayFlags.firstField = true;
2397 clip.left = x - EXTRA_SPACE / 2+1;
2399 clip.right = x + width - EXTRA_SPACE/2 - 0;
2400 clip.bottom = y + rowHeight - 1;
2401 surface.Clip(&clip);
2403 surface.TextFont(font);
2405 surface.SetForeground(foreground);
2406 surface.SetBackground(background);
2408 class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
2412 if(!opacity) surface.TextOpacity(false);
2414 for(field = fields.first; field; field = field.next)
2417 int width = ((!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) || row.header) ?
2418 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2420 // Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
2423 //width -= EXTRA_SPACE;
2425 if(!field.prev) width -= indent;
2428 dataDisplayFlags.firstField = field.prev ? false : true;
2430 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2432 background = this.background;
2433 foreground = this.foreground;
2436 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
2439 surface.SetBackground(background);
2440 surface.Area(x-3, y, x+width-1, y + rowHeight-2);
2443 clip.left = x - EXTRA_SPACE / 2+1;
2445 clip.right = x + width - EXTRA_SPACE/2 - 0;
2446 clip.bottom = y + rowHeight - 1;
2447 surface.Clip(&clip);
2449 for(index = 0, cell = row.cells.first; cell && index != field.index; index++, cell = cell.next);
2450 // Should always be as many cells in the row as fields in the listbox
2451 if(cell && cell.isSet && field.dataType)
2454 surface.TextFont(boldFont);
2456 surface.TextFont(font);
2458 surface.SetForeground(foreground);
2459 surface.SetBackground(background);
2461 if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
2462 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);
2464 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);
2467 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
2468 background = formColor;
2470 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2472 background = formColor;
2473 foreground = this.background;
2476 x += width;// + EXTRA_SPACE;
2478 if(row.header) break;
2484 int plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2486 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)))
2488 surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
2489 surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
2491 surface.SetBackground(row.header ? (formColor) : (this.background)); //white
2492 surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
2494 surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
2496 surface.VLine(y + PLUSY + 2, y + PLUSY + 6, collapseRowStart + 7 + plusIndent);
2501 // Draw the current row stipple
2502 if(style.fullRowSelect && !(style.alwaysEdit) && (dataDisplayFlags.current) && isActive)
2507 surface.LineStipple(0x5555);
2508 if(dataDisplayFlags.selected)
2509 surface.SetForeground(stippleColor);
2511 surface.SetForeground(this.foreground);
2514 surface.SetForeground(selectionColor ? selectionColor : SELECTION_COLOR);
2515 surface.Rectangle(0, y, clientSize.w-1, (y + rowHeight) - 1);
2516 surface.LineStipple(0);
2520 if(y >= clientSize.h)
2523 if(firstRowShown) surface.Clip(null);
2524 if(this.dragRow && this.dropIndex != -1)
2526 int dropIndex = this.dropIndex;
2529 if(!style.multiSelect && currentRow.index < this.dropIndex)
2531 surface.DrawingChar(223);
2533 y = style.header ? rowHeight : 0;
2534 y += dropIndex * rowHeight - scroll.y;
2536 surface.SetForeground(Color { 85, 85, 255 });
2537 surface.HLine(0, clientSize.w-1, y);
2538 surface.HLine(0, clientSize.w-1, y + 1);
2542 void OnDrawOverChildren(Surface surface)
2544 if(draggingField && this.dropField)
2546 int position = this.dropField.x;
2547 if(draggingField.x < position)
2548 position += this.dropField.width + EXTRA_SPACE;
2550 surface.SetForeground(Color { 85, 85, 255 });
2551 surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
2552 surface.VLine(0, rowHeight - 1, position - scroll.x);
2554 if(sortField && !style.clearHeader && style.header)
2556 DataField field = sortField;
2557 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2558 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2561 surface.TextExtent(field.header, strlen(field.header), &tw, &th);
2562 if(tw < width - EXTRA_SPACE)
2564 bool up = field.sortOrder == 1;
2568 field.x + 2 - scroll.x, 0,
2569 field.x + width + EXTRA_SPACE - 1 - scroll.x, rowHeight
2571 surface.Clip(&clip);
2572 if(field.alignment == left || field.alignment == center)
2574 if(field.alignment == center)
2575 x = field.x + (width + EXTRA_SPACE - tw) / 2 + tw + EXTRA_SPACE + 4;
2577 x = field.x + tw + EXTRA_SPACE + 4;
2579 x = Min(x, field.x + width - 4);
2581 else if(field.alignment == right)
2583 x = field.x + width - tw - 2*EXTRA_SPACE - 4;
2584 x = Max(x, field.x + 2);
2590 // surface.SetForeground((wmenu.selectedFlag == item) ? white : black);
2591 // surface.WriteText(clientSize.w-8, y+(wmenu.rh - 8)/2, "\020", 1);
2597 surface.SetForeground(Color { 128,128,128 } );
2598 surface.DrawLine(x + 3, y, x, y + 5);
2599 surface.PutPixel(x + 1, y + 5);
2600 surface.PutPixel(x + 1, y + 3);
2601 surface.PutPixel(x + 2, y + 1);
2603 surface.SetForeground(white);
2604 surface.DrawLine(x + 4, y, x + 7, y + 5);
2605 surface.PutPixel(x + 6, y + 5);
2606 surface.PutPixel(x + 6, y + 3);
2607 surface.PutPixel(x + 5, y + 1);
2609 surface.DrawLine(x, y + 6, x + 7, y + 6);
2613 surface.SetForeground(Color { 128,128,128 });
2614 surface.DrawLine(x + 3, y+6, x, y+1);
2615 surface.PutPixel(x + 1, y+1);
2616 surface.PutPixel(x + 1, y+3);
2617 surface.PutPixel(x + 2, y+5);
2619 surface.SetForeground(white);
2620 surface.DrawLine(x + 4, y+6, x + 7, y+1);
2621 surface.PutPixel(x + 6, y+1);
2622 surface.PutPixel(x + 6, y+3);
2623 surface.PutPixel(x + 5, y+5);
2625 surface.DrawLine(x, y, x + 7, y);
2634 void OnResize(int w, int h)
2637 bool showEndBevel = false;
2639 if(style.collapse && !style.treeBranch)
2641 for(field = fields.first; field; field = field.next)
2643 int width = field.width + EXTRA_SPACE;
2651 (rowCount * rowHeight) +
2652 ((style.header) ? rowHeight : 0) -
2653 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
2655 for(field = fields.first; field; field = field.next)
2657 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2658 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2659 if(style.header && field.headButton)
2661 showEndBevel = true;
2664 field.headButton.position = { field.x, 0 };
2665 field.headButton.size = { width, rowHeight };
2666 field.headButton.visible = true;
2669 field.headButton.visible = false;
2673 if(!style.fillLastField && showEndBevel && endBevel)
2675 endBevel.position = { x, 0 };
2676 endBevel.size = { clientSize.w + 2 - x, rowHeight };
2677 endBevel.visible = true;
2680 endBevel.visible = false;
2682 if(style.alwaysEdit && editData && editData.visible)
2684 HideEditBox(true, false, true);
2688 void AdaptToFieldWidth(DataField field, bool doScroll)
2690 OnResize(clientSize.w, clientSize.h);
2692 // Scroll appropriately
2695 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2696 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2698 SetScrollPosition(field.x + field.width + EXTRA_SPACE - clientSize.w, scroll.y);
2700 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2702 SetScrollPosition(field.x, scroll.y);
2707 bool HeaderPushed(Button control, int x, int y, Modifiers mods)
2709 DataField field = (DataField)control.id;
2710 // false: dont destroy edit box
2711 HideEditBox(true, false, true);
2712 if(style.resizable && ((!field && x < RESIZE_BORDER && fields.last) ||
2713 (field && x < RESIZE_BORDER && field.prev) ||
2714 (field && x >= control.clientSize.w - RESIZE_BORDER)))
2717 field = fields.last;
2718 else if(x < RESIZE_BORDER && field.prev)
2721 if(field.fixed) return false;
2722 resizingField = field;
2723 this.resizeX = x + control.position.x;
2724 this.startWidth = field.width;
2725 this.oldX = x - scroll.x;
2730 if(field.fixed) return false;
2731 draggingField = field;
2732 if(style.moveFields)
2733 field.headButton.stayDown = true;
2734 else if(!style.sortable)
2742 bool HeaderMouseMove(Button control, int x, int y, Modifiers mods)
2747 DataField field = resizingField;
2749 x += control.position.x;
2751 // Tweak to prevent shrinking field if we're actually moving right
2752 if(x - scroll.x > this.oldX &&
2753 this.startWidth + x - this.resizeX < field.width)
2755 this.oldX = x - scroll.x;
2758 this.oldX = x - scroll.x;
2760 field.width = this.startWidth + x - this.resizeX;
2761 field.width = Max(field.width, - EXTRA_SPACE);
2763 AdaptToFieldWidth(field, true);
2765 else if(draggingField)
2767 x += control.position.x;
2768 if(style.moveFields)
2770 DataField field = fields.last;
2772 for(field = fields.first; field; field = field.next)
2774 fieldX += ((field.width || style.resizable) ?
2775 field.width : clientSize.w) + EXTRA_SPACE;
2779 if(draggingField == field)
2781 // Reset scroll position
2782 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2783 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2786 field.x + field.width + EXTRA_SPACE - clientSize.w,
2789 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2791 SetScrollPosition(field.x, scroll.y);
2794 if(this.dropField != field)
2796 this.dropField = field;
2799 int position = field.x;
2801 if(draggingField.x < position)
2803 position += field.width + EXTRA_SPACE - clientSize.w;
2804 if(position > scroll.x)
2805 SetScrollPosition(position, scroll.y);
2810 if(position < scroll.x)
2811 SetScrollPosition(position, scroll.y);
2814 this.movingFields = true;
2820 else if(style.resizable)
2822 DataField field = (DataField)control.id;
2825 if(x < RESIZE_BORDER && field.prev)
2827 if(!field.prev.fixed)
2828 control.cursor = guiApp.GetCursor(sizeWE);
2830 else if(x >= control.clientSize.w - RESIZE_BORDER)
2831 control.cursor = guiApp.GetCursor(sizeWE);
2833 control.cursor = null;
2837 if(x < RESIZE_BORDER && fields.last)
2838 control.cursor = guiApp.GetCursor(sizeWE);
2840 control.cursor = null;
2846 bool HeaderReleased(Button control, int x, int y, Modifiers mods)
2850 NotifyResized(master, this, resizingField, mods);
2851 resizingField = null;
2858 if(style.moveFields)
2863 DataField switchField = fields.last;
2867 x += draggingField.x;
2868 for(field = fields.first; field; field = field.next)
2870 fieldX += ((field.width || style.resizable) ?
2871 field.width : clientSize.w) + EXTRA_SPACE;
2874 switchField = field;
2878 if(switchField && draggingField != switchField && this.dropField)
2880 for(field = fields.first; field; field = field.next)
2882 if(field == switchField || field == draggingField)
2886 // Switch field first: move before
2887 if(field == switchField)
2888 draggingField.Move(switchField.prev);
2889 // Dragged field first: move after
2891 draggingField.Move(switchField);
2893 NotifyMovedField(master, this, draggingField, mods);
2895 draggingField.headButton.stayDown = false;
2900 movingFields = false;
2902 draggingField = null;
2908 bool HeaderClicked(Button control, int x, int y, Modifiers mods)
2910 if(style.header && !this.dropField && style.sortable)
2912 DataField field = (DataField)control.id;
2913 if(sortField == field)
2914 field.sortOrder *= -1;
2919 Sort(sortField, field.sortOrder);
2920 NotifySort(master, this, field, mods);
2926 bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
2930 DataField field = (DataField)control.id;
2933 if(x < RESIZE_BORDER && field.prev)
2935 else if(x >= control.clientSize.w - RESIZE_BORDER);
2941 if(x < RESIZE_BORDER && fields.last)
2942 field = fields.last;
2954 if(style.freeSelect)
2959 this.rolledOver = this.dragging = false;
2966 bool OnLoadGraphics()
2968 display.FontExtent(fontObject, "W", 1, null, &fontH);
2969 if(!style.heightSet)
2971 rowHeight = Max(fontH + 2, 16) + (style.alwaysEdit ? 1 : 0);
2972 SetScrollLineStep(8, rowHeight);
2977 void OnApplyGraphics()
2979 SetScrollLineStep(8, rowHeight);
2983 for(field = fields.first; field; field = field.next)
2985 if(field.headButton)
2987 field.headButton.bevel = (!guiApp.textMode && !style.clearHeader);
2989 field.headButton.background = Color { 0, 170, 0 };
2993 OnResize(clientSize.w, clientSize.h);
2996 bool OnResizing(int *w, int *h)
3000 if(!initSize.w && (!anchor.left.type || !anchor.right.type) /**w*/)
3005 Font font = fontObject;
3006 Font boldFont = this.boldFont.font;
3007 Display display = this.display;
3009 for(row = rows.first; row; row = row.GetNextRow())
3011 Bitmap icon = row.icon ? row.icon.bitmap : null;
3012 int x = -scroll.x + EXTRA_SPACE / 2-1;
3016 for(parent = row.parent; parent; parent = parent.parent)
3020 if(style.treeBranch)
3026 if(style.rootCollapse) indent += 20;
3028 if(style.collapse && !(style.treeBranch)) x += 15;
3032 // Compute the rows size
3033 for(field = fields.first; field; field = field.next)
3035 if(((style.resizable && (!(style.alwaysEdit) || field.next)) || field.width) && !row.header)
3036 x += field.width - (field.prev ? 0 : indent);
3041 for(index = 0, cell = row.cells.first; index != field.index; index++, cell = cell.next);
3043 // Should always be as many cells in the row as fields in the listbox
3044 if(cell && cell.isSet && field.dataType)
3046 static char tempString[4096];
3049 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
3050 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data[0], tempString, field.userData, null);
3052 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data, tempString, field.userData, null);
3054 if(!string) string = "";
3055 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3058 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3060 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, &th);
3063 if(row.header) break;
3067 maxWidth = Max(maxWidth, x);
3073 *h = Min(this.maxShown, this.rowCount) * rowHeight;
3078 if(!*w) *w = rowHeight * 5;
3079 if(!*h) *h = rowHeight * 5;
3086 FontResource font = this.font;
3087 FontResource boldFont
3089 faceName = font.faceName, size = font.size, bold = true
3091 AddResource(boldFont);
3092 RemoveResource(this.boldFont);
3093 this.boldFont = boldFont;
3097 SetInitSize(initSize);
3100 bool OnMouseMove(int x, int y, Modifiers mods)
3102 bool isTimer = false;
3103 int realX = x, realY = y;
3105 if(insideNotifySelect) return true;
3107 if(style.alwaysEdit && style.resizable &&
3108 resizingField && !(mods.isSideEffect))
3111 DataField field = resizingField;
3112 field.width = this.startWidth + x - this.resizeX;
3113 field.width = Max(field.width, - EXTRA_SPACE);
3115 AdaptToFieldWidth(field, true);
3119 if(style.alwaysEdit && style.resizable)
3121 int vx = -scroll.x - 1;
3124 if(style.collapse && !(style.treeBranch))
3127 for(field = fields.first; field; field = field.next)
3129 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3130 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3136 cursor = guiApp.GetCursor(sizeWE);
3140 vx += width + EXTRA_SPACE;
3144 if((editData && editData.visible) || (style.alwaysEdit))
3147 if(x == MAXINT && y == MAXINT)
3154 // ADDED THIS CHECK FOR FieldDropBox LEAKS
3155 if(/*!mods.isSideEffect && */(this.rolledOver || !this.dragging))
3157 int rowY = (style.header) ? rowHeight : 0;
3165 ((vertScroll && vertScroll.visible &&
3166 (y < 0 || y >= clientSize.h)) ||
3167 (horzScroll && horzScroll.visible &&
3168 (x < 0 || x >= clientSize.w))))
3173 if(vertScroll && vertScroll.visible &&
3174 (y < 0 || y >= clientSize.h))
3175 vertScroll.Action((y<0)?up:down, 0, 0);
3176 if(horzScroll && horzScroll.visible &&
3177 (x < 0 || x >= clientSize.w))
3178 horzScroll.Action((x<0)?up:down, 0, 0);
3184 // This must be done after the scrolling took place
3185 rowIndex = firstRowShown ? firstRowShown.index : -1;
3187 y = Min(y, clientSize.h-1);
3188 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3197 if(row && currentRow != row)
3199 if(this.dragRow && style.moveRows)
3201 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3203 else if(style.multiSelect)
3206 for(thisRow = rows.first; thisRow; thisRow = thisRow.GetNextRow())
3207 if((thisRow.selectedFlag == selected || thisRow.selectedFlag == tempSelected) ||
3213 if(this.dropIndex != rowIndex)
3215 this.dropIndex = rowIndex;
3216 this.editRow = null;
3218 this.movedRow = true;
3221 else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || this.rolledOver))
3223 if(!(style.multiSelect))
3225 if(currentRow)currentRow.selectedFlag = unselected;
3226 if(row)row.selectedFlag = selected;
3230 if(style.multiSelect)
3234 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3236 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3237 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3240 if(rowIndex >= clickedRow.index)
3242 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3244 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3251 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3253 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3254 if(selRow == clickedRow)
3260 if(style.freeSelect)
3261 NotifyHighlight(master, this, currentRow, mods);
3264 insideNotifySelect = true;
3265 NotifySelect(master, this, currentRow, mods);
3266 insideNotifySelect = false;
3269 if(style.alwaysEdit && currentRow)
3270 currentRow.Edit(currentField);
3277 bool OnMouseOver(int x, int y, Modifiers mods)
3280 this.rolledOver = true;
3284 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
3286 // TOCHECK: WAS THIS MISSING ? CHECK FOR SLOWDOWN
3287 if(!active) Update(null);
3289 if(!active && (!swap || !swap.isModal))
3291 // true: destroy edit box
3292 HideEditBox(true, true, false);
3294 else if(!swap || !swap.isModal)
3296 // Bring back edit box
3297 if(currentRow && style.alwaysEdit)
3299 currentRow.Edit(currentField ? currentField : null);
3303 return true; //NotifyActivate(master, this, active, swap, 0);
3307 bool OnButtonDown(int x, int y, Modifiers mods, bool right)
3310 // Check to see if we're dragging the vertical divider
3311 if(style.alwaysEdit && style.resizable && !right)
3313 int vx = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
3316 if(style.collapse && !(style.treeBranch))
3319 for(field = fields.first; field; field = field.next)
3321 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3322 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3328 resizingField = field.prev;
3330 this.startWidth = resizingField.width;
3332 SetMouseRangeToClient();
3336 vx += width + EXTRA_SPACE;
3340 if(!(style.freeSelect))
3342 int rowY = (style.header) ? rowHeight : 0;
3344 int rowIndex = firstRowShown ? firstRowShown.index : -1;
3345 DataRow previousRow = currentRow;
3346 DataRow newCurrentRow = null;
3347 DataField newCurrentField = null;
3348 bool moveMultiple = false;
3349 int numSelected = 0;
3350 int rowStart = -scroll.x;
3352 if(style.multiSelect)
3359 for(row = rows.first; row; row = row.GetNextRow())
3361 if(row.selectedFlag == tempSelected)
3362 row.selectedFlag = selected;
3363 else if(row.selectedFlag == tempUnselected)
3364 row.selectedFlag = unselected;
3365 if(row.selectedFlag == selected)
3372 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3375 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3378 if(style.treeBranch)
3381 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3387 /* THIS WAS TOO STRICT:
3388 if(style.collapse && row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) &&
3389 (x >= rowStart + 3 + plusIndent && y >= rowY - rowHeight + PLUSY && x <= rowStart + 11 + plusIndent && y <= rowY - rowHeight + PLUSY + 8))
3391 if(style.collapse &&
3392 (x >= rowStart && y >= rowY - rowHeight && x <= rowStart + 18 + plusIndent && y <= rowY + rowHeight-1))
3394 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) && x >= plusIndent)
3395 row.collapsed = !row.collapsed;
3402 newCurrentRow = row;
3404 if(style.multiSelect)
3406 // Deselect everything if user didn't clicked on a row
3410 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3411 selRow.selectedFlag = unselected;
3413 //this.clickedRowIndex = rowIndex;
3415 else if(style.moveRows && !(mods.shift) &&
3416 (row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
3417 !right && !(mods.isActivate))
3418 moveMultiple = true;
3424 if(row.selectedFlag == tempUnselected || row.selectedFlag == unselected)
3426 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3427 selRow.selectedFlag = unselected;
3428 row.selectedFlag = selected;
3431 //this.clickedRowIndex = rowIndex;
3437 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3438 selRow.selectedFlag = unselected;
3442 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3444 if(selRow != clickedRow)
3446 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3447 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3454 if(rowIndex >= clickedRow.index)
3456 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3460 if(selRow != clickedRow)
3462 if(selRow.selectedFlag)
3463 selRow.selectedFlag = tempUnselected;
3465 selRow.selectedFlag = tempSelected;
3469 selRow.selectedFlag = selected;
3476 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3480 if(selRow != clickedRow)
3482 if(selRow.selectedFlag)
3483 selRow.selectedFlag = tempUnselected;
3485 selRow.selectedFlag = tempSelected;
3489 selRow.selectedFlag = selected;
3490 if(selRow == clickedRow)
3499 if(row.selectedFlag)
3500 row.selectedFlag = tempUnselected;
3501 else row.selectedFlag = tempSelected;
3504 row.selectedFlag = tempSelected;
3506 //this.clickedRowIndex = rowIndex;
3516 // true: destroy edit box
3519 incref newCurrentRow;
3522 if(currentRow != newCurrentRow)
3523 HideEditBox(true, true, false);
3527 if(newCurrentRow._refCount <= 1)
3528 delete newCurrentRow;
3530 newCurrentRow._refCount--;
3535 if(!(style.multiSelect))
3537 if(currentRow) currentRow.selectedFlag = unselected;
3538 if(newCurrentRow) newCurrentRow.selectedFlag = selected;
3542 if(currentRow != newCurrentRow)
3545 // true: destroy edit box
3548 //incref newCurrentRow;
3549 incref newCurrentRow;
3552 HideEditBox(true, true, false);
3557 int headerSize = ((style.header) ? rowHeight : 0);
3558 int height = clientSize.h + 1 - headerSize;
3560 /*if(newCurrentRow._refCount <= 1)
3561 delete newCurrentRow;
3564 newCurrentRow._refCount--;
3565 //newCurrentRow._refCount--;
3568 currentRow = newCurrentRow;
3570 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
3571 SetScrollPosition(scroll.x,
3572 currentRow.index * rowHeight - height + rowHeight);
3573 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
3575 int line = currentRow ? currentRow.index * rowHeight : 0;
3576 //SNAPUP(line, rowHeight);
3577 SetScrollPosition(scroll.x, line);
3580 // GO THROUGH SetCurrentRow eventually?
3581 // SetCurrentRow(newCurrentRow, true);
3585 if(style.freeSelect)
3586 NotifyHighlight(master, this, currentRow, mods);
3587 else if((moveMultiple || (!(style.multiSelect) && previousRow == currentRow)) &&
3588 newCurrentRow && !(mods.shift))
3592 if(!(mods.isActivate))
3596 this.dragRow = currentRow;
3597 this.dropIndex = -1;
3598 this.movedRow = false;
3600 if(editData && editData.visible && style.alwaysEdit)
3607 if(style.collapse && !style.treeBranch)
3610 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3612 indent += (style.treeBranch) ? 20 : 15;
3615 for(field = fields.first; field; field = field.next)
3617 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3618 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3620 if(!field.prev) width -= indent;
3621 if(x >= sx && x < sx + width)
3625 if(field == currentField)
3626 editData.Deactivate();
3629 currentRow.Edit(field);
3630 editData.Activate();
3633 else if(!(mods.ctrl) && numSelected <= 1)
3634 this.editRow = currentRow;
3636 if(style.noDragging && newCurrentRow)
3637 NotifyReclick(master, this, newCurrentRow, mods);
3641 // If the user clicked exactly on the edited field,
3643 if(editData && editData.visible && newCurrentRow)
3645 DataField field, whichField;
3649 if(style.collapse && !(style.treeBranch))
3652 whichField = currentField;
3656 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3658 indent += (style.treeBranch) ? 20 : 15;
3662 for(field = fields.first; field; field = field.next)
3664 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3665 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3666 if(!field.prev) width -= indent;
3667 if(x >= sx && x < sx + width && newCurrentRow)
3672 if(field) //x >= sx && x < sx + width && newCurrentRow)
3674 if(field == currentField)
3675 editData.Activate();
3677 newCurrentRow.Edit(currentField);*/
3679 else if(style.noDragging && newCurrentRow)
3680 NotifyReclick(master, this, newCurrentRow, mods);
3682 else if(style.noDragging && newCurrentRow)
3683 NotifyReclick(master, this, newCurrentRow, mods);
3689 result = NotifySelect(master, this,
3690 currentRow ? currentRow : null, mods);
3691 if(result && style.alwaysEdit && currentRow)
3695 DataField field = null;
3700 if(style.collapse && !style.treeBranch)
3703 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3705 indent += (style.treeBranch) ? 20 : 15;
3708 for(field = fields.first; field; field = field.next)
3710 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3711 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3713 if(!field.prev) width -= indent;
3714 if(x >= sx && x < sx + width)
3716 currentField = field;
3722 currentRow.Edit(currentField);
3724 // If the user clicked exactly on the edited field,
3726 if(editData && editData.visible && newCurrentRow)
3730 editData.Activate();
3732 else if(style.noDragging && newCurrentRow)
3733 NotifyReclick(master, this, newCurrentRow, mods);
3736 else if(style.noDragging && newCurrentRow)
3737 NotifyReclick(master, this, newCurrentRow, mods);
3741 For drop box to capture...
3744 if(x < 0 || y < 0 || x >= clientSize.w || y >= clientSize.h)
3747 master.parent.Activate();
3756 if(!style.noDragging)
3758 this.dragging = true;
3761 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h)
3762 this.rolledOver = true;
3767 this.dragging = false;
3768 OnLeftButtonUp(x, y, mods);
3773 bool OnLeftButtonDown(int x, int y, Modifiers mods)
3775 return OnButtonDown(x,y, mods, false);
3778 bool OnLeftButtonUp(int x, int y, Modifiers mods)
3780 if(resizingField && style.alwaysEdit)
3782 Window::FreeMouseRange();
3784 resizingField = null;
3787 if(dragRow || editRow)
3789 DataRow row, switchRow = rows.last;
3790 int rowY = (style.header) ? rowHeight : 0;
3791 for(row = firstRowShown; row; row = row.GetNextRow())
3800 if(this.editRow == switchRow && y >= 0)
3805 for(field = fields.first; field; field = field.next)
3807 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3808 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3811 if(fieldX > x + scroll.x)
3815 if(field && field.editable)
3817 // true: destroy edit box
3818 HideEditBox(true, true, false);
3819 PopupEditBox(field, false);
3821 else if(!style.noDragging)
3822 NotifyReclick(master, this, currentRow, mods);
3824 else if(style.moveRows && switchRow)
3826 if(this.dragRow == switchRow && this.movedRow == false)
3828 DataRow row = this.dragRow;
3832 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3833 selRow.selectedFlag = unselected;
3837 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3839 if(selRow != clickedRow)
3841 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3842 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3848 if(row.selectedFlag)
3849 row.selectedFlag = tempUnselected;
3850 else row.selectedFlag = tempSelected;
3853 row.selectedFlag = tempSelected;
3858 if(style.multiSelect)
3860 if(!switchRow.selectedFlag)
3862 bool foundSwitch = false;
3865 DataRow afterRow = switchRow.prev;
3866 for(row = rows.first; row; row = next)
3868 next = row.GetNextRow();
3869 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3871 if(!foundSwitch && !after)
3874 afterRow = switchRow;
3876 if(!after || !(row.selectedFlag == selected || row.selectedFlag == tempSelected) ||
3883 else if(row == switchRow)
3890 for(row = rows.first; row; row = row.GetNextRow())
3892 if(row == switchRow || row == this.dragRow)
3896 // Switch row first: move before
3897 if(row == switchRow)
3899 if(NotifyMove(master, this, switchRow.prev, mods))
3900 dragRow.Move(switchRow.prev);
3902 // Dragged row first: move after
3905 if(NotifyMove(master, this, switchRow, mods))
3906 dragRow.Move(switchRow);
3919 if(this.dragging || style.freeSelect)
3923 this.rolledOver = this.dragging = false;
3925 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h && currentRow && style.freeSelect)
3929 result = NotifySelect(master, this, currentRow, mods);
3930 if(style.alwaysEdit)
3931 currentRow.Edit(currentField);
3935 // if(!(style.freeSelect))
3941 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
3943 int rowStart = -scroll.x;
3945 int rowY = (style.header) ? rowHeight : 0;
3948 OnLeftButtonUp(x,y,mods);
3949 if(style.alwaysEdit)
3951 if(!(style.collapse) || x > 15)
3952 if(editData && editData.visible)
3954 editData.Activate();
3955 NotifyDoubleClick(master, this, x, y, mods);
3959 for(row = firstRowShown; row; row = row.GetNextRow())
3962 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3964 if(style.treeBranch)
3967 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3976 if((row && style.collapse && (x >= rowStart && x <= rowStart + 18 + plusIndent)) ||
3977 NotifyDoubleClick(master, this, x, y, mods))
3981 if(row && row.subRows.first)
3983 row.collapsed = !row.collapsed;
3987 // We need to return true here so that OnLeftButtonDown can popup the DataBox Editors
3993 bool OnRightButtonDown(int x, int y, Modifiers mods)
3995 return OnButtonDown(x,y, mods, true);
3998 bool OnRightButtonUp(int x, int y, Modifiers mods)
4000 OnLeftButtonUp(x,y,mods);
4001 return NotifyRightClick(master, this, x, y, mods);
4004 bool GoToLetter(unichar ch, bool keyHit)
4006 bool result = false;
4008 bool checkNextField = true;
4009 int len = keyHit ? 0 : strlen(typedString);
4011 typedString = renew typedString char[len + 2];
4012 typedString[len++] = (char)tolower(ch); // TODO: FIX UNICODE
4013 typedString[len] = '\0';
4015 for(field = fields.first; field; field = field.next)
4017 DataRow startRow = currentRow ? currentRow : rows.first;
4019 if(startRow && field.dataType && field.dataType._vTbl[__ecereVMethodID_class_OnGetString] && ch)
4022 bool looped = false;
4023 if(len == 1 && currentRow)
4024 startRow = (next = startRow.GetNextRow(), (next ? next : rows.first));
4026 for(row = startRow; row != startRow || !looped; next = row.GetNextRow(), row = next ? next : rows.first)
4028 void * data = row.GetData(field);
4029 char tempString[1024] = "";
4030 bool needClass = false;
4031 char * string = data ? (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass) : null;
4033 if(string && string[0])
4034 checkNextField = false;
4035 if(string && string[0] && !strnicmp(string, typedString, len))
4037 if(style.multiSelect)
4040 bool foundRow = false;
4042 //this.clickedRowIndex = 0;
4044 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4046 if(selRow == row) foundRow = true;
4047 selRow.selectedFlag = unselected;
4048 //if(!foundRow) this.clickedRowIndex++;
4050 row.selectedFlag = selected;
4052 SetCurrentRow(row, true);
4059 if(this.typingTimeOut && !keyHit)
4060 typingTimer.Start();
4061 if(!result || !this.typingTimeOut || keyHit)
4062 typedString[len-1] = '\0';
4064 if(!checkNextField || result) break;
4069 bool OnKeyDown(Key key, unichar ch)
4073 if(key == enter || key == keyPadEnter)
4075 if(editData && editData.visible && editData.active)
4077 HideEditBox(true, false, false);
4081 else if(key == escape)
4083 if(resizingField || this.movingFields || (editData && editData.visible) || this.dragRow)
4085 if(editData && editData.visible && style.alwaysEdit && !editData.active)
4087 // false: dont destroy edit box
4088 HideEditBox(false, false, false);
4091 resizingField.width = this.startWidth;
4092 AdaptToFieldWidth(resizingField, true);
4093 resizingField = null;
4096 this.dragRow = null;
4099 this.dragging = false;
4103 this.movingFields = false;
4104 draggingField = null;
4110 if(!currentField || !currentField.editable)
4111 for(field = fields.first; field; field = field.next)
4115 currentField = field;
4119 if(key == f2 && currentField && currentField.editable)
4121 PopupEditBox(currentField, false);
4122 if(editData && editData.visible)
4124 if(style.alwaysEdit)
4125 editData.Activate();
4130 if(!NotifyKeyDown(master, this, currentRow, key, ch))
4133 // Editable fields...
4136 if(style.alwaysEdit && editData && editData.visible)
4137 return editData.OnKeyDown(key, ch);
4138 return true; // We want to pick up the OnKeyHit to replace contents, but skip GoToLetter
4141 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, false))
4143 /*if(inactive && window.state != Hidden)
4144 NotifyHighlight(master, this, currentRow, 0);
4147 NotifySelect(master, this, currentRow, 0);
4154 bool OnKeyHit(Key key, unichar ch)
4156 if(key.code == up && key.alt == true && key.ctrl == false && key.shift == false)
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(!(style.multiSelect) && (key.ctrl))
4193 if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
4199 if(style.alwaysEdit)
4204 for(field = currentField.prev; field; field = field.prev)
4208 currentField = field;
4209 HideEditBox(true, true, false);
4210 PopupEditBox(currentField, false);
4216 if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
4218 if(currentRow.subRows.first && !currentRow.collapsed)
4220 currentRow.collapsed = true;
4222 else if(currentRow.parent)
4223 SetCurrentRow(currentRow.parent, true);
4228 if(style.collapse && currentRow && currentRow.subRows.first)
4230 if(currentRow.collapsed)
4231 currentRow.collapsed = false;
4233 SetCurrentRow(currentRow.subRows.first, true);
4236 else if(style.alwaysEdit)
4241 for(field = currentField.next; field; field = field.next)
4245 currentField = field;
4246 HideEditBox(true, true, false);
4247 PopupEditBox(currentField, false);
4255 case pageDown: case pageUp:
4256 case end: case home:
4258 int headerSize = ((style.header) ? rowHeight : 0);
4259 int height = clientSize.h + 1 - headerSize;
4262 // true: destroy edit box
4263 // !!! TESTING true HERE !!!
4264 HideEditBox(true, true, false);
4265 // HideEditBox(false, true, false);
4267 oldRow = currentRow;
4269 SNAPDOWN(height, rowHeight);
4270 if((!currentRow || key.code == home) && key.code != end)
4272 currentRow = rows.first;
4280 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4283 next = currentRow.GetNextRow();
4290 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4293 next = currentRow.GetPrevRow();
4301 currentRow = lastRow.GetLastRow();
4307 currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
4308 c++, currentRow = next);
4315 currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
4316 c++, currentRow = next);
4321 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
4322 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
4323 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
4324 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
4326 if(style.multiSelect)
4330 if(!(key.shift) && (key.ctrl))
4333 for(row = rows.first; row; row = row.GetNextRow())
4335 if(row.selectedFlag == tempSelected)
4336 row.selectedFlag = selected;
4337 else if(row.selectedFlag == tempUnselected)
4338 row.selectedFlag = unselected;
4344 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4345 selRow.selectedFlag = unselected;
4349 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4351 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
4352 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
4358 if(currentRow.index >= clickedRow.index)
4360 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
4364 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4367 selRow.selectedFlag = selected;
4368 if(selRow == currentRow)
4374 for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
4378 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4381 selRow.selectedFlag = selected;
4382 if(selRow == clickedRow)
4389 if(!(key.ctrl) && currentRow)
4391 currentRow.selectedFlag = selected;
4394 clickedRow = currentRow;
4399 if(oldRow) oldRow.selectedFlag = unselected;
4400 if(currentRow) currentRow.selectedFlag = selected;
4405 if(style.freeSelect)
4406 NotifyHighlight(master, this, currentRow, 0);
4408 NotifySelect(master, this, currentRow, 0);
4410 if(style.alwaysEdit && currentRow)
4411 currentRow.Edit(currentField /*null*/);
4418 if(style.multiSelect && currentRow)
4420 if(currentRow.selectedFlag)
4423 currentRow.selectedFlag = unselected;
4426 currentRow.selectedFlag = selected;
4429 if(style.freeSelect)
4430 NotifyHighlight(master, this, currentRow, 0);
4432 NotifySelect(master, this, currentRow, 0);
4438 if(!NotifyKeyHit(master, this, currentRow, key, ch))
4441 if(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);
4455 void OnHScroll(ScrollBarAction action, int position, Key key)
4460 void OnVScroll(ScrollBarAction action, int position, Key key)
4465 for(firstRowShown = rows.first; firstRowShown; firstRowShown = next)
4467 next = firstRowShown.GetNextRow();
4468 if(y >= position || !next) break;
4478 DataRow firstRowShown;
4482 DataField sortField;
4486 double typingTimeOut;
4499 if(guiApp.GetKeyState(shift)) mods.shift = true;
4500 if(guiApp.GetKeyState(alt)) mods.alt = true;
4501 if(guiApp.GetKeyState(control)) mods.ctrl = true;
4502 OnMouseMove(MAXINT, MAXINT, mods);
4510 delay = 0.5; // typingTimeOut
4515 typedString[0] = '\0';
4517 // The next line was commented... Why? When commented typing words stops working ( only first character jumps )
4523 bool dragging, rolledOver;
4532 // For editing fields
4534 DataField currentField;
4537 // For moving fields
4538 DataField draggingField, dropField;
4541 // For resizing fields
4542 DataField resizingField;
4543 int resizeX, oldX, startWidth;
4546 FontResource boldFont;
4549 // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
4550 bool insideNotifySelect;
4551 Color selectionColor, selectionText, stippleColor;
4552 stippleColor = 0xFFFFFF80;