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

« back to all changes in this revision

Viewing changes to menu.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:
2
2
 
3
3
/*
4
4
 * $Author: tom $
5
 
 * $Date: 2004/08/30 00:26:17 $
6
 
 * $Revision: 1.93 $
 
5
 * $Date: 2006/05/05 00:27:44 $
 
6
 * $Revision: 1.98 $
7
7
 */
8
8
 
9
9
#define TITLELINES 1
13
13
 */
14
14
static void cleanUpMenu (CDKMENU *menu);
15
15
 
16
 
DeclareCDKObjects(MENU, Menu, setCdk, Int);
 
16
DeclareCDKObjects (MENU, Menu, setCdk, Int);
17
17
 
18
18
/*
19
19
 * This creates a new menu widget.
20
20
 */
21
 
CDKMENU *newCDKMenu (CDKSCREEN *cdkscreen, char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS], int menuItems, int *subsize, int *menuloc, int menuPos, chtype titleAttr, chtype subtitleAttr)
 
21
CDKMENU *newCDKMenu (CDKSCREEN *cdkscreen,
 
22
                     char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS],
 
23
                     int menuItems,
 
24
                     int *subsize,
 
25
                     int *menuLocation,
 
26
                     int menuPos,
 
27
                     chtype titleAttr,
 
28
                     chtype subtitleAttr)
22
29
{
23
30
   CDKMENU *menu        = 0;
24
31
   int rightcount       = menuItems - 1;
25
 
   int rightloc         = getmaxx(cdkscreen->window);
 
32
   int rightloc         = getmaxx (cdkscreen->window);
26
33
   int leftloc          = 0;
27
34
   int x, y, max, junk;
28
 
   int xpos             = getbegx(cdkscreen->window);
29
 
   int ypos             = getbegy(cdkscreen->window);
30
 
   int ymax             = getmaxy(cdkscreen->window);
 
35
   int xpos             = getbegx (cdkscreen->window);
 
36
   int ypos             = getbegy (cdkscreen->window);
 
37
   int ymax             = getmaxy (cdkscreen->window);
31
38
 
32
 
   if ((menu = newCDKObject(CDKMENU, &my_funcs)) == 0)
 
39
   if ((menu = newCDKObject (CDKMENU, &my_funcs)) == 0)
33
40
      return (0);
34
41
 
35
42
   /* Start making a copy of the information. */
36
 
   ScreenOf(menu)               = cdkscreen;
37
 
   ObjOf(menu)->box             = FALSE;
38
 
   ObjOf(menu)->acceptsFocus    = FALSE;
 
43
   ScreenOf (menu)              = cdkscreen;
 
44
   ObjOf (menu)->box            = FALSE;
 
45
   ObjOf (menu)->acceptsFocus    = FALSE;
39
46
   rightcount                   = menuItems-1;
40
47
   menu->parent                 = cdkscreen->window;
41
48
   menu->menuItems              = menuItems;
45
52
   menu->currentSubtitle        = 0;
46
53
   menu->lastSelection          = -1;
47
54
   menu->menuPos                = menuPos;
48
 
   initExitType(menu);
 
55
   initExitType (menu);
49
56
 
50
57
   /* Create the pull down menus. */
51
 
   for (x=0; x < menuItems; x++)
 
58
   for (x = 0; x < menuItems; x++)
52
59
   {
53
 
      int x1 = (menuloc[x] == LEFT) ? x : rightcount--;
 
60
      int x1 = (menuLocation[x] == LEFT) ? x : rightcount--;
54
61
      int x2;
55
62
      int y1 = (menuPos == BOTTOM) ? (ymax - 1) : 0;
56
63
      int y2 = (menuPos == BOTTOM) ? (ymax - subsize[x] - 2) : TITLELINES;
65
72
      }
66
73
 
67
74
      max = -1;
68
 
      for (y = TITLELINES; y < subsize[x] ; y++)
 
75
      for (y = TITLELINES; y < subsize[x]; y++)
69
76
      {
70
77
         int y0 = y - TITLELINES;
71
 
         menu->sublist[x1][y0] = char2Chtype (menulist[x][y], &menu->sublistLen[x1][y0], &junk);
 
78
 
 
79
         menu->sublist[x1][y0] = char2Chtype (menulist[x][y],
 
80
                                              &menu->sublistLen[x1][y0],
 
81
                                              &junk);
72
82
         max = MAXIMUM (max, menu->sublistLen[x1][y0]);
73
83
      }
74
84
 
75
 
      if (menuloc[x] == LEFT)
 
85
      if (menuLocation[x] == LEFT)
76
86
      {
77
87
         x2 = leftloc;
78
88
      }
86
96
      menu->pullWin[x1]  = subwin (cdkscreen->window, high, max+2, ypos + y2, xpos + x2);
87
97
      if (menu->titleWin[x1] == 0 || menu->pullWin[x1] == 0)
88
98
      {
89
 
         destroyCDKMenu(menu);
 
99
         destroyCDKMenu (menu);
90
100
         return (0);
91
101
      }
92
102
 
95
105
      keypad (menu->titleWin[x1], TRUE);
96
106
      keypad (menu->pullWin[x1], TRUE);
97
107
   }
