comparison mde/gui/WidgetManager.d @ 110:6acd96f8685f

Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui. Gave AContent support for multiple callbacks. New locale: "en".
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 05 Dec 2008 11:29:39 +0000
parents c9fc2d303178
children 1655693702fc
comparison
equal deleted inserted replaced
109:2a1428ec5344 110:6acd96f8685f
23 23
24 import mde.gui.WidgetDataSet; 24 import mde.gui.WidgetDataSet;
25 import mde.gui.widget.Ifaces; 25 import mde.gui.widget.Ifaces;
26 import mde.gui.renderer.createRenderer; 26 import mde.gui.renderer.createRenderer;
27 27
28 // For adding the input event callbacks and requesting redraws:
29 import imde = mde.imde; 28 import imde = mde.imde;
30 import mde.input.Input; 29 import mde.input.Input;
31 import mde.scheduler.Scheduler; 30 import mde.scheduler.Scheduler;
32 import mde.setup.Screen; 31 import mde.setup.Screen;
32 import Items = mde.content.Items; // loadTranslation
33 import mde.lookup.Options; // miscOpts.L10n callback
33 34
34 import tango.core.sync.Mutex; 35 import tango.core.sync.Mutex;
35 import tango.util.log.Log : Log, Logger; 36 import tango.util.log.Log : Log, Logger;
36 import tango.util.container.CircularList; // pop-up draw callbacks 37 import tango.util.container.CircularList; // pop-up draw callbacks
37 38
67 void init () { 68 void init () {
68 // Doesn't need a lock - cannot conflict with other class functions. 69 // Doesn't need a lock - cannot conflict with other class functions.
69 // Events we want to know about: 70 // Events we want to know about:
70 imde.input.addMouseClickCallback(&clickEvent); 71 imde.input.addMouseClickCallback(&clickEvent);
71 imde.input.addMouseMotionCallback(&motionEvent); 72 imde.input.addMouseMotionCallback(&motionEvent);
73
74 Items.loadTranslation ();
75 miscOpts.L10n.addCallback (&reloadStrings);
72 } 76 }
73 77
74 78
75 /** Draw the gui. */ 79 /** Draw the gui. */
76 void draw() { 80 void draw() {
435 loadData (true); 439 loadData (true);
436 return data.keys; 440 return data.keys;
437 } 441 }
438 } 442 }
439 443
444 /** Called when translation strings have been reloaded. */
445 void reloadStrings (AContent c) {
446 Items.loadTranslation;
447 child.reloadStrings; //FIXME : all widgets, resize
448 requestRedraw;
449 }
450
451 protected:
440 /** Second stage of loading the widgets. 452 /** Second stage of loading the widgets.
441 * 453 *
442 * loadDesign handles the data; this method needs to: 454 * loadDesign handles the data; this method needs to:
443 * --- 455 * ---
444 * // 1. Create the root widget: 456 * // 1. Create the root widget:
482 } 494 }
483 } 495 }
484 496
485 /** Called before saving (usually when the GUI is about to be destroyed, although not 497 /** Called before saving (usually when the GUI is about to be destroyed, although not
486 * necessarily). */ 498 * necessarily). */
487 void preSave () {} 499 void preSave ();
488 500
501 public:
489 //BEGIN IWidgetManager methods 502 //BEGIN IWidgetManager methods
490 IChildWidget makeWidget (widgetID id, IContent content = null) { 503 IChildWidget makeWidget (widgetID id, IContent content = null) {
491 debug (mdeWidgets) logger.trace ("Creating widget \""~id~'"'); 504 debug (mdeWidgets) logger.trace ("Creating widget \""~id~'"');
492 return createWidget (this, id, curData[id], content); 505 return createWidget (this, id, curData[id], content);
493 } 506 }