本文整理汇总了C++中mygui::Widget::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::setPosition方法的具体用法?C++ Widget::setPosition怎么用?C++ Widget::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygui::Widget
的用法示例。
在下文中一共展示了Widget::setPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: align
void WindowCaption::align()
{
MyGUI::IntSize textSize = getTextSize();
MyGUI::Widget* caption = mClient;
caption->setSize(textSize.width + 24, caption->getHeight());
int barwidth = (getWidth()-caption->getWidth())/2;
caption->setPosition(barwidth, caption->getTop());
if (mLeft)
mLeft->setCoord(0, mLeft->getTop(), barwidth, mLeft->getHeight());
if (mRight)
mRight->setCoord(barwidth + caption->getWidth(), mRight->getTop(), barwidth, mRight->getHeight());
}
示例2: reLayout
/*重新布局窗口
*/
void Grid::reLayout(){
assert(parent && column > 0 );
int i,x,y,width,height;
MyGUI::IntSize size;
vector<int> mh((int)(parent->getChildCount()/column)+1),mv(column);
MyGUI::ScrollView *psw = parent->castType<MyGUI::ScrollView>(false);
fill(mh.begin(),mh.end(),0);
fill(mv.begin(),mv.end(),0);
for( i = 0;i<(int)parent->getChildCount();++i ){
MyGUI::Widget* pchild = parent->getChildAt(i);
MyGUI::IntSize size = pchild->getSize();
//如果没有设置这里自动计算
if( size.width==0 ){
size.width = CalcWidgetSize(pchild).width;
}
if( size.height==0 ){
size.height = CalcWidgetSize(pchild).height;
}
if( size.width>mv[i%column] )
mv[i%column] = size.width;
if( size.height>mh[(int)(i/column)] )
mh[(int)(i/column)] = size.height;
}
width = sum(mv,mv.size())+(column-1)*space;
height = sum(mh,mh.size());
size = parent->getSize();
//对于ScrollView可能有Bug,这里减去24感觉正好
if( psw ){
size.width -= 24;
size.height -= 24;
}
//不要小于0
x = max((int)((size.width-width)/2),0);
y = max((int)((size.height-height)/2),0);
for( i = 0;i<(int)parent->getChildCount();++i ){
int col,row;
MyGUI::Widget* pchild = parent->getChildAt(i);
//这里使用中心对齐
col = i%column;
row = (int)(i/column);
pchild->setPosition(MyGUI::IntPoint(x+col*space+sum(mv,col),y+sum(mh,row)));
pchild->setSize(MyGUI::IntSize(mv[col],mh[row]));
}
//如果父窗口是ScrollView
if( psw )psw->setCanvasSize( max(size.width,width),max(size.height,height) );
}
示例3: layoutWidgets
void ItemView::layoutWidgets()
{
if (!mScrollView->getChildCount())
return;
int x = 0;
int y = 0;
MyGUI::Widget* dragArea = mScrollView->getChildAt(0);
int maxHeight = mScrollView->getHeight();
int rows = maxHeight/42;
rows = std::max(rows, 1);
bool showScrollbar = int(std::ceil(dragArea->getChildCount()/float(rows))) > mScrollView->getWidth()/42;
if (showScrollbar)
maxHeight -= 18;
for (unsigned int i=0; i<dragArea->getChildCount(); ++i)
{
MyGUI::Widget* w = dragArea->getChildAt(i);
w->setPosition(x, y);
y += 42;
if (y > maxHeight-42 && i < dragArea->getChildCount()-1)
{
x += 42;
y = 0;
}
}
x += 42;
MyGUI::IntSize size = MyGUI::IntSize(std::max(mScrollView->getSize().width, x), mScrollView->getSize().height);
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
mScrollView->setVisibleVScroll(false);
mScrollView->setVisibleHScroll(false);
mScrollView->setCanvasSize(size);
mScrollView->setVisibleVScroll(true);
mScrollView->setVisibleHScroll(true);
dragArea->setSize(size);
}
示例4: layoutWidgets
void ItemView::layoutWidgets()
{
if (!mScrollView->getChildCount())
return;
int x = 0;
int y = 0;
int maxHeight = mScrollView->getSize().height - 58;
MyGUI::Widget* dragArea = mScrollView->getChildAt(0);
for (unsigned int i=0; i<dragArea->getChildCount(); ++i)
{
MyGUI::Widget* w = dragArea->getChildAt(i);
w->setPosition(x, y);
y += 42;
if (y > maxHeight)
{
x += 42;
y = 0;
}
}
x += 42;
MyGUI::IntSize size = MyGUI::IntSize(std::max(mScrollView->getSize().width, x), mScrollView->getSize().height);
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
mScrollView->setVisibleVScroll(false);
mScrollView->setVisibleHScroll(false);
mScrollView->setCanvasSize(size);
mScrollView->setVisibleVScroll(true);
mScrollView->setVisibleHScroll(true);
dragArea->setSize(size);
}