/*
 * src/menus.h - menu management
 *
 * Copyright (C) 1999, 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 *
 * This 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, or (at your option)
 * any later version.
 * 
 * This software 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 package; see the file COPYING.  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__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#include <X11/Xlib.h>

#include <libsizzle/libsizzle.h>

/*
 * Definition for up to 5 mouse buttons and their corresponding
 * menus.
 */
#define BUTTON_1_MENU 0
#define BUTTON_2_MENU 1
#define BUTTON_3_MENU 2
#define BUTTON_4_MENU 3
#define BUTTON_5_MENU 4

/*
 * Some commands understood by the application launching menu.
 */
#define CMD_EXIT      1
#define CMD_RESTART   2
#define CMD_EXECUTE   3

/*
 * Entry of a menu item list.  The pointers data0 and data1 are
 * treated differently by the different kinds of menus.  For the
 * application launching menu, data0 is an integer which holds one of
 * the CMD_* values defined above, and data1 holds additional data,
 * for CMD_EXECUTE it holds a pointer to the command line to execute.
 *
 * For the window selection menu, data0 holds the window ID of the
 * window to be selected.
 *
 * For the working set selection menu, data0 holds the number of the
 * working set to switch to.
 */
#if 0
typedef struct menu_item * menu_item_t;
struct menu_item
{
  menu_item_t next;
  char * title;
  zzz_scm_t action;
};
#endif /* 0 */

/*
 * This structure is used to keep all state necessary to manage menus
 * in one place.
 */
typedef struct menu * menu_t;
struct menu
{
  Window window;
  int x;
  int y;
  int width;
  int height;
  char * title;
/*    menu_item_t menu_item_root; */
  zzz_scm_t menu_item_list;
  int menu_items;
  int menu_cleared;
  int last_highlight;
};

/*
 * MENUS holds state necessary to draw and handle the various
 * menus.
 */
extern struct menu menus[];
/*  extern Window menu_window[]; */

/*
 * Initialize the menu data structures.
 */
void init_menus (void);

/*
 * Create and map the window for menu number MENU_NUMBER.
 */
result_t create_menu_window (int menu_number);

/*
 * Unmap the menu window for menu number MENU_NUMBER and discard all
 * menu items for that menu.
 */
result_t destroy_menu_window (int menu_number);

/*
 * Draw menu number MENU_NUMBER, taking HIGHLIGHT as the index of the
 * menu item to be highlighted.  When HIGHLIGHT is -1, no item will be
 * highlighted.
 */
result_t menu_draw (int highlight, int menu_number);

/*
 * Change menu number MENU_NUMBER so that the highlighted menu item
 * matches the mouse motion reported in E.
 */
result_t menu_highlight (XMotionEvent * e, int menu_number);

/*
 * Select the highlighted menu item in menu number MENU_NUMBER and
 * perform the corresponding action. Do nothing, if no menu item is
 * currently highlighted.
 */
result_t menu_select (XButtonEvent * e, int menu_number);

#endif /* not __MENUS_H__ */




