示例#1
0
/*************************************************************************
	set the movement range of the thumb for the horizontal axis.
*************************************************************************/
void Thumb::setHorzRange(float min, float max)
{
    Sizef parentSize(getParentPixelSize());

	// ensure min <= max, swap if not.
	if (min > max)
	{
		float tmp = min;
		max = min;
		min = tmp;
	}

	d_horzMax = max;
	d_horzMin = min;

	// validate current position.
	const float cp = CoordConverter::asAbsolute(getXPosition(), parentSize.d_width);

	if (cp < min)
	{
		setXPosition(cegui_absdim(min));
	}
	else if (cp > max)
	{
		setXPosition(cegui_absdim(max));
	}

}
	ContainerContentWindow::ContainerContentWindow(Container* container, InventoryWindow* parent)
		: AbstractWindow("containercontentwindow.xml", WIT_MOUSE_INPUT),
		mContainer(container),
        mInventoryWindow(parent)
	{
		mContentWindow = getWindow("ContainerContentWindow/Content");
		mContentWindow->setUserData(container);
		mContentWindow->subscribeEvent(
			Window::EventDragDropItemDropped,
			boost::bind(&ContainerContentWindow::handleItemDroppedOnContainer, this, _1));
		mContentWindow->subscribeEvent(
            Window::EventDragDropItemEnters,
			boost::bind(&ContainerContentWindow::handleItemEntersContainer, this, _1));
		mContentWindow->subscribeEvent(
            Window::EventDragDropItemLeaves,
			boost::bind(&ContainerContentWindow::handleItemLeavesContainer, this, _1));

        UVector2 size = UVector2(
			cegui_absdim(container->getVolume().first*30),
            cegui_absdim(container->getVolume().second*30));
		mContentWindow->setSize(size);
        size.d_x += cegui_absdim(40);
        size.d_y += cegui_absdim(50);
        mContentWindow->getParent()->setMaxSize(size);
        mContentWindow->getParent()->setMinSize(size);

		initializeContent();

		bindDestroyWindowToXButton();
	}
示例#3
0
/*************************************************************************
	Move the window by the pixel offsets specified in 'offset'.	
*************************************************************************/
void FrameWindow::offsetPixelPosition(const Vector2f& offset)
{
    UVector2 uOffset(cegui_absdim(/*PixelAligned(*/offset.d_x/*)*/),
                     cegui_absdim(/*PixelAligned(*/offset.d_y/*)*/));

    setPosition(d_area.getPosition() + uOffset);
}
	void ContainerContentWindow::initializeContent()
	{
		ItemSet items = mContainer->getItems();
		for (ItemSet::const_iterator it = items.begin(); it != items.end(); it++)
		{
			Item* item = *it;
			Window* itemWindow = createItemWindow(item);

			std::pair<unsigned int, unsigned int> pos = mContainer->getItemPosition(item);
			itemWindow->setPosition(
				UVector2(
					cegui_absdim(pos.first*30),
					cegui_absdim(pos.second*30)));

            itemWindow->subscribeEvent(
                Window::EventMouseClick,
                boost::bind(&ContainerContentWindow::handleItemMouseClick, this, _1, item));

            itemWindow->subscribeEvent(
                Window::EventMouseDoubleClick,
                boost::bind(&ContainerContentWindow::handleItemDoubleClick, this, _1, item));

			mContentWindow->addChildWindow(itemWindow);
		}
	}
