#include "bbtkWtBlackBox.h"
#include "bbtkBlackBoxOutputConnector.h"
-//DELETE ME
-#include <Wt/WContainerWidget>
+
//#include "bbtkWxContainerBlackBox.h"
//#include <wx/dialog.h>
namespace bbtk
{
//=========================================================================
+ // wtData structure
+ //=========================================================================
+ struct wtData
+ {
+ Wt::WContainerWidget *parent;
+ WtBlackBox::Pointer b;
+ Wt::WString title;
+ };
+
+ static wtData myWtData;
+ //=========================================================================
// WxFrame
//=========================================================================
-
+ // Application WT deployed
//==================================================================
- class WtWContainer : public Wt::WContainerWidget
+
+
+
+ class WtWFrame : public Wt::WApplication
{
public:
- WtWContainer(WtBlackBox::Pointer b,
- Wt::WContainerWidget *parent,
- Wt::WString title/*,
- wxSize size);*/
+ WtWFrame(
+ const Wt::WEnvironment& env
);
- ~WtWContainer();
- // void OnCloseWindow(wxCloseEvent& event);
+ ~WtWFrame();
+
+
+
+ WtBlackBox::WeakPointer mBox;
- WtBlackBox::WeakPointer mBox;
- // DECLARE_EVENT_TABLE();
-
};
-
- // BEGIN_EVENT_TABLE(WxFrame, wxFrame)
- // EVT_CLOSE(WxFrame::OnCloseWindow)
- //END_EVENT_TABLE();
- //==================================================================
-
- //==================================================================
-
- WtWContainer::WtWContainer(WtBlackBox::Pointer b,
- Wt::WContainerWidget *parent,
- Wt::WString title/*,
- wxSize size) */
+
+
+ WtWFrame::WtWFrame(
+ const Wt::WEnvironment& env
)
:
- Wt::WContainerWidget( parent),
- mBox(b)
- {
- bbtkDebugMessage("widget",9,"["<<b->bbGetName()<<"] Wt::Widget()"
- <<std::endl);
- Wt::WObject::setObjectName(bbtk::wt2std(title));
- WWt::IncNbWindowsAlive();
- b->bbSetWindow(this);
- // Insert the widget into the window
- //wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
- std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................30%"<<std::endl;
- std::cout<<"NAME : "<<bbtk::wt2std(title);
- if(parent)
- std::cout<<" CON PADRE "<<parent->objectName()<<std::endl;
- else
- std::cout<<" SIN PADRE "<<std::endl;
+ Wt::WApplication(env)
+ {
+
+ mBox = myWtData.b;
+ if(!myWtData.parent)
+ {
+ std::cout<<" SIN PADRE "<<std::endl;
+ if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
+ if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
+ myWtData.parent = new Wt::WContainerWidget();
+ std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
+ }
+
+ Wt::WContainerWidget *myCont = new Wt::WContainerWidget(myWtData.parent);
+ myCont->setMinimumSize(800,500);
std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
- std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................55%"<<std::endl;
- //this->addWidget(new Wt::WContainerWidget());
- std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................58%"<<std::endl;
- b->bbUserCreateWidget(this);
- Wt::WContainerWidget* widget = b->bbGetOutputWidget();
- this->addWidget(widget);
- /* Wt::WWidget* widget = b->bbGetOutputWidget();
- sizer->Add( widget, 1, wxALL|wxGROW, 2);
- SetSizer(sizer);
- Layout();
-*/
+ myWtData.b->bbUserCreateWidget(myCont);
+ root()->addWidget(myWtData.parent);
+ //bbmWindow = myCont;
+ std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................80%"<<std::endl;
+
+
}
//==================================================================
//==================================================================
- WtWContainer::~WtWContainer()
+ WtWFrame::~WtWFrame()
{
if (mBox.lock())
bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
<<std::endl);
else
bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
- //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
+ bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
if (mBox.lock()) mBox.lock()->bbSetWindow(0);
WWt::DecNbWindowsAlive();
}
+
+
+ Wt::WApplication *createApplication(const Wt::WEnvironment& env)
+ {
+ return new WtWFrame(env);
+ }
- //==================================================================
//=========================================================================
- // WxDialog
+ // WxDialogWxBlackBox::Pointer box
//=========================================================================
//==================================================================
wxWindow *parent,
wxString title,
wxSize size);
- ~WxDialog();
+ ~WxDialog();Wt::GetTopWindow()
void OnCloseWindow(wxCloseEvent& event);
mBox(b)
{
bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
- <<std::endl);
+ <<std::endl);WxBlackBox::Pointer box
Wx::IncNbWindowsAlive();
b->bbSetWindow(this);
// Insert the widget into the window
//=========================================================================
//=========================================================================
BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
+
//=========================================================================
-
//=========================================================================
void WtBlackBox::bbUserSetDefaultValues()
{
//=========================================================================
void WtBlackBox::bbUserInitializeProcessing()
{
- //TODO delete this commment
- std::cout<<"Initializing WT BlackBox --- DELETE this message bbtkWtBlackBox.cxx"<<std::endl;
+
}
- //==================================================================
+ //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
//=========================================================================
void WtBlackBox::bbUserFinalizeProcessing()
/// Callback for creating a Dialog window (modal)
void WtBlackBox::bbCreateDialogWindow()
{
- bbtkBlackBoxDebugMessage("widget",3,
+ bbtkBlackBoxDebugMessage("widget",3,
"==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
<<std::endl);
- /* WxDialog* w = 0;
- w = new WxDialog( GetThisPointer<WxBlackBox>(),
- Wx::GetTopWindow(),
- std2wx( bbGetInputWinTitle()
- + " - bbtk (c) CREATIS"),
- wxSize( bbGetInputWinWidth() ,
- bbGetInputWinHeight() ) );
- w->Show(false);
- // w->ShowModal();
-*/
+
}
//=========================================================================
//==================================================================
/// Callback for creating a Frame window
- void WtBlackBox::bbCreateFrameWindow()
- {
-
- std::cout<<"Creating Container WT -- DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
- bbtkBlackBoxDebugMessage("widget",3,
- "==> WtBlackBox::bbCreateFrameWindow() - parent = "
- <<WWt::GetTopWindow()
- <<std::endl);
- WtWContainer* w = 0;
-// WxFrame* w = 0;
- w = new WtWContainer( GetThisPointer<WtBlackBox>(),
- WWt::GetTopWindow(),
- std2wt( bbGetInputWinTitle()
- + " - bbtk (c) CREATIS")
- );
- std::cout<<"Container created succesfully -- DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
- bbmWindow = w;
-
-/*
- w = new WxFrame( GetThisPointer<WxBlackBox>(),
- Wx::GetTopWindow(),
- std2wx( bbGetInputWinTitle()
- + " - bbtk (c) CREATIS"),
- wxSize( bbGetInputWinWidth() ,
- bbGetInputWinHeight() ) );
-
- w->Show();
-*/
- WWt::CreateWtAppIfNeeded();
- }
+ void WtBlackBox::bbCreateFrameWindow()
+ {
+
+ bbtkBlackBoxDebugMessage("widget",3,
+ "==> WtBlackBox::bbCreateFrameWindow() - parent = "
+ <<WWt::GetTopWindow()
+ <<std::endl);
+
+ //Setting necessary data for Wt server deployment
+ myWtData.parent = WWt::GetTopWindow();
+ myWtData.b = GetThisPointer<WtBlackBox>();
+ myWtData.title = std2wt( bbGetInputWinTitle()
+ + " - bbtk (c) CREATIS");
+
+ std::cout<<"Creating Container WT -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
+ char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
+ int argc = 7;
+ /* if(Wt::WServer::instance()->isRunning())
+ {
+ std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
+ Wt::WServer::instance()->stop();
+ }
+ */
+ std::cout<<"Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
+ Wt::WRun(argc,argv,&createApplication);
+ }
//==================================================================
}
bbmWindow = w;
}
- //==================================================================
- //==================================================================
+
+
+ //==================================================================
+
+ //==================================================================
void WtBlackBox::bbShowWindow()
{
if ((bbmWindow) && (!bbIsShown()))
{
// There is not such a thing like show becouse it is a webapp
// bbGetWindow()->Show();
- WWt::CreateWtAppIfNeeded();
+ // WWt::CreateWtAppIfNeeded();
bbSetShown(true);
}
}
BEGIN_EVENT_TABLE(WxFrame, wxFrame)
// EVT_CLOSE(WxFrame::OnCloseWindow)
END_EVENT_TABLE();
- //==================================================================
+ //==========================================Window ========================
//==================================================================
WxFrame::WxFrame(WxBlackBox::Pointer b,
b->bbSetWindow(this);
// Insert the widget into the window
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+ std::cout<<"------------------------------------USER CREATE WIDGET pre DELETE ME bbtkWxBlackBox.cxx--"<<std::endl;
b->bbUserCreateWidget(this);
+ std::cout<<"------------------------------------USER CREATE WIDGET post DELETE ME bbtkWxBlackBox.cxx--"<<std::endl;
wxWindow* widget = b->bbGetOutputWidget();
sizer->Add( widget, 1, wxALL|wxGROW, 2);
SetSizer(sizer);
}
//==================================================================
- //=========================================================================
+ //====================================================SetWin=====================
// WxDialog
//=========================================================================
void WxBlackBox::bbUserSetDefaultValues()
{
bbtkBlackBoxDebugMessage("widget",5,"WxBlackBox::bbUserSetDefaultValues()"<<std::endl);
- bbmWindow = 0;
+ bbmWindow = 0;
}
//=========================================================================
/// Callback for creating a Frame window
void WxBlackBox::bbCreateFrameWindow()
{
+ std::cout<<"--/////////////*****////////////////--JFGA Testing bbCreateFrameWindow Starting ....."<<bbGetInputWinTitle()<<"......!! D E L E T M E !! bbtkWxBlackBox.cxx"<<std::endl;
bbtkBlackBoxDebugMessage("widget",3,
"==> WxBlackBox::bbCreateFrameWindow() - parent = "
<<Wx::GetTopWindow()
+ " - bbtk (c) CREATIS"),
wxSize( bbGetInputWinWidth() ,
bbGetInputWinHeight() ) );
- std::cout<<"--!!--JFGA Testing bbCreateFrameWindow "<<bbGetInputWinTitle()<<"......!! D E L E T M E !! bbtkWxBlackBox.cxx"<<std::endl;
+ std::cout<<"--/////////////*****////////////////!!--JFGA Testing bbCreateFrameWindow Done ........"<<bbGetInputWinTitle()<<"......!! D E L E T M E !! bbtkWxBlackBox.cxx"<<std::endl;
w->Show();
}