Dillo
Classes | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
dw::core::Layout Class Reference

The central class for managing and drawing a widget tree. More...

#include <layout.hh>

Classes

class  Anchor
 
class  Emitter
 
class  LayoutImgRenderer
 
class  LinkEmitter
 
class  LinkReceiver
 
class  Receiver
 Receiver interface different signals. More...
 

Public Member Functions

 Layout (Platform *platform)
 
 ~Layout ()
 
void connectLink (LinkReceiver *receiver)
 
bool emitLinkEnter (Widget *w, int link, int img, int x, int y)
 
bool emitLinkPress (Widget *w, int link, int img, int x, int y, EventButton *event)
 
bool emitLinkRelease (Widget *w, int link, int img, int x, int y, EventButton *event)
 
bool emitLinkClick (Widget *w, int link, int img, int x, int y, EventButton *event)
 
void addWidget (Widget *widget)
 
void setWidget (Widget *widget)
 
void attachView (View *view)
 Attach a view to the layout. More...
 
void detachView (View *view)
 
bool getUsesViewport ()
 
int getWidthViewport ()
 
int getHeightViewport ()
 
int getScrollPosX ()
 
int getScrollPosY ()
 
void scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height)
 Scrolls all viewports, so that the region [x, y, width, height] is seen, according to hpos and vpos. More...
 
void scroll (ScrollCommand)
 
void setAnchor (const char *anchor)
 
void expose (View *view, Rectangle *area)
 
bool buttonPress (View *view, int numPressed, int x, int y, ButtonState state, int button)
 This function is called by a view, to delegate a button press event. More...
 
void containerSizeChanged ()
 
bool buttonRelease (View *view, int numPressed, int x, int y, ButtonState state, int button)
 This function is called by a view, to delegate a button press event. More...
 
bool motionNotify (View *view, int x, int y, ButtonState state)
 This function is called by a view, to delegate a motion notify event. More...
 
void enterNotify (View *view, int x, int y, ButtonState state)
 This function is called by a view, to delegate a enter notify event. More...
 
void leaveNotify (View *view, ButtonState state)
 This function is called by a view, to delegate a leave notify event. More...
 
void scrollPosChanged (View *view, int x, int y)
 
void viewportSizeChanged (View *view, int width, int height)
 
PlatformgetPlatform ()
 
int textWidth (style::Font *font, const char *text, int len)
 
char * textToUpper (const char *text, int len)
 
char * textToLower (const char *text, int len)
 
int nextGlyph (const char *text, int idx)
 
int prevGlyph (const char *text, int idx)
 
float dpiX ()
 
float dpiY ()
 
style::FontcreateFont (style::FontAttrs *attrs, bool tryEverything)
 
bool fontExists (const char *name)
 
style::ColorcreateColor (int color)
 
style::TooltipcreateTooltip (const char *text)
 
void cancelTooltip ()
 
ImgbufcreateImgbuf (Imgbuf::Type type, int width, int height, double gamma)
 
void copySelection (const char *text)
 
ui::ResourceFactorygetResourceFactory ()
 
void connect (Receiver *receiver)
 
FindtextState::Result search (const char *str, bool caseSens, int backwards)
 See dw::core::FindtextState::search. More...
 
void resetSearch ()
 See dw::core::FindtextState::resetSearch. More...
 
void setBgColor (style::Color *color)
 
void setBgImage (style::StyleImage *bgImage, style::BackgroundRepeat bgRepeat, style::BackgroundAttachment bgAttachment, style::Length bgPositionX, style::Length bgPositionY)
 
style::ColorgetBgColor ()
 
style::StyleImagegetBgImage ()
 
- 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. More...
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal. More...
 
virtual int hashValue ()
 Return a hash value for the object. More...
 
virtual Objectclone ()
 Return an exact copy of the object. More...
 
virtual void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer. More...
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object. More...
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses. More...
 

Public Attributes

LinkEmitter linkEmitter
 
lout::misc::ZoneAllocatortextZone
 

Private Types

enum  ButtonEventType { BUTTON_PRESS, BUTTON_RELEASE, MOTION_NOTIFY }
 

Private Member Functions

