本文整理汇总了C++中mygui::Widget::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::getSize方法的具体用法?C++ Widget::getSize怎么用?C++ Widget::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygui::Widget
的用法示例。
在下文中一共展示了Widget::getSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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) );
}
示例2: setHoverSlotsColor
void StashPanel::setHoverSlotsColor(const MyGUI::types::TRect<int>& _value , MyGUI::Colour color)
{
int slot_count = this->mslot_container_panelWidget->getChildCount();
for (int i = 0; i < slot_count; i++)
{
MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
MyGUI::IntRect rectangle = widget->getAbsoluteRect();
MyGUI::IntSize _size = widget->getSize();
MyGUI::IntPoint center_rectangle = MyGUI::IntPoint(rectangle.left + (_size.width / 2), rectangle.top + (_size.height / 2));
//((center_rectangle.left > _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top > _value.top) && (center_rectangle.top < _value.bottom));
if (((center_rectangle.left >= _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top >= _value.top) && (center_rectangle.top < _value.bottom)))
{
//en el check de arriba, algunos son con igual y otros no porque sino se seleccionan mal, o 2 de 4 o 6 de 4 !
widget->setColour(color);
}
}
}
示例3: align
void VBox::align ()
{
unsigned int count = getChildCount ();
size_t v_stretched_count = 0;
int total_height = 0;
int total_width = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
for (unsigned int i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
bool vstretch = w->getUserString ("VStretch") == "true";
v_stretched_count += vstretch;
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
if (aw)
{
sizes.push_back(std::make_pair(aw->getRequestedSize (), vstretch));
total_height += aw->getRequestedSize ().height;
total_width = std::max(total_width, aw->getRequestedSize ().width);
}
else
{
sizes.push_back (std::make_pair(w->getSize(), vstretch));
total_height += w->getSize().height;
if (!(w->getUserString("HStretch") == "true"))
total_width = std::max(total_width, w->getSize().width);
}
if (i != count-1)
total_height += mSpacing;
}
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
{
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
return;
}
int curY = 0;
for (unsigned int i = 0; i < count; ++i)
{
if (i==0)
curY += mPadding;
MyGUI::Widget* w = getChildAt(i);
bool hstretch = w->getUserString ("HStretch") == "true";
int width = hstretch ? total_width : sizes[i].first.width;
MyGUI::IntCoord widgetCoord;
widgetCoord.top = curY;
widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2;
int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count
: sizes[i].first.height;
widgetCoord.height = height;
widgetCoord.width = width;
w->setCoord(widgetCoord);
curY += height;
if (i != count-1)
curY += mSpacing;
}
}
示例4: getWidgetSlotByScreenPosition_modified
MyGUI::Widget* StashPanel::getWidgetSlotByScreenPosition_modified(const MyGUI::types::TPoint<int>& _value)
{
int slot_count = this->mslot_container_panelWidget->getChildCount();
for (int i = 0; i < slot_count; i++)
{
MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
if (widget->getAbsoluteRect().inside(_value))
{
MyGUI::types::TRect<int> big_rect = widget->getAbsoluteRect();
MyGUI::types::TSize<int> big_size = widget->getSize();
/********/
/* 1 2 */
/* 3 4 */
/********/
MyGUI::types::TRect<int> rect_1;
rect_1.set(big_rect.left, big_rect.top, big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2);
MyGUI::types::TRect<int> rect_2;
rect_2.set(big_rect.left + big_size.width / 2, big_rect.top, big_rect.left + big_size.width, big_rect.top + big_size.height / 2);
MyGUI::types::TRect<int> rect_3;
rect_3.set(big_rect.left, big_rect.top + big_size.height / 2, big_rect.left + big_size.width / 2, big_rect.top + big_size.height);
MyGUI::types::TRect<int> rect_4;
rect_4.set(big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2, big_rect.left + big_size.width , big_rect.top + big_size.height);
if (rect_1.inside(_value))
{
//LogManager::getSingletonPtr()->logMessage("rect_1");
return widget;
}
if (rect_2.inside(_value))
{
//LogManager::getSingletonPtr()->logMessage("rect_2");
std::string name = widget->getName();
std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
if (!splitted.empty())
{
std::string slot_num = splitted.at(3);
std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
if (!splitted_number.empty())
{
int r = StringConverter::parseInt(splitted_number.at(0));
int c = StringConverter::parseInt(splitted_number.at(1));
MyGUI::Widget* ret = this->getWidgetSlotByRC(r, c+1);
return ret;
}
}
}
if (rect_3.inside(_value))
{
//LogManager::getSingletonPtr()->logMessage("rect_3");
std::string name = widget->getName();
std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
if (!splitted.empty())
{
std::string slot_num = splitted.at(3);
std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
if (!splitted_number.empty())
{
int r = StringConverter::parseInt(splitted_number.at(0));
int c = StringConverter::parseInt(splitted_number.at(1));
MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c);
return ret;
}
}
}
if (rect_4.inside(_value))
{
//LogManager::getSingletonPtr()->logMessage("rect_4");
std::string name = widget->getName();
std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
if (!splitted.empty())
{
std::string slot_num = splitted.at(3);
std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
if (!splitted_number.empty())
{
int r = StringConverter::parseInt(splitted_number.at(0));
int c = StringConverter::parseInt(splitted_number.at(1));
MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c+1);
return ret;
}
}
}
return widget; //should not return this !
}
}
return 0;
}
示例5: onFrame
//.........这里部分代码省略.........
{
ToolTipInfo info;
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell"));
info.caption = spell->name;
Widgets::SpellEffectList effects;
std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end();
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
{
Widgets::SpellEffectParams params;
params.mEffectID = it->effectID;
params.mSkill = it->skill;
params.mAttribute = it->attribute;
params.mDuration = it->duration;
params.mMagnMin = it->magnMin;
params.mMagnMax = it->magnMax;
params.mRange = it->range;
params.mIsConstant = (spell->data.type == ESM::Spell::ST_Ability);
effects.push_back(params);
}
info.effects = effects;
tooltipSize = createToolTip(info);
}
else if (type == "Layout")
{
// tooltip defined in the layout
MyGUI::Widget* tooltip;
getWidget(tooltip, focus->getUserString("ToolTipLayout"));
tooltip->setVisible(true);
if (!tooltip->isUserString("DontResize"))
{
tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping
tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height);
}
else
tooltipSize = tooltip->getSize();
std::map<std::string, std::string> userStrings = focus->getUserStrings();
for (std::map<std::string, std::string>::iterator it = userStrings.begin();
it != userStrings.end(); ++it)
{
if (it->first == "ToolTipType"
|| it->first == "ToolTipLayout")
continue;
size_t underscorePos = it->first.find("_");
std::string propertyKey = it->first.substr(0, underscorePos);
std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1));
MyGUI::Widget* w;
getWidget(w, widgetName);
w->setProperty(propertyKey, it->second);
}
for (unsigned int i=0; i<tooltip->getChildCount(); ++i)
{
MyGUI::Widget* w = tooltip->getChildAt(i);
if (w->isUserString("AutoResizeHorizontal"))
{
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
}
else if (!tooltip->isUserString("DontResize"))