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
42class PWidget: virtual public PEBLObjectBase
43{
44public:
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);
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
117protected:
118
120 virtual std::ostream & SendToStream(std::ostream& out) const;
121
122
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.
131
135 //image file before or after zooming.
137
138 //These are properties for rotation/zoom
142
145
146 //A list of sub-widgets.
147 std::list<PWidget*> mSubWidgets;
148
149 //Whether this should actually get drawn.
151
155private:
156
157
158
159};
160
161
162#endif
#define pInt
Definition Defs.h:8
#define pDouble
Definition Defs.h:7
ObjectValidationError
Definition PEBLObject.h:37
pInt mDrawX
Definition PWidget.h:129
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PWidget.cpp:188
virtual Variant GetProperty(std::string) const
Definition PWidget.cpp:181
virtual bool Draw()
Definition PWidget.h:68
virtual pInt GetX() const
Definition PWidget.h:82
PWidget()
Definition PWidget.cpp:37
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:220
virtual std::ostream & SendToStream(std::ostream &out) const
An inheritable printing class used by PEBLObjectBase::operator<<.
Definition PWidget.cpp:280
virtual pInt GetWidth() const
Definition PWidget.h:85
virtual void Show()
Definition PWidget.cpp:396
virtual void SetBackgroundColor(const PColor &color)
Definition PWidget.cpp:287
virtual bool RemoveLastSubWidget()
This is probably pretty useless.
Definition PWidget.cpp:388
virtual pInt GetHeight() const
Definition PWidget.h:86
virtual void SetWidth(pInt w)
Definition PWidget.cpp:265
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
pDouble mZoomX
Definition PWidget.h:139
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142
pInt mWidth
Definition PWidget.h:136
virtual std::string ObjectName() const
Definition PWidget.h:115
std::list< PWidget * > mSubWidgets
Definition PWidget.h:147
virtual PColor GetPixel(pInt x, pInt y)
Definition PWidget.cpp:133
PColor mBackgroundColor
The background color of the widget. if alpha = 0, will not be painted.
Definition PWidget.h:144
pInt mX
Definition PWidget.h:125
virtual pInt GetY() const
Definition PWidget.h:83
virtual bool AddSubWidget(PWidget *widget)
Definition PWidget.cpp:330
virtual bool RemoveSubWidgets()
Definition PWidget.cpp:353
pInt mHeight
Definition PWidget.h:136
virtual void SetHeight(pInt h)
Definition PWidget.cpp:258
virtual void Hide()
Definition PWidget.cpp:402
pInt mY
Definition PWidget.h:125
virtual void SetRotation(pDouble x)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:273
virtual bool SetPoint(pInt x, pInt y, PColor col)
Definition PWidget.cpp:125
virtual ~PWidget()
Definition PWidget.cpp:111
virtual PWidget * GetParent()
Definition PWidget.h:63
virtual bool IsParent(PWidget *parent)
Definition PWidget.cpp:323
virtual PColor GetBackgroundColor()
Definition PWidget.h:92
pDouble mZoomY
Definition PWidget.h:140
PWidget * mParent
Definition PWidget.h:154
virtual bool RemoveSubWidget(PWidget *widget)
Definition PWidget.cpp:375
virtual bool IsVisible() const
Definition PWidget.h:113
pInt mDrawY
Definition PWidget.h:130
bool mIsVisible
Definition PWidget.h:150
virtual bool RotoZoom(pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
Definition PWidget.cpp:118
pDouble mRotation
Definition PWidget.h:141
virtual void SetParent(PWidget *widget)
This unconditionally sets the parent widget.
Definition PWidget.cpp:315