]> git.vomp.tv Git - vompclient.git/blob - boxx.h
German updates
[vompclient.git] / boxx.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #ifndef BOXX_H
22 #define BOXX_H
23
24 #include <stdio.h>
25 #include <vector>
26
27 using namespace std;
28
29 #include "colour.h"
30 #include "region.h"
31 #include "message.h"
32
33 #ifdef WIN32
34 #include "surfacewin.h"
35 #else
36 #include "surfacemvp.h"
37 #endif
38
39 class Boxx
40 {
41   public:
42     Boxx();
43     virtual ~Boxx();
44
45     virtual void setSize(UINT w, UINT h);
46     void setPosition(UINT x, UINT y); // Set position on parent. Even numbers only!!!
47     void createBuffer(); // Make this a root view that goes in the BoxStack
48
49     void setGap(UINT gap);
50
51     // Not really for box.. see .cc
52     virtual void draw();
53     virtual int handleCommand(int);
54     virtual void processMessage(Message*);
55     virtual bool mouseMove(int x, int y) {return false;};
56     virtual bool mouseLBDOWN(int x, int y) {return false;};
57
58     void setBackgroundColour(Colour& colour);
59     void setVisible(bool isVisible);
60     virtual void deactivateAllControls(){};
61
62
63     
64     // Drawing functions level 1
65     void fillColour(Colour& colour);
66     void drawPara(char* text, int x, int y, Colour& colour);
67
68     // Drawing functions level 0
69     void rectangle(UINT x, UINT y, UINT w, UINT h, Colour& colour);
70     void rectangle(Region& region, Colour& colour);
71
72     void drawText(const char* text, int x, int y, Colour& colour);
73     void drawTextRJ(const char* text, int x, int y, Colour& colour);
74     void drawTextCentre(const char* text, int x, int y, Colour& colour);
75     void drawPixel(UINT x, UINT y, Colour& colour);
76
77     /* This is for system which need a locking of the drawing surface to speed up drawing */
78     void startFastDraw();
79     void endFastDraw();
80
81     int charWidth(char c);
82
83     // Following 4 used by mouse stuff only, except 1 getWidth/getHeight? in orig. vtabsman
84     int getScreenX();
85     int getScreenY();
86     int getRootBoxOffsetX();
87     int getRootBoxOffsetY();
88     int getX();
89     int getY();
90     UINT getWidth();
91     UINT getHeight();
92     bool getVisible();
93
94     
95
96     void add(Boxx*); // a boxx has a set of child boxxs
97     void remove(Boxx*);
98
99     /*
100     The following function sets the child's parent pointer without adding the child to the children vector.
101     It's a hack (that should be deprecated?) to allow things like WSymbol to be created, do some drawing on
102     the surface and then be deleted again, leaving the drawing present.
103     A better design would be to create many WSymbols - one per symbol and leave them created - then the
104     automatic draw code (not written yet) will be able to redraw the symbols without all that code needing
105     to be in the derived boxx's draw method.
106     */    
107     void TEMPADD(Boxx* child) { child->setParent(this); }
108
109   friend class BoxStack;
110   protected:
111     Boxx* parent;
112     Region area;
113     vector<Boxx*> children;
114
115     void setParent(Boxx*);    
116     void blt(Region& r);
117
118     static const int paraMargin = 10;
119     UINT paraVSpace;
120
121     Colour backgroundColour;
122     bool backgroundColourSet;
123     bool visible;
124
125     static char numBoxxes;
126     Surface* surface;
127 };
128
129 #endif
130
131
132 /*
133
134 New Boxx design
135
136 It's "Boxx" because "Box" was already taken.
137
138 BoxStack replaces Viewman and handles displaying a stack of root boxxs (boxxs with surfaces) on the screen.
139
140 Boxx relaces Box, Widget and parts of View and represents a box with or without a surface.
141 Let's call a Boxx with a surface a root box, and a boxx without a surface a child box.
142
143 A boxx with a surface (root) is like an old View and is handled by BoxStack.
144 A boxx without a surface (child) is like and old Widget and needs to be a child box of another boxx (root or not).
145
146 Don't add a boxx with a surface to another boxx. That isn't the design.
147
148 So, when you create a boxx, either that boxx calls createBuffer() on itself,
149 or some other box add()s the new box to itself.
150
151 Root boxxs can overlap each other - this is managed by boxstack.
152 Child boxxs within a parent boxx do not overlap each other.
153 However, a grandchild box can overlap a child box (but must be entirely contained within the child box).
154
155 TBBoxx replaces View but is now only a convenience class for the window dressing stuff. It isn't required anymore since
156 all the real work that view used to do is done in Boxx now.
157
158 Obseleted classes: Box, View, Viewman, Widget, others?
159 No code outside boxx should talk about surfaces anymore. Hopefully.
160
161 */
162