00001 #ifndef __DW_IMAGE_HH__
00002 #define __DW_IMAGE_HH__
00003
00004 #include "core.hh"
00005
00006 namespace dw {
00007
00023 class ImageMapsList
00024 {
00025 private:
00026 class ImageMap: public lout::object::Object {
00027 private:
00028 class ShapeAndLink: public lout::object::Object {
00029 public:
00030 core::Shape *shape;
00031 int link;
00032
00033 ~ShapeAndLink () { if (shape) delete shape; };
00034 };
00035
00036 lout::container::typed::List <ShapeAndLink> *shapesAndLinks;
00037 int defaultLink;
00038 public:
00039 ImageMap ();
00040 ~ImageMap ();
00041
00042 void draw (core::View *view, core::style::Style *style, int x, int y);
00043 void add (core::Shape *shape, int link);
00044 void setDefaultLink (int link) { defaultLink = link; };
00045 int link (int x, int y);
00046 };
00047
00048 lout::container::typed::HashTable <lout::object::Object, ImageMap>
00049 *imageMaps;
00050 ImageMap *currentMap;
00051
00052 public:
00053 ImageMapsList ();
00054 ~ImageMapsList ();
00055
00056 void startNewMap (lout::object::Object *key);
00057 void addShapeToCurrentMap (core::Shape *shape, int link);
00058 void setCurrentMapDefaultLink (int link);
00059 void drawMap(lout::object::Object *key, core::View *view,
00060 core::style::Style *style, int x, int y);
00061 int link (lout::object::Object *key, int x, int y);
00062 };
00063
00119 class Image: public core::Widget
00120 {
00121 private:
00122 char *altText;
00123 core::Imgbuf *buffer;
00124 int altTextWidth;
00125 bool clicking;
00126 int currLink;
00127 ImageMapsList *mapList;
00128 Object *mapKey;
00129 bool isMap;
00130
00131 protected:
00132 void sizeRequestImpl (core::Requisition *requisition);
00133 void sizeAllocateImpl (core::Allocation *allocation);
00134
00135 void draw (core::View *view, core::Rectangle *area);
00136
00137 bool buttonPressImpl (core::EventButton *event);
00138 bool buttonReleaseImpl (core::EventButton *event);
00139 void enterNotifyImpl (core::EventCrossing *event);
00140 void leaveNotifyImpl (core::EventCrossing *event);
00141 bool motionNotifyImpl (core::EventMotion *event);
00142 int contentX (core::MousePositionEvent *event);
00143 int contentY (core::MousePositionEvent *event);
00144
00145
00146
00147 public:
00148 static int CLASS_ID;
00149
00150 Image(const char *altText);
00151 ~Image();
00152
00153 core::Iterator *iterator (core::Content::Type mask, bool atEnd);
00154
00155 inline core::Imgbuf *getBuffer () { return buffer; }
00156 void setBuffer (core::Imgbuf *buffer, bool resize = false);
00157
00158 void drawRow (int row);
00159
00160 void setIsMap ();
00161 void setUseMap (ImageMapsList *list, Object *key);
00162
00163
00164
00165
00166
00167
00168 void forceMapRedraw () { if (mapKey && ! buffer) queueDraw (); };
00169 };
00170
00171 }
00172
00173 #endif // __DW_IMAGE_HH__