All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties
SciFigs::TextEdit Class Reference

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>

Inheritance diagram for SciFigs::TextEdit:
SciFigs::GraphicObject QGpGuiTools::PropertyContext QGpGuiTools::PropertyItem QGpCoreTools::XMLClass

List of all members.

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

Detailed Description

The TextEdit is a text widget with uniform formatting and a mask that can be printed or exported to an image file.


Constructor & Destructor Documentation

SciFigs::TextEdit::TextEdit ( QWidget *  parent = 0)

References TRACE.

{
  TRACE;
}

Member Function Documentation

bool SciFigs::TextEdit::adjustBox ( ) const [inline]

Referenced by properties().

{return _adjustBox;}
void SciFigs::TextEdit::adjustSize ( ) [protected]
void SciFigs::TextEdit::adjustSize ( int &  width,
int &  height 
) [protected]

References _text, font, MAX_INT, and TRACE.

{
  TRACE;
  QFontMetrics f(font());
  QRect r=f.boundingRect(0, 0, MAX_INT, MAX_INT, Qt::AlignLeft | Qt::AlignTop, _text);
  width=r.width();
  height=r.height();
  if(width < 10) width=10;
  if(height < 10) height=10;
}
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.

void SciFigs::TextEdit::properties ( PropertyWidget w) const [virtual]
void SciFigs::TextEdit::setAdjustBox ( bool  t) [inline]

Referenced by setProperty().

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]
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().

QString SciFigs::TextEdit::text ( ) const [inline]

Referenced by properties().

{return _text;}
void SciFigs::TextEdit::update ( ) [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:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

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;
}

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;}

Member Data Documentation

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]
QString SciFigs::TextEdit::_text [protected]

Referenced by adjustSize(), paint(), and TextEdit().

Referenced by TextEdit(), and xml_setProperty().

const QString SciFigs::TextEdit::xmlTextEditTag = "TextEdit" [static]

Property Documentation

bool SciFigs::TextEdit::adjustBox [read, write]
QString SciFigs::TextEdit::font [read, write]

Referenced by adjustSize(), paint(), and properties().

QString SciFigs::TextEdit::text [read, write]
bool SciFigs::TextEdit::textAsData [read, write]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines