void mouseDrag (const MouseEvent& e) { if (isEnabled() && owner.getModel() != nullptr && ! (e.mouseWasClicked() || isDragging)) { const SparseSet<int> selectedRows (owner.getSelectedRows()); if (selectedRows.size() > 0) { const var dragDescription (owner.getModel()->getDragSourceDescription (selectedRows)); if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty()))) { isDragging = true; owner.startDragAndDrop (e, dragDescription); } } } }
void mouseDrag (const MouseEvent& e) override { if (isEnabled() && owner.getModel() != nullptr && ! (e.mouseWasClicked() || isDragging)) { SparseSet<int> rowsToDrag; if (owner.selectOnMouseDown || owner.isRowSelected (row)) rowsToDrag = owner.getSelectedRows(); else rowsToDrag.addRange (Range<int>::withStartAndLength (row, 1)); if (rowsToDrag.size() > 0) { const var dragDescription (owner.getModel()->getDragSourceDescription (rowsToDrag)); if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty()))) { isDragging = true; owner.startDragAndDrop (e, rowsToDrag, dragDescription, true); } } } }
static Colour getColourFromVar (const var& col) { return col.isString() ? Colour::fromString (col.toString()) : Colours::transparentBlack; }
bool compare::equality(var& x, var& y) { // 1. If Type(x) is the same as Type(y), then if (x.adapter->type == y.adapter->type) { // 1. If Type(x) is Undefined, return true. if (x.isUndefined()) return true; // 2. If Type(x) is Null, return true. if (x.isNull()) return true; // 3. If Type(x) is Number, then if (x.isNumber()) { // 1. If x is NaN, return false. // 2. If y is NaN, return false. // (TODO: NaN checks?) // 3. If x is the same Number value as y, return true. if (x.numberValue == y.numberValue) return true; // 4. If x is +0 and y is -0, return true. if (x.numberValue == +0 && y.numberValue == -0) return true; // 5. If x is -0 and y is +0, return true. if (x.numberValue == -0 && y.numberValue == +0) return true; // 6. Return false. return false; } // 4. If Type(x) is String, then return true if x and y are exactly the same sequence of characters // (same length and same characters in corresponding positions). Otherwise, return false. if (x.isString()) return x.stringValue == y.stringValue; // 5. If Type(x) is Boolean, return true if x and y are both true or both false. Otherwise, return false. if (x.isBoolean()) return x.booleanValue == y.booleanValue; // 6. Return true if x and y refer to the same object. Otherwise, return false. if (x.isObject()) return x.objectValue == y.objectValue; if (x.isArray()) return x.arrayValue == y.arrayValue; return false; } // 2. If x is null and y is undefined, return true. if (x.isNull() && y.isUndefined()) return true; // 3. If x is undefined and y is null, return true. if (x.isUndefined() && y.isNull()) return true; // 4. If Type(x) is Number and Type(y) is String, // return the result of the comparison x == ToNumber(y). if (x.isNumber() && y.isString()) return x == (number) y; // 5. If Type(x) is String and Type(y) is Number, // return the result of the comparison ToNumber(x) == y. if (x.isString() && y.isNumber()) return (var) (number) x == y; // 6. If Type(x) is Boolean, // return the result of the comparison ToNumber(x) == y. if (x.isBoolean()) return (var) (number) x == y; // 7. If Type(y) is Boolean, // return the result of the comparison x == ToNumber(y). if (y.isBoolean()) return x == (number) y; // 8. If Type(x) is either String or Number and Type(y) is Object, // return the result of the comparison x == ToPrimitive(y). if ((x.isString() || x.isNumber()) && (y.isObject() || y.isArray())) return x == (string) y; // 9. If Type(x) is Object and Type(y) is either String or Number, // return the result of the comparison ToPrimitive(x) == y. if ((x.isObject() || x.isArray()) && (y.isString() || y.isNumber())) return (var) (string) x == y; // 10. Return false. return false; }