PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PImageBox Class Referenceabstract

#include <PImageBox.h>

Inheritance diagram for PImageBox:
PWidget PEBLObjectBase PlatformImageBox PlatformImageBox

Public Member Functions

 PImageBox ()
 
virtual ~PImageBox ()
 
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 bool LoadImage (const std::string &imagefilename)=0
 
virtual void SetPosition (pInt x, pInt y)
 
virtual void SetSize (int width, int height)
 
virtual std::string ObjectName () const
 
- 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 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<<.
 

Additional Inherited Members

- 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, a subtype of PComplexData, is the base Object class subtypes include sounds, visual objects, etc.

Definition at line 39 of file PImageBox.h.

Constructor & Destructor Documentation

◆ PImageBox()

PImageBox::PImageBox ( )

Definition at line 33 of file PImageBox.cpp.

33 :
34 PWidget()
35{
36 InitializeProperty("NAME",Variant("<IMAGEBOX>"));
37 __SetProps__();
38
39}
virtual bool InitializeProperty(std::string name, Variant v)
PWidget()
Definition PWidget.cpp:37

References PEBLObjectBase::InitializeProperty().

◆ ~PImageBox()

virtual PImageBox::~PImageBox ( )
inlinevirtual

Definition at line 44 of file PImageBox.h.

44{};

Member Function Documentation

◆ GetProperty()

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

Reimplemented from PWidget.

Definition at line 107 of file PImageBox.cpp.

108{
109
110 //PEBLObjectBase::PrintProperties(cout);
111 return PEBLObjectBase::GetProperty(name);
112}
Variant GetProperty(std::string) const

References PEBLObjectBase::GetProperty().

◆ LoadImage()

virtual bool PImageBox::LoadImage ( const std::string &  imagefilename)
pure virtual

This will load a file into the class data, given a file name. height and width are set automatically.

Implemented in PlatformImageBox, and PlatformImageBox.

◆ ObjectName()

virtual std::string PImageBox::ObjectName ( ) const
inlinevirtual

Reimplemented from PWidget.

Reimplemented in PlatformImageBox, and PlatformImageBox.

Definition at line 62 of file PImageBox.h.

62{return "PImageBox";};

◆ SendToStream()

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

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

Reimplemented from PWidget.

Reimplemented in PlatformImageBox, and PlatformImageBox.

Definition at line 68 of file PImageBox.h.

68{return out;};

◆ SetPosition()

void PImageBox::SetPosition ( pInt  x,
pInt  y 
)
virtual

This sets the imagebox's position on its parent widget. It overrides the parent method because images positions are set by their centers.

Reimplemented from PWidget.

Definition at line 44 of file PImageBox.cpp.

45{
46
47
48 //mx/my is the specified position.
49 mX = x;
50 mY = y;
51 // PWidget::SetPosition(x,y);
52 //mdrawxy is the drawn upper-left corner position.
53 mDrawX = x - GetWidth()/2;
54 mDrawY = y - GetHeight()/2;
55
58
59}
virtual bool SetProperty(std::string name, Variant v)
pInt mDrawX
Definition PWidget.h:129
virtual pInt GetWidth() const
Definition PWidget.h:85
virtual pInt GetHeight() const
Definition PWidget.h:86
pInt mX
Definition PWidget.h:125
pInt mY
Definition PWidget.h:125
pInt mDrawY
Definition PWidget.h:130

References PWidget::GetHeight(), PWidget::GetWidth(), PWidget::mDrawX, PWidget::mDrawY, PWidget::mX, PWidget::mY, and PEBLObjectBase::SetProperty().

Referenced by main(), SetProperty(), and SetSize().

◆ SetProperty()

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

Reimplemented from PWidget.

Reimplemented in PlatformImageBox.

Definition at line 79 of file PImageBox.cpp.

80{
81
82
83 //Width and height are not currently 'settable', in that
84 //they are properties of the object.
85
86 if(name == "X") SetPosition(v,mY);
87 else if (name == "Y") SetPosition(mX,v);
88 else if (name == "HEIGHT") SetSize((int)mWidth,v);
89 else if (name == "WIDTH") SetSize(v,(int)mHeight);
90 else if (name =="ZOOMX") SetZoomX(v);
91 else if (name =="ZOOMY") SetZoomY(v);
92 else if (name == "VISIBLE")
93 {
94 if(v.GetInteger())
95 Show();
96 else
97 Hide();
98 }
99
100
101 else return PWidget::SetProperty(name,v);
102
103 return true;
104}
virtual void SetSize(int width, int height)
Definition PImageBox.cpp:61
virtual void SetPosition(pInt x, pInt y)
Definition PImageBox.cpp:44
virtual void Show()
Definition PWidget.cpp:396
virtual void SetZoomX(pDouble x)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:236
virtual void SetZoomY(pDouble x)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:247
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142
pInt mWidth
Definition PWidget.h:136
pInt mHeight
Definition PWidget.h:136
virtual void Hide()
Definition PWidget.cpp:402
pInt GetInteger() const
Definition Variant.cpp:997

References Variant::GetInteger(), PWidget::Hide(), PWidget::mHeight, PWidget::mWidth, PWidget::mX, PWidget::mY, SetPosition(), PWidget::SetProperty(), SetSize(), PWidget::SetZoomX(), PWidget::SetZoomY(), and PWidget::Show().

Referenced by PlatformImageBox::LoadImage(), and PlatformImageBox::SetProperty().

◆ SetSize()

void PImageBox::SetSize ( int  width,
int  height 
)
virtual

Definition at line 61 of file PImageBox.cpp.

62{
63
64
65 mWidth = width;
66 mHeight = height;
67
68 PEBLObjectBase::SetProperty("WIDTH",width);
69 PEBLObjectBase::SetProperty("HEIGHT",height);
70 //Reset position so it gets centered correctly.
72}

References PWidget::mHeight, PWidget::mWidth, PWidget::mX, PWidget::mY, SetPosition(), and PEBLObjectBase::SetProperty().

Referenced by SetProperty().

◆ ValidateProperty() [1/2]

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

Reimplemented from PWidget.

Reimplemented in PlatformImageBox.

Definition at line 121 of file PImageBox.cpp.

122{
123 //All valid properties are also valid Widget properties
125 if(ove == OVE_VALID)
126 {
127 return ove;
128 }
129 else if(name =="WIDTH" ||
130 name == "HEIGHT")
131 return OVE_VALID;
132 else
133
135}
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 PImageBox::ValidateProperty ( std::string  name,
Variant  v 
) const
virtual

Reimplemented from PWidget.

Reimplemented in PlatformImageBox.

Definition at line 115 of file PImageBox.cpp.

116{
117
118 return ValidateProperty(name);
119}
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const

References ValidateProperty().

Referenced by PlatformImageBox::ValidateProperty(), PlatformImageBox::ValidateProperty(), and ValidateProperty().


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