Changeset 52:32eb31ec810f for source/class
- Timestamp:
- Jan 21, 2008, 7:17:34 PM (17 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/class/pf/Application.js
r48 r52 562 562 var entity = e.getUserData("entity"); 563 563 564 this.gui_entity_units.update(entity.dimension); 564 this.gui_entity_units.update(entity.dimension, 565 this.prefs.units[entity.dimension]); 565 566 566 567 this.updateEntityValue(); … … 1494 1495 e.addEventListener("changeSelected", function(ev) { 1495 1496 var dimension = this.gui_compare_dim.getSelectedValue(); 1496 this.gui_compare_units.update(dimension); 1497 this.gui_compare_units.update(dimension, 1498 this.prefs.units[dimension]); 1497 1499 this.updateFavoritesListView(); 1498 1500 this.updateLegendListView(); … … 1502 1504 1503 1505 l = new qx.ui.basic.Label("Units:"); 1504 e = new pf.UnitSelector ;1506 e = new pf.UnitSelector(); 1505 1507 e.addEventListener("changeSelected", function(ev) { 1506 1508 this.updateFavoritesListView(); … … 1945 1947 }, 1946 1948 1949 prefsCB : function(ev) 1950 { 1951 this.prefsWindow.open(); 1952 }, 1953 1947 1954 buildMenu : function() 1948 1955 { … … 2010 2017 btn = new qx.ui.menu.Button("Preferences", 2011 2018 "pf/image/preferences.png"); 2012 btn.addEventListener("execute", function (ev) { 2013 alert("Not implemented yet")}, this); 2019 btn.addEventListener("execute", this.prefsCB, this); 2014 2020 submenu.add(btn); 2015 2021 … … 2112 2118 }, 2113 2119 2120 getWindowDimensions : function() 2121 { 2122 var dims = new Object; 2123 2124 dims.w = qx.html.Window.getInnerWidth(this.win); 2125 dims.h = qx.html.Window.getInnerHeight(this.win); 2126 2127 return dims; 2128 }, 2129 2130 savePreferences : function() 2131 { 2132 if (this.prefs) { 2133 var prefstr = qx.io.Json.stringify(this.prefs); 2134 qx.io.local.CookieApi.set("prefs", prefstr); 2135 } 2136 }, 2137 2138 loadPreferences : function() 2139 { 2140 var prefstr = qx.io.local.CookieApi.get("prefs"); 2141 // this.warn(prefstr); 2142 if (prefstr) { 2143 this.prefs = qx.io.Json.parseQx(prefstr); 2144 } 2145 2146 if (!this.prefs) { 2147 this.prefs = new Object; 2148 } 2149 2150 if (!this.prefs.units) { 2151 this.prefs.units = new Object; 2152 } 2153 }, 2154 2155 2156 createPrefsDialog : function() 2157 { 2158 var w; 2159 // "Preferences..." dialog 2160 w = new qx.ui.window.Window("Preferences", 2161 "pf/image/preferences.png"); 2162 w.setSpace(200, "auto", 100, "auto"); 2163 w.setModal(true); 2164 w.setShowMinimize(false); 2165 w.setShowMaximize(false); 2166 2167 var vbl = new qx.ui.layout.VerticalBoxLayout("vertical"); 2168 vbl.setStretchChildrenOrthogonalAxis(false); 2169 w.add(vbl); 2170 2171 var fr1, fr2, rc, l, e; 2172 2173 fr1 = new qx.ui.groupbox.GroupBox("Default units"); 2174 fr1.setDimension("auto", "auto"); 2175 vbl.add(fr1); 2176 2177 rc = new qx.ui.layout.HorizontalBoxLayout; 2178 rc.setWidth("100%"); 2179 rc.setHeight("auto"); 2180 rc.setSpacing(10); 2181 fr1.add(rc); 2182 2183 l = new qx.ui.basic.Label("Dimension:"); 2184 e = new pf.ui.ComboBox; 2185 e.add(new qx.ui.form.ListItem("Frequency", null, "frequency")); 2186 e.add(new qx.ui.form.ListItem("Length", null, "length")); 2187 e.add(new qx.ui.form.ListItem("Velocity", null, "velocity")); 2188 e.add(new qx.ui.form.ListItem("Energy", null, "energy")); 2189 e.add(new qx.ui.form.ListItem("Electric field", null, "efield")); 2190 e.addEventListener("changeSelected", function(ev) { 2191 var dimension = ev.getTarget().getSelectedValue(); 2192 this.gui_prefs_units.update(dimension, 2193 this.prefs.units[dimension]); 2194 }, this); 2195 rc.add(l, e); 2196 this.gui_prefs_dim = e; 2197 2198 l = new qx.ui.basic.Label("Units:"); 2199 e = new pf.UnitSelector(); 2200 e.addEventListener("changeSelected", function(ev) { 2201 var dimension = this.gui_prefs_dim.getSelectedValue(); 2202 var units = ev.getTarget().getValue(); 2203 this.prefs.units[dimension] = units; 2204 }, this); 2205 rc.add(l, e); 2206 this.gui_prefs_units = e; 2207 2208 fr2 = new qx.ui.groupbox.GroupBox("Interface"); 2209 fr2.setDimension("auto", "auto"); 2210 vbl.add(fr2); 2211 // A hack... 2212 fr1.addEventListener("appear", function(ev) { 2213 fr2.setWidth(this.getWidthValue()); 2214 }); 2215 2216 e = new qx.ui.form.CheckBox("Remember window dimensions on exit"); 2217 e.setChecked(this.prefs.rememberWindowSize); 2218 e.addEventListener("changeChecked", function(ev) { 2219 this.prefs.rememberWindowSize = ev.getTarget().getChecked(); 2220 }, this); 2221 fr2.add(e); 2222 2223 this.doc.add(w); 2224 this.prefsWindow = w; 2225 }, 2226 2114 2227 /** 2115 2228 * TODOC … … 2128 2241 2129 2242 this.doc = qx.ui.core.ClientDocument.getInstance(); 2243 this.win = this.doc.getWindowElement(); 2244 2245 // Load prefs 2246 this.loadPreferences(); 2130 2247 2131 2248 // Defaults 2132 2133 2249 this.r = new pf.base.Species("r", 1.0, 0, 0, 1.0, null); 2134 2250 this.e = new pf.base.Species("e", (1.0/1836.2), -1, 1e16, 1.0, this.r); … … 2143 2259 2144 2260 if (this.updatePlasmaParameters() != true) { 2145 alert("Error!");2261 this.error("Error updating plasma parameters!"); 2146 2262 } 2147 2263 … … 2188 2304 // The "Plot" tab 2189 2305 this.renderPlotTab(); 2306 2307 // "Preferences" dialog 2308 this.createPrefsDialog(); 2190 2309 2191 2310 // "About..." dialog 2192 varw = new qx.ui.window.Window("About Plasma Formulary",2311 w = new qx.ui.window.Window("About Plasma Formulary", 2193 2312 "pf/image/about.png"); 2194 2313 w.setSpace(200, "auto", 100, "auto"); … … 2210 2329 this.doc.add(w); 2211 2330 this.aboutWindow = w; 2331 2332 if (this.prefs.rememberWindowSize && this.prefs.dims) { 2333 self.resizeTo(this.prefs.dims.w,this.prefs.dims.h) 2334 } 2335 2336 // Handle resize events 2337 this.doc.addEventListener("windowresize", function(e) { 2338 if (this.prefs.rememberWindowSize) { 2339 this.prefs.dims = this.getWindowDimensions(); 2340 } 2341 this.drawCB(); 2342 }, this); 2212 2343 }, 2213 2344 … … 2225 2356 2226 2357 // Prompt user 2227 // return "qooxdoo application: Do you really want to close the application?"; 2228 }, 2229 2358 // return "Do you really want to close the application?"; 2359 }, 2230 2360 2231 2361 /** … … 2237 2367 */ 2238 2368 terminate : function(e) { 2369 // Save preferences 2370 this.savePreferences(); 2371 2239 2372 this.base(arguments); 2240 2373 }
Note: See TracChangeset
for help on using the changeset viewer.