示例#1
0
void InternalWindow::borderDragMouseDragged(MouseEventDetails* const e)
{
    Vec2f Size;
    bool PositionChange;
    Pnt2f Position;
    Pnt2f BottomRight(getPosition() + getSize());
    switch(_BorderDragged)
    {
        case WINDOW_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), getPreferredSize().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - getPosition().x(), getPreferredSize().y());
            break;
        case WINDOW_TOP_BORDER:
            Size.setValues(getPreferredSize().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_BORDER:
            PositionChange = false;
            Size.setValues(getPreferredSize().x(), e->getLocation().y() - getPosition().y());
            break;
        case WINDOW_TOP_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - getPosition().x(), e->getLocation().y() - getPosition().y());
            break;
        case WINDOW_TOP_RIGHT_BORDER:
            Size.setValues(e->getLocation().x() - getPosition().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position.setValues(getPosition().x(), BottomRight.y() - Size.y());
            break;
        case WINDOW_BOTTOM_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), e->getLocation().y() - getPosition().y());
            PositionChange = true;
            Position.setValues( BottomRight.x() - Size.x(), getPosition().y());
            break;
    }

    if(PositionChange)
    {
        setPreferredSize(Size);
        setPosition(Position);
    }
    else
    {
        setPreferredSize(Size);
    }
}
示例#2
0
void ToolTip::changed(ConstFieldMaskArg whichField,
                      UInt32            origin,
                      BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & TextFieldMask)
    {
        setPreferredSize(calculatePreferredSize());
        if(getSize() != getPreferredSize())
        {
            setSize(getPreferredSize());
        }
    }
}
示例#3
0
void AbstractWindow::updateContainerLayout(void)
{
    if(getParentContainer() != NULL)
    {
		Inherited::updateContainerLayout();
    }
	else if(getSize() != getPreferredSize())
	{
		Vec2f Size(osgMax(osgMin(getPreferredSize().x(), getMaxSize().x()), getMinSize().x()),
			       osgMax(osgMin(getPreferredSize().y(), getMaxSize().y()), getMinSize().y()));
        if(getSize() != Size)
        {
			setSize(Size);
        }
	}
}
    int MessageBox::open() {
      getParent()->open();
      uint32_t width;
      uint32_t height;

      MessageBoxSelectionListener selectionListener;

      getPreferredSize(pimpl_->message_, width, height);

      pimpl_->shell_.setBounds(0, 0, width, height);
      pimpl_->shell_.open();

      for(auto i = xxx::instance_.labels_.begin(); i != xxx::instance_.labels_.end(); i++) {
        if(pimpl_->button_ & i->first) {
          std::unique_ptr<Button> b(new Button(&pimpl_->shell_));

          b->setText(i->second);
          b->setBounds(1, 1, 5, 1);
          b->addSelectionListener(&selectionListener);
          pimpl_->buttons_.emplace_back(std::move(b));
        }
      }

      pimpl_->shell_.paint();

      while(!selectionListener.complete()) {
        if(!pimpl_->shell_.getDisplay()->readAndDispatch()) {
          pimpl_->shell_.getDisplay()->sleep();
        }
      }

      return(0);
    }
