The TextEdit is a text widget with uniform formatting and a mask that can be printed or exported to an image file. More...
#include <TextEdit.h>
Public Member Functions | |
virtual void | addProperties (PropertyProxy *pp) |
bool | adjustBox () const |
QString | fontString () const |
bool | isTextAsData () const |
virtual void | polish () |
virtual void | properties (PropertyWidget *w) const |
virtual void | removeProperties (PropertyProxy *pp) |
void | setAdjustBox (bool t) |
void | setFontString (QString fs) |
virtual void | setProperty (uint wid, int pid, QVariant val) |
void | setText (QString t) |
void | setTextAsData (bool b) |
QString | text () const |
TextEdit (QWidget *parent=0) | |
virtual void | update () |
virtual const QString & | xml_tagName () const |
~TextEdit () | |
Static Public Attributes | |
static const QString | xmlTextEditTag = "TextEdit" |
Protected Member Functions | |
void | adjustSize () |
void | adjustSize (int &width, int &height) |
virtual void | paint (QPainter &p, double dotpercm, int w, int h, bool mask) |
virtual void | setPrintSize (double dotpercm) |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
Protected Attributes | |
bool | _adjustBox |
QString | _text |
bool | _textAsData |
Static Protected Attributes | |
static uint | _category = PropertyProxy::uniqueId() |
static uint | _tabFormat = PropertyProxy::uniqueId() |
Properties | |
bool | adjustBox |
QString | font |
QString | text |
bool | textAsData |
The TextEdit is a text widget with uniform formatting and a mask that can be printed or exported to an image file.
SciFigs::TextEdit::TextEdit | ( | QWidget * | parent = 0 | ) |
References _adjustBox, _text, _textAsData, adjustSize(), SciFigs::GraphicObject::setTransparentMask(), QGpCoreTools::tr(), and TRACE.
: GraphicObject(parent) { TRACE; _text=tr( "No text" ); _adjustBox=true; _textAsData=true; setTransparentMask(true); adjustSize(); }
void SciFigs::TextEdit::addProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Setup property editor
Reimplemented from SciFigs::GraphicObject.
References _category, _tabFormat, QGpGuiTools::PropertyProxy::addCategory(), QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), TRACE, and w.
{ TRACE; GraphicObject::addProperties(pp); if( !pp->setCurrentCategory(_category) ) { pp->addCategory(_category, tr("Text"), QIcon( ":/images/TextEdit.png")); } if(pp->setCurrentTab(_tabFormat)) { pp->addReference(this); } else { TextEditProperties * w=new TextEditProperties; pp->addTab(_tabFormat, tr("Format"), w, this); } }
bool SciFigs::TextEdit::adjustBox | ( | ) | const [inline] |
Referenced by properties().
{return _adjustBox;}
void SciFigs::TextEdit::adjustSize | ( | ) | [protected] |
References _adjustBox, SciFigs::GraphicObject::positionChanged(), SciFigs::SciFigsGlobal::screenResolution(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintWidth(), SciFigs::GraphicObject::sizeChanged(), and w.
Referenced by polish(), setPrintSize(), TextEdit(), and update().
{ if(_adjustBox) { int w, h; adjustSize(w, h); if(w!=width() || h!=height()) { setPrintWidth(( w + 1)/SciFigsGlobal::screenResolution()); setPrintHeight(( h + 1)/SciFigsGlobal::screenResolution()); emit positionChanged(); emit sizeChanged(); } } }
void SciFigs::TextEdit::adjustSize | ( | int & | width, |
int & | height | ||
) | [protected] |
QString SciFigs::TextEdit::fontString | ( | ) | const [inline] |
{return font().toString();}
bool SciFigs::TextEdit::isTextAsData | ( | ) | const [inline] |
Referenced by properties().
{return _textAsData;}
void SciFigs::TextEdit::paint | ( | QPainter & | p, |
double | dotpercm, | ||
int | w, | ||
int | h, | ||
bool | mask | ||
) | [protected, virtual] |
Virtual function to be re-implemented for each type of object to paint specific content. It is different than the classical QWidget function of the same type. Actually, the needed resolution is passed as argument as well as the screen width and height of the object. It is called by print().
Nothing is done, calling it in re-implemented function is useless.
Reimplemented from SciFigs::GraphicObject.
References _adjustBox, _text, font, MAX_INT, and TRACE.
{ TRACE; p.setFont(font()); if(_adjustBox) { QRect r=p.boundingRect(0, 0, MAX_INT, MAX_INT, Qt::AlignLeft | Qt::AlignTop, _text); p.drawText(0, 0, r.width(), r.height(), Qt::AlignLeft | Qt::AlignTop, _text); } else { p.drawText(0, 0, w, h, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, _text); } }
void SciFigs::TextEdit::polish | ( | ) | [virtual] |
Ensure that the widget is at least updated once.
Reimplemented from SciFigs::GraphicObject.
References adjustSize(), and TRACE.
{ TRACE; adjustSize(); GraphicObject::polish(); }
void SciFigs::TextEdit::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Reimplemented from SciFigs::GraphicObject.
References _tabFormat, SciFigs::TextEditProperties::AdjustBox, adjustBox(), SciFigs::TextEditProperties::Font, font, QGpGuiTools::PropertyWidget::id(), isTextAsData(), QGpGuiTools::PropertyWidget::setValue(), SciFigs::TextEditProperties::Text, text(), SciFigs::TextEditProperties::TextAsData, and TRACE.
{ TRACE; if(w->id()==_tabFormat) { w->setValue(TextEditProperties::TextAsData, isTextAsData()); w->setValue(TextEditProperties::Text, text()); w->setValue(TextEditProperties::Font, font().toString()); w->setValue(TextEditProperties::AdjustBox, adjustBox()); } else { GraphicObject::properties(w); } }
void SciFigs::TextEdit::removeProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Cleanup property editor
Reimplemented from SciFigs::GraphicObject.
References _category, _tabFormat, QGpGuiTools::PropertyProxy::removeTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), and TRACE.
{ TRACE; GraphicObject::removeProperties(pp); if(pp->setCurrentCategory(_category) ) { pp->removeTab(_tabFormat, this); } }
void SciFigs::TextEdit::setAdjustBox | ( | bool | t | ) | [inline] |
Referenced by setProperty().
{_adjustBox=t;}
void SciFigs::TextEdit::setFontString | ( | QString | fs | ) | [inline] |
{QFont f;f.fromString(fs);setFont(f);}
void SciFigs::TextEdit::setPrintSize | ( | double | dotpercm | ) | [protected, virtual] |
Called before and after printing to adjust the size of object. Normally what you see is what you get, but there might be some slight modification due to rounding error when scaling fonts. All object that offer options to automatically adjust size and if it depends upon fonts must re-implement this function.
The basic implemetation does nothing.
Reimplemented from SciFigs::GraphicObject.
References _adjustBox, adjustSize(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintWidth(), and w.
{ if(_adjustBox) { int w, h; adjustSize(w, h); setPrintWidth(( w + 1)/dotpercm); setPrintHeight(( h + 1)/dotpercm); } }
void SciFigs::TextEdit::setProperty | ( | uint | wid, |
int | pid, | ||
QVariant | val | ||
) | [virtual] |
Set value val to property id, after a user action in property editor
Reimplemented from SciFigs::GraphicObject.
References _tabFormat, SciFigs::TextEditProperties::AdjustBox, SciFigs::TextEditProperties::Font, setAdjustBox(), setText(), setTextAsData(), SciFigs::TextEditProperties::Text, SciFigs::TextEditProperties::TextAsData, TRACE, and update().
{ TRACE; if(wid==_tabFormat) { switch(pid) { case TextEditProperties::TextAsData: setTextAsData(val.toBool()); break; case TextEditProperties::Text: setText(val.toString()); update(); break; case TextEditProperties::Font: { QFont f; if(f.fromString(val.toString()) ) { setFont(f); update(); } } break; case TextEditProperties::AdjustBox: setAdjustBox(val.toBool()); update(); break; default: break; } } else { GraphicObject::setProperty(wid, pid, val); } }
void SciFigs::TextEdit::setText | ( | QString | t | ) | [inline] |
Referenced by DinverDCGui::DCModelViewer::addText(), DampingResults::compute(), LinearFKActiveResults::createObjects(), TFAResults::createObjects(), SpacSelector::createObjects(), createText(), MonoStation::WinResults::loadResults(), ArrayGui::ArrayResponse::setArray(), setProperty(), MonoStation::WinResults::setStations(), LinearFKActiveResults::stackGrids(), MonoStation::StatisticResults::studentTest(), and xml_setProperty().
{_text=t;}
SciFigs::TextEdit::setTextAsData | ( | bool | b | ) | [inline] |
Prevent from text changes when loading *.mkup files usefull for certain result sheets (e.g. geopsyhv).
Referenced by SciFigs::GraphicSheetMenu::addText(), DinverDCGui::DCModelViewer::addText(), and setProperty().
{_textAsData=b;}
QString SciFigs::TextEdit::text | ( | ) | const [inline] |
Referenced by properties().
{return _text;}
void SciFigs::TextEdit::update | ( | ) | [virtual] |
Reimplemented from SciFigs::GraphicObject.
References adjustSize(), and TRACE.
Referenced by DampingResults::compute(), MonoStation::WinResults::loadResults(), ArrayGui::ArrayResponse::setArray(), MonoStation::WinResults::setLayout(), setProperty(), MonoStation::WinResults::setStations(), and MonoStation::StatisticResults::studentTest().
{ TRACE; adjustSize(); GraphicObject::update(); }
XMLMember SciFigs::TextEdit::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore (children and properties) support to your class.
From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:
Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):
static const QString tmp("childrenName"); XMLRestoreAttributeIterator it=map.find(tmp); if(it!=map.end()) { // found attribute "childrenName" }
If the map of attributes is not used:
Q_UNUSED(attributes); if(tag=="x1") return XMLMember(0); else if(tag=="y1") return XMLMember(1); else if(tag=="x2") return XMLMember(2); else if(tag=="y2") return XMLMember(3); else return XMLMember(XMLMember::Unknown);
Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.
if(tag=="anInteger") return XMLMember(0); else if(tag=="aString") return XMLMember(1); else if(tag=="aDouble") return XMLMember(2); return AbstractLine::xml_member(tag, attributes, context)+3;
For the arguments of this function use Macro XML_MEMBER_ARGS.
Reimplemented from SciFigs::GraphicObject.
{ if(tag=="text") return XMLMember(0); else return GraphicObject::xml_member(tag, attributes, context)+1; }
bool SciFigs::TextEdit::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
text property may be considered as Make-up or data This test prevent from altering the text if it is considered as data in case of Make-up restore
Reimplemented from SciFigs::GraphicObject.
References _textAsData, SciFigs::XMLSciFigs::data(), SciFigs::XMLSciFigs::restoring(), and setText().
{ switch(memberID) { case 0: { XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(!scifigsContext->restoring() || !_textAsData || scifigsContext->data()) { setText(content.toString()); } } return true; default: return GraphicObject::xml_setProperty(memberID-1, tag, attributes, content, context); } }
virtual const QString& SciFigs::TextEdit::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GraphicObject.
{return xmlTextEditTag;}
bool SciFigs::TextEdit::_adjustBox [protected] |
Referenced by adjustSize(), paint(), setPrintSize(), and TextEdit().
uint SciFigs::TextEdit::_category = PropertyProxy::uniqueId() [static, protected] |
Reimplemented from SciFigs::GraphicObject.
Referenced by addProperties(), and removeProperties().
uint SciFigs::TextEdit::_tabFormat = PropertyProxy::uniqueId() [static, protected] |
Referenced by addProperties(), properties(), removeProperties(), and setProperty().
QString SciFigs::TextEdit::_text [protected] |
Referenced by adjustSize(), paint(), and TextEdit().
bool SciFigs::TextEdit::_textAsData [protected] |
Referenced by TextEdit(), and xml_setProperty().
const QString SciFigs::TextEdit::xmlTextEditTag = "TextEdit" [static] |
bool SciFigs::TextEdit::adjustBox [read, write] |
QString SciFigs::TextEdit::font [read, write] |
Referenced by adjustSize(), paint(), and properties().
QString SciFigs::TextEdit::text [read, write] |
Referenced by LinearFKActiveResults::stackGrids().
bool SciFigs::TextEdit::textAsData [read, write] |