PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PlatformWidget Class Reference

#include <PlatformWidget.h>

Inheritance diagram for PlatformWidget:
PWidget PWidget PEBLObjectBase PEBLObjectBase PlatformCanvas PlatformCanvas PlatformDrawObject PlatformDrawObject PlatformImageBox PlatformImageBox PlatformLabel PlatformLabel PlatformTextBox PlatformTextBox PlatformWindow PlatformWindow

Public Member Functions

 PlatformWidget ()
 
virtual ~PlatformWidget ()
 
virtual bool Draw ()
 This method initiates everything needed to display the main window

 
virtual SDL_Texture * GetSDL_Texture ()
 Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
 
void SetParent (PlatformWidget *parent)
 
SDL_Surface * GetSurface ()
 
virtual bool SetRenderer (SDL_Renderer *renderer)
 
SDL_Renderer * GetRenderer ()
 
virtual bool AddToParentWidget (PlatformWidget *parent)
 
virtual bool AddSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidgets ()
 
virtual bool RotoZoom (double angle, double zoomx, double zoomy, int smooth)
 This uses the SDL_gfx package to 'rotozoom'.
 
bool SetPoint (int x, int y, PColor col)
 
PColor GetPixel (int x, int y)
 
 PlatformWidget ()
 
 PlatformWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PlatformWidget ()
 
virtual bool Draw ()
 
