Beispiel #1
0
void helpBrowser::processPrintAll() {

  // to print all we prune the individual html help files by hand and then
  // concatenate them
  QRegExp head("<html>.*</head>");
  QRegExp next("Next: *<a.*\\n");
  next.setMinimal(true);
  QRegExp top("Top: *<a.*\\n");
  top.setMinimal(true);
  QRegExp previous("Previous: *<a.*\\n");
  previous.setMinimal(true);
  QRegExp foot("</body>.*");
  QRegExp newUser("<h1>New User.*</p>");
  newUser.setMinimal(true);
  QRegExp dmc("<h1>A Note On DMC.*</p>");
  dmc.setMinimal(true);

  QString overview(::readTextFile(":/overview.html"));
  overview.replace(next, "").replace(top, "").replace(previous, "").replace(foot, "");

  QString colorChooser(::readTextFile(":/colorChooser.html"));
  colorChooser.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "").replace(newUser, "").replace(dmc, "");

  QString colorcompare(::readTextFile(":/colorCompare.html"));
  colorcompare.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "");

  QString square(::readTextFile(":/square.html"));
  square.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "");

  QString pattern(::readTextFile(":/pattern.html"));
  pattern.replace(head, "").replace(top, "").replace(previous, "").replace(next, "");

  QString newText(overview + colorChooser + colorcompare + square + pattern);

  QPrinter printer;
  //printer.setOutputFileName("helpOutAll.pdf");
  QPrintDialog printDialog(&printer, this);
  const int dialogReturnCode = printDialog.exec();
  if (dialogReturnCode == QDialog::Accepted) {
    QTextEdit editor(newText);
    editor.print(&printer);
  }
}
Beispiel #2
0
void gui_getSelectionBoxPseudoResources(const Widget widget, Var* dvStruct)
{

	int listItemCount;
	Var* listItems;

#if DEBUG
	fprintf(stderr, "DEBUG: gui_getSelectionBoxPseudoResources(%ld, %ld)\n", widget, dvStruct);
#endif

	XtVaGetValues(widget, "listItemCount", &listItemCount, NULL);
	if (listItemCount == 0) {
		listItems = newText(0, NULL);
	} else {
		listItems = gui_getXmStringTableCount(widget, "listItems", 0, listItemCount);
	}
	add_struct(dvStruct, "listItems", listItems);

	return;
}
Beispiel #3
0
void QSvgText::insertText(const QString &text, WhitespaceMode mode)
{
    bool isTSpan = (m_formats.count() == 2);
    QString newText(text);
    newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
    newText.replace(QLatin1Char('\n'), QLatin1Char(' '));

    bool prependSpace = !m_appendSpace && !isTSpan && (mode == Default) && !m_paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
    if (m_appendSpace || prependSpace)
        m_paragraphs.back().append(QLatin1Char(' '));

    bool appendSpaceNext = (!isTSpan && (mode == Default) && newText.endsWith(QLatin1Char(' ')));

    if (mode == Default) {
        newText = newText.simplified();
        if (newText.isEmpty())
            appendSpaceNext = false;
    }

    if (!m_formats.isEmpty()) {
        QTextLayout::FormatRange range;
        range.start = m_paragraphs.back().length();
        range.length = newText.length();
        range.format = m_formats.top();
        if (m_appendSpace) {
            Q_ASSERT(!m_formatRanges.back().isEmpty());
            ++m_formatRanges.back().back().length;
        } else if (prependSpace) {
            --range.start;
            ++range.length;
        }
        m_formatRanges.back().append(range);
    }

    m_appendSpace = appendSpaceNext;
    m_paragraphs.back() += newText;
}
Beispiel #4
0
// Read the logfile from disk ===============================================================================================
void ReadLogFile::readFile()
{
	QTextStream in(&logfile);
	
	QString readLine = "";
	int countLines = 0;
	while (!in.atEnd())	// read the logfile line by line
	{
		readLine = in.readLine();
		countLines++;
		
		if (readLine.startsWith("<a name=\"error"))	// if the line is an error increase the total errors
			errorsTotal++;
		
		text.append(readLine + "<br>");
	
		if ((countLines > 2000) || (in.atEnd()))		//when 5000 lines are read or file is at end, append text to the logviewer
		{
			emit newText(text);
			text = "";
			countLines = 0;
		}
	}
}
Beispiel #5
0
void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
    applyStyle(p, states);
    qreal oldOpacity = p->opacity();
    p->setOpacity(oldOpacity * states.fillOpacity);

    // Force the font to have a size of 100 pixels to avoid truncation problems
    // when the font is very small.
    qreal scale = 100.0 / p->font().pointSizeF();
    Qt::Alignment alignment = states.textAnchor;

    QTransform oldTransform = p->worldTransform();
    p->scale(1 / scale, 1 / scale);

    qreal y = 0;
    bool initial = true;
    qreal px = m_coord.x() * scale;
    qreal py = m_coord.y() * scale;
    QSizeF scaledSize = m_size * scale;

    if (m_type == TEXTAREA) {
        if (alignment == Qt::AlignHCenter)
            px += scaledSize.width() / 2;
        else if (alignment == Qt::AlignRight)
            px += scaledSize.width();
    }

    QRectF bounds;
    if (m_size.height() != 0)
        bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.

    bool appendSpace = false;
    QVector<QString> paragraphs;
    QStack<QTextCharFormat> formats;
    QVector<QList<QTextLayout::FormatRange> > formatRanges;
    paragraphs.push_back(QString());
    formatRanges.push_back(QList<QTextLayout::FormatRange>());

    for (int i = 0; i < m_tspans.size(); ++i) {
        if (m_tspans[i] == LINEBREAK) {
            if (m_type == TEXTAREA) {
                if (paragraphs.back().isEmpty()) {
                    QFont font = p->font();
                    font.setPixelSize(font.pointSizeF() * scale);

                    QTextLayout::FormatRange range;
                    range.start = 0;
                    range.length = 1;
                    range.format.setFont(font);
                    formatRanges.back().append(range);

                    paragraphs.back().append(QLatin1Char(' '));;
                }
                appendSpace = false;
                paragraphs.push_back(QString());
                formatRanges.push_back(QList<QTextLayout::FormatRange>());
            }
        } else {
            WhitespaceMode mode = m_tspans[i]->whitespaceMode();
            m_tspans[i]->applyStyle(p, states);

            QFont font = p->font();
            font.setPixelSize(font.pointSizeF() * scale);

            QString newText(m_tspans[i]->text());
            newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
            newText.replace(QLatin1Char('\n'), QLatin1Char(' '));

            bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
            if (appendSpace || prependSpace)
                paragraphs.back().append(QLatin1Char(' '));

            bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));

            if (mode == Default) {
                newText = newText.simplified();
                if (newText.isEmpty())
                    appendSpaceNext = false;
            }

            QTextLayout::FormatRange range;
            range.start = paragraphs.back().length();
            range.length = newText.length();
            range.format.setFont(font);
            range.format.setTextOutline(p->pen());
            range.format.setForeground(p->brush());

            if (appendSpace) {
                Q_ASSERT(!formatRanges.back().isEmpty());
                ++formatRanges.back().back().length;
            } else if (prependSpace) {
                --range.start;
                ++range.length;
            }
            formatRanges.back().append(range);

            appendSpace = appendSpaceNext;
            paragraphs.back() += newText;

            m_tspans[i]->revertStyle(p, states);
        }
    }

    if (states.svgFont) {
        // SVG fonts not fully supported...
        QString text = paragraphs.front();
        for (int i = 1; i < paragraphs.size(); ++i) {
            text.append(QLatin1Char('\n'));
            text.append(paragraphs[i]);
        }
        states.svgFont->draw(p, m_coord * scale, text, p->font().pointSizeF() * scale, states.textAnchor);
    } else {
        for (int i = 0; i < paragraphs.size(); ++i) {
            QTextLayout tl(paragraphs[i]);
            QTextOption op = tl.textOption();
            op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
            tl.setTextOption(op);
            tl.setAdditionalFormats(formatRanges[i]);
            tl.beginLayout();

            forever {
                QTextLine line = tl.createLine();
                if (!line.isValid())
                    break;
                if (m_size.width() != 0)
                    line.setLineWidth(scaledSize.width());
            }
            tl.endLayout();

            bool endOfBoundsReached = false;
            for (int i = 0; i < tl.lineCount(); ++i) {
                QTextLine line = tl.lineAt(i);

                qreal x = 0;
                if (alignment == Qt::AlignHCenter)
                    x -= 0.5 * line.naturalTextWidth();
                else if (alignment == Qt::AlignRight)
                    x -= line.naturalTextWidth();

                if (initial && m_type == TEXT)
                    y -= line.ascent();
                initial = false;

                line.setPosition(QPointF(x, y));

                // Check if the current line fits into the bounding rectangle.
                if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width())
                    || (m_size.height() != 0 && y + line.height() > scaledSize.height())) {
                    // I need to set the bounds height to 'y-epsilon' to avoid drawing the current
                    // line. Since the font is scaled to 100 units, 1 should be a safe epsilon.
                    bounds.setHeight(y - 1);
                    endOfBoundsReached = true;
                    break;
                }

                y += 1.1 * line.height();
            }
            tl.draw(p, QPointF(px, py), QVector<QTextLayout::FormatRange>(), bounds);

            if (endOfBoundsReached)
                break;
        }
    }

    p->setWorldTransform(oldTransform, false);
    p->setOpacity(oldOpacity);
    revertStyle(p, states);
}
Beispiel #6
0
BoxVisualization::BoxVisualization() {
  x = 0;
  y = 0;
  w = 240;
  h = 11*GRID_SIZE;
  setDelay(0);

  waves = Waves();
  waves.setPos(ofPoint(285,375));
  
  tline1.w = w;
  tline1.duration = 40;
  tline1.setDelay(0);
  
  tline2.y = h;
  tline2.w = w;
  tline2.duration = 40;
  tline2.setDelay(0);
  
  texts.clear();
  int textDelay = -55;
  // Top Left
  texts.push_back(newText("SYSTEM SUMMARY", 5,
                          5, 7,
                          10, delay+textDelay,
                          COLOR_135,
                          false));
  // Top Right
  texts.push_back(newText("WAVES VISUALIZATION", 5,
                          w-5, 7,
                          10, delay+textDelay-5,
                          COLOR_55,
                          true));
  // Bottom Right
  texts.push_back(newText("HIGH LOAD", 5,
                          w-5, h-18,
                          10, delay+textDelay-10,
                          COLOR_55,
                          true));
  texts.push_back(newText("ALL ACTIVITY", 5,
                          w-4, h-11,
                          10, delay+textDelay-10,
                          COLOR_55,
                          true));
  // Bottom Left
  texts.push_back(newText("ANALYSIS OF", 5,
                          5,h-18,
                          10, delay+textDelay-15,
                          COLOR_55,
                          false));
  texts.push_back(newText("SYSTEM UTILIZATION", 5,
                          5,h-11,
                          10, delay+textDelay-15,
                          COLOR_55,
                          false));
  
  // Animation settings
  events.clear();
  newEvent(0, 300, 0, 1); // intro
  newEvent(0, -1, 1, 1); // main
  currentEvent = events[0];
  
  updateDependencyEvents();
  updateDependencyDelays(getDelay());
}
Beispiel #7
0
void
main(int argc, char **argv)
{
    void *chain;
    int st;
    char check1 = 0, check2 = 1;
    char name[20];
    char password[20];
    char message[80];
    LIA foo;

    static char msg[] = "This is some text\n"
			"That can be found\n"
			"In a text object\n"
			"At the bottom of the sea\n";

    static ListItem menu[] = {
	/* menuitems need hotkeys */
	{ "A", "Choice A" },
	{ "B", "Choice B" },
	{ "C", "Choice C" },
	{ "D", "Choice D" },
	{ "E", "Choice E" },
	{ "F", "Choice F" },
	{ "G", "Choice G" },
	{ "H", "Choice H" },
    };
    #define NR_MENU	(sizeof menu / sizeof menu[0])

    static ListItem list[] = {
	{ "A", "Choice A", 0, 1 },
	{ "B", "Choice B", 0, 0 },
	{ "C", "Choice C", 0, 0 },
    } ;
    #define NR_LIST	(sizeof list / sizeof list[0])

    strcpy(name, "Fernando Poo");
    name[0] = 0xff;
    strcpy(password, "Sekret");
    strcpy(message, "A MESSAGE");

    setHelpRoot(".");

    chain = ObjChain(newOKButton(1,"OK", 0, 0),
		     newCheck(0,0,"A CHECK ITEM GOES PLONK",0,&check1,0,"demo.html"));
    chain = ObjChain(chain, newCancelButton(2,"CANCEL", 0, "demo.html"));
    chain = ObjChain(chain, newCheck(0,2,0,"Check | your hat?",&check2,0,"demo.html"));
    chain = ObjChain(chain, newString(4,3,10, sizeof name, name,
				      "Name", "Your name", 0, "demo.html"));
    chain = ObjChain(chain, newPWString(0,7,10, sizeof password, password,
				      0, "Your password", 0, "demo.html"));
    chain = ObjChain(chain, newString(0,10,10, sizeof message, message,
				      "String Title", 0, 0, "demo.html"));

    chain = ObjChain(chain, newMenu(30,0,-1,-1,
				    NR_MENU,menu,"A MENU","",
				    MENU_SELECTION, menucallback,"demo.html"));
    chain = ObjChain(chain, list_ying = newList(40,0,-1,-1,
				    NR_LIST,list,"A LIST","",
				    CHECK_SELECTED,0,"demo.html"));
    chain = ObjChain(chain, list_yang = newRadioList(54,0,-1,-1,
					 NR_LIST,list,"SAME LIST","",
					 HIGHLIGHT_SELECTED,0,"demo.html"));

    chain = ObjChain(chain, newText(40,7,20,3,strlen(msg),"Text",0,msg,0,"demo.html"));

    init_dialog();
    if (argc > 1) {
	switch (atoi(argv[1])) {
	default:
		use_helpline("[TAB] to move, [ESC] to exit");
		st = MENU(chain, 0, 0, "title",
		   "SCIENTIFIC PROGRESS\nGOES BONK", FANCY_MENU|ALIGN_RIGHT);
		if (st == MENU_ERROR)
		    perror("MENU");
		break;

	case 1:
		use_helpline("This is an error message");
		Error("Nothing in particular");
		break;

	case 2:
		use_helpline("Counting down");
		errno = 0;
		MENU(0,-1,-1 ,0, " ONE ", 0);
		usleep(400000);
		use_helpline("tick");
		MENU(0,-1,-1, 0, " TWO ", 0);
		usleep(400000);
		use_helpline("tick");
		MENU(0,-1,-1, 0, "THREE", 0);
		usleep(400000);
		break;
	case 4:
		foo = newLIA(0,0);
		addToLIA(foo, "1", "first", 0);
		addToLIA(foo, "2", "second", 0);
		addToLIA(foo, "3", "third", 0);
		addToLIA(foo, "4", "forth", 0);
		addToLIA(foo, "5", "fifth", 0);

		chain = newListWidget(0,0,18,3,foo,"title", 0,0,0,0);
		chain = ObjChain(chain, newCancelButton(0, "Done", 0, 0));

		st = MENU(chain, -1, -1, "list widget", 0, 0);
		if (st == MENU_ERROR)
		    perror("MENU");
		break;
	}
    }
    else {
	use_helpline("[TAB] or the mouse to navigate, [ESC] to exit");
	st = MENU(chain, -1, -1, "title",
		    "SCIENTIFIC PROGRESS\nGOES BONK", ALIGN_RIGHT);
	if (st == MENU_ERROR)
	    perror("MENU");
    }
    end_dialog();
    adump();
}
void TimeLabelAction::setText(QString s) {
	_text = s;
	emit newText(s);
}
Beispiel #9
0
 void Clipboard::_SetText(const ValueList& args, KValueRef result)
 {
     args.VerifyException("setText", "s");
     std::string newText(args.GetString(0, ""));
     this->SetText(newText);
 }