示例#5
0
bool Panel::load( DataSectionPtr section )
{
	lastX_ = section->readInt( "lastX", lastX_ );
	lastY_ = section->readInt( "lastY", lastY_ );
	isExpanded_ = section->readBool( "expanded", isExpanded_ );
	expandedSize_ = section->readInt( "expandedSize", expandedSize_ );
	isFloating_ = section->readBool( "floating", isFloating_ );

	std::vector<DataSectionPtr> tabs;
	section->openSections( "Tab", tabs );
	if ( tabs.empty() )
		return false;
	activeTab_ = 0;
	TabPtr firstTab = 0;
	for( std::vector<DataSectionPtr>::iterator i = tabs.begin(); i != tabs.end(); ++i )
	{
		std::string contentID = (*i)->readString( "contentID" );
		if ( contentID.empty() )
			continue;

		TabPtr newTab = new Tab( this, contentID );

		if ( !newTab->getContent() )
			continue;

		newTab->setVisible( (*i)->readBool( "visible", true ) );

		// ignoring if loading a tab returns false
		newTab->load( *i );

		addTab( newTab );

		newTab->getCWnd()->ShowWindow( SW_HIDE );

		if ( !firstTab && !!activeTab_ )
			firstTab = activeTab_;
	}
	if ( firstTab )
		setActiveTab( firstTab );

	if ( activeTab_ )
	{
		updateTabBar();

		if ( isExpanded_ )
			activeTab_->getCWnd()->ShowWindow( SW_SHOW );
		else
			activeTab_->getCWnd()->ShowWindow( SW_HIDE );
	}

	int w;
	int h;
	getPreferredSize( w, h );
	SetWindowPos( 0, 0, 0,
		section->readInt( "lastWidth", w ), section->readInt( "lastHeight", h ),
		SWP_NOMOVE | SWP_NOZORDER );

	return true;
}
示例#6
0
CheckBox::CheckBox(const scv::Point &p1, bool state, const std::string &str) : StateButton(state), Label(p1, Point( p1.x + 13 + FontTahoma::getInstance()->getStringLength(str) + 3,p1.y + 13), str) {
   _isHResizable = _isVResizable = false;
   _type = CHECKBOX;

   createTexture();

   setMaximumSize(getPreferredSize());
}
示例#7
0
文件: Label.cpp 项目: lucaszardo/SCV
Label::Label(const scv::Point &p1, const scv::Point &p2, const std::string& str) : Component(p1, p2) {
   _isHResizable = _isVResizable = false;
   _str = str;
   _type = LABEL;

   setMaximumSize(getPreferredSize());

   createTexture();
}
示例#8
0
文件: Label.cpp 项目: lucaszardo/SCV
Label::Label(const scv::Point &p, unsigned int width, const std::string& str) : Component(p, Point(p.x + width, p.y + 13)) {
   _isHResizable = _isVResizable = false;
   _str = str;
   _type = LABEL;

   setMaximumSize(getPreferredSize());

   createTexture();
}
示例#9
0
文件: Label.cpp 项目: lucaszardo/SCV
Label::Label(const scv::Point &p, const std::string& str) : Component(p, Point(p.x + FontTahoma::getInstance()->getStringLength(str), p.y + 13)) {
   _isHResizable = _isVResizable = false;
   _str = str;
   _type = LABEL;

   setMaximumSize(getPreferredSize());

   createTexture();
}
示例#10
0
void InternalWindow::updateContainerLayout(void)
{
    if(getParentDrawingSurface() != NULL)
    {
		getParentDrawingSurface()->updateWindowLayout(this);
    }
	else if(getSize() != getPreferredSize())
	{
        Inherited::updateContainerLayout();
	}
}
示例#11
0
Vec2f UIDrawObjectCanvas::getRequestedSize(void) const
{
    if(getUsePreferredSizeAsRequested())
    {
        return getPreferredSize();
    }
    else
    {
        return Inherited::getRequestedSize();
    }
}
示例#12
0
ColorPicker::ColorPicker(const scv::Point &p1) : Panel(p1, Point(p1.x + 360, p1.y + 155)), MatrixTemplate<ColorRGBA>(360, 102, ColorRGBA(0,255,0,255)) {
   _isHResizable = _isVResizable = false;

   _currentColor = ColorRGBA(0,0,0,255);

   _pickerWaitingColor = false;

   _cpTexture = NULL;

   _rgbs[0] = new Spinner(Point(20 ,106),50,0,255,0,1);
   _rgbs[1] = new Spinner(Point(90 ,106),50,0,255,0,1);
   _rgbs[2] = new Spinner(Point(160,106),50,0,255,0,1);
   _rgbs[3] = new Spinner(Point(230,106),50,0,100,100,5);
   _btPicker = new EyeDropper(this);

   _saturation = 100;
   Panel::addChild(_rgbs[0]);
   Panel::addChild(_rgbs[1]);
   Panel::addChild(_rgbs[2]);
   Panel::addChild(_rgbs[3]);
   Panel::addChild(_btPicker);

   Panel::addChild(new Label(Point(  8, 109), "R:"));
   Panel::addChild(new Label(Point( 78, 109), "G:"));
   Panel::addChild(new Label(Point(148, 109), "B:"));
   Panel::addChild(new Label(Point(218, 109), "S:"));

   // initial color
   _currentColorPosition = Point(0, MatrixTemplate<ColorRGBA>::getHeight() - 1);

   _type = COLORPICKER;

   refreshColor();

   createTexture();

   setMaximumSize(getPreferredSize());
   setMinimumSize(getPreferredSize());
}
示例#13
0
void MenuBar::updateLayout(void)
{
	//Determine the Max Preferred Height of my MenuItems
	Real32 MaxHeight(0);
	Real32 TotalWidth(0);
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        if(MaxHeight < getChildren(i)->getPreferredSize().y())
        {
            MaxHeight = getChildren(i)->getPreferredSize().y();
	    }
	    TotalWidth += getChildren(i)->getPreferredSize().x();
	}

    //Set My preferred Size
	Pnt2f TopLeft, BottomRight;
	Pnt2f InsetsTopLeft, InsetsBottomRight;
	getBounds(TopLeft, BottomRight);
	getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);

	Vec2f InsetSize( (BottomRight-TopLeft) - (InsetsBottomRight-InsetsTopLeft) );

    Vec2f NewSize( TotalWidth+InsetSize.x(), MaxHeight+InsetSize.y());
    if(getPreferredSize() != NewSize)
    {
        setPreferredSize(NewSize);
    }
    
	getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);
	
	//Now position and size the Items
	Real32 LeftOffset(InsetsTopLeft.x());
    Vec2f Size;
    Pnt2f Pos;
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        Size.setValues(getChildren(i)->getPreferredSize().x(), MaxHeight);
        if(getChildren(i)->getSize() != Size)
        {
            getChildren(i)->setSize(Size);
        }
        Pos.setValues(LeftOffset, InsetsTopLeft.y());
        if(getChildren(i)->getPosition() != Pos)
        {
            getChildren(i)->setPosition(Pos);
        }

        LeftOffset += getChildren(i)->getPreferredSize().x();
    }
}
	void CCControlBase::needsLayout()	{
		CCSize ctrlSize(getPreferredSize());
		if(getBackGroundSprite() == nullptr)	{
			if(ctrlSize.width == 0)	{
				ctrlSize.width = 100;
			}
			if(ctrlSize.height == 0)	{
				ctrlSize.height = 100;
			}
		}	
		else	{
			ctrlSize = getBackGroundSprite()->getContentSize();
			if(getPreferredSize().width != 0)	{
				ctrlSize.width = getPreferredSize().width;
			}
			if(getPreferredSize().height != 0)	{
				ctrlSize.height = getPreferredSize().height;
			}
			if(ctrlSize.equals(getBackGroundSprite()->getContentSize()) == false)	{
				getBackGroundSprite()->setContentSize(ctrlSize);
			}

			const CCPoint& anchorPoint(getAnchorPoint());

			if(isIgnoreAnchorPointForPosition())	{
				getBackGroundSprite()->setPosition(
					ccp( ctrlSize.width * 0.5f, ctrlSize.height * 0.5f )
					);
			}
			else	{
				getBackGroundSprite()->setPosition(
					ccp( ctrlSize.width, ctrlSize.height )
					);
			}
		}
		setContentSize(ctrlSize);
	}
