dw::core::Widget Class Reference

The base class of all dillo widgets. More...

#include <widget.hh>

List of all members.

Public Member Functions

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!).
virtual void draw (View *view, Rectangle *area)=0
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 Iteratoriterator (Content::Type mask, bool atEnd)=0
 Return an iterator for this widget.
virtual void removeChild (Widget *child)

Public Attributes

int parentRef
 This value is defined by the parent widget, and used for incremential resizing.

Static Public Attributes

static int CLASS_ID = -1

Protected Types

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 Member Functions

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 sizeRequestImpl (Requisition *requisition)=0
 See Sizes of Dillo Widgets.
virtual void getExtremesImpl (Extremes *extremes)
 See Sizes of Dillo Widgets.
virtual void sizeAllocateImpl (Allocation *allocation)
 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.
virtual bool buttonPressImpl (EventButton *event)
virtual bool buttonReleaseImpl (EventButton *event)
virtual bool motionNotifyImpl (EventMotion *event)
virtual void enterNotifyImpl (EventCrossing *event)
virtual void leaveNotifyImpl (EventCrossing *event)
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 Attributes

Allocation allocation
 The current allocation: size and position, always relative to the canvas.
Layoutlayout

Private Attributes

Widgetparent
 The parent widget, NULL for top-level widgets.
style::Stylestyle
Flags flags
Requisition requisition
 Size_request() stores the result of the last call of size_request_impl().
Extremes extremes
 Analogue to dw::core::Widget::requisition.
style::ColorbgColor
 See dw::core::Widget::setBgColor().
bool buttonSensitive
 See dw::core::Widget::setButtonSensitive().
bool buttonSensitiveSet
 See dw::core::Widget::setButtonSensitive().
void * deleteCallbackData
DW_Callback_t deleteCallbackFunc

Friends

class Layout


Detailed Description

The base class of all dillo widgets.

See also:
Dillo Widget Overview, Layout and Widgets

Member Enumeration Documentation

enum dw::core::Widget::Flags [protected]

Enumerator:
NEEDS_RESIZE  Set, when dw::core::Widget::requisition is not up to date anymore.
NEEDS_ALLOCATE  Only used internally, set to enforce size allocation.

(I've forgotten the case, for which this is necessary.)

EXTREMES_CHANGED  Set, when dw::core::Widget::extremes is not up to date anymore.
USES_HINTS  Set by the widget itself (in the constructor), when set... methods are implemented.

Will hopefully be removed, after redesigning the size model.

HAS_CONTENTS  Set by the widget itself (in the constructor), when it contains some contents, e.g. an image, as opposed to a horizontal ruler.

Will hopefully be removed, after redesigning the size model.

WAS_ALLOCATED  Set, when a widget was already once allocated,.

The dw::Image widget uses this flag, see dw::Image::setBuffer.

BLOCK_LEVEL  Set for block-level widgets (as opposed to inline widgets).


Constructor & Destructor Documentation

dw::core::Widget::Widget (  ) 

dw::core::Widget::~Widget (  ) 


Member Function Documentation

char* dw::core::Widget::addAnchor ( const char *  name,
int  y 
) [inline, protected]

char* dw::core::Widget::addAnchor ( const char *  name  )  [inline, protected]

bool dw::core::Widget::blockLevel (  )  [inline]

References BLOCK_LEVEL, and flags.

bool dw::core::Widget::buttonPress ( EventButton event  ) 

bool dw::core::Widget::buttonPressImpl ( EventButton event  )  [protected, virtual]

Reimplemented in dw::Image, dw::Textblock, and dw::core::ui::Embed.

Referenced by buttonPress().

bool dw::core::Widget::buttonRelease ( EventButton event  ) 

bool dw::core::Widget::buttonReleaseImpl ( EventButton event  )  [protected, virtual]

Reimplemented in dw::Image, and dw::Textblock.

Referenced by buttonRelease().

void dw::core::Widget::changeAnchor ( char *  name,
int  y 
) [inline, protected]

virtual void dw::core::Widget::draw ( View view,
Rectangle area 
) [pure virtual]

Area is given in widget coordinates.

Implemented in dw::Bullet, dw::Image, dw::Ruler, dw::Table, dw::Textblock, and dw::core::ui::Embed.

Referenced by dw::core::Layout::draw(), and dw::Textblock::drawLine().

void dw::core::Widget::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).

area is given in widget coordinates.

Todo:
Background images?

References allocation, dw::core::style::StyleAttrs::backgroundColor, dw::core::style::drawBackground(), dw::core::style::drawBorder(), dw::core::Rectangle::height, dw::core::Rectangle::width, dw::core::Allocation::x, dw::core::Rectangle::x, dw::core::Allocation::y, and dw::core::Rectangle::y.

Referenced by dw::Table::draw(), and dw::Textblock::drawLine().

void dw::core::Widget::drawSelected ( View view,
Rectangle area 
)

void dw::core::Widget::drawWidgetBox ( View view,
Rectangle area,
bool  inverse 
)

void dw::core::Widget::enterNotify ( EventCrossing event  ) 

void dw::core::Widget::enterNotifyImpl ( EventCrossing event  )  [protected, virtual]

bool dw::core::Widget::extremesChanged (  )  [inline]

Allocation* dw::core::Widget::getAllocation (  )  [inline]

style::Color * dw::core::Widget::getBgColor (  ) 

int dw::core::Widget::getContentHeight (  )  [inline, protected]

int dw::core::Widget::getContentWidth (  )  [inline, protected]

void dw::core::Widget::getExtremes ( Extremes extremes  ) 

void dw::core::Widget::getExtremesImpl ( Extremes extremes  )  [protected, virtual]

int dw::core::Widget::getHeight (  )  [inline, protected]

Layout* dw::core::Widget::getLayout (  )  [inline]

References layout.

Referenced by dw::core::Iterator::scrollTo().

int dw::core::Widget::getLevel (  ) 

Get the level of the widget within the tree.

The root widget has the level 0.

References parent.

Referenced by dw::core::DeepIterator::DeepIterator(), and getNearestCommonAncestor().

Widget * dw::core::Widget::getNearestCommonAncestor ( Widget otherWidget  ) 

Get the widget with the highest level, which is a direct ancestor of widget1 and widget2.

References getLevel(), and parent.

Referenced by dw::core::Layout::moveToWidget().

Widget* dw::core::Widget::getParent (  )  [inline]

style::Style* dw::core::Widget::getStyle (  )  [inline]

Widget * dw::core::Widget::getTopLevel (  ) 

Get the widget at the root of the tree, this widget is part from.

References parent.

Referenced by dw::core::Layout::moveToWidget().

Widget * dw::core::Widget::getWidgetAtPoint ( int  x,
int  y,
int  level 
) [virtual]

bool dw::core::Widget::hasContents (  )  [inline]

References flags, and HAS_CONTENTS.

bool dw::core::Widget::intersects ( Rectangle area,
Rectangle intersection 
)

Calculates the intersection of widget->allocation and area, returned in intersection (in widget coordinates!).

Typically used by containers when drawing their children. Returns whether intersection is not empty.

References allocation, getHeight(), dw::core::Rectangle::height, dw::core::Rectangle::intersectsWith(), parent, dw::core::Allocation::width, dw::core::Rectangle::width, dw::core::Allocation::x, dw::core::Rectangle::x, dw::core::Allocation::y, and dw::core::Rectangle::y.

Referenced by dw::Textblock::drawLine().

bool dw::core::Widget::isButtonSensitive (  )  [inline]

virtual Iterator* dw::core::Widget::iterator ( Content::Type  mask,
bool  atEnd 
) [pure 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.

Implemented in dw::Bullet, dw::Image, dw::Ruler, dw::Table, dw::Textblock, and dw::core::ui::Embed.

Referenced by dw::core::CharIterator::CharIterator(), dw::core::DeepIterator::DeepIterator(), getWidgetAtPoint(), dw::core::DeepIterator::next(), dw::core::DeepIterator::prev(), dw::core::DeepIterator::searchDownward(), and dw::core::DeepIterator::searchSideward().

void dw::core::Widget::leaveNotify ( EventCrossing event  ) 

void dw::core::Widget::leaveNotifyImpl ( EventCrossing event  )  [protected, virtual]

void dw::core::Widget::markExtremesChange ( int  ref  )  [protected, virtual]

See Sizes of Dillo Widgets.

Reimplemented in dw::Textblock.

Referenced by queueResize().

void dw::core::Widget::markSizeChange ( int  ref  )  [protected, virtual]

See Sizes of Dillo Widgets.

Reimplemented in dw::Textblock.

Referenced by queueResize().

bool dw::core::Widget::motionNotify ( EventMotion event  ) 

bool dw::core::Widget::motionNotifyImpl ( EventMotion event  )  [protected, virtual]

Reimplemented in dw::Image, and dw::Textblock.

Referenced by motionNotify().

bool dw::core::Widget::needsAllocate (  )  [inline]

References flags, and NEEDS_ALLOCATE.

Referenced by sizeAllocate().

bool dw::core::Widget::needsResize (  )  [inline]

References flags, and NEEDS_RESIZE.

Referenced by dw::Table::calcCellSizes(), and sizeRequest().

void dw::core::Widget::queueDraw (  )  [inline, protected]

void dw::core::Widget::queueDrawArea ( int  x,
int  y,
int  width,
int  height 
) [protected]

void dw::core::Widget::queueResize ( int  ref,
bool  extremesChanged 
) [protected]

void dw::core::Widget::removeAnchor ( char *  name  )  [inline, protected]

void dw::core::Widget::removeChild ( Widget child  )  [virtual]

References lout::misc::assertNotReached().

Referenced by ~Widget().

virtual void dw::core::Widget::resizeDrawImpl (  )  [inline, protected, virtual]

Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.

Reimplemented in dw::Table, and dw::Textblock.

References queueDraw().

Referenced by sizeAllocate().

void dw::core::Widget::scrollTo ( HPosition  hpos,
VPosition  vpos,
int  x,
int  y,
int  width,
int  height 
)

bool dw::core::Widget::selectionButtonMotion ( Iterator it,
int  charPos,
int  linkNo,
EventMotion event,
bool  withinContent 
) [inline, protected]

bool dw::core::Widget::selectionButtonPress ( Iterator it,
int  charPos,
int  linkNo,
EventButton event,
bool  withinContent 
) [inline, protected]

bool dw::core::Widget::selectionButtonRelease ( Iterator it,
int  charPos,
int  linkNo,
EventButton event,
bool  withinContent 
) [inline, protected]

bool dw::core::Widget::selectionHandleEvent ( SelectionState::EventType  eventType,
Iterator it,
int  charPos,
int  linkNo,
MousePositionEvent event 
) [inline, protected]

void dw::core::Widget::setAscent ( int  ascent  )  [virtual]

void dw::core::Widget::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.

void dw::core::Widget::setButtonSensitive ( bool  buttonSensitive  ) 

void dw::core::Widget::setCursor ( style::Cursor  cursor  )  [inline, protected]

void dw::core::Widget::setDeleteCallback ( DW_Callback_t  func,
void *  data 
) [inline]

void dw::core::Widget::setDescent ( int  descent  )  [virtual]

void dw::core::Widget::setFlags ( Flags  f  )  [inline, protected]

void dw::core::Widget::setParent ( Widget parent  ) 

void dw::core::Widget::setStyle ( style::Style style  )  [virtual]

Change the style of a widget.

The old style is automatically unreferred, the new is referred. If this call causes the widget to change its size, dw::core::Widget::queueResize is called.

Reimplemented in dw::core::ui::Embed.

References layout, queueDraw(), queueResize(), dw::core::style::Style::ref(), dw::core::style::StyleAttrs::sizeDiffs(), dw::core::style::Style::unref(), and dw::core::Layout::updateCursor().

Referenced by dw::Textblock::addWidget(), and dw::Textblock::changeLinkColor().

void dw::core::Widget::setWidth ( int  width  )  [virtual]

void dw::core::Widget::sizeAllocate ( Allocation allocation  ) 

void dw::core::Widget::sizeAllocateImpl ( Allocation allocation  )  [protected, virtual]

void dw::core::Widget::sizeRequest ( Requisition requisition  ) 

virtual void dw::core::Widget::sizeRequestImpl ( Requisition requisition  )  [protected, pure virtual]

void dw::core::Widget::unsetFlags ( Flags  f  )  [inline, protected]

bool dw::core::Widget::usesHints (  )  [inline]

bool dw::core::Widget::wasAllocated (  )  [inline]


Friends And Related Function Documentation

friend class Layout [friend]


Member Data Documentation

int dw::core::Widget::CLASS_ID = -1 [static]

Referenced by setDeleteCallback(), Widget(), and ~Widget().

Referenced by setDeleteCallback(), Widget(), and ~Widget().

This value is defined by the parent widget, and used for incremential resizing.

See documentation for an explanation.

Referenced by dw::Textblock::addWidget(), and queueResize().

Size_request() stores the result of the last call of size_request_impl().

Do not read this directly, but call size_request().

Referenced by dw::Textblock::calcWidgetSize(), and getExtremesImpl().


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

Generated on Wed Sep 7 02:00:37 2011 for Dillo by  doxygen 1.5.9