Dillo
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
dw::Image Class Reference

Displays an instance of dw::core::Imgbuf. More...

#include <image.hh>

Public Member Functions

 Image (const char *altText)
 
 ~Image ()
 
core::Iteratoriterator (core::Content::Type mask, bool atEnd)
 Return an iterator for this widget.
 
core::ImgbufgetBuffer ()
 
void setBuffer (core::Imgbuf *buffer, bool resize=false)
 
void drawRow (int row)
 
void setIsMap ()
 Sets image as server side image map.
 
void setUseMap (ImageMapsList *list, Object *key)
 Sets image as client side image map.
 
void forceMapRedraw ()
 
- Public Member Functions inherited from dw::core::Widget
void setDeleteCallback (DW_Callback_t func, void *data)
 
 Widget ()
 
 ~Widget ()
 
bool needsResize ()
 
bool needsAllocate ()
 
bool extremesChanged ()
 
bool wasAllocated ()
 
bool usesHints ()
 
bool hasContents ()
 
bool blockLevel ()
 
void setParent (Widget *parent)
 
style::StylegetStyle ()
 
AllocationgetAllocation ()
 
void sizeRequest (Requisition *requisition)
 This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed.
 
void getExtremes (Extremes *extremes)
 Wrapper for Widget::getExtremesImpl().
 
void sizeAllocate (Allocation *allocation)
 Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed.
 
virtual void setWidth (int width)
 
virtual void setAscent (int ascent)
 
virtual void setDescent (int descent)
 
bool intersects (Rectangle *area, Rectangle *intersection)
 Calculates the intersection of widget->allocation and area, returned in intersection (in widget coordinates!).
 
bool buttonPress (EventButton *event)
 
bool buttonRelease (EventButton *event)
 
bool motionNotify (EventMotion *event)
 
void enterNotify (EventCrossing *event)
 
void leaveNotify (EventCrossing *event)
 
virtual void setStyle (style::Style *style)
 Change the style of a widget.
 
void setBgColor (style::Color *bgColor)
 Set the background "behind" the widget, if it is not the background of the parent widget, e.g. the background of a table row.
 
style::ColorgetBgColor ()
 Get the actual background of a widget.
 
void drawBox (View *view, style::Style *style, Rectangle *area, int x, int y, int width, int height, bool inverse)
 Draw borders and background of a widget part, which allocation is given by (x, y, width, height) (widget coordinates).
 
void drawWidgetBox (View *view, Rectangle *area, bool inverse)
 Draw borders and background of a widget.
 
void drawSelected (View *view, Rectangle *area)
 
void setButtonSensitive (bool buttonSensitive)
 
bool isButtonSensitive ()
 
WidgetgetParent ()
 
WidgetgetTopLevel ()
 Get the widget at the root of the tree, this widget is part from.
 
int getLevel ()
 Get the level of the widget within the tree.
 
WidgetgetNearestCommonAncestor (Widget *otherWidget)
 Get the widget with the highest level, which is a direct ancestor of widget1 and widget2.
 
LayoutgetLayout ()
 
virtual WidgetgetWidgetAtPoint (int x, int y, int level)
 Search recursively through widget.
 
void scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height)
 
virtual void removeChild (Widget *child)
 
- Public Member Functions inherited from lout::identity::IdentifiableObject
 IdentifiableObject ()
 
virtual void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer.
 
int getClassId ()
 Returns the class identifier.
 
const char * getClassName ()
 Return the name, under which the class of this object was registered.
 
bool instanceOf (int otherClassId)
 Returns, whether this class is an instance of the class, given by otherClassId, or of a sub class of this class.
 
- Public Member Functions inherited from lout::object::Object
virtual ~Object ()
 The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly.
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal.
 
virtual int hashValue ()
 Return a hash value for the object.
 
virtual Objectclone ()
 Return an exact copy of the object.
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object.
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses.
 

Static Public Attributes

static int CLASS_ID = -1
 
- Static Public Attributes inherited from dw::core::Widget
static int CLASS_ID = -1
 

