Back to index

nux  3.0.0
GridHLayout.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef GRIDHLAYOUT_H
00024 #define GRIDHLAYOUT_H
00025 
00026 #include "Layout.h"
00027 
00028 namespace nux
00029 {
00031 
00034   class GridHLayout: public Layout
00035   {
00036     // The grid layout goes through the child elements and assign them a size and position.
00037     //  0   1   2   3   4   5
00038     //  6   7   8   9   10  11
00039     //  12  13  ..  ..  ..  ..
00040     // This is a left to right fill, going down.
00041 
00042     NUX_DECLARE_OBJECT_TYPE(GridHLayout, Layout);
00043   public:
00044 
00045     enum FillingOrder
00046     {
00047       FILL_HORIZONTAL,
00048       FILL_VERTICAL
00049     };
00050 
00051     GridHLayout(NUX_FILE_LINE_PROTO);
00052     ~GridHLayout();
00053 
00054     virtual void GetCompositeList(std::list<Area *> *ViewList);
00055     
00057 
00062     void EnablePartialVisibility(bool partial_visibility);
00063 
00065 
00070     void SetChildrenSize(int width, int height);
00071 
00073 
00076     Size GetChildrenSize() const;
00077 
00078 
00080 
00083     void ForceChildrenSize(bool force);
00084 
00086     int GetNumColumn() const;
00087 
00089     int GetNumRow() const;
00090 
00092 
00096     void MatchContentSize(bool match_content);
00097 
00099     bool IsMatchingContentSize() const;
00100 
00102 
00110     virtual void ProcessDraw(GraphicsEngine &graphics_engine, bool force_draw);
00111 
00112     void SetSpaceBetweenChildren(int horizontal_space, int vertical_space);
00113 
00114     void SetFillingOrder(FillingOrder order);
00115     FillingOrder GetFillingOrder() const;
00116 
00117   protected:
00118     long ComputeLayoutRowOrder();
00119     long ComputeLayoutColumnOrder();
00120 
00121     virtual long ComputeContentSize();
00122 
00123     int GetChildPos(Area *child);
00124     Area* GetChildAtPosition(int pos);
00125 
00126     Area* KeyNavIterationRowOrder(KeyNavDirection direction);
00127     Area* KeyNavIterationColumnOrder(KeyNavDirection direction);
00128     virtual Area* KeyNavIteration(KeyNavDirection direction);
00129 
00130     FillingOrder filling_order_;
00131     int m_v_in_margin;
00132     int m_h_in_margin;
00133 
00134   private:
00135     Size _children_size;
00136     bool _dynamic_column;
00137     bool _force_children_size;
00138     bool _partial_visibility;
00139     bool match_content_size_; 
00140 
00141     int _num_row;
00142     int _num_column;
00143 
00144 //     //! Compute the how elements are spread inside the layout
00145 //     /*!
00146 //         @param remaining_width  Size that remains after subtracting elements width, inner and outer margins from the content width.
00147 //         @param offset_space     The space at the left of all elements.
00148 //         @param element_margin   The margin between elements.
00149 //     */
00150 //     void ComputeStacking(int remaining_width, int &offset_space, int &element_margin);
00151   };
00152 }
00153 
00154 #endif // GRIDHLAYOUT_H