98
 
   ObjOf(menu)->inputWindow = menu->titleWin[menu->currentTitle];
99
 
 
100
 
   /* Clean the key bindings. */
101
 
   cleanCDKObjectBindings (vMENU, menu);
 
108
   ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
102
109
 
103
110
   /* Register this baby. */
104
111
   registerCDKObject (cdkscreen, vMENU, menu);
113
120
int activateCDKMenu (CDKMENU *menu, chtype *actions)
114
121
{
115
122
   chtype input;
 
123
   boolean functionKey;
116
124
   int ret;
117
125
 
118
126
   /* Draw in the screen. */
119
 
   refreshCDKScreen (ScreenOf(menu));
 
127
   refreshCDKScreen (ScreenOf (menu));
120
128
 
121
129
   /* Display the menu titles. */
122
 
   drawCDKMenu(menu, ObjOf(menu)->box);
 
130
   drawCDKMenu (menu, ObjOf (menu)->box);
123
131
 
124
132
   /* Highlight the current title and window. */
125
133
   drawCDKMenuSubwin (menu);
127
135
   /* If the input string is null, this is an interactive activate. */
128
136
   if (actions == 0)
129
137
   {
130
 
      ObjOf(menu)->inputWindow = menu->titleWin[menu->currentTitle];
 
138
      ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
131
139
 
132
140
      /* Start taking input from the keyboard. */
133
141
      for (;;)
134
142
      {
135
 
         input = getcCDKObject (ObjOf(menu));
 
143
         input = getchCDKObject (ObjOf (menu), &functionKey);
136
144
 
137
145
         /* Inject the character into the widget. */
138
146
         ret = injectCDKMenu (menu, input);
147
155
      int count = chlen (actions);
148
156
      int x = 0;
149
157
 
150
 
      for (x=0; x < count; x++)
 
158
      for (x = 0; x < count; x++)
151
159
      {
152
160
         ret = injectCDKMenu (menu, actions[x]);
153
161
         if (menu->exitType != vEARLY_EXIT)
158
166
   }
159
167
 
160
168
   /* Set the exit type and return. */
161
 
   setExitType(menu, 0);
 
169
   setExitType (menu, 0);
162
170
   return -1;
163
171
}
164
172
 
185
193
static void drawItem (CDKMENU *menu, int item, int offset)
186
194
{
187
195
   writeChtype (menu->pullWin[menu->currentTitle],
188
 
               1, item + TITLELINES - offset,
189
 
               menu->sublist[menu->currentTitle][item],
190
 
               HORIZONTAL,
191
 
               0, menu->sublistLen[menu->currentTitle][item]);
 
196
                1, item + TITLELINES - offset,
 
197
                menu->sublist[menu->currentTitle][item],
 
198
                HORIZONTAL,
 
199
                0, menu->sublistLen[menu->currentTitle][item]);
192
200
}
193
201
 
194
202
/* Highlight the current sub-menu item. */
195
203
static void selectItem (CDKMENU *menu, int item, int offset)
196
204
{
197
205
   writeChtypeAttrib (menu->pullWin[menu->currentTitle],
198
 
               1, item + TITLELINES - offset,
199
 
               menu->sublist[menu->currentTitle][item],
200
 
               menu->subtitleAttr,
201
 
               HORIZONTAL,
202
 
               0, menu->sublistLen[menu->currentTitle][item]);
 
206
                      1, item + TITLELINES - offset,
 
207
                      menu->sublist[menu->currentTitle][item],
 
208
                      menu->subtitleAttr,
 
209
                      HORIZONTAL,
 
210
                      0, menu->sublistLen[menu->currentTitle][item]);
203
211
}
204
212
 
