Exemplo n.º 1
0
void QgsComposerPicture::loadPicture( const QString &path )
{
  if ( path.startsWith( "http" ) )
  {
    //remote location
    loadRemotePicture( path );
  }
  else
  {
    //local location
    loadLocalPicture( path );
  }
  if ( mMode != Unknown ) //make sure we start with a new QImage
  {
    recalculateSize();
  }
  else if ( mHasExpressionError || !( path.isEmpty() ) )
  {
    //trying to load an invalid file or bad expression, show cross picture
    mMode = SVG;
    QString badFile( ":/images/composer/missing_image.svg" );
    mSVG.load( badFile );
    if ( mSVG.isValid() )
    {
      mMode = SVG;
      QRect viewBox = mSVG.viewBox(); //take width/height ratio from view box instead of default size
      mDefaultSvgSize.setWidth( viewBox.width() );
      mDefaultSvgSize.setHeight( viewBox.height() );
      recalculateSize();
    }
  }

  emit itemChanged();
}
Exemplo n.º 2
0
void PageBreakEntry::updateEntry()
{
    if (worksheet()->isPrinting()) {
        m_msgItem->setVisible(false);
        recalculateSize();
    } else if (!m_msgItem->isVisible()) {
        m_msgItem->setVisible(true);
        recalculateSize();
    }
    return;
}
Exemplo n.º 3
0
//! Insert a menu item at specified position.
u32 CGUIContextMenu::insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled,
    bool hasSubMenu, bool checked, bool autoChecking)
{
	SItem s;
	s.Enabled = enabled;
	s.Checked = checked;
	s.AutoChecking = autoChecking;
	s.Text = text;
	s.IsSeparator = (text == 0);
	s.SubMenu = 0;
	s.CommandId = commandId;

	if (hasSubMenu)
	{
		s.SubMenu = new CGUIContextMenu(Environment, this, commandId,
			core::rect<s32>(0,0,100,100), false, false);
		s.SubMenu->setVisible(false);
	}

    u32 result = idx;
    if ( idx < Items.size() )
    {
        Items.insert(s, idx);
    }
    else
    {
        Items.push_back(s);
        result = Items.size() - 1;
    }

	recalculateSize();
	return result;
}
Exemplo n.º 4
0
bool SessionManager::removeSession( std::string addr, SessionType type )
{
    lockSessions();

    SessionEntry* entry = findSessionByAddress( addr, type );
    if ( entry == NULL )
    {
        unlockSessions();
        gravUtil::logWarning( "SessionManager::removeSession: "
                              "session %s not found\n", addr.c_str() );
        return false;
    }

    if ( type == AVAILABLEVIDEOSESSION )
    {
        int i = indexOf( entry );
        // shift rotate position back if what we're removing is before or at it,
        // so we don't skip any
        if ( i <= rotatePos && i != -1 )
            rotatePos--;
    }

    objectManager->lockSources();
    objectManager->removeFromLists( entry, false );
    objectManager->unlockSources();
    delete entry; //destructor will remove object from its group

    recalculateSize();

    unlockSessions();
    return true;
}
Exemplo n.º 5
0
bool SessionManager::addSession( std::string address, SessionType type )
{
    lockSessions();

    bool ret = true;
    bool audio = ( type == AUDIOSESSION );
    SessionEntry* entry = new SessionEntry( address, audio );
    Group* sessions = sessionMap[ type ];
    entry->setPos( sessions->getX(), sessions->getY() );
    Texture t = GLUtil::getInstance()->getTexture( "circle" );
    entry->setTexture( t.ID, t.width, t.height );

    if ( type != AVAILABLEVIDEOSESSION )
    {
        ret = ret && initSession( entry );
    }

    /*
     * Note - used to delete entries on fail. Now will display an entry in a
     * failed state, so it can potentially be reenabled when it could work.
     * (But still returns false on failed init)
     */

    sessions->add( entry );
    objectManager->lockSources();
    objectManager->addToDrawList( entry );
    objectManager->unlockSources();
    entry->show( shown, !shown );

    recalculateSize();

    unlockSessions();
    return ret;
}
Exemplo n.º 6
0
void MidiTrack::writeToFile(ostream & output) {

	if (!mClosed) {
		closeTrack();
	}

	if (mSizeNeedsRecalculating) {
		recalculateSize();
	}

	output.write((char*)IDENTIFIER, 4);
	output.write(MidiUtil::intToBytes(mSize, 4), 4);

	MidiEvent * lastEvent = NULL;

	std::vector<MidiEvent*>::iterator it;
	for (it = mEvents.begin();
		it != mEvents.end();
		it++) {
		MidiEvent * _event = *it;
		if (VERBOSE) {
			cout << "Writing: " << _event->toString().c_str();
		}

		_event->writeToFile(output, _event->requiresStatusByte(lastEvent));

		lastEvent = _event;
	}
}
Exemplo n.º 7
0
void UString::trim() {
	if (_string.empty())
		// Nothing to do
		return;

	// Find the last space, from the end
	iterator itEnd = --end();
	for (; itEnd != begin(); --itEnd) {
		uint32 c = *itEnd;
		if ((c != '\0') && (c != ' ')) {
			++itEnd;
			break;
		}
	}

	if (itEnd == begin()) {
		uint32 c = *itEnd;
		if ((c != '\0') && (c != ' '))
			++itEnd;
	}

	// Find the first non-space
	iterator itStart = begin();
	for (; itStart != itEnd; ++itStart)
		if (*itStart != ' ')
			break;

	_string = std::string(itStart.base(), itEnd.base());
	recalculateSize();
}
Exemplo n.º 8
0
UString &UString::operator=(const std::string &str) {
	_string = str;

	recalculateSize();

	return *this;
}
Exemplo n.º 9
0
//! draws the element and its children
void CGUIMenu::draw()
{
	if (!IsVisible)
		return;

	IGUISkin* skin = Environment->getSkin();
	IGUIFont* font = skin->getFont(EGDF_MENU);
	
	if (font != LastFont)
	{
		if (LastFont)
			LastFont->drop();
		LastFont = font;
		if (LastFont)
			LastFont->grab();

		recalculateSize();
	}

	core::rect<s32> rect = AbsoluteRect;

	// draw frame

	skin->draw3DToolBar(this, rect, &AbsoluteClippingRect);

	// loop through all menu items

	rect = AbsoluteRect;

	for (s32 i=0; i<(s32)Items.size(); ++i)
	{
		if (!Items[i].IsSeparator)
		{
			rect = getRect(Items[i], AbsoluteRect);

			// draw highlighted
			if (i == HighLighted && Items[i].Enabled)
			{
				skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW),
					true, true, rect, &AbsoluteClippingRect);
			}
			// draw text

			EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT;

			if (i == HighLighted)
				c = EGDC_HIGH_LIGHT_TEXT;

			if (!Items[i].Enabled)
				c = EGDC_GRAY_TEXT;

			if (font)
				font->draw(Items[i].Text.c_str(), rect, 
					skin->getColor(c), true, true, &AbsoluteClippingRect);
		}
	}

	IGUIElement::draw();
}
DashLabel::DashLabel(){
    index = -1;
    canID = -2;
    isSelected = false;
    text = "Label";
    recalculateSize();
    setPos(0,0);
}
Exemplo n.º 11
0
//! Sets text of the menu item.
void CGUIContextMenu::setItemText(u32 idx, const wchar_t* text)
{
	if (idx >= Items.size())
		return;

	Items[idx].Text = text;
	recalculateSize();
}
void DashLabel::setFont(){
    bool ok;
    QFont selectFont = QFontDialog::getFont(&ok, font, this);
    if(ok){
        this->font = selectFont;
        recalculateSize();
        emit paintRequest();
    }
}
Exemplo n.º 13
0
//! Removes all menu items
void CGUIContextMenu::removeAllItems()
{
	for (u32 i=0; i<Items.size(); ++i)
		if (Items[i].SubMenu)
			Items[i].SubMenu->drop();

	Items.clear();
	recalculateSize();
}
Exemplo n.º 14
0
//! Reads attributes of the element
void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
{
	IGUIElement::deserializeAttributes(in,options);

	Pos = in->getAttributeAsPosition2d("Position");

	// link to this item's parent
	if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) )
		((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this);

	CloseHandling = (ECONTEXT_MENU_CLOSE)in->getAttributeAsInt("CloseHandling");

	removeAllItems();

	// read the item list
	const s32 count = in->getAttributeAsInt("ItemCount");

	for (s32 i=0; i<count; ++i)
	{
		core::stringc tmp;
		core::stringw txt;
		s32 commandid=-1;
		bool enabled=true;
		bool checked=false;
		bool autochecking=false;

		tmp = "IsSeparator"; tmp += i;
		if ( in->existsAttribute(tmp.c_str()) && in->getAttributeAsBool(tmp.c_str()) )
			addSeparator();
		else
		{
			tmp = "Text"; tmp += i;
			if ( in->existsAttribute(tmp.c_str()) )
				txt = in->getAttributeAsStringW(tmp.c_str());

			tmp = "CommandID"; tmp += i;
			if ( in->existsAttribute(tmp.c_str()) )
				commandid = in->getAttributeAsInt(tmp.c_str());

			tmp = "Enabled"; tmp += i;
			if ( in->existsAttribute(tmp.c_str()) )
				enabled = in->getAttributeAsBool(tmp.c_str());

			tmp = "Checked"; tmp += i;
			if ( in->existsAttribute(tmp.c_str()) )
				checked = in->getAttributeAsBool(tmp.c_str());

 			tmp = "AutoChecking"; tmp += i;
			if ( in->existsAttribute(tmp.c_str()) )
				autochecking = in->getAttributeAsBool(tmp.c_str());

 			addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked, autochecking);
		}
	}

	recalculateSize();
}
Exemplo n.º 15
0
void QgsLayoutItemPicture::setResizeMode( QgsLayoutItemPicture::ResizeMode mode )
{
  mResizeMode = mode;
  if ( mode == QgsLayoutItemPicture::ZoomResizeFrame || mode == QgsLayoutItemPicture::FrameToImageSize
       || ( mode == QgsLayoutItemPicture::Zoom && !qgsDoubleNear( mPictureRotation, 0.0 ) ) )
  {
    //call set scene rect to force item to resize to fit picture
    recalculateSize();
  }
  update();
}
DashLabel::DashLabel(int index, int canID, QJsonObject json){
    this->index = index;
    this->canID = canID;
    this->isSelected = false;

    this->x = json["x"].toInt();
    this->y = json["y"].toInt();
    this->text = json["text"].toString();
    this->font.fromString(json["font"].toString());
    recalculateSize();
}
Exemplo n.º 17
0
void TextLayout::createLayout (const AttributedString& text, float maxWidth, float maxHeight)
{
    lines.clear();
    width = maxWidth;
    height = maxHeight;
    justification = text.getJustification();

    if (! createNativeLayout (text))
        createStandardLayout (text);

    recalculateSize (text);
}
Exemplo n.º 18
0
//! constructor
CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent,
		 s32 id, core::rect<s32> rectangle)
		 : CGUIContextMenu(environment, parent, id, rectangle, false, true)
{
	#ifdef _DEBUG
	setDebugName("CGUIMenu");
	#endif

	Type = EGUIET_MENU;

	recalculateSize();
}
Exemplo n.º 19
0
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
Exemplo n.º 20
0
//! Removes a menu item
void CGUIContextMenu::removeItem(u32 idx)
{
	if (idx >= Items.size())
		return;

	if (Items[idx].SubMenu)
	{
		Items[idx].SubMenu->drop();
		Items[idx].SubMenu = 0;
	}

	Items.erase(idx);
	recalculateSize();
}
Exemplo n.º 21
0
void UString::trimLeft() {
	if (_string.empty())
		// Nothing to do
		return;

	// Find the first non-space
	iterator itStart = begin();
	for (; itStart != end(); ++itStart)
		if (*itStart != ' ')
			break;

	_string = std::string(itStart.base(), end().base());
	recalculateSize();
}
Exemplo n.º 22
0
	//! constructor
	CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent,
		SINT32 id, rect<SINT32> rectangle)
		: CGUIContextMenu(environment, parent, id, rectangle, false, true)
	{
#ifdef _DEBUG
		setDebugName("CGUIMenu");
#endif

		Type = EGUIET_MENU;

		setNotClipped(false);

		recalculateSize();
	}
