MythTV  master
DynamicLineArt.h
Go to the documentation of this file.
1 /* DynamicLineArt.h
2 
3  Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19 
20 */
21 
22 
23 #if !defined(DYNAMICLINEART_H)
24 #define DYNAMICLINEART_H
25 
26 #include "Visible.h"
27 #include "BaseActions.h"
28 
29 class MHDynamicLineArt;
30 class MHDLADisplay;
31 
32 class MHDynamicLineArt : public MHLineArt
33 {
34  public:
35  MHDynamicLineArt() = default;
36  ~MHDynamicLineArt() override;
37  const char *ClassName() override // MHLineArt
38  { return "DynamicLineArt"; }
39  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHLineArt
40  void PrintMe(FILE *fd, int nTabs) const override; // MHLineArt
41  void Preparation(MHEngine *engine) override; // MHLineArt
42 
43  // Display function.
44  void Display(MHEngine *d) override; // MHLineArt
45  // Get the opaque area. This is only opaque if the background is.
46  QRegion GetOpaqueArea() override; // MHVisible
47 
48  // This action also has the effect of clearing the drawing.
49  void SetBoxSize(int nWidth, int nHeight, MHEngine *engine) override; // MHVisible
50 
51  // Actions
52  void Clear() override; // MHRoot
53  // These actions set the properties for subsequent drawing but don't affect anything drawn so far.
54  void SetFillColour(const MHColour &colour, MHEngine *engine) override; // MHLineArt
55  void SetLineColour(const MHColour &colour, MHEngine *engine) override; // MHLineArt
56  void SetLineWidth(int nWidth, MHEngine *engine) override; // MHLineArt
57  void SetLineStyle(int nStyle, MHEngine *engine) override; // MHLineArt
58 
59  void GetLineWidth(MHRoot *pResult) override // MHRoot
60  { pResult->SetVariableValue(m_nLineWidth); }
61  void GetLineStyle(MHRoot *pResult) override // MHRoot
62  { pResult->SetVariableValue(m_LineStyle); }
63  void GetLineColour(MHRoot *pResult) override; // MHRoot
64  void GetFillColour(MHRoot *pResult) override; // MHRoot
65  void DrawArcSector(bool fIsSector, int x, int y, int width, int height, int start, int arc, MHEngine *engine) override; // MHRoot
66  void DrawLine(int x1, int y1, int x2, int y2, MHEngine *engine) override; // MHRoot
67  void DrawOval(int x1, int y1, int width, int height, MHEngine *engine) override; // MHRoot
68  void DrawRectangle(int x1, int y1, int x2, int y2, MHEngine *engine) override; // MHRoot
69  void DrawPoly(bool fIsPolygon, int nPoints, const int *xArray, const int *yArray, MHEngine *engine) override; // MHRoot
70 
71  protected:
72  MHDLADisplay *m_picture {nullptr}; // The sequence of drawing actions.
73 };
74 
75 // Actions
76 // Get Line Width - return the current line width.
78 {
79  public:
80  MHGetLineWidth(): MHActionObjectRef(":GetLineWidth") {}
81  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
82  { pTarget->GetLineWidth(pResult); }
83 };
84 
85 // Get Line Style - return the current line style.
87 {
88  public:
89  MHGetLineStyle(): MHActionObjectRef(":GetLineStyle") {}
90  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
91  { pTarget->GetLineStyle(pResult); }
92 };
93 // Get Line Colour - return the current line colour.
95 {
96  public:
97  MHGetLineColour(): MHActionObjectRef(":GetLineColour") {}
98  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
99  { pTarget->GetLineColour(pResult); }
100 };
101 // Get Fill Colour - return the current fill colour.
103 {
104  public:
105  MHGetFillColour(): MHActionObjectRef(":GetFillColour") {}
106  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
107  { pTarget->GetLineWidth(pResult); }
108 };
109 // Clear - reset the drawing
110 class MHClear: public MHElemAction {
111  public:
112  MHClear(): MHElemAction(":Clear") {}
113  void Perform(MHEngine *engine) override // MHElemAction
114  { Target(engine)->Clear(); }
115 };
116 // Draw an arc or a sector (basically a filled arc).
118  public:
119  MHDrawArcSector(const char *name, bool fIsSector): MHActionInt6(name), m_fIsSector(fIsSector) {}
120  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6) override // MHActionInt6
121  { pTarget->DrawArcSector(m_fIsSector, nArg1, nArg2, nArg3, nArg4, nArg5, nArg6, engine); }
122  protected:
124 };
125 // Draw a line.
126 class MHDrawLine: public MHActionInt4 {
127  public:
128  MHDrawLine(): MHActionInt4(":DrawLine") {}
129  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
130  { pTarget->DrawLine(nArg1, nArg2, nArg3, nArg4, engine); }
131 };
132 // Draw an oval.
133 class MHDrawOval: public MHActionInt4 {
134  public:
135  MHDrawOval(): MHActionInt4(":DrawOval") {}
136  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
137  { pTarget->DrawOval(nArg1, nArg2, nArg3, nArg4, engine); }
138 };
139 // Draw a rectangle.
141  public:
142  MHDrawRectangle(): MHActionInt4(":DrawRectangle") {}
143  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
144  { pTarget->DrawRectangle(nArg1, nArg2, nArg3, nArg4, engine); }
145 };
146 // Polygon and PolyLine
147 class MHDrawPoly: public MHElemAction {
148  public:
149  MHDrawPoly(const char *name, bool fIsPolygon): MHElemAction(name), m_fIsPolygon(fIsPolygon) {}
150  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
151  void Perform(MHEngine *engine) override; // MHElemAction
152  protected:
153  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
156 };
157 
158 #endif
void Display(MHEngine *d) override
MHOwnPtrSequence< MHPointArg > m_Points
void SetLineWidth(int nWidth, MHEngine *engine) override
void SetLineStyle(int nStyle, MHEngine *engine) override
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
void Clear() override
void Initialise(MHParseNode *p, MHEngine *engine) override
virtual void Clear()
Definition: Root.h:192
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
void SetFillColour(const MHColour &colour, MHEngine *engine) override
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
void DrawArcSector(bool fIsSector, int x, int y, int width, int height, int start, int arc, MHEngine *engine) override
void Preparation(MHEngine *engine) override
void Perform(MHEngine *engine) override
void PrintArgs(FILE *fd, int nTabs) const override
int m_LineStyle
Definition: Visible.h:117
static int x2
Definition: mythsocket.cpp:61
static const uint16_t * d
void Perform(MHEngine *engine) override
~MHDynamicLineArt() override
void GetLineWidth(MHRoot *pResult) override
Definition: Root.h:43
int FILE
Definition: mythburn.py:139
const char * ClassName() override
void PrintMe(FILE *fd, int nTabs) const override
void Initialise(MHParseNode *p, MHEngine *engine) override
void SetLineColour(const MHColour &colour, MHEngine *engine) override
MHDynamicLineArt()=default
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
MHDLADisplay * m_picture
void DrawLine(int x1, int y1, int x2, int y2, MHEngine *engine) override
void SetBoxSize(int nWidth, int nHeight, MHEngine *engine) override
void GetLineColour(MHRoot *pResult) override
MHDrawArcSector(const char *name, bool fIsSector)
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6) override
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
void DrawOval(int x1, int y1, int width, int height, MHEngine *engine) override
int m_nLineWidth
Definition: Visible.h:116
QRegion GetOpaqueArea() override
void DrawPoly(bool fIsPolygon, int nPoints, const int *xArray, const int *yArray, MHEngine *engine) override
void DrawRectangle(int x1, int y1, int x2, int y2, MHEngine *engine) override
MHDrawPoly(const char *name, bool fIsPolygon)
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
void GetLineStyle(MHRoot *pResult) override
void GetFillColour(MHRoot *pResult) override
static int x1
Definition: mythsocket.cpp:60