Ejemplo n.º 1
0
void testCensor(const char* source, int length, bool (*testFun)(const char*, int)) {
	if (!Filter::isInitialized()) {
		Filter::init(Filter::HIGH);
	}
	Time startTime = getCurrentTime();
	std::cout << "-- start --------------------------------------" << std::endl;
	std::cout << (testFun(source, length) ? "legal" : "illegal") << std::endl;
	Time endTime = getCurrentTime();
	g_totalSeconds += timeInterval(startTime, endTime);
	std::cout << "time costs: " << g_totalSeconds << " seconds" << std::endl;
	std::cout << "--- end -------------------------------------" << std::endl;
}
Ejemplo n.º 2
0
static PRBool ConsumeChar(nsAString::const_iterator& start,
                          const nsAString::const_iterator &end,
                          PRBool (*testFun)(PRUnichar ch))
{
  if (start == end) {
    return PR_FALSE;
  }
  if (!testFun(*start)) {
    return PR_FALSE;
  }
  ++start;
  return PR_TRUE;
}
BuildFontDialog::BuildFontDialog(Poppler::Document *pdf)
{

    doc = pdf;
    currentPage = 0;
    QPushButton *saveToFileButton = new QPushButton(tr("Save"));
    QPushButton *confirmButton = new QPushButton(tr("OK"));
    QPushButton *closeButton = new QPushButton(tr("Cancel"));
    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(confirmButton, SIGNAL(clicked()), this, SLOT(testFun()));
    connect(saveToFileButton, SIGNAL(clicked()), this, SLOT(saveToFile()));

    imageLabel = new ImageLabel;
    imageLabel->setBackgroundRole(QPalette::Base);
    imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    imageLabel->setScaledContents(true);
    scrollArea = new QScrollArea;
    scrollArea->setBackgroundRole(QPalette::Dark);
    scrollArea->setWidget(imageLabel);
    connect(imageLabel, SIGNAL(clicked(const QPoint & )), this, SLOT(pickLetter(const QPoint & )));
    
    QPushButton *previousButton = new QPushButton(tr("Previous"));
    QPushButton *nextButton = new QPushButton(tr("Next"));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(goPrevious()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(goNext()));
    pageIndicator = new QLabel;
    QRadioButton *displayOriginal = new QRadioButton(tr("Original"));
    QRadioButton *displayBoxed = new QRadioButton(tr("Boxed"));
    isBoxedDisplay.addButton(displayOriginal);
    isBoxedDisplay.addButton(displayBoxed);
    displayOriginal->setChecked(true);
    
    selectionArbitrary = new QCheckBox();
    selectionArbitrary->setChecked(false);
    selectionArbitrary->setText("Arbitrary Rectangle");
    arbitraryLastPoint.setX(-1);
    
    connect(displayOriginal, SIGNAL(clicked()), this, SLOT(displayOriginalPage()));
    connect(displayBoxed, SIGNAL(clicked()), this, SLOT(displayBoxedPage()));

    QHBoxLayout *pageNavigationLayout = new QHBoxLayout;
    pageNavigationLayout->addStretch();
    pageNavigationLayout->addWidget(previousButton);
    pageNavigationLayout->addWidget(pageIndicator);
    pageNavigationLayout->addWidget(nextButton);
    pageNavigationLayout->addStretch();
    pageNavigationLayout->addWidget(selectionArbitrary);
    pageNavigationLayout->addStretch();
    pageNavigationLayout->addWidget(displayOriginal);
    pageNavigationLayout->addWidget(displayBoxed);
    pageNavigationLayout->addStretch();
    
    
    QHBoxLayout *lowerCases = new QHBoxLayout;
    QHBoxLayout *upperCases = new QHBoxLayout;
    buttonGroup= new QButtonGroup;
    createLetters(lowerCases, upperCases);
    connect(buttonGroup,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(displayFontEditorFor(QAbstractButton*)));

    QVBoxLayout *lettersLayout = new QVBoxLayout;
    lettersLayout->addLayout(lowerCases);
    lettersLayout->addLayout(upperCases);
    
    QHBoxLayout *letterAdjustAndLetters = new QHBoxLayout;
    fontEditor = new NCSAFontEditor(&builtFont);
    letterAdjustAndLetters->addLayout(fontEditor);
    letterAdjustAndLetters->addLayout(lettersLayout);

    QHBoxLayout *testLayout = new QHBoxLayout;
    testInput = new QLineEdit;
    testDisplay = new QLabel;
    testLayout->addWidget(testInput);
    testLayout->addStretch();
    testLayout->addWidget(testDisplay);
    connect(testInput,SIGNAL(textChanged(QString)),this,SLOT(testInputChanged(QString)));
    
    QVBoxLayout *verticalLayout = new QVBoxLayout;
    verticalLayout->addWidget(scrollArea);
    verticalLayout->addLayout(pageNavigationLayout);
    verticalLayout->addLayout(letterAdjustAndLetters);
    verticalLayout->addLayout(testLayout);


    QHBoxLayout *buttonsLayout = new QHBoxLayout;
    buttonsLayout->addStretch(1);
    buttonsLayout->addWidget(saveToFileButton);
    buttonsLayout->addWidget(confirmButton);
    buttonsLayout->addWidget(closeButton);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(verticalLayout);
    //mainLayout->addStretch(1);
    //mainLayout->addSpacing(12);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);
    resize(1000, 600);
   
    setWindowTitle(tr("Font Creater"));
    
    displayPage();
}