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

This class is the basic generic text box. More...

#include <PCanvas.h>

Inheritance diagram for PCanvas:
PWidget PEBLObjectBase PlatformCanvas PlatformCanvas

Public Member Functions

 PCanvas ()
 
 PCanvas (int width, int height, Variant color)
 
 PCanvas (int width, int height)
 
 PCanvas (PCanvas &canvas)
 
virtual ~PCanvas ()
 
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 SetPosition (pInt x, pInt y)
 This sets the widget's position on its parent widget.
 
virtual void SetHeight (int h)
 
virtual void SetWidth (int w)
 
virtual void SetColor (Variant col)
 
virtual std::string ObjectName () const
 
virtual bool GetDrawBackground () 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<<.
 

Protected Attributes

bool mDrawBackground
 
bool mReset
 
- 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 is the basic generic text box.

Definition at line 38 of file PCanvas.h.

Constructor & Destructor Documentation

◆ PCanvas() [1/4]

PCanvas::PCanvas ( )

Definition at line 39 of file PCanvas.cpp.

40{
41 InitializeProperty("WIDTH",Variant(0));
42 InitializeProperty("HEIGHT",Variant(0));
43 InitializeProperty("NAME",Variant("<CANVAS>"));
44
45 mReset = false;
46}
bool mReset
Definition PCanvas.h:67
virtual bool InitializeProperty(std::string name, Variant v)

References PEBLObjectBase::InitializeProperty(), and mReset.

◆ PCanvas() [2/4]

PCanvas::PCanvas ( int  width,
int  height,
Variant  color 
)

Definition at line 50 of file PCanvas.cpp.

50 :
51 PWidget(0,0,0,0,false)
52{
53 InitializeProperty("WIDTH",Variant(width));
54 InitializeProperty("HEIGHT",Variant(height));
55 InitializeProperty("NAME",Variant("<CANVAS>"));
56 InitializeProperty("BGCOLOR",pcol);
57
58 SetHeight(height);
59 SetWidth(width);
60 mReset = false;
61 mDrawBackground = true;
62}
virtual void SetWidth(int w)
Definition PCanvas.cpp:153
virtual void SetHeight(int h)
Definition PCanvas.cpp:145
bool mDrawBackground
Definition PCanvas.h:66
PWidget()
Definition PWidget.cpp:37

References PEBLObjectBase::InitializeProperty(), mDrawBackground, mReset, SetHeight(), and SetWidth().

◆ PCanvas() [3/4]

PCanvas::PCanvas ( int  width,
int  height 
)

Definition at line 64 of file PCanvas.cpp.

64 :
65 PWidget(0,0,0,0,false)
66{
67 InitializeProperty("WIDTH",Variant(width));
68 InitializeProperty("HEIGHT",Variant(height));
69 InitializeProperty("NAME",Variant("<CANVAS>"));
70
71 SetHeight(height);
72 SetWidth(width);
73 mReset = false;
74 mDrawBackground = false;
75
76}

References PEBLObjectBase::InitializeProperty(), mDrawBackground, mReset, SetHeight(), and SetWidth().

◆ PCanvas() [4/4]

PCanvas::PCanvas ( PCanvas canvas)

◆ ~PCanvas()

PCanvas::~PCanvas ( )
virtual

Definition at line 79 of file PCanvas.cpp.

80{
81}

Member Function Documentation

◆ GetDrawBackground()

virtual bool PCanvas::GetDrawBackground ( ) const
inlinevirtual

Definition at line 60 of file PCanvas.h.

60{return mDrawBackground;};

References mDrawBackground.

Referenced by PlatformCanvas::PlatformCanvas().

◆ GetProperty()

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

Reimplemented from PWidget.

Definition at line 122 of file PCanvas.cpp.

123{
124 return PWidget::GetProperty(name);
125}
virtual Variant GetProperty(std::string) const
Definition PWidget.cpp:181

References PWidget::GetProperty().

◆ ObjectName()

std::string PCanvas::ObjectName ( ) const
virtual

Reimplemented from PWidget.

Reimplemented in PlatformCanvas, and PlatformCanvas.

