int main(int argc, char **argv) { QApplication app(argc, argv); QStringList args = app.arguments(); if (argc <= 1) { qDebug() << "Usage: " << qPrintable(args[0]) << " <ts-file>"; return 1; } QTranslator trans; trans.load(args[1], "."); app.installTranslator(&trans); QWidget w; QVBoxLayout *layout = new QVBoxLayout(&w); QLabel label1(QObject::tr("XXXXXXXXX \33 XXXXXXXXXXX • and → "), 0); QLabel label2(QObject::tr("\32"), 0); QLabel label3(QObject::tr("\176"), 0); QLabel label4(QObject::tr("\301"), 0); layout->addWidget(&label1); layout->addWidget(&label2); layout->addWidget(&label3); layout->addWidget(&label4); w.show(); return app.exec(); }
const NAString StmtDDLDropView::displayLabel2() const { NAString label2("Drop behavior: "); switch (getDropBehavior()) { case COM_CASCADE_DROP_BEHAVIOR : return label2 + "Cascade"; case COM_RESTRICT_DROP_BEHAVIOR : return label2 + "Restrict"; default : NAAbort("StmtDDLDrop.C", __LINE__, "internal logic error"); return NAString(); } }
const NAString StmtDDLSchRevoke::displayLabel2() const { NAString label2("Drop behavior: "); switch (getDropBehavior()) { case COM_CASCADE_DROP_BEHAVIOR : return label2 + "Cascade"; case COM_RESTRICT_DROP_BEHAVIOR : return label2 + "Restrict"; default : ABORT("internal logic error"); return NAString(); } }
void TestAnnotationProperty() { PropertyModifiedListener l; std::string label1("Label1"); mitk::Point3D point1; point1[0] = 3; point1[1] = 5; point1[2] = -4; std::string str1 = "Label1[3, 5, -4]"; std::string label2("Label2"); mitk::Point3D point2; point2[0] = -2; point2[1] = 8; point2[2] = -4; std::string str2 = "Label2[-2, 8, -4]"; mitk::AnnotationProperty::Pointer prop = mitk::AnnotationProperty::New(label1, point1); MITK_TEST_OUTPUT(<< "**** Test [" << prop->GetNameOfClass() << "] ****"); MITK_TEST_CONDITION_REQUIRED(prop->GetLabel() == label1 && prop->GetPosition() == point1, "Test constructor"); std::string msg = std::string("Test GetValueAsString() [") + prop->GetValueAsString() + " == " + str1 + "]"; MITK_TEST_CONDITION_REQUIRED(prop->GetValueAsString() == str1, msg); mitk::AnnotationProperty::Pointer prop2 = mitk::AnnotationProperty::New(); prop2->AddObserver(itk::ModifiedEvent(), l.m_Cmd.GetPointer()); MITK_TEST_CONDITION_REQUIRED(!l.m_Modified, "Test not modified"); prop2->SetLabel(label2); MITK_TEST_CONDITION_REQUIRED(l.Pop(), "Test modified"); prop2->SetPosition(point2); MITK_TEST_CONDITION_REQUIRED(l.Pop(), "Test modified"); MITK_TEST_CONDITION_REQUIRED(prop2->GetLabel() == label2 && prop2->GetPosition() == point2, "Test Setter"); prop2->SetLabel(label2); MITK_TEST_CONDITION_REQUIRED(!l.Pop(), "Test for no modification"); prop2->SetPosition(point2); MITK_TEST_CONDITION_REQUIRED(!l.Pop(), "Test for no modification"); TestPropInequality(prop, prop2); TestPropAssignment(prop, prop2, str2); prop->SetLabel(label1); prop->SetPosition(point1); TestPropPolymorphicAssignment(prop2, prop, str1); }
int main(int argc, char **argv) { QApplication a(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QWidget w; QLabel label1(QObject::tr("abc", "ascii"), &w); QLabel label2(QObject::tr("æøå", "utf-8"), &w); QLabel label2a(QObject::tr("\303\246\303\270\303\245", "utf-8 oct"), &w); QLabel label3(QObject::trUtf8("Für Élise", "trUtf8"), &w); QLabel label3a(QObject::trUtf8("F\303\274r \303\211lise", "trUtf8 oct"), &w); QBoxLayout *ly = new QVBoxLayout(&w); ly->addWidget(&label1); ly->addWidget(&label2); ly->addWidget(&label2a); ly->addWidget(&label3); ly->addWidget(&label3a); w.show(); return a.exec(); }
/* * This internal helper does all the messy math to work out how to divide * up the space within the current graphics window to neatly fit the board, * the cubes, and the word lists. * This function does not actually add any GObjects to the GWindow; * but it does set the state of the 'gState' structure to be used later. */ static void calculateGeometry(int rowCount, int columnCount) { double boardSize = min(gwp->getWidth() / 3 - 2 * INDENT, gwp->getHeight() - 2 * LABEL_HEIGHT); gState.cubeSize = min((boardSize-BOARD_BORDER)/rowCount, (boardSize-BOARD_BORDER)/columnCount); gState.board.w = gState.board.h = boardSize; gState.board.y = LABEL_HEIGHT + LABEL_HEIGHT; double leftover = gwp->getWidth() - gState.board.w - 2*INDENT; gState.scoreBox[HUMAN].x = INDENT; gState.scoreBox[HUMAN].y = gState.scoreBox[COMPUTER].y = gState.board.y; gState.scoreBox[HUMAN].h = gState.scoreBox[COMPUTER].h = LABEL_HEIGHT; gState.scoreBox[HUMAN].w = leftover*HUMAN_PERCENTAGE; gState.board.x = gState.scoreBox[HUMAN].x + gState.scoreBox[HUMAN].w + INDENT; gState.scoreBox[COMPUTER].x = gState.board.x + gState.board.w + INDENT; gState.scoreBox[COMPUTER].w = gwp->getWidth() - gState.scoreBox[COMPUTER].x - INDENT; gState.statusBox.x = INDENT; gState.statusBox.y = LABEL_HEIGHT; gState.statusBox.w = gwp->getWidth() - 2*INDENT; gState.statusBox.h = LABEL_HEIGHT; gState.rowCount = rowCount; gState.columnCount = columnCount; // figure out an ideal font size by creating labels of different sizes GLabel label("mmmmm"); label.setFont(WORD_FONT + "-" + integerToString(WORD_FONT_SIZE)); gState.wordColumnWidth = label.getWidth(); for (gState.fontSize = 8; gState.fontSize < 48; gState.fontSize++) { GLabel label2("M"); label2.setFont(CUBE_FONT + "-" + integerToString(int(gState.fontSize))); if (label2.getWidth() > FONT_PERCENTAGE * gState.cubeSize) { break; } } }
int main(){ logger.logNoEndl("Setting up window..."); window.create(sf::VideoMode(430,430), "GL"); logger.continueln(" done!"); logger.logNoEndl("Setting up variables..."); rect1.setFillColor(sf::Color(200,200,200)); rect1.setOutlineColor(sf::Color(0,0,0)); rect1.setOutlineThickness(-2); rect1.setPosition(10,10); rect2.setFillColor(sf::Color(200,200,200)); rect2.setOutlineColor(sf::Color(0,0,0)); rect2.setOutlineThickness(-2); rect2.setPosition(220,10); rect3.setFillColor(sf::Color(200,200,200)); rect3.setOutlineColor(sf::Color(0,0,0)); rect3.setOutlineThickness(-2); rect3.setPosition(10,220); rect4.setFillColor(sf::Color(200,200,200)); rect4.setOutlineColor(sf::Color(0,0,0)); rect4.setOutlineThickness(-2); rect4.setPosition(220,220); sf::Font font; if (!font.loadFromFile("arial.ttf")){ logger.log(Logger::LogType::Error, "Arial font not found. Cannot continue..."); return 1; } sf::Text label1("Solid White", font); label1.setColor(sf::Color::Black); label1.setPosition(rect1.getPosition().x + rect1.getSize().x / 2 - label1.getLocalBounds().width / 2, rect1.getPosition().y + rect1.getSize().y / 2 - label1.getLocalBounds().height / 2 - 10); sf::Text label2("Marquee", font); label2.setColor(sf::Color::Black); label2.setPosition(rect2.getPosition().x + rect2.getSize().x / 2 - label2.getLocalBounds().width / 2, rect2.getPosition().y + rect2.getSize().y / 2 - label2.getLocalBounds().height / 2 - 10); sf::Text label3("Color Cycle", font); label3.setColor(sf::Color::Black); label3.setPosition(rect3.getPosition().x + rect3.getSize().x / 2 - label3.getLocalBounds().width / 2, rect3.getPosition().y + rect3.getSize().y / 2 - label3.getLocalBounds().height / 2 - 10); sf::Text label4("Pew", font); label4.setColor(sf::Color::Black); label4.setPosition(rect4.getPosition().x + rect4.getSize().x / 2 - label4.getLocalBounds().width / 2, rect4.getPosition().y + rect4.getSize().y / 2 - label4.getLocalBounds().height / 2 - 10); unsigned short r = 0, g = 0, b = 0; logger.continueln(" done!"); logger.log("Running until told to stop."); bool running = true; while(running){ sf::Event event; while (window.pollEvent(event)){ if (event.type == sf::Event::Closed){ running = false; } else if (event.type == sf::Event::MouseMoved){ doMouseMove(); } else if (event.type == sf::Event::MouseButtonPressed || event.type == sf::Event::MouseButtonReleased){ doMouseButton(event.mouseButton.button); } } window.clear(sf::Color::White); window.draw(rect1); window.draw(rect2); window.draw(rect3); window.draw(rect4); window.draw(label1); window.draw(label2); window.draw(label3); window.draw(label4); window.display(); } logger.log("Closing..."); }