void ClockApplet::updateTipContent() { Plasma::ToolTipContent tipData; QString subText("<table>"); QList<Plasma::DataEngine::Data> tzs; Plasma::DataEngine *engine = dataEngine("time"); Plasma::DataEngine::Data data = engine->query("Local"); const QDate localDate = data["Date"].toDate(); const QString localTz = data["Timezone"].toString(); tzs.append(data); bool highlightLocal = false; const bool hasEvents = d->calendarWidget ? d->calendarWidget->dateHasDetails(localDate) : false; tipData.setMainText(hasEvents ? i18n("Current Time and Events") : i18n("Current Time")); foreach (const QString &tz, d->selectedTimezones) { if (tz != "UTC") { highlightLocal = true; } data = engine->query(tz); tzs.append(data); } qSort(tzs.begin(), tzs.end(), sortTzByData); QDate currentDate; foreach (const Plasma::DataEngine::Data &data, tzs) { bool shouldHighlight = highlightLocal && (data["Timezone"].toString() == localTz); currentDate = d->addTzToTipText(subText, data, currentDate, shouldHighlight); }
void NewMenu::render() { // x pos of character sprites const int SPRITEX = -windowWidth / 1.25; // y positions of the four different characters // static_cast to get rid of compiler warnings about double to float const float SPRITEY[Party::SIZE] = {static_cast<float>(windowHeight / 1.6), static_cast<float>(windowHeight / 4.8), static_cast<float>(-windowHeight / 4.8), static_cast<float>(-windowHeight / 1.6)}; // blue background and border entire window blueBackground(windowWidth, windowHeight); border(-windowWidth, windowWidth, windowHeight, -windowHeight); // borders around submenus subBorders(); // text in submenus subText(); // render sprites, names, and jobs for (int i = Party::FIRST; i < Party::SIZE; i++) { Party::Characters c = static_cast<Party::Characters>(i); party->render(c, SPRITEX - 20, SPRITEY[i] + 82); twenty.drawText(-windowWidth / 2, SPRITEY[i], party->getName(c).c_str()); twenty.drawText(-windowWidth / 2, SPRITEY[i] - 80, party->getJob(c).c_str()); } // render the cursor(s) cursorRender(SPRITEX, SPRITEY); }
void UseSpellMenu::render() { // x pos of character sprites const int SPRITEX = -windowWidth / 1.25; // y positions of the four different characters // static_cast to get rid of compiler warnings about double to float const float SPRITEY[Party::SIZE] = {static_cast<float>(windowHeight * 0.69), static_cast<float>(windowHeight * 0.23), static_cast<float>(-windowHeight * 0.23), static_cast<float>(-windowHeight * 0.69)}; // blue background and border entire window blueBackground(windowWidth, windowHeight); border(-windowWidth, windowWidth, windowHeight, -windowHeight); // borders around submenus subBorders(); // text in submenus subText(); // render names, sprites, lv, job, hp, mp for (int i = Party::FIRST; i < Party::SIZE; i++) { Party::Characters c = static_cast<Party::Characters>(i); // character name and sprite twenty.drawText(SPRITEX - 35, SPRITEY[i] + twenty.getLineSkip() * 0.75, party->getName(c).c_str()); party->render(c, SPRITEX - 20 , SPRITEY[i] + 50); // draw character details std::string level = "Lv. " + std::to_string(party->getAttribute(c, Character::LEVEL)) + " "; std::string details = level + party->getJob(c) + "\nHP\nMP"; twenty.drawText(-windowWidth / 1.75, SPRITEY[i], details.c_str()); // get hp/mp fraction strings std::string hpFraction = "\n" + party->getHPFraction(c); std::string mpFraction = "\n\n" + party->getMPFraction(c); // hp/mp is right aligned const int RIGHTEDGE = -windowWidth / 1.75 + 390; SDL_Rect r = {0, 0, 0, 0}; // draw the hp fraction right aligned twenty.textSize(hpFraction.c_str(), &r); twenty.drawText(RIGHTEDGE - r.w, SPRITEY[i], hpFraction.c_str()); // draw the mp fraction right aligned twenty.textSize(mpFraction.c_str(), &r); twenty.drawText(RIGHTEDGE - r.w, SPRITEY[i], mpFraction.c_str()); } // render the cursor(s) cursorRender(SPRITEX, SPRITEY); }
void ShopMenu::subWindows() { // blue background blueBackground(windowWidth, windowHeight); // message and shop type borders const int LEFTXTOP = windowWidth - 400; border(-windowWidth, LEFTXTOP, windowHeight, windowHeight - 124); border(LEFTXTOP, windowWidth, windowHeight, windowHeight - 124); // menu options and party gil border const int LEFTXOPTIONS = (windowWidth / 2) - 350; border(-windowWidth, LEFTXOPTIONS, windowHeight - 124, windowHeight - 248); border(LEFTXOPTIONS, windowWidth, windowHeight - 124, windowHeight - 248); // text in submenus subText(); }
Text Text::subText( Atom::Type left, Atom::Type right, const Atom *from ) const { const Atom *begin = from ? from : firstAtom(); const Atom *end; while ( begin != 0 && begin->type() != left ) begin = begin->next(); if ( begin != 0 ) begin = begin->next(); end = begin; while ( end != 0 && end->type() != right ) end = end->next(); if ( end == 0 ) begin = 0; return subText( begin, end ); }
Text Text::sectionHeading(const Atom* sectionLeft) { if (sectionLeft != 0) { const Atom* begin = sectionLeft; while (begin != 0 && begin->type() != Atom::SectionHeadingLeft) begin = begin->next(); if (begin != 0) begin = begin->next(); const Atom* end = begin; while (end != 0 && end->type() != Atom::SectionHeadingRight) end = end->next(); if (end != 0) return subText(begin, end); } return Text(); }
Text Text::subText(Atom::Type left, Atom::Type right, const Atom* from, bool inclusive) const { const Atom* begin = from ? from : firstAtom(); const Atom* end; while (begin != 0 && begin->type() != left) begin = begin->next(); if (begin != 0) { if (!inclusive) begin = begin->next(); } end = begin; while (end != 0 && end->type() != right) end = end->next(); if (end == 0) begin = 0; else if (inclusive) end = end->next(); return subText(begin, end); }
void nedTreeView::build() { if( net != NULL ) { tree->clear(); QTreeWidgetItem *networkItem; networkItem = new QTreeWidgetItem( tree ); networkItem->setText( 0, tr( "Network" ) ); networkItem->setText( 1, QString().setNum( net->subnetworksCount() ) + tr( " subnetworks") ); for( int i = 0; i < net->subnetworksCount(); i++ ) { QTreeWidgetItem *subnetworkItem = new QTreeWidgetItem( networkItem ); subnetworkItem->setText( 0, tr( "Subnetwork" ) ); QString subText( "S" ); subText += QString().setNum( i + 1 ); subText += ": ("; subText += QString().setNum( net->subnetwork( i ).illuminationPrototype() ); subText += ")"; subnetworkItem->setText( 1, subText ); QTreeWidgetItem *neuronItem = new QTreeWidgetItem( subnetworkItem ); neuronItem->setText( 0, tr( "Neuron" ) ); neuronItem->setText( 2, tr("weak") ); neuronItem->setText( 3, QString().setNum( net->subnetwork( i ).weakNeuron().upperThreshold() ) ); neuronItem->setText( 4, QString().setNum( net->subnetwork( i ).weakNeuron().lowerThreshold() ) ); neuronItem = new QTreeWidgetItem( subnetworkItem ); neuronItem->setText( 0, tr( "Neuron" ) ); neuronItem->setText( 2, tr("strong") ); neuronItem->setText( 3, QString().setNum( net->subnetwork( i ).strongNeuron().upperThreshold() ) ); neuronItem->setText( 4, QString().setNum( net->subnetwork( i ).strongNeuron().lowerThreshold() ) ); tree->setItemExpanded( subnetworkItem, true ); } tree->setItemExpanded( networkItem, true ); networkItem->setSizeHint( 0, QSize( 300, 40 ) ); tree->resizeColumnToContents( 0 ); } }