2 Copyright 2004-2005 Chris Tallon
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
27 using namespace std;
\r
31 #include "message.h"
\r
34 #include "surface.h"
\r
44 virtual void setSize(UINT w, UINT h); // virtual? really?
\r
45 void setPosition(UINT x, UINT y); // Set position on parent. Even numbers only!!!
\r
46 void createBuffer(); // Make this a root view that goes in the BoxStack
\r
47 virtual void draw();
\r
50 void setGap(UINT gap);
\r
51 void setBackgroundColour(const Colour& colour);
\r
52 void setVisible(bool isVisible);
\r
55 // The following are supposed to be abstract functions
\r
56 // However, it is useful to be able to make instances of Boxx
\r
57 // Therefore the following stubs are provided.
\r
58 virtual void preDelete() {}
\r
59 virtual int handleCommand(int x) { return 0; }
\r
60 virtual void processMessage(Message* m) {}
\r
61 virtual bool mouseMove(int x, int y) { return false; }
\r
62 virtual bool mouseLBDOWN(int x, int y) { return false; }
\r
63 virtual bool mouseAndroidScroll(int x, int y,int sx, int sy) { return false; }
\r
64 virtual void deactivateAllControls() {}
\r
68 I think it's functionally equivalent to e.g. delete timers in Boxx::preDelete
\r
69 because the only place where a Boxx is deleted is in
\r
70 BoxStack::remove. There is now a call in BoxStack::remove to Boxx::preDelete
\r
71 The reason for this is to stop timercalls calling BoxStack::update at the
\r
72 same time BoxStack::remove is locked trying to delete the Boxx
\r
76 int getScreenX(); // where is it on screen
\r
78 int getRootBoxOffsetX(); // where is it relative to the top-parent in the boxstack
\r
79 int getRootBoxOffsetY();
\r
80 int getX(); // where is it relative to its parent
\r
81 int getX2(); // .. and the right edge
\r
87 Region* getRegion(); // Not to be used for changing the region
\r
88 Region getRegionR(); // Same but as an object
\r
89 void getRootBoxRegion(Region*);
\r
91 // Drawing functions level 1
\r
92 void fillColour(const Colour& colour);
\r
93 void drawPara(const char* text, int x, int y, const Colour& colour);
\r
95 // Drawing functions level 0
\r
96 void rectangle(UINT x, UINT y, UINT w, UINT h, const Colour& colour);
\r
97 void rectangle(Region& region, const Colour& colour);
\r
99 void drawText(const char* text, int x, int y, const Colour& colour);
\r
100 void drawText(const char* text, int x, int y, int width, const Colour& colour);
\r
101 void drawTextRJ(const char* text, int x, int y, const Colour& colour);
\r
102 void drawTextCentre(const char* text, int x, int y, const Colour& colour);
\r
103 void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false);
\r
104 void drawBitmap(UINT x, UINT y, const Bitmap& bm);
\r
105 void drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw=false);
\r
106 int getFontHeight();
\r
108 void drawJpeg(const char *fileName,int x, int y,int *width, int *height);
\r
110 void drawTTChar(int ox, int oy,int x, int y, cTeletextChar c);
\r
112 /* This is for system which need a locking of the drawing surface to speed up drawing */
\r
113 void startFastDraw();
\r
114 void endFastDraw();
\r
116 int charWidth(char c);
\r
118 void add(Boxx*); // a boxx has a set of child boxxs
\r
119 void remove(Boxx*);
\r
122 The following function sets the child's parent pointer without adding the child to the children vector.
\r
123 It's a hack (that should be deprecated?) to allow things like WSymbol to be created, do some drawing on
\r
124 the surface and then be deleted again, leaving the drawing present.
\r
125 A better design would be to create many WSymbols - one per symbol and leave them created - then the
\r
126 automatic draw code will be able to redraw the symbols without all that code needing
\r
127 to be in the derived boxx's draw method.
\r
129 void TEMPADD(Boxx* child) { child->setParent(this); }
\r
131 friend class BoxStack;
\r
133 //get the surface this box is drawing to
\r
134 Surface *getSurface();
\r
137 vector<Boxx*> children;
\r
139 void setParent(Boxx*);
\r
140 void blt(Region& r);
\r
142 static const int paraMargin = 10;
\r
145 Colour backgroundColour;
\r
146 bool backgroundColourSet;
\r
149 static char numBoxxes;
\r
160 It's "Boxx" because "Box" was already taken.
\r
162 BoxStack replaces Viewman and handles displaying a stack of root boxxs (boxxs with surfaces) on the screen.
\r
164 Boxx relaces Box, Widget and parts of View and represents a box with or without a surface.
\r
165 Let's call a Boxx with a surface a root box, and a boxx without a surface a child box.
\r
167 A boxx with a surface (root) is like an old View and is handled by BoxStack.
\r
168 A boxx without a surface (child) is like and old Widget and needs to be a child box of another boxx (root or not).
\r
170 Don't add a boxx with a surface to another boxx. That isn't the design.
\r
172 So, when you create a boxx, either that boxx calls createBuffer() on itself,
\r
173 or some other box add()s the new box to itself.
\r
175 Root boxxs can overlap each other - this is managed by boxstack.
\r
176 Child boxxs within a parent boxx do not overlap each other.
\r
177 However, a grandchild box can overlap a child box (but must be entirely contained within the child box).
\r
179 TBBoxx replaces View but is now only a convenience class for the window dressing stuff. It isn't required anymore since
\r
180 all the real work that view used to do is done in Boxx now.
\r
182 Obseleted classes: Box, View, Viewman, Widget, others?
\r
183 No code outside boxx should talk about surfaces anymore. Hopefully.
\r