Dillo
image.hh
Go to the documentation of this file.
1 #ifndef __DW_IMAGE_HH__
2 #define __DW_IMAGE_HH__
3 
4 #include "core.hh"
5 
6 namespace dw {
7 
24 {
25 private:
27  private:
29  public:
31  int link;
32 
33  ~ShapeAndLink () { if (shape) delete shape; };
34  };
35 
38  public:
39  ImageMap ();
40  ~ImageMap ();
41 
42  void draw (core::View *view, core::style::Style *style, int x, int y);
43  void add (core::Shape *shape, int link);
44  void setDefaultLink (int link) { defaultLink = link; };
45  int link (int x, int y);
46  };
47 
51 
52 public:
53  ImageMapsList ();
54  ~ImageMapsList ();
55 
57  void addShapeToCurrentMap (core::Shape *shape, int link);
58  void setCurrentMapDefaultLink (int link);
59  void drawMap(lout::object::Object *key, core::View *view,
60  core::style::Style *style, int x, int y);
61  int link (lout::object::Object *key, int x, int y);
62 };
63 
119 class Image: public core::Widget, public core::ImgRenderer
120 {
121 private:
122  char *altText;
126  bool clicking;
127  int currLink;
129  Object *mapKey;
130  bool isMap;
131 
132 protected:
137 
138  void draw (core::View *view, core::Rectangle *area,
139  core::DrawingContext *context);
140 
141  bool buttonPressImpl (core::EventButton *event);
142  bool buttonReleaseImpl (core::EventButton *event);
143  void enterNotifyImpl (core::EventCrossing *event);
144  void leaveNotifyImpl (core::EventCrossing *event);
145  bool motionNotifyImpl (core::EventMotion *event);
146  int contentX (core::MousePositionEvent *event);
147  int contentY (core::MousePositionEvent *event);
148 
149  //core::Iterator *iterator (Content::Type mask, bool atEnd);
150 
151 public:
152  static int CLASS_ID;
153 
154  Image(const char *altText);
155  ~Image();
156 
157  // For images, the minimal width is not well defined, and
158  // correction of the size makes not much sense.
159  virtual bool getAdjustMinWidth () { return false; }
160 
161  core::Iterator *iterator (core::Content::Type mask, bool atEnd);
162 
163  inline core::Imgbuf *getBuffer () { return buffer; }
164  void setBuffer (core::Imgbuf *buffer, bool resize = false);
165 
166  void drawRow (int row);
167 
168  void finish ();
169  void fatal ();
170 
171  void setIsMap ();
172  void setUseMap (ImageMapsList *list, Object *key);
173 
174  /* This is a hack for the perhaps frivolous feature of drawing image map
175  * shapes when there is no image to display. If the map is defined after
176  * an image using an image map, and the actual image data has not been
177  * loaded, tell the image to redraw.
178  */
179  void forceMapRedraw () { if (mapKey && ! buffer) queueDraw (); };
180 };
181 
182 } // namespace dw
183 
184 #endif // __DW_IMAGE_HH__
void startNewMap(lout::object::Object *key)
Start a new map and make it the current one.
Definition: image.cc:96
core::Imgbuf * buffer
Definition: image.hh:123
static int CLASS_ID
Definition: image.hh:152
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:146
void setUseMap(ImageMapsList *list, Object *key)
Sets image as client side image map.
Definition: image.cc:552
void enterNotifyImpl(core::EventCrossing *event)
Definition: image.cc:312
ImageMap()
Definition: image.cc:31
~ImageMap()
Definition: image.cc:37
Abstract interface for different shapes.
Definition: types.hh:58
void setCurrentMapDefaultLink(int link)
Set default link for current map-.
Definition: image.cc:116
Typed version of container::untyped::HashTable.
Definition: container.hh:514
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:140
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
bool buttonReleaseImpl(core::EventButton *event)
Definition: image.cc:397
ImageMap * currentMap
Definition: image.hh:50
void drawMap(lout::object::Object *key, core::View *view, core::style::Style *style, int x, int y)
Definition: image.cc:121
Definition: image.hh:26
void setIsMap()
Sets image as server side image map.
Definition: image.cc:539
Type
Definition: types.hh:199
lout::container::typed::HashTable< lout::object::Object, ImageMap > * imageMaps
Definition: image.hh:49
int bufHeight
Definition: image.hh:124
int altTextWidth
Definition: image.hh:125
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
void forceMapRedraw()
Definition: image.hh:179
int defaultLink
Definition: image.hh:37
Represents a button press or release event.
Definition: events.hh:57
Represents a enter or leave notify event.
Definition: events.hh:74
int link(int x, int y)
Definition: image.cc:61
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition: image.cc:513
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
void sizeAllocateImpl(core::Allocation *allocation)
See Sizes of Dillo Widgets.
Definition: image.cc:274
lout::container::typed::List< ShapeAndLink > * shapesAndLinks
Definition: image.hh:36
void leaveNotifyImpl(core::EventCrossing *event)
Definition: image.cc:323
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition: image.cc:478
bool clicking
Definition: image.hh:126
~Image()
Definition: image.cc:163
Represents a list of client-side image maps.
Definition: image.hh:23
void sizeRequestSimpl(core::Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition: image.cc:175
Definition: style.hh:613
Definition: types.hh:172
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
void draw(core::View *view, core::style::Style *style, int x, int y)
Definition: image.cc:42
void queueDraw()
Definition: widget.hh:277
int bufWidth
Definition: image.hh:124
int link(lout::object::Object *key, int x, int y)
Definition: image.cc:130
The base class of all dillo widgets.
Definition: widget.hh:23
Base class for all mouse events related to a specific position.
Definition: events.hh:48
Set at the top when drawing.
Definition: types.hh:294
void add(core::Shape *shape, int link)
Definition: image.cc:54
void containerSizeChangedForChildren()
Definition: image.cc:305
Definition: types.hh:179
void fatal()
Called, when there are problems with the retrieval of image data.
Definition: image.cc:530
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:183
int contentX(core::MousePositionEvent *event)
Definition: image.cc:339
bool motionNotifyImpl(core::EventMotion *event)
Definition: image.cc:355
void setBuffer(core::Imgbuf *buffer, bool resize=false)
Called, when an image buffer is attached.
Definition: image.cc:485
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Definition: image.cc:411
Displays an instance of dw::core::Imgbuf.
Definition: image.hh:119
ImageMapsList()
Definition: image.cc:77
The platform independent interface for image buffers.
Definition: imgbuf.hh:161
int currLink
Definition: image.hh:127
void setDefaultLink(int link)
Definition: image.hh:44
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
Object * mapKey
Definition: image.hh:129
Image(const char *altText)
Definition: image.cc:145
Represents a mouse motion event.
Definition: events.hh:67
void addShapeToCurrentMap(core::Shape *shape, int link)
Add a shape to the current map-.
Definition: image.cc:108
void getExtremesSimpl(core::Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition: image.cc:241
bool isMap
Definition: image.hh:130
ImageMapsList * mapList
Definition: image.hh:128
int contentY(core::MousePositionEvent *event)
Definition: image.cc:347
core::Imgbuf * getBuffer()
Definition: image.hh:163
Typed version of container::untyped::List.
Definition: container.hh:463
virtual bool getAdjustMinWidth()
Definition: image.hh:159
void finish()
Called, when all image data has been retrieved.
Definition: image.cc:525
...
Definition: imgrenderer.hh:16
~ImageMapsList()
Definition: image.cc:84
bool buttonPressImpl(core::EventButton *event)
Definition: image.cc:380
char * altText
Definition: image.hh:122