// -*- C++ -*- // $RCSfile: enum.C,v $ // $Revision: 1.5 $ // $Author: langer $ // $Date: 2000/10/13 20:03:09 $ /* This software was produced by NIST, an agency of the U.S. government, * and by statute is not subject to copyright in the United States. * Recipients of this software assume all responsibilities associated * with its operation, modification and maintenance. However, to * facilitate maintenance we ask that before distributing modifed * versions of this software, you first contact the authors at * oof_manager@ctcms.nist.gov. */ #ifndef ENUM_C #define ENUM_C #include #include "enum.h" #include "menuDef.h" #include "varobjects.h" template Vec &Enum::names() { static Vec nms; return nms; } template void Enum::name(const ENUMTYPE &x, const CharString &nm) { int ix = x; if(x >= names().capacity()) names().resize(ix+1); names()[ix] = new CharString(nm); } // --------------------------------------------- // /********** this is illegal! template VarObject* Var< Enum >::create_varobject(Variable *var, Form *form, VarObjectType t, int x, int y, int h, int w) { return new EnumVarObject(var, form, t, x, y, w, h); } ************/ template void EnumVarObject::CB_choice(FL_OBJECT*, long ptr) { ((EVO*) ptr)->set(); } template EnumVarObject::EnumVarObject(Variable *v, Form *f, VarObjectType t, int x, int y, int w, int h) : EVO(v, f, t) { const int width = 150; CharString label(var->name + " ="); choice = fl_add_choice(FL_NORMAL_CHOICE, x+w-width, y, width, h, label); fl_set_object_boxtype(choice, FL_UP_BOX); fl_set_object_lsize(choice, 11); fl_set_choice_fontsize(choice, 11); fl_set_choice_align(choice, FL_ALIGN_LEFT); EVO *ptr = this; fl_set_object_callback(choice, CB_choice, (long) ptr); fl_set_object_resize(choice, FL_RESIZE_NONE); if(type == VO_REACTIVE) fl_set_object_gravity(choice, FL_NorthEast, FL_NorthEast); else fl_set_object_gravity(choice, FL_SouthEast, FL_SouthEast); Vec &names = Enum::names(); for(int i=0; i void EnumVarObject::set() { if(type == VO_PROACTIVE) form->setvariable(var, get()); } template CharString EnumVarObject::get() { return CharString(fl_get_choice_text(choice)); } template void EnumVarObject::show() { fl_set_choice_text(choice, var->tostring()); fl_show_object(choice); } template void EnumVarObject::hide() { fl_hide_object(choice); } #endif