Mercurial > dillo_port1.3
annotate dw/image.hh @ 2104:3e7e5395f0bc
non-ASCII keybindings
Alexander Voigt has kindly done some testing, and it seems that this
makes bindings to most keys on a German keyboard possible -- except
those that need AltGr don't work yet.
author | corvid <corvid@lavabit.com> |
---|---|
date | Thu, 23 Jun 2011 19:24:11 +0000 |
parents | 44025cca807b |
children |
rev | line source |
---|---|
347 | 1 #ifndef __DW_IMAGE_HH__ |
2 #define __DW_IMAGE_HH__ | |
3 | |
4 #include "core.hh" | |
5 | |
6 namespace dw { | |
7 | |
8 /** | |
9 * \brief Represents a list of client-side image maps. | |
10 * | |
11 * All image maps of a HTML page (in the future, also image maps from | |
12 * different HTML pages) are stored in a list, which is passed to the | |
13 * image, so that it is possible to deal with maps, which are defined | |
14 * after the image within the HTML page. | |
15 * | |
16 * Maps are referred by instances of object::Object. These keys are | |
17 * typically URLs, so the type representing URLS should be derived from | |
18 * object::Object. | |
19 * | |
20 * \todo Some methods within the key class have to be implemented, this | |
21 * is not clear at this time. | |
22 */ | |
23 class ImageMapsList | |
24 { | |
25 private: | |
26 class ImageMap: public lout::object::Object { | |
27 private: | |
28 class ShapeAndLink: public lout::object::Object { | |
29 public: | |
30 core::Shape *shape; | |
31 int link; | |
32 | |
33 ~ShapeAndLink () { if (shape) delete shape; }; | |
34 }; | |
35 | |
36 lout::container::typed::List <ShapeAndLink> *shapesAndLinks; | |
37 int defaultLink; | |
38 public: | |
39 ImageMap (); | |
40 ~ImageMap (); | |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
41 |
1617
db2b2e40a177
draw image maps when image not loaded
corvid <corvid@lavabit.com>
parents:
1456
diff
changeset
|
42 void draw (core::View *view, core::style::Style *style, int x, int y); |
347 | 43 void add (core::Shape *shape, int link); |
44 void setDefaultLink (int link) { defaultLink = link; }; | |
45 int link (int x, int y); | |
46 }; | |
47 | |
48 lout::container::typed::HashTable <lout::object::Object, ImageMap> | |
49 *imageMaps; | |
50 ImageMap *currentMap; | |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
51 |
347 | 52 public: |
53 ImageMapsList (); | |
54 ~ImageMapsList (); | |
55 | |
56 void startNewMap (lout::object::Object *key); | |
57 void addShapeToCurrentMap (core::Shape *shape, int link); | |
58 void setCurrentMapDefaultLink (int link); | |
1617
db2b2e40a177
draw image maps when image not loaded
corvid <corvid@lavabit.com>
parents:
1456
diff
changeset
|
59 void drawMap(lout::object::Object *key, core::View *view, |
db2b2e40a177
draw image maps when image not loaded
corvid <corvid@lavabit.com>
parents:
1456
diff
changeset
|
60 core::style::Style *style, int x, int y); |
347 | 61 int link (lout::object::Object *key, int x, int y); |
62 }; | |
63 | |
64 /** | |
65 * \brief Displays an instance of dw::core::Imgbuf. | |
66 * | |
67 * The dw::core::Imgbuf is automatically scaled, when needed, but dw::Image | |
68 * does not keep a reference on the root buffer. | |
69 * | |
70 * | |
71 * <h3>Signals</h3> | |
72 * | |
73 * For image maps, dw::Image uses the signals defined in | |
1456
f1a4a6efe1f1
documentation: update references to LinkReceiver
corvid <corvid@lavabit.com>
parents:
1238
diff
changeset
|
74 * dw::core::Layout::LinkReceiver. For client side image maps, -1 is |
347 | 75 * passed for the coordinates, for server side image maps, the respective |
76 * coordinates are used. See section "Image Maps" below. | |
77 * | |
78 * | |
79 * <h3>%Image Maps</h3> | |
80 * | |
81 * <h4>Client Side %Image Maps</h4> | |
82 * | |
83 * You must first create a list of image maps (dw::ImageMapList), which can | |
84 * be used for multiple images. The caller is responsible for freeing the | |
85 * dw::ImageMapList. | |
86 * | |
87 * Adding a map is done by dw::ImageMapsList::startNewMap. The key is an | |
88 * instance of a sub class of object::Object. In the context of HTML, this is | |
89 * a URL, which defines this map globally, by combining the URL of the | |
90 * document, this map is defined in, with the value of the attribute "name" of | |
91 * the \<MAP\> element, as a fragment. | |
92 * | |
93 * dw::ImageMapsList::addShapeToCurrentMap adds a shape to the current | |
94 * map. The \em link argument is a number, which is later passed to | |
1456
f1a4a6efe1f1
documentation: update references to LinkReceiver
corvid <corvid@lavabit.com>
parents:
1238
diff
changeset
|
95 * the dw::core::Layout::LinkReceiver. |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
96 * |
347 | 97 * This map list is then, together with the key for the image, passed to |
98 * dw::Image::setUseMap. For HTML, a URL with the value of the "ismap" | |
99 * attribute of \<IMG\> should be used. | |
100 * | |
101 * dw::Image will search the correct map, when needed. If it is not found | |
102 * at this time, but later defined, it will be found and used later. This is | |
103 * the case, when an HTML \<MAP\> is defined below the \<IMG\> in the | |
104 * document. | |
105 * | |
106 * Currently, only maps defined in the same document as the image may be | |
107 * used, since the dw::ImageMapsList is stored in the HTML link block, and | |
108 * contains only the image maps defined in the document. | |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
109 * |
347 | 110 * <h4>Server Side %Image Maps</h4> |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
111 * |
347 | 112 * To use images for server side image maps, you must call |
113 * dw::Image::setIsMap, and the dw::Image::style must contain a valid link | |
114 * (dw::core::style::Style::x_link). After this, motions and clicks are | |
1456
f1a4a6efe1f1
documentation: update references to LinkReceiver
corvid <corvid@lavabit.com>
parents:
1238
diff
changeset
|
115 * delegated to dw::core::Layout::LinkReceiver. |
347 | 116 * |
117 * \sa\ref dw-images-and-backgrounds | |
118 */ | |
119 class Image: public core::Widget | |
120 { | |
121 private: | |
122 char *altText; | |
123 core::Imgbuf *buffer; | |
124 int altTextWidth; | |
125 bool clicking; | |
126 int currLink; | |
127 ImageMapsList *mapList; | |
128 Object *mapKey; | |
129 bool isMap; | |
130 | |
131 protected: | |
132 void sizeRequestImpl (core::Requisition *requisition); | |
133 void sizeAllocateImpl (core::Allocation *allocation); | |
134 | |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
135 void draw (core::View *view, core::Rectangle *area); |
347 | 136 |
137 bool buttonPressImpl (core::EventButton *event); | |
138 bool buttonReleaseImpl (core::EventButton *event); | |
139 void enterNotifyImpl (core::EventCrossing *event); | |
140 void leaveNotifyImpl (core::EventCrossing *event); | |
141 bool motionNotifyImpl (core::EventMotion *event); | |
1238
988e79f0f398
fix image map coordinates when margin/border/padding are present
corvid <corvid@lavabit.com>
parents:
930
diff
changeset
|
142 int contentX (core::MousePositionEvent *event); |
988e79f0f398
fix image map coordinates when margin/border/padding are present
corvid <corvid@lavabit.com>
parents:
930
diff
changeset
|
143 int contentY (core::MousePositionEvent *event); |
347 | 144 |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
145 //core::Iterator *iterator (Content::Type mask, bool atEnd); |
347 | 146 |
147 public: | |
148 static int CLASS_ID; | |
149 | |
150 Image(const char *altText); | |
151 ~Image(); | |
152 | |
930
b277eed3119c
whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
153 core::Iterator *iterator (core::Content::Type mask, bool atEnd); |
347 | 154 |
155 inline core::Imgbuf *getBuffer () { return buffer; } | |
156 void setBuffer (core::Imgbuf *buffer, bool resize = false); | |
157 | |
158 void drawRow (int row); | |
159 | |
160 void setIsMap (); | |
161 void setUseMap (ImageMapsList *list, Object *key); | |
1623
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
162 |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
163 /* This is a hack for the perhaps frivolous feature of drawing image map |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
164 * shapes when there is no image to display. If the map is defined after |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
165 * an image using an image map, and the actual image data has not been |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
166 * loaded, tell the image to redraw. |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
167 */ |
44025cca807b
make drawing image map shapes work when <img> precedes <map>
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
1617
diff
changeset
|
168 void forceMapRedraw () { if (mapKey && ! buffer) queueDraw (); }; |
347 | 169 }; |
170 | |
171 } // namespace dw | |
172 | |
173 #endif // __DW_IMAGE_HH__ |