示例#5
0
void TestAARHUD::UpdateStaticText(CEGUI::Window* textControl, const std::string& newText,
                                    float red, float green, float blue, float x, float y)
{
   if (textControl != NULL)
   {
      // text and color
      if (!newText.empty() && textControl->getText() != newText)
      {
         textControl->setText(newText);
         if (red >= 0.00 && blue >= 0.0 && green >= 0.0)
         {
            textControl->setProperty("TextColours", 
               CEGUI::PropertyHelper::colourToString(CEGUI::colour(red, green, blue)));
            // how to do it with a string.  Use "FF00FF00" or "FFFFFFFF" for examples
            //String col = PropertyHelper::colourRectToString(ColourRect(PropertyHelper::stringToColour(String(color))));
            //textControl->setProperty("TextColours", col);         }
         }
      }
      // position
      if (x > 0.0 && y > 0.0)
      {
         CEGUI::UVector2 position = textControl->getPosition();
         CEGUI::UVector2 newPos(cegui_absdim(x), cegui_absdim(y));
         if (position != newPos)
            textControl->setPosition(newPos);
      }
   }
}
示例#6
0
/*************************************************************************
	Calculate size and position for a tab button
*************************************************************************/
void TabControl::calculateTabButtonSizePosition(size_t index)
{
    TabButton* btn = d_tabButtonVector [index];
    // relative height is always 1.0 for buttons since they are embedded in a
    // panel of the correct height already
    btn->setHeight(cegui_reldim(1.0f));
    btn->setYPosition(cegui_absdim(0.0f));
    // x position is based on previous button
    if (!index)
        // First button
        btn->setXPosition(cegui_absdim(d_firstTabOffset));
    else
    {
		Window* prevButton = d_tabButtonVector [index - 1];

		// position is prev pos + width
        btn->setXPosition(prevButton->getArea().d_max.d_x);
    }
    // Width is based on font size (expressed as absolute)
    Font* fnt = btn->getFont();
    btn->setWidth(cegui_absdim(fnt->getTextExtent(btn->getText())) +
                        getTabTextPadding() + getTabTextPadding());

    float left_x = btn->getXPosition ().d_offset;
    btn->setVisible ((left_x < getPixelSize ().d_width) &&
                     (left_x + btn->getPixelSize ().d_width > 0));
    btn->invalidate();
}
示例#7
0
/*************************************************************************
	Move the window by the pixel offsets specified in 'offset'.	
*************************************************************************/
void FrameWindow::offsetPixelPosition(const Vector2& offset)
{
    UVector2 uOffset(cegui_absdim(PixelAligned(offset.d_x)),
                     cegui_absdim(PixelAligned(offset.d_y)));

    setPosition(d_area.getPosition() + uOffset);
}
示例#8
0
/*************************************************************************
	Sets up sizes and positions for attached ItemEntry children.
*************************************************************************/
void PopupMenu::layoutItemWidgets()
{
	// get render area
	Rect render_rect = getItemRenderArea();

	// get starting position
	const float x0 = PixelAligned(render_rect.d_left);
	float y0 = PixelAligned(render_rect.d_top);

	URect rect;
	UVector2 sz(cegui_absdim(PixelAligned(render_rect.getWidth())), cegui_absdim(0)); // set item width

	// iterate through all items attached to this window
	ItemEntryList::iterator item = d_listItems.begin();
	while ( item != d_listItems.end() )
	{
		// get the "optimal" height of the item and use that!
		sz.d_y.d_offset = PixelAligned((*item)->getItemPixelSize().d_height); // rounding errors ?

		// set destination rect
		rect.setPosition(UVector2(cegui_absdim(x0), cegui_absdim(y0)) );
		rect.setSize( sz );
		(*item)->setArea(rect);

		// next position
		y0 += PixelAligned(sz.d_y.d_offset + d_itemSpacing);

		item++; // next item
	}
}
示例#9
0
void Application::initGui()
{
	m_guiRenderer = &CEGUI::OpenGL3Renderer::create();
	static_cast<CEGUI::OpenGL3Renderer*>(m_guiRenderer)->enableExtraStateSettings(true);
	CEGUI::System::create(*m_guiRenderer);
	initialiseResources();

	CEGUI::System& gui_system(CEGUI::System::getSingleton());
	CEGUI::GUIContext* guiContext = &gui_system.getDefaultGUIContext();
	CEGUI::SchemeManager::getSingleton().createFromFile(getGuiFullName(".scheme").c_str());
	guiContext->getMouseCursor().setDefaultImage(getGuiFullName("/MouseArrow").c_str());
	guiContext->getMouseCursor().hide();

	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	m_rootWindow = (CEGUI::DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
	CEGUI::Font& defaultFont = CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
	guiContext->setDefaultFont(&defaultFont);
	guiContext->setRootWindow(m_rootWindow);

	m_fpsLabel = (CEGUI::Window*)winMgr.createWindow(getGuiFullName("/Label").c_str());
	m_rootWindow->addChild(m_fpsLabel);

	m_fpsLabel->setPosition(CEGUI::UVector2(CEGUI::UDim(1.0f, -150.0f), cegui_reldim(0.0)));
	m_fpsLabel->setSize(CEGUI::USize(cegui_absdim(150.0f), cegui_absdim(25.0f)));
	m_fpsLabel->setProperty("HorzFormatting", "RightAligned");
	m_fpsLabel->setText("0 fps");
}
示例#10
0
/*************************************************************************
	Create initialise and return a ListHeaderSegment object, with all
	events subscribed and ready to use.
*************************************************************************/
ListHeaderSegment* ListHeader::createInitialisedSegment(const String& text, uint id, const UDim& width)
{
	// Build unique name
	std::stringstream name;
	name << SegmentNameSuffix << d_uniqueIDNumber;

	// create segment.
	ListHeaderSegment* newseg = createNewSegment(name.str().c_str());
	d_uniqueIDNumber++;

	// setup segment;
	newseg->setSize(USize(width, cegui_reldim(1.0f)));
	newseg->setMinSize(USize(cegui_absdim(MinimumSegmentPixelWidth), cegui_absdim(0)));
	newseg->setText(text);
	newseg->setID(id);
    newseg->setSizingEnabled(d_sizingEnabled);
    newseg->setDragMovingEnabled(d_movingEnabled);
    newseg->setClickable(d_sortingEnabled);

	// subscribe events we listen to
	newseg->subscribeEvent(ListHeaderSegment::EventSegmentSized, Event::Subscriber(&CEGUI::ListHeader::segmentSizedHandler, this));
	newseg->subscribeEvent(ListHeaderSegment::EventSegmentDragStop, Event::Subscriber(&CEGUI::ListHeader::segmentMovedHandler, this));
	newseg->subscribeEvent(ListHeaderSegment::EventSegmentClicked, Event::Subscriber(&CEGUI::ListHeader::segmentClickedHandler, this));
	newseg->subscribeEvent(ListHeaderSegment::EventSplitterDoubleClicked, Event::Subscriber(&CEGUI::ListHeader::segmentDoubleClickHandler, this));
	newseg->subscribeEvent(ListHeaderSegment::EventSegmentDragPositionChanged, Event::Subscriber(&CEGUI::ListHeader::segmentDragHandler, this));

	return newseg;
}
示例#11
0
    void Tooltip::sizeSelf(void)
    {
        Size textSize(getTextSize());

        setSize(
            UVector2(cegui_absdim(textSize.d_width),
                     cegui_absdim(textSize.d_height)));
    }
/************************************************************************
    Configure scroll bars
************************************************************************/
void ScrolledItemListBase::configureScrollbars(const Size& doc_size)
{
    Scrollbar* v = getVertScrollbar();
    Scrollbar* h = getHorzScrollbar();

    Size render_area_size = getItemRenderArea().getSize();

    // setup the pane size
    float pane_size_w = ceguimax(doc_size.d_width, render_area_size.d_width);
    UVector2 pane_size(cegui_absdim(pane_size_w), cegui_absdim(doc_size.d_height));

    d_pane->setMinSize(pane_size);
    d_pane->setMaxSize(pane_size);
    //d_pane->setWindowSize(pane_size);

    // "fix" scrollbar visibility
    if (d_forceVScroll || doc_size.d_height > render_area_size.d_height)
    {
        v->show();
    }
    else
    {
        v->hide();
    }

    //render_area_size = getItemRenderArea().getSize();

    if (d_forceHScroll || doc_size.d_width > render_area_size.d_width)
    {
        h->show();
    }
    else
    {
        h->hide();
    }

    // get a fresh item render area
    Rect render_area = getItemRenderArea();
    render_area_size = render_area.getSize();

    // update the pane clipper area
    static_cast<ClippedContainer*>(d_pane)->setClipArea(render_area);

    // setup vertical scrollbar
    v->setDocumentSize(doc_size.d_height);
    v->setPageSize(render_area_size.d_height);
    v->setStepSize(ceguimax(1.0f, render_area_size.d_height / 10.0f));
    v->setScrollPosition(v->getScrollPosition());

    // setup horizontal scrollbar
    h->setDocumentSize(doc_size.d_width);
    h->setPageSize(render_area_size.d_width);
    h->setStepSize(ceguimax(1.0f, render_area_size.d_width / 10.0f));
    h->setScrollPosition(h->getScrollPosition());
}
示例#13
0
/*************************************************************************
	Layout the segments
*************************************************************************/
void ListHeader::layoutSegments(void)
{
	UVector2 pos(cegui_absdim(-d_segmentOffset), cegui_absdim(0.0f));

	for (uint i = 0; i < getColumnCount(); ++i)
	{
		d_segments[i]->setPosition(pos);
		pos.d_x += d_segments[i]->getWidth();
	}

}
    void DragContainer::doDragging(const Point& local_mouse)
    {
        // calculate amount to move
        UVector2 offset(cegui_absdim(local_mouse.d_x), cegui_absdim(local_mouse.d_y));
        offset -= (d_usingFixedDragOffset) ? d_fixedDragOffset : d_dragPoint;
        // set new position
        setPosition(getPosition() + offset);

        // Perform event notification
        WindowEventArgs args(this);
        onDragPositionChanged(args);
    }
示例#15
0
/************************************************************************
    Resize to fit content
************************************************************************/
void ItemListBase::sizeToContent_impl(void)
{
    Rect renderArea(getItemRenderArea());
    Rect wndArea(getArea().asAbsolute(getParentPixelSize()));

    // get size of content
    Size sz(getContentSize());

    // calculate the full size with the frame accounted for and resize the window to this
    sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
    sz.d_height += wndArea.getHeight() - renderArea.getHeight();
    setSize(UVector2(cegui_absdim(sz.d_width), cegui_absdim(sz.d_height)));
}
示例#16
0
void SizeWindow (CEGUI::Window* w)
{//Size window to contents.
  float height(20.0f);
  height += CEGUI::PropertyHelper::stringToFloat (w->getProperty ("VertExtent"));
  w->setHeight(cegui_absdim(height));
  w->setYPosition(CEGUI::UDim(0.5f, -height/2));
}
示例#17
0
//----------------------------------------------------------------------------//
void ScrollablePane::updateContainerPosition(void)
{
    // basePos is the position represented by the scrollbars
    // (these are negated so pane is scrolled in the correct directions)
    UVector2 basePos(cegui_absdim(-getHorzScrollbar()->getScrollPosition()),
                     cegui_absdim(-getVertScrollbar()->getScrollPosition()));
    
    // this bias is the absolute position that 0 on the scrollbars represent.
    // Allows the pane to function correctly with negatively positioned content.
    UVector2 bias(cegui_absdim(d_contentRect.d_min.d_x),
                  cegui_absdim(d_contentRect.d_min.d_y));
    
    // set the new container pane position to be what the scrollbars request
    // minus any bias generated by the location of the content.
    getScrolledContainer()->setPosition(basePos - bias);
}
示例#18
0
void PushButton::resizeWithText()
{
	Size size = getRenderSize();
	setSize( Absolute, size );

	Point newPos;
	newPos.d_x = m_ptHookPosition.d_x;
	newPos.d_y = m_ptHookPosition.d_y;
	switch( m_HookMode )
	{
	case Hook_Left:
		newPos.d_y -= d_pixelSize.d_height / 2;
		break;
	case Hook_Right:
		newPos.d_x -= d_pixelSize.d_width;
		newPos.d_y -= d_pixelSize.d_height / 2;
		break;
	case Hook_Top:
		newPos.d_x -= d_pixelSize.d_width / 2;
		break;
	case Hook_Bottom:
		newPos.d_x -= d_pixelSize.d_width / 2;
		newPos.d_y -= d_pixelSize.d_height;
		break;
	case Hook_LeftTop:
		break;
	case Hook_LeftBottom:
		newPos.d_y -= d_pixelSize.d_height;
		break;
	case Hook_RightTop:
		newPos.d_x -= d_pixelSize.d_width;
		break;
	case Hook_RightBottom:
		newPos.d_x -= d_pixelSize.d_width;
		newPos.d_y -= d_pixelSize.d_height;
		break;
	case Hook_Center:
		newPos.d_x -= d_pixelSize.d_width / 2;
		newPos.d_y -= d_pixelSize.d_height / 2;
		break;
	default:
		break;
	}
	UVector2  relativePos;
	d_area.setPosition( UVector2(cegui_absdim(PixelAligned(newPos.d_x)), cegui_absdim(PixelAligned( newPos.d_y) ) ) );
}
    void WidgetComponent::layout(const Window& owner) const
    {
        try
        {
            Rect pixelArea(d_area.getPixelRect(owner));
            URect window_area(cegui_absdim(pixelArea.d_left),
                              cegui_absdim(pixelArea.d_top),
                              cegui_absdim(pixelArea.d_right),
                              cegui_absdim(pixelArea.d_bottom));

            Window* wnd = WindowManager::getSingleton().getWindow(owner.getName() + d_nameSuffix);
            wnd->setArea(window_area);
            wnd->notifyScreenAreaChanged();
        }
        catch (UnknownObjectException&)
        {}
    }
bool ScrolledItemListBase::handle_HScroll(const EventArgs& e)
{
    const WindowEventArgs& we = static_cast<const WindowEventArgs&>(e);
    Scrollbar* h = static_cast<Scrollbar*>(we.window);
    float newpos = -h->getScrollPosition();
    d_pane->setXPosition(cegui_absdim(newpos));
    return true;
}
示例#21
0
    void WidgetComponent::layout(const Window& owner) const
    {
        try
        {
            Rectf pixelArea(d_area.getPixelRect(owner));
            URect window_area(cegui_absdim(pixelArea.left()),
                                cegui_absdim(pixelArea.top()),
                                cegui_absdim(pixelArea.right()),
                                cegui_absdim(pixelArea.bottom()));

            Window* wnd = owner.getChild(d_name);
            wnd->setArea(window_area);
            wnd->notifyScreenAreaChanged();
        }
        catch (UnknownObjectException&)
        {}
    }
/************************************************************************
    Initialise
************************************************************************/
void ScrolledItemListBase::initialiseComponents()
{
    // Only process the content pane if it hasn't been done in the past
    // NOTE: This ensures that a duplicate content pane is not created. An example where
    // this would be possible would be when changing the Look'N'Feel of the widget
    // (for instance an ItemListBox), an operation which would reconstruct the child components
    // of the widget by destroying the previous ones and creating new ones with the
    // new Look'N'Feel. However, since the content pane is not defined in the
    // look and feel file and thus not associated with the look'N'Feel itself
    // but instead created here manually, the destruction would not contemplate the content
    // pane itself, so when the children would be rebuilt, a duplicate content pane
    // would be attempted (and an exception would be issued).
    if(!d_pane)
    {
        // IMPORTANT:
        // we must do this before the base class handling or we'll lose the onChildRemoved subscriber!!!
        d_pane = WindowManager::getSingletonPtr()->createWindow("ClippedContainer", d_name+ContentPaneNameSuffix);

        // set up clipping
        static_cast<ClippedContainer*>(d_pane)->setClipperWindow(this);
        addChildWindow(d_pane);
    }

    // base class handling
    ItemListBase::initialiseComponents();

    // set default pane position
    Rect r = getItemRenderArea();
    d_pane->setPosition(UVector2(cegui_absdim(r.d_left),cegui_absdim(r.d_top)));

    // init scrollbars
    Scrollbar* v = getVertScrollbar();
    Scrollbar* h = getHorzScrollbar();

    v->setAlwaysOnTop(true);
    h->setAlwaysOnTop(true);

    v->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_VScroll,this));
    h->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_HScroll,this));

    v->hide();
    h->hide();
}
	bool ContainerContentWindow::handleItemDroppedOnContainer(const EventArgs& evt)
	{
		const DragDropEventArgs& evtArgs = static_cast<const DragDropEventArgs&>(evt);

		if (evtArgs.dragDropItem->testClassName("ItemDragContainer"))
		{
			ItemDragContainer* dragcont = dynamic_cast<ItemDragContainer*>(
				evtArgs.dragDropItem);
			Item* item = dragcont->getItem();


			CEGUI::Vector2 relPos = evtArgs.dragDropItem->getPosition().asAbsolute(evtArgs.dragDropItem->getParentPixelSize()) - 
									mContentWindow->getPosition().asAbsolute(mContentWindow->getParentPixelSize());
			int x = relPos.d_x, y = relPos.d_y;

            // übergangspixel
            x += 14;
            y += 14;

            x = x / 30;
            y = y / 30;

			if( mContainer->addItem(item,IntPair(x,y)) )
            {
                if( dragcont != getItemWindow(item) )
                {
                    CEGUI::WindowManager::getSingleton().destroyWindow(dragcont);
                    //dragcont->destroyWindow();
                    dragcont = createItemWindow(item);
                    mContentWindow->addChildWindow(dragcont);
                }
			    std::pair<unsigned int, unsigned int> pos = mContainer->getItemPosition(item);
			    dragcont->setPosition(
				    UVector2(
					    cegui_absdim(pos.first*30),
					    cegui_absdim(pos.second*30)));
			    dragcont->setItemParent(mContainer);

                handleItemLeavesContainer(evt);
			    return true;
            }
		}
        handleItemLeavesContainer(evt);
		return false;
	}
