コード例 #1
0
	void ChatNetPackageDispatcher::createUI( PeerNode* peerNode, CCControlBase* parentLayer )	{

		CCSize preferredSize(CCSizeMake(0,0));
		_ctrlChatText = ControlUtils::createValueBox(nullptr, preferredSize);
		_ctrlChatText->setText("\n");
		ControlUtils::addCtrlNode(_ctrlChatText, parentLayer);
	}
コード例 #2
0
ファイル: CairoPlugin.cpp プロジェクト: alsabadel/vle
void CairoPlugin::init()
{
    int height, width;

    preferredSize(width, height);

    m_img = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
    m_store = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
    m_ctx = Cairo::Context::create(m_img);

    Cairo::RefPtr < Cairo::Context > ctx = Cairo::Context::create(m_store);

    ctx->save();
    ctx->set_source_rgb(1.0, 1.0, 1.0);
    ctx->set_operator(Cairo::OPERATOR_SOURCE);
    ctx->paint();
    ctx->set_operator(Cairo::OPERATOR_OVER);
    ctx->restore();

    m_ctx->save();
    m_ctx->set_source_rgb(1.0, 1.0, 1.0);
    m_ctx->set_operator(Cairo::OPERATOR_SOURCE);
    m_ctx->paint();
    m_ctx->set_operator(Cairo::OPERATOR_OVER);
    m_ctx->restore();

    m_init = false;
    m_need = true;
}
コード例 #3
0
//  Called when the user wants to maximize the palette
void UBDesktopPalette::maximizeMe()
{
    QList<QAction*> actions;
    clearLayout();

    actions << mActionUniboard;
    actions << UBApplication::mainWindow->actionPen;
    actions << UBApplication::mainWindow->actionEraser;
    actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
    actions << UBApplication::mainWindow->actionSelector;
#endif
    actions << UBApplication::mainWindow->actionPointer;
    if (UBPlatformUtils::hasVirtualKeyboard())
        actions << UBApplication::mainWindow->actionVirtualKeyboard;

    actions << mActionCustomSelect;
    actions << mDisplaySelectAction;
    actions << mShowHideAction;

    //actions << UBApplication::mainWindow->actionDesktopTools;

    setActions(actions);

    QSize newSize = preferredSize();
    this->resize(newSize);

    // Notify that the maximization has been done
    emit maximized();
}
コード例 #4
0
void UBFloatingPalette::adjustSizeAndPosition(bool pUp, bool resetPosition)
{
    QSize newPreferredSize = preferredSize();

    foreach (UBFloatingPalette* palette, mAssociatedPalette)
    {
        QSize palettePreferredSize = palette->preferredSize();
        newPreferredSize.setWidth(newPreferredSize.expandedTo(palettePreferredSize).width());
    }
コード例 #5
0
	void ClientChatNetPackageSender::createClientUI( PeerNode* peerNode, CCControlBase* parentLayer )	{
		CCSize preferredSize(CCSizeMake(0,0));

		_ctrlName = ControlUtils::createEditBox("Name:", preferredSize);
		_ctrlPassword = ControlUtils::createEditBox("Password:"******"Message:", preferredSize);

		ControlUtils::addCtrlNode(_ctrlName, parentLayer);
		ControlUtils::addCtrlNode(_ctrlPassword, parentLayer);
		ControlUtils::addCtrlNode(_ctrlMessage, parentLayer);
	}
コード例 #6
0
	void CCControlBase::layoutChildren(ELayoutMode layoutMode, bool resize)	{
		// now check for all sub layers and call needsLayout to
		CCArray* children(getChildren());
		CCObject* child;

		const float verticalOffset(static_cast<float>(m_marginV));


		if(resize == true)	{

			const CCSize& currentContentSize(getContentSize());
			float contentHeight(verticalOffset);
			// determine the new content height
			CCARRAY_FOREACH(children, child)
			{
				CCControlBase* ctrlBase(dynamic_cast<CCControlBase*>(child));
				if(ctrlBase != nullptr)	{
					CCSize preferredSize(CCSizeMake(currentContentSize.width - (m_marginH * 2),0));
					CCSize ctrlPreferredSize(ctrlBase->getPreferredSize());
					ctrlPreferredSize.width = preferredSize.width;
					ctrlBase->setPreferredSize(ctrlPreferredSize);
					ctrlBase->needsLayout();

					contentHeight += ctrlBase->getContentSize().height;
					contentHeight += verticalOffset;
				}
				else	{
					CCScale9Sprite* sprite(dynamic_cast<CCScale9Sprite*>(child));
					if(sprite == _backGroundSprite)	{

					}
					else	{
						CCControlButton* btn(dynamic_cast<CCControlButton*>(child));
						if(btn != nullptr)	{
							contentHeight += (btn->getContentSize().height + verticalOffset * 2);
							contentHeight += verticalOffset * 2;
						}
						else	{
							CCNode* node(dynamic_cast<CCNode*>(child));
							if(node != nullptr)	{
								contentHeight += node->getContentSize().height;
								contentHeight += verticalOffset;
							}
						}
					}
				}
			}

			CCSize newContentSize(getContentSize());
			newContentSize.height = contentHeight;
			setPreferredSize(newContentSize);
			needsLayout();
			layoutChildren(ELayoutMode_topLeftDown);
		}
コード例 #7
0
ファイル: Button.cpp プロジェクト: HeadHunterEG/pioneer
Point Button::PreferredSize()
{
	// child's preferred size
	Point preferredSize(Single::PreferredSize());

	// grow to minimum size if necessary
	growToMinimum(preferredSize, GetContext()->GetSkin().ButtonMinInnerSize());

	// add borders
	return SizeAdd(preferredSize, Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2));
}
コード例 #8
0
ファイル: DragHelper.cpp プロジェクト: 91yuan/ilixi
void
DragHelper::startDrag(int x, int y)
{
    ILOG_TRACE_W(ILX_DRAGHELPER);
    Application::setDragging(true);
    setVisible(true);
    Size s = preferredSize();
    if (PlatformManager::instance().appOptions() & OptExclusive)
        PlatformManager::instance().setLayerRectangle("cursor", Rectangle(x - s.width() / 2, y - s.height() / 2, s.width(), s.height()));
    showWindow(Point(x - s.width() / 2, y - s.height() / 2));
    _window->dfbWindow()->GrabPointer(_window->dfbWindow());
}
コード例 #9
0
//  Called when the palette is near the border and must be minimized
void UBDesktopPalette::minimizeMe(eMinimizedLocation location)
{
    Q_UNUSED(location);
    QList<QAction*> actions;
    clearLayout();

    actions << mMaximizeAction;
    setActions(actions);

    QSize newSize = preferredSize();
    this->resize(newSize);
}
コード例 #10
0
void NowPlaying::layoutHorizontal()
{
    if (m_currentLayout != HorizontalLayout)
    {
        setMinimumSize(QSizeF());

        m_textPanel->hide();

        QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();

        Plasma::ToolTipManager::self()->registerWidget(this);

        kDebug() << "Minimum size before changing layout" << minimumSize();
        kDebug() << "Preferred size before changing layout" << preferredSize();
        setLayout(layout);
        kDebug() << "Minimum size after changing layout" << minimumSize();
        kDebug() << "Preferred size after changing layout" << preferredSize();

        m_currentLayout = HorizontalLayout;
    }
}
コード例 #11
0
void MImWordTracker::setPosition(const QRect &cursorRect)
{
    if (cursorRect.isNull())
        return;

    QPoint pos = cursorRect.bottomLeft();
    pos.setX(pos.x() + cursorRect.width()/2);

    const QSize pointerSize = style()->wordtrackerPointerSize();
    const int sceneWidth = MPlainWindow::instance()->sceneManager()->visibleSceneSize().width();
    pos.setX(pos.x() - style()->wordtrackerPointerLeftMargin() - pointerSize.width()/2);
    pos.setY(pos.y() + style()->wordtrackerPointerTopMargin());

    if (pos.x() < style()->wordtrackerLeftMargin()) {
        pos.setX(style()->wordtrackerLeftMargin());
    } else if (pos.x() > sceneWidth - mIdealWidth - style()->wordtrackerRightMargin()) {
        pos.setX(sceneWidth - mIdealWidth - style()->wordtrackerRightMargin());
    }
    // pointerXOffset is the related x offset for the cursor from the left side of word tracker.
    pointerXOffset = cursorRect.bottomLeft().x() + cursorRect.width()/2
                     - pointerSize.width()/2 - pos.x(); //- style()->wordtrackerLeftMargin();
    pointerXOffset = qBound<qreal>(style()->wordtrackerPointerLeftMargin(),
                                   pointerXOffset,
                                   mIdealWidth - style()->wordtrackerPointerRightMargin()- pointerSize.width());

    QRectF widgetRect, containerRect;
    QSizeF containerSize = preferredSize();
    containerSize.setHeight(containerSize.height() + pointerHeight());
    containerRect = QRectF(pos, containerSize);
    widgetRect = QRectF(QPointF(0, pointerHeight()), preferredSize());

    containerWidget->setGeometry(containerRect);
    setGeometry(widgetRect);

    if (isVisible()) {
        containerWidget->update();
    }
}
コード例 #12
0
ファイル: layout.cpp プロジェクト: arajar/crawler
void BoxLayout::performLayout(NVGcontext *ctx, Widget *widget) const {
    Vector2i ps = preferredSize(ctx, widget);
    Vector2i fs = widget->fixedSize();
    Vector2i containerSize(
        fs[0] ? fs[0] : ps[0],
        fs[1] ? fs[1] : ps[1]
    );

    int axis1 = (int) mOrientation, axis2 = ((int) mOrientation + 1)%2;
    int position = mMargin;

    if (dynamic_cast<Window *>(widget))
        position += widget->theme()->mWindowHeaderHeight - mMargin/2;

    bool first = true;
    for (auto c : widget->children()) {
        if (first)
            first = false;
        else
            position += mSpacing;

        Vector2i ps = c->preferredSize(ctx), fs = c->fixedSize();
        Vector2i cs(
            fs[0] ? fs[0] : ps[0],
            fs[1] ? fs[1] : ps[1]
        );
        Vector2i pos = Vector2i::Zero();
        pos[axis1] = position;

        switch (mAlignment) {
        case Alignment::Minimum:
            pos[axis2] = mMargin;
            break;
        case Alignment::Middle:
            pos[axis2] = (containerSize[axis2] - cs[axis2]) / 2;
            break;
        case Alignment::Maximum:
            pos[axis2] = containerSize[axis2] - cs[axis2] - mMargin;
            break;
        }

        c->setPosition(pos);
        c->setSize(cs);
        c->performLayout(ctx);
        position += cs[axis1];
    }
}
コード例 #13
0
ファイル: Button.cpp プロジェクト: AmesianX/pioneer
Point Button::PreferredSize()
{
	// child's preferred size
	Point preferredSize(Single::PreferredSize());

	// grow to minimum size if necessary
	growToMinimum(preferredSize, GetContext()->GetSkin().ButtonMinInnerSize());

	// add padding
	const Skin::BorderedRectElement &elem(GetContext()->GetSkin().ButtonNormal());
	preferredSize = SizeAdd(preferredSize, Point(elem.paddingX*2, elem.paddingY*2));

	// grow to border size if necessary
	preferredSize.x = std::max(preferredSize.x, int(elem.borderWidth*2));
	preferredSize.y = std::max(preferredSize.y, int(elem.borderHeight*2));

	return preferredSize;
}
コード例 #14
0
	void ClientChatNetPackageSender::createClientUI( PeerNode* peerNode, CCControlBase* parentLayer )	{
		CCSize preferredSize(CCSizeMake(0,0));

		_ctrlName = ControlUtils::createEditBox("Name:", preferredSize);
		_ctrlPassword = ControlUtils::createEditBox("Password:"******"Message:", preferredSize);

		ControlUtils::addCtrlNode(_ctrlName, parentLayer);
		ControlUtils::addCtrlNode(_ctrlPassword, parentLayer);
		ControlUtils::addCtrlNode(_ctrlMessage, parentLayer);

		CCControlButton* ctrlBtn;
		ctrlBtn = sl::ControlUtils::createButton("Register");
		ctrlBtn->setTag(SL_CTRLID_REGISTER);
		ctrlBtn->addTargetWithActionForControlEvents(
			this, 
			cccontrol_selector(ClientChatNetPackageSender::onUIAction), 
			CCControlEventTouchUpInside);

		ControlUtils::addCtrlNode(ctrlBtn, parentLayer);
	}
コード例 #15
0
/*!
    Constructs a widget which is a child of \a parent, with widget flags set to \a flags.
    Widget creates two buttons ('go' and 'stop'), text field to write url and browser view.
    Note that this is just an simple example so this creates child widgets directly to the layout.
    For more complicated widget layouting, see Orbit documentation and especially WidgetML section of it.
*/
MiniBrowserWidget::MiniBrowserWidget(QGraphicsItem* parent, Qt::WindowFlags flags)
    : HbWidget(parent, flags)
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
    setLayout(layout);
    
    QGraphicsLinearLayout *buttonLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    mGoButton = new HbPushButton("Go");
    connect(mGoButton, SIGNAL(pressed()), SLOT(pressGoButton()));
    buttonLayout->addItem(mGoButton);
    mStopButton = new HbPushButton("Stop");
    connect(mStopButton, SIGNAL(pressed()), SLOT(pressStopButton()));
    buttonLayout->addItem(mStopButton);
    mStopButton->setEnabled(false);
    mEditor = new HbLineEdit();
    buttonLayout->addItem(mEditor);
    
    layout->addItem(buttonLayout);

    mWeb = new QGraphicsWebView();
    layout->addItem(mWeb);
    
    connect(mWeb, SIGNAL(loadStarted()), SLOT(loadStarted()));
    connect(mWeb, SIGNAL(loadProgress(int)), SLOT(loadProgress(int)));
    connect(mWeb, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));

    // maximum size of the home screen widget is (48,39) units. Convert units to pixels and 
    // resize minibrowser as maximum size
    HbFrameDrawer *drawer = new HbFrameDrawer(
        QLatin1String("qtg_fr_hsshortcut_normal"), HbFrameDrawer::NinePieces);
    setBackgroundItem(new HbFrameItem(drawer));
    
    HbDeviceProfile profile;
    qreal factor = profile.unitValue();
    setPreferredSize(48*factor, 39*factor);
    resize(preferredSize());
    
    mUrl = QString("http://www.nokia.com");
}
コード例 #16
0
		CCARRAY_FOREACH(children, child)
		{
			CCControlBase* ctrlBase(dynamic_cast<CCControlBase*>(child));
			if(ctrlBase != nullptr)	{
				CCSize preferredSize(CCSizeMake(contentSize.width - (m_marginH * 2),0));
				CCSize ctrlPreferredSize(ctrlBase->getPreferredSize());
				ctrlPreferredSize.width = preferredSize.width;
				ctrlBase->setPreferredSize(ctrlPreferredSize);
				ctrlBase->needsLayout();

				ctrlPosition.y -= ctrlBase->getContentSize().height;
				ctrlBase->setPosition(ctrlPosition);
				ctrlPosition.y -= verticalOffset;
			}
			else	{
				CCScale9Sprite* sprite(dynamic_cast<CCScale9Sprite*>(child));
				if(sprite == _backGroundSprite)	{

				}
				else	{
					CCControlButton* btn(dynamic_cast<CCControlButton*>(child));
					if(btn != nullptr)	{
						ctrlPosition.y -= (btn->getContentSize().height + verticalOffset * 2);
						btn->setPosition(ctrlPosition);
						ctrlPosition.y -= verticalOffset * 2;
					}
					else	{
						CCNode* node(dynamic_cast<CCNode*>(child));
						if(node != nullptr)	{
							ctrlPosition.y -= node->getContentSize().height;
							node->setPosition(ctrlPosition);
							ctrlPosition.y -= verticalOffset;
						}
					}
				}
			}
		}