Beispiel #10
0
Var* ff_list_dv_modules(vfuncptr func, Var* args)
{
	char* mod_name;
	Var* mod_var;
	Var* mlst;
	int i, n;
	char** mnlst;
	int len;
	dvModule* m;
	Var* v            = NULL;
	char* module_name = NULL;

	Alist alist[2]; /* arguments list */

	alist[0]      = make_alist("module", ID_STRING, NULL, &module_name);
	alist[1].name = NULL;

	if (parse_args(func, args, alist) == 0) {
		parse_error("%s(): argument parsing failed.", func->name);
		return NULL;
	}

	if (module_name != NULL) {
		// Find all the stuff in the specified module.

		// Locate the module
		if (Narray_find(loaded_modules, module_name, (void*)&v) != -1) {
			char* func_name;
			m     = &(V_MODULE(v));
			n     = Narray_count(m->functions);
			mnlst = (char**)calloc(n, sizeof(char*));
			for (i = 0; i < n; i++) {
				Narray_get(m->functions, i, &func_name, NULL);
				mnlst[i] = strdup(func_name);
			}
			return (newText(n, mnlst));
		} else {
			parse_error("Unable to find module %s\n", module_name);
			return (NULL);
		}
	} else {
		n     = Narray_count(loaded_modules);
		mnlst = (char**)calloc(n, sizeof(char*));
		if (mnlst == NULL) {
			return NULL;
		}

		for (i = 0; i < n; i++) {
			Narray_get(loaded_modules, i, &mod_name, (void**)&mod_var);
			m = &V_MODULE(mod_var);

			len = strlen(mod_name) + 1;
			if (m->ver) {
				len += strlen(m->ver) + 1;
			}

			mnlst[i] = (char*)calloc(len, sizeof(char));

			if (mnlst[i] == NULL) { /* memory failure */
				parse_error("Mem allocation error.\n");
				while (--i >= 0) {
					free(mnlst[i]);
				}
				free(mnlst);
				return NULL;
			}

			if (m->ver && strcmp(m->ver, "") == 0) {
				/* include version */
				sprintf(mnlst[i], "%s.%s", mod_name, m->ver);
			} else {
				/* no version associated with the module */
				sprintf(mnlst[i], "%s", mod_name);
			}
		}

		mlst = newText(n, mnlst);
		return mlst;
	}
}
Beispiel #11
0
void readMessageCB (GtkWidget *msg, gpointer user_data)
{
  newText(gtk_entry_get_text(GTK_ENTRY(msg)));
  gtk_entry_set_text(GTK_ENTRY(msg),"");
}
Beispiel #12
0
void drawBoard(int page) {
	switch(page) {
		case 0:
			registerBody("NULL", newHeader(60, 1, "INTRODUCTION", -1));

			registerBody("NULL", newText(65, 9, "STOP!", 0));
			registerBody("NULL", newText(40, 12, "    Welcome to *hammertime*, a text-based \"visual\" framework made and functional with the language C.", max(60, screen.width-40)));
			registerBody("NULL", newText(40, 15, "    The original idea was to create a simple yet useful     framework to use in projects using C, that didn't require   much knowledge in programming.", max(60, screen.width-40)));

			registerBody("NULL", newText(40, 19, "    This little guide will help you with the basics of      *hammertime*. The window on the left indicates the page     you're on. To proceed to the next page, type 'next' (or     'n'). To return to the previous page, type 'prev' (or 'p'). Or if you want you can just type the page's number and pressenter.", max(60, screen.width-40)));
			registerBody("NULL", newText(40, 26, "    Type 'exit' at any time to leave this guide.", 0));

			registerBody("NULL", newText(45, 32, "https://github.com/RenatoGeh/hammertime/wiki", 0));
		break;
		case 1:
			registerBody("NULL", newHeader(60, 1, "USING *HAMMERTIME*", -1));

			registerBody("NULL", newText(40, 10, "    First of all, lets see how to include *hammertime* in   any C source file.", 60));
			registerBody("NULL", newText(40, 13, "    Make sure all files from *hammertime* are in the same   folder as your project.", 60));
			registerBody("NULL", newText(40, 16, "    Just as any other library, you'll need to include       \"hammertime.h\" in the beginning of your C project(#include  \"hammertime.h\").", 60));
			registerBody("NULL", newText(40, 20, "    Instead of a \"int main()\" function, you'll write the    things *hammertime* will print in a \"int run()\" function.", 60));
			registerBody("NULL", newText(40, 23, "    But just as a normal C source file, you can write other functions as well.", 60));
			registerBody("NULL", newText(40, 25, "    Example of a simple *hammertime* project:", 60));
			registerBody("NULL", newTextBox(40, 29, "#include \"hammertime.h\"", 40, '#'));
		break;
		case 2:
			registerBody("NULL", newHeader(60, 1, "BODIES AND BASIC DRAWING", -1));

			registerBody("NULL", newText(40, 10, "    In *hammertime*, the basic thing you'll need to learn is how to create (or register) \"bodies\" and make them visible.", 60));
			registerBody("NULL", newText(40, 13, "    A body is some sort of object, and it may vary from a simple text to a circle made of \"$\".", 60));
			registerBody("NULL", newText(40, 16, "    To create a simple body you follow this model:", 60));
			registerBody("NULL", newText(40, 19, "       registerBody(name, newThing(thing parameters));", 60));
		break;
	}
}
Beispiel #13
0
void basics() {
	/*************** HAMMERTIME BASICS ***************/

	/* Creating a Text Body:
	 * newText accepts four arguments:
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. A String with the text.
	 *		4. Wrap mode:
	 *			= -1 never wraps.
	 *			= 0 wraps on end of screen.
	 *			= n>0 wraps after n characters.
	 *
	 *	Hammertime works the same way as most frameworks,
	 *	the origin (0,0) is set to be the top-left corner 
	 * of the screen.
	 * 
	 * Note: '\n' does not work very well with Hammertime's Text. 	
	*/
	Body *caption = newText(5, 2, "Hello Hammertime!", 0);

	/* Registering a Body:
	 * registerBody accepts two arguments:
	 *		
	 *		1. A name for the Body.
	 *		2. The pointer to the Body.
	 *
	 *	Names will be used to 'kill' or 'get' Bodies.
	*/
	registerBody("hello", caption);

	/* Drawing a Rectangle:
	 * newRectangle accepts six arguments:
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. The rectangle's width.
	 *		4. The rectangle's height.
	 *		5. The rectangle's drawing character.
	 *		6. Draw mode:
	 *			= 'l' line mode -> draws the shape's contour.
	 *			= 'f' fill mode -> fills the shape completely.
	 *
	 *	The drawing character will be used to draw the shape.
	 * This character will be used both in line and fill mode,
	 * and will also work as a 'default paint' when we see
	 * Strokes.
	 * All Bodies are positioned at (x,y) where x and y are 
	 * the top left corner of the object.
	*/
	Body *rect = newRectangle(5, 5, 8, 4, '~', 'f');
	registerBody("rect", rect);

	/* Text + Rectangle = TextBox:
	 *	newTextBox accepts five arguments: 
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. A String with the desired text.
	 *		4. Wrap mode.
	 *		5. The rectangle's drawing character.
	 *	
	 *	TextBox automatically calculates the width and height
	 *	necessary for drawing the rectangle according to the
	 * given text.
	 * Text will be 'glued in' into the Rectangle, meaning there
	 * will be no spacing between the outline and the text.
	 * We will later see how we can override that with the use
	 * of Tables.
	*/
	Body *tb = newTextBox(5, 12, "Help! I'm trapped!", 9, '#');
	registerBody("tb", tb);

	/* Goin' round (Circle):
	 * newCircle accepts five arguments:
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. The circle's radius.
	 *		4. The drawing character.
	 *		5. Draw mode.
	 *		
	 * In Hammertime Circles are actually "pseudo-circles" due to
	 * the console's font dimensions. If the font's width is different
	 * than its height, we will get an ellipse opposed to a circle.
	 * This could be fixed by getting the console's current font, but
	 * due to portability issues and OS dependent requirements, we have
	 * left it this way for now.
	*/
	Body *circle = newCircle(30, 2, 5, 'O', 'l');
	registerBody("circle", circle);

	/* Point:
	 * newPoint accepts three arguments:
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. The drawing character.
	 *
	 *	Points are the most basic shapes in Hammertime. They
	 * are consisted of only one character.
	 * In this tutorial we've drawn the point in the center of
	 * the previous Body, a circle.
	*/
	Body *point = newPoint(35, 7, '*');
	registerBody("point", point);

	/* Lines:
	 * newLine accepts five arguments:
	 *
	 *		1. The x-axis coordinate.
	 *		2. The y-axis coordinate.
	 *		3. The size of the line.
	 *		4. Its direction:
	 *			- 'h'=horizontal
	 *			- 'v'=vertical
	 *		5. The drawing character.
	 *
	 *	For now, lines are only vertical or horizontal. We are
	 *	planning on creating a Function Body, in which the user
	 * inputs the mathematical function and Hammertime draws it.
	 * This will then be the most efficient (and easiest) way to
	 * create horizontal or vertical line. 
	*/
	Body *line = newLine(5, 20, 40, 'h', '_');
	registerBody("line", line);

	/* Drawing:
	 * draw accepts no arguments.
	 * 
	 * For Hammertime to know that you're done and that you
	 * want to actually draw what you've registered, you must
	 * call 'draw'.
	 * Drawing will cause all the registered Bodies to be drawn
	 * in the order that they were added, meaning that objects that
	 * intersect one another will have their intersection overriden
	 * by the last registered Body's drawing character.
	*/
	draw();
}
Beispiel #14
0
void MainWindow::newFile(void)
{
	if(newText())
		setFileName("");
}