mbmenu.h
#ifndef _MBMENU_H_
#define _MBMENU_H_
/* libmb
* Copyright (C) 2002 Matthew Allum
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libmb/mbconfig.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <signal.h>
#include <sys/wait.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/extensions/shape.h>
#include <X11/Xatom.h>
#include <X11/keysymdef.h>
#include <X11/keysym.h>
#include <X11/Xmd.h>
#include <libmb/xsettings-client.h>
#include <libmb/mbpixbuf.h>
#include <libmb/mbexp.h>
/*
TODO?
- mb_menu menu calls to mb_menu_menu ?
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
MBMENU_SET_BG_COL,
MBMENU_SET_FG_COL,
MBMENU_SET_HL_COL,
MBMENU_SET_BD_COL
} MBMenuColorElement;
typedef enum {
MBMENU_NO_SORT = (1<<1),
MBMENU_PREPEND = (1<<2)
} MBMenuItemAddFlags;
enum {
MBMENU_ITEM_APP,
MBMENU_ITEM_FOLDER,
MBMENU_ITEM_SEPERATOR
};
/* for mb_menu_new */
#define MBMENU_FG_COL (1<<1)
#define MBMENU_BG_COL (1<<2)
#define MBMENU_HL_COL (1<<3)
#define MBMENU_BD_COL (1<<4)
#define MBMENU_FONT (1<<5)
#define MBMENU_BD_SZ (1<<6)
#define MBMENU_ICON_SZ (1<<7)
#define MBMENU_ICON_FN (1<<8)
#define MBMENU_ICON_FOLDER_FN (1<<9)
#define MBMENU_TRANS (1<<10)
#define MBMENU_BG_FN (1<<11)
#define MBMENU_BEVEL (1<<12)
typedef struct _menu_options
{
char *fontname;
char *foreground_col_spec;
char *background_col_spec;
char *highlight_col_spec;
char *border_col_spec;
int border_size;
int icon_dimention;
char *default_icon_filename;
char *default_folder_icon_filename;
char *bg_img_filename;
int transparency_level;
int bevel_size;
} MBMenuOptions;
typedef struct _menu
{
/*
#ifdef USE_XFT
XftDraw *xftdraw;
XftDraw *shadow_xftdraw;
XftDraw *active_xftdraw;
int expose_cnt;
#endif
*/
char *title;
struct _menuitem *items;
struct _menuitem *active_item;
struct _menuitem *too_big_start_item;
struct _menuitem *too_big_end_item;
struct _menuitem *parent_item;
int x;
int y;
int width;
int height;
int depth;
Window win;
GC mask_gc;
Bool too_big;
MBDrawable *active_item_drw;
MBDrawable *backing;
} MBMenuMenu;
typedef struct _menuitem
{
int type;
char *title;
void (* cb)( struct _menuitem *item );
void *cb_data;
char *info;
char *icon_fn;
MBPixbufImage *img;
MBMenuMenu *child;
struct _menuitem *next_item;
int y;
int h;
} MBMenuItem; /* XXX MBMenuItem */
typedef struct _mbmemu
{
Display *dpy;
Window root;
int screen;
MBFont *font;
/*
#ifdef USE_XFT
XftFont *xftfont;
XftColor fg_xftcol;
XftColor bg_xftcol;
XftColor hl_xftcol;
XftColor bd_xftcol;
XftColor shadow_xftcol;
#else
XFontStruct* font;
#endif
XColor fg_xcol;
XColor bg_xcol;
XColor hl_xcol;
XColor bd_xcol;
*/
MBColor *fg_col;
MBColor *bg_col;
MBColor *hl_col;
MBColor *bd_col;
GC gc;
Bool have_highlight_col;
int options;
int border_width; /* X window border */
int inner_border_width; /* Non X border */
XColor border_cols[3];
int trans;
int icon_dimention; /* 0 - no icons, else icon size after scale */
MBPixbuf *pb;
MBPixbufImage *img_default_folder;
MBPixbufImage *img_default_app;
MBPixbufImage *img_bg;
Pixmap arrow_icon, arrow_mask; /* XXX Togo */
Pixmap bg_pixmap, bg_pixmap_mask;
struct _menu *rootmenu;
Bool xmenu_is_active;
struct _menu *active[10];
int active_depth;
Atom atom_mbtheme;
struct _menu *keyboard_focus_menu;
XSettingsClient *xsettings_client;
} MBMenu;
typedef void (*MBMenuActivateCB)( MBMenuItem *item ) ;
MBMenu *
mb_menu_new(Display *dpy, int screen);
Bool
mb_menu_set_font (MBMenu *mbmenu,
char *font_desc);
Bool
mb_menu_set_default_icons(MBMenu *mbmenu, char *folder, char *app);
void
mb_menu_set_icon_size(MBMenu *mbmenu, int size);
void
mb_menu_set_col(MBMenu *mbmenu,
MBMenuColorElement element,
char *col_spec);
void
mb_menu_set_trans(MBMenu *mbmenu, int trans);
MBMenuMenu* mb_menu_get_root_menu(MBMenu *mbmenu);
Bool
mb_menu_get_root_menu_size(MBMenu *mbmenu, int *width, int *height);
void
mb_menu_add_seperator_to_menu(MBMenu *mbmenu,
MBMenuMenu *menu,
int flags);
MBMenuMenu
*mb_menu_add_path(MBMenu *mbmenu,
char *path,
char *icon_path,
int flags);
void mb_menu_remove_menu(MBMenu *mbmenu,
MBMenuMenu *menu);
void mb_menu_free(MBMenu *mbmenu);
Bool mb_menu_is_active(MBMenu *mbmenu);
void mb_menu_activate(MBMenu *mbmenu,
int x,
int y);
void mb_menu_deactivate(MBMenu *mbmenu);
void mb_menu_handle_xevent(MBMenu *mbmenu, XEvent *xevent);
MBMenuItem *
mb_menu_new_item (MBMenu *mbmenu,
MBMenuMenu *menu,
char *title,
MBMenuActivateCB activate_callback ,
void *user_data,
MBMenuItemAddFlags flags
);
MBMenuItem * /* XXX TOGO */
mb_menu_add_item_to_menu(MBMenu *mbmenu,
MBMenuMenu *menu,
char *title,
char *icon,
char *info,
void (* cmd)( MBMenuItem *item ),
void *cb_data,
int flags);
void
mb_menu_item_icon_set(MBMenu *mbmenu, MBMenuItem *item, MBPixbufImage *img);
void*
mb_menu_item_get_user_data(MBMenuItem *item);
void mb_menu_item_remove(MBMenu *mbmenu, MBMenuMenu *menu, MBMenuItem *item);
void mb_menu_dump(MBMenu *mbmenu, MBMenuMenu *menu);
#ifdef __cplusplus
}
#endif
#endif
MBPixbufImage
struct MBPixbufImage MBPixbufImage
MBColor
struct MBColor MBColor
MBPixbuf
struct MBPixbuf MBPixbuf
MBFont
struct MBFont MBFont
MBDrawable
struct MBDrawable MBDrawable