Definition at line 162 of file PCanvas.cpp.

163{
164 return "Canvas";
165}

◆ SendToStream()

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

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

Reimplemented from PWidget.

Reimplemented in PlatformCanvas, and PlatformCanvas.

Definition at line 68 of file PCanvas.h.

68{return out;};

◆ SetColor()

void PCanvas::SetColor ( Variant  col)
virtual

Definition at line 112 of file PCanvas.cpp.

113{
114
115 PEBLObjectBase::SetProperty("BGCOLOR",col);
117
118 //mBackgroundColor = *dynamic_cast<PColor*>(col.GetComplexData()->GetObject().get());
119 mReset = true;
120}
counted_ptr< PEBLObjectBase > GetObject() const
virtual bool SetProperty(std::string name, Variant v)
virtual void SetBackgroundColor(const PColor &color)
Definition PWidget.cpp:287
PComplexData * GetComplexData() const
Definition Variant.cpp:1299
X * get() const
Definition rc_ptrs.h:110

References counted_ptr< X >::get(), Variant::GetComplexData(), PComplexData::GetObject(), mReset, PWidget::SetBackgroundColor(), and PEBLObjectBase::SetProperty().

Referenced by PlatformCanvas::PlatformCanvas(), and SetProperty().

◆ SetHeight()

void PCanvas::SetHeight ( int  h)
virtual

Definition at line 145 of file PCanvas.cpp.

146{
147
148
149 mHeight = h;
150 mReset = true;
151}
pInt mHeight
Definition PWidget.h:136

References PWidget::mHeight, and mReset.

Referenced by PCanvas(), PCanvas(), and SetProperty().

◆ SetPosition()

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

This sets the widget's position on its parent widget.

Sets the location of the upper left-hand corner of the image on the parent widget; unless overridden

Reimplemented from PWidget.

Definition at line 102 of file PCanvas.cpp.

103{
104 mX = x;
105 mY = y;
106 mDrawX = x - GetWidth()/2;
107 mDrawY = y - GetHeight()/2;
110}
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().

◆ SetProperty()

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

Reimplemented from PWidget.

Reimplemented in PlatformCanvas, and PlatformCanvas.

Definition at line 84 of file PCanvas.cpp.

85{
86
87 if(PWidget::SetProperty(name,v))
88 {
89 // If we set it at higher level, don't worry.
90 }
91 else if (name =="WIDTH") SetWidth(v);
92 else if(name == "HEIGHT") SetHeight(v);
93 else if (name == "BGCOLOR") SetColor(v);
94 else return false;
95
96 return true;
97}
virtual void SetColor(Variant col)
Definition PCanvas.cpp:112
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142

References SetColor(), SetHeight(), PWidget::SetProperty(), and SetWidth().

Referenced by PlatformCanvas::SetProperty(), and PlatformCanvas::SetProperty().

◆ SetWidth()

void PCanvas::SetWidth ( int  w)
virtual

Definition at line 153 of file PCanvas.cpp.

154{
155
156 mWidth = w;
157 mReset = true;
158}
pInt mWidth
Definition PWidget.h:136

References mReset, and PWidget::mWidth.

Referenced by PCanvas(), PCanvas(), and SetProperty().

◆ ValidateProperty() [1/2]

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

Reimplemented from PWidget.

Reimplemented in PlatformCanvas.

Definition at line 133 of file PCanvas.cpp.

134{
135
136 return PWidget::ValidateProperty(name);
137}
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PWidget.cpp:188

References PWidget::ValidateProperty().

◆ ValidateProperty() [2/2]

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

Reimplemented from PWidget.

Reimplemented in PlatformCanvas.

Definition at line 128 of file PCanvas.cpp.

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

References ValidateProperty().

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

Member Data Documentation

◆ mDrawBackground

bool PCanvas::mDrawBackground
protected

Definition at line 66 of file PCanvas.h.

Referenced by GetDrawBackground(), PCanvas(), PCanvas(), and PlatformCanvas::PlatformCanvas().

◆ mReset

bool PCanvas::mReset
protected

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