205
213
static void withinSubmenu (CDKMENU *menu, int step)
206
214
{
207
 
   int next = wrapped(menu->currentSubtitle + step, menu->subsize[menu->currentTitle]);
 
215
   int next = wrapped (menu->currentSubtitle + step, menu->subsize[menu->currentTitle]);
208
216
 
209
217
   if (next != menu->currentSubtitle)
210
218
   {
211
 
      CDKSCREEN *screen = ScreenOf(menu);
212
 
      int ymax = getmaxy(screen->window);
 
219
      CDKSCREEN *screen = ScreenOf (menu);
 
220
      int ymax = getmaxy (screen->window);
213
221
 
214
 
      if (1 +
215
 
         getbegy (menu->pullWin[menu->currentTitle]) +
216
 
         menu->subsize[menu->currentTitle] >= ymax)
 
222
      if ((1 +
 
223
           getbegy (menu->pullWin[menu->currentTitle]) +
 
224
           menu->subsize[menu->currentTitle]) >= ymax)
217
225
      {
218
226
         menu->currentSubtitle = next;
219
227
         drawCDKMenuSubwin (menu);
232
240
         wrefresh (menu->pullWin[menu->currentTitle]);
233
241
      }
234
242
 
235
 
      ObjOf(menu)->inputWindow = menu->titleWin[menu->currentTitle];
 
243
      ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
236
244
   }
237
245
}
238
246
 
239
247
static void acrossSubmenus (CDKMENU *menu, int step)
240
248
{
241
 
   int next = wrapped(menu->currentTitle + step, menu->menuItems);
 
249
   int next = wrapped (menu->currentTitle + step, menu->menuItems);
242
250
 
243
251
   if (next != menu->currentTitle)
244
252
   {
245
253
      /* Erase the menu sub-window. */
246
254
      eraseCDKMenuSubwin (menu);
247
 
      refreshCDKScreen (ScreenOf(menu));
 
255
      refreshCDKScreen (ScreenOf (menu));
248
256
 
249
257
      /* Set the values. */
250
258
      menu->currentTitle = next;
252
260
 
253
261
      /* Draw the new menu sub-window. */
254
262
      drawCDKMenuSubwin (menu);
255
 
      ObjOf(menu)->inputWindow = menu->titleWin[menu->currentTitle];
 
263
      ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
256
264
   }
257
265
}
258
266
 
259
267
/*
260
 
 * This injects a character into the menu widget.
 
268
 * Inject a character into the menu widget.
261
269
 */