virtual bool RotoZoom (pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
 
virtual bool SetPoint (pInt x, pInt y, PColor col)
 
virtual PColor GetPixel (pInt x, pInt y)
 
- Public Member Functions inherited from PWidget
 PWidget ()
 
 PWidget (const PWidget &pw)
 
 PWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PWidget ()
 
virtual bool SetProperty (std::string, Variant v)
 
virtual Variant GetProperty (std::string) const
 
virtual ObjectValidationError ValidateProperty (std::string, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string) const
 
virtual void SetParent (PWidget *widget)
 This unconditionally sets the parent widget.
 
virtual PWidgetGetParent ()
 
virtual bool IsParent (PWidget *parent)
 
virtual void SetPosition (pInt x, pInt y)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomX (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomY (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetRotation (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetWidth (pInt w)
 
virtual void SetHeight (pInt h)
 
virtual pInt GetX () const
 
virtual pInt GetY () const
 
virtual pInt GetWidth () const
 
virtual pInt GetHeight () const
 
virtual void SetBackgroundColor (const PColor &color)
 
virtual PColor GetBackgroundColor ()
 
virtual bool AddSubWidget (PWidget *widget)
 
virtual bool RemoveSubWidget (PWidget *widget)
 
virtual bool RemoveLastSubWidget ()
 This is probably pretty useless.
 
virtual void Show ()
 
virtual void Hide ()
 
virtual bool IsVisible () const
 
virtual std::string ObjectName () const
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
virtual void PrintSubWidgets (std::ostream &out) const
 
virtual bool LockSurface ()
 This needs to be used on some platforms/video cards.
 
virtual bool UnlockSurface ()
 This needs to be used on some platforms/video cards.
 
virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 

Protected Attributes

pInt mTextureWidth
 
pInt mTextureHeight
 
bool mNeedsTexture
 
SDL_Texture * mTexture
 
SDL_Surface * mSurface
 
SDL_Renderer * mRenderer
 
- Protected Attributes inherited from PWidget
pInt mX
 
pInt mY
 
pInt mDrawX
 
pInt mDrawY
 
pInt mWidth
 
pInt mHeight
 
pDouble mZoomX
 
pDouble mZoomY
 
pDouble mRotation
 
PColor mBackgroundColor
 The background color of the widget. if alpha = 0, will not be painted.
 
std::list< PWidget * > mSubWidgets
 
bool mIsVisible
 
PWidgetmParent
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 

Detailed Description

This is the top-level widget of platform-specific widgets. Widgets inherit from PWidget along two pathways; through PlatformWidget and through their platform-general corresponding widget. This class is used to provide platform-specific drawing mechanisms that may prove useful. For SDL2 branch, the PlatformWidget class shuold ONLY hold a SDL_Texture. Individual subclasses may want SDL_Surface member objects to load things, but these should be transferred into textures on load or modification.

Headless platform widget - base class for all GUI objects All rendering methods are no-ops

Definition at line 44 of file sdl/PlatformWidget.h.

Constructor & Destructor Documentation

◆ PlatformWidget() [1/3]

PlatformWidget::PlatformWidget ( )

Definition at line 47 of file sdl/PlatformWidget.cpp.

47 :
48 mNeedsTexture(true)
49{
51 mSurface = NULL;
52 mTexture = NULL;
53
54 //cout << "Creating null platformwidget\n";
55}
#define NULL
Definition BinReloc.cpp:317
SDL_Surface * mSurface
SDL_Texture * mTexture
SDL_Renderer * mRenderer

References mRenderer, mSurface, mTexture, and NULL.

◆ ~PlatformWidget() [1/2]

PlatformWidget::~PlatformWidget ( )
virtual

Definition at line 57 of file sdl/PlatformWidget.cpp.

58{
59
60
61 //Remove this from its parent (if one exists)
62 if(mParent)
63 {
65 }
66
68
69
70 if(mSurface)
71 {
72
73 SDL_FreeSurface(mSurface);
74 mSurface = NULL;
75 }
76
77 //Don't destroy the 'borrowed' texture of drawobjects.
79 {
80
81 if(mTexture)
82 {
83
84 SDL_DestroyTexture(mTexture);
85 }
86 }
87
88}
PWidget * mParent
Definition PWidget.h:154
virtual bool RemoveSubWidget(PWidget *widget)
Definition PWidget.cpp:375
virtual bool RemoveSubWidgets()

References mNeedsTexture, PWidget::mParent, mSurface, mTexture, NULL, PWidget::RemoveSubWidget(), and RemoveSubWidgets().

◆ PlatformWidget() [2/3]

PlatformWidget::PlatformWidget ( )

◆ PlatformWidget() [3/3]

PlatformWidget::PlatformWidget ( pInt  x,
pInt  y,
pInt  width,
pInt  height,
bool  visible 
)

Definition at line 30 of file validator/PlatformWidget.cpp.

31 : PWidget(x, y, width, height, visible) {
32}
PWidget()
Definition PWidget.cpp:37

◆ ~PlatformWidget() [2/2]

virtual PlatformWidget::~PlatformWidget ( )
virtual

Member Function Documentation

◆ AddSubWidget()

bool PlatformWidget::AddSubWidget ( PlatformWidget widget)
virtual

Definition at line 404 of file sdl/PlatformWidget.cpp.

405{
406 // cout << "Adding subwidget " << *child<<endl;
407
408
409 if(strcmp(child->ObjectName().c_str(),"PlatformMovie")==0)
410 {
411 PError::SignalFatalError("Cannot add movie to another widget\n");
412 } else {
413
414
415 //if(! mRenderer)
416 // {
417 // PError::SignalFatalError("To add a child widget to a parent, renderer must exist.");
418 // exit(0);
419 // }
420
421
422 //This manages the renderer and does a setparent()
423
424
425 //This resets zorder:
427 // child->AddToParentWidget(this);
428 child->SetParent(this);
430
431 }
432
433 return true;
434}
virtual bool AddSubWidget(PWidget *widget)
Definition PWidget.cpp:330
SDL_Renderer * GetRenderer()
virtual bool SetRenderer(SDL_Renderer *renderer)
void SignalFatalError(const std::string &message)

References PWidget::AddSubWidget(), GetRenderer(), PWidget::ObjectName(), SetParent(), SetRenderer(), and PError::SignalFatalError().

Referenced by PEBLObjects::AddObject(), and main().

◆ AddToParentWidget()

bool PlatformWidget::AddToParentWidget ( PlatformWidget parent)
virtual

Definition at line 350 of file sdl/PlatformWidget.cpp.

351{
352
353
354 SetParent(parent);
355
356
357 //Child widgets currently are of one of three types:
358 // * images/canvases have internal mSurfaces that may contain
359 // data but don't have a texture yet
360 // * text objects (labels, textboxes) don't have an msurface,
361 // but when it is first draw()ed/render()ed, a temp surface
362 // will get created and transferred to mTexture, which will
363 //then be used; tmpSurface will be destroyed, and mSurface
364 //not used
365 // * DrawObjects(), which draw directly to the parent texture.
366 // so that no rendercopy'ing is needed. Here, no mSurface and no // mTexture is used.
367
368
369
370
371 //Assign us the parent's renderer. There is only one renderer
372 //per window, and so we can't creat the texture until it gets
373 //added to the window.
374
375 int out = SetRenderer(parent->GetRenderer());
376 return out == 0;
377}
void SetParent(PlatformWidget *parent)

References GetRenderer(), SetParent(), and SetRenderer().

◆ Draw() [1/2]

bool PlatformWidget::Draw ( )
virtual

This method initiates everything needed to display the main window

Reimplemented from PWidget.

Reimplemented in PlatformCanvas, PlatformLine, PlatformThickLine, PlatformRectangle, PlatformSquare, PlatformEllipse, PlatformCircle, PlatformPolygon, PlatformBezier, PlatformImageBox, PlatformLabel, PlatformTextBox, PlatformWindow, PlatformCanvas, PlatformLine, PlatformThickLine, PlatformRectangle, PlatformSquare, PlatformEllipse, PlatformCircle, PlatformPolygon, PlatformBezier, PlatformImageBox, PlatformLabel, PlatformTextBox, and PlatformWindow.

Definition at line 104 of file sdl/PlatformWidget.cpp.

105{
106
107 if(mRenderer)
108 {
109 long unsigned int newWidth = mWidth;
110 long unsigned int newHeight = mHeight;
111
112 if(IsVisible())
113 {
114 //To draw a widget, draw each of the window's subwidgets
115 //(using PlatformWidget::Draw(SDLSurface)
116 //This should be done backwards, so that the last item added
117 //(which is on the front) will be the last item drawn.
118
119
120 std::list<PWidget *>::iterator p = mSubWidgets.end();
121 while(p != mSubWidgets.begin())
122 {
123
124 //decrement iterator--moving backward so we draw things in
125 //reverse order.
126 p--;
127 //Draw the subwidget
128 if((*p)->IsVisible())
129 {
130
131 (*p)->Draw();
132
133 }
134 }
135
136 //Once the widget sub-items are drawn,
137 //draw the widget to its parent.
138
139 if (mParent)
140 {
141 long unsigned int w = mWidth;
142 long unsigned int h = mHeight;
143
144 if(mNeedsTexture)
145 {
146 //SDL_QueryTexture(mTexture,NULL,NULL,&w,&h);
147 w = mTextureWidth;
148 h = mTextureHeight;
149 }
150
151 SDL_Rect fromRect = {0,0,(int)w,(int)h};
152
153 //Check to see if any roto-zooming is needed
154 if(std::abs(mZoomX-1.0)>.001 || std::abs(mZoomY-1.0)>.001 )
155 {
156
157 //We need to reset the sizes.
158 //Calculate the new size.
159
160 newWidth = w * mZoomX;
161 newHeight = h * mZoomY;
162
163 PWidget::SetProperty("WIDTH",newWidth);
164 PWidget::SetProperty("HEIGHT",newHeight);
165 //zoomx and zoomy should take care of setting widths correctly.
166
167
168
169 //these call PWidget::SetZoom
170 SetProperty("ZOOMX",mZoomX);
171 SetProperty("ZOOMY",mZoomY);
172
173 SetPosition(mX,mY); //Reset position so
174 //objects get centered properly
175
176 }
177 else
178 {
179
181 PWidget::SetProperty("HEIGHT", mHeight);
182 PWidget::SetProperty("ZOOMX",1);
183 PWidget::SetProperty("ZOOMY",1);
184 }
185
186
187
188 //The to rect depends on the type of object...
189 //textboxes don't change their to x value;
190 //all others will adjust to self-center.
191
192 SDL_Rect toRect = {static_cast<int>(mDrawX),
193 static_cast<int>(mDrawY),
194 (int)newWidth,
195 (int) newHeight};
196
197
198 //This renders from the texture onto the base window.
199 //we sort of want to render to parent instead.
200 int result;
201 SDL_Texture * parenttexture = dynamic_cast<PlatformWidget*>(mParent)->GetSDL_Texture();
202
203 if(parenttexture)
204 {
205 result = SDL_SetRenderTarget(mRenderer,parenttexture);
206
207 if(result<0)
208 {
209 cerr << " SetRenderTarget failed with error code: " << result << endl;
210
211 cerr << "SDL message: " << SDL_GetError() << endl;
212 cerr << *this << endl;
213 cerr << "Parent:" << parenttexture << endl;
214
215 }
216
217 result = -1;
218 int count = 0;
219 while(result<0 & count++<10)
220 {
221
222 result = SDL_RenderCopyEx(mRenderer, mTexture,
223 &fromRect, &toRect,
224 -mRotation,NULL,SDL_FLIP_NONE);
225
226 if(result<0)
227 {
228 cerr << "SDL_RenderCopyEx failed with error code: " << result << "|" << count<< endl;
229 cerr << "SDL message: " << SDL_GetError() << endl;
230 cerr << *this << endl;
231 cerr << "Texture:" << mTexture << endl;
232
233 }
234 }
235
236 result =SDL_SetRenderTarget(mRenderer,NULL);
237
238 if(result<0)
239 {
240 cerr << "Resetting SDL_SetRenderTarget failed with error code: " << result << endl;
241 cerr << "SDL message: " << SDL_GetError() << endl;
242 cerr << *this << endl;
243 cerr << "Texture:" << mTexture << endl;
244
245 }
246 } else{
247
248
249
250 SDL_SetTextureBlendMode(mTexture, SDL_BLENDMODE_BLEND);
251 result = SDL_RenderCopyEx(mRenderer, mTexture,
252 &fromRect, &toRect,
253 -mRotation,NULL,SDL_FLIP_NONE);
254
255 if(result<0)
256 {
257 cerr << "Rendering failed to NULL texture using SDL_RenderCopyEx with error code: " << result << endl;
258 cerr << "SDL message: " << SDL_GetError() << endl;
259 cerr << *this << endl;
260 cerr << "Texture:" << mTexture << endl;
261
262 }
263
264 }
265 }
266 else
267 {
268
269 // IF there is no parent, this is probably a window or an
270 //unassigned widget
271
272 }
273 }
274 }else{
275
276 //We will sometimes call a Draw() on an object that is not yet assigned
277 //a renderer--not attached to a window, etc.
278 //cout << "Trying to render widget with no renderer" << *this << endl;
279 }
280 return true;
281}
pInt mDrawX
Definition PWidget.h:129
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:220
pDouble mZoomX
Definition PWidget.h:139
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142
pInt mWidth
Definition PWidget.h:136
std::list< PWidget * > mSubWidgets
Definition PWidget.h:147
pInt mX
Definition PWidget.h:125
pInt mHeight
Definition PWidget.h:136
pInt mY
Definition PWidget.h:125
pDouble mZoomY
Definition PWidget.h:140
virtual bool IsVisible() const
Definition PWidget.h:113
pInt mDrawY
Definition PWidget.h:130
pDouble mRotation
Definition PWidget.h:141
virtual SDL_Texture * GetSDL_Texture()
Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
int count
Definition test.cpp:12

References count, GetSDL_Texture(), PWidget::IsVisible(), PWidget::mDrawX, PWidget::mDrawY, PWidget::mHeight, mNeedsTexture, PWidget::mParent, mRenderer, PWidget::mRotation, PWidget::mSubWidgets, mTexture, mTextureHeight, mTextureWidth, PWidget::mWidth, PWidget::mX, PWidget::mY, PWidget::mZoomX, PWidget::mZoomY, NULL, PWidget::SetPosition(), and PWidget::SetProperty().

Referenced by PlatformCanvas::Draw(), PlatformImageBox::Draw(), PlatformLabel::Draw(), PlatformTextBox::Draw(), and PEBLObjects::Draw().

◆ Draw() [2/2]

◆ GetPixel() [1/2]

PColor PlatformWidget::GetPixel ( int  x,
int  y 
)

Definition at line 295 of file sdl/PlatformWidget.cpp.

296{
297 if(mSurface)
298 {
300 }else{
301
302 return PColor(0,0,0,0);
303 }
304
305}
PColor GetPixelColor(SDL_Surface *surface, int x, int y)
This extracts the color of a pixel.

References SDLUtility::GetPixelColor(), and mSurface.

Referenced by PEBLObjects::GetPixelColor().

◆ GetPixel() [2/2]

PColor PlatformWidget::GetPixel ( pInt  x,
pInt  y 
)
virtual

Reimplemented from PWidget.

Definition at line 55 of file validator/PlatformWidget.cpp.

55 {
56 // Return black - no pixel data available
57 return PColor(0, 0, 0, 255);
58}

◆ GetRenderer()

SDL_Renderer * PlatformWidget::GetRenderer ( )
inline

Definition at line 71 of file sdl/PlatformWidget.h.

71{return mRenderer;};

References mRenderer.

Referenced by AddSubWidget(), and AddToParentWidget().

◆ GetSDL_Texture()

SDL_Texture * PlatformWidget::GetSDL_Texture ( )
virtual

Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.

Definition at line 344 of file sdl/PlatformWidget.cpp.

345{
346 return mTexture;
347}

References mTexture.

Referenced by PlatformLine::Draw(), PlatformThickLine::Draw(), PlatformRectangle::Draw(), PlatformSquare::Draw(), PlatformEllipse::Draw(), PlatformCircle::Draw(), PlatformPolygon::Draw(), PlatformBezier::Draw(), Draw(), SDLUtility::DrawLine(), and SDLUtility::DrawPixel().

◆ GetSurface()

SDL_Surface * PlatformWidget::GetSurface ( )
inline

Definition at line 68 of file sdl/PlatformWidget.h.

68{return mSurface;};

References mSurface.

◆ LockSurface()

bool PlatformWidget::LockSurface ( )
protectedvirtual

This needs to be used on some platforms/video cards.

Definition at line 527 of file sdl/PlatformWidget.cpp.

528{
529#ifdef SDL2_DELETE
530 if(SDL_MUSTLOCK(mSurface))
531 {
532
533 //cout << "Locking-------->" << endl;
534 //The below returns 0 on success, -1 otherwise,
535 //so reverse it for t/f
536 if(SDL_LockSurface(mSurface)<0)
537 {
538 cerr << "Need to lock surface but can't\n";
539 return false;
540 }
541 return true;
542 }
543
544#endif
545 return false;
546
547}

References mSurface.

◆ PrintSubWidgets()

void PlatformWidget::PrintSubWidgets ( std::ostream &  out) const
protectedvirtual

Definition at line 502 of file sdl/PlatformWidget.cpp.

503{
504
505 if(mSubWidgets.size()>0)
506 {
507
508 std::list<PWidget*>::const_iterator i = mSubWidgets.begin();
509 while(i != mSubWidgets.end())
510 {
511
512 i++;
513 }
514
515 }else{
516
517 }
518
519}

References PWidget::mSubWidgets.

◆ RemoveSubWidget()

bool PlatformWidget::RemoveSubWidget ( PlatformWidget widget)
virtual

Definition at line 438 of file sdl/PlatformWidget.cpp.

439{
440
441
442
444
445 mSubWidgets.remove(dynamic_cast<PWidget*>(child));
446 mSubWidgets.remove(child);
447 //child->SetParent(NULL); //handled in pwidget::remove
448 child->SetRenderer(NULL);
449
450 return true;
451}

References PWidget::mSubWidgets, NULL, PWidget::RemoveSubWidget(), and SetRenderer().

Referenced by PEBLObjects::RemoveObject().

◆ RemoveSubWidgets()

bool PlatformWidget::RemoveSubWidgets ( )
virtual

Reimplemented from PWidget.

Definition at line 456 of file sdl/PlatformWidget.cpp.

457{
458
459 if(mSubWidgets.size()>0)
460 {
461
462 std::list<PWidget*>::iterator i = mSubWidgets.begin();
463 while(i != mSubWidgets.end())
464 {
465 //(*i)->SetParent(NULL);
466 //mSubWidgets.pop_front();
467 //This might not be the right thing to do:
468 //see removesubwidget above.
469 mSubWidgets.remove(*i);
470 //(*i)->SetParent(NULL);
471
472 //RemoveSubWidget(dynamic_cast<PlatformWidget*>(*i));
473 i=mSubWidgets.begin(); //readjust so it points to the start of the list.
474 }
475
476 mSubWidgets.clear();
477 }
478
479 return true;
480}

References PWidget::mSubWidgets.

Referenced by ~PlatformWidget().

◆ RotoZoom() [1/2]

bool PlatformWidget::RotoZoom ( double  angle,
double  zoomx,
double  zoomy,
int  smooth 
)
virtual

This uses the SDL_gfx package to 'rotozoom'.

Definition at line 309 of file sdl/PlatformWidget.cpp.

311{
312
313#ifdef SDL2_DELETE
314 //This is probably handled directly by SDL2
315 SDL_Surface * tmp = rotozoomSurfaceXY(mSurface, angle,zoomx, zoomy, smooth);
316 SDL_FreeSurface(mSurface);
317 mSurface = tmp;
318
319
320 //We need to reset the sizes.
321
322 mWidth = mSurface->w;
323 mHeight = mSurface->h;
324 PWidget::SetProperty("WIDTH", mSurface->w);
325 PWidget::SetProperty("HEIGHT", mSurface->h);
326 if(mSurface)return true;
327 else return false;
328#endif
329 return false;
330}

References PWidget::mHeight, mSurface, PWidget::mWidth, and PWidget::SetProperty().

Referenced by PEBLObjects::RotoZoom().

◆ RotoZoom() [2/2]

bool PlatformWidget::RotoZoom ( pDouble  angle,
pDouble  zoomx,
pDouble  zoomy,
pInt  smooth 
)
virtual

Reimplemented from PWidget.

Definition at line 42 of file validator/PlatformWidget.cpp.

42 {
43 // Store the values but don't render
44 mRotation = angle;
45 mZoomX = zoomx;
46 mZoomY = zoomy;
47 return true;
48}

References PWidget::mRotation, PWidget::mZoomX, and PWidget::mZoomY.

◆ SendToStream() [1/2]

std::ostream & PlatformWidget::SendToStream ( std::ostream &  out) const
protectedvirtual

◆ SendToStream() [2/2]

◆ SetParent()

void PlatformWidget::SetParent ( PlatformWidget parent)

Definition at line 482 of file sdl/PlatformWidget.cpp.

483{
484
485 PWidget::SetParent(parent);
486}
virtual void SetParent(PWidget *widget)
This unconditionally sets the parent widget.
Definition PWidget.cpp:315

References PWidget::SetParent().

Referenced by AddSubWidget(), and AddToParentWidget().

◆ SetPoint() [1/2]

bool PlatformWidget::SetPoint ( int  x,
int  y,
PColor  col 
)

Definition at line 287 of file sdl/PlatformWidget.cpp.

288{
289
290 SDLUtility::DrawPixel(mRenderer,this,x,y,col);
291 return true;
292}
void DrawPixel(SDL_Renderer *renderer, PlatformWidget *pwidget, int x, int y, PColor color)
This sets a pixel to be a certain color.

References SDLUtility::DrawPixel(), and mRenderer.

Referenced by PEBLObjects::SetPoint().

◆ SetPoint() [2/2]

bool PlatformWidget::SetPoint ( pInt  x,
pInt  y,
PColor  col 
)
virtual

Reimplemented from PWidget.

Definition at line 50 of file validator/PlatformWidget.cpp.

50 {
51 // No-op: no pixel manipulation in validator mode
52 return false;
53}

◆ SetRenderer()

bool PlatformWidget::SetRenderer ( SDL_Renderer *  renderer)
virtual

Definition at line 381 of file sdl/PlatformWidget.cpp.

382{
383
384 // cout<<"****************" << *this << "Setting renderer--" << renderer << endl;
385 mRenderer = renderer;
386
387 //Be sure renderer is set for all children, recursively
388 std::list<PWidget*>::iterator i = mSubWidgets.begin();
389 while(i != mSubWidgets.end())
390 {
391
392 PlatformWidget* p = dynamic_cast<PlatformWidget*>(*i);
393 //cout << "setting child renderer:" << **i <<"|" << mRenderer << endl;
394 p->SetRenderer(renderer);
395
396 i++;
397 }
398
399
400 return true;
401}

References mRenderer, PWidget::mSubWidgets, and SetRenderer().

Referenced by AddSubWidget(), AddToParentWidget(), RemoveSubWidget(), and SetRenderer().

◆ UnlockSurface()

bool PlatformWidget::UnlockSurface ( )
protectedvirtual

This needs to be used on some platforms/video cards.

Definition at line 550 of file sdl/PlatformWidget.cpp.

551{
552#ifdef SDL2_DELETE
553 if(SDL_MUSTLOCK(mSurface))
554 {
555 // cout << "------->Unlocking" << endl;
556 SDL_UnlockSurface(mSurface);
557 }
558#endif
559 return true;
560}

References mSurface.

Member Data Documentation

◆ mNeedsTexture

◆ mRenderer

◆ mSurface

◆ mTexture

◆ mTextureHeight

◆ mTextureWidth


The documentation for this class was generated from the following files: