// optwin.cpp -- the option window // // Written by Frederic Bouvier, started February 2002. // // Copyright (C) 2002 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: optwin.cpp,v 1.10 2005/06/25 16:31:14 fredb2 Exp $ #ifdef _MSC_VER #pragma warning( disable : 4786 ) #endif #include "optwin.hpp" #include #include #include #include "flnuminput.hpp" #include "preferences.hpp" FGSD_OptionWindow::FGSD_OptionWindow( FGSD_Preferences &__prefs ) : _prefs( __prefs ) { _window = new FGSD_Window( 600, 300, "Options" ); _window->begin(); _tabs = new Fl_Tabs( 10, 10, 580, 240 ); _tabs->begin(); _general = new Fl_Group( 10, 30, 580, 220, "General" ); _general->begin(); _outPath = new Fl_Input( 150, 40, 430, 30, "Output path :" ); _outPath->value( _prefs.outputPath().c_str() ); _histLen = new FGSD_NumInput( 150, 80, 50, 30, "History length :" ); _histLen->uint_value( _prefs.historyLength() ); _general->end(); _flightgear = new Fl_Group( 10, 30, 580, 220, "FlightGear" ); _flightgear->begin(); _fgRoot = new Fl_Input( 200, 40, 380, 30, "FlightGear data path :" ); _fgRoot->value( _prefs.fgRootPath().c_str() ); _fgScenery = new Fl_Input( 200, 80, 380, 30, "FlightGear scenery path :" ); _fgScenery->value( _prefs.fgSceneryPath().c_str() ); _fgCmdLine = new Fl_Input( 200, 120, 380, 30, "FlightGear command line :" ); _fgCmdLine->value( _prefs.fgCommandLine().c_str() ); _flightgear->end(); _view = new Fl_Group( 10, 30, 580, 220, "View" ); _view->begin(); _showConstraints = new Fl_Check_Button( 20, 40, 560, 30, "Show constrained edges" ); _showConstraints->value( _prefs.showConstraints() ); _showVertices = new Fl_Check_Button( 20, 80, 560, 30, "Show vertices" ); _showVertices->value( _prefs.showVertices() ); _showInfiniteEdges = new Fl_Check_Button( 20, 120, 560, 30, "Show infinite edges" ); _showInfiniteEdges->value( _prefs.showInfiniteEdges() ); _view->end(); _tabs->end(); _ok = new Fl_Button( 10, 260, 40, 30, "Ok" ); _ok->callback( FGSD_OptionWindow::ok_cb, this ); _cancel = new Fl_Button( 60, 260, 60, 30, "Cancel" ); _cancel->callback( FGSD_OptionWindow::cancel_cb, this ); _window->end(); } FGSD_OptionWindow::~FGSD_OptionWindow() { delete _window; } void FGSD_OptionWindow::ok_cb( Fl_Widget *o, void *v ) { ((FGSD_OptionWindow *)v)->button_cb( true ); } void FGSD_OptionWindow::cancel_cb( Fl_Widget *o, void *v ) { ((FGSD_OptionWindow *)v)->button_cb( false ); } void FGSD_OptionWindow::button_cb( bool __ok ) { if ( __ok ) { if ( _histLen->size() ) _prefs.historyLength( _histLen->uint_value() ); _prefs.outputPath( _outPath->value() ); _prefs.fgRootPath( _fgRoot->value() ); _prefs.fgSceneryPath( _fgScenery->value() ); _prefs.fgCommandLine( _fgCmdLine->value() ); _prefs.showConstraints( _showConstraints->value() != 0 ); _prefs.showVertices( _showVertices->value() != 0 ); _prefs.showInfiniteEdges( _showInfiniteEdges->value() != 0 ); _prefs.save(); _window->set_value(); } else _window->clear_value(); _window->hide(); }