262
270
static int _injectCDKMenu (CDKOBJS *object, chtype input)
263
271
{
267
275
   bool complete = FALSE;
268
276
 
269
277
   /* Set the exit type. */
270
 
   setExitType(menu, 0);
 
278
   setExitType (menu, 0);
271
279
 
272
280
   /* Check if there is a pre-process function to be called. */
273
 
   if (PreProcessFuncOf(menu) != 0)
 
281
   if (PreProcessFuncOf (menu) != 0)
274
282
   {
275
283
      /* Call the pre-process function. */
276
 
      ppReturn = PreProcessFuncOf(menu) (vMENU, menu, PreProcessDataOf(menu), input);
 
284
      ppReturn = PreProcessFuncOf (menu) (vMENU,
 
285
                                          menu,
 
286
                                          PreProcessDataOf (menu),
 
287
                                          input);
277
288
   }
278
289
 
279
290
   /* Should we continue? */
282
293
      /* Check for key bindings. */
283
294
      if (checkCDKObjectBind (vMENU, menu, input) != 0)
284
295
      {
285
 
         checkEarlyExit(menu);
 
296
         checkEarlyExit (menu);
286
297
         complete = TRUE;
287
298
      }
288
299
      else
289
300
      {
290
301
         switch (input)
291
302
         {
292
 
            case KEY_LEFT :
293
 
                 acrossSubmenus(menu, -1);
294
 
                 break;
295
 
 
296
 
            case KEY_RIGHT : case KEY_TAB :
297
 
                 acrossSubmenus(menu, 1);
298
 
                 break;
299
 
 
300
 
            case KEY_UP :
301
 
                 withinSubmenu (menu, -1);
302
 
                 break;
303
 
 
304
 
            case KEY_DOWN : case SPACE :
305
 
                 withinSubmenu (menu, 1);
306
 
                 break;
307
 
 
308
 
            case KEY_ENTER :
309
 
                 cleanUpMenu (menu);
310
 
                 setExitType(menu, input);
311
 
                 menu->lastSelection = ((menu->currentTitle * 100) + menu->currentSubtitle);
312
 
                 ret = menu->lastSelection;
313
 
                 complete = TRUE;
314
 
                 break;
315
 
 
316
 
            case KEY_ESC :
317
 
                 cleanUpMenu (menu);
318
 
                 setExitType(menu, input);
319
 
                 menu->lastSelection = -1;
320
 
                 ret = menu->lastSelection;
321
 
                 complete = TRUE;
322
 
                 break;
323
 
 
324
 
            case CDK_REFRESH :
325
 
                 eraseCDKScreen (ScreenOf(menu));
326
 
                 refreshCDKScreen (ScreenOf(menu));
327
 
                 break;
 
303
         case KEY_LEFT:
 
304
            acrossSubmenus (menu, -1);
 
305
            break;
 
306
 
 
307
         case KEY_RIGHT:
 
308
         case KEY_TAB:
 
309
            acrossSubmenus (menu, 1);
 
310
            break;
 
311
 
 
312
         case KEY_UP:
 
313
            withinSubmenu (menu, -1);
 
314
            break;
 
315
 
 
316
         case KEY_DOWN:
 
317
         case SPACE:
 
318
            withinSubmenu (menu, 1);
 
319
            break;
 
320
 
 
321
         case KEY_ENTER:
 
322
            cleanUpMenu (menu);
 
323
            setExitType (menu, input);
 
324
            menu->lastSelection = ((menu->currentTitle * 100) + menu->currentSubtitle);
 
325
            ret = menu->lastSelection;
 
326
            complete = TRUE;
 
327
            break;
 
328
 
 
329
         case KEY_ESC:
 
330
            cleanUpMenu (menu);
 
331
            setExitType (menu, input);
 
332
            menu->lastSelection = -1;
 
333
            ret = menu->lastSelection;
 
334
            complete = TRUE;
 
335
            break;
 
336
 
 
337
         case CDK_REFRESH:
 
338
            eraseCDKScreen (ScreenOf (menu));
 
339
            refreshCDKScreen (ScreenOf (menu));
 
340
            break;
328
341
         }
329
342
      }
330
343
 
331
344
      /* Should we call a post-process? */
332
 
      if (!complete && (PostProcessFuncOf(menu) != 0))
 
345
      if (!complete && (PostProcessFuncOf (menu) != 0))
333
346
      {
334
 
         PostProcessFuncOf(menu) (vMENU, menu, PostProcessDataOf(menu), input);
 
347
         PostProcessFuncOf (menu) (vMENU, menu, PostProcessDataOf (menu), input);
335
348
      }
336
349
   }
337
350
 
338
351
   if (!complete)
339
352
   {
340
 
      setExitType(menu, 0);
 
353
      setExitType (menu, 0);
341
354
   }
342
355
 
343
 
   ResultOf(menu).valueInt = ret;
 
356
   ResultOf (menu).valueInt = ret;
344
357
   return (ret != unknownInt);
345
358
}
346
359
 
347
360
/*
348
 
 * This draws a menu item subwindow.
 
361
 * Draw a menu item subwindow.
349
362
 */
350
363
void drawCDKMenuSubwin (CDKMENU *menu)
351
364
{
352
365
   int x;
353
 
   int high = getmaxy(menu->pullWin[menu->currentTitle]) - 2;
 
366
   int high = getmaxy (menu->pullWin[menu->currentTitle]) - 2;
354
367
   int x0 = 0;
355
368
   int x1 = menu->subsize[menu->currentTitle];
356
369
 
364
377
   }
