PEBL
2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PWidget.h
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/PWidget.h
4
// Purpose: Contains the Definition of the basic gui widget
5
// Author: Shane T. Mueller, Ph.D.
6
// Copyright: (c) 2003-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
#ifndef __PWIDGET_H__
28
#define __PWIDGET_H__
29
30
#include "../base/PEBLObject.h"
31
#include "
PColor.h
"
32
#include "../utility/Defs.h"
33
34
#include <list>
35
#include <iostream>
36
40
41
42
class
PWidget
:
virtual
public
PEBLObjectBase
43
{
44
public
:
45
46
PWidget
();
47
PWidget
(
const
PWidget
& pw);
48
PWidget
(
pInt
x,
pInt
y,
pInt
width,
pInt
height,
bool
visible);
49
virtual
~PWidget
();
50
51
52
//overloaded generic PEBLObjectBase methods
53
virtual
bool
SetProperty
(std::string,
Variant
v);
54
virtual
Variant
GetProperty
(std::string)
const
;
55
virtual
ObjectValidationError
ValidateProperty
(std::string,
Variant
v)
const
;
56
virtual
ObjectValidationError
ValidateProperty
(std::string)
const
;
57
58
virtual
bool
RotoZoom
(
pDouble
angle,
pDouble
zoomx,
pDouble
zoomy,
pInt
smooth);
59
virtual
bool
SetPoint
(
pInt
x,
pInt
y,
PColor
col);
60
virtual
PColor
GetPixel
(
pInt
x,
pInt
y);
62
virtual
void
SetParent
(
PWidget
* widget);
63
virtual
PWidget
*
GetParent
(){
return
mParent
;}
64
virtual
bool
IsParent
(
PWidget
* parent);
65
68
virtual
bool
Draw
(){
return
false
;}
69
72
virtual
void
SetPosition
(
pInt
x,
pInt
y);
73
74
virtual
void
SetZoomX
(
pDouble
x);
75
virtual
void
SetZoomY
(
pDouble
x);
76
virtual
void
SetRotation
(
pDouble
x);
77
78
virtual
void
SetWidth
(
pInt
w);
79
virtual
void
SetHeight
(
pInt
h);
80
81
82
virtual
pInt
GetX
()
const
{
return
mX
;};
83
virtual
pInt
GetY
()
const
{
return
mY
;};
84
85
virtual
pInt
GetWidth
()
const
{
return
mWidth
;};
86
virtual
pInt
GetHeight
()
const
{
return
mHeight
;};
87
88
89
90
91
virtual
void
SetBackgroundColor
(
const
PColor
&color);
92
virtual
PColor
GetBackgroundColor
(){
return
mBackgroundColor
;};
93
97
virtual
bool
AddSubWidget
(
PWidget
* widget);
98
101
virtual
bool
RemoveSubWidget
(
PWidget
* widget);
102
103
virtual
bool
RemoveSubWidgets
();
104
105
107
virtual
bool
RemoveLastSubWidget
();
108
111
virtual
void
Show
();
112
virtual
void
Hide
();
113
virtual
bool
IsVisible
()
const
{
return
mIsVisible
;}
114
115
virtual
std::string
ObjectName
()
const
{
return
"PWidget"
;};
116
117
protected
:
118
120
virtual
std::ostream &
SendToStream
(std::ostream& out)
const
;
121
122
125
pInt
mX
,
mY
;
126
127
//These are the actual locations of the points to be drawn. They differ
128
//from mX and mY in labels and images, which are drawn on their center point.
129
pInt
mDrawX
;
130
pInt
mDrawY
;
131
135
//image file before or after zooming.
136
pInt
mWidth
,
mHeight
;
137
138
//These are properties for rotation/zoom
139
pDouble
mZoomX
;
140
pDouble
mZoomY
;
141
pDouble
mRotation
;
142
144
PColor
mBackgroundColor
;
145
146
//A list of sub-widgets.
147
std::list<PWidget*>
mSubWidgets
;
148
149
//Whether this should actually get drawn.
150
bool
mIsVisible
;
151
154
PWidget
*
mParent
;
155
private
:
156
157
158
159
};
160
161
162
#endif
pInt
#define pInt
Definition
Defs.h:8
pDouble
#define pDouble
Definition
Defs.h:7
PColor.h
ObjectValidationError
ObjectValidationError
Definition
PEBLObject.h:37
PColor
Definition
PColor.h:37
PEBLObjectBase
Definition
PEBLObject.h:73
PWidget
Definition
PWidget.h:43
PWidget::mDrawX
pInt mDrawX
Definition
PWidget.h:129
PWidget::ValidateProperty
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition
PWidget.cpp:188
PWidget::GetProperty
virtual Variant GetProperty(std::string) const
Definition
PWidget.cpp:181
PWidget::Draw
virtual bool Draw()
Definition
PWidget.h:68
PWidget::GetX
virtual pInt GetX() const
Definition
PWidget.h:82
PWidget::PWidget
PWidget()
Definition
PWidget.cpp:37
PWidget::SetPosition
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition
PWidget.cpp:220
PWidget::SendToStream
virtual std::ostream & SendToStream(std::ostream &out) const
An inheritable printing class used by PEBLObjectBase::operator<<.
Definition
PWidget.cpp:280
PWidget::GetWidth
virtual pInt GetWidth() const
Definition
PWidget.h:85
PWidget::Show
virtual void Show()
Definition
PWidget.cpp:396
PWidget::SetBackgroundColor
virtual void SetBackgroundColor(const PColor &color)
Definition
PWidget.cpp:287
PWidget::RemoveLastSubWidget
virtual bool RemoveLastSubWidget()
This is probably pretty useless.
Definition
PWidget.cpp:388
PWidget::GetHeight
virtual pInt GetHeight() const
Definition
PWidget.h:86
PWidget::SetWidth
virtual void SetWidth(pInt w)
Definition
PWidget.cpp:265
PWidget::SetZoomX
virtual void SetZoomX(pDouble x)
This sets the widget's position on its parent widget.
Definition
PWidget.cpp:236
PWidget::SetZoomY
virtual void SetZoomY(pDouble x)
This sets the widget's position on its parent widget.
Definition
PWidget.cpp:247
PWidget::mZoomX
pDouble mZoomX
Definition
PWidget.h:139
PWidget::SetProperty
virtual bool SetProperty(std::string, Variant v)
Definition
PWidget.cpp:142
PWidget::mWidth
pInt mWidth
Definition
PWidget.h:136
PWidget::ObjectName
virtual std::string ObjectName() const
Definition
PWidget.h:115
PWidget::mSubWidgets
std::list< PWidget * > mSubWidgets
Definition
PWidget.h:147
PWidget::GetPixel
virtual PColor GetPixel(pInt x, pInt y)
Definition
PWidget.cpp:133
PWidget::mBackgroundColor
PColor mBackgroundColor
The background color of the widget. if alpha = 0, will not be painted.
Definition
PWidget.h:144
PWidget::mX
pInt mX
Definition
PWidget.h:125
PWidget::GetY
virtual pInt GetY() const
Definition
PWidget.h:83
PWidget::AddSubWidget
virtual bool AddSubWidget(PWidget *widget)
Definition
PWidget.cpp:330
PWidget::RemoveSubWidgets
virtual bool RemoveSubWidgets()
Definition
PWidget.cpp:353
PWidget::mHeight
pInt mHeight
Definition
PWidget.h:136
PWidget::SetHeight
virtual void SetHeight(pInt h)
Definition
PWidget.cpp:258
PWidget::Hide
virtual void Hide()
Definition
PWidget.cpp:402
PWidget::mY
pInt mY
Definition
PWidget.h:125
PWidget::SetRotation
virtual void SetRotation(pDouble x)
This sets the widget's position on its parent widget.
Definition
PWidget.cpp:273
PWidget::SetPoint
virtual bool SetPoint(pInt x, pInt y, PColor col)
Definition
PWidget.cpp:125
PWidget::~PWidget
virtual ~PWidget()
Definition
PWidget.cpp:111
PWidget::GetParent
virtual PWidget * GetParent()
Definition
PWidget.h:63
PWidget::IsParent
virtual bool IsParent(PWidget *parent)
Definition
PWidget.cpp:323
PWidget::GetBackgroundColor
virtual PColor GetBackgroundColor()
Definition
PWidget.h:92
PWidget::mZoomY
pDouble mZoomY
Definition
PWidget.h:140
PWidget::mParent
PWidget * mParent
Definition
PWidget.h:154
PWidget::RemoveSubWidget
virtual bool RemoveSubWidget(PWidget *widget)
Definition
PWidget.cpp:375
PWidget::IsVisible
virtual bool IsVisible() const
Definition
PWidget.h:113
PWidget::mDrawY
pInt mDrawY
Definition
PWidget.h:130
PWidget::mIsVisible
bool mIsVisible
Definition
PWidget.h:150
PWidget::RotoZoom
virtual bool RotoZoom(pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
Definition
PWidget.cpp:118
PWidget::mRotation
pDouble mRotation
Definition
PWidget.h:141
PWidget::SetParent
virtual void SetParent(PWidget *widget)
This unconditionally sets the parent widget.
Definition
PWidget.cpp:315
Variant
Definition
Variant.h:67
src
objects
PWidget.h
Generated by
1.9.8