Show messagebox.h syntax highlighted
/***************************************************************************
messagebox.h - description
-------------------
begin : Fri Sep 27 2002
copyright : (C) 2002 by Brendon Higgins
email : freepop-devel@lists.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef MESSAGEBOX_H_INCLUDED
#define MESSAGEBOX_H_INCLUDED
#include <deque>
#include <ClanLib/display.h>
#include <ClanLib/gui.h>
/**
* An autoscrolling textbox.
* After a set amount of time the top line gets scrolled off the top of
* the screen with a certain speed. Lines of text can be added to the end
* of the paragraph already there, and will be autoscrolled out of
* existence when the time is right.
*/
class MessageBox: public CL_Component {
private:
/**
* The string and the time it was added.
*/
typedef std::pair<std::string, unsigned int> PairType;
/**
* The list of string and time pairs.
*/
typedef std::deque<PairType> ListType;
/**
* The lines in the message box.
*/
ListType lines;
/**
* Are we scrolling a line off?
*/
bool isMoving;
/**
* When did we start scrolling a line off?
* \see isMoving
*/
unsigned int startedMoving;
/**
* Where do we start drawing? This is <0 if we're moving a line.
*/
int yPos;
/**
* How long does a line stay?
*/
unsigned int duration;
/**
* How long does it take to remove a line?
*/
unsigned int removeTime;
/**
* The frame in which things are drawn.
*/
// CL_Component frame;
/**
* The font to draw with.
*/
CL_Font font;
/**
* Notify when to draw.
*/
CL_Slot slotDraw;
public:
/**
* Constructor.
* \param pos Rectangle containing the text box.
* \param parent The parent component.
* \param f Font to use.
* \param d Minimum duration before the line is scrolled off (in ms).
* \param t Time it takes to scroll off a line (in ms).
*/
MessageBox(const CL_Rect& pos, CL_Component* parent, const CL_Font& f,
unsigned int d = 5000, unsigned int t = 1000);
/**
* Add the line to the end of the paragraph.
*/
void addLine(const std::string& s);
/**
* Add a permamnent line to the end of the paragraph.
* Permanent lines never scroll off, and always remain
* below temporary lines.
*/
// void addPermLine(const char* s);
/**
* Changes a permanent line to a new string.
* \param n The index of the permanent line (0, 1, ...).
*/
// void changePermLine(const char *s, const int n);
/**
* Removes the top line.
* \note This doesn't scroll the line off, but removes it
* instantly, putting the lower line(s) in its place.
*/
void removeTopLine();
/**
* Update scroll positions, remove text, etc.
*/
void step();
/**
* Draws it.
*/
void onPaint();
};
#endif /* ndef MESSAGEBOX_H_INCLUDED */
See more files for this project here