~ubuntu-branches/ubuntu/trusty/libcdk5/trusty

« back to all changes in this revision

Viewing changes to cli/cdkscroll.c

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2007-06-06 03:54:31 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20070606035431-1ac5o7r653u6qk8e
Tags: upstream-5.0.20060507
ImportĀ upstreamĀ versionĀ 5.0.20060507

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: cdkscroll.c,v 1.7 2005/03/08 19:52:29 tom Exp $ */
 
1
/* $Id: cdkscroll.c,v 1.9 2005/12/27 17:29:58 tom Exp $ */
2
2
 
3
 
#include <cdk.h>
 
3
#include <cdk_test.h>
4
4
 
5
5
#ifdef XCURSES
6
6
char *XCursesProgramName="cdkscroll";
38
38
   FILE *fp                     = stderr;
39
39
   char **scrollList            = 0;
40
40
   char **buttonList            = 0;
41
 
   int x, j1, j2;
 
41
   int j1, j2;
42
42
 
43
43
   CDK_PARAMS params;
44
44
   boolean boxWidget;
80
80
      if ((fp = fopen (outputFile, "w")) == 0)
81
81
      {
82
82
         fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
83
 
         exit (-1);
 
83
         ExitProgram (CLI_ERROR);
84
84
      }
85
85
   }
86
86
 
97
97
         if (scrollLines == -1)
98
98
         {
99
99
            fprintf (stderr, "Error: Could not open the file '%s'.\n", filename);
100
 
            exit (-1);
 
100
            ExitProgram (CLI_ERROR);
101
101
         }
102
102
      }
103
103
      else
104
104
      {
105
105
         /* They didn't provide anything. */
106
106
         fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
107
 
         exit (-1);
 
107
         ExitProgram (CLI_ERROR);
108
108
      }
109
109
   }
110
110
   else
148
148
   /* Make sure we could create the widget. */
149
149
   if (widget == 0)
150
150
   {
151
 
      /* Clean up some memory. */
152
 
      for (x=0; x < scrollLines; x++)
153
 
      {
154
 
         freeChar (scrollList[x]);
155
 
      }
 
151
      CDKfreeStrings (scrollList);
156
152
 
157
 
      /* Shut down curses and CDK. */
158
153
      destroyCDKScreen (cdkScreen);
159
154
      endCDK();
160
155
 
161
 
      /* Spit out the message. */
162
156
      fprintf (stderr, "Error: Could not create the scrolling list. Is the window too small?\n");
163
157
 
164
 
      /* Exit with an error. */
165
 
      exit (-1);
 
158
      ExitProgram (CLI_ERROR);
166
159
   }
167
160
 
168
161
   /* Split the buttons if they supplied some. */
180
173
                                        0, 1, buttonCount,
181
174
                                        buttonList, buttonCount,
182
175
                                        A_REVERSE, boxWidget, FALSE);
 
176
      CDKfreeStrings (buttonList);
 
177
 
183
178
      setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
184
179
      setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
185
180
 
186
 
     /*
187
 
      * We need to set the lower left and right
188
 
      * characters of the widget.
189
 
      */
 
181
      /*
 
182
       * We need to set the lower left and right
 
183
       * characters of the widget.
 
184
       */
190
185
      setCDKScrollLLChar (widget, ACS_LTEE);
191
186
      setCDKScrollLRChar (widget, ACS_RTEE);
192
187
 
193
 
     /*
194
 
      * Bind the Tab key in the widget to send a
195
 
      * Tab key to the button box widget.
196
 
      */
 
188
      /*
 
189
       * Bind the Tab key in the widget to send a
 
190
       * Tab key to the button box widget.
 
191
       */
197
192
      bindCDKObject (vSCROLL, widget, KEY_TAB, widgetCB, buttonWidget);
198
193
      bindCDKObject (vSCROLL, widget, CDK_NEXT, widgetCB, buttonWidget);
199
194
      bindCDKObject (vSCROLL, widget, CDK_PREV, widgetCB, buttonWidget);
205
200
      drawCDKButtonbox (buttonWidget, boxWidget);
206
201
   }
207
202
 
208
 
  /*
209
 
   * If the user asked for a shadow, we need to create one.
210
 
   * I do this instead of using the shadow parameter because
211
 
   * the button widget sin't part of the main widget and if
212
 
   * the user asks for both buttons and a shadow, we need to
213
 
   * create a shadow big enough for both widgets. We'll create
214
 
   * the shadow window using the widgets shadowWin element, so
215
 
   * screen refreshes will draw them as well.
216
 
   */
 
203
   /*
 
204
    * If the user asked for a shadow, we need to create one.  Do this instead
 
205
    * of using the shadow parameter because the button widget is not part of
 
206
    * the main widget and if the user asks for both buttons and a shadow, we
 
207
    * need to create a shadow big enough for both widgets.  Create the shadow
 
208
    * window using the widgets shadowWin element, so screen refreshes will draw
 
209
    * them as well.
 
210
    */
217
211
   if (shadowWidget == TRUE)
218
212
   {
219
213
      /* Determine the height of the shadow window. */
232
226
      {
233
227
         widget->shadow = TRUE;
234
228
 
235
 
        /*
236
 
         * We force the widget and buttonWidget to be drawn so the
237
 
         * buttonbox widget will be drawn when the widget is activated.
238
 
         * Otherwise the shadow window will draw over the button widget.
239
 
         */
 
229
         /*
 
230
          * We force the widget and buttonWidget to be drawn so the
 
231
          * buttonbox widget will be drawn when the widget is activated.
 
232
          * Otherwise the shadow window will draw over the button widget.
 
233
          */
240
234
         drawCDKScroll (widget, ObjOf(widget)->box);
241
235
         eraseCDKButtonbox (buttonWidget);
242
236
         drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
273
267
         fprintf (fp, "%s\n", scrollList[answer]);
274
268
      }
275
269
   }
 
270
   fclose (fp);
 
271
 
 
272
   CDKfreeStrings (scrollList);
276
273
 
277
274
   /* Exit with the answer. */
278
 
   exit (selection);
 
275
   ExitProgram (selection);
279
276
}
280
277
 
281
278
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)