|  | #ifndef WUI_TABLE_VIEW_H
 | 
  
    |  | #define WUI_TABLE_VIEW_H
 | 
  
    |  | 
 | 
  
    |  | #include "WUI_TableView.h"
 | 
  
    |  | #include "WUI_Form_Dialog.h"
 | 
  
    |  | 
 | 
  
    |  | #include <Wt/WDialog>
 | 
  
    |  | #include <Wt/WPushButton>
 | 
  
    |  | #include <Wt/WVBoxLayout>
 | 
  
    |  | #include <Wt/WHBoxLayout>
 | 
  
    |  | #include <Wt/WGridLayout>
 | 
  
    |  | #include <Wt/WLabel>
 | 
  
    |  | #include <Wt/WLabel>
 | 
  
    |  | #include <Wt/WBreak>
 | 
  
    |  | #include <Wt/WBorder>
 | 
  
    |  | #include <Wt/WText>
 | 
  
    |  | #include <Wt/Dbo/Dbo>
 | 
  
    |  | using namespace Wt;
 | 
  
    |  | using namespace Wt::Dbo;
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | #include <string>
 | 
  
    |  | using namespace std;
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | template <class Result>
 | 
  
    |  | class WUI_Table_View_Form : public WContainerWidget
 | 
  
    |  | {
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @class DBInterfaceView
 | 
  
    |  | 	 * @brief Template class for showing all tables and settings
 | 
  
    |  | 	 */
 | 
  
    |  | private:
 | 
  
    |  | 	Wt::WGridLayout * layout_grid_main;
 | 
  
    |  |     Wt::WContainerWidget * header;
 | 
  
    |  | 	Wt::WHBoxLayout * layout_H_head;
 | 
  
    |  | 	Wt::WContainerWidget * footer;
 | 
  
    |  | 	Wt::WHBoxLayout * layout_h_foot;
 | 
  
    |  | 	Wt::WText * label_dialog_name;
 | 
  
    |  | public:
 | 
  
    |  | 	Wt::WPushButton *add;
 | 
  
    |  | 	Wt::WPushButton *remove;
 | 
  
    |  | 	Wt::WPushButton *edit;
 | 
  
    |  | 	WUI_TableView <Result> * contents;
 | 
  
    |  | 	Wt::WPushButton *ok;
 | 
  
    |  | 	Wt::WPushButton *cancel;
 | 
  
    |  | 
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @class WUI_Table_View();
 | 
  
    |  | 	 * @brief Default constructor(Does nothing)
 | 
  
    |  | 	 */
 | 
  
    |  | 	WUI_Table_View_Form(){;}
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @fn WUI_Table_View_Form(string dialog_label,Query <Result> * query,bool ok = true ,bool cancel=false)
 | 
  
    |  | 	 * @brief Specialized constructor
 | 
  
    |  | 	 * It creates the whole form
 | 
  
    |  | 	 */
 | 
  
    |  | 	WUI_Table_View_Form(string dialog_label,Query <Result> * query,bool ok = true ,bool cancel=false)
 | 
  
    |  | 	{
 | 
  
    |  |         layout_grid_main = new Wt::WGridLayout();
 | 
  
    |  |         header = new Wt::WContainerWidget();
 | 
  
    |  |         layout_H_head = new WHBoxLayout();
 | 
  
    |  |         footer = new Wt::WContainerWidget();
 | 
  
    |  |         layout_h_foot = new Wt::WHBoxLayout();
 | 
  
    |  |         label_dialog_name = new Wt::WText();
 | 
  
    |  |         contents = new WUI_TableView<Result>(query);
 | 
  
    |  | 
 | 
  
    |  | 		this->setOverflow(OverflowHidden);
 | 
  
    |  |         header->setStyleClass("dialog-head");
 | 
  
    |  | 
 | 
  
    |  | 		this->add = new WPushButton();
 | 
  
    |  | 		add->setIcon("resource/add.png");
 | 
  
    |  | 		this->remove = new WPushButton();
 | 
  
    |  | 		remove->setIcon("resource/remove.png");
 | 
  
    |  | 		this->edit = new WPushButton();
 | 
  
    |  | 		edit->setIcon("resource/edit.png");
 | 
  
    |  | 		this->add->setMaximumSize(48,48);
 | 
  
    |  | 		this->remove->setMaximumSize(48,48);
 | 
  
    |  | 		this->edit->setMaximumSize(48,48);
 | 
  
    |  | 
 | 
  
    |  | 		contents->view->resize(875,300);
 | 
  
    |  | 		contents->resize(875,300);
 | 
  
    |  | 		contents->setMaximumSize(875,300);
 | 
  
    |  | 
 | 
  
    |  | 		layout_H_head->addWidget(add,0);
 | 
  
    |  | 		layout_H_head->addWidget(remove,0);
 | 
  
    |  | 		layout_H_head->addWidget(edit,0);
 | 
  
    |  | 		layout_H_head->addStretch(10);
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | 		label_dialog_name->setText(dialog_label);
 | 
  
    |  |         header->addWidget(label_dialog_name);
 | 
  
    |  | 
 | 
  
    |  |         layout_grid_main->addWidget(header,1,1);
 | 
  
    |  | 		layout_grid_main->addLayout(layout_H_head,2,1);
 | 
  
    |  | 		layout_grid_main->addWidget(contents,3,1);
 | 
  
    |  | 
 | 
  
    |  | 		setFooter(ok,cancel);
 | 
  
    |  | 
 | 
  
    |  | 		layout_grid_main->setRowStretch(1,0);
 | 
  
    |  | 		layout_grid_main->setRowStretch(2,10);
 | 
  
    |  | 		layout_grid_main->setRowStretch(3,0);
 | 
  
    |  | 		layout_grid_main->setVerticalSpacing(2);
 | 
  
    |  | 
 | 
  
    |  | 		this->setLayout(layout_grid_main);
 | 
  
    |  | 		setMinimumSize(150,400);
 | 
  
    |  | 
 | 
  
    |  | 		return;
 | 
  
    |  | 	}
 | 
  
    |  | 
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @fn Wt::WContainerWidget * getContentsWid(){return this->contents;}
 | 
  
    |  | 	 * @brief Makes access to the diaolg contents
 | 
  
    |  | 	 */
 | 
  
    |  | 	Wt::WContainerWidget * getContentsWid(){return this->contents;}
 | 
  
    |  | 
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @fn void setFooter(bool ok, bool cancel)
 | 
  
    |  | 	 * @brief Creates the buttom buttons
 | 
  
    |  | 	 *
 | 
  
    |  | 	 */
 | 
  
    |  | 	void setFooter(bool ok, bool cancel)
 | 
  
    |  | 	{
 | 
  
    |  | 		this->ok = new Wt::WPushButton("Apply");
 | 
  
    |  | 		this->ok->setDefault(true);
 | 
  
    |  | 		this->ok->setMinimumSize(60,10);
 | 
  
    |  | 		this->cancel = new Wt::WPushButton("Cancel");
 | 
  
    |  | 		this->cancel->setDefault(false);
 | 
  
    |  | 		layout_h_foot->addStretch(10);
 | 
  
    |  | 		if (ok)
 | 
  
    |  | 		{
 | 
  
    |  | 			layout_h_foot->addWidget(this->ok);
 | 
  
    |  | 		}
 | 
  
    |  | 		if(cancel)
 | 
  
    |  | 		{
 | 
  
    |  | 			layout_h_foot->addWidget(this->cancel);
 | 
  
    |  | 		}
 | 
  
    |  | 		footer->setLayout(layout_h_foot);
 | 
  
    |  | 		//footer->setStyleClass("bordered-content");
 | 
  
    |  | 		if(ok||cancel)
 | 
  
    |  | 		{
 | 
  
    |  | 			layout_grid_main->addWidget(footer,4,1);
 | 
  
    |  | 		}
 | 
  
    |  | 		return;
 | 
  
    |  | 	}
 | 
  
    |  | 
 | 
  
    |  | 	/**
 | 
  
    |  | 	 * @fn ~WUI_Table_View_Form()
 | 
  
    |  | 	 * @brief Default Destructor
 | 
  
    |  | 	 *
 | 
  
    |  | 	 */
 | 
  
    |  | 	~WUI_Table_View_Form()
 | 
  
    |  | 	{
 | 
  
    |  | //        delete this->contents;
 | 
  
    |  | //        delete this->label_dialog_name;
 | 
  
    |  | //        delete this->header;
 | 
  
    |  | //        delete this->add;
 | 
  
    |  | //        delete this->remove;
 | 
  
    |  | //        delete this->edit;
 | 
  
    |  | //        delete this->ok;
 | 
  
    |  | //        delete this->cancel;
 | 
  
    |  | //        delete this->layout_H_head;
 | 
  
    |  | //        delete this->layout_h_foot;
 | 
  
    |  |         delete this->layout_grid_main;
 | 
  
    |  |     }
 | 
  
    |  | };
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | 
 | 
  
    |  | #endif // WUI_TABLE_VIEW_H
 |