/************************************************************************
    Event subscribers for scrolling
************************************************************************/
bool ScrolledItemListBase::handle_VScroll(const EventArgs& e)
{
    const WindowEventArgs& we = static_cast<const WindowEventArgs&>(e);
    Scrollbar* v = static_cast<Scrollbar*>(we.window);
    Rect render_area = getItemRenderArea();
    float newpos = -v->getScrollPosition()+render_area.d_top;
    d_pane->setYPosition(cegui_absdim(newpos));
    return true;
}
示例#25
0
void Button2d::init( CEGUI::UDim x, CEGUI::UDim y, const QString &image )
{
	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	_ceguiButton = (CEGUI::PushButton*)winMgr.createWindow("AquaLook/ImageButton", "bt_" + QString::number(_counter++).toStdString());

	// Position
	_ceguiButton->setPosition(CEGUI::UVector2(x, y));

	// Size
	CEGUI::Imageset *btImageset = createImageSet(image);
	CEGUI::Size s = btImageset->getNativeResolution();
	_ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(s.d_width), cegui_absdim(s.d_height)));

	_ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseButtonUp, CEGUI::Event::Subscriber(&Button2d::onMouseClick, this));
	_ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseEnters, CEGUI::Event::Subscriber(&Button2d::onMouseEnters, this));