365
378
 
366
379
   /* Box the window. */
367
 
   werase(menu->pullWin[menu->currentTitle]);
 
380
   werase (menu->pullWin[menu->currentTitle]);
368
381
   box (menu->pullWin[menu->currentTitle], ACS_VLINE, ACS_HLINE);
 
382
 
369
383
   if (menu->menuPos == BOTTOM)
370
384
   {
371
385
      mvwaddch (menu->pullWin[menu->currentTitle],
372
 
                menu->subsize[menu->currentTitle]+1, 0, ACS_LTEE);
 
386
                menu->subsize[menu->currentTitle] + 1, 0, ACS_LTEE);
373
387
   }
374
388
   else
375
389
   {
376
390
      mvwaddch (menu->pullWin[menu->currentTitle], 0, 0, ACS_LTEE);
377
391
   }
378
392
 
379
 
   /* Draw in the items. */
380
 
   for (x = x0; x < x1 ; x++)
 
393
   /* Draw the items. */
 
394
   for (x = x0; x < x1; x++)
381
395
   {
382
396
      drawItem (menu, x, x0);
383
397
   }
384
398
 
385
399
   selectItem (menu, menu->currentSubtitle, x0);
386
 
   refreshCDKWindow (menu->pullWin[menu->currentTitle]);
 
400
   wrefresh (menu->pullWin[menu->currentTitle]);
387
401
 
388
402
   /* Highlight the title. */
389
403
   writeChtypeAttrib (menu->titleWin[menu->currentTitle],
390
 
                        0, 0, menu->title[menu->currentTitle],
391
 
                        menu->titleAttr, HORIZONTAL, 0,
392
 
                        menu->titleLen[menu->currentTitle]);
393
 
   refreshCDKWindow (menu->titleWin[menu->currentTitle]);
 
404
                      0, 0, menu->title[menu->currentTitle],
 
405
                      menu->titleAttr, HORIZONTAL, 0,
 
406
                      menu->titleLen[menu->currentTitle]);
 
407
   wrefresh (menu->titleWin[menu->currentTitle]);
394
408
}
395
409
 
396
410
/*
397
 
 * This erases a menu item subwindow.
 
411
 * Erase a menu item subwindow.
398
412
 */
399
413
void eraseCDKMenuSubwin (CDKMENU *menu)
400
414
{
402
416
 
403
417
   /* Redraw the sub-menu title. */
404
418
   drawTitle (menu, menu->currentTitle);
405
 
   refreshCDKWindow (menu->titleWin[menu->currentTitle]);
 
419
   wrefresh (menu->titleWin[menu->currentTitle]);
406
420
}
407
421
 
408
422
/*
409
 
 * This function draws the menu.
 
423
 * Draw the menu.
410
424
 */
411
425
static void _drawCDKMenu (CDKOBJS *object, boolean Box GCC_UNUSED)
412
426
{
414
428
   int x;
415
429
 
416
430
   /* Draw in the menu titles. */
417
 
   for (x=0; x < menu->menuItems; x++)
 
431
   for (x = 0; x < menu->menuItems; x++)
418
432
   {
419
433
      drawTitle (menu, x);
420
 
      refreshCDKWindow (menu->titleWin[x]);
 
434
      wrefresh (menu->titleWin[x]);
421
435
   }
422
436
}
423
437
 
424
438
/*
425
 
 * This moves the menu to the given location.
 
439
 * Move the menu to the given location.
426
440
 */
427
 
static void _moveCDKMenu (CDKOBJS *object, int xplace, int yplace, boolean relative, boolean refresh_flag)
 
441
static void _moveCDKMenu (CDKOBJS *object,
 
442
                          int xplace,
 
443
                          int yplace,
 
444
                          boolean relative,
 
445
                          boolean refresh_flag)
