nux-1.14.0
|
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/VLayout.h" 00023 #include "Nux/HLayout.h" 00024 #include "Nux/WindowThread.h" 00025 #include "Nux/TextEntry.h" 00026 #include "Nux/ScrollView.h" 00027 #include "Nux/GridHLayout.h" 00028 #include "Nux/GridVLayout.h" 00029 #include "Nux/TextureArea.h" 00030 #include "Nux/Panel.h" 00031 00032 void ThreadWidgetInit(nux::NThread* thread, void* InitData) 00033 { 00034 nux::VLayout* MainVLayout = new nux::VLayout(NUX_TRACKER_LOCATION); 00035 00036 nux::GridHLayout *grid_h_layout ((new nux::GridHLayout (NUX_TRACKER_LOCATION))); 00037 for (int i = 0; i < 5360; i++) 00038 { 00039 nux::ColorLayer color (nux::color::RandomColor ()); 00040 nux::TextureArea* texture_area = new nux::TextureArea (); 00041 texture_area->SetPaintLayer (&color); 00042 00043 grid_h_layout->AddView (texture_area, 1, nux::eLeft, nux::eFull); 00044 } 00045 00046 grid_h_layout->ForceChildrenSize (true); 00047 grid_h_layout->SetChildrenSize (64, 42); 00048 grid_h_layout->EnablePartialVisibility (true); 00049 00050 grid_h_layout->SetVerticalExternalMargin (4); 00051 grid_h_layout->SetHorizontalExternalMargin (4); 00052 grid_h_layout->SetVerticalInternalMargin (4); 00053 grid_h_layout->SetHorizontalInternalMargin (4); 00054 00055 00056 nux::ScrollView *scroll_view = new nux::ScrollView(NUX_TRACKER_LOCATION); 00057 00058 grid_h_layout->SetStretchFactor(1); 00059 scroll_view->SetLayout(grid_h_layout); 00060 00061 MainVLayout->AddView(scroll_view, 1, nux::eCenter, nux::eFull); 00062 MainVLayout->SetContentDistribution(nux::eStackCenter); 00063 00064 nux::GetWindowThread ()->SetLayout(MainVLayout); 00065 nux::ColorLayer background(nux::Color(0xFF4D4D4D)); 00066 static_cast<nux::WindowThread*>(thread)->SetWindowBackgroundPaintLayer(&background); 00067 } 00068 00069 int main(int argc, char **argv) 00070 { 00071 nux::NuxInitialize(0); 00072 nux::WindowThread* wt = nux::CreateGUIThread(TEXT("ScrollView"), 400, 300, 0, &ThreadWidgetInit, 0); 00073 wt->Run(NULL); 00074 00075 delete wt; 00076 return 0; 00077 }