本文整理汇总了C++中cegui::Window::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::getPosition方法的具体用法?C++ Window::getPosition怎么用?C++ Window::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::Window
的用法示例。
在下文中一共展示了Window::getPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlignSelection
//------------------------------------------------------------------------
void SelectionMover::AlignSelection(const Alignment alignment)
{
// Validations
wxASSERT_MSG(m_selection != NULL, wxT("Selection member is NULL"));
if(m_selection->Size() <= 1)
{
// Should not happen because of the disabled menu/toolbar item in this case
LogWarning(wxT("You must select more than one window to align!"));
return;
}
// The first selected window is the one to match. This is for example how Visual Studio's
// dialog editor works as well.
Selection::Boxes::iterator boxIt = m_selection->GetMoveableBoxes().begin();
CEGUI::Window *current = boxIt->GetWindow();
const CEGUI::URect rect = current->getArea();
++boxIt;
for(; boxIt != m_selection->GetMoveableBoxes().end(); ++boxIt) {
// Deny when it is blocked
if (boxIt->IsLocked())
continue;
current = boxIt->GetWindow();
switch(alignment)
{
case AlignLeft:
current->setPosition(CEGUI::UVector2(rect.d_min.d_x, current->getPosition().d_y));
break;
case AlignRight:
current->setPosition(CEGUI::UVector2(rect.d_max.d_x - current->getWidth(), current->getPosition().d_y));
break;
case AlignTop:
current->setPosition(CEGUI::UVector2(current->getPosition().d_x, rect.d_min.d_y));
break;
case AlignBottom:
current->setPosition(CEGUI::UVector2(current->getPosition().d_x, rect.d_max.d_y - current->getHeight()));
break;
case AlignWidth:
// The svn diff for this block will be big; no clue what the previous code
// was doing there..
current->setWidth(rect.getWidth());
break;
case AlignHeight:
// The svn diff for this block will be big; no clue what the previous code
// was doing there..
current->setHeight(rect.getHeight());
break;
default:
LogError(wxT("SelectionMover::AlignSelection - Unrecognized align option (%d)"), alignment);
return;
}
}
// Request for a repaint
wxGetApp().GetMainFrame()->Refresh();
}
示例2: SetButtons
void MessageBox::SetButtons(const MessageBoxButtons& buttons)
{
float32 sumWidth = 0;
for (MessageBoxButtons::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
{
CEGUI::Window* button = GetButton(*it);
OC_DASSERT(button != 0);
float32 width = button->getWidth().d_offset;
sumWidth += width;
}
float32 totalWidth = sumWidth + BUTTON_MARGIN * (buttons.size() - 1);
float32 left = 0;
for (MessageBoxButtons::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
{
CEGUI::Window* button = GetButton(*it);
OC_DASSERT(button != 0);
float32 width = button->getWidth().d_offset;
button->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5f, -0.5f * totalWidth + left), button->getPosition().d_y));
button->setWidth(CEGUI::UDim(0, width));
button->setVisible(true);
button->setID((CEGUI::uint)*it);
button->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::MessageBox::OnButtonClicked, this));
left += width + BUTTON_MARGIN;
}
mMinWidth = totalWidth + 2.0f * BUTTON_MARGIN;
}
示例3: createScorePopup
void HUDDemo::createScorePopup(const CEGUI::Vector2<float>& mousePos, int points)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window* popupWindow = winMgr.createWindow("HUDDemo/PopupLabel");
d_rootIngame->addChild(popupWindow);
popupWindow->setPosition(CEGUI::UVector2(cegui_absdim(mousePos.d_x), cegui_absdim(mousePos.d_y)));
popupWindow->setText(CEGUI::PropertyHelper<int>::toString(points));
popupWindow->setRiseOnClickEnabled(false);
popupWindow->subscribeEvent(AnimationInstance::EventAnimationEnded, Event::Subscriber(&HUDDemo::handleScorePopupAnimationEnded, this));
popupWindow->setPixelAligned(false);
popupWindow->setFont("DejaVuSans-14");
popupWindow->setPosition(popupWindow->getPosition() + CEGUI::UVector2(cegui_reldim(0.03f), cegui_reldim(-0.02f)));
if(points < 0)
popupWindow->setProperty("NormalTextColour", "FF880000");
else
{
popupWindow->setText( "+" + popupWindow->getText());
popupWindow->setProperty("NormalTextColour", "FF006600");
}
CEGUI::EventArgs args;
popupWindow->fireEvent("StartAnimation", args);
}
示例4: OnEventKeyDown
bool TabNavigation::OnEventKeyDown(const CEGUI::EventArgs& e)
{
const CEGUI::KeyEventArgs& args = static_cast<const CEGUI::KeyEventArgs&>(e);
if (args.scancode == CEGUI::Key::Tab) // Tab or Shift+Tab
{
WidgetList::iterator itCurrent = Containers::find(mTabOrder.begin(), mTabOrder.end(), args.window);
OC_ASSERT(itCurrent != mTabOrder.end());
WidgetList::iterator itFocus = itCurrent;
CEGUI::Window* newWidget = 0;
do
{
if (args.sysKeys & CEGUI::Shift)
{
// Set previous
if (itFocus == mTabOrder.begin())
itFocus = mTabOrder.end();
--itFocus;
}
else
{
// Set next
++itFocus;
if (itFocus == mTabOrder.end())
itFocus = mTabOrder.begin();
}
newWidget = *itFocus;
}
while ((!newWidget->isVisible() || newWidget->isDisabled() || newWidget->getProperty("ReadOnly") == "True" ) && itFocus != itCurrent);
newWidget->activate();
// Make sure active widget will be visible
if (mScrollablePane)
{
CEGUI::Window* w = newWidget;
CEGUI::Vector2 widgetOffset(0, 0);
do
{
widgetOffset += w->getPosition().asAbsolute(w->getParentPixelSize());
w = w->getParent();
}
while (w != mScrollablePane && w != 0);
float32 scrollViewTop = mScrollablePane->getContentPaneArea().getSize().d_height * mScrollablePane->getVerticalScrollPosition();
float32 scrollViewBottom = scrollViewTop + mScrollablePane->getClipRect().getHeight();
if (widgetOffset.d_y < scrollViewTop || widgetOffset.d_y + newWidget->getPixelSize().d_height > scrollViewBottom)
{
// We need to scroll
mScrollablePane->setVerticalScrollPosition(widgetOffset.d_y / mScrollablePane->getContentPaneArea().getSize().d_height);
}
}
return true;
}
return false;
}
示例5: update
void GamePlate::update(float timeSinceLastUpdate)
{
CEGUI::UVector2 positionOffset;
if(d_isComingFromRight)
positionOffset = CEGUI::UVector2(cegui_reldim(timeSinceLastUpdate * -0.24f), cegui_absdim(0.f));
else
positionOffset = CEGUI::UVector2(cegui_reldim(timeSinceLastUpdate * 0.24f), cegui_absdim(0.f));
d_window->setPosition(d_window->getPosition() + positionOffset);
const CEGUI::UVector2& position = d_window->getPosition();
if(d_isComingFromRight)
{
if(position.d_x.d_scale < -1.2f)
d_isDestroyed = true;
}
else
{
if(position.d_x.d_scale > 1.2f)
d_isDestroyed = true;
}
}