00001 /* $Id: walker_grid.cpp 52869 2012-02-03 20:18:33Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2011 - 2012 by Mark de Wever <koraq@xs4all.nl> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 #define GETTEXT_DOMAIN "wesnoth-lib" 00017 00018 #include "gui/auxiliary/iterator/walker_grid.hpp" 00019 00020 #include "asserts.hpp" 00021 00022 namespace gui2 { 00023 00024 namespace iterator { 00025 00026 tgrid::tgrid(gui2::tgrid& grid) 00027 : grid_(grid) 00028 , widget_(&grid) 00029 , itor_(grid.begin()) 00030 { 00031 } 00032 00033 twalker_::tstate tgrid::next(const tlevel level) 00034 { 00035 if(at_end(level)) { 00036 return fail; 00037 } 00038 00039 switch(level) { 00040 case widget: 00041 if(widget_) { 00042 widget_ = NULL; 00043 return invalid; 00044 } else { 00045 /* FALL DOWN */ 00046 } 00047 case grid: 00048 assert(false); 00049 return fail; 00050 case child: 00051 if(itor_ == grid_.end()) { 00052 /* FALL DOWN */ 00053 } else { 00054 ++itor_; 00055 return itor_ == grid_.end() ? invalid : valid; 00056 } 00057 } 00058 00059 assert(false); 00060 return fail; 00061 } 00062 00063 bool tgrid::at_end(const tlevel level) const 00064 { 00065 switch(level) { 00066 case widget: 00067 return widget_ == NULL; 00068 case grid: 00069 return true; 00070 case child: 00071 return (itor_ == grid_.end()); 00072 } 00073 00074 assert(false); 00075 return true; 00076 } 00077 00078 gui2::twidget* tgrid::get(const tlevel level) 00079 { 00080 switch(level) { 00081 case widget: 00082 return widget_; 00083 case grid: 00084 return NULL; 00085 case child: 00086 if(itor_ == grid_.end()) { 00087 return NULL; 00088 } else { 00089 return *itor_; 00090 } 00091 } 00092 00093 assert(false); 00094 return NULL; 00095 } 00096 00097 } // namespace iterator 00098 00099 } // namespace gui2 00100 00101
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |