// curvetools.cpp -- the toolbar for curve operations // // Written by Frederic Bouvier, started March 2003. // // Copyright (C) 2003 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: curvetools.cpp,v 1.7 2005/05/14 09:45:14 fredb2 Exp $ #ifdef _MSC_VER # pragma warning( disable: 4800 4503 ) #endif #include "curvetools.hpp" #include "mainwin.hpp" FGSD_CurveToolbar::FGSD_CurveToolbar( int x, int y, int w, int h, FGSD_MainWindow *mw ) : Fl_Group( x, y, w, h ) , _mainWindow( mw ) { begin(); _addPoint = new Fl_Button( x+5, y+5, 30, 30, "Ap" ); _addPoint->tooltip( "Add a point to the curve" ); _addPoint->type( FL_TOGGLE_BUTTON ); _addPoint->callback( &FGSD_CurveToolbar::addPoint, this ); _delPoint = new Fl_Button( x+35, y+5, 30, 30, "Rp" ); _delPoint->tooltip( "Remove the current point from the selected curve" ); _delPoint->callback( &FGSD_CurveToolbar::delPoint, mw ); _delCurve = new Fl_Button( x+65, y+5, 30, 30, "Rc" ); _delCurve->tooltip( "Remove the selected curve" ); _delCurve->shortcut( FL_CTRL + 'd' ); _delCurve->callback( &FGSD_CurveToolbar::delCurve, mw ); _embedCurve = new Fl_Button( x+95, y+5, 30, 30, "Ec" ); _embedCurve->tooltip( "Embed the selected curve in the terrain" ); _embedCurve->shortcut( FL_CTRL + 'e' ); _embedCurve->callback( &FGSD_CurveToolbar::embedCurve, mw ); _properties = new Fl_Button( x+125, y+5, 30, 30, "P" ); _properties->tooltip( "Curve properties" ); _properties->callback( &FGSD_CurveToolbar::properties, mw ); _drawCurve = new Fl_Button( x+155, y+5, 30, 30, "Dc" ); _drawCurve->tooltip( "Draw curves" ); _drawCurve->type( FL_TOGGLE_BUTTON ); _drawCurve->value( mw->drawCurves() ); _drawCurve->callback( &FGSD_CurveToolbar::drawCurve, mw ); end(); resizable( 0 ); box( FL_THIN_UP_BOX ); } void FGSD_CurveToolbar::addPoint( Fl_Widget *w, void *v ) { /* if ( w->value() ) { FGSD_CurveToolbar *self = static_cast( v ); Fl_Button *dc = self->_drawCurve; dc->value( true ); drawCurve( dc, self->_mainWindow ); } */ } void FGSD_CurveToolbar::delPoint( Fl_Widget *w, void *v ) { static_cast( v )->remCurvePoint_cb( true ); } void FGSD_CurveToolbar::delCurve( Fl_Widget *w, void *v ) { static_cast( v )->remCurve_cb( true ); } void FGSD_CurveToolbar::embedCurve( Fl_Widget *w, void *v ) { static_cast( v )->embedCurve_cb( true ); } void FGSD_CurveToolbar::properties( Fl_Widget *w, void *v ) { static_cast( v )->curveType_cb( true ); } void FGSD_CurveToolbar::drawCurve( Fl_Widget *w, void *v ) { // static_cast( v )->drawCurves( w->value() ); } void FGSD_CurveToolbar::show( bool yes ) { yes ? Fl_Group::show() : Fl_Group::hide(); // if ( !shown() ) // Fl_Group::show(); // resize( x(), y(), w(), yes ? 30 : 0 ); if ( !yes ) _addPoint->value( 0 ); // parent()->relayout(); }