Exemplo n.º 23
0
//! constructor
CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
								 IGUIElement* parent, s32 id, 
								 core::rect<s32> rectangle,
								 bool getFocus)
: IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1)
{
	#ifdef _DEBUG
	setDebugName("CGUIContextMenu");
	#endif

	Pos = rectangle.UpperLeftCorner;
	recalculateSize();

	if (getFocus)
		Environment->setFocus(this);
}
Exemplo n.º 24
0
void ImageEntry::updateEntry()
{
    qreal oldHeight = height();
    if (m_imagePath.isEmpty()) {
        m_textItem->setPlainText(i18n("Right click here to insert image"));
        m_textItem->setVisible(true);
        if (m_imageItem)
            m_imageItem->setVisible(false);
    }

    else {
        if (!m_imageItem)
            m_imageItem = new WorksheetImageItem(this);

        if (m_imagePath.toLower().endsWith(QLatin1String(".eps"))) {
            m_imageItem->setEps(QUrl::fromLocalFile(m_imagePath));
        } else {
            QImage img(m_imagePath);
            m_imageItem->setImage(img);
        }

        if (!m_imageItem->imageIsValid()) {
            const QString msg = i18n("Cannot load image %1").arg(m_imagePath);
            m_textItem->setPlainText(msg);
            m_textItem->setVisible(true);
            m_imageItem->setVisible(false);
        } else {
            QSizeF size;
            if (worksheet()->isPrinting() && ! m_useDisplaySizeForPrinting)
                size = imageSize(m_printSize);
            else
                size = imageSize(m_displaySize);
            // Hack: Eps images need to be scaled
            if (m_imagePath.toLower().endsWith(QLatin1String(".eps")))
                size /= worksheet()->epsRenderer()->scale();
            m_imageItem->setSize(size);
            qDebug() << size;
            m_textItem->setVisible(false);
            m_imageItem->setVisible(true);
        }
    }

    qDebug() << oldHeight << height();
    if (oldHeight != height())
        recalculateSize();
}
Exemplo n.º 25
0
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //data defined strings
  mDataDefinedNames.insert( QgsComposerObject::PictureSource, QStringLiteral( "dataDefinedSource" ) );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