示例#15
0
void Window::remapWindow()
{
  if (m_isAutoRemap) {
    m_isAutoRemap = false;
    this->setVisible(true);
  }

  setBounds(Rect(Point(getBounds().x, getBounds().y),
                 getPreferredSize()));

  // load layout
  loadLayout();

  invalidate();
}
示例#16
0
Vec2f ToolTip::calculatePreferredSize(void) const
{
    if(getFont() == NULL)
    {
        return getPreferredSize();
    }

    Real32 Top(0),Bottom(0),Left(0),Right(0);
    if(getDrawnBorder() != NULL)
    {
        getDrawnBorder()->getInsets(Left, Right, Top, Bottom);
    }

    Pnt2f TextTopLeft, TextBottomRight;
    getFont()->getBounds(getText(), TextTopLeft, TextBottomRight);
    return TextBottomRight - TextTopLeft + Vec2f(Left+Right+2, Top+Bottom+2);
}
示例#17
0
void PopupMenu::updateLayout(void)
{
    //Determine the Max Preferred Width of my MenuItems
    Real32 MaxWidth(0);
    Real32 TotalHeight(0);
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        if(MaxWidth < getChildren(i)->getRequestedSize().x())
        {
            MaxWidth = getChildren(i)->getRequestedSize().x();
        }
        TotalHeight += getChildren(i)->getRequestedSize().y();
        if(i!=0)
        {
            TotalHeight += 1.0f;
        }
    }

    //Set My preferred Size
    Pnt2f TopLeft, BottomRight;
    Pnt2f InsetsTopLeft, InsetsBottomRight;
    getBounds(TopLeft, BottomRight);
    getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);

    Vec2f InsetSize( (BottomRight-TopLeft) - (InsetsBottomRight-InsetsTopLeft) );
    setPreferredSize(Vec2f(MaxWidth+InsetSize.x(), TotalHeight+InsetSize.y()));

    //Sneakily set my size
    _sfSize.setValue(getPreferredSize());

    getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);

    //Now position and size the Items
    Real32 TopOffset(InsetsTopLeft.y());
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        getChildren(i)->setSize(Vec2f(MaxWidth, getChildren(i)->getRequestedSize().y()));
        getChildren(i)->setPosition(Pnt2f(InsetsTopLeft.x(), TopOffset));

        TopOffset += getChildren(i)->getRequestedSize().y() +1;
    }
}
示例#18
0
void Label_t::update()
{
	Rectangle thisBounds(0, 0, getBounds().width, getBounds().height);

	// Check if the component was ever layouted, otherwise set to a high value
	if (!thisBounds.width && !thisBounds.height)
	{
		thisBounds.width = 9999;
		thisBounds.height = 9999;
	}

	// get text bounds
	cr = graphics.getContext();
	cairo_set_font_face(cr, font->getFace());
	cairo_set_font_size(cr, fontSize);
	cairo_text_extents(cr, this->text.c_str(), &lastExtents);
	Dimension newPreferred(lastExtents.width + 3, lastExtents.height + 3);

	// Set new preferred size
	if (getPreferredSize() != newPreferred) setPreferredSize(newPreferred);
	markFor(COMPONENT_REQUIREMENT_PAINT);
}
示例#19
0
void TableHeader::updateLayout(void)
{
	Pnt2f BorderTopLeft, BorderBottomRight;
	getInsideInsetsBounds(BorderTopLeft, BorderBottomRight);
	
    UInt32 CumulativeWidth(0);
    UInt32 Height(0);
    
    //Use the Model to update the position and sizes of the Headers
    for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
    {
        getColumnHeaders(i)->setPosition( Pnt2f(BorderTopLeft.x() + CumulativeWidth, BorderTopLeft.y()) );
        getColumnHeaders(i)->setSize( Vec2f(getColumnModel()->getColumn(i)->getWidth(), getColumnHeaders(i)->getPreferredSize().y()) );

        Height = osgMax<UInt32>(Height, getColumnHeaders(i)->getSize().y());
        CumulativeWidth += getColumnHeaders(i)->getSize().x();

        //Add on the Margin
        if(i != getMFColumnHeaders()->size()-1)
        {
            CumulativeWidth += getColumnModel()->getColumnMargin();
        }
    }
    
    //Use the Model to update the position and sizes of the Margins
    //Update My Preferred Size
	Pnt2f TopLeft, BottomRight;
	getBounds(TopLeft, BottomRight);

    Vec2f NewPreferredSize(CumulativeWidth + (BottomRight.x() - TopLeft.x() - BorderBottomRight.x() + BorderTopLeft.x()),
                               Height + (BottomRight.y() - TopLeft.y() - BorderBottomRight.y() + BorderTopLeft.y()));
    if(NewPreferredSize != getPreferredSize())
    {
            setPreferredSize(NewPreferredSize);
    }
}
示例#20
0
ColorSelector::ColorSelector()
  : PopupFramePin("Color Selector", false)
  , m_color(Color::fromMask())
  , m_vbox(JI_VERTICAL)
  , m_topBox(JI_HORIZONTAL)
  , m_colorPalette(false)
  , m_indexButton("Index", 1, JI_BUTTON)
  , m_rgbButton("RGB", 1, JI_BUTTON)
  , m_hsvButton("HSB", 1, JI_BUTTON)
  , m_grayButton("Gray", 1, JI_BUTTON)
  , m_maskButton("Mask", 1, JI_BUTTON)
  , m_maskLabel("Transparent Color Selected")
  , m_disableHexUpdate(false)
{
  m_topBox.setBorder(gfx::Border(0));
  m_topBox.child_spacing = 0;

  m_colorPalette.setColumns(40);
  m_colorPalette.setBoxSize(6*jguiscale());
  m_colorPaletteContainer.attachToView(&m_colorPalette);

  m_colorPaletteContainer.setExpansive(true);

  setup_mini_look(&m_indexButton);
  setup_mini_look(&m_rgbButton);
  setup_mini_look(&m_hsvButton);
  setup_mini_look(&m_grayButton);
  setup_mini_look(&m_maskButton);

  m_topBox.addChild(&m_indexButton);
  m_topBox.addChild(&m_rgbButton);
  m_topBox.addChild(&m_hsvButton);
  m_topBox.addChild(&m_grayButton);
  m_topBox.addChild(&m_maskButton);
  m_topBox.addChild(&m_hexColorEntry);
  {
    Box* miniVbox = new Box(JI_VERTICAL);
    miniVbox->addChild(getPin());
    m_topBox.addChild(new BoxFiller);
    m_topBox.addChild(miniVbox);
  }
  m_vbox.addChild(&m_topBox);
  m_vbox.addChild(&m_colorPaletteContainer);
  m_vbox.addChild(&m_rgbSliders);
  m_vbox.addChild(&m_hsvSliders);
  m_vbox.addChild(&m_graySlider);
  m_vbox.addChild(&m_maskLabel);
  addChild(&m_vbox);

  m_indexButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this);
  m_rgbButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this);
  m_hsvButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this);
  m_grayButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this);
  m_maskButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this);

  m_colorPalette.IndexChange.connect(&ColorSelector::onColorPaletteIndexChange, this);
  m_rgbSliders.ColorChange.connect(&ColorSelector::onColorSlidersChange, this);
  m_hsvSliders.ColorChange.connect(&ColorSelector::onColorSlidersChange, this);
  m_graySlider.ColorChange.connect(&ColorSelector::onColorSlidersChange, this);
  m_hexColorEntry.ColorChange.connect(&ColorSelector::onColorHexEntryChange, this);

  selectColorType(Color::RgbType);
  setPreferredSize(gfx::Size(300*jguiscale(), getPreferredSize().h));

  m_onPaletteChangeSlot =
    App::instance()->PaletteChange.connect(&ColorSelector::onPaletteChange, this);

  initTheme();
}
示例#21
0
void kgeography::resizeMainWindow()
{
	if (p_askWidget) resize(getPreferredSize());
}
示例#22
0
Vec2f Component::getPreferredScrollableViewportSize(void)
{
    return getPreferredSize();
}
示例#23
0
Vec2f ComponentMenuItem::getContentRequestedSize(void) const
{
    if(getComponent() != NULL)
    {
        Vec2f ComponentRequestedSize(0.0,0.0);
        if(getComponent() != NULL)
        {
            ComponentRequestedSize = getComponent()->getRequestedSize();
        }

        Pnt2f AcceleratorTextTopLeft, AcceleratorTextBottomRight;
        getFont()->getBounds(_AcceleratorText, AcceleratorTextTopLeft, AcceleratorTextBottomRight);

        Vec2f RequestedSize((ComponentRequestedSize.x()) + (AcceleratorTextBottomRight.x() - AcceleratorTextTopLeft.x()), osgMax(getPreferredSize().y(), ComponentRequestedSize.y()));

        if(!_AcceleratorText.empty())
        {
            RequestedSize[0] += 50.0f;
        }
        else
        {
            RequestedSize[0] += 25.0f;
        }

        return RequestedSize;
    }
    else
    {
        return Inherited::getContentRequestedSize();
    }
}
示例#24
0
Vec2f MenuItem::getContentRequestedSize(void) const
{
    Pnt2f TextTopLeft, TextBottomRight;
    getFont()->getBounds(getText(), TextTopLeft, TextBottomRight);
    Pnt2f AcceleratorTextTopLeft, AcceleratorTextBottomRight;
    getFont()->getBounds(_AcceleratorText, AcceleratorTextTopLeft, AcceleratorTextBottomRight);
    
	Vec2f RequestedSize((TextBottomRight.x() - TextTopLeft.x()) + (AcceleratorTextBottomRight.x() - AcceleratorTextTopLeft.x()), getPreferredSize().y());

	if(!_AcceleratorText.empty())
	{
		RequestedSize[0] += 50.0f;
	}
	else
	{
		RequestedSize[0] += 25.0f;
	}

	return RequestedSize;
}