Ferreteria/v0.6/clade/IO/O/Data/Element/Branch/Text

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | O‎ | Data‎ | Element
Jump to navigation Jump to search
clade: IO\O\Data\Element\Branch\Text
Clade Family
Branch Text
Clade Aliases
Alias Clade
Base* [ca,i] IO\O\Data\Element\Branch
ElemIface IO\O\Data\Element
StyleIface Config\Style\String
Styled* [i,t] IO\O\Data\Element\aux\NeedsStyle
Subpages

About

  • Purpose: a simple text-element, for nesting

History

  • 2024-10-17 created
  • 2024-10-20 moved from [WFe]IO\O\Screen\Layout\Element -> [WFe]IO\O\Layout\tree\branch
  • 2024-10-21 moved from [WFe]IO\O\Layout\tree\branch -> [WFe]IO\O\Layout\Element\Branch
  • 2026-01-29 merged in [WFe]IO\O\Data\Element\Text

Code

as of 2026-01-29 (more revision definitely needed before it works again; there will be at least one language error):

interface iText extends BaseIface, StyledIface {
     function SText(string $s=NULL) : string;
}

class cText extends BaseClass implements iText {
    use StyledTrait;

    // ++ SETUP ++ //

    public function __construct(ElemIface $o, string $s) {
        parent::__construct($o);
        $this->WithString($s);
    }

    // ++ SETUP: dynamic ++ //

    private $s;
    protected function WithString(string $s) { $this->s = $s; }
    protected function Value() : string { return $this->s; }

    // -- SETUP -- //
    // ++ SETTINGS ++ //

    // TEMPLATE
    private $oStyle = NULL;
    public function OStyle() : StyleIface {
        $o = $this->oStyle;
        if (is_null($o)) {
            $o = $this->oStyle = new (static::StyleClass());
        }
        $o->OData($this);
        return $o;
    }

    // -- SETTINGS -- //
    // ++ DATA ++ //

    private $s = NULL;
    public function SText(string $s=NULL) : string { return is_null($s) ? $this->s : ($this->s = $s); }

    // -- DATA -- //
    // ++ OUTPUT ++ //

    public function RenderSelf() : string { return $this->s.CRLF; }

    /* 2026-01-29 Is this still needed/used?
    // CEMENT BaseIface
    public function ShowIt() { echo $this->SText(); }
    */

    // -- OUTPUT -- //
}