00001 #ifndef _MBMENU_H_
00002 #define _MBMENU_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "libmb/mbconfig.h"
00024
00025 #include <stdio.h>
00026 #include <unistd.h>
00027 #include <stdlib.h>
00028 #include <string.h>
00029 #include <sys/types.h>
00030 #include <sys/stat.h>
00031 #include <dirent.h>
00032 #include <signal.h>
00033 #include <sys/wait.h>
00034 #include <X11/Xlib.h>
00035 #include <X11/Xutil.h>
00036 #include <X11/Xatom.h>
00037
00038 #include <X11/Xresource.h>
00039 #include <X11/extensions/shape.h>
00040 #include <X11/Xatom.h>
00041 #include <X11/keysymdef.h>
00042 #include <X11/keysym.h>
00043 #include <X11/Xmd.h>
00044
00045 #ifdef USE_XSETTINGS
00046 #include <xsettings-client.h>
00047 #endif
00048
00049 #include "mbpixbuf.h"
00050 #include "mbexp.h"
00051
00061
00062
00063
00064
00065
00066
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070
00071
00077 typedef enum {
00078 MBMENU_SET_BG_COL,
00079 MBMENU_SET_FG_COL,
00080 MBMENU_SET_HL_COL,
00081 MBMENU_SET_BD_COL
00082 } MBMenuColorElement;
00083
00089 typedef enum {
00090 MBMENU_NO_SORT = (1<<1),
00091 MBMENU_PREPEND = (1<<2)
00092 } MBMenuItemAddFlags;
00093
00094 enum {
00095 MBMENU_ITEM_APP,
00096 MBMENU_ITEM_FOLDER,
00097 MBMENU_ITEM_SEPERATOR
00098 };
00099
00100
00101 #define MBMENU_FG_COL (1<<1)
00102 #define MBMENU_BG_COL (1<<2)
00103 #define MBMENU_HL_COL (1<<3)
00104 #define MBMENU_BD_COL (1<<4)
00105 #define MBMENU_FONT (1<<5)
00106 #define MBMENU_BD_SZ (1<<6)
00107 #define MBMENU_ICON_SZ (1<<7)
00108 #define MBMENU_ICON_FN (1<<8)
00109 #define MBMENU_ICON_FOLDER_FN (1<<9)
00110 #define MBMENU_TRANS (1<<10)
00111 #define MBMENU_BG_FN (1<<11)
00112 #define MBMENU_BEVEL (1<<12)
00113
00114 typedef struct _menu_options
00115 {
00116 char *fontname;
00117 char *foreground_col_spec;
00118 char *background_col_spec;
00119 char *highlight_col_spec;
00120 char *border_col_spec;
00121 int border_size;
00122 int icon_dimention;
00123 char *default_icon_filename;
00124 char *default_folder_icon_filename;
00125 char *bg_img_filename;
00126 int transparency_level;
00127 int bevel_size;
00128
00129 } MBMenuOptions;
00130
00136 typedef struct _menu
00137 {
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 char *title;
00149 struct _menuitem *items;
00150 struct _menuitem *active_item;
00151 struct _menuitem *too_big_start_item;
00152 struct _menuitem *too_big_end_item;
00153 struct _menuitem *parent_item;
00154
00155 int x;
00156 int y;
00157 int width;
00158 int height;
00159 int depth;
00160
00161 Window win;
00162
00163 GC mask_gc;
00164 Bool too_big;
00165
00166 MBDrawable *active_item_drw;
00167 MBDrawable *backing;
00168
00169
00170 } MBMenuMenu;
00171
00172
00178 typedef struct _menuitem
00179 {
00180 int type;
00181
00182 char *title;
00183 void (* cb)( struct _menuitem *item );
00184 void *cb_data;
00185 char *info;
00186 char *icon_fn;
00187
00188 MBPixbufImage *img;
00189
00190 MBMenuMenu *child;
00191 struct _menuitem *next_item;
00192
00193 int y;
00194 int h;
00195
00196
00197 } MBMenuItem;
00198
00204 typedef struct _mbmemu
00205 {
00206 Display *dpy;
00207 Window root;
00208 int screen;
00209 MBFont *font;
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 MBColor *fg_col;
00229 MBColor *bg_col;
00230 MBColor *hl_col;
00231 MBColor *bd_col;
00232
00233
00234 GC gc;
00235
00236 Bool have_highlight_col;
00237
00238 int options;
00239
00240 int border_width;
00241 int inner_border_width;
00242 XColor border_cols[3];
00243 int trans;
00244
00245 int icon_dimention;
00246
00247 MBPixbuf *pb;
00248 MBPixbufImage *img_default_folder;
00249 MBPixbufImage *img_default_app;
00250 MBPixbufImage *img_bg;
00251
00252 Pixmap arrow_icon, arrow_mask;
00253 Pixmap bg_pixmap, bg_pixmap_mask;
00254
00255 struct _menu *rootmenu;
00256 Bool xmenu_is_active;
00257 struct _menu *active[10];
00258 int active_depth;
00259
00260 Atom atom_mbtheme;
00261
00262 struct _menu *keyboard_focus_menu;
00263
00264 #ifdef USE_XSETTINGS
00265 XSettingsClient *xsettings_client;
00266 #endif
00267
00268 } MBMenu;
00269
00275 typedef void (*MBMenuActivateCB)( MBMenuItem *item ) ;
00276
00284 MBMenu *
00285 mb_menu_new(Display *dpy, int screen);
00286
00294 Bool
00295 mb_menu_set_font (MBMenu *mbmenu,
00296 char *font_desc);
00297
00306 Bool
00307 mb_menu_set_default_icons(MBMenu *mbmenu, char *folder, char *app);
00308
00309
00317 void
00318 mb_menu_set_icon_size(MBMenu *mbmenu, int size);
00319
00327 void
00328 mb_menu_set_col(MBMenu *mbmenu,
00329 MBMenuColorElement element,
00330 char *col_spec);
00331
00339 void
00340 mb_menu_set_trans(MBMenu *mbmenu, int trans);
00341
00349 MBMenuMenu* mb_menu_get_root_menu(MBMenu *mbmenu);
00350
00351
00360 Bool
00361 mb_menu_get_root_menu_size(MBMenu *mbmenu, int *width, int *height);
00362
00363
00372 void
00373 mb_menu_add_seperator_to_menu(MBMenu *mbmenu,
00374 MBMenuMenu *menu,
00375 int flags);
00376
00387 MBMenuMenu
00388 *mb_menu_add_path(MBMenu *mbmenu,
00389 char *path,
00390 char *icon_path,
00391 int flags);
00392
00399 void mb_menu_remove_menu(MBMenu *mbmenu,
00400 MBMenuMenu *menu);
00401
00402
00408 void mb_menu_free(MBMenu *mbmenu);
00409
00416 Bool mb_menu_is_active(MBMenu *mbmenu);
00417
00426 void mb_menu_activate(MBMenu *mbmenu,
00427 int x,
00428 int y);
00429
00435 void mb_menu_deactivate(MBMenu *mbmenu);
00436
00437
00445 void mb_menu_handle_xevent(MBMenu *mbmenu, XEvent *xevent);
00446
00459 MBMenuItem *
00460 mb_menu_new_item (MBMenu *mbmenu,
00461 MBMenuMenu *menu,
00462 char *title,
00463 MBMenuActivateCB activate_callback ,
00464 void *user_data,
00465 MBMenuItemAddFlags flags
00466 );
00467
00468
00469 MBMenuItem *
00470 mb_menu_add_item_to_menu(MBMenu *mbmenu,
00471 MBMenuMenu *menu,
00472 char *title,
00473 char *icon,
00474 char *info,
00475 void (* cmd)( MBMenuItem *item ),
00476 void *cb_data,
00477 int flags);
00478
00486 void
00487 mb_menu_item_icon_set(MBMenu *mbmenu, MBMenuItem *item, MBPixbufImage *img);
00488
00495 void*
00496 mb_menu_item_get_user_data(MBMenuItem *item);
00497
00505 void mb_menu_item_remove(MBMenu *mbmenu, MBMenuMenu *menu, MBMenuItem *item);
00506
00514 void mb_menu_dump(MBMenu *mbmenu, MBMenuMenu *menu);
00515
00516 #ifdef __cplusplus
00517 }
00518 #endif
00519
00520
00521
00525 #endif