/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("DE.view.ShapeSettingsAdvancedCnt", {
extend: "Ext.container.Container",
alias: "widget.peshapesettingsadvancedcnt",
requires: ["Ext.form.field.ComboBox", "Ext.data.Model", "Ext.data.Store", "Ext.Array", "Ext.button.Button"],
cls: "image-advanced-container",
height: 330,
width: 320,
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var me = this;
this._originalProps = null;
this._changedProps = null;
this._beginSizeIdx = 0;
this._endSizeIdx = 0;
this._arrCapType = [[c_oAscLineCapType.Flat, this.textFlat], [c_oAscLineCapType.Round, this.textRound], [c_oAscLineCapType.Square, this.textSquare]];
this.cmbCapType = Ext.create("Ext.form.field.ComboBox", {
id: "shape-advanced-cap-type",
width: 100,
editable: false,
store: this._arrCapType,
queryMode: "local",
triggerAction: "all",
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
if (this._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linecap(me._arrCapType[records[0].index][0]);
}
},
this)
}
});
this.cmbCapType.setValue(this._arrCapType[0][1]);
this._arrJoinType = [[c_oAscLineJoinType.Round, this.textRound], [c_oAscLineJoinType.Bevel, this.textBevel], [c_oAscLineJoinType.Miter, this.textMiter]];
this.cmbJoinType = Ext.create("Ext.form.field.ComboBox", {
id: "shape-advanced-join-type",
width: 100,
editable: false,
store: this._arrJoinType,
queryMode: "local",
triggerAction: "all",
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
if (this._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linejoin(me._arrJoinType[records[0].index][0]);
}
},
this)
}
});
this.cmbJoinType.setValue(this._arrJoinType[0][1]);
this.styleURL = "resources/img/right-panels/Begin-EndStyle.png";
this.styleURL2x = "resources/img/right-panels/Begin-EndStyle@2x.png";
var _arrStyles = [],
_arrSize = [];
var _styleTypes = [c_oAscLineBeginType.None, c_oAscLineBeginType.Triangle, c_oAscLineBeginType.Arrow, c_oAscLineBeginType.Stealth, c_oAscLineBeginType.Diamond, c_oAscLineBeginType.Oval];
var _sizeTypes = [c_oAscLineBeginSize.small_small, c_oAscLineBeginSize.small_mid, c_oAscLineBeginSize.small_large, c_oAscLineBeginSize.mid_small, c_oAscLineBeginSize.mid_mid, c_oAscLineBeginSize.mid_large, c_oAscLineBeginSize.large_small, c_oAscLineBeginSize.large_mid, c_oAscLineBeginSize.large_large];
for (var i = 0; i < 6; i++) {
var item = {
value: i,
imagewidth: 44,
imageheight: 20,
offsetx: 80 * i + 10,
offsety: 0
};
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -item.offsety, this.styleURL2x);
_arrStyles.push(item);
}
_arrStyles[0].type = c_oAscLineBeginType.None;
_arrStyles[1].type = c_oAscLineBeginType.Triangle;
_arrStyles[2].type = c_oAscLineBeginType.Arrow;
_arrStyles[3].type = c_oAscLineBeginType.Stealth;
_arrStyles[4].type = c_oAscLineBeginType.Diamond;
_arrStyles[5].type = c_oAscLineBeginType.Oval;
for (i = 0; i < 9; i++) {
var item = {
value: i,
imagewidth: 44,
imageheight: 20,
offsetx: 80 + 10,
offsety: 20 * (i + 1)
};
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -item.offsety, this.styleURL2x);
_arrSize.push(item);
}
_arrSize[0].type = c_oAscLineBeginSize.small_small;
_arrSize[1].type = c_oAscLineBeginSize.small_mid;
_arrSize[2].type = c_oAscLineBeginSize.small_large;
_arrSize[3].type = c_oAscLineBeginSize.mid_small;
_arrSize[4].type = c_oAscLineBeginSize.mid_mid;
_arrSize[5].type = c_oAscLineBeginSize.mid_large;
_arrSize[6].type = c_oAscLineBeginSize.large_small;
_arrSize[7].type = c_oAscLineBeginSize.large_mid;
_arrSize[8].type = c_oAscLineBeginSize.large_large;
var beginStyleStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrStyles
});
var beginSizeStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrSize
});
for (i = 0; i < _arrStyles.length; i++) {
var item = _arrStyles[i];
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -(item.offsety + 200), this.styleURL2x);
}
for (i = 0; i < _arrSize.length; i++) {
var item = _arrSize[i];
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -(item.offsety + 200), this.styleURL2x);
}
var endStyleStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrStyles
});
var endSizeStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrSize
});
this._updateSizeArr = function (sizecombo, record, type, sizeidx) {
var style = Ext.String.format("background:url({0}) repeat scroll 0 -1px", "resources/img/controls/text-bg.gif");
if (record.data.value > 0) {
for (var i = 0; i < _arrSize.length; i++) {
_arrSize[i].offsetx = record.data.value * 80 + 10;
_arrSize[i].borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", me.styleURL, _arrSize[i].imagewidth, _arrSize[i].imageheight, -_arrSize[i].offsetx, -(_arrSize[i].offsety + 200 * type), this.styleURL2x);
}
sizecombo.menu.picker.store.loadData(_arrSize);
sizecombo.setDisabled(false);
if (sizeidx !== null) {
sizecombo.menu.picker.selectByIndex(sizeidx, true);
me._selectStyleItem(sizecombo, sizecombo.menu.picker.store.getAt(sizeidx), type);
} else {
Ext.DomHelper.applyStyles(sizecombo.btnEl, style);
}
} else {
Ext.DomHelper.applyStyles(sizecombo.btnEl, style);
sizecombo.setDisabled(true);
}
};
this._selectStyleItem = function (stylecombo, record, type) {
var style;
if (stylecombo.btnEl) {
style = Ext.String.format("background:url({0}) repeat scroll {1}px {2}px, url({3}) repeat scroll 0 -1px;", me.styleURL, -(record.data.offsetx - 20), -(record.data.offsety + 200 * type), "resources/img/controls/text-bg.gif");
style += Ext.String.format("background-image: -webkit-image-set(url({0}) 1x, url({1}) 2x), -webkit-image-set(url({2}) 1x, url({3}) 2x);", me.styleURL, me.styleURL2x, "resources/img/controls/text-bg.gif", "resources/img/controls/text-bg@2x.gif");
Ext.DomHelper.applyStyles(stylecombo.btnEl, style);
}
};
var endStyleTpl = Ext.create("Ext.XTemplate", '', "