wavelength 1.0.0
Loading...
Searching...
No Matches
rnddrawable.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "os/binstream.h"
6#include "os/prnstream.h"
7#include "rnd/rndobject.h"
8
16class RndDrawable : public virtual RndObject {
17public:
23 RndDrawable() : mShowing(1), mHighlight(0) {
24 }
25
32 ~RndDrawable() override;
33
43 virtual void ListDrawObjects(std::list<RndObject *> &objects);
44
54 virtual void ListDrawables(std::list<RndDrawable *> &drawables);
55
63 virtual void SetShowing(int nShowing) {
64 mShowing = nShowing;
65 }
66
74 virtual void SetHighlight(int nHighlight);
75
85 virtual int DrawShowing() {
86 return 1;
87 }
88
98 void DumpText(PrnStream &stream) override;
99
107 void Save(BinStream &stream) override;
108
119 void Replace(RndObject *pFrom, RndObject *pTo) override;
120
129 void Copy(const RndObject *pSource, int nFlags) override;
130
138 void Load(BinStream &stream) override;
139
150
157 void Draw();
158
170 bool AddDraw(RndDrawable *pDraw, RndDrawable *pBefore);
171
180
188
202 static void CollectChildren(std::list<RndObject *> &objects, RndDrawable *pDrawable) {
203 if (pDrawable == nullptr) {
204 return;
205 }
206 for (RndDrawable *pChild : pDrawable->mDraws) {
207 objects.push_back(pChild);
208 CollectChildren(objects, pChild);
209 }
210 }
211
217 static int sRev;
218
220 int GetShowing() const {
221 return mShowing;
222 }
223
225 const std::list<RndDrawable *> &GetDraws() const {
226 return mDraws;
227 }
228
229protected:
239
249
251
252private:
253 int mHighlight;
254 std::list<RndDrawable *> mDraws;
255};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
void Copy(const RndObject *pSource, int nFlags) override
Copy the showing flag, and the children when the flags request them.
void AcquireDrawRefs()
Take a reference on every child.
void ClearDraws()
Remove every child.
virtual void ListDrawables(std::list< RndDrawable * > &drawables)
Add the drawables to draw this frame to a list.
const std::list< RndDrawable * > & GetDraws() const
Definition rnddrawable.h:225
int mShowing
Definition rnddrawable.h:250
virtual void SetShowing(int nShowing)
Set whether the drawable draws at all.
Definition rnddrawable.h:63
virtual void SetHighlight(int nHighlight)
Set whether the drawable draws with its highlight treatment.
int GetShowing() const
Definition rnddrawable.h:220
virtual void ListDrawObjects(std::list< RndObject * > &objects)
Add the objects the drawable uses to a list.
static void CollectChildren(std::list< RndObject * > &objects, RndDrawable *pDrawable)
Append every draw descendant of a drawable, depth first, each before its descendants.
Definition rnddrawable.h:202
void DumpText(PrnStream &stream) override
Write a description of the drawable.
RndDrawable * Parent()
Find the drawable whose children include this one.
void RemoveDraw(RndDrawable *pDraw)
Remove a child.
void ReleaseDrawRefs()
Drop the reference on every child without emptying the list.
void Save(BinStream &stream) override
Write the showing flag and the names of the children.
~RndDrawable() override
Drop the references on the children.
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a child with another object.
void Load(BinStream &stream) override
Read what Save() wrote.
bool AddDraw(RndDrawable *pDraw, RndDrawable *pBefore)
Add a child before another.
void Draw()
Draw the drawable and then its children, when it is showing.
static int sRev
The format version Save() writes and Load() accepts.
Definition rnddrawable.h:217
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
virtual int DrawShowing()
Draw the drawable alone.
Definition rnddrawable.h:85
RndObject(const char *pszName)
Construct an object and register it under a name.