1999-08-17 18:12:47 -07:00
|
|
|
/* menus.h -- Eterm popup menu module header file
|
|
|
|
*
|
|
|
|
* This file is original work by Michael Jennings <mej@eterm.org> and
|
|
|
|
* Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file
|
|
|
|
* bearing this same message or a similar one, is distributed under
|
|
|
|
* the GNU Public License (GPL) as outlined in the COPYING file.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _MENUS_H
|
|
|
|
# define _MENUS_H
|
|
|
|
|
|
|
|
# include <X11/Xfuncproto.h>
|
|
|
|
# include <Imlib.h>
|
|
|
|
# include "events.h"
|
|
|
|
# include "pixmap.h"
|
|
|
|
|
|
|
|
/************ Macros and Definitions ************/
|
|
|
|
#define MENUITEM_SEP (1UL << 0)
|
|
|
|
#define MENUITEM_SUBMENU (1UL << 1)
|
|
|
|
#define MENUITEM_STRING (1UL << 2)
|
|
|
|
#define MENUITEM_ECHO (1UL << 3)
|
|
|
|
|
|
|
|
#define MENU_STATE_IS_MAPPED (1UL << 0)
|
|
|
|
#define MENU_STATE_IS_CURRENT (1UL << 1)
|
|
|
|
#define MENU_STATE_IS_DRAGGING (1UL << 2)
|
|
|
|
#define MENU_STATE_IS_SUBMENU (1UL << 3)
|
|
|
|
#define MENU_STATE_IS_FOCUSED (1UL << 4)
|
|
|
|
|
|
|
|
/* Constants */
|
|
|
|
#define MENU_HGAP 4
|
|
|
|
#define MENU_VGAP 4
|
|
|
|
#define MENU_CLICK_TIME 20
|
|
|
|
|
Mon Sep 20 18:32:01 PDT 1999 Michael Jennings <mej@eterm.org>
Lots of changes here. First off, this should fix the background draw
bug with transparency that several people pointed out. While I was
at it, I also cleaned up a lot of other related stuff. Three-state
images should be a lot more robust now.
Then again, some stuff may be broken entirely from this, so let me
know. :-)
For one thing, the various image modes should work as expected now.
You can allow and disallow modes for the various widgets. The
fallback mode is "solid" now, rather than "image," so you can cause
a certain widget to refuse to use an image if you want to. If you
specify an image without specifying a "mode" line that allows the
"image" mode, your image will not appear. <-- READ THIS TWICE! I
had to go back and fix all the theme files because of this, so you
will need to remove your current theme directory and allow Eterm's
"make install" to put the new ones in place; otherwise, everything
will go back to being solid colors. =]
Anytime something changes this drastically, there are bound to be
problems. Let me know if you find any of them. :)
SVN revision: 348
1999-09-20 18:16:46 -07:00
|
|
|
#define menu_is_pixmapped() ((images[image_menu].current->iml->im) && (images[image_menu].mode & MODE_MASK))
|
|
|
|
#define menu_submenu_is_pixmapped() ((images[image_submenu].current->iml->im) && (images[image_submenu].mode & MODE_MASK))
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/************ Structures ************/
|
|
|
|
typedef struct menu_t_struct menu_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
image_t *icon;
|
|
|
|
unsigned char type, state;
|
|
|
|
union {
|
|
|
|
menu_t *submenu;
|
|
|
|
char *string;
|
|
|
|
} action;
|
|
|
|
char *text, *rtext;
|
|
|
|
unsigned short len, rlen;
|
|
|
|
unsigned short x, y, w, h;
|
|
|
|
} menuitem_t;
|
|
|
|
|
|
|
|
struct menu_t_struct {
|
|
|
|
char *title;
|
|
|
|
Window win, swin;
|
|
|
|
unsigned short x, y, w, h;
|
|
|
|
GC gc;
|
|
|
|
unsigned char state;
|
|
|
|
XFontStruct *font;
|
|
|
|
#ifdef MULTI_CHARSET
|
|
|
|
XFontSet fontset;
|
|
|
|
#endif
|
|
|
|
unsigned short fwidth, fheight;
|
|
|
|
unsigned short numitems, curitem;
|
|
|
|
menuitem_t **items;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char nummenus;
|
|
|
|
menu_t **menus;
|
|
|
|
} menulist_t;
|
|
|
|
|
|
|
|
/************ Variables ************/
|
|
|
|
extern menulist_t *menu_list;
|
|
|
|
|
|
|
|
/************ Function Prototypes ************/
|
|
|
|
_XFUNCPROTOBEGIN
|
|
|
|
|
|
|
|
extern void menu_init(void);
|
|
|
|
extern void menu_event_init_dispatcher(void);
|
|
|
|
extern unsigned char menu_handle_enter_notify(event_t *);
|
|
|
|
extern unsigned char menu_handle_leave_notify(event_t *);
|
|
|
|
extern unsigned char menu_handle_focus_in(event_t *);
|
|
|
|
extern unsigned char menu_handle_focus_out(event_t *);
|
|
|
|
extern unsigned char menu_handle_expose(event_t *);
|
|
|
|
extern unsigned char menu_handle_button_press(event_t *);
|
|
|
|
extern unsigned char menu_handle_button_release(event_t *);
|
|
|
|
extern unsigned char menu_handle_motion_notify(event_t *);
|
|
|
|
extern unsigned char menu_dispatch_event(event_t *);
|
|
|
|
extern menulist_t *menulist_add_menu(menulist_t *, menu_t *);
|
|
|
|
extern menu_t *menu_create(char *);
|
|
|
|
extern unsigned char menu_set_font(menu_t *, const char *);
|
|
|
|
extern unsigned char menu_add_item(menu_t *, menuitem_t *);
|
|
|
|
extern unsigned char menu_is_child(menu_t *, menu_t *);
|
|
|
|
extern menu_t *find_menu_by_title(menulist_t *, char *);
|
|
|
|
extern menu_t *find_menu_by_window(menulist_t *, Window);
|
|
|
|
extern menuitem_t *find_item_by_coords(menu_t *, int, int);
|
|
|
|
extern unsigned short find_item_in_menu(menu_t *, menuitem_t *);
|
|
|
|
extern void menuitem_change_current(menuitem_t *);
|
|
|
|
extern menuitem_t *menuitem_create(char *);
|
|
|
|
extern unsigned char menuitem_set_icon(menuitem_t *, image_t *);
|
|
|
|
extern unsigned char menuitem_set_action(menuitem_t *, unsigned char, char *);
|
|
|
|
extern unsigned char menuitem_set_rtext(menuitem_t *, char *);
|
|
|
|
|
|
|
|
extern void menu_reset(menu_t *);
|
|
|
|
extern void menu_reset_all(menulist_t *);
|
|
|
|
extern void menu_reset_tree(menu_t *);
|
|
|
|
extern void menu_reset_submenus(menu_t *);
|
|
|
|
extern void menuitem_select(menu_t *, menuitem_t *);
|
|
|
|
extern void menuitem_deselect(menu_t *, menuitem_t *);
|
|
|
|
extern void menu_display_submenu(menu_t *, menuitem_t *);
|
|
|
|
extern void menu_draw(menu_t *);
|
|
|
|
extern void menu_display(int, int, menu_t *);
|
|
|
|
extern void menu_action(menuitem_t *);
|
|
|
|
extern void menu_invoke(int, int, Window, menu_t *, Time);
|
|
|
|
extern void menu_invoke_by_title(int, int, Window, char *, Time);
|
|
|
|
|
|
|
|
_XFUNCPROTOEND
|
|
|
|
|
|
|
|
#endif /* _MENUS_H */
|