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

« back to all changes in this revision

Viewing changes to cli/cdkentry.c

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2007-06-06 03:54:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070606035431-ba4gdvw0h6ybffsu
Tags: 5.0.20060507-1
* New upstream release.
* Fixed header patching.  Patch from Robert Schiele.
  Closes: #402978, #416336.
* Update widget count in description.  Closes: #294709.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: cdkentry.c,v 1.8 2005/03/08 19:51:33 tom Exp $ */
 
1
/* $Id: cdkentry.c,v 1.10 2005/12/27 16:19:26 tom Exp $ */
2
2
 
3
 
#include <cdk.h>
 
3
#include <cdk_test.h>
4
4
 
5
5
#ifdef XCURSES
6
6
char *XCursesProgramName="cdkentry";
81
81
   if (fieldWidth <= 0)
82
82
   {
83
83
      fprintf (stderr, "Usage: %s %s\n", argv[0], FPUsage);
84
 
      exit (-1);
 
84
      ExitProgram (CLI_ERROR);
85
85
   }
86
86
 
87
87
   /* If the user asked for an output file, try to open it. */
90
90
      if ((fp = fopen (outputFile, "w")) == 0)
91
91
      {
92
92
         fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
93
 
         exit (-1);
 
93
         ExitProgram (CLI_ERROR);
94
94
      }
95
95
   }
96
96
 
140
140
      destroyCDKScreen (cdkScreen);
141
141
      endCDK();
142
142
 
143
 
      /* Spit out the message. */
144
143
      fprintf (stderr, "Error: Could not create the entry field. Is the window too small?\n");
145
144
 
146
 
      /* Exit with an error. */
147
 
      exit (-1);
 
145
      ExitProgram (CLI_ERROR);
148
146
   }
149
147
 
150
148
   /* Split the buttons if they supplied some. */
151
149
   if (buttons != 0)
152
150
   {
153
 
      /* Split the button list up. */
154
151
      buttonList = CDKsplitString (buttons, '\n');
155
152
      buttonCount = CDKcountStrings (buttonList);
156
153
 
157
 
      /* We need to create a buttonbox widget. */
158
154
      buttonWidget = newCDKButtonbox (cdkScreen,
159
155
                                        getbegx (widget->win),
160
156
                                        getbegy (widget->win) + widget->boxHeight - 1,
162
158
                                        0, 1, buttonCount,
163
159
                                        buttonList, buttonCount,
164
160
                                        A_REVERSE, boxWidget, FALSE);
 
161
      CDKfreeStrings (buttonList);
 
162
 
165
163
      setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
166
164
      setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
167
165
 
172
170
      setCDKEntryLLChar (widget, ACS_LTEE);
173
171
      setCDKEntryLRChar (widget, ACS_RTEE);
174
172
 
175
 
     /*
176
 
      * Bind the Tab key in the entry field to send a
177
 
      * Tab key to the button box widget.
178
 
      */
 
173
      /*
 
174
       * Bind the Tab key in the entry field to send a
 
175
       * Tab key to the button box widget.
 
176
       */
179
177
      bindCDKObject (vENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
180
178
      bindCDKObject (vENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
181
179
      bindCDKObject (vENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
187
185
      drawCDKButtonbox (buttonWidget, boxWidget);
188
186
   }
189
187
 
190
 
  /*
191
 
   * If the user asked for a shadow, we need to create one.
192
 
   * I do this instead of using the shadow parameter because
193
 
   * the button widget sin't part of the main widget and if
194
 
   * the user asks for both buttons and a shadow, we need to
195
 
   * create a shadow big enough for both widgets. We'll create
196
 
   * the shadow window using the widgets shadowWin element, so
197
 
   * screen refreshes will draw them as well.
198
 
   */
 
188
   /*
 
189
    * If the user asked for a shadow, we need to create one.  Do this instead
 
190
    * of using the shadow parameter because the button widget is not part of
 
191
    * the main widget and if the user asks for both buttons and a shadow, we
 
192
    * need to create a shadow big enough for both widgets.  Create the shadow
 
193
    * window using the widgets shadowWin element, so screen refreshes will draw
 
194
    * them as well.
 
195
    */
199
196
   if (shadowWidget == TRUE)
200
197
   {
201
198
      /* Determine the height of the shadow window. */
255
252
      fprintf (fp, "%s\n", answer);
256
253
      freeChar (answer);
257
254
   }
 
255
   fclose (fp);
258
256
 
259
257
   /* Exit with the button number picked. */
260
 
   exit (selection);
 
258
   ExitProgram (selection);
261
259
}
262
260
 
263
261
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)