428
446
{
429
447
   CDKMENU *menu = (CDKMENU *)object;
430
 
   int currentX = getbegx(WindowOf(menu));
431
 
   int currentY = getbegy(WindowOf(menu));
 
448
   int currentX = getbegx (WindowOf (menu));
 
449
   int currentY = getbegy (WindowOf (menu));
432
450
   int xpos     = xplace;
433
451
   int ypos     = yplace;
434
452
   int xdiff    = 0;
441
459
    */
442
460
   if (relative)
443
461
   {
444
 
      xpos = getbegx(WindowOf(menu)) + xplace;
445
 
      ypos = getbegy(WindowOf(menu)) + yplace;
 
462
      xpos = getbegx (WindowOf (menu)) + xplace;
 
463
      ypos = getbegy (WindowOf (menu)) + yplace;
446
464
   }
447
465
 
448
466
   /* Adjust the window if we need to. */
449
 
   alignxy (WindowOf(menu), &xpos, &ypos, getmaxx(WindowOf(menu)), getmaxy(WindowOf(menu)));
 
467
   alignxy (WindowOf (menu),
 
468
            &xpos,
 
469
            &ypos,
 
470
            getmaxx (WindowOf (menu)),
 
471
            getmaxy (WindowOf (menu)));
450
472
 
451
473
   /* Get the difference. */
452
474
   xdiff = currentX - xpos;
453
475
   ydiff = currentY - ypos;
454
476
 
455
477
   /* Move the windows to the new location. */
456
 
   moveCursesWindow(WindowOf(menu), -xdiff, -ydiff);
457
 
   for (x=0; x < menu->menuItems; x++)
 
478
   moveCursesWindow (WindowOf (menu), -xdiff, -ydiff);
 
479
   for (x = 0; x < menu->menuItems; x++)
458
480
   {
459
 
      moveCursesWindow(menu->titleWin[x], -xdiff, -ydiff);
 
481
      moveCursesWindow (menu->titleWin[x], -xdiff, -ydiff);
460
482
   }
461
483
 
462
484
   /* Touch the windows so they 'move'. */
463
 
   refreshCDKWindow (WindowOf(menu));
 
485
   refreshCDKWindow (WindowOf (menu));
464
486
 
465
487
   /* Redraw the window, if they asked for it. */
466
488
   if (refresh_flag)
467
489
   {
468
 
      drawCDKMenu (menu, ObjOf(menu)->box);
 
490
      drawCDKMenu (menu, ObjOf (menu)->box);
469
491
   }
470
492
}
471
493
 
472
494
/*
473
 
 * This sets the background attribute of the widget.
 
495
 * Set the background attribute of the widget.
474
496
 */
475
497
static void _setBKattrMenu (CDKOBJS *object, chtype attrib)
476
498
{
479
501
      CDKMENU *widget = (CDKMENU *)object;
480
502
      int x;
481
503
 
482
 
      for (x=0; x < widget->menuItems; x++)
 
504
      for (x = 0; x < widget->menuItems; x++)
483
505
      {
484
506
         wbkgd (widget->titleWin[x], attrib);
485
507
         wbkgd (widget->pullWin[x], attrib);
488
510
}
489
511
 
490
512
/*
491
 
 * This function destroys a menu widget.
 
513
 * Destroy a menu widget.
492
514
 */
493
515
static void _destroyCDKMenu (CDKOBJS *object)
494
516
{
498
520
      int x, y;
499
521
 
500
522
      /* Clean up both the winodws and the char pointers. */
501
 
      for (x=0; x < menu->menuItems; x++)
 
523
      for (x = 0; x < menu->menuItems; x++)
502
524
      {
503
525
         /* Clean the windows. */
504
526
         deleteCursesWindow (menu->titleWin[x]);
506
528
 
507
529
         /* Delete the character pointers. */
508
530
         freeChtype (menu->title[x]);
509
 
         for (y=0; y < menu->subsize[x] ; y++)
 
531
         for (y = 0; y < menu->subsize[x]; y++)
510
532
         {
511
533
            freeChtype (menu->sublist[x][y]);
512
534
         }
513
535
      }
514
536
 
 
537
      /* Clean the key bindings. */
 
538
      cleanCDKObjectBindings (vMENU, menu);
 
539
 
515
540
      /* Unregister this object. */
516
541
      unregisterCDKObject (vMENU, menu);
517
542
   }
518
543
}
519
544
 
