Example #1
0
void TestApp::init() {
    glClearColor(0.18f, 0.18f, 0.22f, 1.0f);

    m_camera.setPosition({0.0, -0.5, 14.0});

    m_shader = uptr<OGLW::Shader>(new OGLW::Shader("default.frag", "default.vert"));
    m_meshes = OGLW::loadOBJ("suzanne.obj");
    m_quad = OGLW::quad(1.f);
    m_backgroundShader = uptr<OGLW::Shader>(new OGLW::Shader("background.frag", "background.vert"));

    for (int i = 0; i < N_SEM; ++i) {
        std::string file = "sem-" + std::to_string(i) + ".jpg";
        m_textures[file] = uptr<OGLW::Texture>(new OGLW::Texture(file));
    }

    m_texture = m_textures.begin();
    m_textId = displayText(30.f, {10.f, 30.f}, m_texture->first);
    displayText(20.f, {10.f, m_height - 30.f}, "'N' for next SEM");
}
Example #2
0
void TestApp::update(float _dt) {
    static float time = 0.f;
    time += _dt;

    m_xrot += m_cursorX;
    m_yrot += m_cursorY;

    displayText(15.f, {m_width - 80.f, 20.f}, std::to_string(_dt).c_str() + std::string("ms"), true);

    if(glfwGetKey(m_window, 'N') && time > 0.5f) {
        m_texture++;
        if (m_texture == m_textures.end()) {
            m_texture = m_textures.begin();
        }
        clearText(m_textId);
        m_textId = displayText(30.f, {10.f, 30.f}, m_texture->first);
        time = 0.f;
    }
}
Example #3
0
void drawCheckBox(GLshort x, GLshort y, const char* text)
{
    glColor3f(0,0,0);
    glBegin(GL_LINE_LOOP);
        glVertex2s(x, y);
        glVertex2s(x+20, y);
        glVertex2s(x+20, y+20);
        glVertex2s(x, y+20);
    glEnd();
    displayText(text, x+25, y+5, 'm');
}
bool PlaylistDelegateBase::helpEvent(QHelpEvent* event, QAbstractItemView* view,
                                     const QStyleOptionViewItem& option,
                                     const QModelIndex& index) {
  // This function is copied from QAbstractItemDelegate, and changed to show
  // displayText() in the tooltip, rather than the index's naked
  // Qt::ToolTipRole text.

  Q_UNUSED(option);

  if (!event || !view) return false;

  QHelpEvent* he = static_cast<QHelpEvent*>(event);
  QString text = displayText(index.data(), QLocale::system());

  // Special case: we want newlines in the comment tooltip
  if (index.column() == Playlist::Column_Comment) {
    text = Qt::escape(index.data(Qt::ToolTipRole).toString());
    text.replace("\\r\\n", "<br />");
    text.replace("\\n", "<br />");
    text.replace("\r\n", "<br />");
    text.replace("\n", "<br />");
  }

  if (text.isEmpty() || !he) return false;

  switch (event->type()) {
    case QEvent::ToolTip: {
      QRect displayed_text;
      QSize real_text;
      bool is_elided = false;

      real_text = sizeHint(option, index);
      displayed_text = view->visualRect(index);
      is_elided = displayed_text.width() < real_text.width();
      if (is_elided) {
        QToolTip::showText(he->globalPos(), text, view);
      } else {  // in case that another text was previously displayed
        QToolTip::hideText();
      }
      return true;
    }

    case QEvent::QueryWhatsThis:
      return true;

    case QEvent::WhatsThis:
      QWhatsThis::showText(he->globalPos(), text, view);
      return true;

    default:
      break;
  }
  return false;
}
Example #5
0
void QgsComposerLabel::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
{
  Q_UNUSED( itemStyle );
  Q_UNUSED( pWidget );
  if ( !painter )
  {
    return;
  }
  if ( !shouldDrawItem() )
  {
    return;
  }

  drawBackground( painter );
  painter->save();

  //antialiasing on
  painter->setRenderHint( QPainter::Antialiasing, true );

  double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;
  double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth;
  double yPenAdjust = mMarginY < 0 ? -penWidth : penWidth;
  QRectF painterRect( xPenAdjust + mMarginX, yPenAdjust + mMarginY, rect().width() - 2 * xPenAdjust - 2 * mMarginX, rect().height() - 2 * yPenAdjust - 2 * mMarginY );

  if ( mHtmlState )
  {
    if ( mFirstRender )
    {
      contentChanged();
      mFirstRender = false;
    }
    painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 );
    mWebPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) );
    mWebPage->settings()->setUserStyleSheetUrl( createStylesheetUrl() );
    mWebPage->mainFrame()->render( painter );
  }
  else
  {
    const QString textToDraw = displayText();
    painter->setFont( mFont );
    //debug
    //painter->setPen( QColor( Qt::red ) );
    //painter->drawRect( painterRect );
    QgsComposerUtils::drawText( painter, painterRect, textToDraw, mFont, mFontColor, mHAlignment, mVAlignment, Qt::TextWordWrap );
  }

  painter->restore();

  drawFrame( painter );
  if ( isSelected() )
  {
    drawSelectionBoxes( painter );
  }
}
// Will be called when WiFi station was connected to AP
void connectOk()
{
	Serial.println("I'm CONNECTED");
	displayText("I'm CONNECTED to AP");

	// Run MQTT client
	startMqttClient();

	// Start publishing loop
	procTimer.initializeMs(60*1000, publishMessage).start();
}
Example #7
0
void display(void)
{
	char buffer[256];
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* keep in mind that `D` and `E` are simply pointers to the
	corresponding control points of `spline`. */
	for (i = 0; i < 3; i++) {
		D[i] = A[i] + t*v[i];
		E[i] = C[i] + t*w[i];
	}
	ts_bspline_set_control_points(&spline, ctrlp, NULL);

	/* draw spline */
	glColor3f(1.0, 1.0, 1.0);
	glLineWidth(3);
	gluBeginCurve(theNurb);
		gluNurbsCurve(
			theNurb, 
			(GLint)ts_bspline_num_knots(&spline),
			knots,
			(GLint)ts_bspline_dimension(&spline),
			ctrlp,
			(GLint)ts_bspline_order(&spline),
			GL_MAP1_VERTEX_3
		);
	gluEndCurve(theNurb);

	/* draw control points */
	glColor3f(1.0, 0.0, 0.0);
	glPointSize(5.0);
	glBegin(GL_POINTS);
	  for (i = 0; i < ts_bspline_num_control_points(&spline); i++)
		 glVertex3fv(&ctrlp[i * ts_bspline_dimension(&spline)]);
	glEnd();

	/* draw B */
	glColor3f(0.0, 0.0, 1.0);
	glBegin(GL_POINTS);
		glVertex3fv(B);
	glEnd();

	/* display t */
	sprintf(buffer, "t: %.2f", t);
	displayText(-.2f, 1.2f, 0.0, 1.0, 0.0, buffer);

	glutSwapBuffers();
	glutPostRedisplay();

	t += 0.001f;
	if (t > 1.f) {
		t = 0.f;
	}
}
Example #8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    isBot=false;
    started = false;

    ui->setupUi(this);

    displayText("Start");

    // Load sounds
    bullet = new QSound("/sounds/bullet.wav");

    networkThread = new QThread();
    networkManager = new NetworkManager();

    networkManager->moveToThread(networkThread);
    networkThread->start();
    //connect(networkThread, SIGNAL(started()), networkManager, SLOT(network_init()));

    connect(ui->connectButton,SIGNAL(clicked()),this,SLOT(connect_clicked()));
    connect(networkManager, SIGNAL(writeText(QString)), this, SLOT(displayText(QString)));
    connect(ui->disconnectButton, SIGNAL(released()), this, SLOT(stopPlay()));
    connect(this, SIGNAL(sendKeyEvent(QKeyEvent*,int)), networkManager, SLOT(process_key(QKeyEvent*,int)));
    connect(networkManager, SIGNAL(newPlayerScore(int)), ui->playerScore, SLOT(setNum(int)));
    connect(networkManager, SIGNAL(newHealthPoints(int)), ui->healthPoints, SLOT(setValue(int)));
    connect(networkManager, SIGNAL(newPlayerId(int)), ui->playerIdLabel, SLOT(setNum(int)));
    connect(networkManager, SIGNAL(newTeamId(int)),ui->equipe, SLOT(setNum(int)));
    connect(networkManager, SIGNAL(newIdInTeam(int)), this, SLOT(setSprite(int)));
    connect(ui->checkBoxBot, SIGNAL(stateChanged(int)), this, SLOT(setBot(int)));
    connect(ui->nameEdit, SIGNAL(textChanged(QString)), networkManager, SLOT(setLogin(QString)));
    connect(ui->disconnectButton, SIGNAL(released()), networkManager, SLOT(disconnectClient()));
    connect(this, SIGNAL(setIP(QString,int)), networkManager, SLOT(setIP(QString,int)));
    connect(this, SIGNAL(setRequestedTeam(int)), networkManager, SLOT(setRequestedTeam(int)));
    connect(networkManager, SIGNAL(disconnected()), this, SLOT(stopPlay()));
    connect(this, SIGNAL(startNetworkManager()), networkManager, SLOT(network_init()));

    readSettings();
}
Example #9
0
void InputBox::contextMenuEvent(QContextMenuEvent *event) {
	QMenu *const menu = new QMenu(this);
	
	menu->addAction(tr("&Copy"), this, SLOT(copy()))->setEnabled(hasSelectedText());
	menu->addSeparator();
	menu->addAction(tr("&Select All"), this, SLOT(selectAll()))->setEnabled(!displayText().isEmpty());
	menu->addSeparator();
	menu->addAction(tr("C&lear"), this, SLOT(clearData()))->setEnabled(getData().value != NULL_VALUE);
	menu->exec(event->globalPos());
	
	delete menu;
}
Example #10
0
void Display::updateDisplay(Entities &entities){
    al_clear_to_color(al_map_rgba(0, 0, 0, 255));

    std::list<Entity*> entitiesTemp = entities.getEntities();

    for (std::list<Entity*>::iterator it = entitiesTemp.begin(); it != entitiesTemp.end(); it++){
        (*it)->draw();
    }
    displayText(score, Coordinates(80, 10), font2);

    al_flip_display();
}
 void keyPressed(int k){
     int miniIdx=-1;
     float miniTime=1000000000.0;
     for(int i = 0; i < vecKeyTexts.size(); i++){
         if(vecKeyTexts[i].limb == k){
             if(miniTime > vecKeyTexts[i].timeCreated){
                 miniIdx = i;
                 miniTime = vecKeyTexts[i].timeCreated;
             }
         }
     }
     if(miniIdx != -1){
         displayText(vecDiscoReactionsGood[rand()%vecDiscoReactionsGood.size()], 0);
         vecKeyTexts.erase(vecKeyTexts.begin()+miniIdx);
         score++;
     }
     else{
         displayText(vecDiscoReactionsBad[rand()%vecDiscoReactionsBad.size()], 0);
         score--;
     }
 }
