[Main]
Name=EV_paintOneWindow
Type=Function
Subtype=ROM Call
Header Files=events.h
Definition=short EV_paintOneWindow (void);

[ROM Call]
Index=$CB

[Description]
Repaints the topmost window.

[Explanation]
EV_paintOneWindows searches through a linked list of windows (see
<A HREF="$$LINK(wingraph.h/)">wingraph.h</A> header file) for the first window
which has <A HREF="$$LINK(wingraph.h/WinFlags)">WF_DIRTY</A> flag set. If the found window
is visible (i.e. if <A HREF="$$LINK(wingraph.h/WinFlags)">WF_VISIBLE</A> flag is set), the
<A HREF="$$LINK(EventIDs)">CM_WPAINT</A> message is sent to the application which
is the owner of the window (note that <A HREF="$$LINK(wingraph.h/WinOpen)">WinOpen</A>
stores the task ID of the current application in <I>TaskID</I> field of the
<A HREF="$$LINK(wingraph.h/WINDOW)">WINDOW</A> structure). See also notes about
<A HREF="$$LINK(EV_sendEvent)">EV_sendEvent</A>. After sending this message,
<A HREF="$$LINK(wingraph.h/WinFlags)">WF_DIRTY</A> flag of the window is cleared, and this flag is
set in all other windows in the linked list of windows which overlap with this
window (because repainting of this window may cause trashing of another windows).
<BR><BR>
EV_paintOneWindow returns <A HREF="$$LINK(alloc.h/Bool)">TRUE</A> if the window was "painted"
(more precise, if <A HREF="$$LINK(EventIDs)">CM_WPAINT</A> message is sent), otherwise it
returns <A HREF="$$LINK(alloc.h/Bool)">FALSE</A> (i.e. if none to paint).
<BR><BR>
Here is an example which ilustrates that painting of all TIOS windows is "event
driven". Suppose that you make very simplified loop which "simulates" normal behaviour
of the calculator when it is in the home screen:
<PRE>while (TRUE)
{
  EV_getc (ACTIVITY_NORMAL, &amp;ev);
  EV_sendEvent (AP_CURRENT, &amp;ev);
}
</PRE>
If you try this program, you will notice that although you can type in statements, execute
user programs etc. from this loop, nothing happens on the screen when you type in
2 + 3 &lt;ENTER&gt; (i.e. result 5 is not displayed). This is because the
"Home screen" application didn't receive a message which forces redrawing of the Home screen.
You can see that everything will be correct if you make the following loop:
<PRE>while (TRUE)
{
  EV_getc (ACTIVITY_NORMAL, &amp;ev);
  EV_sendEvent (AP_CURRENT, &amp;ev);
  EV_paintOneWindow ();
}
</PRE>

[References]
In=EV_eventLoop, EV_paintWindows, unknown.h/paint_all_except
Out=EV_sendEvent, graph.h/QScrRectOverlap, wingraph.h/FirstWindow
