00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _GMAPAREAS_H
00058 #define _GMAPAREAS_H
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065
00066
00067 #include "GSmartPointer.h"
00068 #include "GContainer.h"
00069 #include "GString.h"
00070 #include "GRect.h"
00071 #include "GURL.h"
00072
00073 #ifdef HAVE_NAMESPACES
00074 namespace DJVU {
00075 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00076 }
00077 #endif
00078 #endif
00079
00080
00102
00103
00104
00105
00135 class GMapArea : public GPEnabled
00136 {
00137 protected:
00138 GMapArea(void);
00139 public:
00140
00141
00142
00144 virtual ~GMapArea();
00145
00146 static const char MAPAREA_TAG [];
00147 static const char RECT_TAG [];
00148 static const char POLY_TAG [];
00149 static const char OVAL_TAG [];
00150 static const char NO_BORDER_TAG [];
00151 static const char XOR_BORDER_TAG [];
00152 static const char SOLID_BORDER_TAG [];
00153 static const char SHADOW_IN_BORDER_TAG [];
00154 static const char SHADOW_OUT_BORDER_TAG [];
00155 static const char SHADOW_EIN_BORDER_TAG [];
00156 static const char SHADOW_EOUT_BORDER_TAG [];
00157 static const char BORDER_AVIS_TAG [];
00158 static const char HILITE_TAG [];
00159 static const char URL_TAG [];
00160 static const char TARGET_SELF [];
00161
00162 enum BorderType { NO_BORDER=0, XOR_BORDER=1, SOLID_BORDER=2,
00163 SHADOW_IN_BORDER=3, SHADOW_OUT_BORDER=4,
00164 SHADOW_EIN_BORDER=5, SHADOW_EOUT_BORDER=6 };
00165
00166 enum Special_Hilite_Color{ NO_HILITE=0xFFFFFFFF, XOR_HILITE=0xFF000000};
00167
00168
00169
00170 enum MapAreaType { UNKNOWN, RECT, OVAL, POLY };
00171
00177 GUTF8String url;
00184 GUTF8String target;
00187 GUTF8String comment;
00201 BorderType border_type;
00204 bool border_always_visible;
00206 unsigned long int border_color;
00208 int border_width;
00213 unsigned long int hilite_color;
00214
00216 bool is_point_inside(int x, int y) const;
00217
00219 int get_xmin(void) const;
00221 int get_ymin(void) const;
00225 int get_xmax(void) const;
00229 int get_ymax(void) const;
00231 GRect get_bound_rect(void) const;
00234 void move(int dx, int dy);
00237 void resize(int new_width, int new_height);
00239 void transform(const GRect & grect);
00243 char const * const check_object(void);
00246 GUTF8String print(void);
00247
00248 virtual GUTF8String get_xmltag(const int height) const=0;
00249
00251 virtual MapAreaType const get_shape_type( void ) const { return UNKNOWN; };
00253 virtual char const * const get_shape_name(void) const=0;
00255 virtual GP<GMapArea> get_copy(void) const=0;
00258 virtual void get_coords( GList<int> & CoordList ) const;
00260 virtual void map(GRectMapper &mapper)=0;
00262 virtual void unmap(GRectMapper &mapper)=0;
00263
00264 protected:
00265 virtual int gma_get_xmin(void) const=0;
00266 virtual int gma_get_ymin(void) const=0;
00267 virtual int gma_get_xmax(void) const=0;
00268 virtual int gma_get_ymax(void) const=0;
00269 virtual void gma_move(int dx, int dy)=0;
00270 virtual void gma_resize(int new_width, int new_height)=0;
00271 virtual void gma_transform(const GRect & grect)=0;
00272 virtual bool gma_is_point_inside(const int x, const int y) const=0;
00273 virtual char const * const gma_check_object(void) const=0;
00274 virtual GUTF8String gma_print(void)=0;
00275
00276 void clear_bounds(void) { bounds_initialized=0; }
00277 private:
00278 int xmin, xmax, ymin, ymax;
00279 bool bounds_initialized;
00280
00281 void initialize_bounds(void);
00282 };
00283
00284
00285
00290 class GMapRect: public GMapArea
00291 {
00292 protected:
00293 GMapRect(void);
00294 GMapRect(const GRect & rect);
00295 public:
00297 static GP<GMapRect> create(void) {return new GMapRect();}
00299 static GP<GMapRect> create(const GRect &rect) {return new GMapRect(rect);}
00300
00301 virtual ~GMapRect();
00302
00304 int get_width(void) const { return xmax-xmin; }
00306 int get_height(void) const { return ymax-ymin; }
00307
00309 GMapRect & operator=(const GRect & rect);
00310
00312 operator GRect(void);
00313
00314 virtual GUTF8String get_xmltag(const int height) const;
00316 virtual MapAreaType const get_shape_type( void ) const { return RECT; };
00318 virtual char const * const get_shape_name(void) const;
00320 virtual GP<GMapArea> get_copy(void) const;
00322 virtual void map(GRectMapper &mapper);
00324 virtual void unmap(GRectMapper &mapper);
00325 protected:
00326 int xmin, ymin, xmax, ymax;
00327 virtual int gma_get_xmin(void) const;
00328 virtual int gma_get_ymin(void) const;
00329 virtual int gma_get_xmax(void) const;
00330 virtual int gma_get_ymax(void) const;
00331 virtual void gma_move(int dx, int dy);
00332 virtual void gma_resize(int new_width, int new_height);
00333 virtual void gma_transform(const GRect & grect);
00334 virtual bool gma_is_point_inside(const int x, const int y) const;
00335 virtual char const * const gma_check_object(void) const;
00336 virtual GUTF8String gma_print(void);
00337 };
00338
00339
00340
00348 class GMapPoly : public GMapArea
00349 {
00350 protected:
00351 GMapPoly(void);
00352 GMapPoly(const int * xx, const int * yy, int points, bool open=false);
00353 public:
00355 static GP<GMapPoly> create(void) {return new GMapPoly();}
00356
00358 static GP<GMapPoly> create(
00359 const int xx[], const int yy[], const int points, const bool open=false)
00360 {return new GMapPoly(xx,yy,points,open);}
00361
00363 virtual ~GMapPoly();
00364
00366 bool does_side_cross_rect(const GRect & grect, int side);
00367
00369 int get_points_num(void) const;
00370
00372 int get_sides_num(void) const;
00373
00375 int get_x(int i) const;
00376
00378 int get_y(int i) const;
00379
00381 void move_vertex(int i, int x, int y);
00382
00384 int add_vertex(int x, int y);
00385
00387 void close_poly();
00389 void optimize_data(void);
00391 char const * const check_data(void);
00392
00393 virtual GUTF8String get_xmltag(const int height) const;
00395 virtual MapAreaType const get_shape_type( void ) const { return POLY; };
00397 virtual char const * const get_shape_name(void) const;
00399 virtual GP<GMapArea> get_copy(void) const;
00401 void get_coords( GList<int> & CoordList ) const;
00403 virtual void map(GRectMapper &mapper);
00405 virtual void unmap(GRectMapper &mapper);
00406 protected:
00407 virtual int gma_get_xmin(void) const;
00408 virtual int gma_get_ymin(void) const;
00409 virtual int gma_get_xmax(void) const;
00410 virtual int gma_get_ymax(void) const;
00411 virtual void gma_move(int dx, int dy);
00412 virtual void gma_resize(int new_width, int new_height);
00413 virtual void gma_transform(const GRect & grect);
00414 virtual bool gma_is_point_inside(const int x, const int y) const;
00415 virtual char const * const gma_check_object(void) const;
00416 virtual GUTF8String gma_print(void);
00417 private:
00418 bool open;
00419 int points, sides;
00420 GTArray<int> xx, yy;
00421 static int sign(int x);
00422 static bool is_projection_on_segment(int x, int y, int x1, int y1, int x2, int y2);
00423 static bool do_segments_intersect(int x11, int y11, int x12, int y12,
00424 int x21, int y21, int x22, int y22);
00425 static bool are_segments_parallel(int x11, int y11, int x12, int y12,
00426 int x21, int y21, int x22, int y22);
00427 };
00428
00429
00430
00435 class GMapOval: public GMapArea
00436 {
00437 protected:
00438 GMapOval(void);
00439 GMapOval(const GRect & rect);
00440 public:
00442 static GP<GMapOval> create(void) {return new GMapOval();}
00443
00445 static GP<GMapOval> create(const GRect &rect) {return new GMapOval(rect);}
00446
00448 virtual ~GMapOval();
00449
00451 int get_a(void) const;
00453 int get_b(void) const;
00455 int get_rmin(void) const;
00457 int get_rmax(void) const;
00458
00459 virtual GUTF8String get_xmltag(const int height) const;
00461 virtual MapAreaType const get_shape_type( void ) const { return OVAL; };
00463 virtual char const * const get_shape_name(void) const;
00465 virtual GP<GMapArea> get_copy(void) const;
00467 virtual void map(GRectMapper &mapper);
00469 virtual void unmap(GRectMapper &mapper);
00470 protected:
00471 virtual int gma_get_xmin(void) const;
00472 virtual int gma_get_ymin(void) const;
00473 virtual int gma_get_xmax(void) const;
00474 virtual int gma_get_ymax(void) const;
00475 virtual void gma_move(int dx, int dy);
00476 virtual void gma_resize(int new_width, int new_height);
00477 virtual void gma_transform(const GRect & grect);
00478 virtual bool gma_is_point_inside(const int x, const int y) const;
00479 virtual char const * const gma_check_object(void) const;
00480 virtual GUTF8String gma_print(void);
00481 private:
00482 int rmax, rmin;
00483 int a, b;
00484 int xf1, yf1, xf2, yf2;
00485 int xmin, ymin, xmax, ymax;
00486
00487 void initialize(void);
00488 };
00489
00490 inline
00491 GMapRect::operator GRect(void)
00492 {
00493 return GRect(xmin, ymin, xmax-xmin, ymax-ymin);
00494 }
00495
00496 inline int
00497 GMapRect::gma_get_xmin(void) const { return xmin; }
00498
00499 inline int
00500 GMapRect::gma_get_ymin(void) const { return ymin; }
00501
00502 inline int
00503 GMapRect::gma_get_xmax(void) const { return xmax; }
00504
00505 inline int
00506 GMapRect::gma_get_ymax(void) const { return ymax; }
00507
00508 inline char const * const
00509 GMapRect::gma_check_object(void) const{ return ""; }
00510
00511 inline char const * const
00512 GMapRect::get_shape_name(void) const { return RECT_TAG; }
00513
00514 inline int
00515 GMapPoly::get_points_num(void) const { return points; }
00516
00517 inline int
00518 GMapPoly::get_sides_num(void) const { return sides; }
00519
00520 inline int
00521 GMapPoly::get_x(int i) const { return xx[i]; }
00522
00523 inline int
00524 GMapPoly::get_y(int i) const { return yy[i]; }
00525
00526 inline char const * const
00527 GMapPoly::get_shape_name(void) const { return POLY_TAG; }
00528
00529 inline int
00530 GMapOval::get_a(void) const { return a; }
00531
00532 inline int
00533 GMapOval::get_b(void) const { return b; }
00534
00535 inline int
00536 GMapOval::get_rmin(void) const { return rmin; }
00537
00538 inline int
00539 GMapOval::get_rmax(void) const { return rmax; }
00540
00541 inline int
00542 GMapOval::gma_get_xmin(void) const { return xmin; }
00543
00544 inline int
00545 GMapOval::gma_get_ymin(void) const { return ymin; }
00546
00547 inline int
00548 GMapOval::gma_get_xmax(void) const { return xmax; }
00549
00550 inline int
00551 GMapOval::gma_get_ymax(void) const { return ymax; }
00552
00553 inline char const * const
00554 GMapOval::get_shape_name(void) const { return OVAL_TAG; }
00555
00557
00558
00559 #ifdef HAVE_NAMESPACES
00560 }
00561 # ifndef NOT_USING_DJVU_NAMESPACE
00562 using namespace DJVU;
00563 # endif
00564 #endif
00565 #endif