void detachWidget (Widget *widget)
 
WidgetgetWidgetAtPoint (int x, int y)
 
void moveToWidget (Widget *newWidgetAtPoint, ButtonState state)
 
void moveToWidgetAtPoint (int x, int y, ButtonState state)
 Emit the necessary crossing events, when the mouse pointer has moved to position (x, );. More...
 
void moveOutOfView (ButtonState state)
 Emit the necessary crossing events, when the mouse pointer has moved out of the view. More...
 
bool processMouseEvent (MousePositionEvent *event, ButtonEventType type)
 Common processing of press, release and motion events. More...
 
bool buttonEvent (ButtonEventType type, View *view, int numPressed, int x, int y, ButtonState state, int button)
 
void resizeIdle ()
 
void setSizeHints ()
 
void draw (View *view, Rectangle *area)
 
void scrollTo0 (HPosition hpos, VPosition vpos, int x, int y, int width, int height, bool scrollingInterrupted)
 
void scrollIdle ()
 
void adjustScrollPos ()
 
int currHScrollbarThickness ()
 
int currVScrollbarThickness ()
 
void updateAnchor ()
 
char * addAnchor (Widget *widget, const char *name)
 
char * addAnchor (Widget *widget, const char *name, int y)
 
void changeAnchor (Widget *widget, char *name, int y)
 
void removeAnchor (Widget *widget, char *name)
 
void setCursor (style::Cursor cursor)
 
void updateCursor ()
 
void queueDraw (int x, int y, int width, int height)
 
void queueDrawExcept (int x, int y, int width, int height, int ex, int ey, int ewidth, int eheight)
 
void queueResize (bool extremesChanged)
 
void removeWidget ()
 
void enterResizeIdle ()
 
void leaveResizeIdle ()
 

Static Private Member Functions

static bool calcScrollInto (int targetValue, int requestedSize, int *value, int viewportSize)
 

Private Attributes

LayoutImgRendererlayoutImgRenderer
 
Emitter emitter
 
Platformplatform
 
Viewview
 
WidgettopLevel
 
WidgetwidgetAtPoint
 
lout::container::typed::Vector
< Widget > * 
queueResizeList
 
style::ColorbgColor
 
style::StyleImagebgImage
 
style::BackgroundRepeat bgRepeat
 
style::BackgroundAttachment bgAttachment
 
style::Length bgPositionX
 
style::Length bgPositionY
 
style::Cursor cursor
 
int canvasWidth
 
int canvasAscent
 
int canvasDescent
 
bool usesViewport
 
bool drawAfterScrollReq
 
int scrollX
 
int scrollY
 
int viewportWidth
 
int viewportHeight
 
bool canvasHeightGreater
 
int hScrollbarThickness
 
int vScrollbarThickness
 
HPosition scrollTargetHpos
 
VPosition scrollTargetVpos
 
int scrollTargetX
 
int scrollTargetY
 
int scrollTargetWidth
 
int scrollTargetHeight
 
char * requestedAnchor
 
int scrollIdleId
 
int resizeIdleId
 
bool scrollIdleNotInterrupted
 
lout::container::typed::HashTable
< lout::object::String, Anchor > * 
anchorsTable
 
SelectionState selectionState
 
FindtextState findtextState
 
int resizeIdleCounter
 
int queueResizeCounter
 
int sizeAllocateCounter
 
int sizeRequestCounter
 
int getExtremesCounter
 

Friends

class Widget
 

Detailed Description

The central class for managing and drawing a widget tree.

See also
Dillo Widget Overview, Layout and Widgets, Layout and Views

Member Enumeration Documentation

Enumerator
BUTTON_PRESS 
BUTTON_RELEASE 
MOTION_NOTIFY 

Constructor & Destructor Documentation

dw::core::Layout::Layout ( Platform platform)
dw::core::Layout::~Layout ( )

References DBG_OBJ_DELETE, and platform.

Member Function Documentation

char * dw::core::Layout::addAnchor ( Widget widget,
const char *  name 
)
private

Used, when the widget is not allocated yet.

Referenced by dw::core::Widget::addAnchor().

char * dw::core::Layout::addAnchor ( Widget widget,
const char *  name,
int  y 
)
private
void dw::core::Layout::addWidget ( Widget widget)
void dw::core::Layout::adjustScrollPos ( )
private
void dw::core::Layout::attachView ( View view)
bool dw::core::Layout::buttonEvent ( ButtonEventType  type,
View view,
int  numPressed,
int  x,
int  y,
ButtonState  state,
int  button 
)
private

Referenced by buttonPress(), and buttonRelease().

bool dw::core::Layout::buttonPress ( View view,
int  numPressed,
int  x,
int  y,
ButtonState  state,
int  button 
)
inline

This function is called by a view, to delegate a button press event.

numPressed is 1 for simple presses, 2 for double presses etc. (more that 2 is never needed), x and y the world coordinates, and button the number of the button pressed.

References BUTTON_PRESS, and buttonEvent().

Referenced by dw::fltk::FltkViewBase::handle().

bool dw::core::Layout::buttonRelease ( View view,
int  numPressed,
int  x,
int  y,
ButtonState  state,
int  button 
)
inline

This function is called by a view, to delegate a button press event.

Arguments are similar to dw::core::Layout::buttonPress.

References BUTTON_RELEASE, and buttonEvent().

Referenced by dw::fltk::FltkViewBase::handle().

bool dw::core::Layout::calcScrollInto ( int  targetValue,
int  requestedSize,
int *  value,
int  viewportSize 
)
staticprivate
void dw::core::Layout::cancelTooltip ( )
inline
void dw::core::Layout::changeAnchor ( Widget widget,
char *  name,
int  y 
)
private
void dw::core::Layout::connect ( Receiver receiver)
inline
void dw::core::Layout::connectLink ( LinkReceiver receiver)
inline
void dw::core::Layout::containerSizeChanged ( )

References DBG_OBJ_ENTER0, and DBG_OBJ_LEAVE.

void dw::core::Layout::copySelection ( const char *  text)
inline
style::Color* dw::core::Layout::createColor ( int  color)
inline
style::Font* dw::core::Layout::createFont ( style::FontAttrs attrs,
bool  tryEverything 
)
inline
Imgbuf* dw::core::Layout::createImgbuf ( Imgbuf::Type  type,
int  width,
int  height,
double  gamma 
)
inline
style::Tooltip* dw::core::Layout::createTooltip ( const char *  text)
inline
int dw::core::Layout::currHScrollbarThickness ( )
private
int dw::core::Layout::currVScrollbarThickness ( )
private
void dw::core::Layout::detachView ( View view)
Todo:
Actually, viewportMarkerWidthDiff and viewportMarkerHeightDiff have to be recalculated here, since the effective (i.e. maximal) values may change, after the view has been detached. Same applies to the usage of viewports.

References platform, and dw::core::View::setLayout().

void dw::core::Layout::detachWidget ( Widget widget)
private
float dw::core::Layout::dpiX ( )
inline
float dw::core::Layout::dpiY ( )
inline
void dw::core::Layout::draw ( View view,
Rectangle area 
)
private
bool dw::core::Layout::emitLinkClick ( Widget w,
int  link,
int  img,
int  x,
int  y,
EventButton event 
)
inline
bool dw::core::Layout::emitLinkEnter ( Widget w,
int  link,
int  img,
int  x,
int  y 
)
inline
bool dw::core::Layout::emitLinkPress ( Widget w,
int  link,
int  img,
int  x,
int  y,
EventButton event 
)
inline
bool dw::core::Layout::emitLinkRelease ( Widget w,
int  link,
int  img,
int  x,
int  y,
EventButton event 
)
inline
void dw::core::Layout::enterNotify ( View view,
int  x,
int  y,
ButtonState  state 
)

This function is called by a view, to delegate a enter notify event.

Arguments are similar to dw::core::Layout::buttonPress.

References dw::core::Widget::enterNotify().

Referenced by dw::fltk::FltkViewBase::handle().

void dw::core::Layout::enterResizeIdle ( )
inlineprivate
void dw::core::Layout::expose ( View view,
Rectangle area 
)
inline
bool dw::core::Layout::fontExists ( const char *  name)
inline
style::Color* dw::core::Layout::getBgColor ( )
inline

References bgColor.

Referenced by dw::core::style::drawBackground().

style::StyleImage* dw::core::Layout::getBgImage ( )
inline

References bgImage.

Referenced by dw::core::style::drawBackground().

int dw::core::Layout::getHeightViewport ( )
inline

References viewportHeight.

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

Platform* dw::core::Layout::getPlatform ( )
inline

References platform.

ui::ResourceFactory* dw::core::Layout::getResourceFactory ( )
inline
int dw::core::Layout::getScrollPosX ( )
inline

References scrollX.

int dw::core::Layout::getScrollPosY ( )
inline

References scrollY.

bool dw::core::Layout::getUsesViewport ( )
inline

References usesViewport.

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

Widget * dw::core::Layout::getWidgetAtPoint ( int  x,
int  y 
)
private
int dw::core::Layout::getWidthViewport ( )
inline

References viewportWidth.

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

void dw::core::Layout::leaveNotify ( View view,
ButtonState  state 
)

This function is called by a view, to delegate a leave notify event.

Arguments are similar to dw::core::Layout::buttonPress.

References dw::core::Widget::leaveNotify().

Referenced by dw::fltk::FltkViewBase::handle().

void dw::core::Layout::leaveResizeIdle ( )
inlineprivate
bool dw::core::Layout::motionNotify ( View view,
int  x,
int  y,
ButtonState  state 
)

This function is called by a view, to delegate a motion notify event.

Arguments are similar to dw::core::Layout::buttonPress.

Referenced by dw::fltk::FltkViewBase::handle(), and dw::fltk::FltkViewport::positionChanged().

void dw::core::Layout::moveOutOfView ( ButtonState  state)
inlineprivate

Emit the necessary crossing events, when the mouse pointer has moved out of the view.

References moveToWidget().

void dw::core::Layout::moveToWidget ( Widget newWidgetAtPoint,
ButtonState  state 
)
private
void dw::core::Layout::moveToWidgetAtPoint ( int  x,
int  y,
ButtonState  state 
)
inlineprivate

Emit the necessary crossing events, when the mouse pointer has moved to position (x, );.

References getWidgetAtPoint(), and moveToWidget().

int dw::core::Layout::nextGlyph ( const char *  text,
int  idx 
)
inline
int dw::core::Layout::prevGlyph ( const char *  text,
int  idx 
)
inline
bool dw::core::Layout::processMouseEvent ( MousePositionEvent event,
ButtonEventType  type 
)
private
void dw::core::Layout::queueDraw ( int  x,
int  y,
int  width,
int  height 
)
private
void dw::core::Layout::queueDrawExcept ( int  x,
int  y,
int  width,
int  height,
int  ex,
int  ey,
int  ewidth,
int  eheight 
)
private
void dw::core::Layout::queueResize ( bool  extremesChanged)
private
void dw::core::Layout::removeAnchor ( Widget widget,
char *  name 
)
private
void dw::core::Layout::removeWidget ( )
private
Bug:
Some more attributes must be reset here.
void dw::core::Layout::resetSearch ( )
inline
void dw::core::Layout::resizeIdle ( )
private
void dw::core::Layout::scroll ( ScrollCommand  cmd)
void dw::core::Layout::scrollIdle ( )
private
void dw::core::Layout::scrollPosChanged ( View view,
int  x,
int  y 
)
void dw::core::Layout::scrollTo ( HPosition  hpos,
VPosition  vpos,
int  x,
int  y,
int  width,
int  height 
)

Scrolls all viewports, so that the region [x, y, width, height] is seen, according to hpos and vpos.

Referenced by dw::fltk::FltkViewBase::manageTabToFocus(), and dw::core::Iterator::scrollTo().

void dw::core::Layout::scrollTo0 ( HPosition  hpos,
VPosition  vpos,
int  x,
int  y,
int  width,
int  height,
bool  scrollingInterrupted 
)
private

References platform.

FindtextState::Result dw::core::Layout::search ( const char *  str,
bool  caseSens,
int  backwards 
)
inline
void dw::core::Layout::setAnchor ( const char *  anchor)

Sets the anchor to scroll to.

Referenced by anchorCallback().

void dw::core::Layout::setBgColor ( style::Color color)
void dw::core::Layout::setBgImage ( style::StyleImage bgImage,
style::BackgroundRepeat  bgRepeat,
style::BackgroundAttachment  bgAttachment,
style::Length  bgPositionX,
style::Length  bgPositionY 
)
void dw::core::Layout::setCursor ( style::Cursor  cursor)
private
void dw::core::Layout::setSizeHints ( )
private
void dw::core::Layout::setWidget ( Widget widget)

References DBG_OBJ_ASSOC_CHILD.

Referenced by main(), and textTimeout().

char* dw::core::Layout::textToLower ( const char *  text,
int  len 
)
inline
char* dw::core::Layout::textToUpper ( const char *  text,
int  len 
)
inline
int dw::core::Layout::textWidth ( style::Font font,
const char *  text,
int  len 
)
inline
void dw::core::Layout::updateAnchor ( )
private
void dw::core::Layout::updateCursor ( )
private
void dw::core::Layout::viewportSizeChanged ( View view,
int  width,
int  height 
)

Friends And Related Function Documentation

friend class Widget
friend

Member Data Documentation

lout::container::typed::HashTable<lout::object::String, Anchor>* dw::core::Layout::anchorsTable
private
style::BackgroundAttachment dw::core::Layout::bgAttachment
private
style::Color* dw::core::Layout::bgColor
private

Referenced by getBgColor().

style::StyleImage* dw::core::Layout::bgImage
private

Referenced by getBgImage().

style::Length dw::core::Layout::bgPositionX
private
style::Length dw::core::Layout::bgPositionY
private
style::BackgroundRepeat dw::core::Layout::bgRepeat
private
int dw::core::Layout::canvasAscent
private
int dw::core::Layout::canvasDescent
private
bool dw::core::Layout::canvasHeightGreater
private
int dw::core::Layout::canvasWidth
private
style::Cursor dw::core::Layout::cursor
private
bool dw::core::Layout::drawAfterScrollReq
private
Emitter dw::core::Layout::emitter
private
FindtextState dw::core::Layout::findtextState
private
int dw::core::Layout::getExtremesCounter
private
int dw::core::Layout::hScrollbarThickness
private
LayoutImgRenderer* dw::core::Layout::layoutImgRenderer
private
LinkEmitter dw::core::Layout::linkEmitter
Platform* dw::core::Layout::platform
private

Referenced by getPlatform().

int dw::core::Layout::queueResizeCounter
private
lout::container::typed::Vector<Widget>* dw::core::Layout::queueResizeList
private
char* dw::core::Layout::requestedAnchor
private
int dw::core::Layout::resizeIdleCounter
private
int dw::core::Layout::resizeIdleId
private
int dw::core::Layout::scrollIdleId
private
bool dw::core::Layout::scrollIdleNotInterrupted
private
int dw::core::Layout::scrollTargetHeight
private
HPosition dw::core::Layout::scrollTargetHpos
private
VPosition dw::core::Layout::scrollTargetVpos
private
int dw::core::Layout::scrollTargetWidth
private
int dw::core::Layout::scrollTargetX
private
int dw::core::Layout::scrollTargetY
private
int dw::core::Layout::scrollX
private

Referenced by getScrollPosX().

int dw::core::Layout::scrollY
private

Referenced by getScrollPosY().

SelectionState dw::core::Layout::selectionState
private
int dw::core::Layout::sizeAllocateCounter
private
int dw::core::Layout::sizeRequestCounter
private
lout::misc::ZoneAllocator* dw::core::Layout::textZone
Widget* dw::core::Layout::topLevel
private
bool dw::core::Layout::usesViewport
private

Referenced by getUsesViewport().

View* dw::core::Layout::view
private
int dw::core::Layout::viewportHeight
private

Referenced by getHeightViewport().

int dw::core::Layout::viewportWidth
private

Referenced by getWidthViewport().

int dw::core::Layout::vScrollbarThickness
private
Widget * dw::core::Layout::widgetAtPoint
private

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