~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to tads/tads3/test/data/banner_api2.t

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <tads.h>
 
2
 
 
3
main(args)
 
4
{
 
5
    local win;
 
6
    local win2;
 
7
    local win3;
 
8
    local moreStyle;
 
9
 
 
10
    /* 
 
11
     *   use MORE mode in most of the banners unless there's a "-nomore"
 
12
     *   option in the arguments 
 
13
     */
 
14
    moreStyle = (args.indexOf('-nomore') == nil ? BannerStyleMoreMode : 0);
 
15
    
 
16
    "This is a test of various banner API capabilities.\n";
 
17
 
 
18
    win = bannerCreate(nil, BannerLast, nil, BannerTypeText, BannerAlignLeft,
 
19
                       20, BannerSizePercent,
 
20
                       BannerStyleVScroll | BannerStyleAutoVScroll
 
21
                       | BannerStyleBorder | moreStyle);
 
22
    bannerSay(win, '<body bgcolor=silver text=black>This is a
 
23
        vertical banner window on the left sized to 20% of the
 
24
        total application window size.  This window has a border
 
25
        and a vertical scrollbar, and automatically scrolls vertically
 
26
        when new contents are displayed and they don\'t fit in the
 
27
        window\'s existing height. [end part one]');
 
28
 
 
29
    "Press a key to continue...\n";
 
30
    inputKey();
 
31
 
 
32
    bannerSay(win, '\bThis is some more text, following a blank line,
 
33
        in the left banner window.  The goal here is to eventually
 
34
        provide enough text to make the window scroll past the bottom,
 
35
        so that we can see the auto-vscroll effect in action.
 
36
        [end part two]');
 
37
 
 
38
    "Press another key to continue...\n";
 
39
    inputKey();
 
40
 
 
41
    bannerSay(win, '\bAnd finally, some more text, again following a
 
42
        blank line.  This should be enough to overflow 50 lines, so
 
43
        it should give us auto-scrolling on the DOS console version,
 
44
        and should be plenty even for a fairly good-sized window in
 
45
        HTML mode. [end part three]');
 
46
 
 
47
    "Press yet another key...\n";
 
48
    inputKey();
 
49
 
 
50
    win2 = bannerCreate(win, BannerFirst, nil, BannerTypeText, BannerAlignTop,
 
51
                        40, BannerSizePercent, BannerStyleBorder);
 
52
    bannerSay(win2, '<body bgcolor=navy text=white>This is a banner that
 
53
        should split off the top half of the left pane. This is to exercise
 
54
        the parent/child parameters. [end of child banner text]');
 
55
 
 
56
    "Press another key...\n";
 
57
    inputKey();
 
58
 
 
59
    bannerDelete(win);
 
60
    bannerDelete(win2);
 
61
 
 
62
    win = bannerCreate(nil, BannerLast, nil, BannerTypeText, BannerAlignRight,
 
63
                       15, BannerSizePercent,
 
64
                       BannerStyleVScroll | BannerStyleBorder);
 
65
    bannerSay(win, '<body bgcolor=yellow text=black>This is another
 
66
        vertical banner.  This time, the banner is only 15% of the total
 
67
        screen/application window width.  This one has a border and
 
68
        a vertical scrollbar, but it does NOT scroll automatically when
 
69
        it overflows. [end part one]');
 
70
 
 
71
    "\bPress a key...\n";
 
72
    inputKey();
 
73
    
 
74
    bannerSay(win, '\bHopefully we can overflpow this one a bit more
 
75
        quickly because of its diminutive width.  When this one overflows,
 
76
        it should just sit at the top - it should not scroll down by itself.
 
77
        On interpreters that offer a scrollbar, of course, the user can
 
78
        manually scroll down; on non-scrollbar interpreters, the text after
 
79
        the bottom of the window will be unviewable. [end part two]');
 
80
 
 
81
    "\nPress a key...\n";
 
82
    inputKey();
 
83
 
 
84
    win2 = bannerCreate(nil, BannerFirst, nil, BannerTypeText,
 
85
                        BannerAlignBottom, 20, BannerSizePercent,
 
86
                        BannerStyleVScroll | BannerStyleBorder
 
87
                        | BannerStyleAutoVScroll | moreStyle);
 
88
    bannerSay(win2, '<body bgcolor=text text=bgcolor>This one is a
 
89
        bottom banner.  It has a scrollbar and a border, and
 
90
        automatic vertical scrolling.  The interesting thing about this
 
91
        one will be to ensure that the border is properly excluded from
 
92
        the scrolling area.
 
93
        \bNote another important thing about this banner: it\'s inserted
 
94
        first in the banner list, so it should be formatted to take up
 
95
        the entire bottom of the screen.  The right-aligned banner still
 
96
        on the screen from earlier should shrink vertically to give room
 
97
        to this banner.[end part one]');
 
98
    
 
99
    "\bPress a key...\n";
 
100
    inputKey();
 
101
 
 
102
    bannerSay(win2, '\bHere is some more text.  That should about do
 
103
        it.  We should not need too much, since the banner should only
 
104
        get about ten lines or so on a 50-line main window.  So, we
 
105
        should be getting pretty close to the bottom by now.
 
106
        \b
 
107
        That blank line should help!
 
108
        \n[end part two]');
 
109
 
 
110
    win3 = bannerCreate(nil, BannerBefore, win2, BannerTypeTextGrid,
 
111
                        BannerAlignBottom, nil, nil, 0);
 
112
 
 
113
    /* size the banner to a height of eight lines */
 
114
    bannerSetScreenColor(win3, ColorRGB(255, 255, 0));
 
115
    bannerSetTextColor(win3, ColorRGB(255, 0, 0), ColorTransparent);
 
116
    bannerGoTo(win3, 8, 1);
 
117
    bannerSay(win3, '\u00A0');
 
118
    bannerFlush(win3);
 
119
    bannerSizeToContents(win3);
 
120
 
 
121
    /* show some stuff in the banner at various positions */
 
122
    bannerGoTo(win3, 5, 10);
 
123
    bannerSay(win3, '* at row 5, column 10');
 
124
    bannerSetTextColor(win3, ColorRGB(0, 0, 128), ColorTransparent);
 
125
    bannerGoTo(win3, 7, 20);
 
126
    bannerSay(win3, '* at row 7, column 20');
 
127
 
 
128
    "\bPress a key...\n";
 
129
    inputKey();
 
130
 
 
131
    bannerGoTo(win3, 3, 10);
 
132
    bannerSay(win3, '> at row 3, column 10');
 
133
    bannerGoTo(win3, 4, 20);
 
134
    bannerSay(win3, '> at row 4, column 20');
 
135
    bannerGoTo(win3, 6, 10);
 
136
    bannerSay(win3, '  Here  is  a   line    with   excess   spaces.   ');
 
137
    bannerSay(win3, '<eol>');
 
138
 
 
139
    "\nPress a key...\n";
 
140
    inputKey();
 
141
 
 
142
    bannerSetScreenColor(win3, ColorRGB(255, 255, 255));
 
143
    bannerSetTextColor(win3, ColorRGB(0, 255, 0), ColorTransparent);
 
144
    bannerGoTo(win3, 5, 15);
 
145
    bannerSay(win3, '@ 5/15 @');
 
146
 
 
147
    "\nPress a key...\n";
 
148
    inputKey();
 
149
 
 
150
    bannerSetScreenColor(win3, ColorMaroon);
 
151
    bannerClear(win3);
 
152
    bannerGoTo(win3, 3, 20);
 
153
    bannerSay(win3, '% cleared - now at row 3, col 20');
 
154
 
 
155
    /* show the sizes of the banners */
 
156
    "\bRight banner: "; showBannerInfo(win);
 
157
    "\bBottom banner 1: "; showBannerInfo(win2);
 
158
    "\bBottom banner 2 (grid): "; showBannerInfo(win3);
 
159
 
 
160
    "\bPress another key...\n";
 
161
    inputKey();
 
162
 
 
163
    win3 = bannerCreate(win2, BannerFirst, nil, BannerTypeText,
 
164
                        BannerAlignLeft,
 
165
                        33, BannerSizePercent, BannerStyleBorder);
 
166
    bannerSay(win3, '<body bgcolor=#a000a0 text=black>This is a child
 
167
        banner on the left side of the second-to-bottom banner.  It
 
168
        should take up a third of the banner\'s width, on the left side.');
 
169
 
 
170
    "Another key please...\n";
 
171
    inputKey();
 
172
 
 
173
    win3 = bannerCreate(win2, BannerAfter, win3, BannerTypeText,
 
174
                        BannerAlignLeft,
 
175
                        50, BannerSizePercent, BannerStyleBorder);
 
176
    bannerSay(win3, '<body bgcolor=#505050 text=white>This is a second
 
177
        child banner.  It should appear in the middle of the second-to-bottom
 
178
        banner, and should take up half the remaining area (so, the bottom
 
179
        banner should now be split into thirds).');
 
180
 
 
181
    "\bPress another key to exit...\n";
 
182
    inputKey();
 
183
}
 
184
 
 
185
showBannerInfo(win)
 
186
{
 
187
    local info = bannerGetInfo(win);
 
188
 
 
189
    "align = <<info[1]>>, style = <<toString(info[2], 16)>>,
 
190
    rows = <<info[3]>>, columns = <<info[4]>>, pixel height = <<info[5]>>,
 
191
    pixel width = <<info[6]>>";
 
192
}