Example #12
0
void CTFTSerial::setIdleInt()
{
	// Clear the screen
	clearScreen();

	setFontSize(FONT_LARGE);

	// Draw MMDVM logo
	displayBitmap(0U, 0U, "MMDVM_sm.bmp");

	char text[30];
	::sprintf(text, "%-6s / %u", m_callsign.c_str(), m_dmrid);

	gotoPosPixel(18U, 55U);
	displayText(text);

	gotoPosPixel(45U, 90U);
	displayText("IDLE");

	m_mode = MODE_IDLE;
}
Example #13
0
 FillCellHelper( QAbstractItemModel* tableModel, const QModelIndex& index, const QSize& _span, const QSize& iconSz )
 {
     iconSize = iconSz;
     cellDecoration = tableModel->data( index, Qt::DecorationRole );
     cellFont = tableModel->data( index, Qt::FontRole );
     cellText = displayText( tableModel->data( index, Qt::DisplayRole ) );
     foreground = qvariant_cast<QColor>( tableModel->data( index, Qt::ForegroundRole ) );
     background = qvariant_cast<QColor>( tableModel->data( index, Qt::BackgroundRole ) );
     alignment = Qt::Alignment( tableModel->data( index, Qt::TextAlignmentRole ).toInt() );
     decorationAlignment = tableModel->data( index, KDReports::AutoTableElement::DecorationAlignmentRole );
     nonBreakableLines = tableModel->data( index, KDReports::AutoTableElement::NonBreakableLinesRole ).toBool();
     span = _span;
 }
