nux-1.16.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/WindowThread.h" 00024 #include "Nux/CheckBox.h" 00025 #include "Nux/ToggleButton.h" 00026 #include "Nux/Button.h" 00027 #include "Nux/TextureArea.h" 00028 00029 void UserInterfaceInitialization(nux::NThread* thread, void* init_data) 00030 { 00031 // Create a vertical Layout 00032 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION); 00033 00034 //Create a button of type Button 00035 nux::Button* button = new nux::Button ("Party on Garth", NUX_TRACKER_LOCATION); 00036 00037 // Add the button to the layout 00038 layout->AddView ( 00039 button, 00040 0, 00041 nux::MINOR_POSITION_CENTER, 00042 nux::MINOR_SIZE_MATCHCONTENT); 00043 00044 // Create a button with an image 00045 nux::ColorLayer color (nux::Color (0.6, 0.4, 0.7, 1.0)); 00046 nux::TextureArea* texture_area = new nux::TextureArea (); 00047 texture_area->SetPaintLayer (&color); 00048 00049 nux::Button* button_with_image = new nux::Button("Party on Wayne", texture_area, NUX_TRACKER_LOCATION); 00050 //button_with_image->image_position = nux::NUX_POSITION_BOTTOM; 00051 00052 // Add the button to the layout 00053 layout->AddView ( 00054 button_with_image, 00055 0, 00056 nux::MINOR_POSITION_CENTER, 00057 nux::MINOR_SIZE_MATCHCONTENT); 00058 00059 color = nux::Color (0.6, 0.4, 0.7, 1.0); 00060 texture_area = new nux::TextureArea (); 00061 texture_area->SetPaintLayer (&color); 00062 00063 nux::Button* button_without_image = new nux::Button(texture_area, NUX_TRACKER_LOCATION); 00064 00065 // Add the button to the layout 00066 layout->AddView ( 00067 button_without_image, 00068 0, 00069 nux::MINOR_POSITION_CENTER, 00070 nux::MINOR_SIZE_MATCHCONTENT); 00071 00072 nux::ToggleButton *toggle_button = new nux::ToggleButton ("This is a Toggle button, nux just doesn't have a theme for that", NUX_TRACKER_LOCATION); 00073 layout->AddView ( 00074 toggle_button, 00075 0, 00076 nux::MINOR_POSITION_CENTER, 00077 nux::MINOR_SIZE_MATCHCONTENT); 00078 00079 nux::CheckBox *check_button = new nux::CheckBox ("Check box widget? Check!", NUX_TRACKER_LOCATION); 00080 layout->AddView ( 00081 check_button, 00082 0, 00083 nux::MINOR_POSITION_CENTER, 00084 nux::MINOR_SIZE_MATCHCONTENT); 00085 00086 // Control the position of elements inside the layout 00087 layout->SetContentDistribution (nux::MAJOR_POSITION_CENTER); 00088 00089 // Set the layout as the container of the window thread 00090 nux::GetWindowThread ()->SetLayout (layout); 00091 00092 // Set the background color of the window 00093 nux::ColorLayer background (nux::Color (0xFF222222)); 00094 static_cast<nux::WindowThread*> (thread)->SetWindowBackgroundPaintLayer(&background); 00095 } 00096 00097 int main(int argc, char **argv) 00098 { 00099 // Initialize Nux subsystem 00100 nux::NuxInitialize (0); 00101 00102 // Create a Window thread 00103 nux::WindowThread* wt = nux::CreateGUIThread( 00104 TEXT("Button"), 00105 800, 00106 600, 00107 0, 00108 &UserInterfaceInitialization, 00109 0); 00110 00111 // Start the main loop 00112 wt->Run (0); 00113 00114 delete wt; 00115 return 0; 00116 }