Segger Logo Embedded Software Solutions
Software productsHardware productsDownloadsPricesCustomersOur PartnersSitemapForumAbout us
emWin: Window Manager
| Samples | Simulation | Font Converter | Bitmap Converter | Memory devices | Window Manager | Widgets | Dialogs | Multiple Layer/Displays | VNC Support | Touch Screen | Antialiasing | Drivers | Starter Boards | Virtual Screen Support | emWin Applications | PC Evaluation Versions |

The window manager supplies a set of routines which allow you to easily create, move, resize, and otherwise manipulate any number of windows. It also provides lower-level support by managing the layering of windows on the display and by alerting your application to display changes that affect its windows.

Explanation of terms

Windows are rectangular in shape, defined by their origin (the X- and Y-coordinates of the upper left corner) as well as their X- and Y-sizes (width and height, respectively). A window in emWin:

  • is rectangular.
  • has a Z-position.
  • may be hidden or shown.
  • may have valid and/or invalid areas.
  • may or may not have transparency.
  • may or may not have a callback routine.

Active window

The window which is currently being used for drawing operations is referred to as the active window. It is not necessarily the same as the topmost window.

Callback routines

Callback routines are defined by the user program, instructing the graphic system to call a specific function when a specific event occurs. Normally they are used to automatically redraw a window when its content has changed.

Child/parent windows, siblings

A child window is one that is defined relative to another window, called the parent. Whenever a parent window moves, its child or children move correspondingly. A child window is always completely contained within its parent, and will be clipped if necessary. Multiple child windows with the same parent are considered "siblings" to one another.

Client area

The client area of a window is simply its usable area. If a window contains a frame or title bar, then the client area is the rectangular inner area. If there is no such frame, then the coordinates of the client area are identical to those of the window itself.

Clipping, clip area

Clipping is the process of limiting output to a window or part of it. The clip area of a window is its visible area. This is the window area minus the area obstructed by siblings of higher Z-order, minus any part that does not fit into the visible area of the parent window.

Desktop window

The desktop window is automatically created by the window manager, and always covers the entire display area. It is always the bottommost window, and when no other window has been defined, it is the default (active) window. All windows are descendants (children, grandchildren, etc.) of the desktop window.

Handle

When a new window is created, the WM assigns it a unique identifier called a handle. The handle is used in any further operations performed on that particular window.

Hiding/showing windows

A hidden window is not visible, although it still exists (has a handle). When a window is created, it is hidden by default if no create flag is specified. Showing a window makes it visible; hiding it makes it invisible.

Transparency

A window that has transparency contains areas that are not redrawn with the rest of the window. These areas operate as though the window behind "shows through" them. In this case, it is important that the window behind is redrawn before the win- dow with transparency. The WM automatically handles redrawal in the correct order.

Validation/invalidation

Validation/invalidation

Z-position, bottom/top

Although a window is displayed on a two-dimensional screen in terms of X and Y, the WM also manages what is known as a Z-position, or depth coordinate -- a position in a virtual third dimension which determines its placement from background to fore- ground. Windows can therefore appear on top of or beneath one another. Setting a window to the bottom will place it "underneath" all of its sibling windows (if any); setting it to the top will place it "on top of" its siblings. When a window is created, it is set to the top by default if no create flag is specified.

API reference: WM

The following table lists the available routines of the emWin window manager API. All functions are listed in alphabetical order within their respective categories:

