// matwin.cpp -- the material window // // Written by Frederic Bouvier, started August 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: matwin.cpp,v 1.4 2005/05/09 07:02:10 fredb Exp $ #ifdef _MSC_VER #pragma warning( disable : 4786 ) #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "matwin.hpp" #include "bobject.hpp" FGSD_MaterialWindow::FGSD_MaterialWindow( const std::string ¤t ) { _window = new FGSD_Window( 290, 90, "Change material" ); _window->begin(); _material = new Flu_Combo_List( 90, 10, 190, 30, "Material :" ); _material->editable( false ); _material->list.add( "None" ); _material->value( "None" ); int i = 1; for ( FGSD_BaseObject::MaterialColorMap::iterator it = FGSD_BaseObject::_materialColorMap.begin(); it != FGSD_BaseObject::_materialColorMap.end(); ++it ) { _material->list.add( it->first.c_str() ); i++; } _material->value( current.c_str() ); _ok = new Fl_Button( 10, 50, 40, 30, "Ok" ); _ok->callback( FGSD_MaterialWindow::ok_cb, this ); _cancel = new Fl_Button( 60, 50, 60, 30, "Cancel" ); _cancel->callback( FGSD_MaterialWindow::cancel_cb, this ); _window->end(); } FGSD_MaterialWindow::~FGSD_MaterialWindow() { delete _window; } void FGSD_MaterialWindow::ok_cb( Fl_Widget *o, void *v ) { ((FGSD_MaterialWindow *)v)->button_cb( true ); } void FGSD_MaterialWindow::cancel_cb( Fl_Widget *o, void *v ) { ((FGSD_MaterialWindow *)v)->button_cb( false ); } void FGSD_MaterialWindow::button_cb( bool __ok ) { if ( __ok ) _window->set_value(); else _window->clear_value(); _window->hide(); }