PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PLabel.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/objects/PLabel.cpp
4// Purpose: Contains methods primary visual 'word' structure
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2004-2026 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#include "PLabel.h"
28#include "PFont.h"
29
30#include <string>
31#include <iostream>
32
33using std::cout;
34using std::endl;
35
37 PTextObject("")
38{
39 InitializeProperty("NAME",Variant("<LABEL>"));
40 InitializeProperty("FORMATTED",Variant(0));
42}
43
44
45
46PLabel::PLabel(const std::string & text):
47 PTextObject(text)
48{
49 InitializeProperty("NAME",Variant("<LABEL>"));
50 InitializeProperty("FORMATTED",Variant(0));
52}
53
54
55
56PLabel::PLabel(const PLabel & label):
57 PTextObject(label.GetText())
58{
59 InitializeProperty("NAME",Variant("<LABEL>"));
60 InitializeProperty("FORMATTED",Variant(0));
62}
63
67
68
69bool PLabel::SetProperty(std::string name, Variant v)
70{
71 if(name == "FORMATTED") {
72 // FORMATTED property: 0 or 1
74 return true;
75 }
76 else if(PTextObject::SetProperty(name,v))
77 return true;
78 else return false;
79
80}
81
82
83Variant PLabel::GetProperty(std::string name)const
84{
85 return PTextObject::GetProperty(name);
86}
87
88
90{
91 return ValidateProperty(name);
92}
93
95{
96 // Check for Label-specific properties first
97 if(name == "FORMATTED") {
98 return OVE_VALID;
99 }
100
101 // Then check parent class properties
103
104 if(ove == OVE_VALID)
105 return ove;
106 else
108}
109
111{
112 //Why does this get called 4x with an EasyLabel?
113
114 mX = x;
115 mY = y;
116 mDrawX = x - GetWidth()/2;
117 mDrawY = y - GetHeight()/2;
118 // cout << "Setting label position\n" << x << ","<<y<<"|" << mDrawX << "," << mDrawY<<endl;
121}
122
123
124std::string PLabel::ObjectName()const
125{
126 return "Text Label";
127}
#define pInt
Definition Defs.h:8
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40
@ OVE_VALID
Definition PEBLObject.h:39
@ CDT_LABEL
Definition PEBLObject.h:59
virtual bool InitializeProperty(std::string name, Variant v)
virtual bool SetProperty(std::string name, Variant v)
ComplexDataType mCDT
Definition PEBLObject.h:109
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PLabel.cpp:89
virtual ~PLabel()
Definition PLabel.cpp:64
virtual Variant GetProperty(std::string) const
Definition PLabel.cpp:83
virtual bool SetProperty(std::string, Variant v)
Definition PLabel.cpp:69
PLabel()
Definition PLabel.cpp:36
void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PLabel.cpp:110
virtual std::string ObjectName() const
Definition PLabel.cpp:124
This class simply represent an abstract text-based object.
Definition PTextObject.h:41
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
virtual bool SetProperty(std::string, Variant v)
virtual Variant GetProperty(std::string) const
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