Ejemplo n.º 1
0
void RichText::visit()
{
    if (_enabled)
    {
        formatText();
        Widget::visit();
    }
}
Ejemplo n.º 2
0
void WidgetSaver::serializeLabel(WidgetLabel* w, Variant& root)
{
	//	special board attributes
	root.insert("sizeChar", Variant(w->sizeChar));
	root.insert("textConfiguration", Variant((int)w->textConfiguration));
	if (w->font) root.insert("font", Variant(w->font->name));
	root.insert("text", formatText(w->text));
}
Ejemplo n.º 3
0
void RichText::visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
{
    if (_enabled)
    {
        formatText();
        Widget::visit(renderer, parentTransform, parentTransformUpdated);
    }
}
Ejemplo n.º 4
0
void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
    if (_enabled)
    {
        formatText();
        Widget::visit(renderer, parentTransform, parentFlags);
    }
}
Ejemplo n.º 5
0
/*************************************************************************
	Handler for when widget size is changed.
*************************************************************************/
void MultiLineEditbox::onSized(WindowEventArgs& e)
{
	formatText();

	// base class handling
	Window::onSized(e);

	e.handled = true;
}
Ejemplo n.º 6
0
void HelpFormatter::formatOptions(std::ostream& ostr) const
{
    int optWidth = calcIndent();
    for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it)
    {
        formatOption(ostr, *it, optWidth);
        if (_indent < optWidth)
        {
            ostr << '\n' << std::string(_indent, ' ');
            formatText(ostr, it->description(), _indent, _indent);
        }
        else
        {
            formatText(ostr, it->description(), _indent, optWidth);
        }
        ostr << '\n';
    }
}
Ejemplo n.º 7
0
void SpinBoxRange::setText(QString text)
{
    QValidator::State state;
    stringToRange(text, _valMin, _valMax, state);
    formatText();

    // Sélection de la totalité
    this->lineEdit()->selectAll();
}
Ejemplo n.º 8
0
void CalculatorTestApp::drawDisplay() {
  screen.fillRect(screen.clipLeft(), screen.clipTop(), screen.clipWidth(), displayHeight, screen.lightergrey);
  screen.setTextColor(screen.black);

  char number[100];
  char* printNumber;
  if (strlen(topText)) {
    printNumber = topText;
  } else {
    formatText(number, top(0));
    printNumber = number;
  }

  if (strlen(printNumber) < 11) {
    screen.setFont(&Arial_28);
  } else if (strlen(number) < 15) {
    screen.setFont(&Arial_20);
  } else {
    screen.setFont(&Arial_16);
  }

  coord_t w = screen.measureTextWidth(printNumber);

  screen.setCursor(screen.clipRight()-w, screen.clipTop() + displayHeight/2 - screen.measureTextHeight(printNumber)/2);
  screen.drawText(printNumber);

  coord_t topWidth = screen.measureTextWidth(printNumber);

  char line1[100];
  char line2[100];
  char line3[100];
  sprintf(number, "%s\n%s\n%s", formatText(line1, top(3)), formatText(line2, top(2)), formatText(line3, top(1)));

  screen.setFont(&Arial_9_Bold);

  // if it doesn't fit, shrink it down
  if ((screen.measureTextWidth(number) + topWidth)>(screen.clipWidth()-10)) {
    screen.setFont(&Arial_8);
  }

  screen.setCursor(screen.clipLeft() + 5, screen.clipTop()+displayHeight/2-screen.measureTextHeight(number)/2);
  screen.drawText(number);
}
Ejemplo n.º 9
0
void WidgetSaver::serializeRadioButton(WidgetRadioButton* w, Variant& root)
{
	//	special board attributes
	root.insert("sizeChar", Variant(w->sizeChar));
	root.insert("textConfiguration", Variant((int)w->textConfiguration));
	if (w->font) root.insert("font", Variant(w->font->name));
	root.insert("text", formatText(w->text));
	if (w->onTexture) root.insert("onTexture", Variant(w->onTexture->name));
	if (w->offTexture) root.insert("offTexture", Variant(w->offTexture->name));
}
Ejemplo n.º 10
0
void WidgetSaver::serializeConsole(WidgetConsole* w, Variant& root)
{
	//	special board attributes
	root.insert("cornerConfig", Variant((int)w->cornerConfiguration));
	root.insert("borderWidth", Variant(w->borderWidth));
	root.insert("borderThickness", Variant(w->borderThickness));
	root.insert("margin", Variant(w->margin));
	root.insert("sizeChar", Variant(w->sizeChar));
	if (w->font) root.insert("font", Variant(w->font->name));
	root.insert("text", formatText(w->text));
}
Ejemplo n.º 11
0
void CalculatorTestApp::keySend() {
  char textNum[100];
  formatText(textNum, top(0));

  Keyboard.print(textNum);
  // todo: make this not blocking
  for (size_t i = 0; i < strlen(textNum); i++) {
    sound.click();
    delay(50);
  }
}
Ejemplo n.º 12
0
/*************************************************************************
	Set whether the text will be word wrapped or not.
*************************************************************************/
void MultiLineEditbox::setWordWrapping(bool setting)
{
	if (setting != d_wordWrap)
	{
		d_wordWrap = setting;
		formatText();

		WindowEventArgs args(this);
		onWordWrapModeChanged(args);
	}

}
Ejemplo n.º 13
0
void HelpFormatter::format(std::ostream& ostr) const
{
	ostr << "usage: " << _command;
	if (!_usage.empty())
	{
		ostr << ' ';
		formatText(ostr, _usage, (int) _command.length() + 1);
	}
	ostr << '\n';
	if (!_header.empty())
	{
		formatText(ostr, _header, 0);
		ostr << "\n\n";
	}
	formatOptions(ostr);
	if (!_footer.empty())
	{
		ostr << '\n';
		formatText(ostr, _footer, 0);
		ostr << '\n';
	}
}
Ejemplo n.º 14
0
void TextEditWidget::onTextChanged( int position, int charsRemoved, int charsAdded  )
{
   if ( charsAdded == 1 )
   {
      formatText( position );
   }

   if ( charsRemoved > 0 || charsAdded > 0 )
   {
      // inform the listeners only if the text changed - we're not interested in formatting changes
      emit textChanged();
   }
}
Ejemplo n.º 15
0
void SpinBoxRange::stepBy(int steps)
{
    int selection = 0;
    switch (getCurrentSection())
    {
    case SectionMin:
        _valMin += steps;
        if (_valMin < MINI)
            _valMin = MINI;
        else if (_valMin > MAXI)
            _valMin = MAXI;
        if (_valMin > _valMax)
            _valMax = _valMin;

        // Sélection à gauche
        selection = -1;

        break;
    case SectionMax:
        _valMax += steps;
        if (_valMax < MINI)
            _valMax = MINI;
        else if (_valMax > MAXI)
            _valMax = MAXI;
        if (_valMax < _valMin)
            _valMin = _valMax;

        // Sélection à droite
        selection = 1;

        break;
    case SectionNone:
        break;
    }
    formatText();

    if (selection == -1)
    {
        QString txt = lineEdit()->text();
        int posSeparator = txt.indexOf(QRegExp("[0-9]" + SEPARATOR)) + 1;
        lineEdit()->setSelection(0, posSeparator);
    }
    else if (selection == 1)
    {
        QString txt = lineEdit()->text();
        int posSeparator = txt.indexOf(QRegExp("[0-9]" + SEPARATOR)) + 1;
        lineEdit()->setSelection(posSeparator + SEPARATOR.size(), txt.size() - posSeparator + SEPARATOR.size());
    }

    emit(valueChanged());
}
Ejemplo n.º 16
0
/*************************************************************************
	Initialise the Window based object ready for use.	
*************************************************************************/
void MultiLineEditbox::initialise(void)
{
	// create the component sub-widgets
	d_vertScrollbar = createVertScrollbar(getName() + "__auto_vscrollbar__");
	d_horzScrollbar = createHorzScrollbar(getName() + "__auto_hscrollbar__");

	addChildWindow(d_vertScrollbar);
	addChildWindow(d_horzScrollbar);

    d_vertScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&MultiLineEditbox::handle_scrollChange, this));
    d_horzScrollbar->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(&MultiLineEditbox::handle_scrollChange, this));

	formatText();
	performChildWindowLayout();
}
Ejemplo n.º 17
0
void SpinBoxRange::updateValue()
{
    QValidator::State state = QValidator::Invalid;
    int valMin, valMax;
    stringToRange(lineEdit()->text(), valMin, valMax, state);
    if (state != QValidator::Acceptable)
        return;

    if (valMin == _valMin && valMax == _valMax)
        return;

    _valMin = valMin;
    _valMax = valMax;

    formatText();
    emit(valueChanged());
}
Ejemplo n.º 18
0
void echoHtmlPage(FILE *client,char *req){
//use the plain text to fill the html template
//这个函数派上用场实在单独的一个web页面中(<a href=xxx,不同于其他链接)
	///view?resp=html&dir=xxx,dir is absname
	char abspath[MAXPATH];
	extern char webpage_root[];
	sscanf(req,"/view?resp=html&dir=%s",abspath);
	
	chinese2host(abspath);
	
	if(strncasecmp(webpage_root,abspath,strlen(webpage_root))!=0){
		fputs("Permission denied!",client);
		return;
	}
	int fd=open(abspath,O_RDONLY);
	if(fd==-1){
		info("open file error:");
		info(abspath);
		sendHead(client);
		fputs("open file error!",client);
		return;
	}
	
	int len=lseek(fd,0,SEEK_END);
	char* p=(char *)malloc(len+1);//maybe need '\0'
	bzero(p,len+1);
	lseek(fd,0,SEEK_SET);
	int ret=read(fd,p,len);//一次性读取文件,对于大文件会出错,有时间再改,分批读取和传送文件
	if(ret<0) info("echoHtmlPage:read fail");
	close(fd);
	
	sendHead(client);
//	char msg[128];
//	sprintf(msg,"strlen of head:%d",strlen(packHead_close));
//	info(msg);
	char title[MAX_FN];//,time[MAX_FN];
	sscanf(p,"%s",title);
	p=formatText(p,len);//space -> &nbsp; etc
//	info("there");
	fprintf(client,"<html lang=\"zh-cn\"><html><head><meta charset=\"utf-8\"><title>Online</title></head><body><font color=\"115599\" size=+3>%s</font><br><hr width=\"100%%\"><br><font color=\"119966\" size=+2>%s</body></html>",title,p);
//	fwrite(p,len,1,client);//send file content
	fflush(client);
	free(p);
}
Ejemplo n.º 19
0
void MWGui::JournalWindow::open()
{
    mPageNumber = 0;
    MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0);
    if(MWBase::Environment::get().getJournal()->begin()!=MWBase::Environment::get().getJournal()->end())
    {
        book journal;
        journal.endLine = 0;

        for(std::deque<MWDialogue::StampedJournalEntry>::const_iterator it = MWBase::Environment::get().getJournal()->begin();it!=MWBase::Environment::get().getJournal()->end();++it)
        {
            std::string a = it->getText(MWBase::Environment::get().getWorld()->getStore());
            journal = formatText(a,journal,10,17);
            journal.endLine = journal.endLine +1;
            journal.pages.back() = journal.pages.back() + std::string("\n");
        }
        //std::string a = MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore());
        //std::list<std::string> journal = formatText(a,10,20,1);
        bool left = true;
        for(std::list<std::string>::iterator it = journal.pages.begin(); it != journal.pages.end();++it)
        {
            if(left)
            {
                mLeftPages.push_back(*it);
            }
            else
            {
                mRightPages.push_back(*it);
            }
            left = !left;
        }
        if(!left) mRightPages.push_back("");

        mPageNumber = mLeftPages.size()-1;
        displayLeftText(mLeftPages[mPageNumber]);
        displayRightText(mRightPages[mPageNumber]);

    }
    else
    {
        //std::cout << MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore());
    }
}
Ejemplo n.º 20
0
QString CLHelp::formatHelp(QString parameter, QString help, bool html) {
	if (html) {
		return "<tr><td><b>"+parameter+"</b></td><td>"+help+"</td></tr>";
	} else {
		int par_width = 20;
		int help_width = 80 - par_width;

		QString s;
		s = s.fill( ' ', par_width - (parameter.count()+2) );
		s = s + parameter + ": ";

		QString f;
		f = f.fill(' ', par_width);

		QString s2 = formatText(help, help_width);
		int pos = s2.indexOf('\n');
		while (pos != -1) {
			s2 = s2.insert(pos+1, f);
			pos = s2.indexOf('\n', pos+1);
		}

		return s + s2 + "\n";
	}
}
Ejemplo n.º 21
0
/*************************************************************************
	Handler for when text is programmatically changed.
*************************************************************************/
void MultiLineEditbox::onTextChanged(WindowEventArgs& e)
{
    // ensure last character is a new line
    if ((d_text.length() == 0) || (d_text[d_text.length() - 1] != '\n'))
        d_text.append(1, '\n');

    // base class processing
    Window::onTextChanged(e);

    // clear selection
    clearSelection();
    // layout new text
    formatText();
    // layout child windows (scrollbars) since text layout may have changed
    performChildWindowLayout();
    // ensure carat is still within the text
    setCaratIndex(getCaratIndex());
    // ensure carat is visible
    // NB: this will already have been called at least once, but since we
    // may have changed the formatting of the text, it needs to be called again.
    ensureCaratIsVisible();

    e.handled = true;
}
void TextFormatButtons::addSquareRoot()
{
	if (d_buttons == Equation)
		formatText("\\sqrt{","}");
}
void TextFormatButtons::addFraction()
{
	if (d_buttons == Equation)
		formatText("\\frac{","}{}");
}
void TextFormatButtons::addBold()
{
	formatText("<b>","</b>");
}
void TextFormatButtons::addItalics()
{
	formatText("<i>","</i>");
}
void TextFormatButtons::addUnderline()
{
	formatText("<u>","</u>");
}
void TextFormatButtons::addCurve()
{
	formatText("\\l(",")");
}
Ejemplo n.º 28
0
QString CLHelp::help(bool html) {
	QString app_name = QFileInfo(qApp->applicationFilePath()).baseName();

	QString options = QString("%1 [-minigui] [-defaultgui] [-mpcgui] [-config-path %2] "
                        "[-send-action %3] [-actions %4] "
                        "[-close-at-end] [-no-close-at-end] [-fullscreen] [-no-fullscreen] "
                        "[-ontop] [-no-ontop] "
                        "[-sub %5] [-pos x y] [-size %6 %7] "
                        "[-add-to-playlist] [-help|--help|-h|-?] "
                        "[%8] [%8]...")
                        .arg(app_name)
                        .arg(QObject::tr("directory"))
                        .arg(QObject::tr("action_name"))
                        .arg(QObject::tr("action_list"))
                        .arg(QObject::tr("subtitle_file"))
                        .arg(QObject::tr("width")).arg(QObject::tr("height"))
                        .arg(QObject::tr("media"));

	QString s;

	if (html) {
		s = QObject::tr("Usage:") + " <b>" + options + "</b><br>";
		s += "<table>";
	} else {
		s = formatText(QObject::tr("Usage:") + " " + options, 80);
		s += "\n\n";
	}

#ifdef Q_OS_WIN	
	s += formatHelp( "-uninstall", QObject::tr(
		"Restores the old associations and cleans up the registry."), html );
#endif
	s += formatHelp( "-minigui", QObject::tr(
		"opens the mini gui instead of the default one."), html );

	s += formatHelp( "-mpcgui", QObject::tr(
		"opens the mpc gui."), html );

	s += formatHelp( "-defaultgui", QObject::tr(
		"opens the default gui."), html );

#ifdef SKINS
	s += formatHelp( "-skingui", QObject::tr(
		"opens the gui with support for skins."), html );
#endif

	s += formatHelp( "-config-path", QObject::tr(
		"specifies the directory where smplayer will store its configuration "
        "files (smplayer.ini, smplayer_files.ini...)"), html );

	s += formatHelp( "-send-action", QObject::tr(
		"tries to make a connection to another running instance "
        "and send to it the specified action. Example: -send-action pause "
        "The rest of options (if any) will be ignored and the "
        "application will exit. It will return 0 on success or -1 "
        "on failure."), html );

	s += formatHelp( "-actions", QObject::tr(
		"action_list is a list of actions separated by spaces. "
		"The actions will be executed just after loading the file (if any) "
		"in the same order you entered. For checkable actions you can pass "
		"true or false as parameter. Example: "
		"-actions \"fullscreen compact true\". Quotes are necessary in "
		"case you pass more than one action."), html );

	s += formatHelp( "-close-at-end", QObject::tr(
		"the main window will be closed when the file/playlist finishes."), html );

	s += formatHelp( "-no-close-at-end", QObject::tr(
		"the main window won't be closed when the file/playlist finishes."), html );

	s += formatHelp( "-fullscreen", QObject::tr(
		"the video will be played in fullscreen mode."), html );

	s += formatHelp( "-no-fullscreen", QObject::tr(
		"the video will be played in window mode."), html );

	s += formatHelp( "-ontop", QObject::tr(
		"sets the stay on top option to always."), html );

	s += formatHelp( "-no-ontop", QObject::tr(
		"sets the stay on top option to never."), html );

	s += formatHelp( "-sub", QObject::tr(
		"specifies the subtitle file to be loaded for the first video."), html );

	s += formatHelp( "-pos", QObject::tr(
		"specifies the coordinates where the main window will be displayed."), html );

	s += formatHelp( "-size", QObject::tr(
		"specifies the size of the main window."), html );

	s += formatHelp( "-help", QObject::tr(
		"will show this message and then will exit."), html );

	s += formatHelp( "-add-to-playlist", QObject::tr(
		"if there's another instance running, the media will be added "
        "to that instance's playlist. If there's no other instance, "
        "this option will be ignored and the "
        "files will be opened in a new instance."), html );

	s += formatHelp( QObject::tr("media"), QObject::tr(
		"'media' is any kind of file that SMPlayer can open. It can "
        "be a local file, a DVD (e.g. dvd://1), an Internet stream "
        "(e.g. mms://....) or a local playlist in format m3u or pls."), html );

	if (html) s += "</table>";

	return s;
}
Ejemplo n.º 29
0
void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int indent) const
{
	formatText(ostr, text, indent, indent);
}
Ejemplo n.º 30
0
void DebugFont::setText(const std::string &text)
{
	this->text = text;
	formatText();
}