Example #14
0
void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
	assert(source != NULL);
	assert(dest != NULL);
	assert(type != NULL);
	assert(origin != NULL);

	if (m_mode != MODE_YSF) {
		// Clear the screen
		clearScreen();

		setFontSize(FONT_MEDIUM);

		// Draw the System Fusion insignia
		displayBitmap(0U, 0U, "YSF_sm.bmp");
	}

	char text[30U];
	::sprintf(text, "%s %.10s", type, source);

	gotoPosPixel(5U, 70U);
	displayText(text);

	::sprintf(text, "  %.10s", dest);

	gotoPosPixel(5U, 90U);
	displayText(text);

	if (::strcmp(origin, "          ") != 0) {
		::sprintf(text, "at %.10s", origin);
		gotoPosPixel(5U, 110U);
		displayText(text);
	} else {
		gotoPosPixel(5U, 110U);
		displayText("              ");
	}

	m_mode = MODE_YSF;
}
Example #15
0
void CTFTSerial::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{
	assert(my1 != NULL);
	assert(my2 != NULL);
	assert(your != NULL);
	assert(type != NULL);
	assert(reflector != NULL);

	if (m_mode != MODE_DSTAR) {
		// Clear the screen
		clearScreen();

		setFontSize(FONT_MEDIUM);

		// Draw D-Star insignia
		displayBitmap(0U, 0U, "DStar_sm.bmp");
	}

	char text[30U];

	::sprintf(text, "%s %.8s/%4.4s", type, my1, my2);
	gotoPosPixel(5U, 70U);
	displayText(text);

	::sprintf(text, "%.8s", your);
	gotoPosPixel(5U, 90U);
	displayText(text);

	if (::strcmp(reflector, "        ") != 0) {
		::sprintf(text, "via %.8s", reflector);
		gotoPosPixel(5U, 110U);
		displayText(text);
	} else {
		gotoPosPixel(5U, 110U);
		displayText("            ");
	}

	m_mode = MODE_DSTAR;
}
Example #16
0
void Display() {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(0, 0, 1);
    drawCircle(playerx,playery, 20);
    glPushMatrix();
    glColor3f(0, 0, 0);
    drawRect(0,320 ,300, 20);
    glColor3f(1, 0, 1);
    drawRect(0,340, 20, 200);
    glColor3f(1, 0, 1);
    drawRect(200,0, 50, 20);
    glPopMatrix();
    
    //    if(freez){
    //        playerx =700;
    //        playery =600;
    //        freez = 0;
    //    }
    std::string name="TIME : ",result;
    char numstr[2];
    sprintf(numstr, "%i",t);
    result = name + numstr;
    displayText(600, 700, 0, 0, 0, result);
    if(won){
        displayText(400, 600, 0, 1,0, " CHARGES DROPED :D YOU ARE FREE TO GO!!!");
    }
    if(lost){
        displayText(400, 600, 1, 0,0, "JURIES FOUND THAT YOU ARE GUILTY :/ !!");
        //        usleep(1500000);
        
        t = 0;
        
    }
    
    
    glFlush();
    
}
Example #17
0
void TextMgr::displayTextInsideWindow(const char *textPtr, int16 windowRow, int16 windowColumn) {
	int16 textRow = 0;
	int16 textColumn = 0;

	if (!_messageState.window_Active)
		return;

	charPos_Push();
	textRow = _messageState.textPos.row + windowRow;
	textColumn = _messageState.textPos.column + windowColumn;
	charPos_Set(textRow, textColumn);
	displayText(textPtr);
	charPos_Pop();
}
/* displayInitials
 Input: char initials[NUM_INITIALS] The current initials entered
		Polygon* theFont The game font
 Output: none
 Displays the screen asking the user to enter his initials for the high score table
*/
void displayInitials(char initials[NUM_INITIALS], Polygon* theFont)
{
	int i; /* Counter */
	GLfloat currentY = INITIAL_INFO_MAX_Y; /* coordinate for the text */
	GLfloat	currentX = INITIALS_X; /* coordinate for the text */

	displayText ( INITIAL_INFO_X, currentY, "your score is one of the ten best", INFO_SIZE, theFont);
	currentY -= INFO_SPACING_Y;
	displayText ( INITIAL_INFO_X, currentY, "please enter your initials", INFO_SIZE, theFont);
	currentY -= INFO_SPACING_Y;
	displayText (INITIAL_INFO_X, currentY, "push rotate to select letter", INFO_SIZE, theFont);
	currentY -= INFO_SPACING_Y;
	displayText ( INITIAL_INFO_X, currentY, "push hyperspace when letter is correct",INFO_SIZE,  theFont);
	currentY -= INFO_SPACING_Y;

	for ( i = 0; i < NUM_INITIALS; i++)
	{
		char* display = (char*) malloc ( 2 *sizeof(char) );
		display[0] = initials[i];
		display[1] = '\0';
		currentX = displayText ( currentX, INITIALS_Y, display, INITIALS_SIZE, theFont );
	}
}
Example #19
0
bool PSDResourceBlock::write(QIODevice* io) const
{

    dbgFile << "Writing Resource Block" << PSDImageResourceSection::idToString((PSDImageResourceSection::PSDResourceID)identifier) << identifier;

    if (resource && !resource->valid()) {
        error = QString("Cannot write an invalid Resource Block");
        return false;
    }

    if (identifier == PSDImageResourceSection::LAYER_STATE ||
        identifier == PSDImageResourceSection::LAYER_GROUP ||
        identifier == PSDImageResourceSection::LAYER_COMPS ||
        identifier == PSDImageResourceSection::LAYER_GROUP_ENABLED_ID ||
        identifier == PSDImageResourceSection::LAYER_SELECTION_ID) {

        /**
         * We can actually handle LAYER_SELECTION_ID. It consists
         * of a number of layers and a list of IDs to select, which
         * are retrieved from 'lyid' additional layer block.
         */
        dbgFile << "Skip writing resource block" << identifier << displayText();
        return true;
    }

    QByteArray ba;

    // createBlock returns true by default but does not change the data.
    if (resource && !resource->createBlock(ba)) {
        error = resource->error;
        return false;
    }
    else if (!resource) {
        // reconstruct from the data
        QBuffer buf(&ba);
        buf.open(QBuffer::WriteOnly);
        buf.write("8BIM", 4);
        psdwrite(&buf, identifier);
        psdwrite_pascalstring(&buf, name);
        psdwrite(&buf, dataSize);
        buf.write(data);
        buf.close();
    }
    if (io->write(ba.constData(), ba.size()) != ba.size()) {
        error = QString("Could not write complete resource");
        return false;
    }

    return true;
}
Example #20
0
void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) {
	static const uint8 textColors256[] = { 0xfe, 0xa2, 0x84, 0x97, 0x9F };
	static const uint8 textColors16[] = { 0x33, 0xaa, 0x88, 0x55, 0x99 };
	static const uint8 soundEffect[] = { 0x0B, 0x00, 0x2B, 0x1B, 0x00 };

	const uint8 *textColors = _vm->gameFlags().use16ColorMode ? textColors16 : textColors256;

	if (type & 4)
		type ^= 4;
	else
		_vm->stopPortraitSpeechAnim();

	uint16 col = textColors[type & 0x7fff];

	int od = _screen->curDimIndex();

	if (_vm->_updateFlags & 2) {
		clearDim(4);
		_textDimData[4].color1 = col;
	} else {
		clearDim(3);
		if (_vm->gameFlags().use16ColorMode) {
			_textDimData[3].color1 = col;
		} else {
			_screen->copyColor(192, col);
			_textDimData[3].color1 = 192;
		}
		_vm->enableTimer(11);
	}

	va_list args;
	va_start(args, str);

	vsnprintf((char *)_buffer, 240, str, args);

	va_end(args);

	displayText(_buffer);

	_screen->setScreenDim(od);
	_lineCount = 0;

	if (!(type & 0x8000)) {
		if (soundEffect[type])
			_vm->sound()->playSoundEffect(soundEffect[type]);
	}

	_vm->_textColorFlag = type & 0x7fff;
	_vm->_fadeText = false;
}
// main task
task main ()
{
  int _dirDC = 0;
  int _dirAC = 0;
	int dcS1, dcS2, dcS3, dcS4, dcS5 = 0;
	int acS1, acS2, acS3, acS4, acS5 = 0;
	string tmpString;

  // show the user what to do
  displayInstructions();

  eraseDisplay();
  for (int i = 0; i < 8; ++i)
    sTextLines[i] = "";

  // display the current DSP mode
  // When connected to a SMUX, the IR Seeker V2 can only be
  // used in 1200Hz mode.
  nxtDisplayTextLine(0, "      DC  1200");

  // The sensor is connected to the first port
  // of the SMUX which is connected to the NXT port S1.
  // To access that sensor, we must use msensor_S1_1.  If the sensor
  // were connected to 3rd port of the SMUX connected to the NXT port S4,
  // we would use msensor_S4_3

  while (true)
  {
    // Read the current non modulated signal direction
    _dirDC = HTIRS2readDCDir(HTIRS2);
    if (_dirDC < 0)
      break; // I2C read error occurred

    // read the current modulated signal direction
    _dirAC = HTIRS2readACDir(HTIRS2);
    if (_dirAC < 0)
      break; // I2C read error occurred

    // Read the individual signal strengths of the internal sensors
    // Do this for both unmodulated (DC) and modulated signals (AC)
    if (!HTIRS2readAllDCStrength(HTIRS2, dcS1, dcS2, dcS3, dcS4, dcS5))
      break; // I2C read error occurred
    if (!HTIRS2readAllACStrength(HTIRS2, acS1, acS2, acS3, acS4, acS5 ))
      break; // I2C read error occurred

      displayText(1, "D", _dirDC, _dirAC);
      displayText(2, "0", dcS1, acS1);
      displayText(3, "1", dcS2, acS2);
      displayText(4, "2", dcS3, acS3);
      displayText(5, "3", dcS4, acS4);
      displayText(6, "4", dcS5, acS5);
    if (HTSMUXreadPowerStatus(HTSMUX))
      nxtDisplayTextLine(7, "Batt: bad");
    else
      nxtDisplayTextLine(7, "Batt: good");
  }
}
Example #22
0
void CTFTSerial::setLockoutInt()
{
	// Clear the screen
	clearScreen();

	setFontSize(FONT_LARGE);

	// Draw MMDVM logo
	displayBitmap(0U, 0U, "MMDVM_sm.bmp");

	gotoPosPixel(20U, 60U);
	displayText("LOCKOUT");

	m_mode = MODE_LOCKOUT;
}
Example #23
0
void CTFTSerial::setErrorInt(const char* text)
{
	assert(text != NULL);

	// Clear the screen
	clearScreen();

	setFontSize(FONT_MEDIUM);

	// Draw MMDVM logo
	displayBitmap(0U, 0U, "MMDVM_sm.bmp");

	setForeground(COLOUR_RED);

	gotoPosPixel(18U, 55U);
	displayText(text);

	gotoPosPixel(18U, 90U);
	displayText("ERROR");

	setForeground(COLOUR_BLACK);

	m_mode = MODE_ERROR;
}
void CtrlText::onUpdate( Subject<VarBool> &rVariable, void *arg  )
{
    (void)arg;
    // Visibility changed
    if( &rVariable == m_pVisible )
    {
        if( isVisible() )
        {
            displayText( m_rVariable.get() );
            notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
        }
        else
        {
            notifyLayout();
        }
    }
}
/*
    Update the data for, and show the index feedback (if it's not already shown)
*/
void HbIndexFeedbackPrivate::showIndexFeedback()
{
    if (!mItemView 
        || mIndexFeedbackPolicy == HbIndexFeedback::IndexFeedbackNone) {
        return;
    }

    QList <HbAbstractViewItem *> visibleItems = mItemView->visibleItems();

    QModelIndex targetIndex = visibleItems.first()->modelIndex();   
    qreal top = visibleItems.first()->mapToItem(mItemView, 0, 0).y();
    if (top < 0 
        && visibleItems.count() > 1) {
        targetIndex = visibleItems.at(1)->modelIndex();
    }

    if (targetIndex.isValid()) {
        QVariant data = targetIndex.data(Hb::IndexFeedbackRole);
        if (data.canConvert<QString>()) {

            QString testString = displayText(data);
            if (testString != mPopupContent) {
                mPopupContent = testString;
                updatePrimitives();
            }

            if (mTextItem && mTextItem->opacity() == 0.0) {
                HbEffect::start(mPopupItemList, HB_INDEXFEEDBACK_TYPE, EFFECT_IFAPPEAR);
            }
            if (mTextItem) {
                mTextItem->show();
            }

            if (mPopupItem) {
                mPopupItem->show();
            }

            if (mDisappearTimer) {
                mDisappearTimer->stop();
            }
        } else {
            _q_hideIndexFeedback();
        }
    }
}
Example #26
0
void QExpandingLineEdit::resizeToContents()
{
    int oldWidth = width();
    if (originalWidth == -1)
        originalWidth = oldWidth;
    if (QWidget *parent = parentWidget()) {
        QPoint position = pos();
        int hintWidth = minimumWidth() + fontMetrics().width(displayText());
        int parentWidth = parent->width();
        int maxWidth = isRightToLeft() ? position.x() + oldWidth : parentWidth - position.x();
        int newWidth = qBound(originalWidth, hintWidth, maxWidth);
        if (widgetOwnsGeometry)
            setMaximumWidth(newWidth);
        if (isRightToLeft())
            move(position.x() - newWidth + oldWidth, position.y());
        resize(newWidth, height());
    }
}
Example #27
0
void QgsComposerLabel::adjustSizeToText()
{
  double textWidth = QgsComposerUtils::textWidthMM( mFont, displayText() );
  double fontHeight = QgsComposerUtils::fontHeightMM( mFont );

  double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;

  double width = textWidth + 2 * mMarginX + 2 * penWidth + 1;
  double height = fontHeight + 2 * mMarginY + 2 * penWidth;

  //keep alignment point constant
  double xShift = 0;
  double yShift = 0;
  itemShiftAdjustSize( width, height, xShift, yShift );

  //update rect for data defined size and position
  QRectF evaluatedRect = evalItemRect( QRectF( pos().x() + xShift, pos().y() + yShift, width, height ) );
  setSceneRect( evaluatedRect );
}
Example #28
0
void RelationDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
{
	switch (index.column()) {
		case COLUMN_VALUE:
		case COLUMN_VOLTAGE:
		case COLUMN_AMP:
		case COLUMN_POWER:
		case COLUMN_TOLERANCE:
		case COLUMN_TEMP:
		case COLUMN_COUNT:
		case COLUMN_PRICE:
		case COLUMN_PRICE_VOL:
			option->displayAlignment = Qt::AlignRight;
			break;
	}

	// a bit hackish: let base class prepare and then override text
	QStyledItemDelegate::initStyleOption(option, index);

	QVariant value = index.data(Qt::DisplayRole);

	if(index.column() == COLUMN_CATEGORY || index.column() == COLUMN_FOOTPRINT ||
	   index.column() == COLUMN_TEMP || index.column() == COLUMN_SUPPL) {
		if (value.isValid() && !value.isNull()) {
			int id = index.model()->data(index, Qt::EditRole).toInt();
			QString q;
			switch (index.column()) {
				case COLUMN_CATEGORY:	q = "SELECT name FROM category WHERE id = :id"; break;
				case COLUMN_FOOTPRINT:	q = "SELECT name FROM footprint WHERE id = :id"; break;
				case COLUMN_TEMP:		q = "SELECT name FROM temp WHERE id = :id";	break;
				case COLUMN_SUPPL:		q = "SELECT name FROM suppl WHERE id = :id";	break;
			}
			QSqlQuery query;
			query.prepare(q);
			query.bindValue(":id", id);

			if (!query.exec())
				qDebug() << "sql query failed '" << query.lastQuery() << "': " <<  query.lastError().text();
			else if (query.next())
				option->text = displayText(query.value(0).toString(), option->locale);
		}
	}
}
Example #29
0
void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
	int oldDim = 0;

	const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);

	if (dim == 3) {
		if (_vm->_updateFlags & 2) {
			oldDim = clearDim(4);
			_textDimData[4].color1 = isPc98 ? 0x33 : 254;
			_textDimData[4].color2 = _screen->_curDim->unkA;
		} else {
			oldDim = clearDim(3);
			_textDimData[3].color1 = isPc98 ? 0x33 : 192;
			_textDimData[3].color2 = _screen->_curDim->unkA;
			if (!isPc98)
				_screen->copyColor(192, 254);
			_vm->enableTimer(11);
			_vm->_textColorFlag = 0;
			_vm->_fadeText = false;
		}
	} else {
		oldDim = _screen->curDimIndex();
		_screen->setScreenDim(dim);
		_lineCount = 0;
		_textDimData[dim].color1 = isPc98 ? 0x33 : 254;
		_textDimData[dim].color2 = _screen->_curDim->unkA;
	}

	int cp = _screen->setCurPage(0);
	Screen::FontId of = _screen->setFont(_vm->gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);

	preprocessString(str, script, paramList, paramIndex);
	_numCharsTotal = strlen(_dialogueBuffer);
	displayText(_dialogueBuffer);

	_screen->setScreenDim(oldDim);
	_lineCount = 0;
	_screen->setCurPage(cp);
	_screen->setFont(of);

	_vm->_fadeText = false;
}
// main task
task main ()
{
  int _dirDC = 0;
  int _dirAC = 0;
	int dcS1, dcS2, dcS3, dcS4, dcS5 = 0;
	int acS1, acS2, acS3, acS4, acS5 = 0;

	// the default DSP mode is 1200 Hz.
  tHTIRS2DSPMode _mode = DSP_1200;

  while(true)
  {
    // You can switch between the two different DSP modes by pressing the
    // orange enter button



    for (int i = 0; i < 8; ++i)
      sTextLines[i] = "";

    // display the current DSP mode
      nxtDisplayTextLine(0, "      DC  1200");

      // Read the current non modulated signal direction
      _dirDC = HTIRS2readDCDir(HTIRS2);
      if (_dirDC < 0)
        break; // I2C read error occurred

      // read the current modulated signal direction
      _dirAC = HTIRS2readACDir(HTIRS2);
      if (_dirAC < 0)
        break; // I2C read error occurred

      // Read the individual signal strengths of the internal sensors
      // Do this for both unmodulated (DC) and modulated signals (AC)
      if (!HTIRS2readAllDCStrength(HTIRS2, dcS1, dcS2, dcS3, dcS4, dcS5))
        break; // I2C read error occurred
      if (!HTIRS2readAllACStrength(HTIRS2, acS1, acS2, acS3, acS4, acS5 ))
        break; // I2C read error occurred

      displayText(1, "D", _dirDC, _dirAC);
      displayText(2, "0", dcS1, acS1);
      displayText(3, "1", dcS2, acS2);
      displayText(4, "2", dcS3, acS3);
      displayText(5, "3", dcS4, acS4);
      displayText(6, "4", dcS5, acS5);

  }
}