//	setCursor(QCursor(Qt::PointingHandCursor));
}
示例#26
0
/*************************************************************************
    Open the PopupMenu attached to this item.
*************************************************************************/
void MenuItem::openPopupMenu(bool notify)
{
    // no popup? or already open...
    if (d_popup == 0 || d_opened)
        return;

    d_popupOpening = false;
    d_popupClosing = false;

    // should we notify ?
    // if so, and we are attached to a menu bar or popup menu, we let it handle the "activation"
    Window* p = d_ownerList;

    if (notify && p)
    {
        if (dynamic_cast<Menubar*>(p))
        {
            // align the popup to the bottom-left of the menuitem
            UVector2 pos(cegui_absdim(0), cegui_absdim(d_pixelSize.d_height));
            d_popup->setPosition(pos + d_popupOffset);

            static_cast<Menubar*>(p)->changePopupMenuItem(this);
            return; // the rest is handled when the menu bar eventually calls us itself
        }
        // or maybe a popup menu?
        else if (dynamic_cast<PopupMenu*>(p))
        {
            // align the popup to the top-right of the menuitem
            UVector2 pos(cegui_absdim(d_pixelSize.d_width), cegui_absdim(0));
            d_popup->setPosition(pos + d_popupOffset);

            static_cast<PopupMenu*>(p)->changePopupMenuItem(this);
            return; // the rest is handled when the popup menu eventually calls us itself
        }
    }

    // by now we must handle it ourselves
    // match up with Menubar::changePopupMenu
    d_popup->openPopupMenu(false);

    d_opened = true;
    invalidate();
}
示例#27
0
/*!
	Init method, for every button created
*/
void Button2d::init( qreal x, qreal y, const QString &image )
{
	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	_ceguiButton = (CEGUI::PushButton*)winMgr.createWindow("AquaLook/ImageButton", "bt_" + QString::number(_counter++).toStdString());

	// Position
	_ceguiButton->setPosition(CEGUI::UVector2(cegui_absdim(x), cegui_absdim(y)));

	// Size
	CEGUI::Imageset *btImageset = createImageSet(image);
	if(btImageset == NULL)
	{
		qWarning() << "[Button2d::init] Imageset is NULL, reseting size to 64x64";
		_ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(64), cegui_absdim(64)));
	}
	else
	{
		CEGUI::Size s = btImageset->getNativeResolution();
		_ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(s.d_width), cegui_absdim(s.d_height)));
	}

	// Uses click to make sure that button down occurred. (ex: problem when opening options after clicking a 3D button)
	_ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseClick, CEGUI::Event::Subscriber(&Button2d::onMouseClick, this));
	_ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseEnters, CEGUI::Event::Subscriber(&Button2d::onMouseEnters, this));
