41 #if !defined( GLS_MENUSET_H )
42 # define GLS_MENUSET_H
45 # pragma warning( disable : 4786 )
48 # include <FL/filename.H>
65 template<
class MenuType_t,
class DataFactory_t>
129 std::map<std::string, GlsMenuAction::ActionHandler_t*>::iterator iter;
136 delete actionHandler;
137 actionHandler = NULL;
164 const std::string& name,
190 virtual void Show(
const std::string& menuName =
"" )
193 std::string::size_type start( menuName.find_first_not_of(
' ' ) );
195 if( start == std::string::npos )
200 disti::AttributeName newMenuName(
201 menuName.empty() ?
_showMenuName : disti::DecodeString( menuName.substr( start ) ) );
207 Menu_t* newMenu =
_menus->
Item( newMenuName );
231 virtual void Read( std::istream& instr )
243 void Read(
const std::string& filename )
246 fstr.open( filename.c_str() );
248 if( !fstr.is_open() )
250 fprintf( stderr,
"Unable to open file: %s\n", filename.c_str() );
269 const std::string& directory,
270 const std::string& ext =
"menu" )
272 const std::string MENU_EXT( disti::Uppercase( ext ) );
275 std::string fileDir( directory );
276 disti::AppendTrailingSlash( fileDir );
278 fileCount = fl_filename_list( fileDir.c_str(), &flist );
282 for(
int fileNum = 0; fileNum < fileCount; ++fileNum )
284 std::string fileExt = disti::GetExtension( flist[ fileNum ]->d_name );
285 if( !fileExt.empty() )
287 fileExt = disti::Uppercase( fileExt );
289 if( fileExt == MENU_EXT )
291 std::string menuFile( fileDir + flist[ fileNum ]->d_name );
300 for(
int i = fileCount - 1; i >= 0; --i )
302 free( (
void*)( flist[ i ] ) );
305 free( (
void*)flist );
328 void Write(
const std::string& filename )
331 fstr.open( filename.c_str(), std::ios::out );
333 if( !fstr.is_open() )
335 fprintf( stderr,
"Unable to open file: %s\n", filename );
340 fstr.setf( std::ios_base::fixed, std::ios::floatfield );
374 std::string menuName;
375 std::getline( args, menuName );
394 disti::AttributeName name( nameStr );
417 disti::AttributeName( name ), val );
435 disti::AttributeName( name ), val );
454 _menuData.
Get( disti::AttributeName( name ) ) );
466 #endif // GLS_MENUSET_H
GlsStaticMemberFunctor_T< T > * GlsFunctor(T(*f)())
T * Item(const std::string &name) const