元编程参考文档

图形界面应用

37 个节点

本页内容 37

图形界面应用

函数

此节点没有文档说明。

签名
图形界面应用() -> GUI Application
GUIApplication GUIApplication()

返回

图形界面应用GUI Application
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

添加按钮

函数

Add a button. Pressing it delivers its intent to the Clicked callback.

签名
添加按钮
    GUI Application: GUI Application
    文本: 文本
    意图: 文本
    种类: Button Kind
    名称: 文本
void AddButton(
    GUIApplication GUI Application,
    string text,
    string intent,
    ButtonKind kind = ButtonKind.Secondary,
    string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
文本文本—The caption.
意图文本—What pressing it means. The caption, unless the graph says otherwise - so a keypad's "7" means "7" with nothing more said, and a button captioned "Go" can mean "Start Run".
种类Button Kind次要How it looks, which says how important it is.
名称文本—A name, so the button can be reached afterwards. The intent, unless the graph says otherwise.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

添加分隔线

函数

Add a hairline rule.

签名
添加分隔线(GUI Application: GUI Application)
void AddDivider(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

添加标签

函数

Add a line of text.

签名
添加标签
    GUI Application: GUI Application
    文本: 文本
    名称: 文本
    角色: Label Role
    对齐方式: Text Alignment
void AddLabel(
    GUIApplication GUI Application,
    string text = "",
    string name,
    LabelRole role = LabelRole.Body,
    TextAlignment alignment = TextAlignment.Left)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
文本文本—What it says.
名称文本—A name, so the text can be changed afterwards with Set Text.
角色Label Role正文How prominent it is.
对齐方式Text Alignment左对齐Where the text sits in the room it has.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

添加间隔

函数

Add empty room: a fixed number of pixels, or with no size, whatever room is free.

签名
添加间隔(GUI Application: GUI Application, 大小: 数字)
void AddSpacer(GUIApplication GUI Application, double size = 0)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
大小数字0Pixels, or 0 to take the free room in a column or row.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

添加文本框

函数

Add a line of text the person can edit. Read it back with Get Text.

签名
添加文本框
    GUI Application: GUI Application
    名称: 文本
    文本: 文本
    占位文本: 文本
    意图: 文本
void AddTextBox(
    GUIApplication GUI Application,
    string name,
    string text = "",
    string placeholder = "",
    string intent)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—A name; a text box exists to be read, so it always has one.
文本文本—What it starts out saying.
占位文本文本—A hint shown while it is empty.
意图文本—在框中按 Enter 的含义,像按下按钮一样交给“已点击”——让文本框和它的按钮用同一个意图,Enter 和按钮就做同一件事,只写一次。留空时,按 Enter 不通知任何东西。
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

开始卡片

函数

Open a card: a raised surface with an optional heading, holding its children in a column.

签名
开始卡片
    GUI Application: GUI Application
    标题: 文本
    副标题: 文本
    名称: 文本
void BeginCard(
    GUIApplication GUI Application,
    string title,
    string subtitle,
    string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
标题文本—The heading, or nothing for a plain surface.
副标题文本—A second line under the heading.
名称文本—A name, if the graph will need to reach the card afterwards.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

开始列

函数

Open a column: everything added until the matching End stacks top to bottom.

签名
开始列(GUI Application: GUI Application, 间距: 数字, 名称: 文本)
void BeginColumn(
    GUIApplication GUI Application,
    double spacing = 10,
    string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
间距数字10Gap between the children, in pixels.
名称文本—A name, if the graph will need to reach the column afterwards.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

开始网格

函数

Open a grid of equal cells. Children fill it row by row, in the order they are added, unless one is
placed explicitly with GUIApplication.PlaceInGrid.

签名
开始网格
    GUI Application: GUI Application
    列数: 整数
    行数: 整数
    间距: 数字
    名称: 文本
void BeginGrid(
    GUIApplication GUI Application,
    int columns = 2,
    int rows = 0,
    double spacing = 8,
    string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
列数整数2How many cells across.
行数整数0How many cells down, or 0 for as many as the children need.
间距数字8Gap between cells, in pixels.
名称文本—A name, if the graph will need to reach the grid afterwards.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

开始行

函数

Open a row: everything added until the matching End runs left to right.

签名
开始行(GUI Application: GUI Application, 间距: 数字, 名称: 文本)
void BeginRow(
    GUIApplication GUI Application,
    double spacing = 8,
    string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
间距数字8Gap between the children, in pixels.
名称文本—A name, if the graph will need to reach the row afterwards.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

关闭

函数

Ask to stop. Whatever is running the application decides what that means - a windowed host closes its
window, an offline driver stops pumping.

签名
关闭(GUI Application: GUI Application)
void Close(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

结束

函数

Close the innermost open container. Every Begin needs one.

签名
结束(GUI Application: GUI Application)
void End(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

期望的窗口大小

函数

How big a window to open. A host offers a default before anything runs; the entry callback may say
otherwise, and the host honours whatever the answer is when it opens a window.

签名
期望的窗口大小(GUI Application: GUI Application) -> Size
Size DesiredWindowSize(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—

返回

结果Size
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

期望的窗口标题

函数

The window's title.

签名
期望的窗口标题(GUI Application: GUI Application) -> 文本
string DesiredWindowTitle(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—

返回

结果文本
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

获取已用时间

函数

Time the current frame represents, in milliseconds.

签名
获取已用时间(GUI Application: GUI Application) -> 数字
double GetElapsedTime(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—

返回

结果数字
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

获取文本

函数

What a named element says right now - for a text box, what the person has typed.

签名
获取文本(GUI Application: GUI Application, 名称: 文本) -> 文本
string GetText(GUIApplication GUI Application, string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—

返回

结果文本
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

是否有该元素

函数

Whether the screen has an element of this name.

签名
是否有该元素 -> 真否
    GUI Application: GUI Application
    名称: 文本
bool HasElement(GUIApplication GUI Application, string name)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—

返回

结果真否
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

放入网格

函数

Put the element added most recently in a particular cell of the grid it is in.

签名
放入网格
    GUI Application: GUI Application
    行: 整数
    列: 整数
    跨行数: 整数
    跨列数: 整数
void PlaceInGrid(
    GUIApplication GUI Application,
    int row,
    int column,
    int rowSpan = 1,
    int columnSpan = 1)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
行整数—The row, from 0 at the top.
列整数—The column, from 0 at the left.
跨行数整数1How many rows it covers.
跨列数整数1How many columns it covers.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

按下

函数

Act on an intent as if a button meaning it had been pressed - what a keyboard shortcut does.

签名
按下(GUI Application: GUI Application, 意图: 文本)
void Press(GUIApplication GUI Application, string intent)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
意图文本—What to act on.

备注

The reason a keyboard arm does not have to repeat a click arm: a graph reads a key, decides which of
its own keys it stands for, and presses that. The press is indistinguishable from a real one - the
same GUIApplication.Clicked, the same GUIApplication.WasClicked for the rest of the frame - because it
goes through the same door. An intent no button carries is allowed: a key may mean something the
screen has no button for.

Calling this from inside GUIApplication.Clicked with the intent being handled would not return; that
is the ordinary hazard of a callback that calls itself, and the answer is the ordinary one.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

重新构建

函数

Ask for the screen to be described again: Build runs afresh before the next frame, and the widgets
are made anew from what it says.

签名
重新构建(GUI Application: GUI Application)
void Rebuild(GUIApplication GUI Application)

参数

名称类型默认值说明
GUI ApplicationGUI Application—

备注

Requested rather than done here, because the host is in the middle of a frame - possibly inside the
very button handler asking for this - and the widgets it is routing input through must not be replaced
under it. Nothing is lost by waiting one frame; a rebuild is for a screen whose SHAPE changes, and
text that merely changes goes through GUIApplication.SetText without one.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置启用

函数

Whether a named element can be used. A disabled button draws dimmed and delivers nothing.

签名
设置启用
    GUI Application: GUI Application
    名称: 文本
    启用: 真否
void SetEnabled(
    GUIApplication GUI Application,
    string name,
    bool enabled = true)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—
启用真否True
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置内边距

函数

Set the room inside the edge of the container opened most recently.

签名
设置内边距(GUI Application: GUI Application, 内边距: 数字)
void SetPadding(
    GUIApplication GUI Application,
    double padding = 14)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
内边距数字14Pixels on every side.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置大小

函数

Fix the size of the element added most recently. Leave a dimension NaN to keep it free.

签名
设置大小
    GUI Application: GUI Application
    宽度: 数字
    高度: 数字
void SetSize(
    GUIApplication GUI Application,
    double width = double.NaN,
    double height = double.NaN)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
宽度数字NaNPixels, or NaN for "as wide as it needs and may".
高度数字NaNPixels, or NaN for "as tall as it needs and may".
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置拉伸

函数

Give the element added most recently a share of the free room in its column or row.

签名
设置拉伸(GUI Application: GUI Application, 权重: 数字)
void SetStretch(
    GUIApplication GUI Application,
    double weight = 1)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
权重数字1Its share, against the shares of its siblings. 1 for an equal share.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置文本

函数

Change what a named element says: a label's text, a button's caption, a text box's content.

签名
设置文本
    GUI Application: GUI Application
    名称: 文本
    文本: 文本
void SetText(
    GUIApplication GUI Application,
    string name,
    string text = "")

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—
文本文本—
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置文字自适应

函数

Draw the text of the element added most recently as large as fits it, growing and shrinking with the room it is given - or, for a container, the text of every label and button inside it.

签名
设置文字自适应
    GUI Application: GUI Application
    自适应: 真否
    边距: 数字
void SetTextFit(
    GUIApplication GUI Application,
    bool fit = true,
    double margin = 0.2)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
自适应真否TrueWhether to fit the text; false goes back to the size its role has.
边距数字0.2How much room to leave round the text, as a share of the box's shorter side on each side: 0.2 leaves a fifth above and below.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置可见

函数

Whether a named element is shown at all. A hidden element takes no room.

签名
设置可见
    GUI Application: GUI Application
    名称: 文本
    可见: 真否
void SetVisible(
    GUIApplication GUI Application,
    string name,
    bool visible = true)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
名称文本—
可见真否True
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置窗口大小

函数

Set the size the window opens at.

签名
设置窗口大小
    GUI Application: GUI Application
    宽度: 数字
    高度: 数字
void SetWindowSize(
    GUIApplication GUI Application,
    double width = 480,
    double height = 640)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
宽度数字480
高度数字640
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

设置窗口标题

函数

Set the window's title.

签名
设置窗口标题(GUI Application: GUI Application, 标题: 文本)
void SetWindowTitle(
    GUIApplication GUI Application,
    string title = "Divooka")

参数

名称类型默认值说明
GUI ApplicationGUI Application—
标题文本Divooka
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

显示通知

函数

Show a brief notice in the corner of the window.

签名
显示通知(GUI Application: GUI Application, 消息: 文本)
void ShowNotice(GUIApplication GUI Application, string message)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
消息文本—

备注

Queued rather than shown, because this package has nothing to show it with; the host drains the queue
each frame. A message posted from Start, before there is a window, is shown on the first frame.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

是否被点击

函数

Whether a button meaning this was pressed during the current frame.

签名
是否被点击(GUI Application: GUI Application, 意图: 文本) -> 真否
bool WasClicked(GUIApplication GUI Application, string intent)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
意图文本—

返回

结果真否

备注

The polling half of input, for an Update that would rather ask than be told. False outside a
frame and false for an intent nobody named: an unpressed button is the ordinary case.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

是否按下了键

函数

Whether this key was pressed during the current frame.

签名
是否按下了键(GUI Application: GUI Application, 键: 文本) -> 真否
bool WasKeyPressed(GUIApplication GUI Application, string key)

参数

名称类型默认值说明
GUI ApplicationGUI Application—
键文本—The key, as GUIApplication.KeyPressed describes it.

返回

结果真否

备注

The polling half of the keyboard, for an Update that would rather ask than be told.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
图形界面应用
所属包
图形界面应用

构建

事件

Describe the screen: open containers, add labels and buttons, close containers. Runs once when the
window is ready, and again whenever the graph asks to GUIApplication.Rebuild.

签名
构建()
void Build()
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 状态机状态
声明于
图形界面应用
所属包
图形界面应用

已点击

事件

A button was pressed.

签名
已点击(意图: 文本)
void Clicked(string intent)

参数

名称类型默认值说明
意图文本—What the button MEANS - the intent it was added with, which is its caption unless the graph said otherwise.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 状态机状态
声明于
图形界面应用
所属包
图形界面应用

已按键

事件

A key was pressed.

签名
已按键(键: 文本)
void KeyPressed(string key)

参数

名称类型默认值说明
键文本—The key, as text. A key that types something arrives as what it typed - "7", ".", "+", "A" - and a key that types nothing arrives by name: "Enter", "Escape", "Backspace", "Tab", "Delete", "Left", "Right", "Up", "Down", "Home", "End", "Page Up", "Page Down", "Insert", "F1".."F12". See GUIApplication.NamedKeys.

备注

Text rather than a key enumeration, for two reasons. A graph compares text - that is what its Equals
and Choose nodes are for - and an enumeration would need a palette of its own before a document could
name a key. And what a key TYPES is the layout's answer, not the keycode's: the key beside
0 types . on one keyboard and , on another, and a calculator wants the former.
A key held down repeats as the platform repeats it, because that is what a person typing expects.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 状态机状态
声明于
图形界面应用
所属包
图形界面应用

启动

事件

Divooka procedural program entry, equivalent to "Main" in many programming languages. Runs before the
window exists, which is where window size and title belong; the screen itself is described in
GUIApplication.Build.

签名
启动()
void Start()
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 状态机状态
声明于
图形界面应用
所属包
图形界面应用

更新

事件

Called once per frame, after that frame's presses have been delivered.

签名
更新(时间增量(毫秒): 数字)
void Update(double deltaTimeMilliseconds)

参数

名称类型默认值说明
时间增量(毫秒)数字—Time elapsed since the previous frame.
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 状态机状态
声明于
图形界面应用
所属包
图形界面应用