520
545
/*
521
 
 * This function erases the menu widget from the screen.
 
546
 * Erase the menu widget from the screen.
522
547
 */
523
548
static void _eraseCDKMenu (CDKOBJS *object)
524
549
{
527
552
      CDKMENU *menu = (CDKMENU *)object;
528
553
      int x = 0;
529
554
 
530
 
      /* Erase the menu items. */
531
 
      for (x=0 ; x < menu->menuItems; x++)
 
555
      for (x = 0; x < menu->menuItems; x++)
532
556
      {
533
557
         werase (menu->titleWin[x]);
534
558
         wrefresh (menu->titleWin[x]);
539
563
}
540
564
 
541
565
/*
542
 
 * This sets multiple features of the menu.
 
566
 * Set multiple features of the menu.
543
567
 */
544
 
void setCDKMenu (CDKMENU *menu, int menuItem, int subMenuItem, chtype titleHighlight, chtype subTitleHighlight)
 
568
void setCDKMenu (CDKMENU *menu,
 
569
                 int menuItem,
 
570
                 int subMenuItem,
 
571
                 chtype titleHighlight,
 
572
                 chtype subTitleHighlight)
545
573
{
546
574
   setCDKMenuCurrentItem (menu, menuItem, subMenuItem);
547
575
   setCDKMenuTitleHighlight (menu, titleHighlight);
549
577
}
550
578
 
551
579
/*
552
 
 * This sets the current menu item to highlight.
 
580
 * Set the current menu item to highlight.
553
581
 */
554
582
void setCDKMenuCurrentItem (CDKMENU *menu, int menuitem, int submenuitem)
555
583
{
556
 
   menu->currentTitle    = wrapped(menuitem,    menu->menuItems);
557
 
   menu->currentSubtitle = wrapped(submenuitem, menu->subsize[menu->currentTitle]);
 
584
   menu->currentTitle    = wrapped (menuitem,    menu->menuItems);
 
585
   menu->currentSubtitle = wrapped (submenuitem, menu->subsize[menu->currentTitle]);
558
586
}
559
587
void getCDKMenuCurrentItem (CDKMENU *menu, int *menuItem, int *subMenuItem)
560
588
{
563
591
}
564
592
 
565
593
/*
566
 
 * This sets the attribute of the menu titles.
 
594
 * Set the attribute of the menu titles.
567
595
 */
568
596
void setCDKMenuTitleHighlight (CDKMENU *menu, chtype highlight)
569
597
{
575
603
}
576
604
 
577
605
/*
578
 
 * This sets the attribute of the sub-title.
 
606
 * Set the attribute of the sub-title.
579
607
 */
580
608
void setCDKMenuSubTitleHighlight (CDKMENU *menu, chtype highlight)
581
609
{
587
615
}
588
616
 
589
617
/*
590
 
 * This exits the menu.
 
618
 * Exit the menu.
591
619
 */
592
620
static void cleanUpMenu (CDKMENU *menu)
593
621
{
596
624
   wrefresh (menu->pullWin[menu->currentTitle]);
597
625
 
598
626
   /* Refresh the screen. */
599
 
   refreshCDKScreen (ScreenOf(menu));
 
627
   refreshCDKScreen (ScreenOf (menu));
600
628
}
601
629
 
602
 
static void _focusCDKMenu(CDKOBJS *object)
 
630
static void _focusCDKMenu (CDKOBJS *object)
603
631
{
604
632
   CDKMENU *menu = (CDKMENU *)object;
605
633
 
606
 
   drawCDKMenuSubwin(menu);
607
 
   ObjOf(menu)->inputWindow = menu->titleWin[menu->currentTitle];
 
634
   drawCDKMenuSubwin (menu);
 
635
   ObjOf (menu)->inputWindow = menu->titleWin[menu->currentTitle];
608
636
}
609
637
 
610
 
dummyUnfocus(Menu)
611
 
 
612
 
dummyRefreshData(Menu)
613
 
 
614
 
dummySaveData(Menu)
 
638
dummyUnfocus (Menu)
 
639
 
 
640
dummyRefreshData (Menu)
 
641
 
 
642
dummySaveData (Menu)