gui/auxiliary/iterator/walker_widget.cpp

Go to the documentation of this file.
00001 /* $Id: walker_widget.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_widget.hpp"
00019 
00020 #include "asserts.hpp"
00021 #include "gui/widgets/widget.hpp"
00022 
00023 namespace gui2 {
00024 
00025 namespace iterator {
00026 
00027 namespace walker {
00028 
00029 twidget::twidget(gui2::twidget& widget)
00030     : widget_(&widget)
00031 {
00032 }
00033 
00034 twalker_::tstate twidget::next(const tlevel level)
00035 {
00036     if(at_end(level)) {
00037         return fail;
00038     }
00039 
00040     switch(level) {
00041         case widget:
00042             if(widget_) {
00043                 widget_ = NULL;
00044                 return invalid;
00045             } else {
00046                 /* FALL DOWN */
00047             }
00048         case grid: /* FALL DOWN */
00049         case child: /* FALL DOWN */
00050             ;
00051     }
00052 
00053     assert(false);
00054     return fail;
00055 }
00056 
00057 bool twidget::at_end(const tlevel level) const
00058 {
00059     switch(level) {
00060         case widget:
00061             return widget_ == NULL;
00062         case grid: /* FALL DOWN */
00063         case child:
00064             return true;
00065     }
00066 
00067     assert(false);
00068     return true;
00069 }
00070 
00071 gui2::twidget* twidget::get(const tlevel level)
00072 {
00073     switch(level) {
00074         case widget:
00075             return widget_;
00076         case grid: /* FALL DOWN */
00077         case child:
00078             return NULL;
00079     }
00080 
00081     assert(false);
00082     return NULL;
00083 }
00084 
00085 } //  namespace walker
00086 
00087 } // namespace iterator
00088 
00089 } // namespace gui2
00090 
00091 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs