3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 * Copyright(c) 2006-2011 Sencha Inc.
18 * licensing@sencha.com
19 * http://www.sencha.com/license
22 Ext.define('MyDesktop.Settings', {
23 extend: 'Ext.window.Window',
28 'Ext.form.field.Checkbox',
29 'Ext.layout.container.Anchor',
30 'Ext.layout.container.Border',
32 'Ext.ux.desktop.Wallpaper',
34 'MyDesktop.WallpaperModel'
38 title: 'Change Settings',
44 initComponent: function () {
47 me.selected = me.desktop.getWallpaper();
48 me.stretch = me.desktop.wallpaper.stretch;
50 me.preview = Ext.create('widget.wallpaper');
51 me.preview.setWallpaper(me.selected);
52 me.tree = me.createTree();
55 { text: 'OK', handler: me.onOK, scope: me },
56 { text: 'Cancel', handler: me.close, scope: me }
77 boxLabel: 'Stretch to fit',
80 change: function (comp) {
81 me.stretch = comp.checked;
90 createTree : function() {
93 function child (img) {
94 return { img: img, text: me.getTextOfWallpaper(img), iconCls: '', leaf: true };
97 var tree = new Ext.tree.Panel({
98 title: 'Desktop Background',
107 afterrender: { fn: this.setInitialSelection, delay: 100 },
108 select: this.onSelect,
111 store: new Ext.data.TreeStore({
112 model: 'MyDesktop.WallpaperModel',
117 { text: "None", iconCls: '', leaf: true },
118 child('Blue-Sencha.jpg'),
119 child('Dark-Sencha.jpg'),
120 child('Wood-Sencha.jpg'),
123 child('desktop.jpg'),
124 child('desktop2.jpg'),
134 getTextOfWallpaper: function (path) {
135 var text = path, slash = path.lastIndexOf('/');
137 text = text.substring(slash+1);
139 var dot = text.lastIndexOf('.');
140 text = Ext.String.capitalize(text.substring(0, dot));
141 text = text.replace(/[-]/g, ' ');
148 me.desktop.setWallpaper(me.selected, me.stretch);
153 onSelect: function (tree, record) {
156 if (record.data.img) {
157 me.selected = 'wallpapers/' + record.data.img;
159 me.selected = Ext.BLANK_IMAGE_URL;
162 me.preview.setWallpaper(me.selected);
165 setInitialSelection: function () {
166 var s = this.desktop.getWallpaper();
168 var path = '/Wallpaper/' + this.getTextOfWallpaper(s);
169 this.tree.selectPath(path, 'text');