Protected Member Functions

void sizeRequestImpl (core::Requisition *requisition)
 See Sizes of Dillo Widgets.
 
void sizeAllocateImpl (core::Allocation *allocation)
 See Sizes of Dillo Widgets.
 
void draw (core::View *view, core::Rectangle *area)
 
bool buttonPressImpl (core::EventButton *event)
 
bool buttonReleaseImpl (core::EventButton *event)
 
void enterNotifyImpl (core::EventCrossing *event)
 
void leaveNotifyImpl (core::EventCrossing *event)
 
bool motionNotifyImpl (core::EventMotion *event)
 
int contentX (core::MousePositionEvent *event)
 
int contentY (core::MousePositionEvent *event)
 
- Protected Member Functions inherited from dw::core::Widget
int getHeight ()
 
int getContentWidth ()
 
int getContentHeight ()
 
void setFlags (Flags f)
 
void unsetFlags (Flags f)
 
void queueDraw ()
 
void queueDrawArea (int x, int y, int width, int height)
 
void queueResize (int ref, bool extremesChanged)
 This method should be called, when a widget changes its size.
 
virtual void getExtremesImpl (Extremes *extremes)
 See Sizes of Dillo Widgets.
 
virtual void resizeDrawImpl ()
 Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.
 
virtual void markSizeChange (int ref)
 See Sizes of Dillo Widgets.
 
virtual void markExtremesChange (int ref)
 See Sizes of Dillo Widgets.
 
char * addAnchor (const char *name)
 
char * addAnchor (const char *name, int y)
 
void changeAnchor (char *name, int y)
 
void removeAnchor (char *name)
 
void setCursor (style::Cursor cursor)
 
bool selectionButtonPress (Iterator *it, int charPos, int linkNo, EventButton *event, bool withinContent)
 
bool selectionButtonRelease (Iterator *it, int charPos, int linkNo, EventButton *event, bool withinContent)
 
bool selectionButtonMotion (Iterator *it, int charPos, int linkNo, EventMotion *event, bool withinContent)
 
bool selectionHandleEvent (SelectionState::EventType eventType, Iterator *it, int charPos, int linkNo, MousePositionEvent *event)
 
- Protected Member Functions inherited from lout::identity::IdentifiableObject
void registerName (const char *className, int *classId)
 This method must be called in the constructor for the sub class. See class comment for details.
 

Private Attributes

char * altText
 
core::Imgbufbuffer
 
int altTextWidth
 
bool clicking
 
int currLink
 
ImageMapsListmapList
 
ObjectmapKey
 
bool isMap
 

Additional Inherited Members

- Public Attributes inherited from dw::core::Widget
int parentRef
 This value is defined by the parent widget, and used for incremential resizing.
 
- Protected Types inherited from dw::core::Widget
enum  Flags {
  NEEDS_RESIZE = 1 << 0, NEEDS_ALLOCATE = 1 << 1, EXTREMES_CHANGED = 1 << 2, USES_HINTS = 1 << 3,
  HAS_CONTENTS = 1 << 4, WAS_ALLOCATED = 1 << 5, BLOCK_LEVEL = 1 << 6
}
 
- Protected Attributes inherited from dw::core::Widget
Allocation allocation
 The current allocation: size and position, always relative to the canvas.
 
Layoutlayout
 

Detailed Description

Displays an instance of dw::core::Imgbuf.

The dw::core::Imgbuf is automatically scaled, when needed, but dw::Image does not keep a reference on the root buffer.

Signals

For image maps, dw::Image uses the signals defined in dw::core::Layout::LinkReceiver. For client side image maps, -1 is passed for the coordinates, for server side image maps, the respective coordinates are used. See section "Image Maps" below.

Image Maps

Client Side Image Maps

You must first create a list of image maps (dw::ImageMapList), which can be used for multiple images. The caller is responsible for freeing the dw::ImageMapList.

Adding a map is done by dw::ImageMapsList::startNewMap. The key is an instance of a sub class of object::Object. In the context of HTML, this is a URL, which defines this map globally, by combining the URL of the document, this map is defined in, with the value of the attribute "name" of the <MAP> element, as a fragment.

