Exemplo n.º 1
0
WImage *WItemDelegate::iconWidget(WidgetRef& w,
                                  const WModelIndex& index, bool autoCreate)
{
  WImage *image = dynamic_cast<WImage *>(w.w->find("i"));
  if (image || !autoCreate)
    return image;

  IndexContainerWidget *wc =
      dynamic_cast<IndexContainerWidget *>(w.w->find("a"));

  if (!wc)
    wc = dynamic_cast<IndexContainerWidget *>(w.w->find("o"));

  if (!wc) {
    wc = new IndexContainerWidget(index);
    wc->setObjectName("o");
    wc->addWidget(w.w);
    w.w = wc;
  }

  image = new WImage();
  image->setObjectName("i");
  image->setStyleClass("icon");
  wc->insertWidget(wc->count() - 1, image);

  // IE does not want to center vertically without this:
  if (wApp->environment().agentIsIE()) {
    WImage *inv = new WImage(wApp->onePixelGifUrl());
    inv->setStyleClass("rh w0 icon");
    inv->resize(0, WLength::Auto);
    wc->insertWidget(wc->count() -1, inv);
  }

  return image;
}
Exemplo n.º 2
0
void AuthWidget::createOAuthLoginView()
{
  if (!model_->oAuth().empty()) {
    setCondition("if:oauth", true);

    WContainerWidget *icons = new WContainerWidget();
    icons->setInline(isInline());

    for (unsigned i = 0; i < model_->oAuth().size(); ++i) {
      const OAuthService *auth = model_->oAuth()[i];

      WImage *w = new WImage("css/oauth-" + auth->name() + ".png", icons);
      w->setToolTip(auth->description());
      w->setStyleClass("Wt-auth-icon");
      w->setVerticalAlignment(AlignMiddle);

      OAuthProcess *const process 
	= auth->createProcess(auth->authenticationScope());
#ifndef WT_TARGET_JAVA
      w->clicked().connect(process, &OAuthProcess::startAuthenticate);
#else
      process->connectStartAuthenticate(w->clicked());
#endif

      process->authenticated().connect
	(boost::bind(&AuthWidget::oAuthDone, this, process, _1));

      WObject::addChild(process);
    }

    bindWidget("icons", icons);
  }
}
Exemplo n.º 3
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 创建标题
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CEccBaseTable::createTitle(bool bHasHelp)
{
    int nRow = numRows();
    // 标题表
    WTable *pTitle = new WTable(elementAt(nRow, 0));
    if(pTitle)
    {
        pTitle->setStyleClass("padding_2");
    
        m_pTitle = new WText("Title", pTitle->elementAt(0, 0));
        if(m_pTitle)
            m_pTitle->setStyleClass("textbold");

        // 是否创建帮助
        if(bHasHelp)
        {
            // 创建帮助
            // 2007.1.23 Kevin Yang
            // 将help.gif修改为help.png
            WImage *pHelp = new WImage("../Images/help.png", pTitle->elementAt(0, 1));
            pTitle->elementAt(0, 1)->setContentAlignment(AlignRight);
            if(pHelp)
            {
                pHelp->setStyleClass("hand");
                WObject::connect(pHelp, SIGNAL(clicked()), this, SLOT(ShowHideHelp()));
            }
        }
    }
    elementAt(nRow, 0)->setStyleClass("padding_top");
}
Exemplo n.º 4
0
void SVConditionParam::createShowButton(int nRow)
{
    WImage * pSet = new WImage("../icons/set.gif", (WContainerWidget*)elementAt(nRow,1));
    if(pSet)
    {
        pSet->setStyleClass("imgbutton");
        WObject::connect(pSet, SIGNAL(clicked()), this, SLOT(showAddCondition()));
    }
}
Exemplo n.º 5
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 创建显示追加条件
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SVConditionParam::createShowButton(int nRow)
{
    WImage * pSet = new WImage("../Images/more.gif", elementAt(nRow,1));
    if(pSet)
    {
        pSet->setStyleClass("hand");
        WObject::connect(pSet, SIGNAL(clicked()), this, SLOT(showAddCondition()));
    }
}
Exemplo n.º 6
0
void SVConditionParam::createHideButton()
{
    int nRow = m_pOperate->numRows();

    WImage  * pClose = new WImage("../icons/closewnd.gif", (WContainerWidget*)m_pOperate->elementAt(nRow,1));
    m_pOperate->elementAt(nRow, 1)->setContentAlignment(AlignTop | AlignRight);
    if(pClose)
    {
        pClose->setStyleClass("imgbutton");
        WObject::connect(pClose, SIGNAL(clicked()), this, SLOT(hideAddCondition()));
    }
}
Exemplo n.º 7
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 创建隐藏按钮
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SVConditionParam::createHideButton()
{
    int nRow = m_pOperate->numRows();

    WImage  * pClose = new WImage("../Images/tocHide.gif", m_pOperate->elementAt(nRow,1));
    m_pOperate->elementAt(nRow, 1)->setContentAlignment(AlignTop | AlignRight);
    if(pClose)
    {
        pClose->setStyleClass("hand");
        WObject::connect(pClose, SIGNAL(clicked()), this, SLOT(hideAddCondition()));
    }
}
Exemplo n.º 8
0
void RegistrationWidget::update()
{
  if (model_->passwordAuth())
    bindString("password-description",
	       tr("Wt.Auth.password-registration"));
  else
    bindEmpty("password-description");

  updateView(model_);

  if (!created_) {
    WLineEdit *password = resolve<WLineEdit *>
      (RegistrationModel::ChoosePasswordField);
    WLineEdit *password2 = resolve<WLineEdit *>
      (RegistrationModel::RepeatPasswordField);
    WText *password2Info = resolve<WText *>
      (RegistrationModel::RepeatPasswordField + std::string("-info"));

    if (password && password2 && password2Info)
      model_->validatePasswordsMatchJS(password, password2, password2Info);
  }

  WAnchor *isYou = resolve<WAnchor *>("confirm-is-you");
  if (!isYou) {
    isYou = new WAnchor(std::string("#"), tr("Wt.Auth.confirm-is-you"));
    isYou->hide();
    bindWidget("confirm-is-you", isYou);
  }

  if (model_->isConfirmUserButtonVisible()) {
    if (!isYou->clicked().isConnected())
      isYou->clicked().connect(this, &RegistrationWidget::confirmIsYou);
    isYou->show();
  } else
    isYou->hide();

  if (model_->isFederatedLoginVisible()) {
    if (!conditionValue("if:oauth")) {
      setCondition("if:oauth", true);
      if (model_->passwordAuth())
	bindString("oauth-description", tr("Wt.Auth.or-oauth-registration"));
      else
	bindString("oauth-description", tr("Wt.Auth.oauth-registration"));

      WContainerWidget *icons = new WContainerWidget();
      icons->addStyleClass("Wt-field");

      for (unsigned i = 0; i < model_->oAuth().size(); ++i) {
	const OAuthService *service = model_->oAuth()[i];

	WImage *w = new WImage("css/oauth-" + service->name() + ".png", icons);
	w->setToolTip(service->description());
	w->setStyleClass("Wt-auth-icon");
	w->setVerticalAlignment(AlignMiddle);
	OAuthProcess *const process
	  = service->createProcess(service->authenticationScope());
	w->clicked().connect(process, &OAuthProcess::startAuthenticate);

	process->authenticated().connect
	  (boost::bind(&RegistrationWidget::oAuthDone, this, process, _1));

	WObject::addChild(process);
      }

      bindWidget("icons", icons);
    }
  } else {
    setCondition("if:oauth", false);
    bindEmpty("icons");
  }

  if (!created_) {
    WPushButton *okButton = new WPushButton(tr("Wt.Auth.register"));
    WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel"));

    bindWidget("ok-button", okButton);
    bindWidget("cancel-button", cancelButton);

    okButton->clicked().connect(this, &RegistrationWidget::doRegister);
    cancelButton->clicked().connect(this, &RegistrationWidget::close);

    created_ = true;
  }
}
Exemplo n.º 9
0
void SVSEView::addSVSEList(string &szName, string &szIndex)
{
    if(m_pSEList)
    {
        int nRow = m_pSEList->numRows();

        SVTableCell cell;

        sv_group_state groupState = getSVSEState(szIndex, m_pSVUser, m_szIDCUser, m_szIDCPwd);
        bool bHasEditRight = true;
        bool bHasDelRight = true;
        if(m_pSVUser)
        {
            bHasEditRight = m_pSVUser->haveUserRight(szIndex, "se_edit");
            bHasDelRight = m_pSVUser->haveUserRight(szIndex, "se_delse");
        }
        else
        {
            bHasEditRight = false;
            bHasDelRight = false;
        }
        // Ñ¡Ôñ
        //if(szIndex.compare("1") != 0)
        //{
        //    WCheckBox * pCheck = NULL;
        //    if(bHasEditRight || bHasDelRight) pCheck = new WCheckBox("", (WContainerWidget *)m_pSEList->elementAt(nRow, 0));
        //    if(pCheck)
        //    {
        //        cell.setType(adCheckBox);
        //        cell.setValue(pCheck);
        //        m_svSEList.WriteCell(szIndex, 0, cell);
        //    }
        //}
        // ÃèÊö
        WText *pDesc = new WText("", (WContainerWidget *)m_pSEList->elementAt(nRow, 0));
        if(pDesc)
        {
            char szState[512] = {0};
            sprintf(szState, "%s%d<BR>%s%d<BR>%s%d<BR>%s%d<BR>%s%d", 
                SVResString::getResString("IDS_Device_Count").c_str(), groupState.nDeviceCount,
                SVResString::getResString("IDS_Monitor_Count").c_str(), groupState.nMonitorCount, 
                SVResString::getResString("IDS_Monitor_Disable_Count").c_str(), groupState.nDisableCount,
                SVResString::getResString("IDS_Monitor_Error_Count").c_str(), groupState.nErrorCount, 
                SVResString::getResString("IDS_Monitor_Warn_Count").c_str(), groupState.nWarnCount);
            pDesc->setText(szState);
        }
        // Ãû³Æ
        WText *pName = new WText(szName, (WContainerWidget *)m_pSEList->elementAt(nRow, 1));
        if ( pName )
        {
            sprintf(pName->contextmenu_, "style='color:#669;cursor:pointer;' onmouseover='" \
                "this.style.textDecoration=\"underline\"' " \
                "onmouseout='this.style.textDecoration=\"none\"'");
            pName->setToolTip(szName);
            WObject::connect(pName, SIGNAL(clicked()), "showbar();", &m_wNameMapper, SLOT(map()), WObject::ConnectionType::JAVASCRIPTDYNAMIC);
            m_wNameMapper.setMapping(pName, szIndex);

            cell.setType(adText);
            cell.setValue(pName);

            m_svSEList.WriteCell(szIndex, 2, cell);
            SVTableRow *pRow = m_svSEList.Row(szIndex);
            if(pRow)
                pRow->setProperty(szIndex.c_str());
        }
        // ±à¼­
        WImage * pEdit = NULL;
        if(bHasEditRight) pEdit = new WImage("../icons/edit.gif", (WContainerWidget *)m_pSEList->elementAt(nRow, 2));
        if (pEdit)
        {
            pEdit->setToolTip(SVResString::getResString("IDS_Edit"));
            pEdit->setStyleClass("imgbutton");
            WObject::connect(pEdit, SIGNAL(clicked()), "showbar();", &m_wEditMapper, SLOT(map()), WObject::ConnectionType::JAVASCRIPTDYNAMIC);
            m_wEditMapper.setMapping(pEdit,szIndex);
        }

        if((nRow + 1) % 2 == 0)
            m_pSEList->GetRow(nRow)->setStyleClass("tr1");
        else
            m_pSEList->GetRow(nRow)->setStyleClass("tr2");
    }

}
Exemplo n.º 10
0
WImage *Captcha::GenCap()
{
    size_t n1 = (rand() % 10) + 1;
    size_t n2 = (rand() % 10) + 1;
    int rotate = (rand() % 7 - 3);
    int skew = (rand() % 9 - 4);

    Result = n1 * n2;

    string captcha(lexical_cast<string>(n1));
    captcha += " X ";
    captcha += lexical_cast<string>(n2);

    Image img(Geometry(115, 35), Color("white"));
    list<Drawable> drawList;

    drawList.push_back(DrawableTextAntialias(true));
    drawList.push_back(DrawableFont("../fnt/HAZELN.TTF"));
    drawList.push_back(DrawablePointSize(32));
    drawList.push_back(DrawableStrokeColor(Color("black")));
    drawList.push_back(DrawableFillColor(Color(0, 0, 0, MaxRGB)));
    drawList.push_back(DrawableTextDecoration(UnderlineDecoration));
    drawList.push_back(DrawableGravity(CenterGravity));


    drawList.push_back(DrawableRotation(rotate));
    drawList.push_back(DrawableRotation(skew));
    drawList.push_back(DrawableText(0, 0, captcha));

    img.draw(drawList);


    string capPath;

    do {
        capPath = "../tmp/captcha-";
        capPath += lexical_cast<string>(rand());
        capPath += ".png";
    } while (System::FileExists(capPath));


    img.write(capPath);

    WMemoryResource *capResource = new WMemoryResource("image/png");

    char *buffer = NULL;
    size_t size = 0;
    System::ReadFile(capPath, size, &buffer);

    capResource->setData(reinterpret_cast<const unsigned char*>(buffer),
                         static_cast<int>(size));

    delete buffer;

    System::EraseFile(capPath);

    WImage *capImage = new WImage(capResource, "Captcha");
    capImage->setStyleClass("captcha");

    return capImage;
}
Exemplo n.º 11
0
void CSVReportSet::AddGroupOperate(WTable * pTable)
{
	PrintDebugString("begin Init AddOperator function\n");

    m_pGroupOperate = new WTable((WContainerWidget *)pTable->elementAt( 8, 0));
   
	if ( m_pGroupOperate )
    {

        WImage * pSelAll = new WImage("../icons/selall.gif", (WContainerWidget *)m_pGroupOperate->elementAt(0, 1));
        if (pSelAll)
        {
            pSelAll->setStyleClass("imgbutton");
			pSelAll->setToolTip(m_formText.szTipSelAll1);
			connect(pSelAll, SIGNAL(clicked()), this, SLOT(SelAll()));
        }

        WImage * pSelNone = new WImage("../icons/selnone.gif", (WContainerWidget *)m_pGroupOperate->elementAt(0, 2));
        if (pSelAll)
        {
            pSelNone->setStyleClass("imgbutton");
			pSelNone->setToolTip(m_formText.szTipSelNone);
			connect(pSelNone, SIGNAL(clicked()), this, SLOT(SelNone()));
        }

        WImage * pSelinvert = new WImage("../icons/selinvert.gif", (WContainerWidget *)m_pGroupOperate->elementAt(0, 3));
        if (pSelinvert)
        {
            pSelinvert->setStyleClass("imgbutton");
			pSelinvert->setToolTip(m_formText.szTipSelInv);
			connect(pSelinvert, SIGNAL(clicked()), this, SLOT(SelInvert()));
        }

		
		pDel = new WImage("../icons/del.gif", (WContainerWidget *)m_pGroupOperate->elementAt(0, 4));
		if(!GetUserRight("m_reportlistDel"))
			pDel->hide();
		else
			pDel->show();

        if (pDel)
        {
           
			pDel->setStyleClass("imgbutton");
			pDel->setToolTip(m_formText.szTipDel);
			connect(pDel , SIGNAL(clicked()),this, SLOT(BeforeDelPhone()));
        }

		
		pAdd = new WPushButton(m_formText.szAddPhoneBut, (WContainerWidget *)m_pGroupOperate->elementAt(0, 6));
		pAdd->setStyleClass("wizardbutton");
		if(!GetUserRight("m_reportlistAdd"))
			pAdd->hide();
		else
			pAdd->show();

        if (pAdd)
        {
            pAdd->setToolTip(m_formText.szTipAddNew);
			WObject::connect(pAdd, SIGNAL(clicked()),"showbar();", this, SLOT(AddPhone())
				, WObject::ConnectionType::JAVASCRIPTDYNAMIC);
        }
		m_pGroupOperate->elementAt(0, 6)->resize(WLength(100,WLength::Percentage),WLength(100,WLength::Percentage));
		m_pGroupOperate->elementAt(0, 6)->setContentAlignment(AlignRight);
		
    }

	PrintDebugString("Init AddOperator function\n");

	//隐藏按钮
	pHideBut = new WPushButton("hide button",this);
	if(pHideBut)
	{
		pHideBut->setToolTip("Hide Button");
		connect(pHideBut,SIGNAL(clicked()),this,SLOT(DelPhone()));
		pHideBut->hide();
	}

	PrintDebugString("Init AddOperator function finish\n");
}
Exemplo n.º 12
0
DetailManipulation::DetailManipulation(bool enhance, WContainerWidget *parent)
	: WContainerWidget(parent), onlySmooth(!enhance)
{

	resize(WLength::Auto, WLength::Auto);

	// Image bar
	prepareInputImages();
	WContainerWidget *imageBar = new WContainerWidget;
	WVBoxLayout *imageBarLayout = new WVBoxLayout();
	for (size_t i = 0; i < inputImages.size(); ++i) {
		WImage *img = inputImages[i]->getOriginalImage();
		img->setStyleClass("image_button");
		img->resize(160, 120);
		img->setAttributeValue("onMouseOver", "this.width=192; this.height=144;");
		img->setAttributeValue("onMouseOut", "this.width=160; this.height=120;");
		img->clicked().connect(
				boost::bind(&DetailManipulation::selectImage,
							this,
							i
							)
		);
		imageBarLayout->addWidget(img);
	}
	imageBar->resize(200, WLength::Auto);
	imageBar->setLayout(imageBarLayout);
	selectedImageId = 0;

	// Main component
	imageTab = new WTabWidget();
	imageTab->addTab(inputImages[selectedImageId]->getOriginalImage(), "Original");
	if (onlySmooth) {
		imageTab->addTab(new WImage(smoothedResult[selectedImageId].second), smoothedResult[selectedImageId].first);
	}
	else {
		imageTab->addTab(new WImage(enhancedResult[selectedImageId].second), enhancedResult[selectedImageId].first);
	}
	imageTab->resize(600, WLength::Auto);


	WGridLayout *controllerLayout = new WGridLayout();
	WSlider *rSlider = new WSlider(Wt::Vertical);
	rSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM);
	rSlider->setTickPosition(Wt::WSlider::TicksBothSides);
	WDoubleSpinBox *rSpinBox = new WDoubleSpinBox();
	rSpinBox->setMinimum(R_MINIMUM);
	rSpinBox->setMaximum(R_MAXIMUM);
	rSlider->sliderMoved().connect(
			boost::bind(&DetailManipulation::changeDoubleSpinBoxValue,
						this,
						rSpinBox,
						true,
						_1)
	);
	rSpinBox->valueChanged().connect(
			boost::bind(&DetailManipulation::changeSliderValue,
						this,
						rSlider,
						1.f/(R_MAXIMUM-R_MINIMUM),
						_1)
	);
	controllerLayout->addWidget(rSlider, 2, 0, 6, 1);
	controllerLayout->addWidget(rSpinBox, 9, 0);
	controllerLayout->addWidget(new WText("radius"), 10, 0);


	WSlider *epsSlider = new WSlider(Wt::Vertical);
	epsSlider->setMinimum(SLIDER_MINIMUM);
	epsSlider->setMaximum(SLIDER_MAXIMUM);
	epsSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM);
	epsSlider->setTickPosition(WSlider::TicksBothSides);
	WDoubleSpinBox *epsSpinBox = new WDoubleSpinBox();
	epsSpinBox->setMinimum(EPS_MINIMUM);
	epsSpinBox->setMaximum(EPS_MAXIMUM);
	epsSlider->sliderMoved().connect(
			boost::bind(&DetailManipulation::changeDoubleSpinBoxValue,
						this,
						epsSpinBox,
						false,
						_1)
	);
	epsSpinBox->valueChanged().connect(
			boost::bind(&DetailManipulation::changeSliderValue,
						this,
						epsSlider,
						1.f/(EPS_MAXIMUM-EPS_MINIMUM),
						_1)
	);
	controllerLayout->addWidget(epsSlider, 2, 1, 6, 1);
	controllerLayout->addWidget(epsSpinBox, 9, 1);
	controllerLayout->addWidget(new WText("epsilon"), 10, 1);

	WPushButton *apply = new WPushButton("Apply");
	apply->clicked().connect(
			boost::bind(&DetailManipulation::applyEnhancement,
					this,
					rSpinBox,
					epsSpinBox
					)
	);
	controllerLayout->addWidget(apply, 1, 0, 1, 2);


	WContainerWidget *controller = new WContainerWidget();
	controller->resize(120, WLength::Auto);
	controller->setLayout(controllerLayout);


	WBorderLayout *mainLayout = new WBorderLayout(this);
	mainLayout->addWidget(imageBar, WBorderLayout::West);
	mainLayout->addWidget(imageTab, WBorderLayout::Center);
	mainLayout->addWidget(controller, WBorderLayout::East);
	//setLayout(mainLayout, Wt::AlignTop | Wt::AlignJustify);
	/*
		doJavaScript(
			    "(function () { \
						     var imageTags = document.getElementsByClassName(\"image_button\"); \
						     for (var i=0; image=imageTags[i]; ++i) { \
						         if (image.width>200 && image.height>0) { \
						             image.width = 192;  \
						         } \
						     }\
				 })();"
		);*/

}