120
Chapter 11: Creating the User Interface
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
11.6. Example
This section will discuss the following example in detail. It has all of the
components described in this chapter: windows, menus (toolbars and pop-ups),
and dialog boxes. It uses the resource compiler for a static menu and dialog box,
and creates a dynamic pop-up.
// APP1.C
1
#include "tiams.h"
2
#include "app1.h"
3
#include "appr1.h"
4
5
static void AP_app(pFrame self, PEvent e);
6
FRAME(appObj, OO_SYSTEM_FRAME, 0, OO_APP_FLAGS, 4)
7
ATTR(OO_APP_FLAGS, APP_INTERACTIVE)
8
ATTR(OO_APP_NAME, "app1")
9
ATTR(OO_APP_PROCESS_EVENT, &AP_app)
10
ATTR(OO_APP_DEFAULT_MENU, &AppMenu )
11
ENDFRAME
12
13
pFrame pAppObj = (pFrame)&appObj; /* Must be 1st! */
14
WINDOW appW;
15
char buf[22];
16
17
static void AP_app(pFrame self, PEvent e) {
18
Access_AMS_Global_Variables;
19
WIN_RECT appWR;
20
HANDLE hPopup;
21
short key, vSelect; WORD opts[3];
22
char outStr[256];
23
24
switch (e->command) {
25
case CM_START:
26
appWR = *(e->info.startInfo.startRect);
27
if (WinOpen( &appW, &appWR, WF_TTY | WF_DUP_SCR))
28
WinClr( &appW );
29
else
30
EV_quit();
31
strcpy( buf, "FIRST" );
32
strcpy( buf+11, "SECOND" );
33
break;
34
case CM_ACTIVATE:
35
EV_defaultHandler(e);
36
EV_disableCmd(ACM_NOTHING);
37
WinBeginPaint( &appW );
38
WinActivate( &appW );
39
WinStr( &appW, "Just activated\n" );
40
break;
41
case CM_DEACTIVATE:
42
WinEndPaint( &appW );
43
break;
44
case CM_QUIT:
45
if (appW.Next) {
46
WinClose( &appW );
47
appW.Next = NULL;
48