dw::ImageMapsList::addShapeToCurrentMap adds a shape to the current map. The link argument is a number, which is later passed to the dw::core::Layout::LinkReceiver.

This map list is then, together with the key for the image, passed to dw::Image::setUseMap. For HTML, a URL with the value of the "ismap" attribute of <IMG> should be used.

dw::Image will search the correct map, when needed. If it is not found at this time, but later defined, it will be found and used later. This is the case, when an HTML <MAP> is defined below the <IMG> in the document.

Currently, only maps defined in the same document as the image may be used, since the dw::ImageMapsList is stored in the HTML link block, and contains only the image maps defined in the document.

Server Side Image Maps

To use images for server side image maps, you must call dw::Image::setIsMap, and the dw::Image::style must contain a valid link (dw::core::style::Style::x_link). After this, motions and clicks are delegated to dw::core::Layout::LinkReceiver.

See Also
Images and Backgrounds in Dw

Constructor & Destructor Documentation

dw::Image::Image ( const char *  altText)
dw::Image::~Image ( )

Member Function Documentation

bool dw::Image::buttonPressImpl ( core::EventButton event)
protectedvirtual

Reimplemented from dw::core::Widget.

References dw::core::EventButton::button.

bool dw::Image::buttonReleaseImpl ( core::EventButton event)
protectedvirtual

Reimplemented from dw::core::Widget.

int dw::Image::contentX ( core::MousePositionEvent event)
protected
int dw::Image::contentY ( core::MousePositionEvent event)
protected
void dw::Image::draw ( core::View view,
core::Rectangle area 
)
protectedvirtual
void dw::Image::drawRow ( int  row)
void dw::Image::enterNotifyImpl ( core::EventCrossing event)
protectedvirtual

Reimplemented from dw::core::Widget.

void dw::Image::forceMapRedraw ( )
inline
core::Imgbuf* dw::Image::getBuffer ( )
inline

References buffer.

core::Iterator * dw::Image::iterator ( core::Content::Type  mask,
bool  atEnd 
)
virtual

Return an iterator for this widget.

mask can narrow the types returned by the iterator, this can enhance performance quite much, e.g. when only searching for child widgets.

With atEnd == false, the iterator starts before the beginning, i.e. the first call of dw::core::Iterator::next will let the iterator point on the first piece of contents. Likewise, With atEnd == true, the iterator starts after the last piece of contents, call dw::core::Iterator::prev in this case.

Bug:
Not implemented.

Implements dw::core::Widget.

void dw::Image::leaveNotifyImpl ( core::EventCrossing event)
protectedvirtual

Reimplemented from dw::core::Widget.

bool dw::Image::motionNotifyImpl ( core::EventMotion event)
protectedvirtual

Reimplemented from dw::core::Widget.

References dw::core::style::CURSOR_POINTER.

void dw::Image::setBuffer ( core::Imgbuf buffer,
bool  resize = false 
)
void dw::Image::setIsMap ( )

Sets image as server side image map.

void dw::Image::setUseMap ( ImageMapsList list,
object::Object key 
)

Sets image as client side image map.

"list" is not owned by the image, the caller has to free it. "key" is owned by the image, if it is used by the caller afterwards, a copy should be passed.

void dw::Image::sizeAllocateImpl ( core::Allocation allocation)
protectedvirtual
void dw::Image::sizeRequestImpl ( core::Requisition requisition)
protectedvirtual

Member Data Documentation

char* dw::Image::altText
private
int dw::Image::altTextWidth
private
core::Imgbuf* dw::Image::buffer
private

Referenced by forceMapRedraw(), and getBuffer().

int dw::Image::CLASS_ID = -1
static
bool dw::Image::clicking
private
int dw::Image::currLink
private
bool dw::Image::isMap
private
Object* dw::Image::mapKey
private

Referenced by forceMapRedraw().

ImageMapsList* dw::Image::mapList
private

The documentation for this class was generated from the following files: