#P1567. WIMP

WIMP

本题没有可用的提交语言。

描述

窗口管理器负责在图形用户界面中创建、显示、移动和调整窗口集合大小的细节。它还处理与这些窗口管理任务相关的输入事件(如鼠标单击)。您的项目是编写一个窗口管理程序(WIMP)。

WIMP控制的屏幕大小为102410241024 * 1024(以像素为单位),左上角像素为0,0(0,0),x坐标范围为屏幕左边缘00到右边缘10231023yy坐标范围为屏幕顶部00到底部10231023。所有坐标都是整数。用户可以通过移动鼠标并单击鼠标按钮来创建和操作矩形窗口。一个窗口有四个不同的区域:

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

一个窗口将总是至少512651 * 26,所以所有四个区域都是非空的。每个窗口被分配一个唯一的整数标识符,从00开始(创建的第一个窗口的idid00,创建的第二个窗口的idid11,依此类推)。标识符不被重用。

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

xyltrbx、y、l、t、r、b在屏幕尺寸范围内均为非负整数。CRCR事件总是生成一个适当形式的窗口。因为窗口可以重叠,在RERE事件中,它们必须从后(最近最少在顶部)到前(最近在顶部)重新绘制。这样可以确保它们正确地重叠在用户面前。WIMP的工作是跟踪所有的窗口,即使有些窗口是重叠的。它使用的规则是:

  1. 新窗口始终完全可见(位于所有其他窗口的“顶部”)。

  2. 窗口可见部分任意位置的 DNDN 事件都会选中该窗口并将其置于顶部,使整个窗口可见。不在任何窗口可见部分发生的DN DN 事件不会影响当前选定的窗口。

  3. 关闭和缩放都需要 DNDN 事件,并在相应的框中随后触发 UPUP 事件。两者之间可能有一个或多个AT AT 事件。DNDN 事件和 UPUP 事件必须位于同一个框中,但不必位于完全相同的位置。

  4. 关闭窗口会将其从屏幕上移除。

  5. 缩放是一个切换开关,可使窗口占据整个屏幕或恢复其初始大小。

  6. 移动栏中的 DNDN 事件允许重新定位窗口。UPUP 事件会停止移动。窗口移动的距离和方向与鼠标在 DNDN 事件和 UPUP 事件之间移动的距离和方向相同。

  7. 移动窗口时发生的 ATAT 事件必须输出窗口的当前位置。其他时间发生的 ATAT 事件不会产生任何输出。

  8. 占据整个屏幕的窗口无法移动。

  9. 窗口可以部分移出可见屏幕。

  10. 发生 ATAT 事件。

Input

输入包含一行或多行,每行包含一个事件。ZZZZ事件表示输入结束。这些事件都是同一会话的一部分。

输出

对于每个用户操作,输出相应的消息。在RERE事件中,所有窗口的位置必须使用如下格式从后往前输出。

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