onRemove();
}
- //----------------------------------------------------------------------------
- void NasalWidget::invalidate()
- {
- LayoutItem::invalidate();
- _flags |= LAYOUT_DIRTY;
- }
-
- //----------------------------------------------------------------------------
- void NasalWidget::setGeometry(const SGRect<int>& geom)
- {
- if( _geometry != geom )
- {
- _geometry = geom;
- _flags |= LAYOUT_DIRTY;
- }
-
- if( !_set_geometry || !(_flags & LAYOUT_DIRTY) )
- return;
-
- try
- {
- nasal::Context c;
- _set_geometry(nasal::to_nasal(c, this), geom);
- _flags &= ~LAYOUT_DIRTY;
- }
- catch( std::exception const& ex )
- {
- SG_LOG(
- SG_GUI,
- SG_WARN,
- "NasalWidget::setGeometry: callback error: '" << ex.what() << "'"
- );
- }
- }
-
//----------------------------------------------------------------------------
void NasalWidget::onRemove()
{
- if( !_nasal_impl.valid() )
- return;
-
- typedef boost::function<void(nasal::Me)> Deleter;
-
- naContext c = naNewContext();
try
{
- Deleter del =
- nasal::get_member<Deleter>(c, _nasal_impl.get_naRef(), "onRemove");
- if( del )
- del(nasal::to_nasal(c, this));
+ callMethod<void>("onRemove");
}
catch( std::exception const& ex )
{
"NasalWidget::onRemove: callback error: '" << ex.what() << "'"
);
}
- naFreeContext(c);
}
//----------------------------------------------------------------------------
return !_height_for_width.empty() || !_min_height_for_width.empty();
}
- //----------------------------------------------------------------------------
- int NasalWidget::heightForWidth(int w) const
- {
- return callHeightForWidthFunc( _height_for_width.empty()
- ? _min_height_for_width
- : _height_for_width, w );
- }
-
- //----------------------------------------------------------------------------
- int NasalWidget::minimumHeightForWidth(int w) const
- {
- return callHeightForWidthFunc( _min_height_for_width.empty()
- ? _height_for_width
- : _min_height_for_width, w );
- }
-
//----------------------------------------------------------------------------
static naRef f_makeNasalWidget(const nasal::CallContext& ctx)
{
);
}
+
+ //----------------------------------------------------------------------------
+ int NasalWidget::heightForWidthImpl(int w) const
+ {
+ return callHeightForWidthFunc( _height_for_width.empty()
+ ? _min_height_for_width
+ : _height_for_width, w );
+ }
+
+ //----------------------------------------------------------------------------
+ int NasalWidget::minimumHeightForWidthImpl(int w) const
+ {
+ return callHeightForWidthFunc( _min_height_for_width.empty()
+ ? _height_for_width
+ : _min_height_for_width, w );
+ }
+
+
+ //----------------------------------------------------------------------------
+ void NasalWidget::contentsRectChanged(const SGRect<int>& rect)
+ {
+ if( !_set_geometry )
+ return;
+
+ try
+ {
+ nasal::Context c;
+ _set_geometry(nasal::to_nasal(c, this), rect);
+ _flags &= ~LAYOUT_DIRTY;
+ }
+ catch( std::exception const& ex )
+ {
+ SG_LOG(
+ SG_GUI,
+ SG_WARN,
+ "NasalWidget::setGeometry: callback error: '" << ex.what() << "'"
+ );
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void NasalWidget::visibilityChanged(bool visible)
+ {
+ try
+ {
+ callMethod<void>("visibilityChanged", visible);
+ }
+ catch( std::exception const& ex )
+ {
+ SG_LOG(
+ SG_GUI,
+ SG_WARN,
+ "NasalWidget::visibilityChanged: callback error: '" << ex.what() << "'"
+ );
+ }
+ }
+
} // namespace canvas
} // namespace simgear