File: McMenu.h

package info (click to toggle)
mctools-lite 970129-16
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,680 kB
  • ctags: 1,659
  • sloc: ansic: 16,035; sh: 164; makefile: 69
file content (130 lines) | stat: -rw-r--r-- 3,919 bytes parent folder | download | duplicates (6)
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
124
125
126
127
128
129
130
/* Copyright (C) 1994 - 1996 
            Olav Woelfelschneider (wosch@rbg.informatik.th-darmstadt.de)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public License as
  published by the Free Software Foundation; either version 2 of the
  License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public
  License along with this library; see the file COPYING.LIB.  If
  not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  Cambridge, MA 02139, USA.
*/

#ifndef _McMenu_h_
#define _McMenu_h_

#include <X11/Xlib.h>
#include "McApp.h"

#define MENU_CENTER		   1
#define MENU_ISDRAWN		   2
#define MENU_HOTKEY		   4

#define ITEM_ENABLED		   1
#define ITEM_TOGGLE		   2  /* Toggle status on each selection */
#define ITEM_CHECKED		   4
#define ITEM_HIGH		   8
#define ITEM_HNONE		   0
#define ITEM_H3D		  16
#define ITEM_HBOX		  32
#define ITEM_LINE		  64
#define ITEM_DOUBLE_LINE	 128
#define ITEM_CENTER		 256
#define ITEM_CHECKIT		 512
#define ITEM_UPDATE		1024  /* Item needs to be redrawn */
#define ITEM_GRAY		2048  /* Item is drawn stippled gray */
#define ITEM_GREY		ITEM_GRAY /* Which is which? */

struct McMenuItem;
struct McMenuList;

typedef struct McMenu {
  int x,y;
  struct McMenuList *list;
  McWindow *mcw;
  McGadget *gadget;
  McGadget *starter;
  struct McMenu *child;
  struct McMenu *parent;
  struct McMenuItem *subMenuItem;
} McMenu;

typedef struct McMenuGadget {
  McSpecialInfo specialInfo;
  McMenu *menu;
} McMenuGadget;


typedef struct McMenuList {
  int flags;
  int w,h;
  McWindow *mcw;
  struct McMenuItem *first;
  void	(*callback)(int id, struct McMenuItem *item);
  McHotkeyHandler hotkeyHandler;
} McMenuList;

typedef struct McMenuItem {
  struct McMenuItem *next;
  struct McMenuItem *prev;
  int flags;
  int x,y,w,h;
  int id;
  unsigned long mutual_exclude;
  void *customData;
  struct McBitmap *normalBitmap;
  struct McBitmap *selectBitmap;
  struct McText *normalLabel;
  struct McText *selectLabel;
  struct McBitmap *checkMark;
  struct McMenuList *subMenu;
  void	(*callback)(int id, struct McMenuItem *);
  unsigned char hotkey;
} McMenuItem;

typedef struct McMenuInit {
  unsigned char *text;
  int flags;
  int id;
  void	(*callback)(int id, struct McMenuItem *);
  struct McMenuInit *sub;
  int nsub;
  unsigned char hotkey;
} McMenuInit;

#define MENUTITLE(text) { text, ITEM_CENTER, 0, NULL, NULL, 0 }
#define MENUITEM(text,hk,flags,id) { text, flags, id, NULL, NULL, 0, hk }
#define MENULINE { NULL, ITEM_LINE, 0, NULL, NULL, 0 }
#define MENUDOUBLELINE { NULL, ITEM_DOUBLE_LINE, 0, NULL, NULL, 0 }
#define SUBMENUITEM(text,flags,id,sm) \
				 { text, flags, id, NULL, sm,MENU_ITEMS(sm),0 }
#define MENUITEMCB(text,hk,flags,id,cb) { text, flags, id, cb, NULL, 0, hk }
#define SUBMENUITEMCB(text,flags,id,sm,cb) \
				 { text, flags, id, cb, sm, MENU_ITEMS(sm), 0 }
#define MENU_ITEMS(i) (sizeof(i)/sizeof(McMenuInit))

extern McMenuList *McCreateMenu(McWindow *mcw,
				void (*callback)(int, struct McMenuItem *),
				McMenuInit *items, int nitems, int flags);
extern McMenu *McShowMenu(McApp *, McGadget *starter, McMenuList *list,
			  int x, int y);
extern void McZapMenus(McMenu *first);
extern void McFreeMenu(McMenu *mnu);
extern void McFreeMenuList(McMenuList *mls);
extern void McFreeMenuItem(McMenuItem *item);

extern McMenuList *McFindMenuList(McMenuList *parent, int num);
extern McMenuItem *McFindMenuItem(McMenuList *parent, int num);

extern int _McHandleHotkeyInItems(McMenuList *menu, McMenuItem *item,
				  unsigned char key);

#endif /* _McMenu_h_ */