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;
2291 bool lastWasHeader = row.header;
2293 for(parent = row.parent; parent; parent = parent.parent)
2295 if(!parent.header || lastWasHeader)
2297 if(style.treeBranch)
2303 if(style.rootCollapse) indent += 20;
2306 dataDisplayFlags.fullRow = style.fullRowSelect;
2307 dataDisplayFlags.active = isActive;
2308 dataDisplayFlags.header = row.header;
2313 collapseRowStart = rowStart;
2315 if(!(style.treeBranch))
2322 if(style.multiSelect)
2324 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2325 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2329 dataDisplayFlags.selected = row.selectedFlag == selected || row.selectedFlag == tempSelected;
2330 dataDisplayFlags.current = row == currentRow || (!currentRow && row == firstRowShown);
2332 if(row == currentRow)
2334 dataDisplayFlags.current = true;
2335 dataDisplayFlags.selectedFlag = true;
2337 else if(!currentRow && row == firstRowShown)
2339 dataDisplayFlags.current = true;
2343 surface.TextOpacity(true);
2345 background = this.background;
2346 foreground = this.foreground;
2348 // Draw the current row background
2351 background = formColor;
2352 surface.SetBackground(formColor);
2353 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - 1);
2354 foreground = branchesColor;
2356 else if(dataDisplayFlags.selected)
2358 if(dataDisplayFlags.selected && (isActive || style.alwaysHL || (style.alwaysEdit && style.fullRowSelect)))
2360 if(!isActive && style.alwaysEdit)
2361 background = formColor;
2363 background = selectionColor ? selectionColor : SELECTION_COLOR;
2364 if(style.fullRowSelect)
2366 int offset = (style.alwaysEdit) ? 2 : 1;
2367 surface.SetBackground(background);
2368 surface.Area(rowStart, y, clientSize.w, (y + rowHeight) - offset);
2370 if(isActive || !(style.alwaysEdit))
2371 foreground = selectionText ? selectionText : SELECTION_TEXT;
2373 foreground = branchesColor;
2379 surface.Blit(icon, x + (20 - icon.width) /2,y + 2,0,0, icon.width, icon.height);
2385 int width = clientSize.w;
2387 dataDisplayFlags.firstField = true;
2388 clip.left = x - EXTRA_SPACE / 2+1;
2390 clip.right = x + width - EXTRA_SPACE/2 - 0;
2391 clip.bottom = y + rowHeight - 1;
2392 surface.Clip(&clip);
2394 surface.TextFont(font);
2396 surface.SetForeground(foreground);
2397 surface.SetBackground(background);
2399 class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), "(none)", surface, x, y - 1 + (rowHeight - fontH)/2, width - EXTRA_SPACE/2, null, Alignment::left, dataDisplayFlags);
2403 if(!opacity) surface.TextOpacity(false);
2405 for(field = fields.first; field; field = field.next)
2408 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2409 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2411 // Box clip = { x, y+1, x + field.width - EXTRA_SPACE - 1, y + rowHeight - 2 };
2414 //width -= EXTRA_SPACE;
2416 if(!field.prev) width -= indent;
2419 dataDisplayFlags.firstField = field.prev ? false : true;
2421 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2423 background = this.background;
2424 foreground = this.foreground;
2427 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable && opacity)
2430 surface.SetBackground(background);
2431 surface.Area(x-3, y, x+width-1, y + rowHeight-2);
2434 clip.left = x - EXTRA_SPACE / 2+1;
2436 clip.right = x + width - EXTRA_SPACE/2 - 0;
2437 clip.bottom = y + rowHeight - 1;
2438 surface.Clip(&clip);
2440 for(index = 0, cell = row.cells.first; cell && index != field.index; index++, cell = cell.next);
2441 // Should always be as many cells in the row as fields in the listbox
2442 if(cell && cell.isSet && field.dataType)
2445 surface.TextFont(boldFont);
2447 surface.TextFont(font);
2449 surface.SetForeground(foreground);
2450 surface.SetBackground(background);
2452 if(field.dataType.type == noHeadClass || field.dataType.type == normalClass)
2453 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);
2455 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);
2458 if(!isActive && dataDisplayFlags.selected && style.alwaysEdit && field.editable)
2459 background = formColor;
2461 if(!dataDisplayFlags.firstField && !dataDisplayFlags.fullRow)
2463 background = formColor;
2464 foreground = this.background;
2467 x += width;// + EXTRA_SPACE;
2469 if(row.header) break;
2475 int plusIndent = (style.treeBranch) ? (indent - 20 + 4) : indent;
2477 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)))
2479 surface.SetForeground(row.header ? headerCollapseForeground : this.foreground);
2480 surface.Rectangle(collapseRowStart + 3 + plusIndent, y + PLUSY, collapseRowStart + 11 + plusIndent, y + PLUSY + 8);
2482 surface.SetBackground(row.header ? (formColor) : (this.background)); //white
2483 surface.Area(collapseRowStart + 4 + plusIndent, y + PLUSY + 1, collapseRowStart + 10 + plusIndent, y + PLUSY + 7);
2485 surface.HLine(collapseRowStart + 5 + plusIndent, collapseRowStart + 9 + plusIndent, y+PLUSY+4);
2487 surface.VLine(y + PLUSY + 2, y + PLUSY + 6, collapseRowStart + 7 + plusIndent);
2492 // Draw the current row stipple
2493 if(style.fullRowSelect && !(style.alwaysEdit) && (dataDisplayFlags.current) && isActive)
2498 surface.LineStipple(0x5555);
2499 if(dataDisplayFlags.selected)
2500 surface.SetForeground(stippleColor);
2502 surface.SetForeground(this.foreground);
2505 surface.SetForeground(selectionColor ? selectionColor : SELECTION_COLOR);
2506 surface.Rectangle(0, y, clientSize.w-1, (y + rowHeight) - 1);
2507 surface.LineStipple(0);
2511 if(y >= clientSize.h)
2514 if(firstRowShown) surface.Clip(null);
2515 if(this.dragRow && this.dropIndex != -1)
2517 int dropIndex = this.dropIndex;
2520 if(!style.multiSelect && currentRow.index < this.dropIndex)
2522 surface.DrawingChar(223);
2524 y = style.header ? rowHeight : 0;
2525 y += dropIndex * rowHeight - scroll.y;
2527 surface.SetForeground(Color { 85, 85, 255 });
2528 surface.HLine(0, clientSize.w-1, y);
2529 surface.HLine(0, clientSize.w-1, y + 1);
2533 void OnDrawOverChildren(Surface surface)
2535 if(draggingField && this.dropField)
2537 int position = this.dropField.x;
2538 if(draggingField.x < position)
2539 position += this.dropField.width + EXTRA_SPACE;
2541 surface.SetForeground(Color { 85, 85, 255 });
2542 surface.VLine(0, rowHeight - 1, position - scroll.x - 2);
2543 surface.VLine(0, rowHeight - 1, position - scroll.x);
2545 if(sortField && !style.clearHeader && style.header)
2547 DataField field = sortField;
2548 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2549 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2552 surface.TextExtent(field.header, strlen(field.header), &tw, &th);
2553 if(tw < width - EXTRA_SPACE)
2555 bool up = field.sortOrder == 1;
2559 field.x + 2 - scroll.x, 0,
2560 field.x + width + EXTRA_SPACE - 1 - scroll.x, rowHeight
2562 surface.Clip(&clip);
2563 if(field.alignment == left || field.alignment == center)
2565 if(field.alignment == center)
2566 x = field.x + (width + EXTRA_SPACE - tw) / 2 + tw + EXTRA_SPACE + 4;
2568 x = field.x + tw + EXTRA_SPACE + 4;
2570 x = Min(x, field.x + width - 4);
2572 else if(field.alignment == right)
2574 x = field.x + width - tw - EXTRA_SPACE - 4;
2575 x = Max(x, field.x + 2);
2581 // surface.SetForeground((wmenu.selectedFlag == item) ? white : black);
2582 // surface.WriteText(clientSize.w-8, y+(wmenu.rh - 8)/2, "\020", 1);
2588 surface.SetForeground(Color { 128,128,128 } );
2589 surface.DrawLine(x + 3, y, x, y + 5);
2590 surface.PutPixel(x + 1, y + 5);
2591 surface.PutPixel(x + 1, y + 3);
2592 surface.PutPixel(x + 2, y + 1);
2594 surface.SetForeground(white);
2595 surface.DrawLine(x + 4, y, x + 7, y + 5);
2596 surface.PutPixel(x + 6, y + 5);
2597 surface.PutPixel(x + 6, y + 3);
2598 surface.PutPixel(x + 5, y + 1);
2600 surface.DrawLine(x, y + 6, x + 7, y + 6);
2604 surface.SetForeground(Color { 128,128,128 });
2605 surface.DrawLine(x + 3, y+6, x, y+1);
2606 surface.PutPixel(x + 1, y+1);
2607 surface.PutPixel(x + 1, y+3);
2608 surface.PutPixel(x + 2, y+5);
2610 surface.SetForeground(white);
2611 surface.DrawLine(x + 4, y+6, x + 7, y+1);
2612 surface.PutPixel(x + 6, y+1);
2613 surface.PutPixel(x + 6, y+3);
2614 surface.PutPixel(x + 5, y+5);
2616 surface.DrawLine(x, y, x + 7, y);
2625 void OnResize(int w, int h)
2628 bool showEndBevel = false;
2630 if(style.collapse && !style.treeBranch)
2632 for(field = fields.first; field; field = field.next)
2634 int width = field.width + EXTRA_SPACE;
2642 (rowCount * rowHeight) +
2643 ((style.header) ? rowHeight : 0) -
2644 ((!((clientSize.h+1) % rowHeight)) ? rowHeight : 0), true);
2646 for(field = fields.first; field; field = field.next)
2648 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
2649 clientSize.w - field.x : (field.width + EXTRA_SPACE);
2650 if(style.header && field.headButton)
2652 showEndBevel = true;
2655 field.headButton.position = { field.x, 0 };
2656 field.headButton.size = { width, rowHeight };
2657 field.headButton.visible = true;
2660 field.headButton.visible = false;
2664 if(!style.fillLastField && showEndBevel && endBevel)
2666 endBevel.position = { x, 0 };
2667 endBevel.size = { clientSize.w + 2 - x, rowHeight };
2668 endBevel.visible = true;
2671 endBevel.visible = false;
2673 if(style.alwaysEdit && editData && editData.visible)
2675 HideEditBox(true, false, true);
2679 void AdaptToFieldWidth(DataField field, bool doScroll)
2681 OnResize(clientSize.w, clientSize.h);
2683 // Scroll appropriately
2686 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2687 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2689 SetScrollPosition(field.x + field.width + EXTRA_SPACE - clientSize.w, scroll.y);
2691 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2693 SetScrollPosition(field.x, scroll.y);
2698 bool HeaderPushed(Button control, int x, int y, Modifiers mods)
2700 DataField field = (DataField)control.id;
2701 // false: dont destroy edit box
2702 HideEditBox(true, false, true);
2703 if(style.resizable && ((!field && x < RESIZE_BORDER && fields.last) ||
2704 (field && x < RESIZE_BORDER && field.prev) ||
2705 (field && x >= control.clientSize.w - RESIZE_BORDER)))
2708 field = fields.last;
2709 else if(x < RESIZE_BORDER && field.prev)
2712 resizingField = field;
2713 this.resizeX = x + control.position.x;
2714 this.startWidth = field.width;
2715 this.oldX = x - scroll.x;
2720 draggingField = field;
2721 if(style.moveFields)
2722 field.headButton.stayDown = true;
2723 else if(!style.sortable)
2731 bool HeaderMouseMove(Button control, int x, int y, Modifiers mods)
2736 DataField field = resizingField;
2738 x += control.position.x;
2740 // Tweak to prevent shrinking field if we're actually moving right
2741 if(x - scroll.x > this.oldX &&
2742 this.startWidth + x - this.resizeX < field.width)
2744 this.oldX = x - scroll.x;
2747 this.oldX = x - scroll.x;
2749 field.width = this.startWidth + x - this.resizeX;
2750 field.width = Max(field.width, - EXTRA_SPACE);
2752 AdaptToFieldWidth(field, true);
2754 else if(draggingField)
2756 x += control.position.x;
2757 if(style.moveFields)
2759 DataField field = fields.last;
2761 for(field = fields.first; field; field = field.next)
2763 fieldX += ((field.width || style.resizable) ?
2764 field.width : clientSize.w) + EXTRA_SPACE;
2768 if(draggingField == field)
2770 // Reset scroll position
2771 if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x &&
2772 field.x >= field.x + field.width + EXTRA_SPACE - clientSize.w)
2775 field.x + field.width + EXTRA_SPACE - clientSize.w,
2778 else if(field.x + field.width + EXTRA_SPACE - clientSize.w > scroll.x ||
2780 SetScrollPosition(field.x, scroll.y);
2783 if(this.dropField != field)
2785 this.dropField = field;
2788 int position = field.x;
2790 if(draggingField.x < position)
2792 position += field.width + EXTRA_SPACE - clientSize.w;
2793 if(position > scroll.x)
2794 SetScrollPosition(position, scroll.y);
2799 if(position < scroll.x)
2800 SetScrollPosition(position, scroll.y);
2803 this.movingFields = true;
2809 else if(style.resizable)
2811 DataField field = (DataField)control.id;
2814 if(x < RESIZE_BORDER && field.prev)
2815 control.cursor = guiApp.GetCursor(sizeWE);
2816 else if(x >= control.clientSize.w - RESIZE_BORDER)
2817 control.cursor = guiApp.GetCursor(sizeWE);
2819 control.cursor = null;
2823 if(x < RESIZE_BORDER && fields.last)
2824 control.cursor = guiApp.GetCursor(sizeWE);
2826 control.cursor = null;
2832 bool HeaderReleased(Button control, int x, int y, Modifiers mods)
2836 NotifyResized(master, this, resizingField, mods);
2837 resizingField = null;
2844 if(style.moveFields)
2849 DataField switchField = fields.last;
2853 x += draggingField.x;
2854 for(field = fields.first; field; field = field.next)
2856 fieldX += ((field.width || style.resizable) ?
2857 field.width : clientSize.w) + EXTRA_SPACE;
2860 switchField = field;
2864 if(switchField && draggingField != switchField && this.dropField)
2866 for(field = fields.first; field; field = field.next)
2868 if(field == switchField || field == draggingField)
2872 // Switch field first: move before
2873 if(field == switchField)
2874 draggingField.Move(switchField.prev);
2875 // Dragged field first: move after
2877 draggingField.Move(switchField);
2879 NotifyMovedField(master, this, draggingField, mods);
2881 draggingField.headButton.stayDown = false;
2886 movingFields = false;
2888 draggingField = null;
2894 bool HeaderClicked(Button control, int x, int y, Modifiers mods)
2896 if(style.header && !this.dropField && style.sortable)
2898 DataField field = (DataField)control.id;
2899 if(sortField == field)
2900 field.sortOrder *= -1;
2905 Sort(sortField, field.sortOrder);
2906 NotifySort(master, this, field, mods);
2912 bool HeaderDoubleClicked(Button control, int x, int y, Modifiers mods)
2916 DataField field = (DataField)control.id;
2919 if(x < RESIZE_BORDER && field.prev)
2921 else if(x >= control.clientSize.w - RESIZE_BORDER);
2927 if(x < RESIZE_BORDER && fields.last)
2928 field = fields.last;
2940 if(style.freeSelect)
2945 this.rolledOver = this.dragging = false;
2952 bool OnLoadGraphics()
2954 display.FontExtent(fontObject, "W", 1, null, &fontH);
2955 if(!style.heightSet)
2957 rowHeight = Max(fontH + 2, 16) + (style.alwaysEdit ? 1 : 0);
2958 SetScrollLineStep(8, rowHeight);
2963 void OnApplyGraphics()
2965 SetScrollLineStep(8, rowHeight);
2969 for(field = fields.first; field; field = field.next)
2971 if(field.headButton)
2973 field.headButton.bevel = (!guiApp.textMode && !style.clearHeader);
2975 field.headButton.background = Color { 0, 170, 0 };
2979 OnResize(clientSize.w, clientSize.h);
2982 bool OnResizing(int *w, int *h)
2986 if(!initSize.w && (!anchor.left.type || !anchor.right.type) /**w*/)
2991 Font font = fontObject;
2992 Font boldFont = this.boldFont.font;
2993 Display display = this.display;
2995 for(row = rows.first; row; row = row.GetNextRow())
2997 Bitmap icon = row.icon ? row.icon.bitmap : null;
2998 int x = -scroll.x + EXTRA_SPACE / 2-1;
3002 for(parent = row.parent; parent; parent = parent.parent)
3006 if(style.treeBranch)
3012 if(style.rootCollapse) indent += 20;
3014 if(style.collapse && !(style.treeBranch)) x += 15;
3018 // Compute the rows size
3019 for(field = fields.first; field; field = field.next)
3021 if(((style.resizable && (!(style.alwaysEdit) || field.next)) || field.width) && !row.header)
3022 x += field.width - (field.prev ? 0 : indent);
3027 for(index = 0, cell = row.cells.first; index != field.index; index++, cell = cell.next);
3029 // Should always be as many cells in the row as fields in the listbox
3030 if(cell && cell.isSet && field.dataType)
3032 static char tempString[4096];
3035 if(field.dataType.type == normalClass || field.dataType.type == noHeadClass)
3036 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data[0], tempString, field.userData, null);
3038 string = (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, cell.data, tempString, field.userData, null);
3040 if(!string) string = "";
3041 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3044 display.FontExtent(row.header ? boldFont : font, string, strlen(string), &tw, &th);
3046 display.FontExtent(row.header ? boldFont : font, "", 0, &tw, &th);
3049 if(row.header) break;
3053 maxWidth = Max(maxWidth, x);
3059 *h = Min(this.maxShown, this.rowCount) * rowHeight;
3064 if(!*w) *w = rowHeight * 5;
3065 if(!*h) *h = rowHeight * 5;
3072 FontResource font = this.font;
3073 FontResource boldFont
3075 faceName = font.faceName, size = font.size, bold = true
3077 AddResource(boldFont);
3078 RemoveResource(this.boldFont);
3079 this.boldFont = boldFont;
3083 SetInitSize(initSize);
3086 bool OnMouseMove(int x, int y, Modifiers mods)
3088 bool isTimer = false;
3089 int realX = x, realY = y;
3091 if(insideNotifySelect) return true;
3093 if(style.alwaysEdit && style.resizable &&
3094 resizingField && !(mods.isSideEffect))
3097 DataField field = resizingField;
3098 field.width = this.startWidth + x - this.resizeX;
3099 field.width = Max(field.width, - EXTRA_SPACE);
3101 AdaptToFieldWidth(field, true);
3105 if(style.alwaysEdit && style.resizable)
3107 int vx = -scroll.x - 1;
3110 if(style.collapse && !(style.treeBranch))
3113 for(field = fields.first; field; field = field.next)
3115 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3116 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3122 cursor = guiApp.GetCursor(sizeWE);
3126 vx += width + EXTRA_SPACE;
3130 if((editData && editData.visible) || (style.alwaysEdit))
3133 if(x == MAXINT && y == MAXINT)
3140 // ADDED THIS CHECK FOR FieldDropBox LEAKS
3141 if(/*!mods.isSideEffect && */(this.rolledOver || !this.dragging))
3143 int rowY = (style.header) ? rowHeight : 0;
3151 ((vertScroll && vertScroll.visible &&
3152 (y < 0 || y >= clientSize.h)) ||
3153 (horzScroll && horzScroll.visible &&
3154 (x < 0 || x >= clientSize.w))))
3159 if(vertScroll && vertScroll.visible &&
3160 (y < 0 || y >= clientSize.h))
3161 vertScroll.Action((y<0)?up:down, 0, 0);
3162 if(horzScroll && horzScroll.visible &&
3163 (x < 0 || x >= clientSize.w))
3164 horzScroll.Action((x<0)?up:down, 0, 0);
3170 // This must be done after the scrolling took place
3171 rowIndex = firstRowShown ? firstRowShown.index : -1;
3173 y = Min(y, clientSize.h-1);
3174 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3183 if(row && currentRow != row)
3185 if(this.dragRow && style.moveRows)
3187 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3189 else if(style.multiSelect)
3192 for(thisRow = rows.first; thisRow; thisRow = thisRow.GetNextRow())
3193 if((thisRow.selectedFlag == selected || thisRow.selectedFlag == tempSelected) ||
3199 if(this.dropIndex != rowIndex)
3201 this.dropIndex = rowIndex;
3202 this.editRow = null;
3204 this.movedRow = true;
3207 else if((style.freeSelect || this.dragging) && ((realX>= 0 && realY >= 0 && realX< clientSize.w && realY < clientSize.h) || this.rolledOver))
3209 if(!(style.multiSelect))
3211 if(currentRow)currentRow.selectedFlag = unselected;
3212 if(row)row.selectedFlag = selected;
3216 if(style.multiSelect)
3220 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3222 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3223 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3226 if(rowIndex >= clickedRow.index)
3228 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3230 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3237 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3239 selRow.selectedFlag = (selRow.selectedFlag == selected) ? tempUnselected : tempSelected;
3240 if(selRow == clickedRow)
3246 if(style.freeSelect)
3247 NotifyHighlight(master, this, currentRow, mods);
3250 insideNotifySelect = true;
3251 NotifySelect(master, this, currentRow, mods);
3252 insideNotifySelect = false;
3255 if(style.alwaysEdit && currentRow)
3256 currentRow.Edit(currentField);
3263 bool OnMouseOver(int x, int y, Modifiers mods)
3266 this.rolledOver = true;
3270 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
3272 // TOCHECK: WAS THIS MISSING ? CHECK FOR SLOWDOWN
3273 if(!active) Update(null);
3275 if(!active && (!swap || !swap.isModal))
3277 // true: destroy edit box
3278 HideEditBox(true, true, false);
3280 else if(!swap || !swap.isModal)
3282 // Bring back edit box
3283 if(currentRow && style.alwaysEdit)
3285 currentRow.Edit(currentField ? currentField : null);
3289 return true; //NotifyActivate(master, this, active, swap, 0);
3293 bool OnButtonDown(int x, int y, Modifiers mods, bool right)
3296 // Check to see if we're dragging the vertical divider
3297 if(style.alwaysEdit && style.resizable && !right)
3299 int vx = -scroll.x - 1;// + EXTRA_SPACE;// / 2 - 1;
3302 if(style.collapse && !(style.treeBranch))
3305 for(field = fields.first; field; field = field.next)
3307 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3308 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3314 resizingField = field.prev;
3316 this.startWidth = resizingField.width;
3318 SetMouseRangeToClient();
3322 vx += width + EXTRA_SPACE;
3326 if(!(style.freeSelect))
3328 int rowY = (style.header) ? rowHeight : 0;
3330 int rowIndex = firstRowShown ? firstRowShown.index : -1;
3331 DataRow previousRow = currentRow;
3332 DataRow newCurrentRow = null;
3333 DataField newCurrentField = null;
3334 bool moveMultiple = false;
3335 int numSelected = 0;
3336 int rowStart = -scroll.x;
3338 if(style.multiSelect)
3345 for(row = rows.first; row; row = row.GetNextRow())
3347 if(row.selectedFlag == tempSelected)
3348 row.selectedFlag = selected;
3349 else if(row.selectedFlag == tempUnselected)
3350 row.selectedFlag = unselected;
3351 if(row.selectedFlag == selected)
3358 for(row = firstRowShown; row; row = row.GetNextRow(), rowIndex ++)
3361 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3364 if(style.treeBranch)
3367 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3373 /* THIS WAS TOO STRICT:
3374 if(style.collapse && row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) &&
3375 (x >= rowStart + 3 + plusIndent && y >= rowY - rowHeight + PLUSY && x <= rowStart + 11 + plusIndent && y <= rowY - rowHeight + PLUSY + 8))
3377 if(style.collapse &&
3378 (x >= rowStart && y >= rowY - rowHeight && x <= rowStart + 18 + plusIndent && y <= rowY + rowHeight-1))
3380 if(row.subRows.first && (row.parent || !(style.treeBranch) || (style.rootCollapse)) && x >= plusIndent)
3381 row.collapsed = !row.collapsed;
3388 newCurrentRow = row;
3390 if(style.multiSelect)
3392 // Deselect everything if user didn't clicked on a row
3396 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3397 selRow.selectedFlag = unselected;
3399 //this.clickedRowIndex = rowIndex;
3401 else if(style.moveRows && !(mods.shift) &&
3402 (row.selectedFlag == selected || row.selectedFlag == tempSelected) &&
3403 !right && !(mods.isActivate))
3404 moveMultiple = true;
3410 if(row.selectedFlag == tempUnselected || row.selectedFlag == unselected)
3412 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3413 selRow.selectedFlag = unselected;
3414 row.selectedFlag = selected;
3417 //this.clickedRowIndex = rowIndex;
3423 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3424 selRow.selectedFlag = unselected;
3428 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3430 if(selRow != clickedRow)
3432 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3433 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3440 if(rowIndex >= clickedRow.index)
3442 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
3446 if(selRow != clickedRow)
3448 if(selRow.selectedFlag)
3449 selRow.selectedFlag = tempUnselected;
3451 selRow.selectedFlag = tempSelected;
3455 selRow.selectedFlag = selected;
3462 for(selRow = row; selRow; selRow = selRow.GetNextRow())
3466 if(selRow != clickedRow)
3468 if(selRow.selectedFlag)
3469 selRow.selectedFlag = tempUnselected;
3471 selRow.selectedFlag = tempSelected;
3475 selRow.selectedFlag = selected;
3476 if(selRow == clickedRow)
3485 if(row.selectedFlag)
3486 row.selectedFlag = tempUnselected;
3487 else row.selectedFlag = tempSelected;
3490 row.selectedFlag = tempSelected;
3492 //this.clickedRowIndex = rowIndex;
3502 // true: destroy edit box
3505 incref newCurrentRow;
3508 if(currentRow != newCurrentRow)
3509 HideEditBox(true, true, false);
3513 if(newCurrentRow._refCount <= 1)
3514 delete newCurrentRow;
3516 newCurrentRow._refCount--;
3521 if(!(style.multiSelect))
3523 if(currentRow) currentRow.selectedFlag = unselected;
3524 if(newCurrentRow) newCurrentRow.selectedFlag = selected;
3528 if(currentRow != newCurrentRow)
3531 // true: destroy edit box
3534 //incref newCurrentRow;
3535 incref newCurrentRow;
3538 HideEditBox(true, true, false);
3543 int headerSize = ((style.header) ? rowHeight : 0);
3544 int height = clientSize.h + 1 - headerSize;
3546 /*if(newCurrentRow._refCount <= 1)
3547 delete newCurrentRow;
3550 newCurrentRow._refCount--;
3551 //newCurrentRow._refCount--;
3554 currentRow = newCurrentRow;
3556 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
3557 SetScrollPosition(scroll.x,
3558 currentRow.index * rowHeight - height + rowHeight);
3559 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
3561 int line = currentRow ? currentRow.index * rowHeight : 0;
3562 //SNAPUP(line, rowHeight);
3563 SetScrollPosition(scroll.x, line);
3566 // GO THROUGH SetCurrentRow eventually?
3567 // SetCurrentRow(newCurrentRow, true);
3571 if(style.freeSelect)
3572 NotifyHighlight(master, this, currentRow, mods);
3573 else if((moveMultiple || (!(style.multiSelect) && previousRow == currentRow)) &&
3574 newCurrentRow && !(mods.shift))
3578 if(!(mods.isActivate))
3582 this.dragRow = currentRow;
3583 this.dropIndex = -1;
3584 this.movedRow = false;
3586 if(editData && editData.visible && style.alwaysEdit)
3593 if(style.collapse && !style.treeBranch)
3596 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3598 indent += (style.treeBranch) ? 20 : 15;
3601 for(field = fields.first; field; field = field.next)
3603 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3604 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3606 if(!field.prev) width -= indent;
3607 if(x >= sx && x < sx + width)
3611 if(field == currentField)
3612 editData.Deactivate();
3615 currentRow.Edit(field);
3616 editData.Activate();
3619 else if(!(mods.ctrl) && numSelected <= 1)
3620 this.editRow = currentRow;
3622 if(style.noDragging && newCurrentRow)
3623 NotifyReclick(master, this, newCurrentRow, mods);
3627 // If the user clicked exactly on the edited field,
3629 if(editData && editData.visible && newCurrentRow)
3631 DataField field, whichField;
3635 if(style.collapse && !(style.treeBranch))
3638 whichField = currentField;
3642 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3644 indent += (style.treeBranch) ? 20 : 15;
3648 for(field = fields.first; field; field = field.next)
3650 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3651 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3652 if(!field.prev) width -= indent;
3653 if(x >= sx && x < sx + width && newCurrentRow)
3658 if(field) //x >= sx && x < sx + width && newCurrentRow)
3660 if(field == currentField)
3661 editData.Activate();
3663 newCurrentRow.Edit(currentField);*/
3665 else if(style.noDragging && newCurrentRow)
3666 NotifyReclick(master, this, newCurrentRow, mods);
3668 else if(style.noDragging && newCurrentRow)
3669 NotifyReclick(master, this, newCurrentRow, mods);
3675 result = NotifySelect(master, this,
3676 currentRow ? currentRow : null, mods);
3677 if(result && style.alwaysEdit && currentRow)
3681 DataField field = null;
3686 if(style.collapse && !style.treeBranch)
3689 for(parent = newCurrentRow.parent; parent; parent = parent.parent)
3691 indent += (style.treeBranch) ? 20 : 15;
3694 for(field = fields.first; field; field = field.next)
3696 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3697 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3699 if(!field.prev) width -= indent;
3700 if(x >= sx && x < sx + width)
3702 currentField = field;
3708 currentRow.Edit(currentField);
3710 // If the user clicked exactly on the edited field,
3712 if(editData && editData.visible && newCurrentRow)
3716 editData.Activate();
3718 else if(style.noDragging && newCurrentRow)
3719 NotifyReclick(master, this, newCurrentRow, mods);
3722 else if(style.noDragging && newCurrentRow)
3723 NotifyReclick(master, this, newCurrentRow, mods);
3727 For drop box to capture...
3730 if(x < 0 || y < 0 || x >= clientSize.w || y >= clientSize.h)
3733 master.parent.Activate();
3742 if(!style.noDragging)
3744 this.dragging = true;
3747 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h)
3748 this.rolledOver = true;
3753 this.dragging = false;
3754 OnLeftButtonUp(x, y, mods);
3759 bool OnLeftButtonDown(int x, int y, Modifiers mods)
3761 return OnButtonDown(x,y, mods, false);
3764 bool OnLeftButtonUp(int x, int y, Modifiers mods)
3766 if(resizingField && style.alwaysEdit)
3768 Window::FreeMouseRange();
3770 resizingField = null;
3773 if(dragRow || editRow)
3775 DataRow row, switchRow = rows.last;
3776 int rowY = (style.header) ? rowHeight : 0;
3777 for(row = firstRowShown; row; row = row.GetNextRow())
3786 if(this.editRow == switchRow && y >= 0)
3791 for(field = fields.first; field; field = field.next)
3793 int width = (!field.next && style.fillLastField && (!hasHorzScroll || clientSize.w - field.x > field.width + EXTRA_SPACE)) ?
3794 clientSize.w - field.x : (field.width + EXTRA_SPACE);
3797 if(fieldX > x + scroll.x)
3801 if(field && field.editable)
3803 // true: destroy edit box
3804 HideEditBox(true, true, false);
3805 PopupEditBox(field, false);
3807 else if(!style.noDragging)
3808 NotifyReclick(master, this, currentRow, mods);
3810 else if(style.moveRows && switchRow)
3812 if(this.dragRow == switchRow && this.movedRow == false)
3814 DataRow row = this.dragRow;
3818 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3819 selRow.selectedFlag = unselected;
3823 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
3825 if(selRow != clickedRow)
3827 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
3828 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
3834 if(row.selectedFlag)
3835 row.selectedFlag = tempUnselected;
3836 else row.selectedFlag = tempSelected;
3839 row.selectedFlag = tempSelected;
3844 if(style.multiSelect)
3846 if(!switchRow.selectedFlag)
3848 bool foundSwitch = false;
3851 DataRow afterRow = switchRow.prev;
3852 for(row = rows.first; row; row = next)
3854 next = row.GetNextRow();
3855 if(row.selectedFlag == selected || row.selectedFlag == tempSelected)
3857 if(!foundSwitch && !after)
3860 afterRow = switchRow;
3862 if(!after || !(row.selectedFlag == selected || row.selectedFlag == tempSelected) ||
3869 else if(row == switchRow)
3876 for(row = rows.first; row; row = row.GetNextRow())
3878 if(row == switchRow || row == this.dragRow)
3882 // Switch row first: move before
3883 if(row == switchRow)
3885 if(NotifyMove(master, this, switchRow.prev, mods))
3886 dragRow.Move(switchRow.prev);
3888 // Dragged row first: move after
3891 if(NotifyMove(master, this, switchRow, mods))
3892 dragRow.Move(switchRow);
3905 if(this.dragging || style.freeSelect)
3909 this.rolledOver = this.dragging = false;
3911 if(x >= 0 && y >= 0 && x < clientSize.w && y < clientSize.h && currentRow && style.freeSelect)
3915 result = NotifySelect(master, this, currentRow, mods);
3916 if(style.alwaysEdit)
3917 currentRow.Edit(currentField);
3921 // if(!(style.freeSelect))
3927 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
3929 int rowStart = -scroll.x;
3931 int rowY = (style.header) ? rowHeight : 0;
3934 OnLeftButtonUp(x,y,mods);
3935 if(style.alwaysEdit)
3937 if(!(style.collapse) || x > 15)
3938 if(editData && editData.visible)
3940 editData.Activate();
3941 NotifyDoubleClick(master, this, x, y, mods);
3945 for(row = firstRowShown; row; row = row.GetNextRow())
3948 if(rowY > y || (style.multiSelect && !row.GetNextRow()))
3950 if(style.treeBranch)
3953 for(parent = (style.rootCollapse) ? row.parent : (row.parent ? row.parent.parent : null); parent; parent = parent.parent)
3962 if((row && style.collapse && (x >= rowStart && x <= rowStart + 18 + plusIndent)) ||
3963 NotifyDoubleClick(master, this, x, y, mods))
3967 if(row && row.subRows.first)
3969 row.collapsed = !row.collapsed;
3973 // We need to return true here so that OnLeftButtonDown can popup the DataBox Editors
3979 bool OnRightButtonDown(int x, int y, Modifiers mods)
3981 return OnButtonDown(x,y, mods, true);
3984 bool OnRightButtonUp(int x, int y, Modifiers mods)
3986 OnLeftButtonUp(x,y,mods);
3987 return NotifyRightClick(master, this, x, y, mods);
3990 bool GoToLetter(unichar ch, bool keyHit)
3992 bool result = false;
3994 bool checkNextField = true;
3995 int len = keyHit ? 0 : strlen(typedString);
3997 typedString = renew typedString char[len + 2];
3998 typedString[len++] = (char)tolower(ch); // TODO: FIX UNICODE
3999 typedString[len] = '\0';
4001 for(field = fields.first; field; field = field.next)
4003 DataRow startRow = currentRow ? currentRow : rows.first;
4005 if(startRow && field.dataType && field.dataType._vTbl[__ecereVMethodID_class_OnGetString] && ch)
4008 bool looped = false;
4009 if(len == 1 && currentRow)
4010 startRow = (next = startRow.GetNextRow(), (next ? next : rows.first));
4012 for(row = startRow; row != startRow || !looped; next = row.GetNextRow(), row = next ? next : rows.first)
4014 void * data = row.GetData(field);
4015 char tempString[1024] = "";
4016 bool needClass = false;
4017 char * string = data ? (char *)field.dataType._vTbl[__ecereVMethodID_class_OnGetString](field.dataType, data, tempString, null, &needClass) : null;
4019 if(string && string[0])
4020 checkNextField = false;
4021 if(string && string[0] && !strnicmp(string, typedString, len))
4023 if(style.multiSelect)
4026 bool foundRow = false;
4028 //this.clickedRowIndex = 0;
4030 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4032 if(selRow == row) foundRow = true;
4033 selRow.selectedFlag = unselected;
4034 //if(!foundRow) this.clickedRowIndex++;
4036 row.selectedFlag = selected;
4038 SetCurrentRow(row, true);
4045 if(this.typingTimeOut && !keyHit)
4046 typingTimer.Start();
4047 if(!result || !this.typingTimeOut || keyHit)
4048 typedString[len-1] = '\0';
4050 if(!checkNextField || result) break;
4055 bool OnKeyDown(Key key, unichar ch)
4059 if(key == enter || key == keyPadEnter)
4061 if(editData && editData.visible && editData.active)
4063 HideEditBox(true, false, false);
4067 else if(key == escape)
4069 if(resizingField || this.movingFields || (editData && editData.visible) || this.dragRow)
4071 if(editData && editData.visible && style.alwaysEdit && !editData.active)
4073 // false: dont destroy edit box
4074 HideEditBox(false, false, false);
4077 resizingField.width = this.startWidth;
4078 AdaptToFieldWidth(resizingField, true);
4079 resizingField = null;
4082 this.dragRow = null;
4085 this.dragging = false;
4089 this.movingFields = false;
4090 draggingField = null;
4096 if(!currentField || !currentField.editable)
4097 for(field = fields.first; field; field = field.next)
4101 currentField = field;
4105 if(key == f2 && currentField && currentField.editable)
4107 PopupEditBox(currentField, false);
4108 if(editData && editData.visible)
4110 if(style.alwaysEdit)
4111 editData.Activate();
4116 if(!NotifyKeyDown(master, this, currentRow, key, ch))
4119 // Editable fields...
4122 if(style.alwaysEdit && editData && editData.visible)
4123 return editData.OnKeyDown(key, ch);
4124 return true; // We want to pick up the OnKeyHit to replace contents, but skip GoToLetter
4127 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, false))
4129 /*if(inactive && window.state != Hidden)
4130 NotifyHighlight(master, this, currentRow, 0);
4133 NotifySelect(master, this, currentRow, 0);
4140 bool OnKeyHit(Key key, unichar ch)
4142 if(key.code == up && key.alt == true && key.ctrl == false && key.shift == false)
4145 if(!ch && !key.alt && !key.ctrl)
4147 key.code = (SmartKey)key.code;
4149 if(ch >= 32 && !key.alt && !key.ctrl && ch != 128)
4152 if(!currentField || !currentField.editable)
4153 for(field = fields.first; field; field = field.next)
4157 currentField = field;
4161 if(currentField && currentField.editable)
4163 if((!editData || !editData.visible) || !editData.active)
4165 PopupEditBox(currentField, false);
4166 if(editData && editData.visible)
4168 editData.Activate();
4169 editData.OnKeyHit(key, ch);
4176 if(!(style.multiSelect) && (key.ctrl))
4179 if(editData && editData.visible && ch && !key.alt && !key.ctrl && editData.active)
4185 if(style.alwaysEdit)
4190 for(field = currentField.prev; field; field = field.prev)
4194 currentField = field;
4195 HideEditBox(true, true, false);
4196 PopupEditBox(currentField, false);
4202 if(style.collapse && currentRow /*&& !currentField*/) // THIS PREVENTED COLLAPSING THE PROPERTY SHEET
4204 if(currentRow.subRows.first && !currentRow.collapsed)
4206 currentRow.collapsed = true;
4208 else if(currentRow.parent)
4209 SetCurrentRow(currentRow.parent, true);
4214 if(style.collapse && currentRow && currentRow.subRows.first)
4216 if(currentRow.collapsed)
4217 currentRow.collapsed = false;
4219 SetCurrentRow(currentRow.subRows.first, true);
4222 else if(style.alwaysEdit)
4227 for(field = currentField.next; field; field = field.next)
4231 currentField = field;
4232 HideEditBox(true, true, false);
4233 PopupEditBox(currentField, false);
4241 case pageDown: case pageUp:
4242 case end: case home:
4244 int headerSize = ((style.header) ? rowHeight : 0);
4245 int height = clientSize.h + 1 - headerSize;
4248 // true: destroy edit box
4249 // !!! TESTING true HERE !!!
4250 HideEditBox(true, true, false);
4251 // HideEditBox(false, true, false);
4253 oldRow = currentRow;
4255 SNAPDOWN(height, rowHeight);
4256 if((!currentRow || key.code == home) && key.code != end)
4258 currentRow = rows.first;
4266 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4269 next = currentRow.GetNextRow();
4276 if(!(style.multiSelect) && currentRow && !currentRow.selectedFlag)
4279 next = currentRow.GetPrevRow();
4287 currentRow = lastRow.GetLastRow();
4293 currentRow && (next = currentRow.GetPrevRow()) && c < height / rowHeight;
4294 c++, currentRow = next);
4301 currentRow && (next = currentRow.GetNextRow()) && c < height / rowHeight;
4302 c++, currentRow = next);
4307 if(currentRow && currentRow.index * rowHeight > scroll.y + height - rowHeight)
4308 SetScrollPosition(scroll.x, currentRow.index * rowHeight - height + rowHeight);
4309 else if(!currentRow || currentRow.index * rowHeight < scroll.y)
4310 SetScrollPosition(scroll.x, currentRow ? currentRow.index * rowHeight : 0);
4312 if(style.multiSelect)
4316 if(!(key.shift) && (key.ctrl))
4319 for(row = rows.first; row; row = row.GetNextRow())
4321 if(row.selectedFlag == tempSelected)
4322 row.selectedFlag = selected;
4323 else if(row.selectedFlag == tempUnselected)
4324 row.selectedFlag = unselected;
4330 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4331 selRow.selectedFlag = unselected;
4335 for(selRow = rows.first; selRow; selRow = selRow.GetNextRow())
4337 if(selRow.selectedFlag == tempUnselected) selRow.selectedFlag = selected;
4338 else if(selRow.selectedFlag == tempSelected) selRow.selectedFlag = unselected;
4344 if(currentRow.index >= clickedRow.index)
4346 for(selRow = clickedRow; selRow; selRow = selRow.GetNextRow())
4350 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4353 selRow.selectedFlag = selected;
4354 if(selRow == currentRow)
4360 for(selRow = currentRow; selRow; selRow = selRow.GetNextRow())
4364 if(selRow.selectedFlag) selRow.selectedFlag = tempUnselected; else selRow.selectedFlag = tempSelected;
4367 selRow.selectedFlag = selected;
4368 if(selRow == clickedRow)
4375 if(!(key.ctrl) && currentRow)
4377 currentRow.selectedFlag = selected;
4380 clickedRow = currentRow;
4385 if(oldRow) oldRow.selectedFlag = unselected;
4386 if(currentRow) currentRow.selectedFlag = selected;
4391 if(style.freeSelect)
4392 NotifyHighlight(master, this, currentRow, 0);
4394 NotifySelect(master, this, currentRow, 0);
4396 if(style.alwaysEdit && currentRow)
4397 currentRow.Edit(currentField /*null*/);
4404 if(style.multiSelect && currentRow)
4406 if(currentRow.selectedFlag)
4409 currentRow.selectedFlag = unselected;
4412 currentRow.selectedFlag = selected;
4415 if(style.freeSelect)
4416 NotifyHighlight(master, this, currentRow, 0);
4418 NotifySelect(master, this, currentRow, 0);
4424 if(!NotifyKeyHit(master, this, currentRow, key, ch))
4427 if(ch != 128 && !key.alt && !key.ctrl && GoToLetter(ch, true))
4429 /*if(inactive && window.state != Hidden)
4430 return NotifyHighlight(master, this, currentRow, 0);
4433 return NotifySelect(master, this, currentRow, 0);
4441 void OnHScroll(ScrollBarAction action, int position, Key key)
4446 void OnVScroll(ScrollBarAction action, int position, Key key)
4451 for(firstRowShown = rows.first; firstRowShown; firstRowShown = next)
4453 next = firstRowShown.GetNextRow();
4454 if(y >= position || !next) break;
4464 DataRow firstRowShown;
4468 DataField sortField;
4472 double typingTimeOut;
4485 if(guiApp.GetKeyState(shift)) mods.shift = true;
4486 if(guiApp.GetKeyState(alt)) mods.alt = true;
4487 if(guiApp.GetKeyState(control)) mods.ctrl = true;
4488 OnMouseMove(MAXINT, MAXINT, mods);
4496 delay = 0.5; // typingTimeOut
4501 typedString[0] = '\0';
4503 // The next line was commented... Why? When commented typing words stops working ( only first character jumps )
4509 bool dragging, rolledOver;
4518 // For editing fields
4520 DataField currentField;
4523 // For moving fields
4524 DataField draggingField, dropField;
4527 // For resizing fields
4528 DataField resizingField;
4529 int resizeX, oldX, startWidth;
4532 FontResource boldFont;
4535 // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
4536 bool insideNotifySelect;
4537 Color selectionColor, selectionText, stippleColor;
4538 stippleColor = 0xFFFFFF80;