• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

GMapAreas.h

Go to the documentation of this file.
00001 //C-  -*- C++ -*-
00002 //C- -------------------------------------------------------------------
00003 //C- DjVuLibre-3.5
00004 //C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
00005 //C- Copyright (c) 2001  AT&T
00006 //C-
00007 //C- This software is subject to, and may be distributed under, the
00008 //C- GNU General Public License, Version 2. The license should have
00009 //C- accompanied the software or you may obtain a copy of the license
00010 //C- from the Free Software Foundation at http://www.fsf.org .
00011 //C-
00012 //C- This program is distributed in the hope that it will be useful,
00013 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //C- GNU General Public License for more details.
00016 //C- 
00017 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
00018 //C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
00019 //C- Software authorized us to replace the original DjVu(r) Reference 
00020 //C- Library notice by the following text (see doc/lizard2002.djvu):
00021 //C-
00022 //C-  ------------------------------------------------------------------
00023 //C- | DjVu (r) Reference Library (v. 3.5)
00024 //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
00025 //C- | The DjVu Reference Library is protected by U.S. Pat. No.
00026 //C- | 6,058,214 and patents pending.
00027 //C- |
00028 //C- | This software is subject to, and may be distributed under, the
00029 //C- | GNU General Public License, Version 2. The license should have
00030 //C- | accompanied the software or you may obtain a copy of the license
00031 //C- | from the Free Software Foundation at http://www.fsf.org .
00032 //C- |
00033 //C- | The computer code originally released by LizardTech under this
00034 //C- | license and unmodified by other parties is deemed "the LIZARDTECH
00035 //C- | ORIGINAL CODE."  Subject to any third party intellectual property
00036 //C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
00037 //C- | non-exclusive license to make, use, sell, or otherwise dispose of 
00038 //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
00039 //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
00040 //C- | General Public License.   This grant only confers the right to 
00041 //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
00042 //C- | the extent such infringement is reasonably necessary to enable 
00043 //C- | recipient to make, have made, practice, sell, or otherwise dispose 
00044 //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
00045 //C- | any greater extent that may be necessary to utilize further 
00046 //C- | modifications or combinations.
00047 //C- |
00048 //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
00049 //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
00050 //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
00051 //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00052 //C- +------------------------------------------------------------------
00053 // 
00054 // $Id: GMapAreas.h,v 1.8 2003/11/07 22:08:21 leonb Exp $
00055 // $Name: release_3_5_15 $
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 // ---------- GMAPAREA ---------
00105 
00135 class GMapArea : public GPEnabled
00136 {
00137 protected:
00138    GMapArea(void);
00139 public:
00140 //      // Default creator.
00141 //   static GP<GMapArea> create(void) {return new GMapArea();}
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    // Enumeration for reporting the type of map area. "MapUnknown" is reported
00169    // for objects of type GMapArea (there shouldn't be any).
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 // ---------- GMAPRECT ---------
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 // ---------- GMAPPOLY ---------
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 // ---------- GMAPOVAL ---------
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

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal