gui/widgets/multi_page.hpp

Go to the documentation of this file.
00001 /* $Id: multi_page.hpp 54007 2012-04-28 19:16:10Z mordante $ */
00002 /*
00003    Copyright (C) 2008 - 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 
00017 #ifndef GUI_WIDGETS_MULTI_PAGE_HPP_INCLUDED
00018 #define GUI_WIDGETS_MULTI_PAGE_HPP_INCLUDED
00019 
00020 #include "gui/widgets/container.hpp"
00021 
00022 namespace gui2 {
00023 
00024 namespace implementation {
00025     struct tbuilder_multi_page;
00026 }
00027 
00028 class tgenerator_;
00029 
00030 /** The multi page class. */
00031 class tmulti_page
00032         : public tcontainer_
00033 {
00034     friend struct implementation::tbuilder_multi_page;
00035     friend class tdebug_layout_graph;
00036 
00037 public:
00038 
00039     tmulti_page();
00040 
00041     /***** ***** ***** ***** Page handling. ***** ***** ****** *****/
00042 
00043     /**
00044      * Adds single page to the grid.
00045      *
00046      * This function expect a page to one multiple widget.
00047      *
00048      * @param item                The data to send to the set_members of the
00049      *                            widget.
00050      */
00051     void add_page(const string_map& item);
00052 
00053     /**
00054      * Adds single page to the grid.
00055      *
00056      * This function expect a page to have multiple widgets (either multiple
00057      * columns or one column with multiple widgets).
00058      *
00059      *
00060      * @param data                The data to send to the set_members of the
00061      *                            widgets. If the member id is not an empty
00062      *                            string it is only send to the widget that
00063      *                            has the wanted id (if any). If the member
00064      *                            id is an empty string, it is send to all
00065      *                            members. Having both empty and non-empty
00066      *                            id's gives undefined behaviour.
00067      */
00068     void add_page(const std::map<std::string /* widget id */,
00069             string_map>& data);
00070 
00071     /**
00072      * Removes a page in the multi page.
00073      *
00074      * @param page                The page to remove, when not in
00075      *                            range the function is ignored.
00076      * @param count               The number of pages to remove, 0 means all
00077      *                            pages (starting from page).
00078      */
00079     void remove_page(const unsigned page, unsigned count = 1);
00080 
00081     /** Removes all pages in the multi page, clearing it. */
00082     void clear();
00083 
00084     /** Returns the number of pages. */
00085     unsigned get_page_count() const;
00086 
00087     /**
00088      * Selectes a page.
00089      *
00090      * @param page                The page to select.
00091      * @param select              Select or deselect the page.
00092      */
00093     void select_page(const unsigned page, const bool select = true);
00094 
00095     /**
00096      * Returns the selected page.
00097      *
00098      * @returns                   The selected page.
00099      * @retval -1                 No page selected.
00100      */
00101     int get_selected_page() const;
00102 
00103     /**
00104      * Returns the grid for the page.
00105      *
00106      * @param page                The page to get the grid from, the caller
00107      *                            has to make sure the page is a valid page.
00108      *
00109      * @returns                   The grid of the wanted page.
00110      */
00111     const tgrid& page_grid(const unsigned page) const;
00112 
00113     /**
00114      * Returns the grid for the page.
00115      *
00116      * @param page                The page to get the grid from, the caller
00117      *                            has to make sure the page is a valid page.
00118      *
00119      * @returns                   The grid of the wanted page.
00120      */
00121     tgrid& page_grid(const unsigned page);
00122 
00123     /***** ***** ***** inherited ***** ****** *****/
00124 
00125     /** Inherited from tcontrol. */
00126     bool get_active() const { return true; }
00127 
00128     /** Inherited from tcontrol. */
00129     unsigned get_state() const { return 0; }
00130 
00131     /***** ***** ***** setters / getters for members ***** ****** *****/
00132 
00133     void set_page_builder(tbuilder_grid_ptr page_builder)
00134         { page_builder_ = page_builder; }
00135 
00136 private:
00137 
00138     /**
00139      * Finishes the building initialization of the widget.
00140      *
00141      * @param page_data           The initial data to fill the widget with.
00142      */
00143     void finalize(const std::vector<string_map>& page_data);
00144 
00145     /**
00146      * Contains a pointer to the generator.
00147      *
00148      * The pointer is not owned by this class, it's stored in the content_grid_
00149      * of the tscrollbar_container super class and freed when it's grid is
00150      * freed.
00151      */
00152     tgenerator_* generator_;
00153 
00154     /** Contains the builder for the new items. */
00155     tbuilder_grid_const_ptr page_builder_;
00156 
00157     /**
00158      * Inherited from tcontrol.
00159      *
00160      * Since we're always empty the draw does nothing.
00161      */
00162     void impl_draw_background(surface& /*frame_buffer*/) {}
00163     void impl_draw_background(
00164               surface& /*frame_buffer*/
00165             , int /*x_offset*/
00166             , int /*y_offset*/) {}
00167 
00168     /** Inherited from tcontrol. */
00169     const std::string& get_control_type() const;
00170 
00171     /** Inherited from tcontainer_. */
00172     void set_self_active(const bool /*active*/) {}
00173 };
00174 
00175 } // namespace gui2
00176 
00177 #endif
00178 
00179 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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