当前位置: 首页>>代码示例>>C++>>正文


C++ Widget::setPosition方法代码示例

本文整理汇总了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());
    }
开发者ID:Allofich,项目名称:openmw,代码行数:13,代码来源:windowcaption.cpp

示例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) );
}
开发者ID:JohnCrash,项目名称:iRobot,代码行数:50,代码来源:SimpleUI.cpp

示例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);
}
开发者ID:ace13,项目名称:openmw,代码行数:42,代码来源:itemview.cpp

示例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);
}
开发者ID:nthauvin,项目名称:openmw,代码行数:36,代码来源:itemview.cpp


注:本文中的mygui::Widget::setPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。