nux-0.9.48

Nux/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     GridHLayout (NUX_FILE_LINE_PROTO);
00045     ~GridHLayout ();
00046 
00047     virtual long ComputeLayout2 ();
00048 
00049     virtual void GetCompositeList (std::list<Area *> *ViewList);
00050     
00052 
00057     void EnablePartialVisibility (bool partial_visibility);
00058 
00060 
00065     void SetChildrenSize (int width, int height);
00066 
00068 
00071     Size GetChildrenSize () const;
00072 
00073 
00075 
00078     void ForceChildrenSize (bool force);
00079 
00081     int GetNumColumn () const;
00082 
00084     int GetNumRow () const;
00085 
00087 
00091     void SetHeightMatchContent (bool match_content);
00092 
00094     bool GetHeightMatchContent () const;
00095 
00097 
00105     virtual void ProcessDraw (GraphicsEngine &GfxContext, bool force_draw);
00106 
00107   protected:
00108     int GetChildPos (Area *child);
00109     Area* GetChildAtPosition (int pos);
00110     virtual long DoFocusUp  (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00111     virtual long DoFocusDown (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00112     virtual long DoFocusLeft  (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00113     virtual long DoFocusRight (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00114     
00115   private:
00116     Size _children_size;
00117     bool _dynamic_column;
00118     bool _force_children_size;
00119     bool _partial_visibility;
00120     bool _height_match_content; 
00121 
00122     int _num_row;
00123     int _num_column;
00124 
00125 //     //! Compute the how elements are spread inside the layout
00126 //     /*!
00127 //         @param remaining_width  Size that remains after subtracting elements width, inner and outer margins from the content width.
00128 //         @param offset_space     The space at the left of all elements.
00129 //         @param element_margin   The margin between elements.
00130 //     */
00131 //     void ComputeStacking (t_s32 remaining_width, t_s32 &offset_space, t_s32 &element_margin);
00132   };
00133 }
00134 
00135 #endif // GRIDHLAYOUT_H