00001 #ifndef __DW_TYPES_HH__
00002 #define __DW_TYPES_HH__
00003
00004 #ifndef __INCLUDED_FROM_DW_CORE_HH__
00005 # error Do not include this file directly, use "core.hh" instead.
00006 #endif
00007
00008 namespace dw {
00009 namespace core {
00010
00011 namespace style {
00012 class Style;
00013 }
00014
00015 enum HPosition
00016 {
00017 HPOS_LEFT,
00018 HPOS_CENTER,
00019 HPOS_RIGHT,
00020 HPOS_INTO_VIEW,
00021
00022 HPOS_NO_CHANGE
00023 };
00024
00025 enum VPosition
00026 {
00027 VPOS_TOP,
00028 VPOS_CENTER,
00029 VPOS_BOTTOM,
00030 VPOS_INTO_VIEW,
00031
00032 VPOS_NO_CHANGE
00033 };
00034
00035 enum ScrollCommand {SCREEN_UP_CMD, SCREEN_DOWN_CMD, LINE_UP_CMD, LINE_DOWN_CMD,
00036 LEFT_CMD, RIGHT_CMD, TOP_CMD, BOTTOM_CMD};
00037
00038
00039
00040
00041 enum HighlightLayer
00042 {
00043 HIGHLIGHT_SELECTION,
00044 HIGHLIGHT_FINDTEXT,
00045 HIGHLIGHT_NUM_LAYERS
00046 };
00047
00048 struct Point
00049 {
00050 int x;
00051 int y;
00052 };
00053
00057 class Shape: public lout::object::Object
00058 {
00059 public:
00060 virtual bool isPointWithin (int x, int y) = 0;
00061 virtual void draw (core::View *view, core::style::Style *style, int x,
00062 int y) = 0;
00063 };
00064
00068 class Rectangle: public Shape
00069 {
00070 public:
00071 int x;
00072 int y;
00073 int width;
00074 int height;
00075
00076 inline Rectangle () { }
00077 Rectangle (int x, int y, int width, int height);
00078
00079 void draw (core::View *view, core::style::Style *style, int x, int y);
00080 bool intersectsWith (Rectangle *otherRect, Rectangle *dest);
00081 bool isSubsetOf (Rectangle *otherRect);
00082 bool isPointWithin (int x, int y);
00083 bool isEmpty () { return width <= 0 || height <= 0; };
00084 };
00085
00089 class Circle: public Shape
00090 {
00091 public:
00092 int x, y, radius;
00093
00094 Circle (int x, int y, int radius);
00095
00096 void draw (core::View *view, core::style::Style *style, int x, int y);
00097 bool isPointWithin (int x, int y);
00098 };
00099
00103 class Polygon: public Shape
00104 {
00105 private:
00106 lout::misc::SimpleVector<Point> *points;
00107 int minx, miny, maxx, maxy;
00108
00114 inline int zOfVectorProduct(int x1, int y1, int x2, int y2) {
00115 return x1 * y2 - x2 * y1;
00116 }
00117
00118 bool linesCross0(int ax1, int ay1, int ax2, int ay2,
00119 int bx1, int by1, int bx2, int by2);
00120 bool linesCross(int ax1, int ay1, int ax2, int ay2,
00121 int bx1, int by1, int bx2, int by2);
00122
00123 public:
00124 Polygon ();
00125 ~Polygon ();
00126
00127 void draw (core::View *view, core::style::Style *style, int x, int y);
00128 void addPoint (int x, int y);
00129 bool isPointWithin (int x, int y);
00130 };
00131
00139 class Region
00140 {
00141 private:
00142 lout::container::typed::List <Rectangle> *rectangleList;
00143
00144 public:
00145 Region ();
00146 ~Region ();
00147
00148 void clear () { rectangleList->clear (); };
00149
00150 void addRectangle (Rectangle *r);
00151
00152 lout::container::typed::Iterator <Rectangle> rectangles ()
00153 {
00154 return rectangleList->iterator ();
00155 };
00156 };
00157
00162 struct Allocation
00163 {
00164 int x;
00165 int y;
00166 int width;
00167 int ascent;
00168 int descent;
00169 };
00170
00171 struct Requisition
00172 {
00173 int width;
00174 int ascent;
00175 int descent;
00176 };
00177
00178 struct Extremes
00179 {
00180 int minWidth;
00181 int maxWidth;
00182 };
00183
00184 struct Content
00185 {
00186 enum Type {
00187 START = 1 << 0,
00188 END = 1 << 1,
00189 TEXT = 1 << 2,
00190 WIDGET = 1 << 3,
00191 BREAK = 1 << 4,
00192 ALL = 0xff,
00193 REAL_CONTENT = 0xff ^ (START | END),
00194 SELECTION_CONTENT = TEXT | WIDGET | BREAK
00195 };
00196
00197
00198
00199 short type;
00200 bool space;
00201 union {
00202 const char *text;
00203 Widget *widget;
00204 int breakSpace;
00205 };
00206 };
00207
00208 }
00209 }
00210
00211 #endif // __DW_TYPES_HH__