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.GetNextRow())
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 if(sortField == field)
1231 for(row = rows.first; row; )
1236 for(cell = row.cells.first, c = 0; c < index && cell; c++, cell = cell.next);
1237 if(cell && index == c)
1241 // TOCHECK: Is this check good? Will need incref/decref sometime?
1242 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
1244 if(cell.data[0] && field.freeData)
1245 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data[0]);
1248 field.dataType._vTbl[__ecereVMethodID_class_OnFree](field.dataType, cell.data);
1251 row.cells.Remove(cell);
1255 if(row.subRows.first)
1256 row = row.subRows.first;
1259 for(; row; row = row.parent)
1261 if(row.next) { row = row.next; break; }
1270 endBevel.visible = false;
1274 DataRow AddRowNone()
1276 DataRow row { noneRow = true };
1285 rows.Insert(null, row);
1288 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1294 firstRowShown = row;
1298 (rowCount * rowHeight) +
1299 ((style.header) ? rowHeight : 0) -
1300 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1301 if(style.autoScroll)
1302 SetScrollPosition(0, MAXINT - rowHeight);
1303 modifiedDocument = true;
1322 // Find very last row
1325 for(lastRow = rows.last; lastRow && !lastRow.collapsed && lastRow.subRows.last; lastRow)
1326 lastRow = lastRow.subRows.last;
1327 row.index = lastRow ? (lastRow.index + 1) : 0;
1335 for(c = 0; c<fields.count; c++)
1337 for(field = fields.first; field; field = field.next)
1338 if((int)field.index == c)
1342 int size = (field.dataType && field.dataType.typeSize) ?
1343 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1344 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1345 row.cells.Add(cell);
1346 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1353 firstRowShown = row;
1359 (rowCount * rowHeight) +
1360 ((style.header) ? rowHeight : 0) -
1361 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1362 if(style.autoScroll)
1363 SetScrollPosition(0, MAXINT - rowHeight);
1364 modifiedDocument = true;
1375 DataRow AddRowAfter(DataRow after)
1387 if(after && after.subRows.first && !after.collapsed)
1389 for(search = after.subRows.last; !search.collapsed && search.subRows.last; )
1390 search = search.subRows.last;
1391 row.index = search.index + 1;
1394 row.index = after ? (after.index + 1) : 0;
1395 rows.Insert(after, row);
1398 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1403 for(c = 0; c<fields.count; c++)
1405 for(field = fields.first; field; field = field.next)
1406 if((int)field.index == c)
1410 int size = (field.dataType && field.dataType.typeSize) ?
1411 (sizeof(class ListBoxCell) + field.dataType.typeSize - sizeof(void *)) : sizeof(class ListBoxCell);
1412 ListBoxCell cell = (ListBoxCell) new0 byte[size];
1413 row.cells.Add(cell);
1414 FillBytes(cell.data, 0, size - (uint)&((ListBoxCell)0).data);
1418 if(!firstRowShown || !after)
1420 firstRowShown = row;
1425 (rowCount * rowHeight) +
1426 ((style.header) ? rowHeight : 0) -
1427 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1428 if(style.autoScroll)
1429 SetScrollPosition(0, MAXINT - rowHeight);
1430 modifiedDocument = true;
1440 DataRow AddStringf(char * format, ...)
1446 char string[MAX_F_STRING];
1449 va_start(args, format);
1450 vsprintf(string, format ? format : "", args);
1454 row.SetData(fields.first, string);
1460 DataRow AddString(char * string)
1466 row.SetData(fields.first, string);
1472 void SelectRow(DataRow row)
1474 SetCurrentRow(row, true);
1477 void DeleteRow(DataRow row)
1479 if(!row) row = currentRow;
1482 DataRow sub, next, search;
1483 // Trying to move this here (Messed up deleting watches)
1484 //HideEditBox(false, false, true);
1487 for(sub = row.subRows.first; sub; sub = next)
1493 if(row.parent.IsExpanded())
1495 for(search = row.GetNextRow(); search; search = search.GetNextRow())
1500 HideEditBox(false, false, true);
1502 if(row == clickedRow)
1504 clickedRow = row.GetNextRow();
1506 clickedRow = row.GetPrevRow();
1509 if(row == currentRow)
1511 DataRow newCurrentRow = row.GetNextRow();
1513 newCurrentRow = row.GetPrevRow();
1514 SetCurrentRow(newCurrentRow, true);
1517 if(row == firstRowShown)
1519 firstRowShown = row.GetPrevRow();
1521 firstRowShown = row.GetNextRow();
1524 (row.parent ? row.parent.subRows: rows).Remove(row);
1527 //HideEditBox(false, false, true);
1531 (this.rowCount * rowHeight) +
1532 ((style.header) ? rowHeight : 0) -
1533 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1535 modifiedDocument = true;
1544 DataRow FindRow(int tag)
1549 for(row = rows.first; row; row = row.next)
1551 if(!row.noneRow && row.tag == tag)
1559 DataRow FindString(char * searchedString)
1562 bool checkNextField = true;
1563 int len = searchedString ? strlen(searchedString) : 0;
1565 for(field = fields.first; field; field = field.next)
1567 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1570 for(row = rows.first; row; row = row.GetNextRow())
1574 void * data = row.GetData(field);
1575 char tempString[1024] = "";
1576 bool needClass = false;
1577 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1579 if(string && string[0])
1580 checkNextField = false;
1581 if(string && string[0] && !strcmp(string, searchedString))
1586 if(!checkNextField) break;
1591 DataRow FindSubString(char * subString)
1594 bool checkNextField = true;
1595 int len = subString ? strlen(subString) : 0;
1599 for(field = fields.first; field; field = field.next)
1601 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1604 for(row = rows.first; row; row = row.GetNextRow())
1608 void * data = row.GetData(field);
1609 char tempString[1024] = "";
1610 bool needClass = false;
1611 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1613 if(string && string[0])
1614 checkNextField = false;
1615 if(string && string[0] && !strncmp(string, subString, len))
1620 if(!checkNextField) break;
1626 DataRow FindSubStringi(char * subString)
1629 bool checkNextField = true;
1630 int len = subString ? strlen(subString) : 0;
1631 DataRow result = null;
1632 char * bestResult = null;
1637 for(field = fields.first; field; field = field.next)
1639 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1642 for(row = rows.first; row; row = row.GetNextRow())
1646 void * data = row.GetData(field);
1647 char tempString[1024] = "";
1648 bool needClass = false;
1649 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1651 if(string && string[0])
1652 checkNextField = false;
1653 if(string && string[0])
1655 int stringLen = strlen(string);
1657 if(!strnicmp(string, subString, Min(len, stringLen)))
1659 if(bestLen < Min(len, stringLen))
1661 if(!bestResult || strcmpi(string, bestResult) < 0)
1663 bestLen = Min(len, stringLen);
1664 bestResult = string;
1672 if(!checkNextField) break;
1678 DataRow FindSubStringAfter(DataRow after, char * subString)
1681 bool checkNextField = true;
1682 int len = subString ? strlen(subString) : 0;
1686 for(field = fields.first; field; field = field.next)
1688 if(field.dataType._vTbl[__ecereVMethodID_class_OnGetString])
1691 for(row = after.GetNextRow(); row && row != after; row = row.GetNextRow(), (!row) ? (row = rows.first) : null)
1695 void * data = row.GetData(field);
1696 char tempString[1024] = "";
1697 bool needClass = false;
1698 char * string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass);
1700 if(string && string[0])
1701 checkNextField = false;
1702 if(string && string[0] && !strncmp(string, subString, len))
1707 if(!checkNextField) break;
1713 DataRow FindSubRow(int tag)
1719 for(row = rows.first; row; row = row.next)
1721 if(!row.noneRow && row.tag == tag)
1723 if(!row.noneRow && row.subRows.first)
1725 DataRow subRow = row.FindSubRow(tag);
1739 Window master = this.master;
1741 HideEditBox(false, true, false);
1742 editData.Destroy(0);
1744 firstRowShown = currentRow = null;
1749 if(style.freeSelect)
1750 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
1752 NotifySelect(master, this, currentRow ? currentRow : null, 0);
1755 if(style.alwaysEdit && currentRow)
1756 currentRow.Edit(currentField);
1763 (this.rowCount * rowHeight) +
1764 ((style.header) ? rowHeight : 0) -
1765 ((rowHeight && !((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
1770 void Sort(DataField field, int order)
1775 int headerSize = ((style.header) ? rowHeight : 0);
1776 int height = clientSize.h + 1 - headerSize;
1778 if(!field) field = fields.first;
1780 field.sortOrder = order ? order : 1;
1781 rows.Sort(DataRow::Compare, field);
1783 for(search = rows.first; search; search = search.next)
1784 search._SortSubRows(field, order);
1788 for(search = rows.first; search; search = search.GetNextRow())
1789 search.index = index++;
1792 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1793 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
1794 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1795 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
1797 OnVScroll(0, scroll.y, 0);
1799 // SetScrollPosition(0, scroll.y);
1804 void StopEditing(bool save)
1806 HideEditBox(save, false, true);
1809 void GetMultiSelection(OldList list)
1812 if(this && style.multiSelect)
1816 for(row = rows.first; row; row = row.GetNextRow())
1818 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
1820 list.Add(OldLink { data = row });
1826 // Convenience Current Row Methods
1827 void * SetData(DataField field, any_object data)
1829 return currentRow.SetData(field, data);
1832 any_object GetData(DataField field)
1834 return (void *)currentRow.GetData(field);
1839 return currentRow ? currentRow.tag : 0;
1845 DataField defaultField { };
1846 rows.offset = (uint)&((DataRow)0).prev;
1847 fields.offset = (uint)&((DataField)0).prev;
1848 style.fullRowSelect = true;
1849 style.fillLastField = true;
1850 style.expandOnAdd = true;
1851 typingTimeOut = 0.5;
1852 rowHeight = 16; // Stuff depending on creation and default property checking
1855 defaultField.defaultField = true;
1857 AddField(defaultField);
1859 typedString = new char[1];
1860 typedString[0] = '\0';
1875 while((field = fields.first))
1877 // fields.Remove(field);
1887 while((row = rows.first))
1894 ListBoxCell GetCell(DataRow * row, DataField * field)
1896 ListBoxCell cell = null;
1897 if(!*row) *row = currentRow;
1900 if(!*field) *field = this ? currentField : null;
1903 for(*field = fields.first; (*field).index != 0; *field = (*field).next);
1908 if(field->listBox == this)
1910 for(index = 0, cell = (*row).cells.first; cell && index != (*field).index; index++, cell = cell.next);
1917 void HideEditBox(bool save, bool alwaysStopEdit, bool repositionOnly)
1919 if(editData && editData.visible)
1921 Class dataType = currentField.dataType;
1923 editData.SaveData();
1925 editData.visible = false;
1926 NotifyEditDone(master, this, currentRow);
1928 // ENSURE DATA BOX IS NOT VISIBLE
1929 editData.visible = false;
1931 if(style.alwaysEdit && !alwaysStopEdit)
1934 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
1935 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
1936 int x = currentField.x;
1937 int width = (!currentField.next && style.fillLastField && (!hasHorzScroll || clientSize.w - currentField.x > currentField.width + EXTRA_SPACE)) ?
1938 clientSize.w - currentField.x : (currentField.width + EXTRA_SPACE);
1940 if(!style.alwaysEdit)
1942 editData.position = { x, y };
1943 editData.size = { width, height };
1947 editData.position = { x, y - editData.clientStart.y };
1948 editData.size = { width, height + editData.clientStart.y * 2 };
1950 editData.visible = true;
1951 if(style.alwaysEdit)
1952 editData.Deactivate();
1954 PopupEditBox(currentField, repositionOnly);
1960 currentField = null;*/
1964 void SetCurrentRow(DataRow row, bool notify)
1966 if(currentRow != row || (currentRow && currentRow.selectedFlag == unselected))
1968 int headerSize = ((style.header) ? rowHeight : 0);
1969 int height = clientSize.h + 1 - headerSize;
1971 // true: destroy edit box
1972 HideEditBox(true, true, false);
1974 if(!(style.multiSelect) && currentRow)
1975 currentRow.selectedFlag = unselected;
1979 if(style.multiSelect)
1983 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
1984 selRow.selectedFlag = unselected;
1986 currentRow.selectedFlag = selected;
1991 currentRow.selectedFlag = selected;
1993 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
1994 SetScrollPosition(scroll.x,
1995 currentRow.index * rowHeight - height + rowHeight);
1996 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
1998 int line = currentRow ? currentRow.index * rowHeight : 0;
1999 //SNAPUP(line, rowHeight);
2000 SetScrollPosition(scroll.x, line);
2005 Window master = this.master;
2008 if(style.freeSelect && visible)
2009 NotifyHighlight(master, this, currentRow ? currentRow : null, 0);
2011 NotifySelect(master, this, currentRow ? currentRow : null, 0);
2012 if(style.alwaysEdit && currentRow)
2013 currentRow.Edit(currentField);
2021 void PopupEditBox(DataField whichField, bool repositionOnly)
2023 if((!editData || !editData.visible || currentField != whichField) && currentRow)
2025 // true: destroy edit box
2026 HideEditBox(true, true, false);
2029 int height = rowHeight - (style.alwaysEdit ? 1 : 0);
2031 int y = currentRow.index * rowHeight + (style.header ? rowHeight : 0);
2033 //void * data = currentRow.GetData(whichField);
2038 if(style.collapse && !(style.treeBranch))
2041 for(field = fields.first; field; field = field.next)
2043 width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2044 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2045 if(field == whichField) break;
2049 currentField = whichField;
2050 cell = GetCell(&row, ¤tField);
2057 background = dataBoxBackground;
2058 foreground = dataBoxForeground;
2060 bool NotifyChanged(bool closingDropDown)
2063 DataField field = null;
2064 ListBoxCell cell = GetCell(&row, &field);
2068 modifiedDocument = true;
2070 NotifyChanged(master, this, currentRow);
2075 bool NotifyModified()
2077 //DataRow row = null;
2078 //DataField field = null;
2079 //ListBoxCell cell = GetCell(&row, &field);
2080 //cell.isSet = true;
2081 modifiedDocument = true;
2083 NotifyModified(master, this, currentRow);
2087 bool OnKeyDown(Key key, unichar ch)
2089 bool result = DataBox::OnKeyDown(key, ch);
2090 if(visible && active) // Added this check here, because we will not use enter/escape otherwise, and lose DataBox's result
2092 if((SmartKey)key == enter || (SmartKey)key == escape)
2101 editData.Destroy(0);
2102 editData.type = whichField.dataType;
2103 editData.fieldData = whichField.userData;
2104 editData.borderStyle = style.alwaysEdit ? 0 : deep;
2105 editData.data = cell ? cell.data : null;
2108 // Might not really need this anymore...
2109 NotifyEditing(master, this, currentRow);
2112 if(!style.alwaysEdit)
2114 editData.position = { x, y - editData.clientStart.y };
2115 editData.size = { width, height + editData.clientStart.y * 2 };
2119 editData.position = { x, y };
2120 editData.size = { width, height };
2124 editData.visible = true;
2126 if(style.alwaysEdit)
2127 editData.Deactivate();
2129 // MOVED THIS HIGHER FOR DATALIST EDITOR
2131 // Might not really need this anymore...
2132 NotifyEdited(master, this, currentRow);
2137 void OnRedraw(Surface surface)
2140 int y = (style.header) ? rowHeight : 0;
2141 bool isActive = active;
2142 Font font = fontObject;
2143 Font boldFont = this.boldFont.font;
2147 if(style.alwaysEdit && style.fullRowSelect)
2150 int y = (style.header) ? rowHeight : 0;
2151 int x = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
2152 int w = clientSize.w;
2153 int h = clientSize.h;
2157 // Fill out indent column
2158 if(style.collapse && !(style.treeBranch) && rows.first)
2161 surface.SetBackground(formColor);
2162 surface.Area(-scroll.x, 0, x, clientSize.h);
2165 surface.SetForeground(formColor);
2166 for(row = firstRowShown; row; row = row.GetNextRow())
2169 surface.HLine(x + 1, w-1, y-1);
2175 for(field = fields.first; field; field = field.next)
2177 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2178 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2179 if(field.prev && y > 0)
2180 surface.VLine(0, y-1, x);
2185 surface.foreground = this.foreground;
2186 surface.TextOpacity(false);
2188 // Draw the tree branches
2189 if(style.treeBranch)
2191 int y = -scroll.y + ((style.header) ? rowHeight : 0);
2192 surface.LineStipple(0x5555);
2193 surface.SetForeground(branchesColor);
2194 for(row = rows.first; row; row = row.GetNextRow() )
2196 int x = -scroll.x + EXTRA_SPACE / 2-1;
2197 int rowStart = -scroll.x;
2202 for(parent = row.parent; parent; parent = parent.parent)
2203 if(!parent.header) indent += 20;
2204 if(style.rootCollapse) indent += 20;
2206 plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2211 if(row.subRows.first)
2214 int y1 = y + PLUSY + 4;
2218 for(child = row.collapsed ? null : row.subRows.first; child && child != row; )
2221 if(child.subRows.first && !child.collapsed && child != row.subRows.last)
2222 child = child.subRows.first;
2227 for(; child && child != row; child = child.parent)
2237 y2 = y + numRows * rowHeight + PLUSY + 4;
2238 surface.VLine(y1, y2, rowStart + plusIndent + 7 + 20);
2240 surface.HLine(rowStart + plusIndent + 7, rowStart + indent, y + PLUSY + 4);
2243 if(y >= clientSize.h)
2246 // Root Vertical Lines
2247 if(style.rootCollapse && rows.first)
2252 y = -scroll.y + ((style.header) ? rowHeight : 0);
2254 for(child = rows.first; child && child != rows.last; )
2257 if(child.subRows.first && !child.collapsed && child != rows.last)
2258 child = child.subRows.first;
2263 for(; child; child = child.parent)
2273 y2 = y + numRows * rowHeight + PLUSY + 4;
2274 surface.VLine(y1, y2, -scroll.x + 11);
2276 surface.LineStipple(0);
2279 for(row = firstRowShown; row; row = row.GetNextRow() )
2281 int x = -scroll.x + EXTRA_SPACE / 2-1;
2284 Color foreground = this.foreground /*black*/, background = this.background /*white*/;
2285 DataDisplayFlags dataDisplayFlags = 0;
2286 int rowStart = -scroll.x;
2289 Bitmap icon = row.icon ? row.icon.bitmap : null;
2290 int collapseRowStart;
2292 for(parent = row.parent; parent; parent = parent.parent)
2296 if(style.treeBranch)
2302 if(style.rootCollapse) indent += 20;
2305 dataDisplayFlags.fullRow = style.fullRowSelect;
2306 dataDisplayFlags.active = isActive;
2307 dataDisplayFlags.header = row.header;
2312 collapseRowStart = rowStart;
2314 if(!(style.treeBranch))
2321 if(style.multiSelect)
2323 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2324 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2328 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2329 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2331 if(row == currentRow)
2333 dataDisplayFlags.current = true;
2334 dataDisplayFlags.selectedFlag = true;
2336 else if(!currentRow && row == firstRowShown)
2338 dataDisplayFlags.current = true;
2342 surface.TextOpacity(true);
2344 background = this.background;
2345 foreground = this.foreground;
2347 // Draw the current row background
2350 background = formColor;
2351 surface.SetBackground(formColor);
2352 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
2353 foreground = branchesColor;
2355 else if(dataDisplayFlags.selected)
2357 if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
2359 if(!isActive && style.alwaysEdit)
2360 background = formColor;
2362 background = selectionColor ? selectionColor : SELECTION_COLOR;
2363 if(style.fullRowSelect)
2365 int offset = (style.alwaysEdit) ? 2 : 1;
2366 surface.SetBackground(background);
2367 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - offset);
2369 if(isActive || !(style.alwaysEdit))
2370 foreground = selectionText ? selectionText : SELECTION_TEXT;
2372 foreground = branchesColor;
2378 surface.Blit(icon, x + (20 - icon.width) /2,y + 2,0,0, icon.width, icon.height);
2384 int width = clientSize.w;
2386 dataDisplayFlags.firstField = true;
2387 clip.left = x - EXTRA_SPACE / 2+1;
2389 clip.right = x + width - EXTRA_SPACE/2 - 0;
2390 clip.bottom = y + rowHeight - 1;
2391 surface.Clip(&clip);
2393 surface.TextFont(font);
2395 surface.SetForeground(foreground);
2396 surface.SetBackground(background);
2398 class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
2402 if(!opacity) surface.TextOpacity(false);
2404 for(field = fields.first; field; field = field.next)
2407 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2408 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2410 // Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
2413 //width -= EXTRA_SPACE;
2415 if(!field.prev) width -= indent;
2418 dataDisplayFlags.firstField = field.prev ? false : true;
2420 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2422 background = this.background;
2423 foreground = this.foreground;
2426 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
2429 surface.SetBackground(background);
2430 surface.Area(x-3, y, x+width-1, y + rowHeight-2);
2433 clip.left = x - EXTRA_SPACE / 2+1;
2435 clip.right = x + width - EXTRA_SPACE/2 - 0;
2436 clip.bottom = y + rowHeight - 1;
2437 surface.Clip(&clip);
2439 for(index = 0, cell = row.cells.first; cell && index != field.index; index++, cell = cell.next);
2440 // Should always be as many cells in the row as fields in the listbox
2441 if(cell && cell.isSet && field.dataType)
2444 surface.TextFont(boldFont);
2446 surface.TextFont(font);
2448 surface.SetForeground(foreground);
2449 surface.SetBackground(background);
2451 if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
2452 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);
2454 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);
2457 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
2458 background = formColor;
2460 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2462 background = formColor;
2463 foreground = this.background;
2466 x += width;// + EXTRA_SPACE;
2468 if(row.header) break;
2474 int plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2476 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)))
2478 surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
2479 surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
2481 surface.SetBackground(row.header ? (formColor) : (this.background)); //white
2482 surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
2484 surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
2486 surface.VLine(y + PLUSY + 2, y + PLUSY + 6, collapseRowStart + 7 + plusIndent);
2491 // Draw the current row stipple
2492 if(style.fullRowSelect && !(style.alwaysEdit) && (dataDisplayFlags.current) && isActive)
2497 surface.LineStipple(0x5555);
2498 if(dataDisplayFlags.selected)
2499 surface.SetForeground(stippleColor);
2501 surface.SetForeground(this.foreground);
2504 surface.SetForeground(selectionColor ? selectionColor : SELECTION_COLOR);
2505 surface.Rectangle(0, y, clientSize.w-1, (y + rowHeight) - 1);
2506 surface.LineStipple(0);
2510 if(y >= clientSize.h)
2513 if(firstRowShown) surface.Clip(null);
2514 if(this.dragRow && this.dropIndex != -1)
2516 int dropIndex = this.dropIndex;
2519 if(!style.multiSelect && currentRow.index < this.dropIndex)
2521 surface.DrawingChar(223);
2523 y = style.header ? rowHeight : 0;
2524 y += dropIndex * rowHeight - scroll.y;
2526 surface.SetForeground(Color { 85, 85, 255 });
2527 surface.HLine(0, clientSize.w-1, y);
2528 surface.HLine(0, clientSize.w-1, y + 1);
2532 void OnDrawOverChildren(Surface surface)
2534 if(draggingField && this.dropField)
2536 int position = this.dropField.x;
2537 if(draggingField.x < position)
2538 position += this.dropField.width + EXTRA_SPACE;
2540 surface.SetForeground(Color { 85, 85, 255 });
2541 surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
2542 surface.VLine(0, rowHeight - 1, position - scroll.x);
2544 if(sortField && !style.clearHeader && style.header)
2546 DataField field = sortField;
2547 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2548 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2551 surface.TextExtent(field.header, strlen(field.header), &tw, &th);
2552 if(tw < width - EXTRA_SPACE)
2554 bool up = field.sortOrder == 1;
2558 field.x + 2 - scroll.x, 0,
2559 field.x + width + EXTRA_SPACE - 1 - scroll.x, rowHeight
2561 surface.Clip(&clip);
2562 if(field.alignment == left || field.alignment == center)
2564 if(field.alignment == center)
2565 x = field.x + (width + EXTRA_SPACE - tw) / 2 + tw + EXTRA_SPACE + 4;
2567 x = field.x + tw + EXTRA_SPACE + 4;
2569 x = Min(x, field.x + width - 4);
2571 else if(field.alignment == right)
2573 x = field.x + width - tw - EXTRA_SPACE - 4;
2574 x = Max(x, field.x + 2);
2580 // surface.SetForeground((wmenu.selectedFlag == item) ? white : black);
2581 // surface.WriteText(clientSize.w-8, y+(wmenu.rh - 8)/2, "\020", 1);
2587 surface.SetForeground(Color { 128,128,128 } );
2588 surface.DrawLine(x + 3, y, x, y + 5);
2589 surface.PutPixel(x + 1, y + 5);
2590 surface.PutPixel(x + 1, y + 3);
2591 surface.PutPixel(x + 2, y + 1);
2593 surface.SetForeground(white);
2594 surface.DrawLine(x + 4, y, x + 7, y + 5);
2595 surface.PutPixel(x + 6, y + 5);
2596 surface.PutPixel(x + 6, y + 3);
2597 surface.PutPixel(x + 5, y + 1);
2599 surface.DrawLine(x, y + 6, x + 7, y + 6);
2603 surface.SetForeground(Color { 128,128,128 });
2604 surface.DrawLine(x + 3, y+6, x, y+1);
2605 surface.PutPixel(x + 1, y+1);
2606 surface.PutPixel(x + 1, y+3);
2607 surface.PutPixel(x + 2, y+5);
2609 surface.SetForeground(white);
2610 surface.DrawLine(x + 4, y+6, x + 7, y+1);
2611 surface.PutPixel(x + 6, y+1);
2612 surface.PutPixel(x + 6, y+3);
2613 surface.PutPixel(x + 5, y+5);
2615 surface.DrawLine(x, y, x + 7, y);
2624 void OnResize(int w, int h)
2627 bool showEndBevel = false;
2629 if(style.collapse && !style.treeBranch)
2631 for(field = fields.first; field; field = field.next)
2633 int width = field.width + EXTRA_SPACE;
2641 (rowCount * rowHeight) +
2642 ((style.header) ? rowHeight : 0) -
2643 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
2645 for(field = fields.first; field; field = field.next)
2647 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2648 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2649 if(style.header && field.headButton)
2651 showEndBevel = true;
2654 field.headButton.position = { field.x, 0 };
2655 field.headButton.size = { width, rowHeight };
2656 field.headButton.visible = true;
2659 field.headButton.visible = false;
2663 if(!style.fillLastField && showEndBevel && endBevel)
2665 endBevel.position = { x, 0 };
2666 endBevel.size = { clientSize.w + 2 - x, rowHeight };
2667 endBevel.visible = true;
2670 endBevel.visible = false;
2672 if(style.alwaysEdit && editData && editData.visible)
2674 HideEditBox(true, false, true);
2678 void AdaptToFieldWidth(DataField field, bool doScroll)
2680 OnResize(clientSize.w, clientSize.h);
2682 // Scroll appropriately
2685 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2686 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2688 SetScrollPosition(field.x + field.width + EXTRA_SPACE - clientSize.w, scroll.y);
2690 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2692 SetScrollPosition(field.x, scroll.y);
2697 bool HeaderPushed(Button control, int x, int y, Modifiers mods)
2699 DataField field = (DataField)control.id;
2700 // false: dont destroy edit box
2701 HideEditBox(true, false, true);
2702 if(style.resizable && ((!field && x < RESIZE_BORDER && fields.last) ||
2703 (field && x < RESIZE_BORDER && field.prev) ||
2704 (field && x >= control.clientSize.w - RESIZE_BORDER)))
2707 field = fields.last;
2708 else if(x < RESIZE_BORDER && field.prev)
2711 resizingField = field;
2712 this.resizeX = x + control.position.x;
2713 this.startWidth = field.width;
2714 this.oldX = x - scroll.x;
2719 draggingField = field;
2720 if(style.moveFields)
2721 field.headButton.stayDown = true;
2722 else if(!style.sortable)
2730 bool HeaderMouseMove(Button control, int x, int y, Modifiers mods)
2735 DataField field = resizingField;
2737 x += control.position.x;
2739 // Tweak to prevent shrinking field if we're actually moving right
2740 if(x - scroll.x > this.oldX &&
2741 this.startWidth + x - this.resizeX < field.width)
2743 this.oldX = x - scroll.x;
2746 this.oldX = x - scroll.x;
2748 field.width = this.startWidth + x - this.resizeX;
2749 field.width = Max(field.width, - EXTRA_SPACE);
2751 AdaptToFieldWidth(field, true);
2753 else if(draggingField)
2755 x += control.position.x;
2756 if(style.moveFields)
2758 DataField field = fields.last;
2760 for(field = fields.first; field; field = field.next)
2762 fieldX += ((field.width || style.resizable) ?
2763 field.width : clientSize.w) + EXTRA_SPACE;
2767 if(draggingField == field)
2769 // Reset scroll position
2770 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2771 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2774 field.x + field.width + EXTRA_SPACE - clientSize.w,
2777 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2779 SetScrollPosition(field.x, scroll.y);
2782 if(this.dropField != field)
2784 this.dropField = field;
2787 int position = field.x;
2789 if(draggingField.x < position)
2791 position += field.width + EXTRA_SPACE - clientSize.w;
2792 if(position > scroll.x)
2793 SetScrollPosition(position, scroll.y);
2798 if(position < scroll.x)
2799 SetScrollPosition(position, scroll.y);
2802 this.movingFields = true;
2808 else if(style.resizable)
2810 DataField field = (DataField)control.id;
2813 if(x < RESIZE_BORDER && field.prev)
2814 control.cursor = guiApp.GetCursor(sizeWE);
2815 else if(x >= control.clientSize.w - RESIZE_BORDER)
2816 control.cursor = guiApp.GetCursor(sizeWE);
2818 control.cursor = null;
2822 if(x < RESIZE_BORDER && fields.last)
2823 control.cursor = guiApp.GetCursor(sizeWE);
2825 control.cursor = null;
2831 bool HeaderReleased(Button control, int x, int y, Modifiers mods)
2835 NotifyResized(master, this, resizingField, mods);
2836 resizingField = null;
2843 if(style.moveFields)
2848 DataField switchField = fields.last;
2852 x += draggingField.x;
2853 for(field = fields.first; field; field = field.next)
2855 fieldX += ((field.width || style.resizable) ?
2856 field.width : clientSize.w) + EXTRA_SPACE;
2859 switchField = field;
2863 if(switchField && draggingField != switchField && this.dropField)
2865 for(field = fields.first; field; field = field.next)
2867 if(field == switchField || field == draggingField)
2871 // Switch field first: move before
2872 if(field == switchField)
2873 draggingField.Move(switchField.prev);
2874 // Dragged field first: move after
2876 draggingField.Move(switchField);
2878 NotifyMovedField(master, this, draggingField, mods);
2880 draggingField.headButton.stayDown = false;
2885 movingFields = false;
2887 draggingField = null;
2893 bool HeaderClicked(Button control, int x, int y, Modifiers mods)
2895 if(style.header && !this.dropField && style.sortable)
2897 DataField field = (DataField)control.id;
2898 if(sortField == field)
2899 field.sortOrder *= -1;
2904 Sort(sortField, field.sortOrder);
2905 NotifySort(master, this, field, mods);
2911 bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
2915 DataField field = (DataField)control.id;
2918 if(x < RESIZE_BORDER && field.prev)
2920 else if(x >= control.clientSize.w - RESIZE_BORDER);
2926 if(x < RESIZE_BORDER && fields.last)
2927 field = fields.last;
2939 if(style.freeSelect)
2944 this.rolledOver = this.dragging = false;
2951 bool OnLoadGraphics()
2953 display.FontExtent(fontObject, "W", 1, null, &fontH);
2954 if(!style.heightSet)
2956 rowHeight = Max(fontH + 2, 16) + (style.alwaysEdit ? 1 : 0);
2957 SetScrollLineStep(8, rowHeight);
2962 void OnApplyGraphics()
2964 SetScrollLineStep(8, rowHeight);
2968 for(field = fields.first; field; field = field.next)
2970 if(field.headButton)
2972 field.headButton.bevel = (!guiApp.textMode && !style.clearHeader);
2974 field.headButton.background = Color { 0, 170, 0 };
2978 OnResize(clientSize.w, clientSize.h);
2981 bool OnResizing(int *w, int *h)
2985 if(!initSize.w && (!anchor.left.type || !anchor.right.type) /**w*/)
2990 Font font = fontObject;
2991 Font boldFont = this.boldFont.font;
2992 Display display = this.display;
2994 for(row = rows.first; row; row = row.GetNextRow())
2996 Bitmap icon = row.icon ? row.icon.bitmap : null;
2997 int x = -scroll.x + EXTRA_SPACE / 2-1;
3001 for(parent = row.parent; parent; parent = parent.parent)
3005 if(style.treeBranch)
3011 if(style.rootCollapse) indent += 20;
3013 if(style.collapse && !(style.treeBranch)) x += 15;
3017 // Compute the rows size
3018 for(field = fields.first; field; field = field.next)
3020 if(((style.resizable && (!(style.alwaysEdit) || field.next)) || field.width) && !row.header)
3021 x += field.width - (field.prev ? 0 : indent);
3026 for(index = 0, cell = row.cells.first; index != field.index; index++, cell = cell.next);
3028 // Should always be as many cells in the row as fields in the listbox
3029 if(cell && cell.isSet && field.dataType)
3031 static char tempString[4096];
3034 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
3035 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data[0], tempString, field.userData, null);
3037 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data, tempString, field.userData, null);
3039 if(!string) string = "";
3040 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3043 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3045 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, &th);
3048 if(row.header) break;
3052 maxWidth = Max(maxWidth, x);
3058 *h = Min(this.maxShown, this.rowCount) * rowHeight;
3063 if(!*w) *w = rowHeight * 5;
3064 if(!*h) *h = rowHeight * 5;
3071 FontResource font = this.font;
3072 FontResource boldFont
3074 faceName = font.faceName, size = font.size, bold = true
3076 AddResource(boldFont);
3077 RemoveResource(this.boldFont);
3078 this.boldFont = boldFont;
3082 SetInitSize(initSize);
3085 bool OnMouseMove(int x, int y, Modifiers mods)
3087 bool isTimer = false;
3088 int realX = x, realY = y;
3090 if(insideNotifySelect) return true;
3092 if(style.alwaysEdit && style.resizable &&
3093 resizingField && !(mods.isSideEffect))
3096 DataField field = resizingField;
3097 field.width = this.startWidth + x - this.resizeX;
3098 field.width = Max(field.width, - EXTRA_SPACE);
3100 AdaptToFieldWidth(field, true);
3104 if(style.alwaysEdit && style.resizable)
3106 int vx = -scroll.x - 1;
3109 if(style.collapse && !(style.treeBranch))
3112 for(field = fields.first; field; field = field.next)
3114 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3115 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3121 cursor = guiApp.GetCursor(sizeWE);
3125 vx += width + EXTRA_SPACE;
3129 if((editData && editData.visible) || (style.alwaysEdit))
3132 if(x == MAXINT && y == MAXINT)
3139 // ADDED THIS CHECK FOR FieldDropBox LEAKS
3140 if(/*!mods.isSideEffect && */(this.rolledOver || !this.dragging))
3142 int rowY = (style.header) ? rowHeight : 0;
3150 ((vertScroll && vertScroll.visible &&
3151 (y < 0 || y >= clientSize.h)) ||
3152 (horzScroll && horzScroll.visible &&
3153 (x < 0 || x >= clientSize.w))))
3158 if(vertScroll && vertScroll.visible &&
3159 (y < 0 || y >= clientSize.h))
3160 vertScroll.Action((y<0)?up:down, 0, 0);
3161 if(horzScroll && horzScroll.visible &&
3162 (x < 0 || x >= clientSize.w))
3163 horzScroll.Action((x<0)?up:down, 0, 0);
3169 // This must be done after the scrolling took place
3170 rowIndex = firstRowShown ? firstRowShown.index : -1;
3172 y = Min(y, clientSize.h-1);
3173 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3182 if(row && currentRow != row)
3184 if(this.dragRow && style.moveRows)
3186 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3188 else if(style.multiSelect)
3191 for(thisRow = rows.first; thisRow; thisRow = thisRow.GetNextRow())
3192 if((thisRow.selectedFlag == selected || thisRow.selectedFlag == tempSelected) ||
3198 if(this.dropIndex != rowIndex)
3200 this.dropIndex = rowIndex;
3201 this.editRow = null;
3203 this.movedRow = true;
3206 else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || this.rolledOver))
3208 if(!(style.multiSelect))
3210 if(currentRow)currentRow.selectedFlag = unselected;
3211 if(row)row.selectedFlag = selected;
3215 if(style.multiSelect)
3219 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3221 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3222 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3225 if(rowIndex >= clickedRow.index)
3227 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3229 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3236 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3238 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3239 if(selRow == clickedRow)
3245 if(style.freeSelect)
3246 NotifyHighlight(master, this, currentRow, mods);
3249 insideNotifySelect = true;
3250 NotifySelect(master, this, currentRow, mods);
3251 insideNotifySelect = false;
3254 if(style.alwaysEdit && currentRow)
3255 currentRow.Edit(currentField);
3262 bool OnMouseOver(int x, int y, Modifiers mods)
3265 this.rolledOver = true;
3269 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
3271 // TOCHECK: WAS THIS MISSING ? CHECK FOR SLOWDOWN
3272 if(!active) Update(null);
3274 if(!active && (!swap || !swap.isModal))
3276 // true: destroy edit box
3277 HideEditBox(true, true, false);
3279 else if(!swap || !swap.isModal)
3281 // Bring back edit box
3282 if(currentRow && style.alwaysEdit)
3284 currentRow.Edit(currentField ? currentField : null);
3288 return true; //NotifyActivate(master, this, active, swap, 0);
3292 bool OnButtonDown(int x, int y, Modifiers mods, bool right)
3295 // Check to see if we're dragging the vertical divider
3296 if(style.alwaysEdit && style.resizable && !right)
3298 int vx = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
3301 if(style.collapse && !(style.treeBranch))
3304 for(field = fields.first; field; field = field.next)
3306 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3307 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3313 resizingField = field.prev;
3315 this.startWidth = resizingField.width;
3317 SetMouseRangeToClient();
3321 vx += width + EXTRA_SPACE;
3325 if(!(style.freeSelect))
3327 int rowY = (style.header) ? rowHeight : 0;
3329 int rowIndex = firstRowShown ? firstRowShown.index : -1;
3330 DataRow previousRow = currentRow;
3331 DataRow newCurrentRow = null;
3332 DataField newCurrentField = null;
3333 bool moveMultiple = false;
3334 int numSelected = 0;
3335 int rowStart = -scroll.x;
3337 if(style.multiSelect)
3344 for(row = rows.first; row; row = row.GetNextRow())
3346 if(row.selectedFlag == tempSelected)
3347 row.selectedFlag = selected;
3348 else if(row.selectedFlag == tempUnselected)
3349 row.selectedFlag = unselected;
3350 if(row.selectedFlag == selected)
3357 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3360 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3363 if(style.treeBranch)
3366 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3372 /* THIS WAS TOO STRICT:
3373 if(style.collapse && row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) &&
3374 (x >= rowStart + 3 + plusIndent && y >= rowY - rowHeight + PLUSY && x <= rowStart + 11 + plusIndent && y <= rowY - rowHeight + PLUSY + 8))
3376 if(style.collapse &&
3377 (x >= rowStart && y >= rowY - rowHeight && x <= rowStart + 18 + plusIndent && y <= rowY + rowHeight-1))
3379 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) && x >= plusIndent)
3380 row.collapsed = !row.collapsed;
3387 newCurrentRow = row;
3389 if(style.multiSelect)
3391 // Deselect everything if user didn't clicked on a row
3395 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3396 selRow.selectedFlag = unselected;
3398 //this.clickedRowIndex = rowIndex;
3400 else if(style.moveRows && !(mods.shift) &&
3401 (row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
3402 !right && !(mods.isActivate))
3403 moveMultiple = true;
3409 if(row.selectedFlag == tempUnselected || row.selectedFlag == unselected)
3411 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3412 selRow.selectedFlag = unselected;
3413 row.selectedFlag = selected;
3416 //this.clickedRowIndex = rowIndex;
3422 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3423 selRow.selectedFlag = unselected;
3427 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3429 if(selRow != clickedRow)
3431 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3432 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3439 if(rowIndex >= clickedRow.index)
3441 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3445 if(selRow != clickedRow)
3447 if(selRow.selectedFlag)
3448 selRow.selectedFlag = tempUnselected;
3450 selRow.selectedFlag = tempSelected;
3454 selRow.selectedFlag = selected;
3461 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3465 if(selRow != clickedRow)
3467 if(selRow.selectedFlag)
3468 selRow.selectedFlag = tempUnselected;
3470 selRow.selectedFlag = tempSelected;
3474 selRow.selectedFlag = selected;
3475 if(selRow == clickedRow)
3484 if(row.selectedFlag)
3485 row.selectedFlag = tempUnselected;
3486 else row.selectedFlag = tempSelected;
3489 row.selectedFlag = tempSelected;
3491 //this.clickedRowIndex = rowIndex;
3501 // true: destroy edit box
3504 incref newCurrentRow;
3507 if(currentRow != newCurrentRow)
3508 HideEditBox(true, true, false);
3512 if(newCurrentRow._refCount <= 1)
3513 delete newCurrentRow;
3515 newCurrentRow._refCount--;
3520 if(!(style.multiSelect))
3522 if(currentRow) currentRow.selectedFlag = unselected;
3523 if(newCurrentRow) newCurrentRow.selectedFlag = selected;
3527 if(currentRow != newCurrentRow)
3530 // true: destroy edit box
3533 //incref newCurrentRow;
3534 incref newCurrentRow;
3537 HideEditBox(true, true, false);
3542 int headerSize = ((style.header) ? rowHeight : 0);
3543 int height = clientSize.h + 1 - headerSize;
3545 /*if(newCurrentRow._refCount <= 1)
3546 delete newCurrentRow;
3549 newCurrentRow._refCount--;
3550 //newCurrentRow._refCount--;
3553 currentRow = newCurrentRow;
3555 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
3556 SetScrollPosition(scroll.x,
3557 currentRow.index * rowHeight - height + rowHeight);
3558 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
3560 int line = currentRow ? currentRow.index * rowHeight : 0;
3561 //SNAPUP(line, rowHeight);
3562 SetScrollPosition(scroll.x, line);
3565 // GO THROUGH SetCurrentRow eventually?
3566 // SetCurrentRow(newCurrentRow, true);
3570 if(style.freeSelect)
3571 NotifyHighlight(master, this, currentRow, mods);
3572 else if((moveMultiple || (!(style.multiSelect) && previousRow == currentRow)) &&
3573 newCurrentRow && !(mods.shift))
3577 if(!(mods.isActivate))
3581 this.dragRow = currentRow;
3582 this.dropIndex = -1;
3583 this.movedRow = false;
3585 if(editData && editData.visible && style.alwaysEdit)
3592 if(style.collapse && !style.treeBranch)
3595 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3597 indent += (style.treeBranch) ? 20 : 15;
3600 for(field = fields.first; field; field = field.next)
3602 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3603 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3605 if(!field.prev) width -= indent;
3606 if(x >= sx && x < sx + width)
3610 if(field == currentField)
3611 editData.Deactivate();
3614 currentRow.Edit(field);
3615 editData.Activate();
3618 else if(!(mods.ctrl) && numSelected <= 1)
3619 this.editRow = currentRow;
3621 if(style.noDragging && newCurrentRow)
3622 NotifyReclick(master, this, newCurrentRow, mods);
3626 // If the user clicked exactly on the edited field,
3628 if(editData && editData.visible && newCurrentRow)
3630 DataField field, whichField;
3634 if(style.collapse && !(style.treeBranch))
3637 whichField = currentField;
3641 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3643 indent += (style.treeBranch) ? 20 : 15;
3647 for(field = fields.first; field; field = field.next)
3649 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3650 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3651 if(!field.prev) width -= indent;
3652 if(x >= sx && x < sx + width && newCurrentRow)
3657 if(field) //x >= sx && x < sx + width && newCurrentRow)
3659 if(field == currentField)
3660 editData.Activate();
3662 newCurrentRow.Edit(currentField);*/
3664 else if(style.noDragging && newCurrentRow)
3665 NotifyReclick(master, this, newCurrentRow, mods);
3667 else if(style.noDragging && newCurrentRow)
3668 NotifyReclick(master, this, newCurrentRow, mods);
3674 result = NotifySelect(master, this,
3675 currentRow ? currentRow : null, mods);
3676 if(result && style.alwaysEdit && currentRow)
3680 DataField field = null;
3685 if(style.collapse && !style.treeBranch)
3688 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3690 indent += (style.treeBranch) ? 20 : 15;
3693 for(field = fields.first; field; field = field.next)
3695 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3696 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3698 if(!field.prev) width -= indent;
3699 if(x >= sx && x < sx + width)
3701 currentField = field;
3707 currentRow.Edit(currentField);
3709 // If the user clicked exactly on the edited field,
3711 if(editData && editData.visible && newCurrentRow)
3715 editData.Activate();
3717 else if(style.noDragging && newCurrentRow)
3718 NotifyReclick(master, this, newCurrentRow, mods);
3721 else if(style.noDragging && newCurrentRow)
3722 NotifyReclick(master, this, newCurrentRow, mods);
3726 For drop box to capture...
3729 if(x < 0 || y < 0 || x >= clientSize.w || y >= clientSize.h)
3732 master.parent.Activate();
3741 if(!style.noDragging)
3743 this.dragging = true;
3746 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h)
3747 this.rolledOver = true;
3752 this.dragging = false;
3753 OnLeftButtonUp(x, y, mods);
3758 bool OnLeftButtonDown(int x, int y, Modifiers mods)
3760 return OnButtonDown(x,y, mods, false);
3763 bool OnLeftButtonUp(int x, int y, Modifiers mods)
3765 if(resizingField && style.alwaysEdit)
3767 Window::FreeMouseRange();
3769 resizingField = null;
3772 if(dragRow || editRow)
3774 DataRow row, switchRow = rows.last;
3775 int rowY = (style.header) ? rowHeight : 0;
3776 for(row = firstRowShown; row; row = row.GetNextRow())
3785 if(this.editRow == switchRow && y >= 0)
3790 for(field = fields.first; field; field = field.next)
3792 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3793 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3796 if(fieldX > x + scroll.x)
3800 if(field && field.editable)
3802 // true: destroy edit box
3803 HideEditBox(true, true, false);
3804 PopupEditBox(field, false);
3806 else if(!style.noDragging)
3807 NotifyReclick(master, this, currentRow, mods);
3809 else if(style.moveRows && switchRow)
3811 if(this.dragRow == switchRow && this.movedRow == false)
3813 DataRow row = this.dragRow;
3817 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3818 selRow.selectedFlag = unselected;
3822 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3824 if(selRow != clickedRow)
3826 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3827 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3833 if(row.selectedFlag)
3834 row.selectedFlag = tempUnselected;
3835 else row.selectedFlag = tempSelected;
3838 row.selectedFlag = tempSelected;
3843 if(style.multiSelect)
3845 if(!switchRow.selectedFlag)
3847 bool foundSwitch = false;
3850 DataRow afterRow = switchRow.prev;
3851 for(row = rows.first; row; row = next)
3853 next = row.GetNextRow();
3854 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3856 if(!foundSwitch && !after)
3859 afterRow = switchRow;
3861 if(!after || !(row.selectedFlag == selected || row.selectedFlag == tempSelected) ||
3868 else if(row == switchRow)
3875 for(row = rows.first; row; row = row.GetNextRow())
3877 if(row == switchRow || row == this.dragRow)
3881 // Switch row first: move before
3882 if(row == switchRow)
3884 if(NotifyMove(master, this, switchRow.prev, mods))
3885 dragRow.Move(switchRow.prev);
3887 // Dragged row first: move after
3890 if(NotifyMove(master, this, switchRow, mods))
3891 dragRow.Move(switchRow);
3904 if(this.dragging || style.freeSelect)
3908 this.rolledOver = this.dragging = false;
3910 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h && currentRow && style.freeSelect)
3914 result = NotifySelect(master, this, currentRow, mods);
3915 if(style.alwaysEdit)
3916 currentRow.Edit(currentField);
3920 // if(!(style.freeSelect))
3926 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
3928 int rowStart = -scroll.x;
3930 int rowY = (style.header) ? rowHeight : 0;
3933 OnLeftButtonUp(x,y,mods);
3934 if(style.alwaysEdit)
3936 if(!(style.collapse) || x > 15)
3937 if(editData && editData.visible)
3939 editData.Activate();
3940 NotifyDoubleClick(master, this, x, y, mods);
3944 for(row = firstRowShown; row; row = row.GetNextRow())
3947 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3949 if(style.treeBranch)
3952 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3961 if((row && style.collapse && (x >= rowStart && x <= rowStart + 18 + plusIndent)) ||
3962 NotifyDoubleClick(master, this, x, y, mods))
3966 if(row && row.subRows.first)
3968 row.collapsed = !row.collapsed;
3972 // We need to return true here so that OnLeftButtonDown can popup the DataBox Editors
3978 bool OnRightButtonDown(int x, int y, Modifiers mods)
3980 return OnButtonDown(x,y, mods, true);
3983 bool OnRightButtonUp(int x, int y, Modifiers mods)
3985 OnLeftButtonUp(x,y,mods);
3986 return NotifyRightClick(master, this, x, y, mods);
3989 bool GoToLetter(unichar ch, bool keyHit)
3991 bool result = false;
3993 bool checkNextField = true;
3994 int len = keyHit ? 0 : strlen(typedString);
3996 typedString = renew typedString char[len + 2];
3997 typedString[len++] = (char)tolower(ch); // TODO: FIX UNICODE
3998 typedString[len] = '\0';
4000 for(field = fields.first; field; field = field.next)
4002 DataRow startRow = currentRow ? currentRow : rows.first;
4004 if(startRow && field.dataType && field.dataType._vTbl[__ecereVMethodID_class_OnGetString] && ch)
4007 bool looped = false;
4008 if(len == 1 && currentRow)
4009 startRow = (next = startRow.GetNextRow(), (next ? next : rows.first));
4011 for(row = startRow; row != startRow || !looped; next = row.GetNextRow(), row = next ? next : rows.first)
4013 void * data = row.GetData(field);
4014 char tempString[1024] = "";
4015 bool needClass = false;
4016 char * string = data ? (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass) : null;
4018 if(string && string[0])
4019 checkNextField = false;
4020 if(string && string[0] && !strnicmp(string, typedString, len))
4022 if(style.multiSelect)
4025 bool foundRow = false;
4027 //this.clickedRowIndex = 0;
4029 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4031 if(selRow == row) foundRow = true;
4032 selRow.selectedFlag = unselected;
4033 //if(!foundRow) this.clickedRowIndex++;
4035 row.selectedFlag = selected;
4037 SetCurrentRow(row, true);
4044 if(this.typingTimeOut && !keyHit)
4045 typingTimer.Start();
4046 if(!result || !this.typingTimeOut || keyHit)
4047 typedString[len-1] = '\0';
4049 if(!checkNextField || result) break;
4054 bool OnKeyDown(Key key, unichar ch)
4058 if(key == enter || key == keyPadEnter)
4060 if(editData && editData.visible && editData.active)
4062 HideEditBox(true, false, false);
4066 else if(key == escape)
4068 if(resizingField || this.movingFields || (editData && editData.visible) || this.dragRow)
4070 if(editData && editData.visible && style.alwaysEdit && !editData.active)
4072 // false: dont destroy edit box
4073 HideEditBox(false, false, false);
4076 resizingField.width = this.startWidth;
4077 AdaptToFieldWidth(resizingField, true);
4078 resizingField = null;
4081 this.dragRow = null;
4084 this.dragging = false;
4088 this.movingFields = false;
4089 draggingField = null;
4095 if(!currentField || !currentField.editable)
4096 for(field = fields.first; field; field = field.next)
4100 currentField = field;
4104 if(key == f2 && currentField && currentField.editable)
4106 PopupEditBox(currentField, false);
4107 if(editData && editData.visible)
4109 if(style.alwaysEdit)
4110 editData.Activate();
4115 if(!NotifyKeyDown(master, this, currentRow, key, ch))
4118 // Editable fields...
4121 if(style.alwaysEdit && editData && editData.visible)
4122 return editData.OnKeyDown(key, ch);
4123 return true; // We want to pick up the OnKeyHit to replace contents, but skip GoToLetter
4126 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, false))
4128 /*if(inactive && window.state != Hidden)
4129 NotifyHighlight(master, this, currentRow, 0);
4132 NotifySelect(master, this, currentRow, 0);
4139 bool OnKeyHit(Key key, unichar ch)
4141 if(key.code == up && key.alt == true && key.ctrl == false && key.shift == false)
4144 if(!ch && !key.alt && !key.ctrl)
4146 key.code = (SmartKey)key.code;
4148 if(ch >= 32 && !key.alt && !key.ctrl && ch != 128)
4151 if(!currentField || !currentField.editable)
4152 for(field = fields.first; field; field = field.next)
4156 currentField = field;
4160 if(currentField && currentField.editable)
4162 if((!editData || !editData.visible) || !editData.active)
4164 PopupEditBox(currentField, false);
4165 if(editData && editData.visible)
4167 editData.Activate();
4168 editData.OnKeyHit(key, ch);
4175 if(!(style.multiSelect) && (key.ctrl))
4178 if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
4184 if(style.alwaysEdit)
4189 for(field = currentField.prev; field; field = field.prev)
4193 currentField = field;
4194 HideEditBox(true, true, false);
4195 PopupEditBox(currentField, false);
4201 if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
4203 if(currentRow.subRows.first && !currentRow.collapsed)
4205 currentRow.collapsed = true;
4207 else if(currentRow.parent)
4208 SetCurrentRow(currentRow.parent, true);
4213 if(style.collapse && currentRow && currentRow.subRows.first)
4215 if(currentRow.collapsed)
4216 currentRow.collapsed = false;
4218 SetCurrentRow(currentRow.subRows.first, true);
4221 else if(style.alwaysEdit)
4226 for(field = currentField.next; field; field = field.next)
4230 currentField = field;
4231 HideEditBox(true, true, false);
4232 PopupEditBox(currentField, false);
4240 case pageDown: case pageUp:
4241 case end: case home:
4243 int headerSize = ((style.header) ? rowHeight : 0);
4244 int height = clientSize.h + 1 - headerSize;
4247 // true: destroy edit box
4248 // !!! TESTING true HERE !!!
4249 HideEditBox(true, true, false);
4250 // HideEditBox(false, true, false);
4252 oldRow = currentRow;
4254 SNAPDOWN(height, rowHeight);
4255 if((!currentRow || key.code == home) && key.code != end)
4257 currentRow = rows.first;
4265 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4268 next = currentRow.GetNextRow();
4275 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4278 next = currentRow.GetPrevRow();
4286 currentRow = lastRow.GetLastRow();
4292 currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
4293 c++, currentRow = next);
4300 currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
4301 c++, currentRow = next);
4306 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
4307 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
4308 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
4309 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
4311 if(style.multiSelect)
4315 if(!(key.shift) && (key.ctrl))
4318 for(row = rows.first; row; row = row.GetNextRow())
4320 if(row.selectedFlag == tempSelected)
4321 row.selectedFlag = selected;
4322 else if(row.selectedFlag == tempUnselected)
4323 row.selectedFlag = unselected;
4329 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4330 selRow.selectedFlag = unselected;
4334 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4336 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
4337 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
4343 if(currentRow.index >= clickedRow.index)
4345 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
4349 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4352 selRow.selectedFlag = selected;
4353 if(selRow == currentRow)
4359 for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
4363 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4366 selRow.selectedFlag = selected;
4367 if(selRow == clickedRow)
4374 if(!(key.ctrl) && currentRow)
4376 currentRow.selectedFlag = selected;
4379 clickedRow = currentRow;
4384 if(oldRow) oldRow.selectedFlag = unselected;
4385 if(currentRow) currentRow.selectedFlag = selected;
4390 if(style.freeSelect)
4391 NotifyHighlight(master, this, currentRow, 0);
4393 NotifySelect(master, this, currentRow, 0);
4395 if(style.alwaysEdit && currentRow)
4396 currentRow.Edit(currentField /*null*/);
4403 if(style.multiSelect && currentRow)
4405 if(currentRow.selectedFlag)
4408 currentRow.selectedFlag = unselected;
4411 currentRow.selectedFlag = selected;
4414 if(style.freeSelect)
4415 NotifyHighlight(master, this, currentRow, 0);
4417 NotifySelect(master, this, currentRow, 0);
4423 if(!NotifyKeyHit(master, this, currentRow, key, ch))
4426 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, true))
4428 /*if(inactive && window.state != Hidden)
4429 return NotifyHighlight(master, this, currentRow, 0);
4432 return NotifySelect(master, this, currentRow, 0);
4440 void OnHScroll(ScrollBarAction action, int position, Key key)
4445 void OnVScroll(ScrollBarAction action, int position, Key key)
4450 for(firstRowShown = rows.first; firstRowShown; firstRowShown = next)
4452 next = firstRowShown.GetNextRow();
4453 if(y >= position || !next) break;
4463 DataRow firstRowShown;
4467 DataField sortField;
4471 double typingTimeOut;
4484 if(guiApp.GetKeyState(shift)) mods.shift = true;
4485 if(guiApp.GetKeyState(alt)) mods.alt = true;
4486 if(guiApp.GetKeyState(control)) mods.ctrl = true;
4487 OnMouseMove(MAXINT, MAXINT, mods);
4495 delay = 0.5; // typingTimeOut
4500 typedString[0] = '\0';
4502 // The next line was commented... Why? When commented typing words stops working ( only first character jumps )
4508 bool dragging, rolledOver;
4517 // For editing fields
4519 DataField currentField;
4522 // For moving fields
4523 DataField draggingField, dropField;
4526 // For resizing fields
4527 DataField resizingField;
4528 int resizeX, oldX, startWidth;
4531 FontResource boldFont;
4534 // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
4535 bool insideNotifySelect;
4536 Color selectionColor, selectionText, stippleColor;
4537 stippleColor = 0xFFFFFF80;