Exemplo n.º 26
0
//! constructor
CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
				IGUIElement* parent, s32 id,
				core::rect<s32> rectangle, bool getFocus, bool allowFocus)
	: IGUIContextMenu(environment, parent, id, rectangle), EventParent(0), LastFont(0),
		CloseHandling(ECMC_REMOVE), HighLighted(-1), ChangeTime(0), AllowFocus(allowFocus)
{
	#ifdef _DEBUG
	setDebugName("CGUIContextMenu");
	#endif

	Pos = rectangle.UpperLeftCorner;
	recalculateSize();

	if (getFocus)
		Environment->setFocus(this);

	setNotClipped(true);
}
Exemplo n.º 27
0
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //data defined strings
  mDataDefinedNames.insert( QgsComposerObject::PictureSource, QString( "dataDefinedSource" ) );

  //insert PictureSource data defined property (only required due to deprecated API elements,
  //remove after 3.0
  setDataDefinedProperty( QgsComposerObject::PictureSource, false, true, QString(), QString() );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
Exemplo n.º 28
0
//! Adds a menu item.
s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu)
{
	SItem s;
	s.Enabled = enabled;
	s.Text = text;
	s.IsSeparator = (text == 0);
	s.SubMenu = 0;
	s.CommandId = id;

	if (hasSubMenu)
	{
		s.SubMenu = new CGUIContextMenu(Environment, this, -1, 
			core::rect<s32>(0,0,100,100), false);
		s.SubMenu->setVisible(false);
	}

	Items.push_back(s);

	recalculateSize();
	return Items.size() - 1;
}
Exemplo n.º 29
0
bool SessionManager::shiftSession( SessionEntry* entry )
{
    Group* to;
    Group* from = entry->getGroup();

    if ( from == videoSessions )
    {
        to = availableVideoSessions;
        disableSession( entry );
    }
    else if ( from = availableVideoSessions )
    {
        to = videoSessions;

        if ( !entry->isSessionEnabled() )
        {
            initSession( entry );
        }

        int i = indexOf( entry );
        // shift rotate position back if what we're removing is before or at it,
        // so we don't skip any
        if ( i <= rotatePos && i != -1 )
            rotatePos--;
    }
    else
    {
        const char* name = from != NULL ? from->getName().c_str() : "NULL";
        gravUtil::logWarning( "SessionManager::shiftSession: invalid source "
                              "group input (%s)\n", name );
        return false;
    }

    from->remove( entry );
    to->add( entry );

    recalculateSize();

    return true;
}
Exemplo n.º 30
0
EmotePopup::EmotePopup():
    mSelectedEmoteIndex(-1),
    mHoveredEmoteIndex(-1),
    mRowCount(1),
    mColumnCount(1)
{
    // Setup emote sprites
    for (int i = 0; i <= EmoteDB::getLast(); ++i)
    {
        mEmotes.push_back(EmoteDB::get(i)->sprite);
    }

    mSelectionImage = Theme::getImageFromTheme("selection.png");
    if (!mSelectionImage)
        logger->error("Unable to load selection.png");

    mSelectionImage->setAlpha(config.getFloatValue("guialpha"));

    addMouseListener(this);
    recalculateSize();
    setVisible(true);
}