3, Ucgui Windows Manager principle

Source: Internet
Author: User

1, the window shape is a rectangle, by their origin (the upper left corner of the x and Y coordinates) and their x and y dimensions (respectively, width and height) are defined.

A window in Μc/gui:

is a rectangle · There is a Z-coordinate ·

may be hidden or visible, may have a valid/or invalid area · May or may not have transparent areas · Can or may not have a callback function

2.

active window

The window that is currently in use for drawing operations is treated as the active window.

callback function

The callback function is defined in the user program and notifies the graphics system to invoke the specified function when a specified event occurs. This is typically applied when a window content is changed automatically when it is redrawn.

Child/Parent window, sibling

The definition of a child window is relative to another window, which is called the parent window. Whenever a parent window moves, its child window moves accordingly. A child window is always completely contained within its parent window and is clipped if needed. The relationships between multiple child windows that belong to the same parent window are called "compatriots."

3.

Customer Area

The client area of a window is simply its available area. If a window includes a border or title bar, the customer area is the inner rectangular area. If there is no such a border, the client area is equivalent to the window itself.

Cut, cut area

Clipping is an action that restricts the output of a window or part of it. The clipping area is the original visible area of a window. These parts are clipped because the sibling window of the higher Z-sequence is obscured, or is not within the range of the visible area of the parent window.

Desktop window

The Desktop window is created automatically by the Windows Manager and always covers the entire display area. It is always a bottom-level window. If no other window is defined, it is the default (active) window. All windows are inherited windows of the Desktop window.

4.

Handle

When a new window is created, the WM assigns it a unique identifier, called a handle. Handles are used to perform further operations on a particular window.

Hide/Show window

A hidden window is invisible, although it still exists (with a handle). When a window is created, the default state is hidden if the specified identity is not created. Makes a window visible so that it can be displayed, or invisible, to hide it.

Transparent

A window with a transparent part includes an area that is not redrawn when the window is stationary. The operations of these areas are as if the following windows can be displayed through them. In this case, it is important that the following window is redrawn before this transparent window. The WM can automatically handle the correct redraw order.

5.

Valid/invalid

A valid window is a fully updated window that does not need to be redrawn. An invalid window is no longer responsive to all updates, so it needs to be completely or partially redrawn. When the change affects a particular window, the WM tag window is invalid. The next time the window is redrawn (either manually or through a callback function), it will be valid.

Z-order, bottom/top layer

Although a window is displayed on a two-dimensional screen that consists of only X and Y coordinates, the WM also manages the coordinates that are considered z-order, or depth (a virtual three-dimensional coordinate), which determines the window from background to foreground placement. So the window can be displayed above or below the other window.

Setting a window to the bottom will place it under all sibling windows (if one exists), and setting it to the top level will place it on top of all the sibling windows. When you create a window, if you do not specify the creation identifier, it is set to the top level by default.

6. WM API function

7. Callback mechanism of Windows Manager

The philosophy behind the callback mechanism
Μc/gui the callback mechanism provided for window and window objects (controls) is essentially an event-driven system. As in most Windows systems, the principle is that the control process is not just from the user program to the graphics system (the user program calls the graphics system function to update the window), but also from the graphics system back to the user program. This means that the graphical system can also invoke the callback function provided by the user program to achieve the purpose of updating the window. This mechanism often shows the characteristics of the Hollywood law ("Don't call us, we'll call you!") ")--is primarily the need for Windows Manager to redraw the window to start. Compared to traditional programs, it makes it possible to develop invalid logic for the Windows manager.

Do not use callback functions

You do not have to use a callback function, but in doing so, the WM will reduce efficiency when redrawing the window management. It can also be mixed, for example, some windows use callbacks while others are not used. However, if a window does not use a callback mechanism, your application must be responsible for updating the contents of the window.

Warning: When the callback mechanism is not used, the management of screen updates becomes your responsibility.

8. Using callback function

In order to create a window with a callback function, you must have a callback function. The name of the function will match the name of the callback function pointer parameter that corresponds to the window when it was created (that is, the CB parameter in Wm_createwindow (). All callback functions must have the following function prototypes:

Function prototype: void callback (wm_message* PMSG);

A pointer to the PMSG message.

The execution behavior of a callback function depends on the type of message it receives. The function prototypes above usually come with a switch declaration that defines the different processing methods used for different messages that use one or more event declarations (typically at least wm_paint ()).

3, Ucgui Windows Manager principle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.