PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PTextObject Class Reference

This class simply represent an abstract text-based object. More...

#include <PTextObject.h>

Inheritance diagram for PTextObject:
PWidget PEBLObjectBase PLabel PTextBox PlatformLabel PlatformLabel PlatformTextBox PlatformTextBox

Public Member Functions

 PTextObject ()
 
 PTextObject (const std::string &text)
 
 PTextObject (PTextObject &object)
 
virtual ~PTextObject ()
 
virtual bool SetProperty (std::string, Variant v)
 
virtual Variant GetProperty (std::string) const
 
virtual ObjectValidationError ValidateProperty (std::string, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string) const
 
virtual void SetText (const std::string &text)
 
virtual void SetDirection (int i)
 
virtual std::string GetText () const
 
virtual unsigned long int GetNumCharacters ()
 
- Public Member Functions inherited from PWidget
 PWidget ()
 
 PWidget (const PWidget &pw)
 
 PWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PWidget ()
 
virtual bool RotoZoom (pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
 
virtual bool SetPoint (pInt x, pInt y, PColor col)
 
virtual PColor GetPixel (pInt x, pInt y)
 
virtual void SetParent (PWidget *widget)
 This unconditionally sets the parent widget.
 
virtual PWidgetGetParent ()
 
virtual bool IsParent (PWidget *parent)
 
virtual bool Draw ()
 
virtual void SetPosition (pInt x, pInt y)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomX (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomY (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetRotation (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetWidth (pInt w)
 
virtual void SetHeight (pInt h)
 
virtual pInt GetX () const
 
virtual pInt GetY () const
 
virtual pInt GetWidth () const
 
virtual pInt GetHeight () const
 
virtual void SetBackgroundColor (const PColor &color)
 
virtual PColor GetBackgroundColor ()
 
virtual bool AddSubWidget (PWidget *widget)
 
virtual bool RemoveSubWidget (PWidget *widget)
 
virtual bool RemoveSubWidgets ()
 
virtual bool RemoveLastSubWidget ()
 This is probably pretty useless.
 
virtual void Show ()
 
virtual void Hide ()
 
virtual bool IsVisible () const
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
virtual std::string ObjectName () const
 

Protected Attributes

bool mChanged
 
std::string mText
 
int mDirection
 
- Protected Attributes inherited from PWidget
pInt mX
 
pInt mY
 
pInt mDrawX
 
pInt mDrawY
 
pInt mWidth
 
pInt mHeight
 
pDouble mZoomX
 
pDouble mZoomY
 
pDouble mRotation
 
PColor mBackgroundColor
 The background color of the widget. if alpha = 0, will not be painted.
 
std::list< PWidget * > mSubWidgets
 
bool mIsVisible
 
PWidgetmParent
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 

Detailed Description

This class simply represent an abstract text-based object.

Definition at line 40 of file PTextObject.h.

Constructor & Destructor Documentation

◆ PTextObject() [1/3]

PTextObject::PTextObject ( )

Definition at line 37 of file PTextObject.cpp.

37 :
38 PWidget(0,0,0,0,false),
39 mChanged(true),
40 mText(""),
41 mDirection(1)
42{
43 InitializeProperty("TEXT","");
44 InitializeProperty("DIRECTION",1);
45 InitializeProperty("LINEHEIGHT",0);
46
47}
virtual bool InitializeProperty(std::string name, Variant v)
std::string mText
Definition PTextObject.h:70
PWidget()
Definition PWidget.cpp:37

References PEBLObjectBase::InitializeProperty().

◆ PTextObject() [2/3]

PTextObject::PTextObject ( const std::string &  text)

Definition at line 51 of file PTextObject.cpp.

51 :
52 PWidget(0,0,0,0,false),
53 mChanged(true),
54 mText(std::string(text)),
55 mDirection(1)
56{
57
59 InitializeProperty("DIRECTION",1);
60 InitializeProperty("LINEHEIGHT",0);
61}

References PEBLObjectBase::InitializeProperty(), and mText.

◆ PTextObject() [3/3]

PTextObject::PTextObject ( PTextObject object)

Definition at line 64 of file PTextObject.cpp.

64 :
65 PWidget(0,0,0,0,false),
66 mChanged(true),
67 mText(object.GetText()),
68 mDirection(1)
69{
71 InitializeProperty("DIRECTION",1);
72 InitializeProperty("LINEHEIGHT",0);
73}
virtual std::string GetText() const
Definition PTextObject.h:56

References PEBLObjectBase::InitializeProperty(), and mText.

◆ ~PTextObject()

PTextObject::~PTextObject ( )
virtual

Definition at line 155 of file PTextObject.cpp.

156{
157}

Member Function Documentation

◆ GetNumCharacters()

virtual unsigned long int PTextObject::GetNumCharacters ( )
inlinevirtual

Definition at line 58 of file PTextObject.h.

58{return mText.length();}

References mText.

◆ GetProperty()

Variant PTextObject::GetProperty ( std::string  name) const
virtual

Reimplemented from PWidget.

Reimplemented in PlatformTextBox, PLabel, and PTextBox.

Definition at line 122 of file PTextObject.cpp.

123{
124 return PEBLObjectBase::GetProperty(name);
125}
Variant GetProperty(std::string) const

References PEBLObjectBase::GetProperty().

Referenced by PLabel::GetProperty(), and PTextBox::GetProperty().

◆ GetText()

virtual std::string PTextObject::GetText ( ) const
inlinevirtual

Definition at line 56 of file PTextObject.h.

56{return mText;}

References mText.

Referenced by PEBLEnvironment::GetInput0(), and PEBLObjects::GetText().

◆ ObjectName()

virtual std::string PTextObject::ObjectName ( ) const
inlineprotectedvirtual

Reimplemented from PWidget.

Reimplemented in PLabel, PTextBox, PlatformLabel, PlatformTextBox, PlatformLabel, and PlatformTextBox.

Definition at line 71 of file PTextObject.h.

71{return "PTextObject";};

◆ SendToStream()

virtual std::ostream & PTextObject::SendToStream ( std::ostream &  out) const
inlineprotectedvirtual

An inheritable printing class used by PEBLObjectBase::operator<<.

Reimplemented from PWidget.

Reimplemented in PLabel, PTextBox, PlatformLabel, PlatformTextBox, PlatformLabel, and PlatformTextBox.

Definition at line 67 of file PTextObject.h.

67{return out;};

◆ SetDirection()

void PTextObject::SetDirection ( int  i)
virtual

Definition at line 84 of file PTextObject.cpp.

85{
86 if(dir ==1 | dir == -1)
87 {
88 PEBLObjectBase::SetProperty("DIRECTION",Variant(dir));
89 mDirection = dir;
90 mChanged = true;
91 } else
92 {
93 PError::SignalFatalError("Improper value for direction");
94 }
95}
virtual bool SetProperty(std::string name, Variant v)
void SignalFatalError(const std::string &message)

References mChanged, mDirection, PEBLObjectBase::SetProperty(), and PError::SignalFatalError().

Referenced by SetProperty().

◆ SetProperty()

bool PTextObject::SetProperty ( std::string  name,
Variant  v 
)
virtual

Reimplemented from PWidget.

Reimplemented in PlatformLabel, PlatformTextBox, PLabel, PTextBox, PlatformLabel, and PlatformTextBox.

Definition at line 97 of file PTextObject.cpp.

98{
99
100
101 if(PWidget::SetProperty(name,v))
102 {
103 mChanged = true;
104 return true;
105 }
106 else
107 {
108 if (name == "TEXT")
109 {
110 SetText(v);
111 return true;
112 }
113 else if(name == "DIRECTION")
114 {
115 SetDirection(v);
116 }
117 return PWidget::SetProperty(name,v);
118 }
119}
virtual void SetDirection(int i)
virtual void SetText(const std::string &text)
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142

References mChanged, SetDirection(), PWidget::SetProperty(), and SetText().

Referenced by PLabel::SetProperty(), and PTextBox::SetProperty().

◆ SetText()

void PTextObject::SetText ( const std::string &  text)
virtual

Reimplemented in PlatformLabel.

Definition at line 76 of file PTextObject.cpp.

77{
78 mText = text;
80 mChanged = true;
81}

References mChanged, mText, and PEBLObjectBase::SetProperty().

Referenced by PTextBox::SetProperty(), SetProperty(), PlatformLabel::SetText(), and PlatformTextBox::SetText().

◆ ValidateProperty() [1/2]

ObjectValidationError PTextObject::ValidateProperty ( std::string  name) const
virtual

Reimplemented from PWidget.

Reimplemented in PlatformLabel, PlatformTextBox, PLabel, and PTextBox.

Definition at line 133 of file PTextObject.cpp.

134{
135
137
138 if(ove == OVE_VALID)
139 return ove;
140
141 else if(name == "TEXT" ||
142 name == "WIDTH" ||
143 name == "HEIGHT" ||
144 name == "FONT" ||
145 name == "DIRECTION"||
146 name == "LINEHEIGHT")
147
148 return OVE_VALID;
149 else
151
152}
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40
@ OVE_VALID
Definition PEBLObject.h:39
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PWidget.cpp:188

References OVE_INVALID_PROPERTY_NAME, OVE_VALID, and PWidget::ValidateProperty().

◆ ValidateProperty() [2/2]

ObjectValidationError PTextObject::ValidateProperty ( std::string  name,
Variant  v 
) const
virtual

Reimplemented from PWidget.

Reimplemented in PlatformLabel, PlatformTextBox, PLabel, and PTextBox.

Definition at line 128 of file PTextObject.cpp.

129{
130 return ValidateProperty(name);
131}
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const

References ValidateProperty().

Referenced by PLabel::ValidateProperty(), PTextBox::ValidateProperty(), and ValidateProperty().

Member Data Documentation

◆ mChanged

◆ mDirection

int PTextObject::mDirection
protected

Definition at line 72 of file PTextObject.h.

Referenced by PlatformLabel::RenderText(), and SetDirection().

◆ mText


The documentation for this class was generated from the following files: