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 Alignment alignment
69 if(headButton) headButton.alignment = value;
70 if(listBox) listBox.Update(null);
72 get { return alignment; }
78 width = Max(value, -EXTRA_SPACE);
80 listBox.AdaptToFieldWidth(this, false);
84 property int index { get { return this ? index : 0; } };
93 for(field = listBox.fields.first; field; field = field.next)
95 if(index == value - 2)
108 for(field = listBox.fields.first; field; field = field.next)
120 property int sortOrder { get { return this ? sortOrder : 0; } };
121 property char * header
127 headButton.text = header;
130 property void * userData
138 return this ? userData : null;
141 property bool freeData
143 set { freeData = value; } get { return freeData; }
145 property DataField prev { get { return prev; } };
146 property DataField next { get { return next; } };
148 void Move(DataField after)
155 listBox.fields.Move(this, after);
158 listBox.OnResize(listBox.clientSize.w, listBox.clientSize.h);
159 listBox.Update(null);
165 if(listBox && dataType)
167 Display display = listBox.display;
168 Font boldFont = listBox.boldFont.font;
169 Font font = listBox.fontObject;
172 for(row = listBox.firstRow; row; row = row.next)
176 for(i = 0, cell = row.cells.first; i != index; i++, cell = cell.next);
177 if(cell && cell.isSet && dataType)
179 static char tempString[4096];
182 if(dataType.type == normalClass || dataType.type == noHeadClass)
183 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, cell.data[0], tempString, userData, null);
185 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, cell.data, tempString, userData, null);
187 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, null);
189 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, null);
190 if(tw > width) width = tw;
194 property::width = width;
201 // property::dataType = "String";
202 property::dataType = "char *";
214 headButton.Destroy(0);
219 listBox.fields.Remove(this);
220 for(field = listBox.fields.first; field; field = field.next)
222 if(field.index >= index)
225 if(listBox.currentField == this)
226 listBox.currentField = null;
228 listBox.OnResize(listBox.clientSize.w, listBox.clientSize.h);
233 DataField prev, next;
256 property int tag { set { tag = value; } get { return tag; } };
257 property DataRow previous { get { return prev; } };
258 property DataRow next { get { return next; } };
259 property int index { get { return (this && (!parent || parent.IsExpanded())) ? index : -1; } };
260 property char * string
262 set { SetData(listBox.fields.first, value); }
263 get { return GetData(listBox.fields.first); }
265 property bool isHeader { set { header = value; } get { return this ? header : false; } };
266 property BitmapResource icon { set { icon = value; } get { return icon; } };
267 property bool collapsed
271 if(collapsed != value)
274 if(parent.IsExpanded())
281 for(search = subRows.first; search; search = search.next)
282 search.selectedFlag = 0;
284 if(listBox.clickedRow && !listBox.clickedRow.parent.IsExpanded())
286 listBox.clickedRow = GetNextRow();
287 if(!listBox.clickedRow)
288 listBox.clickedRow = this;
290 if(listBox.currentRow && !listBox.currentRow.parent.IsExpanded())
292 listBox.SetCurrentRow(this, true);
294 if(listBox.firstRowShown && !listBox.firstRowShown.parent.IsExpanded())
296 listBox.firstRowShown = GetPrevRow();
297 if(!listBox.firstRowShown)
298 listBox.firstRowShown = this;
302 index = this.index+1;
303 for(search = GetNextRow(); search; search = search.GetNextRow())
304 search.index = index++;
305 listBox.rowCount = index;
307 listBox.HideEditBox(false, false, true);
309 listBox.SetScrollArea(
311 (listBox.rowCount * listBox.rowHeight) +
312 ((listBox.style.header) ? listBox.rowHeight : 0) -
313 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
314 listBox.Update(null);
315 listBox.NotifyCollapse(listBox.master, listBox, this, value);
320 listBox.CheckConsistency();
323 get { return this ? collapsed : false; }
325 property bool selected
331 selectedFlag = value ? selected : unselected;
332 listBox.Update(null);
335 get { return selectedFlag == selected || selectedFlag == tempSelected; }
337 property DataRow parent
341 if(this && (value != this))
344 DataRow after = value ? value.subRows.last : listBox.rows.last;
345 int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
346 if(parent.IsExpanded())
348 for(search = GetNextRow(); search; search = search.GetNextRow())
349 search.index -= ixCount;
350 listBox.rowCount -= ixCount;
353 listBox.HideEditBox(false, false, true);
356 if(this == listBox.clickedRow)
358 listBox.clickedRow = GetNextRow();
359 if(!listBox.clickedRow)
360 listBox.clickedRow = GetPrevRow();
363 if(this == listBox.currentRow)
365 DataRow newCurrentRow = GetNextRow();
366 if(!listBox.newCurrentRow)
367 listBox.newCurrentRow = GetPrevRow();
368 listBox.SetCurrentRow(newCurrentRow, true);
371 if(this == listBox.firstRowShown)
373 listBox.firstRowShown = GetPrevRow();
374 if(!listBox.firstRowShown)
375 listBox.firstRowShown = GetNextRow();
379 (parent ? parent.subRows : listBox.rows).Remove(this);
382 value.subRows.Insert(after, this);
384 listBox.rows.Insert(after, this);
388 if(value && listBox.style.expandOnAdd)
391 value.skipCheck = true;
393 value.collapsed = false;
395 value.skipCheck = false;
399 if(value.IsExpanded(this))
403 if(after && after.subRows.first && !after.collapsed)
405 search = after.GetLastRow();
406 index = search.index + 1;
409 index = after ? (after.index + 1) : (index + 1);
411 listBox.rowCount += ixCount;
415 for(search = GetNextRow(); search; search = search.GetNextRow())
419 listBox.SetScrollArea(
421 (listBox.rowCount * listBox.rowHeight) +
422 ((listBox.style.header) ? listBox.rowHeight : 0) -
423 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
424 if(listBox.style.autoScroll)
425 listBox.SetScrollPosition(0, MAXINT - listBox.rowHeight);
427 // TESTING THIS HERE...
429 listBox.Sort(listBox.sortField, listBox.sortField.sortOrder);
432 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
433 int height = listBox.clientSize.h + 1 - headerSize;
434 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
435 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
436 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
438 int line = listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0;
439 listBox.SetScrollPosition(listBox.scroll.x, line);
442 listBox.OnVScroll(0, listBox.scroll.y, 0);
444 listBox.Update(null);
452 property DataRow lastRow { get { return this ? subRows.last : null; } };
453 property DataRow firstRow { get { return this ? subRows.first : null; } };
455 void Edit(DataField field)
461 if(!field || !field.editable)
463 for(field = listBox.fields.first; field; field = field.next)
464 if(field.editable) break;
466 if(field && field.editable)
468 listBox.SetCurrentRow(this, true);
469 listBox.PopupEditBox(field, false);
475 // NOTE: This does not support reparenting (Use row.parent = first)
476 void Move(DataRow after)
481 if(listBox && prev != after)
485 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
486 int height = listBox.clientSize.h + 1 - headerSize;
487 int ixCount = (!collapsed && subRows.count) ? GetLastRow().index - index + 1 : 1;
489 if(!after || after.index < index)
491 if(after == listBox.firstRowShown.prev)
492 listBox.firstRowShown = this;
494 // All rows between AFTER (exclusive) and ROW (exclusive) are incremented by one
495 // ROW is equal to AFTER's index + 1
497 for(search = after ? after.next : listBox.rows.first; search && search != this; search = search.GetNextRow())
498 search.index += ixCount;
500 if(after && after.subRows.first && !after.collapsed)
502 search = after.GetLastRow();
503 index = search.index + 1;
506 index = after ? (after.index + 1) : 0;
508 // Fix indices of sub rows
512 for(c = 1, search = GetNextRow(); search && c < ixCount; c++, search = search.GetNextRow())
518 DataRow nextRow = GetNextRow();
519 if(this == listBox.firstRowShown)
521 listBox.firstRowShown = nextRow;
522 index = after ? (after.index + 1) : 0;
525 // All rows between ROW (exclusive) and AFTER (inclusive) are decremented by one
526 // ROW is equal to AFTER's index
528 for(search = nextRow; search; search = search.GetNextRow())
530 search.index -= ixCount;
531 if(search == after) break;
534 listBox.rows.Move(this, after);
537 listBox.CheckConsistency();
540 listBox.HideEditBox(true, false, true);
543 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
544 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
545 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
547 int line = listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0;
548 //SNAPUP(line, listBox.rowHeight);
549 listBox.SetScrollPosition(listBox.scroll.x, line);
552 listBox.OnVScroll(0, listBox.scroll.y, 0);
554 listBox.modifiedDocument = true;
556 listBox.Update(null);
563 any_object GetData(DataField field)
567 ListBoxCell cell = listBox.GetCell(&this, &field);
568 if(cell && cell.isSet && cell.data)
570 if((field.dataType.type == normalClass || field.dataType.type == noHeadClass))
573 return (void *)cell.data; // Cast for MemoryGuard
579 void * SetData(DataField field, any_object newData)
583 ListBoxCell cell = listBox.GetCell(&this, &field);
586 Class dataType = field.dataType;
590 if(dataType.type == normalClass || dataType.type == noHeadClass)
592 if(cell.data[0] && field.freeData)
593 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
595 if(eClass_IsDerived(dataType, class(char *)) && field.freeData)
596 dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
598 cell.data[0] = (void *)newData;
602 // Free old data first
603 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
604 dataType._vTbl[__ecereVMethodID_class_OnCopy](dataType, cell.data, newData);
608 listBox.modifiedDocument = true;
609 listBox.Update(null);
610 if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
611 return (void *)cell.data; // Cast for MemoryGuard
619 void UnsetData(DataField field)
623 ListBoxCell cell = listBox.GetCell(&this, &field);
626 Class dataType = field.dataType;
630 if(dataType.type == normalClass || dataType.type == noHeadClass)
632 if(cell.data[0] && field.freeData)
633 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data[0]);
638 // Free old data first
639 dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, cell.data);
643 listBox.Update(null);
648 DataRow FindRow(int tag)
651 for(row = subRows.first; row; row = row.next)
653 if(!row.noneRow && row.tag == tag)
659 DataRow FindSubRow(int tag)
662 for(row = subRows.first; row; row = row.next)
664 if(!row.noneRow && row.tag == tag)
666 if(row.subRows.first)
668 DataRow subRow = row.FindSubRow(tag);
676 DataRow AddRowAfter(DataRow after)
686 subRows.Insert(after, row);
687 row.listBox = listBox;
691 for(c = 0; c<listBox.fields.count; c++)
693 for(field = listBox.fields.first; field; field = field.next)
694 if((int)field.index == c)
698 int size = (field.dataType && field.dataType.typeSize) ?
699 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
700 ListBoxCell cell = (ListBoxCell)new0 byte[size];
702 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
711 if(after && after.subRows.first && !after.collapsed)
713 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
714 search = search.subRows.last;
715 row.index = search.index + 1;
718 row.index = after ? (after.index + 1) : (index + 1);
722 for(search = row.GetNextRow(); search; search = search.GetNextRow())
725 listBox.SetScrollArea(
727 (listBox.rowCount * listBox.rowHeight) +
728 ((listBox.style.header) ? listBox.rowHeight : 0) -
729 ((!((listBox.clientSize.h+1) % listBox.rowHeight)) ? listBox.rowHeight : 0), true);
730 if(listBox.style.autoScroll)
731 listBox.SetScrollPosition(0, MAXINT - listBox.rowHeight);
734 listBox.modifiedDocument = true;
737 listBox.CheckConsistency();
747 return AddRowAfter(subRows.last);
751 DataRow AddStringf(char * format, ...)
756 char string[MAX_F_STRING];
759 va_start(args, format);
760 vsprintf(string, format, args);
764 row.SetData(null, string);
770 DataRow AddString(char * string)
776 row.SetData(listBox.fields.first, string);
786 subRows.offset = (uint)&((DataRow)0).prev;
791 ListBoxCell cell, next;
796 while((subRow = subRows.first))
798 subRows.Remove(subRow);
802 for(cell = cells.first; cell; cell = next, cellIndex++)
807 for(field = listBox.fields.first; field && field.index != cellIndex; field = field.next);
810 // TOCHECK: Is this check good? Will need incref/decref sometime?
811 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
813 if(cell.data[0] && field.freeData)
814 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
817 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
827 return !this || (!collapsed && (!parent || parent.IsExpanded()));
830 int Compare(DataRow b, DataField sortField)
833 ListBoxCell cell1, cell2;
835 for(index = 0, cell1 = cells.first, cell2 = b.cells.first;
836 index != sortField.index;
837 index++, cell1 = cell1.next, cell2 = cell2.next);
839 if(!cell1.isSet && !cell2.isSet)
841 else if(!cell1.isSet)
843 else if(!cell2.isSet)
846 if(noneRow && !b.noneRow) return -1;
847 else if(!noneRow && b.noneRow) return 1;
848 else if(noneRow && b.noneRow) return 0;
850 if(sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare])
852 if(sortField.dataType.type == normalClass || sortField.dataType.type == noHeadClass)
854 result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
855 (cell1.isSet && cell1.data) ? cell1.data[0] : null,
856 (cell2.isSet && cell2.data) ? cell2.data[0] : null);
860 result = sortField.dataType._vTbl[__ecereVMethodID_class_OnCompare](sortField.dataType,
861 cell1.isSet ? cell1.data : null,
862 cell2.isSet ? cell2.data : null);
865 return sortField.sortOrder * result;
868 void _SortSubRows(DataField field, int order)
871 for(search = subRows.first; search; search = search.next)
872 search._SortSubRows(field, order);
873 subRows.Sort(Compare, field);
876 public void SortSubRows(bool scrollToCurrent)
878 if(this && listBox && listBox.sortField)
880 _SortSubRows(listBox.sortField, listBox.sortField.sortOrder);
884 int index = this.index;
885 for(search = this; search; search = search.GetNextRow())
886 search.index = index++;
890 int headerSize = ((listBox.style.header) ? listBox.rowHeight : 0);
891 int height = listBox.clientSize.h + 1 - headerSize;
892 if(listBox.currentRow && listBox.currentRow.index * listBox.rowHeight > listBox.scroll.y + height - listBox.rowHeight)
893 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow.index * listBox.rowHeight - height + listBox.rowHeight);
894 else if(!listBox.currentRow || listBox.currentRow.index * listBox.rowHeight < listBox.scroll.y)
895 listBox.SetScrollPosition(listBox.scroll.x, listBox.currentRow ? listBox.currentRow.index * listBox.rowHeight : 0);
896 listBox.OnVScroll(0, listBox.scroll.y, 0);
901 public DataRow GetPrevRow()
907 for(row = prev; row && !row.collapsed && row.subRows.last; row = row.subRows.last);
914 public DataRow GetNextRow()
918 if(subRows.first && !collapsed)
922 for(row = this; row; row = row.parent)
924 if(row.next) { row = row.next; break; }
930 private DataRow GetLastRow()
933 while(row && !row.collapsed && row.subRows.last)
934 row = row.subRows.last;
941 SelectedFlag selectedFlag;
952 public class ListBox : CommonControl
954 hasVertScroll = true;
955 // background = white;
957 snapVertScroll = true;
959 class_property(icon) = "<:ecere>controls/listBox.png";
963 property bool freeSelect { property_category $"Behavior" set { style.freeSelect = value; } get { return style.freeSelect; } };
964 property DataRow currentRow { property_category $"Private" /*"Behavior"*/ set { SetCurrentRow(value, false); } get { return currentRow; } };
965 property DataField currentField
967 get { return currentField; }
968 // TODO: Document what this does
971 currentField = value;
972 HideEditBox(true, true, false);
973 if(value && value.editable)
974 PopupEditBox(currentField, false);
978 property int rowHeight
980 property_category $"Appearance"
981 isset { return style.heightSet; }
986 style.heightSet = true;
988 SetScrollLineStep(8, value);
992 style.heightSet = false;
997 get { return rowHeight; }
999 property Seconds typingTimeout
1001 property_category $"Behavior"
1004 typedString[0] = '\0';
1005 typingTimer.delay = value;
1006 typingTimeOut = value;
1008 get { return typingTimeOut; }
1010 property bool moveRows { property_category $"Behavior" set { style.moveRows = value; } get { return style.moveRows; } };
1011 property bool moveFields { property_category $"Behavior" set { style.moveFields = value; } get { return style.moveFields; } };
1012 property bool resizable { property_category $"Behavior" set { style.resizable = value; } get { return style.resizable; } };
1013 property bool autoScroll { property_category $"Behavior" set { style.autoScroll = value; } get { return style.autoScroll; } };
1014 property bool alwaysHighLight { property_category $"Appearance" set { style.alwaysHL = value; } get { return style.alwaysHL; } };
1015 property bool hasClearHeader { property_category $"Appearance" set { style.clearHeader = value; if(value) property::hasHeader = true; } get { return style.clearHeader; } };
1016 property bool hasHeader
1018 property_category $"Appearance"
1021 if(value && !style.header)
1027 bevel = !guiApp.textMode && !style.clearHeader;
1028 dontScrollVert = true;
1031 NotifyPushed = HeaderPushed;
1032 NotifyClicked = HeaderClicked;
1033 NotifyDoubleClick = HeaderDoubleClicked;
1034 NotifyReleased = HeaderReleased;
1035 NotifyMouseMove = HeaderMouseMove;
1039 endBevel.visible = false;
1041 style.header = value;
1043 get { return style.header; }
1045 property bool multiSelect { property_category $"Behavior" set { style.multiSelect = value; } get { return style.multiSelect; } };
1046 property bool alwaysEdit { property_category $"Behavior" set { style.alwaysEdit = value; } get { return style.alwaysEdit; } };
1047 property bool fullRowSelect { property_category $"Appearance" set { style.fullRowSelect = value; } get { return style.fullRowSelect; } };
1048 property bool collapseControl { property_category $"Appearance" set { style.collapse = value; } get { return style.collapse; } };
1049 property bool treeBranches { property_category $"Appearance" set { style.treeBranch = value; } get { return style.treeBranch; } };
1050 property bool rootCollapseButton { property_category $"Appearance" set { style.rootCollapse = value; } get { return style.rootCollapse; } };
1051 property bool sortable { property_category $"Behavior" set { style.sortable = value; } get { return style.sortable; } };
1052 property bool noDragging { property_category $"Behavior" set { style.noDragging = value; } get { return style.noDragging; } };
1053 property bool fillLastField
1055 property_category $"Behavior"
1058 style.fillLastField = value;
1060 get { return style.fillLastField; }
1062 property int numSelections
1066 int numSelections = 0;
1067 if(this && style.multiSelect)
1070 for(row = rows.first; row; row = row.GetNextRow())
1071 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1074 return numSelections;
1077 property int currentIndex
1079 get { return currentRow ? currentRow.index : -1; }
1081 property DataRow lastRow { get { return this ? rows.last : null; } };
1082 property DataRow firstRow { get { return this ? rows.first : null; } };
1083 property int rowCount { get { return rowCount; } };
1084 property DataField firstField { get { return this ? fields.first : null; } };
1085 property Color selectionColor { set { selectionColor = value; } get { return selectionColor; } isset { return selectionColor ? true : false; } };
1086 property Color selectionText { set { selectionText = value; } get { return selectionText; } isset { return selectionText ? true : false; } };
1087 property Color stippleColor { set { stippleColor = value; } get { return stippleColor; } };
1088 property bool expandOnAdd { set { style.expandOnAdd = value; } get { return style.expandOnAdd; } };
1091 virtual bool Window::NotifySelect(ListBox listBox, DataRow row, Modifiers mods);
1092 virtual bool Window::NotifyHighlight(ListBox listBox, DataRow row, Modifiers mods);
1093 virtual bool Window::NotifyReclick(ListBox listBox, DataRow row, Modifiers mods);
1094 virtual bool Window::NotifySort(ListBox listBox, DataField field, Modifiers mods);
1095 virtual bool Window::NotifyChanged(ListBox listBox, DataRow row);
1096 virtual bool Window::NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch);
1097 virtual bool Window::NotifyEdited(ListBox listBox, DataRow row);
1098 virtual bool Window::NotifyEditDone(ListBox listBox, DataRow row);
1099 virtual bool Window::NotifyMovedField(ListBox listBox, DataField field, Modifiers mods);
1100 virtual bool Window::NotifyMove(ListBox listBox, DataRow row, Modifiers mods);
1101 virtual bool Window::NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods);
1102 virtual bool Window::NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods);
1103 virtual bool Window::NotifyResized(ListBox listBox, DataField field, Modifiers mods);
1104 virtual bool Window::NotifyCollapse(ListBox listBox, DataRow row, bool collapsed);
1105 virtual bool Window::NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch);
1106 virtual bool Window::NotifyModified(ListBox listBox, DataRow row);
1107 virtual bool Window::NotifyEditing(ListBox listBox, DataRow row);
1110 private void CheckConsistency()
1115 for(r = rows.first; r; r = r.GetNextRow())
1117 if(r.index != index++)
1125 void AddField(DataField addedField)
1130 if(fields.first && ((DataField)fields.first).defaultField)
1132 DataField defaultField = fields.first;
1133 defaultField.Free();
1134 delete defaultField;
1138 addedField = DataField { };
1142 addedField.listBox = this;
1143 fields.Add(addedField);
1145 addedField.sortOrder = 1;
1146 addedField.index = numFields;
1150 addedField.headButton.Destroy(0);
1151 delete addedField.headButton;
1152 addedField.headButton = Button
1157 dontScrollVert = true;
1158 id = (uint)addedField;
1159 text = addedField.header;
1160 bevel = (!guiApp.textMode && !style.clearHeader);
1162 alignment = addedField.alignment;
1163 NotifyPushed = HeaderPushed;
1164 NotifyClicked = HeaderClicked;
1165 NotifyDoubleClick = HeaderDoubleClicked;
1166 NotifyReleased = HeaderReleased;
1167 NotifyMouseMove = HeaderMouseMove;
1169 incref addedField.headButton;
1170 addedField.headButton.Create();
1173 addedField.headButton.background = Color { 0, 170, 0 };
1179 for(row = rows.first; row; )
1181 int size = (field.dataType && field.dataType.typeSize) ?
1182 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1183 ListBoxCell cell = (ListBoxCell)new0 byte[size];
1184 row.cells.Add(cell);
1185 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1188 if(row.subRows.first)
1189 row = row.subRows.first;
1192 for(; row; row = row.parent)
1194 if(row.next) { row = row.next; break; }
1199 OnResize(clientSize.w, clientSize.h);
1208 while((field = fields.first))
1214 endBevel.visible = false;
1219 void RemoveField(DataField field)
1225 int index = field.index;
1228 for(row = rows.first; row; )
1233 for(cell = row.cells.first, c = 0; c < index && cell; c++, cell = cell.next);
1234 if(cell && index == c)
1238 // TOCHECK: Is this check good? Will need incref/decref sometime?
1239 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
1241 if(cell.data[0] && field.freeData)
1242 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
1245 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
1248 row.cells.Remove(cell);
1252 if(row.subRows.first)
1253 row = row.subRows.first;
1256 for(; row; row = row.parent)
1258 if(row.next) { row = row.next; break; }
1267 endBevel.visible = false;
1271 DataRow AddRowNone()
1273 DataRow row { noneRow = true };
1282 rows.Insert(null, row);
1285 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1291 firstRowShown = row;
1295 (rowCount * rowHeight) +
1296 ((style.header) ? rowHeight : 0) -
1297 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1298 if(style.autoScroll)
1299 SetScrollPosition(0, MAXINT - rowHeight);
1300 modifiedDocument = true;
1319 // Find very last row
1322 for(lastRow = rows.last; lastRow && !lastRow.collapsed && lastRow.subRows.last; lastRow)
1323 lastRow = lastRow.subRows.last;
1324 row.index = lastRow ? (lastRow.index + 1) : 0;
1332 for(c = 0; c<fields.count; c++)
1334 for(field = fields.first; field; field = field.next)
1335 if((int)field.index == c)
1339 int size = (field.dataType && field.dataType.typeSize) ?
1340 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1341 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1342 row.cells.Add(cell);
1343 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1350 firstRowShown = row;
1356 (rowCount * rowHeight) +
1357 ((style.header) ? rowHeight : 0) -
1358 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1359 if(style.autoScroll)
1360 SetScrollPosition(0, MAXINT - rowHeight);
1361 modifiedDocument = true;
1372 DataRow AddRowAfter(DataRow after)
1384 if(after && after.subRows.first && !after.collapsed)
1386 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
1387 search = search.subRows.last;
1388 row.index = search.index + 1;
1391 row.index = after ? (after.index + 1) : 0;
1392 rows.Insert(after, row);
1395 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1400 for(c = 0; c<fields.count; c++)
1402 for(field = fields.first; field; field = field.next)
1403 if((int)field.index == c)
1407 int size = (field.dataType && field.dataType.typeSize) ?
1408 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1409 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1410 row.cells.Add(cell);
1411 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1415 if(!firstRowShown || !after)
1417 firstRowShown = row;
1422 (rowCount * rowHeight) +
1423 ((style.header) ? rowHeight : 0) -
1424 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1425 if(style.autoScroll)
1426 SetScrollPosition(0, MAXINT - rowHeight);
1427 modifiedDocument = true;
1437 DataRow AddStringf(char * format, ...)
1443 char string[MAX_F_STRING];
1446 va_start(args, format);
1447 vsprintf(string, format ? format : "", args);
1451 row.SetData(fields.first, string);
1457 DataRow AddString(char * string)
1463 row.SetData(fields.first, string);
1469 void SelectRow(DataRow row)
1471 SetCurrentRow(row, true);
1474 void DeleteRow(DataRow row)
1476 if(!row) row = currentRow;
1479 DataRow sub, next, search;
1480 // Trying to move this here (Messed up deleting watches)
1481 //HideEditBox(false, false, true);
1484 for(sub = row.subRows.first; sub; sub = next)
1490 if(row.parent.IsExpanded())
1492 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1497 HideEditBox(false, false, true);
1499 if(row == clickedRow)
1501 clickedRow = row.GetNextRow();
1503 clickedRow = row.GetPrevRow();
1506 if(row == currentRow)
1508 DataRow newCurrentRow = row.GetNextRow();
1510 newCurrentRow = row.GetPrevRow();
1511 SetCurrentRow(newCurrentRow, true);
1514 if(row == firstRowShown)
1516 firstRowShown = row.GetPrevRow();
1518 firstRowShown = row.GetNextRow();
1521 (row.parent ? row.parent.subRows: rows).Remove(row);
1524 //HideEditBox(false, false, true);
1528 (this.rowCount * rowHeight) +
1529 ((style.header) ? rowHeight : 0) -
1530 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1532 modifiedDocument = true;
1541 DataRow FindRow(int tag)
1546 for(row = rows.first; row; row = row.next)
1548 if(!row.noneRow && row.tag == tag)
1556 DataRow FindString(char * searchedString)
1559 bool checkNextField = true;
1560 int len = searchedString ? strlen(searchedString) : 0;
1562 for(field = fields.first; field; field = field.next)
1564 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1567 for(row = rows.first; row; row = row.GetNextRow())
1571 void * data = row.GetData(field);
1572 char tempString[1024] = "";
1573 bool needClass = false;
1574 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1576 if(string && string[0])
1577 checkNextField = false;
1578 if(string && string[0] && !strcmp(string, searchedString))
1583 if(!checkNextField) break;
1588 DataRow FindSubString(char * subString)
1591 bool checkNextField = true;
1592 int len = subString ? strlen(subString) : 0;
1596 for(field = fields.first; field; field = field.next)
1598 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1601 for(row = rows.first; row; row = row.GetNextRow())
1605 void * data = row.GetData(field);
1606 char tempString[1024] = "";
1607 bool needClass = false;
1608 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1610 if(string && string[0])
1611 checkNextField = false;
1612 if(string && string[0] && !strncmp(string, subString, len))
1617 if(!checkNextField) break;
1623 DataRow FindSubStringi(char * subString)
1626 bool checkNextField = true;
1627 int len = subString ? strlen(subString) : 0;
1628 DataRow result = null;
1629 char * bestResult = null;
1634 for(field = fields.first; field; field = field.next)
1636 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1639 for(row = rows.first; row; row = row.GetNextRow())
1643 void * data = row.GetData(field);
1644 char tempString[1024] = "";
1645 bool needClass = false;
1646 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1648 if(string && string[0])
1649 checkNextField = false;
1650 if(string && string[0])
1652 int stringLen = strlen(string);
1654 if(!strnicmp(string, subString, Min(len, stringLen)))
1656 if(bestLen < Min(len, stringLen))
1658 if(!bestResult || strcmpi(string, bestResult) < 0)
1660 bestLen = Min(len, stringLen);
1661 bestResult = string;
1669 if(!checkNextField) break;
1675 DataRow FindSubStringAfter(DataRow after, char * subString)
1678 bool checkNextField = true;
1679 int len = subString ? strlen(subString) : 0;
1683 for(field = fields.first; field; field = field.next)
1685 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1688 for(row = after.GetNextRow(); row && row != after; row = row.GetNextRow(), (!row) ? (row = rows.first) : null)
1692 void * data = row.GetData(field);
1693 char tempString[1024] = "";
1694 bool needClass = false;
1695 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1697 if(string && string[0])
1698 checkNextField = false;
1699 if(string && string[0] && !strncmp(string, subString, len))
1704 if(!checkNextField) break;
1710 DataRow FindSubRow(int tag)
1716 for(row = rows.first; row; row = row.next)
1718 if(!row.noneRow && row.tag == tag)
1720 if(!row.noneRow && row.subRows.first)
1722 DataRow subRow = row.FindSubRow(tag);
1736 Window master = this.master;
1738 HideEditBox(false, true, false);
1739 editData.Destroy(0);
1741 firstRowShown = currentRow = null;
1746 if(style.freeSelect)
1747 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
1749 NotifySelect(master, this, currentRow ? currentRow : null, 0);
1752 if(style.alwaysEdit && currentRow)
1753 currentRow.Edit(currentField);
1760 (this.rowCount * rowHeight) +
1761 ((style.header) ? rowHeight : 0) -
1762 ((rowHeight && !((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1767 void Sort(DataField field, int order)
1772 int headerSize = ((style.header) ? rowHeight : 0);
1773 int height = clientSize.h + 1 - headerSize;
1775 if(!field) field = fields.first;
1777 field.sortOrder = order ? order : 1;
1778 rows.Sort(DataRow::Compare, field);
1780 for(search = rows.first; search; search = search.next)
1781 search._SortSubRows(field, order);
1785 for(search = rows.first; search; search = search.GetNextRow())
1786 search.index = index++;
1789 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1790 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
1791 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1792 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
1794 OnVScroll(0, scroll.y, 0);
1796 // SetScrollPosition(0, scroll.y);
1801 void StopEditing(bool save)
1803 HideEditBox(save, false, true);
1806 void GetMultiSelection(OldList list)
1809 if(this && style.multiSelect)
1813 for(row = rows.first; row; row = row.GetNextRow())
1815 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1817 list.Add(OldLink { data = row });
1823 // Convenience Current Row Methods
1824 void * SetData(DataField field, any_object data)
1826 return currentRow.SetData(field, data);
1829 any_object GetData(DataField field)
1831 return (void *)currentRow.GetData(field);
1836 return currentRow ? currentRow.tag : 0;
1842 DataField defaultField { };
1843 rows.offset = (uint)&((DataRow)0).prev;
1844 fields.offset = (uint)&((DataField)0).prev;
1845 style.fullRowSelect = true;
1846 style.fillLastField = true;
1847 style.expandOnAdd = true;
1848 typingTimeOut = 0.5;
1849 rowHeight = 16; // Stuff depending on creation and default property checking
1852 defaultField.defaultField = true;
1854 AddField(defaultField);
1856 typedString = new char[1];
1857 typedString[0] = '\0';
1872 while((field = fields.first))
1874 // fields.Remove(field);
1884 while((row = rows.first))
1891 ListBoxCell GetCell(DataRow * row, DataField * field)
1893 ListBoxCell cell = null;
1894 if(!*row) *row = currentRow;
1897 if(!*field) *field = this ? currentField : null;
1900 for(*field = fields.first; (*field).index != 0; *field = (*field).next);
1905 if(field->listBox == this)
1907 for(index = 0, cell = (*row).cells.first; cell && index != (*field).index; index++, cell = cell.next);
1914 void HideEditBox(bool save, bool alwaysStopEdit, bool repositionOnly)
1916 if(editData && editData.visible)
1918 Class dataType = currentField.dataType;
1920 editData.SaveData();
1922 editData.visible = false;
1923 NotifyEditDone(master, this, currentRow);
1925 // ENSURE DATA BOX IS NOT VISIBLE
1926 editData.visible = false;
1928 if(style.alwaysEdit && !alwaysStopEdit)
1931 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
1932 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
1933 int x = currentField.x;
1934 int width = (!currentField.next && style.fillLastField && (!hasHorzScroll || clientSize.w - currentField.x > currentField.width + EXTRA_SPACE)) ?
1935 clientSize.w - currentField.x : (currentField.width + EXTRA_SPACE);
1937 if(!style.alwaysEdit)
1939 editData.position = { x, y };
1940 editData.size = { width, height };
1944 editData.position = { x, y - editData.clientStart.y };
1945 editData.size = { width, height + editData.clientStart.y * 2 };
1947 editData.visible = true;
1948 if(style.alwaysEdit)
1949 editData.Deactivate();
1951 PopupEditBox(currentField, repositionOnly);
1957 currentField = null;*/
1961 void SetCurrentRow(DataRow row, bool notify)
1963 if(currentRow != row || (currentRow && currentRow.selectedFlag == unselected))
1965 int headerSize = ((style.header) ? rowHeight : 0);
1966 int height = clientSize.h + 1 - headerSize;
1968 // true: destroy edit box
1969 HideEditBox(true, true, false);
1971 if(!(style.multiSelect) && currentRow)
1972 currentRow.selectedFlag = unselected;
1976 if(style.multiSelect)
1980 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
1981 selRow.selectedFlag = unselected;
1983 currentRow.selectedFlag = selected;
1988 currentRow.selectedFlag = selected;
1990 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1991 SetScrollPosition(scroll.x,
1992 currentRow.index * rowHeight - height + rowHeight);
1993 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1995 int line = currentRow ? currentRow.index * rowHeight : 0;
1996 //SNAPUP(line, rowHeight);
1997 SetScrollPosition(scroll.x, line);
2002 Window master = this.master;
2005 if(style.freeSelect && visible)
2006 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
2008 NotifySelect(master, this, currentRow ? currentRow : null, 0);
2009 if(style.alwaysEdit && currentRow)
2010 currentRow.Edit(currentField);
2018 void PopupEditBox(DataField whichField, bool repositionOnly)
2020 if((!editData || !editData.visible || currentField != whichField) && currentRow)
2022 // true: destroy edit box
2023 HideEditBox(true, true, false);
2026 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
2028 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
2030 //void * data = currentRow.GetData(whichField);
2035 if(style.collapse && !(style.treeBranch))
2038 for(field = fields.first; field; field = field.next)
2040 width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2041 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2042 if(field == whichField) break;
2046 currentField = whichField;
2047 cell = GetCell(&row, ¤tField);
2054 background = dataBoxBackground;
2055 foreground = dataBoxForeground;
2057 bool NotifyChanged(bool closingDropDown)
2060 DataField field = null;
2061 ListBoxCell cell = GetCell(&row, &field);
2065 modifiedDocument = true;
2067 NotifyChanged(master, this, currentRow);
2072 bool NotifyModified()
2074 //DataRow row = null;
2075 //DataField field = null;
2076 //ListBoxCell cell = GetCell(&row, &field);
2077 //cell.isSet = true;
2078 modifiedDocument = true;
2080 NotifyModified(master, this, currentRow);
2084 bool OnKeyDown(Key key, unichar ch)
2086 bool result = DataBox::OnKeyDown(key, ch);
2087 if(visible && active) // Added this check here, because we will not use enter/escape otherwise, and lose DataBox's result
2089 if((SmartKey)key == enter || (SmartKey)key == escape)
2098 editData.Destroy(0);
2099 editData.type = whichField.dataType;
2100 editData.fieldData = whichField.userData;
2101 editData.borderStyle = style.alwaysEdit ? 0 : deep;
2102 editData.data = cell ? cell.data : null;
2105 // Might not really need this anymore...
2106 NotifyEditing(master, this, currentRow);
2109 if(!style.alwaysEdit)
2111 editData.position = { x, y - editData.clientStart.y };
2112 editData.size = { width, height + editData.clientStart.y * 2 };
2116 editData.position = { x, y };
2117 editData.size = { width, height };
2121 editData.visible = true;
2123 if(style.alwaysEdit)
2124 editData.Deactivate();
2126 // MOVED THIS HIGHER FOR DATALIST EDITOR
2128 // Might not really need this anymore...
2129 NotifyEdited(master, this, currentRow);
2134 void OnRedraw(Surface surface)
2137 int y = (style.header) ? rowHeight : 0;
2138 bool isActive = active;
2139 Font font = fontObject;
2140 Font boldFont = this.boldFont.font;
2144 if(style.alwaysEdit && style.fullRowSelect)
2147 int y = (style.header) ? rowHeight : 0;
2148 int x = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
2149 int w = clientSize.w;
2150 int h = clientSize.h;
2154 // Fill out indent column
2155 if(style.collapse && !(style.treeBranch) && rows.first)
2158 surface.SetBackground(formColor);
2159 surface.Area(-scroll.x, 0, x, clientSize.h);
2162 surface.SetForeground(formColor);
2163 for(row = firstRowShown; row; row = row.GetNextRow())
2166 surface.HLine(x + 1, w-1, y-1);
2172 for(field = fields.first; field; field = field.next)
2174 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2175 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2176 if(field.prev && y > 0)
2177 surface.VLine(0, y-1, x);
2182 surface.foreground = this.foreground;
2183 surface.TextOpacity(false);
2185 // Draw the tree branches
2186 if(style.treeBranch)
2188 int y = -scroll.y + ((style.header) ? rowHeight : 0);
2189 surface.LineStipple(0x5555);
2190 surface.SetForeground(branchesColor);
2191 for(row = rows.first; row; row = row.GetNextRow() )
2193 int x = -scroll.x + EXTRA_SPACE / 2-1;
2194 int rowStart = -scroll.x;
2199 for(parent = row.parent; parent; parent = parent.parent)
2200 if(!parent.header) indent += 20;
2201 if(style.rootCollapse) indent += 20;
2203 plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2208 if(row.subRows.first)
2211 int y1 = y + PLUSY + 4;
2215 for(child = row.collapsed ? null : row.subRows.first; child && child != row; )
2218 if(child.subRows.first && !child.collapsed && child != row.subRows.last)
2219 child = child.subRows.first;
2224 for(; child && child != row; child = child.parent)
2234 y2 = y + numRows * rowHeight + PLUSY + 4;
2235 surface.VLine(y1, y2, rowStart + plusIndent + 7 + 20);
2237 surface.HLine(rowStart + plusIndent + 7, rowStart + indent, y + PLUSY + 4);
2240 if(y >= clientSize.h)
2243 // Root Vertical Lines
2244 if(style.rootCollapse && rows.first)
2249 y = -scroll.y + ((style.header) ? rowHeight : 0);
2251 for(child = rows.first; child && child != rows.last; )
2254 if(child.subRows.first && !child.collapsed && child != rows.last)
2255 child = child.subRows.first;
2260 for(; child; child = child.parent)
2270 y2 = y + numRows * rowHeight + PLUSY + 4;
2271 surface.VLine(y1, y2, -scroll.x + 11);
2273 surface.LineStipple(0);
2276 for(row = firstRowShown; row; row = row.GetNextRow() )
2278 int x = -scroll.x + EXTRA_SPACE / 2-1;
2281 Color foreground = this.foreground /*black*/, background = this.background /*white*/;
2282 DataDisplayFlags dataDisplayFlags = 0;
2283 int rowStart = -scroll.x;
2286 Bitmap icon = row.icon ? row.icon.bitmap : null;
2287 int collapseRowStart;
2289 for(parent = row.parent; parent; parent = parent.parent)
2293 if(style.treeBranch)
2299 if(style.rootCollapse) indent += 20;
2302 dataDisplayFlags.fullRow = style.fullRowSelect;
2303 dataDisplayFlags.active = isActive;
2304 dataDisplayFlags.header = row.header;
2309 collapseRowStart = rowStart;
2311 if(!(style.treeBranch))
2318 if(style.multiSelect)
2320 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2321 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2325 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2326 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2328 if(row == currentRow)
2330 dataDisplayFlags.current = true;
2331 dataDisplayFlags.selectedFlag = true;
2333 else if(!currentRow && row == firstRowShown)
2335 dataDisplayFlags.current = true;
2339 surface.TextOpacity(true);
2341 background = this.background;
2342 foreground = this.foreground;
2344 // Draw the current row background
2347 background = formColor;
2348 surface.SetBackground(formColor);
2349 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
2350 foreground = branchesColor;
2352 else if(dataDisplayFlags.selected)
2354 if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
2356 if(!isActive && style.alwaysEdit)
2357 background = formColor;
2359 background = selectionColor ? selectionColor : SELECTION_COLOR;
2360 if(style.fullRowSelect)
2362 int offset = (style.alwaysEdit) ? 2 : 1;
2363 surface.SetBackground(background);
2364 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - offset);
2366 if(isActive || !(style.alwaysEdit))
2367 foreground = selectionText ? selectionText : SELECTION_TEXT;
2369 foreground = branchesColor;
2375 surface.Blit(icon, x + (20 - icon.width) /2,y + 2,0,0, icon.width, icon.height);
2381 int width = clientSize.w;
2383 dataDisplayFlags.firstField = true;
2384 clip.left = x - EXTRA_SPACE / 2+1;
2386 clip.right = x + width - EXTRA_SPACE/2 - 0;
2387 clip.bottom = y + rowHeight - 1;
2388 surface.Clip(&clip);
2390 surface.TextFont(font);
2392 surface.SetForeground(foreground);
2393 surface.SetBackground(background);
2395 class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
2399 if(!opacity) surface.TextOpacity(false);
2401 for(field = fields.first; field; field = field.next)
2404 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2405 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2407 // Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
2410 //width -= EXTRA_SPACE;
2412 if(!field.prev) width -= indent;
2415 dataDisplayFlags.firstField = field.prev ? false : true;
2417 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2419 background = this.background;
2420 foreground = this.foreground;
2423 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
2426 surface.SetBackground(background);
2427 surface.Area(x-3, y, x+width-1, y + rowHeight-2);
2430 clip.left = x - EXTRA_SPACE / 2+1;
2432 clip.right = x + width - EXTRA_SPACE/2 - 0;
2433 clip.bottom = y + rowHeight - 1;
2434 surface.Clip(&clip);
2436 for(index = 0, cell = row.cells.first; cell && index != field.index; index++, cell = cell.next);
2437 // Should always be as many cells in the row as fields in the listbox
2438 if(cell && cell.isSet && field.dataType)
2441 surface.TextFont(boldFont);
2443 surface.TextFont(font);
2445 surface.SetForeground(foreground);
2446 surface.SetBackground(background);
2448 if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
2449 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);
2451 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);
2454 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
2455 background = formColor;
2457 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2459 background = formColor;
2460 foreground = this.background;
2463 x += width;// + EXTRA_SPACE;
2465 if(row.header) break;
2471 int plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2473 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)))
2475 surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
2476 surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
2478 surface.SetBackground(row.header ? (formColor) : (this.background)); //white
2479 surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
2481 surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
2483 surface.VLine(y + PLUSY + 2, y + PLUSY + 6, collapseRowStart + 7 + plusIndent);
2488 // Draw the current row stipple
2489 if(style.fullRowSelect && !(style.alwaysEdit) && (dataDisplayFlags.current) && isActive)
2494 surface.LineStipple(0x5555);
2495 if(dataDisplayFlags.selected)
2496 surface.SetForeground(stippleColor);
2498 surface.SetForeground(this.foreground);
2501 surface.SetForeground(selectionColor ? selectionColor : SELECTION_COLOR);
2502 surface.Rectangle(0, y, clientSize.w-1, (y + rowHeight) - 1);
2503 surface.LineStipple(0);
2507 if(y >= clientSize.h)
2510 if(firstRowShown) surface.Clip(null);
2511 if(this.dragRow && this.dropIndex != -1)
2513 int dropIndex = this.dropIndex;
2516 if(!style.multiSelect && currentRow.index < this.dropIndex)
2518 surface.DrawingChar(223);
2520 y = style.header ? rowHeight : 0;
2521 y += dropIndex * rowHeight - scroll.y;
2523 surface.SetForeground(Color { 85, 85, 255 });
2524 surface.HLine(0, clientSize.w-1, y);
2525 surface.HLine(0, clientSize.w-1, y + 1);
2529 void OnDrawOverChildren(Surface surface)
2531 if(draggingField && this.dropField)
2533 int position = this.dropField.x;
2534 if(draggingField.x < position)
2535 position += this.dropField.width + EXTRA_SPACE;
2537 surface.SetForeground(Color { 85, 85, 255 });
2538 surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
2539 surface.VLine(0, rowHeight - 1, position - scroll.x);
2541 if(sortField && !style.clearHeader && style.header)
2543 DataField field = sortField;
2544 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2545 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2548 surface.TextExtent(field.header, strlen(field.header), &tw, &th);
2549 if(tw < width - EXTRA_SPACE)
2551 bool up = field.sortOrder == 1;
2555 field.x + 2 - scroll.x, 0,
2556 field.x + width + EXTRA_SPACE - 1 - scroll.x, rowHeight
2558 surface.Clip(&clip);
2559 if(field.alignment == left || field.alignment == center)
2561 if(field.alignment == center)
2562 x = field.x + (width + EXTRA_SPACE - tw) / 2 + tw + EXTRA_SPACE + 4;
2564 x = field.x + tw + EXTRA_SPACE + 4;
2566 x = Min(x, field.x + width - 4);
2568 else if(field.alignment == right)
2570 x = field.x + width - tw - EXTRA_SPACE - 4;
2571 x = Max(x, field.x + 2);
2577 // surface.SetForeground((wmenu.selectedFlag == item) ? white : black);
2578 // surface.WriteText(clientSize.w-8, y+(wmenu.rh - 8)/2, "\020", 1);
2584 surface.SetForeground(Color { 128,128,128 } );
2585 surface.DrawLine(x + 3, y, x, y + 5);
2586 surface.PutPixel(x + 1, y + 5);
2587 surface.PutPixel(x + 1, y + 3);
2588 surface.PutPixel(x + 2, y + 1);
2590 surface.SetForeground(white);
2591 surface.DrawLine(x + 4, y, x + 7, y + 5);
2592 surface.PutPixel(x + 6, y + 5);
2593 surface.PutPixel(x + 6, y + 3);
2594 surface.PutPixel(x + 5, y + 1);
2596 surface.DrawLine(x, y + 6, x + 7, y + 6);
2600 surface.SetForeground(Color { 128,128,128 });
2601 surface.DrawLine(x + 3, y+6, x, y+1);
2602 surface.PutPixel(x + 1, y+1);
2603 surface.PutPixel(x + 1, y+3);
2604 surface.PutPixel(x + 2, y+5);
2606 surface.SetForeground(white);
2607 surface.DrawLine(x + 4, y+6, x + 7, y+1);
2608 surface.PutPixel(x + 6, y+1);
2609 surface.PutPixel(x + 6, y+3);
2610 surface.PutPixel(x + 5, y+5);
2612 surface.DrawLine(x, y, x + 7, y);
2621 void OnResize(int w, int h)
2624 bool showEndBevel = false;
2626 if(style.collapse && !style.treeBranch)
2628 for(field = fields.first; field; field = field.next)
2630 int width = field.width + EXTRA_SPACE;
2638 (rowCount * rowHeight) +
2639 ((style.header) ? rowHeight : 0) -
2640 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
2642 for(field = fields.first; field; field = field.next)
2644 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2645 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2646 if(style.header && field.headButton)
2648 showEndBevel = true;
2651 field.headButton.position = { field.x, 0 };
2652 field.headButton.size = { width, rowHeight };
2653 field.headButton.visible = true;
2656 field.headButton.visible = false;
2660 if(!style.fillLastField && showEndBevel && endBevel)
2662 endBevel.position = { x, 0 };
2663 endBevel.size = { clientSize.w + 2 - x, rowHeight };
2664 endBevel.visible = true;
2667 endBevel.visible = false;
2669 if(style.alwaysEdit && editData && editData.visible)
2671 HideEditBox(true, false, true);
2675 void AdaptToFieldWidth(DataField field, bool doScroll)
2677 OnResize(clientSize.w, clientSize.h);
2679 // Scroll appropriately
2682 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2683 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2685 SetScrollPosition(field.x + field.width + EXTRA_SPACE - clientSize.w, scroll.y);
2687 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2689 SetScrollPosition(field.x, scroll.y);
2694 bool HeaderPushed(Button control, int x, int y, Modifiers mods)
2696 DataField field = (DataField)control.id;
2697 // false: dont destroy edit box
2698 HideEditBox(true, false, true);
2699 if(style.resizable && ((!field && x < RESIZE_BORDER && fields.last) ||
2700 (field && x < RESIZE_BORDER && field.prev) ||
2701 (field && x >= control.clientSize.w - RESIZE_BORDER)))
2704 field = fields.last;
2705 else if(x < RESIZE_BORDER && field.prev)
2708 resizingField = field;
2709 this.resizeX = x + control.position.x;
2710 this.startWidth = field.width;
2711 this.oldX = x - scroll.x;
2716 draggingField = field;
2717 if(style.moveFields)
2718 field.headButton.stayDown = true;
2719 else if(!style.sortable)
2727 bool HeaderMouseMove(Button control, int x, int y, Modifiers mods)
2732 DataField field = resizingField;
2734 x += control.position.x;
2736 // Tweak to prevent shrinking field if we're actually moving right
2737 if(x - scroll.x > this.oldX &&
2738 this.startWidth + x - this.resizeX < field.width)
2740 this.oldX = x - scroll.x;
2743 this.oldX = x - scroll.x;
2745 field.width = this.startWidth + x - this.resizeX;
2746 field.width = Max(field.width, - EXTRA_SPACE);
2748 AdaptToFieldWidth(field, true);
2750 else if(draggingField)
2752 x += control.position.x;
2753 if(style.moveFields)
2755 DataField field = fields.last;
2757 for(field = fields.first; field; field = field.next)
2759 fieldX += ((field.width || style.resizable) ?
2760 field.width : clientSize.w) + EXTRA_SPACE;
2764 if(draggingField == field)
2766 // Reset scroll position
2767 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2768 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2771 field.x + field.width + EXTRA_SPACE - clientSize.w,
2774 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2776 SetScrollPosition(field.x, scroll.y);
2779 if(this.dropField != field)
2781 this.dropField = field;
2784 int position = field.x;
2786 if(draggingField.x < position)
2788 position += field.width + EXTRA_SPACE - clientSize.w;
2789 if(position > scroll.x)
2790 SetScrollPosition(position, scroll.y);
2795 if(position < scroll.x)
2796 SetScrollPosition(position, scroll.y);
2799 this.movingFields = true;
2805 else if(style.resizable)
2807 DataField field = (DataField)control.id;
2810 if(x < RESIZE_BORDER && field.prev)
2811 control.cursor = guiApp.GetCursor(sizeWE);
2812 else if(x >= control.clientSize.w - RESIZE_BORDER)
2813 control.cursor = guiApp.GetCursor(sizeWE);
2815 control.cursor = null;
2819 if(x < RESIZE_BORDER && fields.last)
2820 control.cursor = guiApp.GetCursor(sizeWE);
2822 control.cursor = null;
2828 bool HeaderReleased(Button control, int x, int y, Modifiers mods)
2832 NotifyResized(master, this, resizingField, mods);
2833 resizingField = null;
2840 if(style.moveFields)
2845 DataField switchField = fields.last;
2849 x += draggingField.x;
2850 for(field = fields.first; field; field = field.next)
2852 fieldX += ((field.width || style.resizable) ?
2853 field.width : clientSize.w) + EXTRA_SPACE;
2856 switchField = field;
2860 if(switchField && draggingField != switchField && this.dropField)
2862 for(field = fields.first; field; field = field.next)
2864 if(field == switchField || field == draggingField)
2868 // Switch field first: move before
2869 if(field == switchField)
2870 draggingField.Move(switchField.prev);
2871 // Dragged field first: move after
2873 draggingField.Move(switchField);
2875 NotifyMovedField(master, this, draggingField, mods);
2877 draggingField.headButton.stayDown = false;
2882 movingFields = false;
2884 draggingField = null;
2890 bool HeaderClicked(Button control, int x, int y, Modifiers mods)
2892 if(style.header && !this.dropField && style.sortable)
2894 DataField field = (DataField)control.id;
2895 if(sortField == field)
2896 field.sortOrder *= -1;
2901 Sort(sortField, field.sortOrder);
2902 NotifySort(master, this, field, mods);
2908 bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
2912 DataField field = (DataField)control.id;
2915 if(x < RESIZE_BORDER && field.prev)
2917 else if(x >= control.clientSize.w - RESIZE_BORDER);
2923 if(x < RESIZE_BORDER && fields.last)
2924 field = fields.last;
2936 if(style.freeSelect)
2941 this.rolledOver = this.dragging = false;
2948 bool OnLoadGraphics()
2950 display.FontExtent(fontObject, "W", 1, null, &fontH);
2951 if(!style.heightSet)
2953 rowHeight = Max(fontH + 2, 16) + (style.alwaysEdit ? 1 : 0);
2954 SetScrollLineStep(8, rowHeight);
2959 void OnApplyGraphics()
2961 SetScrollLineStep(8, rowHeight);
2965 for(field = fields.first; field; field = field.next)
2967 if(field.headButton)
2969 field.headButton.bevel = (!guiApp.textMode && !style.clearHeader);
2971 field.headButton.background = Color { 0, 170, 0 };
2975 OnResize(clientSize.w, clientSize.h);
2978 bool OnResizing(int *w, int *h)
2982 if(!initSize.w && (!anchor.left.type || !anchor.right.type) /**w*/)
2987 Font font = fontObject;
2988 Font boldFont = this.boldFont.font;
2989 Display display = this.display;
2991 for(row = rows.first; row; row = row.GetNextRow())
2993 Bitmap icon = row.icon ? row.icon.bitmap : null;
2994 int x = -scroll.x + EXTRA_SPACE / 2-1;
2998 for(parent = row.parent; parent; parent = parent.parent)
3002 if(style.treeBranch)
3008 if(style.rootCollapse) indent += 20;
3010 if(style.collapse && !(style.treeBranch)) x += 15;
3014 // Compute the rows size
3015 for(field = fields.first; field; field = field.next)
3017 if(((style.resizable && (!(style.alwaysEdit) || field.next)) || field.width) && !row.header)
3018 x += field.width - (field.prev ? 0 : indent);
3023 for(index = 0, cell = row.cells.first; index != field.index; index++, cell = cell.next);
3025 // Should always be as many cells in the row as fields in the listbox
3026 if(cell && cell.isSet && field.dataType)
3028 static char tempString[4096];
3031 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
3032 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data[0], tempString, field.userData, null);
3034 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data, tempString, field.userData, null);
3036 if(!string) string = "";
3037 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3040 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3042 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, &th);
3045 if(row.header) break;
3049 maxWidth = Max(maxWidth, x);
3055 *h = Min(this.maxShown, this.rowCount) * rowHeight;
3060 if(!*w) *w = rowHeight * 5;
3061 if(!*h) *h = rowHeight * 5;
3068 FontResource font = this.font;
3069 FontResource boldFont
3071 faceName = font.faceName, size = font.size, bold = true
3073 AddResource(boldFont);
3074 RemoveResource(this.boldFont);
3075 this.boldFont = boldFont;
3079 SetInitSize(initSize);
3082 bool OnMouseMove(int x, int y, Modifiers mods)
3084 bool isTimer = false;
3085 int realX = x, realY = y;
3087 if(insideNotifySelect) return true;
3089 if(style.alwaysEdit && style.resizable &&
3090 resizingField && !(mods.isSideEffect))
3093 DataField field = resizingField;
3094 field.width = this.startWidth + x - this.resizeX;
3095 field.width = Max(field.width, - EXTRA_SPACE);
3097 AdaptToFieldWidth(field, true);
3101 if(style.alwaysEdit && style.resizable)
3103 int vx = -scroll.x - 1;
3106 if(style.collapse && !(style.treeBranch))
3109 for(field = fields.first; field; field = field.next)
3111 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3112 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3118 cursor = guiApp.GetCursor(sizeWE);
3122 vx += width + EXTRA_SPACE;
3126 if((editData && editData.visible) || (style.alwaysEdit))
3129 if(x == MAXINT && y == MAXINT)
3136 // ADDED THIS CHECK FOR FieldDropBox LEAKS
3137 if(/*!mods.isSideEffect && */(this.rolledOver || !this.dragging))
3139 int rowY = (style.header) ? rowHeight : 0;
3147 ((vertScroll && vertScroll.visible &&
3148 (y < 0 || y >= clientSize.h)) ||
3149 (horzScroll && horzScroll.visible &&
3150 (x < 0 || x >= clientSize.w))))
3155 if(vertScroll && vertScroll.visible &&
3156 (y < 0 || y >= clientSize.h))
3157 vertScroll.Action((y<0)?up:down, 0, 0);
3158 if(horzScroll && horzScroll.visible &&
3159 (x < 0 || x >= clientSize.w))
3160 horzScroll.Action((x<0)?up:down, 0, 0);
3166 // This must be done after the scrolling took place
3167 rowIndex = firstRowShown ? firstRowShown.index : -1;
3169 y = Min(y, clientSize.h-1);
3170 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3179 if(row && currentRow != row)
3181 if(this.dragRow && style.moveRows)
3183 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3185 else if(style.multiSelect)
3188 for(thisRow = rows.first; thisRow; thisRow = thisRow.GetNextRow())
3189 if((thisRow.selectedFlag == selected || thisRow.selectedFlag == tempSelected) ||
3195 if(this.dropIndex != rowIndex)
3197 this.dropIndex = rowIndex;
3198 this.editRow = null;
3200 this.movedRow = true;
3203 else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || this.rolledOver))
3205 if(!(style.multiSelect))
3207 if(currentRow)currentRow.selectedFlag = unselected;
3208 if(row)row.selectedFlag = selected;
3212 if(style.multiSelect)
3216 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3218 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3219 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3222 if(rowIndex >= clickedRow.index)
3224 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3226 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3233 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3235 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3236 if(selRow == clickedRow)
3242 if(style.freeSelect)
3243 NotifyHighlight(master, this, currentRow, mods);
3246 insideNotifySelect = true;
3247 NotifySelect(master, this, currentRow, mods);
3248 insideNotifySelect = false;
3251 if(style.alwaysEdit && currentRow)
3252 currentRow.Edit(currentField);
3259 bool OnMouseOver(int x, int y, Modifiers mods)
3262 this.rolledOver = true;
3266 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
3268 // TOCHECK: WAS THIS MISSING ? CHECK FOR SLOWDOWN
3269 if(!active) Update(null);
3271 if(!active && (!swap || !swap.isModal))
3273 // true: destroy edit box
3274 HideEditBox(true, true, false);
3276 else if(!swap || !swap.isModal)
3278 // Bring back edit box
3279 if(currentRow && style.alwaysEdit)
3281 currentRow.Edit(currentField ? currentField : null);
3285 return true; //NotifyActivate(master, this, active, swap, 0);
3289 bool OnButtonDown(int x, int y, Modifiers mods, bool right)
3292 // Check to see if we're dragging the vertical divider
3293 if(style.alwaysEdit && style.resizable && !right)
3295 int vx = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
3298 if(style.collapse && !(style.treeBranch))
3301 for(field = fields.first; field; field = field.next)
3303 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3304 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3310 resizingField = field.prev;
3312 this.startWidth = resizingField.width;
3314 SetMouseRangeToClient();
3318 vx += width + EXTRA_SPACE;
3322 if(!(style.freeSelect))
3324 int rowY = (style.header) ? rowHeight : 0;
3326 int rowIndex = firstRowShown ? firstRowShown.index : -1;
3327 DataRow previousRow = currentRow;
3328 DataRow newCurrentRow = null;
3329 DataField newCurrentField = null;
3330 bool moveMultiple = false;
3331 int numSelected = 0;
3332 int rowStart = -scroll.x;
3334 if(style.multiSelect)
3341 for(row = rows.first; row; row = row.GetNextRow())
3343 if(row.selectedFlag == tempSelected)
3344 row.selectedFlag = selected;
3345 else if(row.selectedFlag == tempUnselected)
3346 row.selectedFlag = unselected;
3347 if(row.selectedFlag == selected)
3354 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3357 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3360 if(style.treeBranch)
3363 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3369 /* THIS WAS TOO STRICT:
3370 if(style.collapse && row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) &&
3371 (x >= rowStart + 3 + plusIndent && y >= rowY - rowHeight + PLUSY && x <= rowStart + 11 + plusIndent && y <= rowY - rowHeight + PLUSY + 8))
3373 if(style.collapse &&
3374 (x >= rowStart && y >= rowY - rowHeight && x <= rowStart + 18 + plusIndent && y <= rowY + rowHeight-1))
3376 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) && x >= plusIndent)
3377 row.collapsed = !row.collapsed;
3384 newCurrentRow = row;
3386 if(style.multiSelect)
3388 // Deselect everything if user didn't clicked on a row
3392 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3393 selRow.selectedFlag = unselected;
3395 //this.clickedRowIndex = rowIndex;
3397 else if(style.moveRows && !(mods.shift) &&
3398 (row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
3399 !right && !(mods.isActivate))
3400 moveMultiple = true;
3406 if(row.selectedFlag == tempUnselected || row.selectedFlag == unselected)
3408 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3409 selRow.selectedFlag = unselected;
3410 row.selectedFlag = selected;
3413 //this.clickedRowIndex = rowIndex;
3419 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3420 selRow.selectedFlag = unselected;
3424 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3426 if(selRow != clickedRow)
3428 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3429 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3436 if(rowIndex >= clickedRow.index)
3438 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3442 if(selRow != clickedRow)
3444 if(selRow.selectedFlag)
3445 selRow.selectedFlag = tempUnselected;
3447 selRow.selectedFlag = tempSelected;
3451 selRow.selectedFlag = selected;
3458 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3462 if(selRow != clickedRow)
3464 if(selRow.selectedFlag)
3465 selRow.selectedFlag = tempUnselected;
3467 selRow.selectedFlag = tempSelected;
3471 selRow.selectedFlag = selected;
3472 if(selRow == clickedRow)
3481 if(row.selectedFlag)
3482 row.selectedFlag = tempUnselected;
3483 else row.selectedFlag = tempSelected;
3486 row.selectedFlag = tempSelected;
3488 //this.clickedRowIndex = rowIndex;
3498 // true: destroy edit box
3501 incref newCurrentRow;
3504 if(currentRow != newCurrentRow)
3505 HideEditBox(true, true, false);
3509 if(newCurrentRow._refCount <= 1)
3510 delete newCurrentRow;
3512 newCurrentRow._refCount--;
3517 if(!(style.multiSelect))
3519 if(currentRow) currentRow.selectedFlag = unselected;
3520 if(newCurrentRow) newCurrentRow.selectedFlag = selected;
3524 if(currentRow != newCurrentRow)
3527 // true: destroy edit box
3530 //incref newCurrentRow;
3531 incref newCurrentRow;
3534 HideEditBox(true, true, false);
3539 int headerSize = ((style.header) ? rowHeight : 0);
3540 int height = clientSize.h + 1 - headerSize;
3542 /*if(newCurrentRow._refCount <= 1)
3543 delete newCurrentRow;
3546 newCurrentRow._refCount--;
3547 //newCurrentRow._refCount--;
3550 currentRow = newCurrentRow;
3552 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
3553 SetScrollPosition(scroll.x,
3554 currentRow.index * rowHeight - height + rowHeight);
3555 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
3557 int line = currentRow ? currentRow.index * rowHeight : 0;
3558 //SNAPUP(line, rowHeight);
3559 SetScrollPosition(scroll.x, line);
3562 // GO THROUGH SetCurrentRow eventually?
3563 // SetCurrentRow(newCurrentRow, true);
3567 if(style.freeSelect)
3568 NotifyHighlight(master, this, currentRow, mods);
3569 else if((moveMultiple || (!(style.multiSelect) && previousRow == currentRow)) &&
3570 newCurrentRow && !(mods.shift))
3574 if(!(mods.isActivate))
3578 this.dragRow = currentRow;
3579 this.dropIndex = -1;
3580 this.movedRow = false;
3582 if(editData && editData.visible && style.alwaysEdit)
3589 if(style.collapse && !style.treeBranch)
3592 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3594 indent += (style.treeBranch) ? 20 : 15;
3597 for(field = fields.first; field; field = field.next)
3599 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3600 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3602 if(!field.prev) width -= indent;
3603 if(x >= sx && x < sx + width)
3607 if(field == currentField)
3608 editData.Deactivate();
3611 currentRow.Edit(field);
3612 editData.Activate();
3615 else if(!(mods.ctrl) && numSelected <= 1)
3616 this.editRow = currentRow;
3618 if(style.noDragging && newCurrentRow)
3619 NotifyReclick(master, this, newCurrentRow, mods);
3623 // If the user clicked exactly on the edited field,
3625 if(editData && editData.visible && newCurrentRow)
3627 DataField field, whichField;
3631 if(style.collapse && !(style.treeBranch))
3634 whichField = currentField;
3638 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3640 indent += (style.treeBranch) ? 20 : 15;
3644 for(field = fields.first; field; field = field.next)
3646 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3647 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3648 if(!field.prev) width -= indent;
3649 if(x >= sx && x < sx + width && newCurrentRow)
3654 if(field) //x >= sx && x < sx + width && newCurrentRow)
3656 if(field == currentField)
3657 editData.Activate();
3659 newCurrentRow.Edit(currentField);*/
3661 else if(style.noDragging && newCurrentRow)
3662 NotifyReclick(master, this, newCurrentRow, mods);
3664 else if(style.noDragging && newCurrentRow)
3665 NotifyReclick(master, this, newCurrentRow, mods);
3671 result = NotifySelect(master, this,
3672 currentRow ? currentRow : null, mods);
3673 if(result && style.alwaysEdit && currentRow)
3677 DataField field = null;
3682 if(style.collapse && !style.treeBranch)
3685 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3687 indent += (style.treeBranch) ? 20 : 15;
3690 for(field = fields.first; field; field = field.next)
3692 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3693 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3695 if(!field.prev) width -= indent;
3696 if(x >= sx && x < sx + width)
3698 currentField = field;
3704 currentRow.Edit(currentField);
3706 // If the user clicked exactly on the edited field,
3708 if(editData && editData.visible && newCurrentRow)
3712 editData.Activate();
3714 else if(style.noDragging && newCurrentRow)
3715 NotifyReclick(master, this, newCurrentRow, mods);
3718 else if(style.noDragging && newCurrentRow)
3719 NotifyReclick(master, this, newCurrentRow, mods);
3723 For drop box to capture...
3726 if(x < 0 || y < 0 || x >= clientSize.w || y >= clientSize.h)
3729 master.parent.Activate();
3738 if(!style.noDragging)
3740 this.dragging = true;
3743 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h)
3744 this.rolledOver = true;
3749 this.dragging = false;
3750 OnLeftButtonUp(x, y, mods);
3755 bool OnLeftButtonDown(int x, int y, Modifiers mods)
3757 return OnButtonDown(x,y, mods, false);
3760 bool OnLeftButtonUp(int x, int y, Modifiers mods)
3762 if(resizingField && style.alwaysEdit)
3764 Window::FreeMouseRange();
3766 resizingField = null;
3769 if(dragRow || editRow)
3771 DataRow row, switchRow = rows.last;
3772 int rowY = (style.header) ? rowHeight : 0;
3773 for(row = firstRowShown; row; row = row.GetNextRow())
3782 if(this.editRow == switchRow && y >= 0)
3787 for(field = fields.first; field; field = field.next)
3789 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3790 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3793 if(fieldX > x + scroll.x)
3797 if(field && field.editable)
3799 // true: destroy edit box
3800 HideEditBox(true, true, false);
3801 PopupEditBox(field, false);
3803 else if(!style.noDragging)
3804 NotifyReclick(master, this, currentRow, mods);
3806 else if(style.moveRows && switchRow)
3808 if(this.dragRow == switchRow && this.movedRow == false)
3810 DataRow row = this.dragRow;
3814 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3815 selRow.selectedFlag = unselected;
3819 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3821 if(selRow != clickedRow)
3823 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3824 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3830 if(row.selectedFlag)
3831 row.selectedFlag = tempUnselected;
3832 else row.selectedFlag = tempSelected;
3835 row.selectedFlag = tempSelected;
3840 if(style.multiSelect)
3842 if(!switchRow.selectedFlag)
3844 bool foundSwitch = false;
3847 DataRow afterRow = switchRow.prev;
3848 for(row = rows.first; row; row = next)
3850 next = row.GetNextRow();
3851 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3853 if(!foundSwitch && !after)
3856 afterRow = switchRow;
3858 if(!after || !(row.selectedFlag == selected || row.selectedFlag == tempSelected) ||
3865 else if(row == switchRow)
3872 for(row = rows.first; row; row = row.GetNextRow())
3874 if(row == switchRow || row == this.dragRow)
3878 // Switch row first: move before
3879 if(row == switchRow)
3881 if(NotifyMove(master, this, switchRow.prev, mods))
3882 dragRow.Move(switchRow.prev);
3884 // Dragged row first: move after
3887 if(NotifyMove(master, this, switchRow, mods))
3888 dragRow.Move(switchRow);
3901 if(this.dragging || style.freeSelect)
3905 this.rolledOver = this.dragging = false;
3907 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h && currentRow && style.freeSelect)
3911 result = NotifySelect(master, this, currentRow, mods);
3912 if(style.alwaysEdit)
3913 currentRow.Edit(currentField);
3917 // if(!(style.freeSelect))
3923 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
3925 int rowStart = -scroll.x;
3927 int rowY = (style.header) ? rowHeight : 0;
3930 OnLeftButtonUp(x,y,mods);
3931 if(style.alwaysEdit)
3933 if(!(style.collapse) || x > 15)
3934 if(editData && editData.visible)
3936 editData.Activate();
3937 NotifyDoubleClick(master, this, x, y, mods);
3941 for(row = firstRowShown; row; row = row.GetNextRow())
3944 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3946 if(style.treeBranch)
3949 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3958 if((row && style.collapse && (x >= rowStart && x <= rowStart + 18 + plusIndent)) ||
3959 NotifyDoubleClick(master, this, x, y, mods))
3963 if(row && row.subRows.first)
3965 row.collapsed = !row.collapsed;
3969 // We need to return true here so that OnLeftButtonDown can popup the DataBox Editors
3975 bool OnRightButtonDown(int x, int y, Modifiers mods)
3977 return OnButtonDown(x,y, mods, true);
3980 bool OnRightButtonUp(int x, int y, Modifiers mods)
3982 OnLeftButtonUp(x,y,mods);
3983 return NotifyRightClick(master, this, x, y, mods);
3986 bool GoToLetter(unichar ch, bool keyHit)
3988 bool result = false;
3990 bool checkNextField = true;
3991 int len = keyHit ? 0 : strlen(typedString);
3993 typedString = renew typedString char[len + 2];
3994 typedString[len++] = (char)tolower(ch); // TODO: FIX UNICODE
3995 typedString[len] = '\0';
3997 for(field = fields.first; field; field = field.next)
3999 DataRow startRow = currentRow ? currentRow : rows.first;
4001 if(startRow && field.dataType && field.dataType._vTbl[__ecereVMethodID_class_OnGetString] && ch)
4004 bool looped = false;
4005 if(len == 1 && currentRow)
4006 startRow = (next = startRow.GetNextRow(), (next ? next : rows.first));
4008 for(row = startRow; row != startRow || !looped; next = row.GetNextRow(), row = next ? next : rows.first)
4010 void * data = row.GetData(field);
4011 char tempString[1024] = "";
4012 bool needClass = false;
4013 char * string = data ? (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass) : null;
4015 if(string && string[0])
4016 checkNextField = false;
4017 if(string && string[0] && !strnicmp(string, typedString, len))
4019 if(style.multiSelect)
4022 bool foundRow = false;
4024 //this.clickedRowIndex = 0;
4026 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4028 if(selRow == row) foundRow = true;
4029 selRow.selectedFlag = unselected;
4030 //if(!foundRow) this.clickedRowIndex++;
4032 row.selectedFlag = selected;
4034 SetCurrentRow(row, true);
4041 if(this.typingTimeOut && !keyHit)
4042 typingTimer.Start();
4043 if(!result || !this.typingTimeOut || keyHit)
4044 typedString[len-1] = '\0';
4046 if(!checkNextField || result) break;
4051 bool OnKeyDown(Key key, unichar ch)
4055 if(key == enter || key == keyPadEnter)
4057 if(editData && editData.visible && editData.active)
4059 HideEditBox(true, false, false);
4063 else if(key == escape)
4065 if(resizingField || this.movingFields || (editData && editData.visible) || this.dragRow)
4067 if(editData && editData.visible && style.alwaysEdit && !editData.active)
4069 // false: dont destroy edit box
4070 HideEditBox(false, false, false);
4073 resizingField.width = this.startWidth;
4074 AdaptToFieldWidth(resizingField, true);
4075 resizingField = null;
4078 this.dragRow = null;
4081 this.dragging = false;
4085 this.movingFields = false;
4086 draggingField = null;
4092 if(!currentField || !currentField.editable)
4093 for(field = fields.first; field; field = field.next)
4097 currentField = field;
4101 if(key == f2 && currentField && currentField.editable)
4103 PopupEditBox(currentField, false);
4104 if(editData && editData.visible)
4106 if(style.alwaysEdit)
4107 editData.Activate();
4112 if(!NotifyKeyDown(master, this, currentRow, key, ch))
4115 // Editable fields...
4118 if(style.alwaysEdit && editData && editData.visible)
4119 return editData.OnKeyDown(key, ch);
4120 return true; // We want to pick up the OnKeyHit to replace contents, but skip GoToLetter
4123 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, false))
4125 /*if(inactive && window.state != Hidden)
4126 NotifyHighlight(master, this, currentRow, 0);
4129 NotifySelect(master, this, currentRow, 0);
4136 bool OnKeyHit(Key key, unichar ch)
4138 if(key.code == up && key.alt == true && key.ctrl == false && key.shift == false)
4141 if(!ch && !key.alt && !key.ctrl)
4143 key.code = (SmartKey)key.code;
4145 if(ch >= 32 && !key.alt && !key.ctrl && ch != 128)
4148 if(!currentField || !currentField.editable)
4149 for(field = fields.first; field; field = field.next)
4153 currentField = field;
4157 if(currentField && currentField.editable)
4159 if((!editData || !editData.visible) || !editData.active)
4161 PopupEditBox(currentField, false);
4162 if(editData && editData.visible)
4164 editData.Activate();
4165 editData.OnKeyHit(key, ch);
4172 if(!(style.multiSelect) && (key.ctrl))
4175 if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
4181 if(style.alwaysEdit)
4186 for(field = currentField.prev; field; field = field.prev)
4190 currentField = field;
4191 HideEditBox(true, true, false);
4192 PopupEditBox(currentField, false);
4198 if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
4200 if(currentRow.subRows.first && !currentRow.collapsed)
4202 currentRow.collapsed = true;
4204 else if(currentRow.parent)
4205 SetCurrentRow(currentRow.parent, true);
4210 if(style.collapse && currentRow && currentRow.subRows.first)
4212 if(currentRow.collapsed)
4213 currentRow.collapsed = false;
4215 SetCurrentRow(currentRow.subRows.first, true);
4218 else if(style.alwaysEdit)
4223 for(field = currentField.next; field; field = field.next)
4227 currentField = field;
4228 HideEditBox(true, true, false);
4229 PopupEditBox(currentField, false);
4237 case pageDown: case pageUp:
4238 case end: case home:
4240 int headerSize = ((style.header) ? rowHeight : 0);
4241 int height = clientSize.h + 1 - headerSize;
4244 // true: destroy edit box
4245 // !!! TESTING true HERE !!!
4246 HideEditBox(true, true, false);
4247 // HideEditBox(false, true, false);
4249 oldRow = currentRow;
4251 SNAPDOWN(height, rowHeight);
4252 if((!currentRow || key.code == home) && key.code != end)
4254 currentRow = rows.first;
4262 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4265 next = currentRow.GetNextRow();
4272 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4275 next = currentRow.GetPrevRow();
4283 currentRow = lastRow.GetLastRow();
4289 currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
4290 c++, currentRow = next);
4297 currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
4298 c++, currentRow = next);
4303 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
4304 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
4305 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
4306 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
4308 if(style.multiSelect)
4312 if(!(key.shift) && (key.ctrl))
4315 for(row = rows.first; row; row = row.GetNextRow())
4317 if(row.selectedFlag == tempSelected)
4318 row.selectedFlag = selected;
4319 else if(row.selectedFlag == tempUnselected)
4320 row.selectedFlag = unselected;
4326 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4327 selRow.selectedFlag = unselected;
4331 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4333 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
4334 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
4340 if(currentRow.index >= clickedRow.index)
4342 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
4346 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4349 selRow.selectedFlag = selected;
4350 if(selRow == currentRow)
4356 for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
4360 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4363 selRow.selectedFlag = selected;
4364 if(selRow == clickedRow)
4371 if(!(key.ctrl) && currentRow)
4373 currentRow.selectedFlag = selected;
4376 clickedRow = currentRow;
4381 if(oldRow) oldRow.selectedFlag = unselected;
4382 if(currentRow) currentRow.selectedFlag = selected;
4387 if(style.freeSelect)
4388 NotifyHighlight(master, this, currentRow, 0);
4390 NotifySelect(master, this, currentRow, 0);
4392 if(style.alwaysEdit && currentRow)
4393 currentRow.Edit(currentField /*null*/);
4400 if(style.multiSelect && currentRow)
4402 if(currentRow.selectedFlag)
4405 currentRow.selectedFlag = unselected;
4408 currentRow.selectedFlag = selected;
4411 if(style.freeSelect)
4412 NotifyHighlight(master, this, currentRow, 0);
4414 NotifySelect(master, this, currentRow, 0);
4420 if(!NotifyKeyHit(master, this, currentRow, key, ch))
4423 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, true))
4425 /*if(inactive && window.state != Hidden)
4426 return NotifyHighlight(master, this, currentRow, 0);
4429 return NotifySelect(master, this, currentRow, 0);
4437 void OnHScroll(ScrollBarAction action, int position, Key key)
4442 void OnVScroll(ScrollBarAction action, int position, Key key)
4447 for(firstRowShown = rows.first; firstRowShown; firstRowShown = next)
4449 next = firstRowShown.GetNextRow();
4450 if(y >= position || !next) break;
4460 DataRow firstRowShown;
4464 DataField sortField;
4468 double typingTimeOut;
4481 if(guiApp.GetKeyState(shift)) mods.shift = true;
4482 if(guiApp.GetKeyState(alt)) mods.alt = true;
4483 if(guiApp.GetKeyState(control)) mods.ctrl = true;
4484 OnMouseMove(MAXINT, MAXINT, mods);
4492 delay = 0.5; // typingTimeOut
4497 typedString[0] = '\0';
4499 // The next line was commented... Why? When commented typing words stops working ( only first character jumps )
4505 bool dragging, rolledOver;
4514 // For editing fields
4516 DataField currentField;
4519 // For moving fields
4520 DataField draggingField, dropField;
4523 // For resizing fields
4524 DataField resizingField;
4525 int resizeX, oldX, startWidth;
4528 FontResource boldFont;
4531 // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
4532 bool insideNotifySelect;
4533 Color selectionColor, selectionText, stippleColor;
4534 stippleColor = 0xFFFFFF80;