nux-1.16.0
gridlayout.cpp
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 General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00018  *
00019  */
00020 
00021 #include "Nux/Nux.h"
00022 #include "Nux/WindowThread.h"
00023 #include "NuxGraphics/GraphicsEngine.h"
00024 
00025 #include "Nux/TextureArea.h"
00026 #include "Nux/HLayout.h"
00027 #include "Nux/VLayout.h"
00028 #include "Nux/GridHLayout.h"
00029 #include "Nux/GridVLayout.h"
00030 
00031 
00032 void GridLayoutInit(nux::NThread* thread, void* InitData)
00033 {
00034   int a = 0;
00035 
00036   nux::HLayout *main_layout((new nux::HLayout(NUX_TRACKER_LOCATION)));
00037 
00038   nux::GridHLayout *grid_h_layout ((new nux::GridHLayout (NUX_TRACKER_LOCATION)));
00039   for (int i = 0; i < 30; i++)
00040   {
00041     nux::ColorLayer color (nux::color::RandomColor ());
00042     nux::TextureArea* texture_area = new nux::TextureArea ();
00043     texture_area->SetPaintLayer (&color);
00044     texture_area->SetVisible (a % 2);
00045     grid_h_layout->AddView (texture_area, 1, nux::eLeft, nux::eFull);
00046 
00047     a++;
00048   }
00049 
00050   grid_h_layout->ForceChildrenSize (true);
00051   grid_h_layout->SetChildrenSize (64, 42);
00052   grid_h_layout->EnablePartialVisibility (false);
00053 
00054   grid_h_layout->SetVerticalExternalMargin (4);
00055   grid_h_layout->SetHorizontalExternalMargin (4);
00056   grid_h_layout->SetVerticalInternalMargin (4);
00057   grid_h_layout->SetHorizontalInternalMargin (4);
00058 
00059 
00060   nux::GridVLayout *grid_v_layout ((new nux::GridVLayout (NUX_TRACKER_LOCATION)));
00061   for (int i = 0; i < 30; i++)
00062   {
00063     nux::ColorLayer color (nux::color::RandomColor());
00064     nux::TextureArea* texture_area = new nux::TextureArea();
00065     texture_area->SetPaintLayer (&color);
00066     texture_area->SetVisible (a % 2);
00067     grid_v_layout->AddView(texture_area, 1, nux::eLeft, nux::eFull);
00068 
00069     a++;
00070   }
00071 
00072   grid_v_layout->ForceChildrenSize (true);
00073   grid_v_layout->SetChildrenSize (64, 64);
00074   grid_v_layout->EnablePartialVisibility (false);
00075 
00076   grid_v_layout->SetVerticalExternalMargin (6);
00077   grid_v_layout->SetHorizontalExternalMargin (6);
00078   grid_v_layout->SetVerticalInternalMargin (6);
00079   grid_v_layout->SetHorizontalInternalMargin (6);
00080 
00081 
00082   main_layout->AddLayout (grid_h_layout, 1);
00083   main_layout->AddLayout (grid_v_layout, 1);
00084   
00085   nux::GetWindowThread ()->SetLayout(main_layout);
00086 }
00087 
00088 int main(int argc, char **argv)
00089 {
00090   nux::NuxInitialize(0);
00091 
00092   nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Grid Layout"), 1024, 600, 0, &GridLayoutInit, 0);
00093   wt->Run(NULL);
00094 
00095   delete wt;
00096 
00097   return 0;
00098 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends