#P1567. WIMP
WIMP
本题没有可用的提交语言。
描述
窗口管理器负责在图形用户界面中创建、显示、移动和调整窗口集合大小的细节。它还处理与这些窗口管理任务相关的输入事件(如鼠标单击)。您的项目是编写一个窗口管理程序(WIMP)。
WIMP控制的屏幕大小为(以像素为单位),左上角像素为,x坐标范围为屏幕左边缘到右边缘,坐标范围为屏幕顶部到底部。所有坐标都是整数。用户可以通过移动鼠标并单击鼠标按钮来创建和操作矩形窗口。一个窗口有四个不同的区域:
Area Location and Size
Close box upper left hand corner of the window (25 *25 pixels)
Zoom box upper right hand corner of the window (25 *25 pixels)
Motion bar fills the top 25 pixels of the window, excluding zoom and close boxes
Data area remainder of the window
一个窗口将总是至少,所以所有四个区域都是非空的。每个窗口被分配一个唯一的整数标识符,从开始(创建的第一个窗口的为,创建的第二个窗口的为,依此类推)。标识符不被重用。
WIMP接受以下事件:
Event Meaning
DN x y user pressed mouse button at location (x, y)
UP x y user released mouse button at location (x, y)
AT x y user moved mouse to location (x, y)
CR l t r b create new window with positions left, top, right, and bottom
RE redraw all windows from back to front
ZZ exit the WIMP
在屏幕尺寸范围内均为非负整数。事件总是生成一个适当形式的窗口。因为窗口可以重叠,在事件中,它们必须从后(最近最少在顶部)到前(最近在顶部)重新绘制。这样可以确保它们正确地重叠在用户面前。WIMP的工作是跟踪所有的窗口,即使有些窗口是重叠的。它使用的规则是:
-
新窗口始终完全可见(位于所有其他窗口的“顶部”)。
-
窗口可见部分任意位置的 事件都会选中该窗口并将其置于顶部,使整个窗口可见。不在任何窗口可见部分发生的 事件不会影响当前选定的窗口。
-
关闭和缩放都需要 事件,并在相应的框中随后触发 事件。两者之间可能有一个或多个 事件。 事件和 事件必须位于同一个框中,但不必位于完全相同的位置。
-
关闭窗口会将其从屏幕上移除。
-
缩放是一个切换开关,可使窗口占据整个屏幕或恢复其初始大小。
-
移动栏中的 事件允许重新定位窗口。 事件会停止移动。窗口移动的距离和方向与鼠标在 事件和 事件之间移动的距离和方向相同。
-
移动窗口时发生的 事件必须输出窗口的当前位置。其他时间发生的 事件不会产生任何输出。
-
占据整个屏幕的窗口无法移动。
-
窗口可以部分移出可见屏幕。
-
发生 事件。
Input
输入包含一行或多行,每行包含一个事件。事件表示输入结束。这些事件都是同一会话的一部分。
输出
对于每个用户操作,输出相应的消息。在事件中,所有窗口的位置必须使用如下格式从后往前输出。
Action Message
Create window `Created window n at l, t, r, b'
Select window `Selected window n'
Close window `Closed window n'
Move window `Moved window n to l, t, r, b'
Zoom window `Resized window n to l, t, r, b'
Redraw `Window n at l, t, r, b'
CR 0 0 200 200
CR 50 50 250 250
RE
DN 195 5
AT 50 50
UP 198 6
AT 100 100
AT 1000 1000
DN 1020 10
UP 1020 10
RE
DN 100 100
UP 800 0
DN 0 700
UP 1023 1023
DN 50 10
AT 70 70
UP 100 100
DN 60 60
UP 60 60
RE
ZZ
Created window 0 at 0, 0, 200, 200
Created window 1 at 50, 50, 250, 250
Window 0 at 0, 0, 200, 200
Window 1 at 50, 50, 250, 250
Selected window 0
Resized window 0 to 0, 0, 1023, 1023
Selected window 0
Resized window 0 to 0, 0, 200, 200
Window 1 at 50, 50, 250, 250
Window 0 at 0, 0, 200, 200
Selected window 0
Selected window 0
Moved window 0 to 20, 60, 220, 260
Moved window 0 to 50, 90, 250, 290
Selected window 1
Closed window 1
Window 0 at 50, 90, 250, 290
来源
美国中南部1997