예제 #1
0
Page::Page(string& html)
{
	cout << "bulding page... string size: " << html.length() << endl;
	if(html.empty())
		cout << "ERROR: unable to build Page" << endl;
	makeText(html);
}
예제 #2
0
static inline Layer* makeItem(string sprite, string text, char code, bool numbered=false)
{
    Layer* l = Layer::create();
    Layer* s = Layer::create();
    auto sp = MAKESPRITE(sprite);
    l->addChild(s);
    s->addChild(sp);
    s->setPosition(Point(-64, -64));
    auto t = makeText(text);
    s->setTag(1);

    t->setTag(2);
    l->addChild(t);

    auto spriteSize = sp->getContentSize();
    auto spriteMidPoint = Point(
                              spriteSize.width * 0.5f,
                              spriteSize.height * 0.5f);
    sp->setPosition(spriteMidPoint);
    sp->setTag(0);

    if (numbered)
    {
        auto num = Label::createWithBMFont(MATH_FNT, "--");
        sp->addChild(num);
        num->setHorizontalAlignment(TextHAlignment::CENTER);
        num->setVerticalAlignment(TextVAlignment::BOTTOM);
        num->setPosition(Point(32, 34));
    }
    return l;
}
예제 #3
0
CommandAddObject::CommandAddObject( dp::sg::core::ObjectSharedPtr const& parent, dp::sg::core::ObjectSharedPtr const& child, bool add )
  : ViewerCommand( ViewerCommand::UPDATE_SCENE_TREE )
  , m_add(add)
  , m_parent(parent)
  , m_child(child)
{
  setText( makeText( m_add, parent, child ) );
}
예제 #4
0
CommandAddItem::CommandAddItem( SceneTreeItem * parent, SceneTreeItem * child, bool add )
  : ViewerCommand( ViewerCommand::UPDATE_SCENE_TREE )
  , m_add(add)
  , m_parent(parent)
  , m_child(child)
  , m_childTaken(add)
{
  setText( makeText( m_add, m_parent->getObject(), m_child->getObject() ) );
}
예제 #5
0
bool HelpScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    touched = false;
    Size visibleSize = Director::getInstance()->getVisibleSize();

    //setKeyboardEnabled(true);
    auto keyboard = EventListenerKeyboard::create();
    keyboard->onKeyReleased = CC_CALLBACK_2(HelpScene::onKeyReleased, this);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(keyboard, this);

    //setTouchEnabled(true);
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = CC_CALLBACK_2(HelpScene::onTouchBegan, this);
    listener->onTouchMoved = CC_CALLBACK_2(HelpScene::onTouchMoved, this);
    listener->onTouchEnded = CC_CALLBACK_2(HelpScene::onTouchEnded, this);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

    addChild(BackgroundWidget::create("bg", Color3B(20, 20, 80)));

    addChild(Vignette::create());

    auto layer = Layer::create();
    layer->setTag(1);
    addChild(layer);

    auto bg = LayerColor::create(C4Fto4B(0.12f, 0.02f, 0.15f, 1.0f), visibleSize.width, visibleSize.height);
    bg->setPositionY(PY(0.82f));
    addChild(bg);

    auto hooker = TopAnchor::create();
    addChild(hooker, 1);
    auto pMenu = Menu::create();
    pMenu->setPosition(Point::ZERO);
    //hooker->addChild(bg);
    hooker->addChild(pMenu);

    auto txt1 = Label::createWithTTF(LS("HowToPlay"), NORMAL_TTF, 48.0f);
    txt1->setPosition(VCP(0.22f, 0.935f));
    txt1->setAnchorPoint(Point(0, 0.5f));
    txt1->setHorizontalAlignment(TextHAlignment::LEFT);
    txt1->setColor(Color3B::WHITE);

    hooker->addChild(txt1);
    //addChild(txt1, 5);

    auto btnBack = MAKEBUTTON("btnBackBlackUp", "btnBackBlackDn", HelpScene::btnBackPressed);
    pMenu->addChild(btnBack, 2);
    btnBack->setPosition(VCP(0.03f, 0.935f));
    btnBack->setAnchorPoint(Point(0, 0.5f));

    auto playerLayer = makeItem("manRt1", LS("HelpPlayer"), '@');
    playerLayer->setPosition(CP(0.2f, 0.80f));
    layer->addChild(playerLayer);

    auto robotLayer = makeItem("robot", LS("HelpRobot"), 'R');
    robotLayer->setPosition(CP(0.2f, 0.50f));
    robotLayer->SPRITEREF->runAction(
        RepeatForever::create(Sequence::createWithTwoActions(
                                  ScaleTo::create(1.0f, 1.0f), ScaleTo::create(1.0f, 0.9f)
                              )));
    layer->addChild(robotLayer);

    auto holeLayer = makeItem("hazard", LS("HelpBlackhole"), '!');
    holeLayer->setPosition(CP(0.2f, 0.10f));
    holeLayer->SPRITEREF->runAction(RepeatForever::create(RotateBy::create(2.0f, 365.0f)));
    holeLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        TintTo::create(0.5f, 210, 255, 255), TintTo::create(0.5f, 255, 0, 0)
                                    )));
    layer->addChild(holeLayer);

    auto starLayer = makeItem("dronesGoal", LS("HelpStar"), 'X');
    starLayer->setPosition(CP(0.2f, -0.10f));
    starLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        TintTo::create(1.0f, 255, 255, 255), TintTo::create(1.0f, 255, 255, 0)
                                    )));
    starLayer->SPRITEREF->runAction(RepeatForever::create(Sequence::createWithTwoActions(
                                        DelayTime::create(10.0f), RotateBy::create(1.0, -360)
                                    )));
    layer->addChild(starLayer);

    auto gemLayer = makeItem("gem", LS("HelpGem"), 'g');
    gemLayer->setPosition(CP(0.2f, -0.30f));
    layer->addChild(gemLayer);

    auto creditsY = -0.20f;

    auto creditsLayer3 = makeText(LS("HelpConclusion"), 38.0f);
    creditsLayer3->setPosition(CP(0.5f, creditsY-0.3f));
    creditsLayer3->setHorizontalAlignment(TextHAlignment::CENTER);
    creditsLayer3->setAnchorPoint(Point(0.5f, 1.0f));
    layer->addChild(creditsLayer3);

    auto facebook = MAKESPRITE("facebook");
    facebook->setPosition(CP(0.5f, creditsY - 0.6f));
    layer->addChild(facebook);
    return true;
}
예제 #6
0
SMESH_Exception::SMESH_Exception( const char *text, const char *fileName, const unsigned int lineNumber ) : /*exception(),*/ _text( makeText( text , fileName , lineNumber ) )
{
}
예제 #7
0
//------------------------------------------------------------------------------
// redisplay() -- redisplay the value
//------------------------------------------------------------------------------
void NumericReadout::redisplay()
{
   // Check if we are displaying blank for zero
   if ((num == 0) && blankZero) {
      size_t i;
      for (i = 0; i < width(); i++) {
         cbuf[i] = ' ';
      }
      cbuf[width()] = '\0';
      setText(cbuf);
      return;
   }

   // Check if we have an undefined value and should place dashes in the display
   if (num == base::UNDEFINED_VALUE) {
      size_t i;
      for (i = 0; i < width(); i++) {
         cbuf[i] = undefinedChar;
      }
      cbuf[width()] = '\0';
      setText(cbuf);
      return;
   }

   // Check if we have an undefined value and should place dashes in the display
   if (maxNum != base::UNDEFINED_VALUE && num > maxNum) {
      size_t i;
      for (i = 0; i < width(); i++) {
         cbuf[i] = overflowChar;
      }
      cbuf[width()] = '\0';
      setText(cbuf);
      return;
   }

   // Create the readout text string
   makeText();

   size_t len = std::strlen(cbuf);

   // When we have a replacement char for the sign character
   if (plusChar != '\0' || minusChar != '\0' || postSign) {

      // Find the sign character (if any)
      size_t i = 0;
      while (i < len) {
         if (cbuf[i] == '+' || cbuf[i] == '-') break;
         i++;
      }

      // When we have a sign character
      if (i < len) {
         if (cbuf[i] == '+' && plusChar  != '\0')  cbuf[i] = plusChar;
         if (cbuf[i] == '-' && minusChar != '\0')  cbuf[i] = minusChar;
         if (postSign) {
            // move sign character to the end of the string
            char cc = cbuf[i];
            while (i < (len-1)) {
               cbuf[i] = cbuf[i+1];
               i++;
            }
            cbuf[i] = cc;
         }
      }
   }

   // When we have a replacement char for the decimal point
   if (dpChar != '\0') {

      // Find the decimal point (if any)
      size_t i = 0;
      while (i < len) {
         if (cbuf[i] == '.') break;
         i++;
      }

      // when we have a decimal point
      if (i < len) cbuf[i] = dpChar;
   }

   // Have Field display this text
   setText(cbuf);
}
예제 #8
0
/*!
  Factory function for QwtText objects. Creates a text according
  to QwtText::defaultFormat()

  \param text Contents of the text
  \param align Or'd values of Qt::AlignmentFlags for drawing the text
  \param font Font of the text
  \param color Color of the text
  \param pen Pen to draw the enclosing rectangle
  \param brush Brush to draw the enclosing rectangle 
  \return Pointer to a new QwtPlainText or QwtRichText object
  \sa QwtText::defaultFormat, QwtText::setDefaultFormat
*/
QwtText *QwtText::makeText(const QString &text, 
    int align, const QFont &font, const QColor &color,
    const QPen &pen, const QBrush &brush)
{
    return makeText(text, d_defaultFormat, align, font, color, pen, brush);
}