| 1 | #include <Wt/WApplication>
|
| 2 | #include <Wt/WText>
|
| 3 | #include <Wt/WLogger>
|
| 4 | #include <Wt/WHBoxLayout>
|
| 5 | #include <Wt/WVBoxLayout>
|
| 6 | #include <Wt/WContainerWidget>
|
| 7 | #include <Wt/WPushButton>
|
| 8 | #include <Wt/WStandardItemModel>
|
| 9 | #include <Wt/WStandardItem>
|
| 10 | #include <Wt/WTreeView>
|
| 11 |
|
| 12 | #include <Wt/Ext/TableView>
|
| 13 |
|
| 14 | #include <boost/lexical_cast.hpp>
|
| 15 |
|
| 16 | using namespace Wt;
|
| 17 |
|
| 18 | struct WebApp: public WApplication {
|
| 19 | WebApp( const WEnvironment& env );
|
| 20 |
|
| 21 | WContainerWidget* head;
|
| 22 | WContainerWidget* menu;
|
| 23 | WContainerWidget* main;
|
| 24 | WContainerWidget* tail;
|
| 25 | WContainerWidget* time;
|
| 26 |
|
| 27 | void clicked();
|
| 28 | void makeMenu();
|
| 29 | };
|
| 30 |
|
| 31 | WebApp::WebApp( const WEnvironment& env ):
|
| 32 | WApplication( env )
|
| 33 | {
|
| 34 | head = new WContainerWidget();
|
| 35 | head->setId( "head" );
|
| 36 | head->setStyleClass( "lean" );
|
| 37 |
|
| 38 | menu = new WContainerWidget();
|
| 39 | menu->setId( "menu" );
|
| 40 | menu->setStyleClass( "lean" );
|
| 41 |
|
| 42 | main = new WContainerWidget();
|
| 43 | main->setId( "main" );
|
| 44 | main->setStyleClass( "lean" );
|
| 45 |
|
| 46 | tail = new WContainerWidget();
|
| 47 | tail->setId( "tail" );
|
| 48 | tail->setStyleClass( "lean" );
|
| 49 |
|
| 50 | time = new WContainerWidget();
|
| 51 | time->setId( "time" );
|
| 52 | root()->addWidget( time );
|
| 53 |
|
| 54 | WVBoxLayout* vb1 = new WVBoxLayout();
|
| 55 | vb1->addWidget( head,2 );
|
| 56 | vb1->addWidget( menu,8 );
|
| 57 | WVBoxLayout* vb2 = new WVBoxLayout();
|
| 58 | vb2->addWidget( main,9 );
|
| 59 | vb2->addWidget( tail,1 );
|
| 60 |
|
| 61 | WHBoxLayout* hbl = new WHBoxLayout();
|
| 62 | hbl->addLayout( vb1,3 );
|
| 63 | hbl->addLayout( vb2,7 );
|
| 64 | root()->setLayout( hbl );
|
| 65 |
|
| 66 | WPushButton *butt = new WPushButton( "Go!",menu );
|
| 67 | butt->clicked().connect( this,&WebApp::clicked );
|
| 68 | }
|
| 69 |
|
| 70 | void WebApp::clicked() {
|
| 71 | WApplication::log( "info" ) << "Clicked!";
|
| 72 | WHBoxLayout* hbl = new WHBoxLayout();
|
| 73 | main->setLayout( hbl );
|
| 74 | int rows=54;
|
| 75 | int cols=40;
|
| 76 |
|
| 77 | WStandardItemModel *model = new WStandardItemModel( rows,cols );
|
| 78 |
|
| 79 | for( int col=0; col<cols; col++ )
|
| 80 | model->setHeaderData( col,boost::any( "COL "+boost::lexical_cast<std::string>( col ) ) );
|
| 81 | for( int row=0; row<rows; ++row ) {
|
| 82 | for( int col = 0; col<cols; col++ ) {
|
| 83 | WStandardItem *item = new WStandardItem();
|
| 84 | item->setText( "Item "+boost::lexical_cast<std::string>( row )+"."+boost::lexical_cast<std::string>( col ) );
|
| 85 | model->setItem( row,col,item );
|
| 86 | }
|
| 87 | }
|
| 88 |
|
| 89 | Ext::TableView *table = new Ext::TableView();
|
| 90 | table->setModel( model );
|
| 91 | table->setAlternatingRowColors( true );
|
| 92 | table->setHighlightMouseOver( true );
|
| 93 | table->setColumnAlignment( 2,AlignRight );
|
| 94 | hbl->addWidget( table );
|
| 95 | }
|
| 96 |
|
| 97 | WApplication* ApplicationFactory( const WEnvironment& env ) {
|
| 98 | WebApp* wa = new WebApp( env );
|
| 99 | wa->useStyleSheet( "acss.css" );
|
| 100 | wa->setTitle( "Window's title" );
|
| 101 | wa->head->addWidget( new WText( "Activity" ) );
|
| 102 | wa->refresh();
|
| 103 | return wa;
|
| 104 | }
|
| 105 |
|
| 106 | int main( int argc, char* argv[] ) {
|
| 107 | return WRun( argc,argv,&ApplicationFactory );
|
| 108 | }
|
| 109 |
|
| 110 | //EOF
|