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

« back to all changes in this revision

Viewing changes to cli/cdkmentry.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: cdkmentry.c,v 1.7 2005/03/08 19:52:08 tom Exp $ */
 
1
/* $Id: cdkmentry.c,v 1.9 2005/12/27 16:57:01 tom Exp $ */
2
2
 
3
 
#include <cdk.h>
 
3
#include <cdk_test.h>
4
4
 
5
5
#ifdef XCURSES
6
6
char *XCursesProgramName="cdkmentry";
81
81
   if ((fieldWidth <= 0) || (screenRows <= 0) || (virtualRows <= 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
 
139
139
      destroyCDKScreen (cdkScreen);
140
140
      endCDK();
141
141
 
142
 
      /* Spit out the message. */
143
142
      fprintf (stderr, "Error: Could not create the multiple line entry field. Is the window too small?\n");
144
143
 
145
 
      /* Exit with an error. */
146
 
      exit (-1);
 
144
      ExitProgram (CLI_ERROR);
147
145
   }
148
146
 
149
147
   /* Split the buttons if they supplied some. */
150
148
   if (buttons != 0)
151
149
   {
152
 
      /* Split the button list up. */
153
150
      buttonList = CDKsplitString (buttons, '\n');
154
151
      buttonCount = CDKcountStrings (buttonList);
155
152
 
161
158
                                        NULL, 1, buttonCount,
162
159
                                        buttonList, buttonCount,
163
160
                                        A_REVERSE, boxWidget, FALSE);
 
161
      CDKfreeStrings (buttonList);
 
162
 
164
163
      setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
165
164
      setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
166
165
 
167
 
     /*
168
 
      * We need to set the lower left and right
169
 
      * characters of the widget.
170
 
      */
 
166
      /*
 
167
       * We need to set the lower left and right
 
168
       * characters of the widget.
 
169
       */
171
170
      setCDKMentryLLChar (widget, ACS_LTEE);
172
171
      setCDKMentryLRChar (widget, ACS_RTEE);
173
172
 
174
 
     /*
175
 
      * Bind the Tab key in the widget to send a
176
 
      * Tab key to the button box widget.
177
 
      */
 
173
      /*
 
174
       * Bind the Tab key in the widget to send a
 
175
       * Tab key to the button box widget.
 
176
       */
178
177
      bindCDKObject (vMENTRY, widget, KEY_TAB, widgetCB, buttonWidget);
179
178
      bindCDKObject (vMENTRY, widget, CDK_NEXT, widgetCB, buttonWidget);
180
179
      bindCDKObject (vMENTRY, widget, CDK_PREV, widgetCB, buttonWidget);
186
185
      drawCDKButtonbox (buttonWidget, boxWidget);
187
186
   }
188
187
 
189
 
  /*
190
 
   * If the user asked for a shadow, we need to create one.
191
 
   * I do this instead of using the shadow parameter because
192
 
   * the button widget sin't part of the main widget and if
193
 
   * the user asks for both buttons and a shadow, we need to
194
 
   * create a shadow big enough for both widgets. We'll create
195
 
   * the shadow window using the widgets shadowWin element, so
196
 
   * screen refreshes will draw them as well.
197
 
   */
 
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
    */
198
196
   if (shadowWidget == TRUE)
199
197
   {
200
198
      /* Determine the height of the shadow window. */
213
211
      {
214
212
         widget->shadow = TRUE;
215
213
 
216
 
        /*
217
 
         * We force the widget and buttonWidget to be drawn so the
218
 
         * buttonbox widget will be drawn when the widget is activated.
219
 
         * Otherwise the shadow window will draw over the button widget.
220
 
         */
 
214
         /*
 
215
          * We force the widget and buttonWidget to be drawn so the
 
216
          * buttonbox widget will be drawn when the widget is activated.
 
217
          * Otherwise the shadow window will draw over the button widget.
 
218
          */
221
219
         drawCDKMentry (widget, ObjOf(widget)->box);
222
220
         eraseCDKButtonbox (buttonWidget);
223
221
         drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
254
252
      fprintf (fp, "%s\n", answer);
255
253
      freeChar (answer);
256
254
   }
 
255
   fclose (fp);
257
256
 
258
257
   /* Exit with the button number picked. */
259
 
   exit (selection);
 
258
   ExitProgram (selection);
260
259
}
261
260
 
262
261
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)