WinOpen Function (ROM Call 0x1E)

wingraph.h

short WinOpen (WINDOW *w, const WIN_RECT *rect, unsigned short Flags, ...);

Opens a new window.

WinOpen opens a new window, initializing all fields of the WINDOW structure pointed to by w, and then links this window into the current list of windows as the topmost window. rect is the pointer to the rectangular structure of type WIN_RECT which defines the window area. The flags defined in Flags may be set as one or more of the following constants defined in the enum WinFlags (they have to be ORed; note that WF_SAVE_SCR and WF_DUP_SCR are mutually exclusive):

WF_SAVE_SCR Save the screen region underneath the window (restore it when the window is closed).
WF_DUP_SCR Keep a duplicate copy of all data written to the window; when the window needs to be updated, the application will not receive a CM_WPAINT message, instead the system will update the window (see EV_paintOneWindow for more info).
WF_TTY Write characters in TTY mode (translate '\n' and '\r' to a newline, '\f' to clear screen, and wrap at end of lines).
WF_NOBOLD When window is activated, do not make the window's border bold.
WF_NOBORDER Do not draw a border around the window.
WF_ROUNDEDBORDER Draw a rounded border instead of rectangular border (this option implies WF_NOBOLD as well).
WF_TITLE Draw a title bar; in this case the Flags parameter must be followed by a text string which will be used as the window title (according to my experience, it seems that only windows with rounded borders may have title bars).
WF_VIRTUAL Set this flag for virtual windows which are just allocated bitmaps in memory and which are not limited to the size of the screen; no writes to actual LCD are done, only writes to a duplicate screen area (so WF_DUP_SCR must also be set).

WinOpen returns FALSE if there is not enough memory to allocate the save buffer, else returns TRUE. Here is an example (called "Window 4") which displays "hello everyone" in a window (assuming that there were no errors):

#define USE_TI89              // Compile for TI-89
#define USE_TI92PLUS          // Compile for TI-92 Plus
#define USE_V200              // Compile for V200

#define OPTIMIZE_ROM_CALLS    // Use ROM Call Optimization
#define MIN_AMS 100           // Compile for AMS 1.00 or higher
#define SAVE_SCREEN           // Save/Restore LCD Contents

#include <tigcclib.h>         // Include All Header Files

// Main Function
void _main(void)
{
  WINDOW *wind = HeapAllocPtr (sizeof (WINDOW));
  WinOpen (wind, MakeWinRect (20, 20, 80, 50), WF_SAVE_SCR | WF_TTY);
  WinActivate (wind);
  WinFont (wind, F_6x8);
  WinStr (wind, "hello everyone");
  ngetchx ();
  WinClose (wind);
  HeapFreePtr (wind);
}
Like any other function which allocates a memory block, WinOpen may cause heap compression.

Note: You must call WinActivate to display a window on the screen, although TI said that you do not need to do so. Also, don't forget to close all windows (using WinClose or WinRemove) before the end of the program, else the TI will crash later, when the TIOS window manager tries to refresh a window in the list which ceased to exist after terminating the program!


Uses: FirstWindow, WinClr, WinHome, HeapAlloc, BitmapGet, BitmapInit, BitmapSize, memcpy, memset, EV_runningApp
Used by: WinReOpen, assert, cmd_newpic, cmd_showstat, Dialog, ERD_dialog, ABT_dialog, EV_defaultHandler, handleVarLinkKey, HelpKeys, ERD_notice, EV_quit, ROM Call 0x45B