StyleOptions

Package: Libraries.Web.Styles · Inherits from: Libraries.Language.Object

StyleOptions holds a website's global look: one layout or style for each role an element can play, such as a stack of sections, a bulleted list, or a heading at each level. A page uses a role with, for example, SetStyle(list, options:GetBulletList()). For one element with its own look, copy the role and change the copy; the global role stays as it is. Those are the only two levels: the global one here, and one element's own. The values here are plain, broad defaults, so any page looks reasonable with no work. A website's own options are a child class that changes values in its "on create", never the roles.

Example Code

use Libraries.Web.Page.all
use Libraries.Web.Styles.StyleOptions

class Main is WebPage
    action Main
        StyleOptions options
        SetStyleOptions(options)

        Section section
        SetLayout(section, options:GetStack())
        UnorderedList list
        SetStyle(list, options:GetBulletList())
        list:AddListItem("First")
        section:Add(list)
        Add(section)
    end
end

Actions

AddScriptClass(text name, Libraries.Web.Styles.WebStyle style)

Gives a look a name of its own, which a page's scripts add to and remove from elements by name, such as "hidden" for something a button shows and hides. A named look wins over an element's own look while the element has it. Names use lowercase letters, digits and hyphens.

Parameters

Example

use Libraries.Web.Styles.StyleOptions
use Libraries.Web.Styles.WebBoxStyle

StyleOptions options
WebBoxStyle hidden
hidden:SetDisplayed(false)
options:AddScriptClass("hidden", hidden)

AddScriptClass(text name, Libraries.Web.Layouts.WebLayout layout)

Gives a layout a name of its own, which a page's scripts add to and remove from elements by name, such as a menu that is laid out in a row while it is open.

Parameters

AddStyleSheet(text location)

Adds a stylesheet that every page using these options links, such as a reset that clears the browser's own spacing. A page links it as soon as it is handed these options, so pages never name it.

Parameters

  • location text: The stylesheet's location in the site, with no leading slash, such as "style/reset.css".

Example

use Libraries.Web.Styles.StyleOptions

StyleOptions options
options:AddStyleSheet("style/reset.css")

GetBold()

Returns the style for bold words with no other meaning.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for bold words with no other meaning.

GetBulletList()

Returns the style for a bulleted list.

Returns

Libraries.Web.Styles.WebListStyle: The global bulleted list style.

GetCallout()

Returns the style for the body of a callout: a box set apart from the text, such as a tip.

Returns

Libraries.Web.Styles.WebBoxStyle: The global callout style.

GetCalloutLabel()

Returns the style for a callout's label, the bar naming it, such as "Tip". A site with several kinds of callout gives each its own label style in its options.

Returns

Libraries.Web.Styles.WebBoxStyle: The global callout label style.

GetCode()

Returns the style for code, such as an action's name.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for code, such as an action's name.

GetCodeExample()

Returns the style for code shown as an example, on its own lines.

Returns

Libraries.Web.Styles.WebBoxStyle: The global code example style.

GetDescription()

Returns the style for a description in a description list, under its term.

Returns

Libraries.Web.Styles.WebBoxStyle: The global description style.

GetDescriptionList()

Returns the layout for a description list: each term beside its description, with the descriptions lined up.

Returns

Libraries.Web.Layouts.WebGridLayout: The global description list layout.

GetDescriptionListLabel()

Returns the style for a description list's label, above its pairs.

Returns

Libraries.Web.Styles.WebTextStyle: The global description list label style.

GetDescriptionTerm()

Returns the style for a term in a description list.

Returns

Libraries.Web.Styles.WebTextStyle: The global description term style.

GetEmphasis()

Returns the style for words said with stress.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for words said with stress.

GetFigure()

Returns the layout for a figure: a picture with its caption under it.

Returns

Libraries.Web.Layouts.WebStackLayout: The global figure layout.

GetFigureCaption()

Returns the style for a figure's caption.

Returns

Libraries.Web.Styles.WebTextStyle: The global figure caption style.

GetHeading(integer level)

Returns the style for a heading at one level, from 1 (the largest) to 6.

Parameters

  • level integer: The heading's level, from 1 to 6.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for headings at that level.

GetKey()

Returns the style for a key to press.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for a key to press.

GetLabeledDescriptionList()

Returns the style for the box around a description list that has a label.

Returns

Libraries.Web.Styles.WebBoxStyle: The global labeled description list style.

Returns the style for links in the text, such as in a paragraph or list item.

Returns

Libraries.Web.Styles.WebTextStyle: The global link style.

GetNumberedList()

Returns the style for a numbered list.

Returns

Libraries.Web.Styles.WebListStyle: The global numbered list style.

GetOutput()

Returns the style for what a program prints or says.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for program output.

GetPage()

Returns the style for the page as a whole: its background, and, through its text style, its font, text size and color. Every page using these options has it.

Returns

Libraries.Web.Styles.WebBoxStyle: The global page style.

GetScriptClass(text name)

Gives a look a name of its own, which a page's scripts add to and remove from elements by name, such as "hidden" for something a button shows and hides. A named look wins over an element's own look while the element has it. Names use lowercase letters, digits and hyphens.

Parameters

  • name text: The name scripts use.

Returns

Libraries.Web.Styles.WebStyle

Example

use Libraries.Web.Styles.StyleOptions
use Libraries.Web.Styles.WebBoxStyle

StyleOptions options
WebBoxStyle hidden
hidden:SetDisplayed(false)
options:AddScriptClass("hidden", hidden)

GetScriptClassDeclarations(text name)

Returns the declarations of a named look, for the stylesheet.

Parameters

  • name text: The name.

Returns

text: The declarations.

GetScriptClassNames()

Gives a layout a name of its own, which a page's scripts add to and remove from elements by name, such as a menu that is laid out in a row while it is open.

Returns

Libraries.Containers.Array<text>

GetStack()

Returns the layout for a stack: items one under another, such as the parts of a lesson.

Returns

Libraries.Web.Layouts.WebStackLayout: The global stack layout.

GetStrong()

Returns the style for important words.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for important words.

GetStyleSheets()

Returns the stylesheets every page using these options links.

Returns

Libraries.Containers.Array<text>: The stylesheets' locations.

GetTable()

Returns the style for a table.

Returns

Libraries.Web.Styles.WebTableStyle: The global table style.

GetTableCaption()

Returns the style for a table's caption, its name above it.

Returns

Libraries.Web.Styles.WebBoxStyle: The global table caption style.

GetTableCell()

Returns the style for the rest of a table's cells.

Returns

Libraries.Web.Styles.WebBoxStyle: The global table cell style.

GetTableHeaderCell()

Returns the style for a cell naming a column, in a table's first row.

Returns

Libraries.Web.Styles.WebBoxStyle: The global column name style.

GetTableRowHeaderCell()

Returns the style for a cell naming a row, at the start of each of a table's rows after the first.

Returns

Libraries.Web.Styles.WebBoxStyle: The global row name style.

GetTerm()

Returns the style for a term at the place it is introduced or defined.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for a term at the place it is introduced or defined.

GetVariable()

Returns the style for the name of a variable.

Returns

Libraries.Web.Styles.WebTextStyle: The global style for variable names.

SetReset(boolean value)

Sets whether the site's stylesheet starts by clearing browsers' own spacing and sizes (margins around headings and paragraphs, list indents, and the like), so pages look the same in every browser and only the site's styles add space. The default is true.

Parameters

  • value boolean: True to clear browsers' own spacing.

UsesReset()

Sets whether the site's stylesheet starts by clearing browsers' own spacing and sizes (margins around headings and paragraphs, list indents, and the like), so pages look the same in every browser and only the site's styles add space. The default is true.

Returns

boolean

Inherited Actions

3 actions from Libraries.Language.Object