コード例 #17
0
ファイル: mgSimpleField.cpp プロジェクト: Kelimion/SeaOfMemes
//--------------------------------------------------------------
// return minimum size of control
void mgSimpleField::minimumSize(
  mgDimension& size) 
{
  preferredSize(size);
}
コード例 #18
0
//--------------------------------------------------------------
// get minimum size
void mgSimpleDesktop::minimumSize(
  mgDimension& size) 
{
  preferredSize(size);
}
コード例 #19
0
ファイル: mgUglyList.cpp プロジェクト: duaneking/SeaOfMemes
//--------------------------------------------------------------
// get minimum size
void mgUglyList::minimumSize(
  mgDimension& size) 
{
  preferredSize(size);
}
	void PeerNodeControlLayer::addPeerControls( CCLayer* layer, PeerNode* peerNode )
	{
		const Peer& peer(*peerNode->getPeer());

		CCDictionary* peerSetting(peer.getPeerConfiguration());
		if(peerSetting == nullptr)	{
			SL_PROCESS_APP()->log(ELogType_Error,"failed to retrieve peer configuration");
			return;
		}

		CCSize preferredSize(CCSizeMake(layer->getContentSize().width - 20,0));
		CCControlBase* ctrlContainer;
		CCArray* subCtrls;



		subCtrls = CCArray::create();
		subCtrls->addObject(peerNode->createPeerInfoControl());

		{
			CCSize btnContainerSize(CCSizeMake(0,0));
			CCArray* columnCtrls = CCArray::create();

			CCControlButton* ctrlBtn;
			ctrlBtn = ControlUtils::createButton("Options");
			ctrlBtn->setTag(SL_CTRLID_PEER_OPTIONS);
			ctrlBtn->addTargetWithActionForControlEvents(
				peerNode, 
				cccontrol_selector(PeerNode::onUIAction), 
				CCControlEventTouchUpInside);
			columnCtrls->addObject(ctrlBtn);

			if(peer.isClient())	{
				ctrlBtn = ControlUtils::createButton("Login");
			}
			else	{
				ctrlBtn = ControlUtils::createButton("Start");
			}
			ctrlBtn->setTag(SL_CTRLID_PEER_CONNECT);

			// add two targets for this button
			// one general action
			ctrlBtn->addTargetWithActionForControlEvents(
				peerNode, 
				cccontrol_selector(PeerNode::onUIAction), 
				CCControlEventTouchUpInside);

			// the specific connect action
			ctrlBtn->addTargetWithActionForControlEvents(
				peerNode, 
				cccontrol_selector(PeerNode::onConnectAction), 
				CCControlEventTouchUpInside);
			columnCtrls->addObject(ctrlBtn);

			CCControlColumn* btnContainer = ControlUtils::createControlColumn(columnCtrls,btnContainerSize);
			subCtrls->addObject(btnContainer);
		}


		ctrlContainer = ControlUtils::createControlRow(subCtrls, preferredSize);
		ctrlContainer->getCtrlFlags().removeFlag(ECtrlFlag_UseScissorTest);

		ControlUtils::addCtrlNode(ctrlContainer, layer);


		if(peer.isServer())	{
			ctrlContainer = ControlUtils::createEditBox("Port:", preferredSize);
			ControlUtils::addCtrlNode(ctrlContainer, layer);

			ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_SERVER_PORT);
			ctrlContainer->deserialize(peerSetting);

			peerNode->setCtrlServerPort(ctrlContainer);
		}
		else if(peer.isClient())	{
			ctrlContainer = ControlUtils::createEditBox("Svr-IP:", preferredSize);
			ControlUtils::addCtrlNode(ctrlContainer, layer);
			ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_SERVERIP);
			ctrlContainer->deserialize(peerSetting);

			ctrlContainer = ControlUtils::createEditBox("Svr-Port:", preferredSize);
			ControlUtils::addCtrlNode(ctrlContainer, layer);
			ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_SERVER_PORT);
			ctrlContainer->deserialize(peerSetting);

			peerNode->setCtrlServerPort(ctrlContainer);

			ctrlContainer = ControlUtils::createEditBox("Port:", preferredSize);
			ControlUtils::addCtrlNode(ctrlContainer, layer);
			ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_CLIENT_PORT);
			ctrlContainer->deserialize(peerSetting);

			peerNode->setCtrlClientPort(ctrlContainer);
		}
		else if(peer.isPeerToPeer())	{
			ctrlContainer = ControlUtils::createEditBox("Port:", preferredSize);
			ControlUtils::addCtrlNode(ctrlContainer, layer);
			ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_P2P_PORT);
			ctrlContainer->deserialize(peerSetting);

			CCControlCheckBox* ctrlCheckBox;

			ctrlCheckBox = ControlUtils::createCheckBox("Advertise System", preferredSize);
			ctrlCheckBox->setValueKey(SL_SERIALIZEKEY_PEER_ADVERTISE_SYSTEM);
			ctrlCheckBox->deserialize(peerSetting);
			ControlUtils::addCtrlNode(ctrlCheckBox, layer);


			peerNode->setCtrlPeerToPeerPort(ctrlContainer);
		}

		// common controls for client and server

		ctrlContainer = ControlUtils::createValueBox("Connections:", preferredSize);

		ControlUtils::addCtrlNode(ctrlContainer, layer);

		ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_CONNECTIONS);
		ctrlContainer->deserialize(peerSetting);

		peerNode->setCtrlConnections(ctrlContainer);

		ctrlContainer = ControlUtils::createValueBox("Local-IP:", preferredSize);

		ControlUtils::addCtrlNode(ctrlContainer, layer);

		ctrlContainer->setValueKey(SL_SERIALIZEKEY_PEER_LOCALIP);
		ctrlContainer->deserialize(peerSetting);

		peerNode->setCtrlLocalIP(ctrlContainer);
	}
