Dillo v3.1.1-14-g8f67d6e0
Loading...
Searching...
No Matches
dw::Image Class Reference

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

#include <image.hh>

Public Member Functions

 Image (const char *altText)
 
 ~Image ()
 
virtual bool getAdjustMinWidth ()
 
core::Iteratoriterator (core::Content::Type mask, bool atEnd)
 Return an iterator for this widget.
 
core::ImgbufgetBuffer ()
 
void setBuffer (core::Imgbuf *buffer, bool resize=false)
 Called, when an image buffer is attached.
 
void drawRow (int row)
 Called, when data from a row is available and has been copied into the image buffer.
 
void finish ()
 Called, when all image data has been retrieved.
 
void fatal ()
 Called, when there are problems with the retrieval of image data.
 
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 resizeQueued ()
 
bool extremesQueued ()
 
bool needsResize ()
 
bool needsAllocate ()
 
bool allocateQueued ()
 
bool extremesChanged ()
 
bool wasAllocated ()
 
void setParent (Widget *parent)
 
void setQuasiParent (Widget *quasiParent)
 
void setGenerator (Widget *generator)
 
style::StylegetStyle ()
 
AllocationgetAllocation ()
 
bool inAllocation (int x, int y)
 
int boxOffsetX ()
 
int boxRestWidth ()
 
int boxDiffWidth ()
 
int boxOffsetY ()
 
int boxRestHeight ()
 
int boxDiffHeight ()
 
virtual int numSizeRequestReferences ()
 See Sizes of Dillo Widgets (or Size requisitions depending on positions).
 
virtual WidgetsizeRequestReference (int index)
 See Sizes of Dillo Widgets (or Size requisitions depending on positions).
 
virtual int numGetExtremesReferences ()
 See Sizes of Dillo Widgets (or Size requisitions depending on positions).
 
virtual WidgetgetExtremesReference (int index)
 See Sizes of Dillo Widgets (or Size requisitions depending on positions).
 