//	_ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseLeaves, CEGUI::Event::Subscriber(&Button2d::onMouseLeaves, this));

//	setCursor(QCursor(Qt::PointingHandCursor));
}
void InitPetSelectWnd(CEGUI::Window* mainPage)
{
	if (!mainPage)
		return;

	CEGUI::Window* wnd;
	char tempText[256];

	for (int i = 0; i < PET_SELECT_WND_CNT; ++i)
	{
		sprintf(tempText, "PetStrengthen/PetSelectWnd/Pet%d/DragContainer", i+1);
		wnd = mainPage->getChildRecursive(tempText);
		if (wnd)
		{
			wnd->setSize(CEGUI::UVector2(cegui_absdim(32 + 0),cegui_absdim(32 + 0)));
			wnd->setPosition(CEGUI::UVector2(cegui_absdim(5),cegui_absdim(5)));
		}

		sprintf(tempText, "PetStrengthen/PetSelectWnd/Pet%d", i+1);
		wnd = mainPage->getChildRecursive(tempText);
		if (wnd)
		{
			wnd->setSize(CEGUI::UVector2(cegui_absdim(32 + 10),cegui_absdim(32 + 10)));
		}
	}
}
示例#29
0
CEGUI::Window* TestAARHUD::CreateText(const std::string& name, CEGUI::Window* parent, const std::string& text,
                                 float x, float y, float width, float height)
{
   CEGUI::WindowManager* wm = CEGUI::WindowManager::getSingletonPtr();

   // create base window and set our default attribs
   CEGUI::Window* result = wm->createWindow("WindowsLook/StaticText", name);
   parent->addChildWindow(result);
   result->setText(text);
   result->setPosition(CEGUI::UVector2(cegui_absdim(x), cegui_absdim(y)));
   result->setSize(CEGUI::UVector2(cegui_absdim(width), cegui_absdim(height)));
   result->setProperty("FrameEnabled", "false");
   result->setProperty("BackgroundEnabled", "false");
   result->setHorizontalAlignment(CEGUI::HA_LEFT);
   result->setVerticalAlignment(CEGUI::VA_TOP);
   // set default color to white
   result->setProperty("TextColours", 
      CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0f, 1.0f, 1.0f)));
   result->show();

   return result;
}
    void DragContainer::onMouseButtonDown(MouseEventArgs& e)
    {
        Window::onMouseButtonDown(e);

        if (e.button == LeftButton)
        {
            // ensure all inputs come to us for now
            if (captureInput())
            {
                // get position of mouse as co-ordinates local to this window.
                Vector2 localPos = CoordConverter::screenToWindow(*this, e.position);

                // store drag point for possible sizing or moving operation.
                d_dragPoint.d_x = cegui_absdim(localPos.d_x);
                d_dragPoint.d_y = cegui_absdim(localPos.d_y);
                d_leftMouseDown = true;
            }

            ++e.handled;
        }

    }