Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

SelectLang.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "SelectLang.h"
00010 
00011 #include "HBox.h"
00012 #include "RadioBox.h"
00013 
00014 #include "def-script.h"
00015 #include "Path.h"
00016 #include "ScriptState.h"
00017 
00018 //-----------------------------------------------------------------
00019     inline SelectLang *
00020 getSelect(lua_State *L)
00021 {
00022     return dynamic_cast<SelectLang*>(script_getLeader(L));
00023 }
00024 //-----------------------------------------------------------------
00025 /**
00026  * void select_addFlag(value, picture)
00027  */
00028     int
00029 script_select_addFlag(lua_State *L) throw()
00030 {
00031     BEGIN_NOEXCEPTION;
00032     const char *value = luaL_checkstring(L, 1);
00033     const char *picture = luaL_checkstring(L, 2);
00034 
00035     getSelect(L)->addFlag(value, Path::dataReadPath(picture));
00036     END_NOEXCEPTION;
00037     return 0;
00038 }
00039 
00040 //-----------------------------------------------------------------
00041 /**
00042  * Execute script which will add flags.
00043  */
00044 SelectLang::SelectLang(const std::string &option, const Path &datafile)
00045 {
00046     m_option = option;
00047     m_activeRow = new HBox();
00048 
00049     m_script->registerFunc("select_addFlag", script_select_addFlag);
00050     scriptInclude(datafile);
00051 
00052     addWidget(m_activeRow);
00053 }
00054 //-----------------------------------------------------------------
00055 /**
00056  * Stack flags in table.
00057  */
00058     void
00059 SelectLang::addFlag(const std::string &value, const Path &picture)
00060 {
00061     m_activeRow->addWidget(new RadioBox(m_option, value, picture));
00062     if (m_activeRow->getW() > MAX_WIDTH) {
00063         addWidget(m_activeRow);
00064         m_activeRow = new HBox();
00065     }
00066 }
00067 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2