void sizeRequest (Requisition *requisition, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
 This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed.
 
void getExtremes (Extremes *extremes, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
 Wrapper for Widget::getExtremesImpl().
 
void sizeAllocate (Allocation *allocation)
 Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed.
 
void calcExtraSpace (int numPos, Widget **references, int *x, int *y)
 Calculates dw::core::Widget::extraSpace.
 
int getAvailWidth (bool forceValue)
 Return available width including margin/border/padding (extraSpace?), not only the content width.
 
int getAvailHeight (bool forceValue)
 Return available height including margin/border/padding (extraSpace?), not only the content height.
 
void correctRequisition (Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
 
void correctExtremes (Extremes *extremes, bool useAdjustmentWidth)
 
int calcWidth (style::Length cssValue, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue)
 Computes a width value in pixels from cssValue.
 
void calcFinalWidth (style::Style *style, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue, int *finalWidth)
 
int calcHeight (style::Length cssValue, bool usePercentage, int refHeight, Widget *refWidget, bool forceValue)
 
virtual int applyPerWidth (int containerWidth, style::Length perWidth)
 
virtual int applyPerHeight (int containerHeight, style::Length perHeight)
 
int getMinWidth (Extremes *extremes, bool forceValue)
 Used to evaluate Widget::adjustMinWidth.
 
virtual bool isBlockLevel ()
 
virtual bool isPossibleContainer ()
 
void containerSizeChanged ()
 
bool intersects (Widget *refWidget, Rectangle *area, Rectangle *intersection)
 Calculates the intersection of the visible allocation (i.
 
void drawInterruption (View *view, Rectangle *area, DrawingContext *context)
 See Interrupted drawing for details.
 
virtual WidgetgetWidgetAtPoint (int x, int y, GettingWidgetAtPointContext *context)
 
WidgetgetWidgetAtPointInterrupted (int x, int y, GettingWidgetAtPointContext *context)
 
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.
 
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 ()
 
WidgetgetContainer ()
 
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.
 
int getGeneratorLevel ()
 Get the level of the widget within the tree, regarting the generators, not the parents.
 
WidgetgetNearestCommonAncestor (Widget *otherWidget)
 Get the widget with the highest level, which is a direct ancestor of widget1 and widget2.
 
WidgetReferencegetWidgetReference ()
 
void setWidgetReference (WidgetReference *widgetReference)
 
WidgetgetGenerator ()
 
LayoutgetLayout ()
 
void scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height)
 
void getMarginArea (int *xMar, int *yMar, int *widthMar, int *heightMar)
 
void getBorderArea (int *xBor, int *yBor, int *widthBor, int *heightBor)
 
void getPaddingArea (int *xPad, int *yPad, int *widthPad, int *heightPad)
 Return the padding area (content plus padding).
 
virtual void removeChild (Widget *child)
 
- Public Member Functions inherited from lout::identity::IdentifiableObject
 IdentifiableObject ()
 
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.
 
- Public Member Functions inherited from dw::core::ImgRenderer
virtual ~ImgRenderer ()
 

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 sizeRequestSimpl (core::Requisition *requisition)
 Simple variant, to be implemented by widgets with sizes not depending on positions.
 
void getExtremesSimpl (core::Extremes *extremes)
 Simple variant, to be implemented by widgets with extremes not depending on positions.
 
void sizeAllocateImpl (core::Allocation *allocation)
 See Sizes of Dillo Widgets.
 
void containerSizeChangedForChildren ()
 
void draw (core::View *view, core::Rectangle *area, core::DrawingContext *context)
 Area is given in widget coordinates.
 
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 ()
 
StackingContextMgrgetNextStackingContextMgr ()
 
void printFlag (Flags f)
 
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)
 
virtual void sizeRequestImpl (Requisition *requisition, int numPos, Widget **references, int *x, int *y)
 See Sizes of Dillo Widgets.
 
virtual void getExtremesImpl (Extremes *extremes, int numPos, Widget **references, int *x, int *y)
 See Sizes of Dillo Widgets.
 
virtual void calcExtraSpaceImpl (int numPos, Widget **references, int *x, int *y)
 The actual implementation for calculating dw::core::Widget::extraSpace.
 
virtual void resizeDrawImpl ()
 Called after sizeAllocateImpl() to redraw necessary areas.
 
virtual void markSizeChange (int ref)
 See Sizes of Dillo Widgets.
 
virtual void markExtremesChange (int ref)
 See Sizes of Dillo Widgets.
 
virtual int getAvailWidthOfChild (Widget *child, bool forceValue)
 Computes the content width available of a child widget.
 
virtual int getAvailHeightOfChild (Widget *child, bool forceValue)
 
virtual void correctRequisitionOfChild (Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
 
void correctReqWidthOfChild (Widget *child, Requisition *requisition, bool allowDecreaseWidth)
 
void correctReqHeightOfChild (Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
 
virtual void correctExtremesOfChild (Widget *child, Extremes *extremes, bool useAdjustmentWidth)
 
virtual bool affectedByContainerSizeChange ()
 
virtual bool affectsSizeChangeContainerChild (Widget *child)
 
virtual bool usesAvailWidth ()
 Must be implemengted by a method returning true, when getAvailWidth() is called.
 
virtual bool usesAvailHeight ()
 Must be implemengted by a method returning true, when getAvailHeight() is called.
 
virtual void notifySetAsTopLevel ()
 This method is called after a widget has been set as the top of a widget tree.
 
virtual void notifySetParent ()
 This method is called after a widget has been added to a parent.
 
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 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.
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from dw::core::Widget
static void setAdjustMinWidth (bool adjustMinWidth)
 
static void adjustHeight (int *height, bool allowDecreaseHeight, int ascent, int descent)
 
- 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 {
  RESIZE_QUEUED = 1 << 0 , EXTREMES_QUEUED = 1 << 1 , NEEDS_RESIZE = 1 << 2 , NEEDS_ALLOCATE = 1 << 3 ,
  ALLOCATE_QUEUED = 1 << 4 , EXTREMES_CHANGED = 1 << 5 , WAS_ALLOCATED = 1 << 6
}
 
- Protected Attributes inherited from dw::core::Widget
WidgetImgRendererwidgetImgRenderer
 
Allocation allocation
 The current allocation: size and position, always relative to the canvas.
 
Layoutlayout
 
style::Box extraSpace
 Space around the margin box.
 
StackingContextMgrstackingContextMgr
 Set iff this widget constitutes a stacking context, as defined by CSS.
 
WidgetstackingContextWidget
 The bottom-most ancestor (or this) for which stackingContextMgr is set.
 

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

Definition at line 119 of file image.hh.

Constructor & Destructor Documentation

◆ Image()

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

Definition at line 145 of file image.cc.

References DBG_OBJ_CREATE, and DBG_OBJ_SET_NUM.

◆ ~Image()

dw::Image::~Image ( )

Definition at line 163 of file image.cc.

References DBG_OBJ_DELETE.

Member Function Documentation

◆ buttonPressImpl()

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

Reimplemented from dw::core::Widget.

Definition at line 380 of file image.cc.

References dw::core::EventButton::button, and layout.

◆ buttonReleaseImpl()

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

Reimplemented from dw::core::Widget.

Definition at line 397 of file image.cc.

References layout.

◆ containerSizeChangedForChildren()

void dw::Image::containerSizeChangedForChildren ( )
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 305 of file image.cc.

References DBG_OBJ_ENTER0, and DBG_OBJ_LEAVE.

◆ contentX()

int dw::Image::contentX ( core::MousePositionEvent event)
protected

Definition at line 339 of file image.cc.

References lout::misc::max(), and lout::misc::min().

◆ contentY()

int dw::Image::contentY ( core::MousePositionEvent event)
protected

Definition at line 347 of file image.cc.

References lout::misc::max(), and lout::misc::min().

◆ draw()

◆ drawRow()

void dw::Image::drawRow ( int  row)
virtual

Called, when data from a row is available and has been copied into the image buffer.

The implementation will typically queue the respective area for drawing.

Implements dw::core::ImgRenderer.

Definition at line 513 of file image.cc.

References dw::core::Rectangle::height, dw::core::Rectangle::width, dw::core::Rectangle::x, and dw::core::Rectangle::y.

Referenced by imageDrawTimeout(), imageDrawTimeout(), and imageDrawTimeout().

◆ enterNotifyImpl()

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

Reimplemented from dw::core::Widget.

Definition at line 312 of file image.cc.

References layout.

◆ fatal()

void dw::Image::fatal ( )
virtual

Called, when there are problems with the retrieval of image data.

The implementation may use this to indicate an error.

Implements dw::core::ImgRenderer.

Definition at line 530 of file image.cc.

◆ finish()

void dw::Image::finish ( )
virtual

Called, when all image data has been retrieved.

The implementation may use this instead of "drawRow" for drawing, to limit the number of draws.

Implements dw::core::ImgRenderer.

Definition at line 525 of file image.cc.

◆ forceMapRedraw()

void dw::Image::forceMapRedraw ( )
inline

Definition at line 179 of file image.hh.

References buffer, mapKey, and dw::core::Widget::queueDraw().

Referenced by Html_tag_close_map().

◆ getAdjustMinWidth()

virtual bool dw::Image::getAdjustMinWidth ( )
inlinevirtual

Reimplemented from dw::core::Widget.

Definition at line 159 of file image.hh.

◆ getBuffer()

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

Definition at line 163 of file image.hh.

References buffer.

◆ getExtremesSimpl()

void dw::Image::getExtremesSimpl ( core::Extremes extremes)
protectedvirtual

Simple variant, to be implemented by widgets with extremes not depending on positions.

Reimplemented from dw::core::Widget.

Definition at line 241 of file image.cc.

References dw::core::Extremes::adjustmentWidth, dw::core::style::isPerLength(), layout, dw::core::Extremes::maxWidth, dw::core::Extremes::maxWidthIntrinsic, lout::misc::min(), dw::core::Extremes::minWidth, and dw::core::Extremes::minWidthIntrinsic.

◆ iterator()

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.

Definition at line 478 of file image.cc.

◆ leaveNotifyImpl()

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

Reimplemented from dw::core::Widget.

Definition at line 323 of file image.cc.

References layout.

◆ motionNotifyImpl()

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

Reimplemented from dw::core::Widget.

Definition at line 355 of file image.cc.

References dw::core::style::CURSOR_POINTER, and layout.

◆ setBuffer()

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

Called, when an image buffer is attached.

This is typically the case when all meta data (size, depth) has been read.

Implements dw::core::ImgRenderer.

Definition at line 485 of file image.cc.

References DBG_OBJ_ASSOC_CHILD, DBG_OBJ_SET_NUM, dw::core::Imgbuf::getRootHeight(), dw::core::Imgbuf::getRootWidth(), dw::core::Imgbuf::getScaledBuf(), dw::core::Imgbuf::ref(), and dw::core::Imgbuf::unref().

Referenced by imageInitTimeout(), imageInitTimeout(), and imageInitTimeout().

◆ setIsMap()

void dw::Image::setIsMap ( )

Sets image as server side image map.

Definition at line 539 of file image.cc.

Referenced by Html_tag_content_img().

◆ setUseMap()

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.

Definition at line 552 of file image.cc.

Referenced by Html_tag_content_img().

◆ sizeAllocateImpl()

◆ sizeRequestSimpl()

void dw::Image::sizeRequestSimpl ( core::Requisition requisition)
protectedvirtual

Simple variant, to be implemented by widgets with sizes not depending on positions.

Reimplemented from dw::core::Widget.

Definition at line 175 of file image.cc.

References dw::core::Requisition::ascent, DBG_OBJ_ENTER0, DBG_OBJ_LEAVE, DBG_OBJ_MSGF, dw::core::Requisition::descent, layout, dw::core::style::LENGTH_AUTO, dw::core::splitHeightPreserveDescent(), and dw::core::Requisition::width.

Member Data Documentation

◆ altText

char* dw::Image::altText
private

Definition at line 122 of file image.hh.

◆ altTextWidth

int dw::Image::altTextWidth
private

Definition at line 125 of file image.hh.

◆ buffer

core::Imgbuf* dw::Image::buffer
private

Definition at line 123 of file image.hh.

Referenced by forceMapRedraw(), and getBuffer().

◆ bufHeight

int dw::Image::bufHeight
private

Definition at line 124 of file image.hh.

◆ bufWidth

int dw::Image::bufWidth
private

Definition at line 124 of file image.hh.

◆ CLASS_ID

int dw::Image::CLASS_ID = -1
static

Definition at line 152 of file image.hh.

◆ clicking

bool dw::Image::clicking
private

Definition at line 126 of file image.hh.

◆ currLink

int dw::Image::currLink
private

Definition at line 127 of file image.hh.

◆ isMap

bool dw::Image::isMap
private

Definition at line 130 of file image.hh.

◆ mapKey

Object* dw::Image::mapKey
private

Definition at line 129 of file image.hh.

Referenced by forceMapRedraw().

◆ mapList

ImageMapsList* dw::Image::mapList
private

Definition at line 128 of file image.hh.


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