2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
34 #include "osdvector.h"
44 virtual void setSize(UINT w, UINT h); // virtual? really?
45 void setPosition(UINT x, UINT y); // Set position on parent. Even numbers only!!!
46 void createBuffer(); // Make this a root view that goes in the BoxStack
50 void setGap(UINT gap);
51 void setBackgroundColour(const DrawStyle& colour);
52 void setVisible(bool isVisible);
53 void setVideoBackground();
56 // The following are supposed to be abstract functions
57 // However, it is useful to be able to make instances of Boxx
58 // Therefore the following stubs are provided.
59 virtual void preDelete() {}
60 virtual int handleCommand(int) { return 0; }
61 virtual void processMessage(Message*) {}
62 virtual bool mouseMove(int x, int y);
63 virtual bool mouseLBDOWN(int x, int y);
64 virtual bool mouseAndroidScroll(int /* x */, int /* y */, int /* sx */, int /* sy */) { return false; }
65 virtual void deactivateAllControls() {}
69 I think it's functionally equivalent to e.g. delete timers in Boxx::preDelete
70 because the only place where a Boxx is deleted is in
71 BoxStack::remove. There is now a call in BoxStack::remove to Boxx::preDelete
72 The reason for this is to stop timercalls calling BoxStack::update at the
73 same time BoxStack::remove is locked trying to delete the Boxx
77 int getScreenX(); // where is it on screen
79 int getRootBoxOffsetX(); // where is it relative to the top-parent in the boxstack
80 int getRootBoxOffsetY();
81 int getX(); // where is it relative to its parent
82 int getX2(); // .. and the right edge
88 Region* getRegion(); // Not to be used for changing the region
89 Region getRegionR(); // Same but as an object
90 void getRootBoxRegion(Region*);
92 bool getVideoDisplay(VideoDisplay &vd);
94 // Drawing functions level 1
95 void fillColour(const DrawStyle & colour);
96 int drawPara(const char* text, int x, int y, const DrawStyle& colour, unsigned int skiplines=0);
98 // Drawing functions level 0
99 void rectangle(UINT x, UINT y, UINT w, UINT h, const DrawStyle& colour);
100 void rectangle(Region& region, const DrawStyle& colour);
102 void drawText(const char* text, int x, int y, const DrawStyle& colour);
103 void drawText(const char* text, int x, int y, int width, const DrawStyle& colour);
104 void drawTextRJ(const char* text, int x, int y, const DrawStyle& colour);
105 void drawTextCentre(const char* text, int x, int y, const DrawStyle& colour);
107 //void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false);
108 void drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion & region);
110 // void drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw=false);
111 void drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float width, float height, Corner corner=TopLeft);
112 void drawClippingRectangle(float x, float y, float w, float h);
115 void drawJpeg(const char *fileName,int x, int y,int *width, int *height);
117 void drawTTChar(int ox, int oy,int x, int y, cTeletextChar c);
118 void drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, DrawStyle& nextColour);
120 /* This is for system which need a locking of the drawing surface to speed up drawing */
121 void startFastDraw();
124 float charWidth(wchar_t c);
126 void add(Boxx*); // a boxx has a set of child boxxs
130 The following function sets the child's parent pointer without adding the child to the children vector.
131 It's a hack (that should be deprecated?) to allow things like WSymbol to be created, do some drawing on
132 the surface and then be deleted again, leaving the drawing present.
133 A better design would be to create many WSymbols - one per symbol and leave them created - then the
134 automatic draw code will be able to redraw the symbols without all that code needing
135 to be in the derived boxx's draw method.
137 void TEMPADD(Boxx* child) { child->setParent(this); }
139 friend class BoxStack;
141 //get the surface this box is drawing to
142 Surface *getSurface();
144 // I want a parent box or a surface.
149 std::vector<Boxx*> children;
150 VideoDisplay vdisplay;
152 void setParent(Boxx*);
154 void removeVisibleChilds(Region & r);
156 static const int paraMargin = 10;
157 UINT paraVSpace{6}; // default gap for drawPara
159 DrawStyle backgroundColour;
160 bool backgroundColourSet{};
163 static char numBoxxes;
173 It's "Boxx" because "Box" was already taken.
175 BoxStack replaces Viewman and handles displaying a stack of root boxxs (boxxs with surfaces) on the screen.
177 Boxx relaces Box, Widget and parts of View and represents a box with or without a surface.
178 Let's call a Boxx with a surface a root box, and a boxx without a surface a child box.
180 A boxx with a surface (root) is like an old View and is handled by BoxStack.
181 A boxx without a surface (child) is like and old Widget and needs to be a child box of another boxx (root or not).
183 Don't add a boxx with a surface to another boxx. That isn't the design.
185 So, when you create a boxx, either that boxx calls createBuffer() on itself,
186 or some other box add()s the new box to itself.
188 Root boxxs can overlap each other - this is managed by boxstack.
189 Child boxxs within a parent boxx do not overlap each other.
190 However, a grandchild box can overlap a child box (but must be entirely contained within the child box).
192 TBBoxx replaces View but is now only a convenience class for the window dressing stuff. It isn't required anymore since
193 all the real work that view used to do is done in Boxx now.
195 Obseleted classes: Box, View, Viewman, Widget, others?
196 No code outside boxx should talk about surfaces anymore. Hopefully.