PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
sdl/PlatformWidget.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/platforms/sdl/PlatformWidget.h
4// Purpose: Contains SDL-specific interface for GUI Objects
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 __PLATFORMWIDGET_H__
28#define __PLATFORMWIDGET_H__
29
30
31#include "../../objects/PWidget.h"
32#include "../../utility/Defs.h"
33#include "SDL.h"
34
39
43
44class PlatformWidget: virtual public PWidget
45{
46public:
47
49 virtual ~PlatformWidget();
50
51
53 virtual bool Draw();
54
56
57 // virtual SDL_Surface * GetSDL_Surface();
58 virtual SDL_Texture * GetSDL_Texture();
59
60 void SetParent(PlatformWidget * parent);
61
62#ifdef SD2_DELETE
63 //For sdl2, lets try to get rid of 'parent surface' notion,
64 //and use 'parent widget' instead, which is part of PWidget
65 virtual void SetParentSurface(SDL_Surface * surface);
66#endif
67
68 SDL_Surface * GetSurface(){return mSurface;};
69
70 virtual bool SetRenderer(SDL_Renderer* renderer);
71 SDL_Renderer* GetRenderer(){return mRenderer;};
72 virtual bool AddToParentWidget(PlatformWidget * parent);
73 virtual bool AddSubWidget(PlatformWidget * widget);
74 virtual bool RemoveSubWidget(PlatformWidget * widget);
75 virtual bool RemoveSubWidgets();
77 virtual bool RotoZoom(double angle, double zoomx, double zoomy, int smooth);
78
79
80 //Draws a pixel on the widget.
81 bool SetPoint(int x, int y, PColor col);
82 PColor GetPixel(int x, int y);
83
84
85protected:
86
87 //These are inherited by the SDL-specific widgets:
88 virtual std::ostream & SendToStream(std::ostream& out) const;
89
90 virtual void PrintSubWidgets(std::ostream& out) const;
91 //Obsolete:
92 virtual bool LockSurface();
93 virtual bool UnlockSurface();
94
95 //Size of base 'texture', useful for zoom calculating.
98
99 bool mNeedsTexture; //true for most widgets, false for drawobjects.
100 //Texture shuold only get
101 SDL_Texture * mTexture;
102 SDL_Surface * mSurface;
103 //Widgets get created on a surface,
104 //and transferred to a texture when it gets added to a window.
105 //using addsubwidget.
106 SDL_Renderer * mRenderer;
107
108
109
110};
111
112
113#endif
#define pInt
Definition Defs.h:8
virtual bool AddSubWidget(PlatformWidget *widget)
bool SetPoint(int x, int y, PColor col)
SDL_Surface * mSurface
virtual void PrintSubWidgets(std::ostream &out) const
virtual std::ostream & SendToStream(std::ostream &out) const
An inheritable printing class used by PEBLObjectBase::operator<<.
virtual bool LockSurface()
This needs to be used on some platforms/video cards.
void SetParent(PlatformWidget *parent)
SDL_Texture * mTexture
SDL_Renderer * GetRenderer()
virtual bool Draw()
This method initiates everything needed to display the main window
virtual bool RemoveSubWidget(PlatformWidget *widget)
virtual bool RotoZoom(double angle, double zoomx, double zoomy, int smooth)
This uses the SDL_gfx package to 'rotozoom'.
virtual bool UnlockSurface()
This needs to be used on some platforms/video cards.
SDL_Renderer * mRenderer
virtual bool SetRenderer(SDL_Renderer *renderer)
PColor GetPixel(int x, int y)
SDL_Surface * GetSurface()
virtual SDL_Texture * GetSDL_Texture()
Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
virtual bool AddToParentWidget(PlatformWidget *parent)
virtual bool RemoveSubWidgets()