コード例 #21
0
//--------------------------------------------------------------
// return minimum size
void mgSimpleButton::minimumSize(
  mgDimension& size)
{
  preferredSize(size);
}
コード例 #22
0
    }

    return palettePreferredSize;
}

void UBFloatingPalette::adjustSizeAndPosition(bool pUp, bool resetPosition)
{
    QSize newPreferredSize = preferredSize();

    foreach (UBFloatingPalette* palette, mAssociatedPalette)
    {
        QSize palettePreferredSize = palette->preferredSize();
        newPreferredSize.setWidth(newPreferredSize.expandedTo(palettePreferredSize).width());
    }
    QSize previousSize = size();
    int biggerHeight = preferredSize().height() - previousSize.height();
    if ((pUp && (biggerHeight > 0))
        || (!pUp && (biggerHeight < 0)))
    {
        move(pos().x(), pos().y() - biggerHeight);
    }

    if (newPreferredSize != size())
    {
        resize(newPreferredSize);
        moveInsideParent(pos());
        foreach(UBFloatingPalette* palette, mAssociatedPalette)
        {
            palette->move(pos().x(), palette->pos().y());
            palette->resize(newPreferredSize.width(), palette->size().height());
        }
コード例 #23
0
	int Widget::matchingHeight( int width ) const
	{
		return preferredSize().h;		// Default is to stick with best height no matter what width.
	}
コード例 #24
0
ファイル: mgUglyButton.cpp プロジェクト: duaneking/SeaOfMemes
//--------------------------------------------------------------
// return minimum size
void mgUglyButton::minimumSize(
  mgDimension& size)
{
  preferredSize(size);
}
コード例 #25
0
	void ServerChatNetPackageSender::createServerUI( PeerNode* peerNode, CCControlBase* parentLayer )	{
		CCSize preferredSize(CCSizeMake(0,0));
	}
コード例 #26
0
	int Widget::matchingWidth( int height ) const
	{
		return preferredSize().w;		// Default is to stick with best width no matter what height.
	}
コード例 #27
0
//--------------------------------------------------------------
// get minimum size of control
void mgUglyScrollbar::minimumSize(
  mgDimension& size) 
{
  preferredSize(size);
}