File: wl_menu.c

package info (click to toggle)
gwm 1.8d-2
  • links: PTS
  • area: main
  • in suites: potato, woody
  • size: 5,120 kB
  • ctags: 3,030
  • sloc: ansic: 19,617; makefile: 1,763; lisp: 437; sh: 321; ml: 21
file content (123 lines) | stat: -rw-r--r-- 2,804 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* Copyright 1989 GROUPE BULL -- See license conditions in file COPYRIGHT
 * Copyright 1989 Massachusetts Institute of Technology
 */
/*********************\
* 		      *
*  WOOL_OBJECT: Menu  *
*  BODY		      *
* 		      *
\*********************/

#include "EXTERN.h"
#include <stdio.h>
#include "wool.h"
#include "wl_atom.h"
#include "wl_number.h"
#include "wl_string.h"
#include "wl_list.h"
#include "gwm.h"
#include "wl_event.h"
#include "wl_fsm.h"
#include "wl_bar.h"
#include "INTERN.h"
#include "wl_menu.h"

extern Menu SetUpMenu();

/*
 * Constructor: wool_menu_make callable from wool
 * with direction, bars
 */

WOOL_Menu
wool_menu_make(argc, argv)
int		argc;
WOOL_Bar	argv[];
{
    int             i,j;
    WOOL_Menu       menu;

    menu = (WOOL_Menu) Malloc(sizeof(struct _WOOL_Menu) +
			    Max(0, argc - 1) * sizeof(WOOL_OBJECT));
    zrt_put(menu);
    menu -> type = WLMenu;
    menu -> direction = DefaultMenuDirection;
    menu -> borderwidth = DefaultBorderWidth;
    menu -> bar_separator = DefaultBarSeparator;
    menu -> borderpixel = Context -> pixel.Border;
    menu -> background = Context -> pixel.Back;
    get_val_from_context(menu -> menu, WA_menu);
    get_val_from_context(menu -> bordertile, WA_bordertile);
    get_val_from_context(menu -> fsm, WA_fsm);
    get_val_from_context(menu -> cursor, WA_cursor);
    get_val_from_context(menu -> property, WA_property);

    fix_fsm(&(menu -> fsm));
    menu -> bars_size = argc;
    for (i = 0, j = 0; i < argc; i++, j++) {
	increase_reference(menu -> bars[j] = argv[i]);
	if (NIL == (WOOL_OBJECT) menu -> bars [j]) 
	    j--, menu -> bars_size--;
    }
    menu -> wob_menu = SetUpMenu(menu);
    return menu;
}

/*
 * WLMenu_print:
 * MENU(text)
 */

WOOL_OBJECT
WLMenu_print(obj)
WOOL_Menu       obj;
{
    int i;

    wool_printf("{MENU 0x%x: ", obj);
    for (i = 0; i < obj -> bars_size; i++) {
	wool_print((obj -> bars)[i]);
	wool_puts(" ");
    }
    wool_puts("}");
    return (WOOL_OBJECT) obj;
}

/*
 * WLMenu_free:
 * recursivly free string and fsm
 */

WOOL_OBJECT
WLMenu_free(obj)
WOOL_Menu       obj;
{
    int i;

    decrease_reference(obj -> menu);
    decrease_reference(obj -> bordertile);
    decrease_reference(obj -> fsm);
    decrease_reference(obj -> cursor);
    decrease_reference(obj -> property);
    for (i = 0; i < obj -> bars_size; i++)
        decrease_reference(obj -> bars[i]);
    Free(obj);
    return NULL;
}

WOOL_OBJECT
WLMenu_get_dimensions(obj, box)
WOOL_Menu obj;
Box     box;                    /* RETURN the dimensions */
{
    return (WOOL_OBJECT) WOOL_send(WOOL_get_dimensions,
		     obj -> wob_menu, (obj -> wob_menu, box));
}

WOOL_OBJECT
WLMenu_wob(wl_menu)
WOOL_Menu wl_menu;
{
    must_be_menu(wl_menu, 0);
    return (WOOL_OBJECT) WLNumber_make(wl_menu -> wob_menu);
}