PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PMovie.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/PMovie.cpp
4// Purpose: Contains generic specification for a movie player widget.
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2012-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
28
29#include "PMovie.h"
30#include "../utility/Defs.h"
31#include <iostream>
32
33using std::cout;
34
36 PWidget()
37{
38 InitializeProperty("NAME",Variant("<MOVIE>"));
39 InitializeProperty("FILENAME","UNKNOWN");
40 InitializeProperty("DURATION",0);
41 InitializeProperty("PLAYBACKPOSITION",0);
42 InitializeProperty("VOLUME",1);
43 __SetProps__();
44
45}
46
50void PMovie::SetPosition(int x, int y)
51{
52
53
55 mDrawX = x - GetWidth()/2;
56 mDrawY = y - GetHeight()/2;
57}
58
59void PMovie::SetSize(int width, int height)
60{
61 mWidth = width;
62 mHeight = height;
63
64 PEBLObjectBase::SetProperty("WIDTH",width);
65 PEBLObjectBase::SetProperty("HEIGHT",height);
66
67}
68
69
70void PMovie::SetPlaybackPosition(long unsigned int pos)
71{
73 PEBLObjectBase::SetProperty("PLAYBACKPOSITION",pos);
74
75}
76
77
78void PMovie::SetVolume(long double v)
79{
81}
82
83
84//overloaded generic PEBLObjectBase methods
85bool PMovie::SetProperty(std::string name, Variant v)
86{
87
88 //Width and height are not currently 'settable', in that
89 //they are properties of the object.
90
91 if(name == "X") SetPosition(v,mY);
92 else if (name == "Y") SetPosition(mX,v);
93 else if (name == "HEIGHT") SetSize(v,mWidth);
94 else if (name == "WIDTH") SetSize(mHeight, v);
95 else if (name == "DURATION")
96 PEBLObjectBase::SetProperty("DURATION",v);
97 else if (name == "PLAYBACKPOSITION") SetPlaybackPosition(v);
98 else if (name == "VOLUME") SetVolume((pDouble)v);
99 else if (name == "FILENAME")
100 PEBLObjectBase::SetProperty("FILENAME",v);
101 else if (name == "VISIBLE")
102 {
103 if(v.GetInteger())
104 Show();
105 else
106 Hide();
107 }
108 else return PWidget::SetProperty(name,v);
109
110 return true;
111}
112
113
114
115Variant PMovie::GetProperty(std::string name)const
116{
117
118 return PEBLObjectBase::GetProperty(name);
119}
120
121
123{
125 if((code==OVE_VALID) & (name == "VOLUME"))
126 {
127
128 if((pDouble)v < 0)
129 {
131 }
132 }
133
134 return code;
135}
136
138{
139 //All valid properties are also valid Widget properties
141 if(ove == OVE_VALID)
142 {
143 return ove;
144 }
145 else if(name =="WIDTH" ||
146 name == "HEIGHT"||
147 name == "DURATION"||
148 name == "FILENAME"||
149 name == "PLAYBACKPOSITION" ||
150 name == "VOLUME" )
151
152 return OVE_VALID;
153 else
155}
156
157
158
159//This makes sure that the object properties are synced with the class properties.
160void PMovie::__SetProps__()
161{
162
163 SetProperty("X",mX);
164 SetProperty("Y",mY);
165 SetProperty("VISIBLE",mIsVisible);
166 SetProperty("WIDTH",mWidth);
167 SetProperty("HEIGHT",mHeight);
168
169}
#define pDouble
Definition Defs.h:7
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_INVALID_PROPERTY_VALUE
Definition PEBLObject.h:42
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40
@ OVE_VALID
Definition PEBLObject.h:39
virtual bool InitializeProperty(std::string name, Variant v)
virtual bool SetProperty(std::string name, Variant v)
Variant GetProperty(std::string) const
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PMovie.cpp:122
virtual bool SetProperty(std::string, Variant v)
Definition PMovie.cpp:85
virtual void SetSize(int width, int height)
Definition PMovie.cpp:59
virtual Variant GetProperty(std::string) const
Definition PMovie.cpp:115
PMovie()
Definition PMovie.cpp:35
virtual void SetPlaybackPosition(unsigned long int x)
Definition PMovie.cpp:70
virtual void SetVolume(long double vol)
Definition PMovie.cpp:78
virtual void SetPosition(int x, int y)
Definition PMovie.cpp:50
double mPlaybackPosition
Definition PMovie.h:73
pInt mDrawX
Definition PWidget.h:129
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PWidget.cpp:188
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:220
virtual pInt GetWidth() const
Definition PWidget.h:85
virtual void Show()
Definition PWidget.cpp:396
virtual pInt GetHeight() const
Definition PWidget.h:86
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142
pInt mWidth
Definition PWidget.h:136
pInt mX
Definition PWidget.h:125
pInt mHeight
Definition PWidget.h:136
virtual void Hide()
Definition PWidget.cpp:402
pInt mY
Definition PWidget.h:125
pInt mDrawY
Definition PWidget.h:130
bool mIsVisible
Definition PWidget.h:150
pInt GetInteger() const
Definition Variant.cpp:997