]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.hxx
ok, so the old ~FGFontCache() was useless. But at least it didn't call
[flightgear.git] / src / GUI / new_gui.hxx
index 8cc39b4753d960246e44a39243d86f547e5915e1..352024a66b07511f153e3b4602dee0962979b54b 100644 (file)
@@ -63,7 +63,7 @@ public:
     virtual void init ();
 
     /**
-     * Reinitialize the GUI subsystem.
+     * Reinitialize the GUI subsystem. Reloads all XML dialogs.
      */
     virtual void reinit ();
 
@@ -88,6 +88,11 @@ public:
      */
     virtual void update (double delta_time_sec);
 
+    /**
+     * Redraw the GUI picking up new GUI colors.
+     */
+    virtual void redraw ();
+
     /**
      * Creates a new dialog box, using the same property format as the
      * gui/dialogs configuration files.  Does not display the
@@ -133,12 +138,18 @@ public:
      */
     virtual bool closeDialog (const string &name);
 
+    /**
+     * Get dialog property tree's root node.
+     * @param name The name of the dialog box.
+     * @return node pointer if the dialog was found, zero otherwise.
+     */
+    virtual SGPropertyNode_ptr getDialogProperties (const string &name);
+
     /**
      * Return a pointer to the current menubar.
      */
     virtual FGMenuBar * getMenuBar ();
 
-
     /**
      * Ignore this method.
      *
@@ -154,27 +165,29 @@ public:
      */
     virtual FGDialog * getActiveDialog ();
 
+
+    /**
+     * Get the named dialog if active.
+     *
+     * @return The named dialog, or 0 if it isn't active.
+     */
+    virtual FGDialog * getDialog (const string &name);
+
+
     virtual FGColor *getColor (const char * name) const {
-        _itt_t it = _colors.find(name);
+        _citt_t it = _colors.find(name);
         return (it != _colors.end()) ? it->second : NULL;
     }
     virtual FGColor *getColor (const string &name) const {
-        _itt_t it = _colors.find(name.c_str());
+        _citt_t it = _colors.find(name.c_str());
         return (it != _colors.end()) ? it->second : NULL;
     }
 
-    virtual puFont *getDefaultFont() { return &_font; }
-
+    virtual puFont *getDefaultFont() { return _font; }
 
-    /**
-     * menu wide font cache, accessible from other classes as well.
-     */
-    FGFontCache *get_fontcache() { return _fontcache; }
 
 protected:
 
-    FGFontCache * _fontcache;
-
     /**
      * Test if the menubar is visible.
      *
@@ -192,6 +205,15 @@ protected:
     virtual void setStyle ();
     virtual void setupFont (SGPropertyNode *);
 
+    /**
+     * Used by reinit() and redraw() to close all dialogs and to apply
+     * current GUI colors. If "reload" is false, reopens all dialogs.
+     * Otherwise reloads all XML dialog files from disk and reopens all
+     * but Nasal * generated dialogs, omitting dynamic widgets. (This
+     * is only useful for GUI development.)
+     */
+    virtual void reset (bool reload);
+
 private:
     struct ltstr
     {
@@ -200,13 +222,12 @@ private:
         }
     };
 
-    fntTexFont _tex_font;
-    puFont _font;
+    puFont *_font;
     map<const char*,FGColor*, ltstr> _colors;
-    typedef map<const char*,FGColor*, ltstr>::const_iterator _itt_t;
+    typedef map<const char*,FGColor*, ltstr>::iterator _itt_t;
+    typedef map<const char*,FGColor*, ltstr>::const_iterator _citt_t;
 
-    // Free all allocated memory.
-    void clear ();
+    void clear_colors();
 
     // Read all the configuration files in a directory.
     void readDir (const char * path);
@@ -272,10 +293,18 @@ private:
  */
 class FGFontCache {
 private:
+    struct fnt {
+        fnt(puFont *pu = 0) : pufont(pu), texfont(0) {}
+        ~fnt() { if (texfont) { delete pufont; delete texfont; } }
+        puFont *pufont;
+        fntTexFont *texfont;
+    };
     SGPath _path;
 
-    map<const char*,puFont*> _fonts;
-    typedef map<const char*,puFont*>::iterator _itt_t;
+    map<const string,fnt *> _fonts;
+    typedef map<const string,fnt *>::const_iterator _itt_t;
+    bool _initialized;
+    struct fnt *getfnt(const char *name, float size, float slant);
 
 public:
     FGFontCache();
@@ -283,6 +312,8 @@ public:
 
     puFont *get(const char *name, float size=15.0, float slant=0.0);
     puFont *get(SGPropertyNode *node);
+
+    fntTexFont *getTexFont(const char *name, float size=15.0, float slant=0.0);
 };