Routine Explanation
Basic functions
WM_ActivateActivates the window manager
WM_AttachWindowAttaches a window to a new parent window
WM_AttachWindowAtAttaches a window to a new parent window at the given position
WM_BroadcastMessageSends a message to all existing windows
WM_BringToBottomPlaces a window behind its siblings
WM_BringToTopPlaces a window in front of its siblings
WM_ClrHasTransClears the has transparency flag
WM_CreateWindowCreates a window
WM_CreateWindowAsChildCreates a child window
WM_DeactivateDeactivates the window manager
WM_DefaultProcDefault routine to handle messages
WM_DeleteWindowDeletes a window
WM_DetachWindowDetaches a window from its parent window
WM_DisableWindowSets the widget state to disabled
WM_EnableWindowSets the window state to enabled (default)
WM_ExecRedraws invalid windows by executing callbacks (all jobs)
WM_Exec1Redraws one invalid window by executing one callback (one job only)
WM_ForEachDescIterates over all descendants of a window
WM_GetActiveWindowReturns handle of the active window
WM_GetCallbackReturns a pointer to the callback function of a window
WM_GetClientRectReturns the size of the active window
WM_GetClientRectExReturns the size of a window
WM_GetDesktopWindowReturns the window handle of the desktop window
WM_GetDesktopWindowExReturns the window handle of the specified desktop window
WM_GetDialogItemReturns the window handle of a dialog box item (widget)
WM_GetFirstChildReturns handle of a window™s first child window
WM_GetFocussedWindowReturns the handle of the window with the input focus
WM_GetHasTransReturns current value of the has transparency flag
WM_GetInvalidRectReturns the invalid rectangle of the given window
WM_GetNextSiblingReturns the handle of a window™s next sibling
WM_GetOrgXReturns the origin in X of the active window
WM_GetOrgYReturns the origin in Y of the active window
WM_GetParentReturns handle of a window™s parent window
WM_GetPrevSiblingReturns the handle of a window™s previous sibling
WM_GetStayOnTopReturns current value of the stay on top flag
WM_GetUserDataRetrieves the user data of a window
WM_GetWindowOrgXReturns the origin in X of a window
WM_GetWindowOrgYReturns the origin in Y of a window
WM_GetWindowRectReturns the screen coordinates of the active window
WM_GetWindowRectExReturns the screen coordinates of a window
WM_GetWindowSizeXReturns the horizontal size (width) of a window
WM_GetWindowSizeYReturns the vertical size (height) of a window
WM_HasCapturedChecks if the given window has captured mouse- and touch screen-input
WM_HasFocusChecks if the given window has the input focus
WM_HideWindowMakes a window invisible
WM_InvalidateAreaInvalidates a certain section of the display
WM_InvalidateRectInvalidates a part of a window
WM_InvalidateWindowInvalidates a window
WM_IsCompletelyCoveredChecks if a window is completely covered or not
WM_IsCompletelyVisibleChecks if a window is completely visible or not
WM_IsEnabledReturns if a window is enabled or not
WM_IsVisibleReturns if a window is visible or not
WM_IsWindowDetermine whether a specified handle is a valid window handle
WM_MakeModalChanges the window to a ™modal™ window
WM_MoveChildToSets the position of a window in window coordinates
WM_MoveToSets the position of a window in desktop coordinates
WM_MoveWindowMoves a window to another position
WM_NotifyParentSends a WM_NOTIFY_PARENT message to the parent of the given window
WM_PaintDraws or redraws a window immediately
WM_PaintWindowAndDescsDraws a given window and all descendant windows immediately
WM_ReleaseCaptureStops capturing mouse- and touch screen-input
WM_ResizeWindowChanges window size
WM_SelectWindowSets the active window to be used for drawing operations
WM_SendMessageSends a message to a window
WM_SendMessageNoParaSends a message without parameters to a window
WM_SendToParentSends the given message to the parent window of the given window
WM_SetDesktopColorSets desktop window color
WM_SetDesktopColorExSets desktop window color of the given desktop
WM_SetCallbackSets the callback routine for a window
WM_SetCaptureStarts capturing mouse- and touch screen-input
WM_SetCreateFlagsSets the flags to be used as default when creating new windows
WM_SetFocusSets input focus to a specified window
WM_SetHasTransSets the has transparency flag
WM_SetIdSends a WM_SET_ID message to the given window
WM_SetpfPollPIDSets a function to be called by the WM for polling the PID
WM_SetSizeSets the new size of a window
WM_SetWindowPosSets size and position of a window
WM_SetXSizeSets the new X-size of a window
WM_SetYSizeSets the new Y-size of a window
WM_SetStayOnTopSets the stay on top flag
WM_SetTransStateSets or clears the WM_CF_HASTRANS and WM_CF_CONST_OUTLINE flags
WM_SetUserClipRectTemporarily reduce the clipping area
WM_SetUserDataSets the user data of the given window
WM_ShowWindowMakes a window visible
WM_UpdateDraws the invalid part of the given window
WM_UpdateWindowAndDescsDraws the invalid part of a given window and the invalid part of all descendant windows
WM_ValidateRectValidates parts of a window
WM_ValidateWindowValidates a window
Memory devices support (optional)
WM_DisableMemdevDisables usage of memory devices for redrawing
WM_EnableMemdevEnables usage of memory devices for redrawing
Time related
WM_CreateTimerCreates a timer which sends a WM_TIMER message to a window
WM_DeleteTimerDeletes a timer
WM_RestartTimerRestarts a timer
Widget related functions
WM_GetClientWindowReturns the handle of the client window
WM_GetIdReturns the ID of a widget
WM_GetInsideRectReturns the size of the active window less the border
WM_GetInsideRectExReturns the size of a window less the border
WM_GetScrollPosHReturns the scroll position of the windows horizontal scroll bar
WM_GetScrollPosVReturns the scroll position of the windows vertical scroll bar
WM_GetScrollStateGets the state of a scroll bar widget
WM_SetScrollPosHSets the scroll position of the windows horizontal scroll bar
WM_SetScrollPosVSets the scroll position of the windows vertical scroll bar
WM_SetScrollStateSets the state of a scroll bar widget

Callback mechanism of the window manager

The WM may be used with or without callback routines. In most cases, using callbacks is preferable.

Philosophy behind the callback mechanism

The idea behind the callback mechanism that emWin offers for windows and window objects (widgets) is that of an event-driven system. As in most windowing systems, the principle is that the flow of control is not just from the user program to the graphic system, but also from the user program to the graphic system and back up to the user program by means of the callback routines provided by the user program. This mechanism -- often characterized as the Hollywood principle ("Don't call us, we'll call you!") -- is needed by the window manager mainly in order to trigger the redrawing of windows. This contrasts with classical programming, but it makes it possible to exploit the invalidation logic of the window manager.

Not using callbacks

You do not have to use callback routines, but in doing so, the WM loses the ability to manage redrawing (updating) of the windows. It is also possible to mix; for example, having some windows use callbacks and others not. However, if a window does not use the callback mechanism, your application is responsible for updating its contents.

Copyright SEGGER Microcontroller GmbH & Co.KG. All rights reserved.
For more information, please visit our web site www.segger.com or contact us at info@segger.com
Last update: December 7, 2007