nux-1.14.0
tab_view.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/VLayout.h"
00023 #include "Nux/WindowThread.h"
00024 #include "Nux/TabView.h"
00025 #include "Nux/TextureArea.h"
00026 #include "Nux/PaintLayer.h"
00027 
00028 void UserInterfaceInitialization(nux::NThread* thread, void* init_data)
00029 {
00030   // Create a vertical Layout
00031   nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
00032   
00033   nux::TabView* tabview(new nux::TabView());
00034   
00035   nux::ColorLayer color_layer (nux::color::Black, true);
00036   nux::VLayout *tab_view_layout = 0;
00037   nux::TextureArea *texture_area = 0;
00038 
00039   for (int i = 0; i < 50; i++)
00040   {
00041     tab_view_layout = new nux::VLayout ();
00042     texture_area = new nux::TextureArea ();
00043     color_layer.SetColor (nux::color::RandomColor ());
00044     texture_area->SetPaintLayer (&color_layer);
00045 
00046     tab_view_layout->AddView (texture_area, 1);
00047 
00048     nux::NString str = nux::NString::Printf("View %d", i);
00049 
00050     tabview->AddTab (str.GetTCharPtr (), tab_view_layout);
00051   }
00052 
00053   // Add the button to the layout
00054   layout->AddView (
00055     tabview,
00056     1,
00057     nux::MINOR_POSITION_CENTER,
00058     nux::MINOR_SIZE_FULL);
00059 
00060   // Set the layout as the container of the window thread
00061   nux::GetWindowThread ()->SetLayout (layout);
00062 
00063   // Set the background color of the window
00064   nux::ColorLayer background (nux::Color (0xFF2D2D2D));
00065   static_cast<nux::WindowThread*> (thread)->SetWindowBackgroundPaintLayer(&background);
00066 }
00067 
00068 int main(int argc, char **argv)
00069 {
00070   // Initialize Nux subsystem
00071   nux::NuxInitialize (0);
00072 
00073   // Create a Window thread
00074   nux::WindowThread* wt = nux::CreateGUIThread(
00075     TEXT("Tab View"),
00076     400,
00077     300,
00078     0,
00079     &UserInterfaceInitialization,
00080     0);
00081 
00082   // Start the main loop
00083   wt->Run (0);
00084 
00085   delete wt;
00086   return 0;
00087 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends