@startuml

note as N1
    This diagram shows only the important classes
    and interfaces. In case of class attributes and
    methods, it may not be complete compared to
    sourcecode.
end note

class YAGfx

class WidgetGroup {
    - m_gfx : YAGfx&
    - m_widgets : LinkedList<Widget*>
    + WidgetGroup(width : uint16_t, height : uint16_t, x : uint16_t, y : uint16_t)
    + getWidth() const : uint16_t
    + getHeight() const : uint16_t
    + getColor(x : int16_t, y : int16_t) = 0 : Color&
    + getColor(x : int16_t, y : int16_t) const : const Color&
    + addWidget(widget : Widget&) : bool
    + removeWidget(widget : Widget&) : bool
    + children() : const LinkedList<Widget*>&
    + update() : void
    + find(name : const char*) : Widget*
    - paint(gfx : YAGfx&) : void
    - drawPixel(x : int16_t, y : int16_t, color : uint16_t) : void
}

YAGfx <|-- WidgetGroup
Widget <|-- WidgetGroup
WidgetGroup o--> Widget

note right of WidgetGroup
    A widget group contains several widgets and
    will update them periodically. It ensures
    that a widget can not draw over the canvas
    borders.

    The widget group itself is a widget too and therefore
    can be inside another widget group.
end note

class Widget {
    - m_type : const char*
    - m_posX : uint16_t
    - m_posY : uint16_t
    - m_name : const char*
    - m_isEnabled : bool
    + move(x : uint16_t, y : uint16_t) : void
    + getPos(x : uint16_t&, y : uint16_t&) const : void
    + update(gfx : YAGfx&) : void
    + getType() : const char*
    + getName() : const char*
    + setName(name : const char*) : void
    + find(name : const char*) : Widget*
    # {abstract} paint(gfx : YAGfx&) = 0 : void
}

note left of Widget
    The base widget contains the
    position inside a canvas and declares
    the graphics interface.
end note

class TextWidget {
    - m_str : String
    - m_textColor : uint16_t
    + setFormatStr(str : const String&) : void
    + getFormatStr() : String
    + getStr() : String
    + setTextColor(color : uint16_t) : void
    + getTextColor() const : uint16_t
    + setFont(font : const GFXfont*) : void
    + getFont() : const GFXfont*
    + {static} setScrollPause(pause : uint32_t) : bool
    + getScrollInfo(isScrollingEnabled : bool&, scrollingCnt : uint32_t&) : bool
    - paint(gfx : YAGfx&) : void
}

Widget <|-- TextWidget

class BitmapWidget {
    - m_buffer : uint16_t*
    - m_width : uint16_t
    - m_height : uint16_t
    + set(bitmap : const Color*, width : uint16_t, height : uint16_t)
    + get(width : uint16_t&, height: uint16_t&) : const Color*
    + load(fs : FS&, filename : const String&) : bool
    - paint(gfx : YAGfx&) : void
}

Widget <|-- BitmapWidget

class LampWidget {
    - m_isOn : bool
    - m_colorOff : uint16_t
    - m_colorOn : uint16_t
    - m_width : uint16_t
    + setOnState(state : bool) : void
    + getOnState() const : bool
    + setColorOff(color : const Color&) : void
    + getColorOff() : const Color&
    + setColorOn(color : const Color&) : void
    + getColorOn() : const Color&
    + setWidth(width : uint16_t) : void
    + getWidth() const : uin16_t
    - paint(gfx : YAGfx&) : void
}

Widget <|-- LampWidget

@enduml