]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/layout/NasalWidget.hxx
canvas::Text: add heightForWidth method.
[simgear.git] / simgear / canvas / layout / NasalWidget.hxx
index d9e80450ba323d930980ff28db3ff3cfc2f0f416..1fc4446a1cdd1e961d6b11b41a70a49b453ef3f5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <simgear/nasal/cppbind/from_nasal.hxx>
 #include <simgear/nasal/cppbind/NasalHash.hxx>
+#include <simgear/nasal/cppbind/NasalObject.hxx>
 
 namespace simgear
 {
@@ -33,11 +34,13 @@ namespace canvas
    * Baseclass/ghost to create widgets with Nasal.
    */
   class NasalWidget:
-    public LayoutItem
+    public LayoutItem,
+    public nasal::Object
   {
     public:
 
       typedef boost::function<void (nasal::Me, const SGRecti&)> SetGeometryFunc;
+      typedef boost::function<int (nasal::Me, int)> HeightForWidthFunc;
 
       /**
        *
@@ -49,15 +52,16 @@ namespace canvas
       virtual void setGeometry(const SGRecti& geom);
 
       void setSetGeometryFunc(const SetGeometryFunc& func);
-
-      void setImpl(naRef obj);
-      naRef getImpl() const;
+      void setHeightForWidthFunc(const HeightForWidthFunc& func);
+      void setMinimumHeightForWidthFunc(const HeightForWidthFunc& func);
 
       void setSizeHint(const SGVec2i& s);
       void setMinimumSize(const SGVec2i& s);
       void setMaximumSize(const SGVec2i& s);
 
-      bool _set(naContext c, const std::string& key, naRef val);
+      virtual bool hasHeightForWidth() const;
+      virtual int heightForWidth(int w) const;
+      virtual int minimumHeightForWidth(int w) const;
 
       /**
        * @param ns  Namespace to register the class interface
@@ -66,9 +70,11 @@ namespace canvas
 
     protected:
       SetGeometryFunc       _set_geometry;
-      nasal::ObjectHolder<> _nasal_impl;
+      HeightForWidthFunc    _height_for_width,
+                            _min_height_for_width;
 
-      static naRef getParents(NasalWidget&, naContext);
+      int callHeightForWidthFunc( const HeightForWidthFunc& hfw,
+                                  int w ) const;
 
       virtual SGVec2i sizeHintImpl() const;
       virtual SGVec2i minimumSizeImpl() const;