本文整理汇总了C++中WContainerWidget::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ WContainerWidget::resize方法的具体用法?C++ WContainerWidget::resize怎么用?C++ WContainerWidget::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WContainerWidget
的用法示例。
在下文中一共展示了WContainerWidget::resize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WContainerWidget
WWidget *StyleLayout::wGridLayout()
{
WContainerWidget *result = new WContainerWidget();
topic("WGridLayout", result);
addText(tr("layout-WGridLayout"), result);
WContainerWidget *container;
container = new WContainerWidget(result);
container->resize(WLength::Auto, 400);
container->setStyleClass("yellow-box");
WGridLayout *grid = new WGridLayout();
container->setLayout(grid);
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 4; ++column) {
WText *t = addText(tr("grid-item").arg(row).arg(column));
if (row == 1 || column == 1 || column == 2)
t->setStyleClass("blue-box");
else
t->setStyleClass("green-box");
grid->addWidget(t, row, column);
}
}
grid->setRowStretch(1, 1);
grid->setColumnStretch(1, 1);
grid->setColumnStretch(2, 1);
return result;
}
示例2: WApplication
/*
* The env argument contains information about the new session, and
* the initial request. It must be passed to the WApplication
* constructor so it is typically also an argument for your custom
* application constructor.
*/
DataAnalyzer::DataAnalyzer(const WEnvironment& env)
: WApplication(env)
{
setTitle(WString::fromUTF8("行车数据管理平台",true));
WContainerWidget *w = new WContainerWidget(root());
w->resize(WLength::Auto, WLength::Auto);
HomeUI* home = new HomeUI(w);
w->addWidget(home);
root()->addWidget(w);
setLocale(WT_LOCALE("cn"));
WMessageResourceBundle* pTranslate = new WMessageResourceBundle();
pTranslate->use(appRoot()+"resources/auth");
setLocalizedStrings(pTranslate);
useStyleSheet("resources/analyzer.css");
log("info") << "constructed" ;
}
示例3: WText
WWidget *EventsDemo::wMouseEvent()
{
WContainerWidget *result = new WContainerWidget();
topic("WMouseEvent", result);
addText(tr("events-WMouseEvent"), result);
WContainerWidget *c = new WContainerWidget(result);
WHBoxLayout *hlayout = new WHBoxLayout;
c->setLayout(hlayout);
WContainerWidget *l = new WContainerWidget;
WContainerWidget *r = new WContainerWidget;
new WText("clicked<br/>doubleClicked<br/>mouseWentOut<br/>mouseWentOver",
l);
new WText("mouseWentDown<br/>mouseWentUp<br/>mouseMoved<br/>mouseWheel", r);
hlayout->addWidget(l);
hlayout->addWidget(r);
c->resize(600, 300);
l->decorationStyle().setBackgroundColor(Wt::gray);
r->decorationStyle().setBackgroundColor(Wt::gray);
// prevent that firefox interprets drag as drag&drop action
l->setStyleClass("unselectable");
r->setStyleClass("unselectable");
l->clicked().connect(this, &EventsDemo::showClicked);
l->doubleClicked().connect(this, &EventsDemo::showDoubleClicked);
l->mouseWentOut().connect(this, &EventsDemo::showMouseWentOut);
l->mouseWentOver().connect(this, &EventsDemo::showMouseWentOver);
r->mouseMoved().connect(this, &EventsDemo::showMouseMoved);
r->mouseWentUp().connect(this, &EventsDemo::showMouseWentUp);
r->mouseWentDown().connect(this, &EventsDemo::showMouseWentDown);
r->mouseWheel().connect(this, &EventsDemo::showMouseWheel);
r->mouseWheel().preventDefaultAction(true);
l->setAttributeValue
("oncontextmenu",
"event.cancelBubble = true; event.returnValue = false; return false;");
r->setAttributeValue
("oncontextmenu",
"event.cancelBubble = true; event.returnValue = false; return false;");
new WBreak(result);
new WText("Last event: ", result);
mouseEventType_ = new WText(result);
new WBreak(result);
mouseEventDescription_ = new WText(result);
return result;
}
示例4: main
void WebGLDemo::main(){
glContainer_ = new WContainerWidget(root());
glContainer_->resize(500, 500);
glContainer_->setInline(false);
root()->addWidget(new WBreak());
root()->addWidget(new WText("Rotate with mouse and zoom with scroll"));
root()->addWidget(new WBreak());
root()->addWidget(new WText(" "));
root()->addWidget(new WBreak());
root()->addWidget(new WText("LIGHT DIRECTION"));
root()->addWidget(new WBreak());
root()->addWidget(new WText("X : "));
lightDirX = new WLineEdit("-1.0",root());
root()->addWidget(new WText(" Y : "));
lightDirY = new WLineEdit("-1.0",root());
root()->addWidget(new WText(" Z : "));
lightDirZ = new WLineEdit("-1.0",root());
root()->addWidget(new WBreak());
root()->addWidget(new WText(" "));
root()->addWidget(new WBreak());
root()->addWidget(new WText("LIGHT COLOR"));
root()->addWidget(new WBreak());
root()->addWidget(new WText("R : "));
lightColR = new WLineEdit("0.8",root());
root()->addWidget(new WText(" G : "));
lightColG = new WLineEdit("0.8",root());
root()->addWidget(new WText(" B : "));
lightColB = new WLineEdit("0.8",root());
root()->addWidget(new WBreak());
root()->addWidget(new WText(" "));
root()->addWidget(new WBreak());
root()->addWidget(new WText("AMBIENT LIGHT COLOR"));
root()->addWidget(new WBreak());
root()->addWidget(new WText("R : "));
ambLightColR = new WLineEdit("0.2",root());
root()->addWidget(new WText(" G : "));
ambLightColG = new WLineEdit("0.2",root());
root()->addWidget(new WText(" B : "));
ambLightColB = new WLineEdit("0.2",root());
lightDirX->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
lightDirY->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
lightDirZ->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
lightColR->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
lightColG->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
lightColB->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
ambLightColR->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
ambLightColG->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
ambLightColB->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
updateShaders();
this->globalKeyWentDown().connect(this,&WebGLDemo::eventKeyWentDown);
}
示例5: WContainerWidget
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
)
);
//.........这里部分代码省略.........
示例6: updateState
void PaintedSlider::updateState()
{
bool rtl = WApplication::instance()->layoutDirection() == RightToLeft;
std::string resourcesURL = WApplication::resourcesUrl();
Orientation o = slider_->orientation();
handle_->setStyleClass("handle");
if (o == Horizontal) {
handle_->resize(HANDLE_WIDTH, h());
handle_->setOffsets(0, Top);
} else {
handle_->resize(w(), HANDLE_WIDTH);
handle_->setOffsets(0, Left);
}
double l = o == Horizontal ? w() : h();
double pixelsPerUnit = (l - HANDLE_WIDTH) / range();
std::string dir;
if (o == Horizontal)
dir = rtl ? "right" : "left";
else
dir = "top";
std::string u = (o == Horizontal ? "x" : "y");
std::string U = (o == Horizontal ? "X" : "Y");
std::string maxS = boost::lexical_cast<std::string>(l - HANDLE_WIDTH);
std::string ppU = boost::lexical_cast<std::string>(pixelsPerUnit);
std::string minimumS = boost::lexical_cast<std::string>(slider_->minimum());
std::string maximumS = boost::lexical_cast<std::string>(slider_->maximum());
std::string width = boost::lexical_cast<std::string>(w());
std::string horizontal = boost::lexical_cast<std::string>(o == Horizontal);
/*
* Note: cancelling the mouseDown event prevents the selection behaviour
*/
std::string mouseDownJS =
"""obj.setAttribute('down', " WT_CLASS ".widgetCoordinates(obj, event)."
+ u + "); "
WT_CLASS ".cancelEvent(event);";
// = 'u' position relative to background, corrected for slider
std::string computeD =
"" "var objh = " + handle_->jsRef() + ","
"" "objb = " + jsRef() + ","
"" "page_u = WT.pageCoordinates(event)." + u + ","
"" "widget_page_u = WT.widgetPageCoordinates(objb)." + u + ","
"" "pos = page_u - widget_page_u,"
"" "rtl = " + boost::lexical_cast<std::string>(rtl) + ","
"" "horizontal = " + horizontal + ";"
"" "if (rtl && horizontal)"
"" " pos = " + width + " - pos;"
"" "var d = pos - down;";
std::string mouseMovedJS =
"""var down = obj.getAttribute('down');"
"""var WT = " WT_CLASS ";"
"""if (down != null && down != '') {"
+ computeD +
"" "d = Math.max(0, Math.min(d, " + maxS + "));"
"" "var v = Math.round(d/" + ppU + ");"
"" "var intd = v*" + ppU + ";"
"" "if (Math.abs(WT.pxself(objh, '" + dir + "') - intd) > 1) {"
"" "objh.style." + dir + " = intd + 'px';" +
slider_->sliderMoved().createCall(o == Horizontal ? "v + " + minimumS
: maximumS + " - v") +
"" "}"
"""}";
std::string mouseUpJS =
"""var down = obj.getAttribute('down');"
"""var WT = " WT_CLASS ";"
"""if (down != null && down != '') {"
+ computeD +
"""d += " + boost::lexical_cast<std::string>(HANDLE_WIDTH / 2) + ";" +
sliderReleased_.createCall("d") +
"" "obj.removeAttribute('down');"
"""}";
bool enabled = !slider_->isDisabled();
mouseDownJS_.setJavaScript(std::string("function(obj, event) {")
+ (enabled ? mouseDownJS : "")
+ "}");
mouseMovedJS_.setJavaScript(std::string("function(obj, event) {")
+ (enabled ? mouseMovedJS : "")
+ "}");
mouseUpJS_.setJavaScript(std::string("function(obj, event) {")
+ (enabled ? mouseUpJS : "")
+ "}");
update();
updateSliderPosition();
}