| 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 | // Comment out the two alines above and
|
| 69 | // uncomment the one below
|
| 70 | // clicked();
|
| 71 | }
|
| 72 |
|
| 73 | void WebApp::clicked() {
|
| 74 | log( "info" ) << "Clicked!";
|
| 75 | WHBoxLayout* hbl = new WHBoxLayout();
|
| 76 | main->setLayout( hbl );
|
| 77 |
|
| 78 | int rows = 32;
|
| 79 | int cols = 4;
|
| 80 | WStandardItemModel *model = new WStandardItemModel( rows,cols );
|
| 81 |
|
| 82 | for( int col=0; col<cols; col++ )
|
| 83 | model->setHeaderData( col,boost::any( "COL "+boost::lexical_cast<std::string>( col ) ) );
|
| 84 | for( int row=0; row<rows; ++row ) {
|
| 85 | for( int col = 0; col<cols; col++ ) {
|
| 86 | WStandardItem *item = new WStandardItem();
|
| 87 | item->setText( "Item "+boost::lexical_cast<std::string>( row )+"."+boost::lexical_cast<std::string>( col ) );
|
| 88 | model->setItem( row,col,item );
|
| 89 | }
|
| 90 | }
|
| 91 |
|
| 92 | Ext::TableView *table = new Ext::TableView();
|
| 93 | table->setModel( model );
|
| 94 | table->setAlternatingRowColors( true );
|
| 95 | table->setHighlightMouseOver( true );
|
| 96 | table->setColumnAlignment( 2,AlignRight );
|
| 97 | hbl->addWidget( table );
|
| 98 | }
|
| 99 |
|
| 100 | WApplication* ApplicationFactory( const WEnvironment& env ) {
|
| 101 | WebApp* wa = new WebApp( env );
|
| 102 | wa->useStyleSheet( "acss.css" );
|
| 103 | wa->setTitle( "Window's title" );
|
| 104 | wa->head->addWidget( new WText( "This is the activity panel" ) );
|
| 105 | wa->refresh();
|
| 106 | return wa;
|
| 107 | }
|
| 108 |
|
| 109 | int main( int argc, char* argv[] ) {
|
| 110 | return WRun( argc,argv,&ApplicationFactory );
|
| 111 | }
|
| 112 |
|
| 113 | //EOF
|