"Fossies" - the Fresh Open Source Software Archive

Member "feh-3.4.1/src/menu.h" (29 May 2020, 6287 Bytes) of package /linux/privat/feh-3.4.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "menu.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.4_vs_3.4.1.

    1 /* menu.h
    2 
    3 Copyright (C) 1999-2003 Tom Gilbert.
    4 Copyright (C) 2010-2020 Daniel Friesel.
    5 
    6 Permission is hereby granted, free of charge, to any person obtaining a copy
    7 of this software and associated documentation files (the "Software"), to
    8 deal in the Software without restriction, including without limitation the
    9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   10 sell copies of the Software, and to permit persons to whom the Software is
   11 furnished to do so, subject to the following conditions:
   12 
   13 The above copyright notice and this permission notice shall be included in
   14 all copies of the Software and its documentation and acknowledgment shall be
   15 given in the documentation and software packages that this Software was
   16 used.
   17 
   18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   21 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
   22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   24 
   25 */
   26 
   27 #ifndef MENU_H
   28 #define MENU_H
   29 
   30 typedef struct _feh_menu feh_menu;
   31 typedef struct _feh_menu_item feh_menu_item;
   32 typedef struct _feh_menu_list feh_menu_list;
   33 
   34 #define MENU_ITEM_STATE_NORMAL   0x00
   35 #define MENU_ITEM_STATE_SELECTED 0x01
   36 #define MENU_ITEM_STATE_ON       0x02
   37 
   38 #define MENU_ITEM_IS_SELECTED(item) \
   39 ((item)->state & MENU_ITEM_STATE_SELECTED)
   40 #define MENU_ITEM_SET_NORMAL(item) \
   41 (item)->state = (item)->state & (~MENU_ITEM_STATE_SELECTED)
   42 #define MENU_ITEM_SET_SELECTED(item) \
   43 (item)->state = (item)->state | MENU_ITEM_STATE_SELECTED
   44 
   45 #define MENU_ITEM_IS_ON(item) \
   46 ((item)->state & MENU_ITEM_STATE_ON)
   47 #define MENU_ITEM_TOGGLE_ON(item) \
   48 ((item)->state |= MENU_ITEM_STATE_ON)
   49 #define MENU_ITEM_TOGGLE_OFF(item) \
   50 ((item)->state &= ~(MENU_ITEM_STATE_ON))
   51 #define MENU_ITEM_TOGGLE_SET(item, setting) \
   52 ((setting) ? MENU_ITEM_TOGGLE_ON(item) : MENU_ITEM_TOGGLE_OFF(item))
   53 #define MENU_ITEM_TOGGLE(item) \
   54 (((item)->state & MENU_ITEM_STATE_ON) ? MENU_ITEM_TOGGLE_OFF(item) : MENU_ITEM_TOGGLE_ON(item))
   55 
   56 #define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
   57 ((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
   58 #define SPANS_COMMON(x1, w1, x2, w2) \
   59 (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
   60 
   61 #define FEH_MENU_PAD_LEFT 3
   62 #define FEH_MENU_PAD_RIGHT 3
   63 #define FEH_MENU_PAD_TOP 3
   64 #define FEH_MENU_PAD_BOTTOM 3
   65 
   66 #define FEH_MENUITEM_PAD_LEFT 2
   67 #define FEH_MENUITEM_PAD_RIGHT 2
   68 #define FEH_MENUITEM_PAD_TOP 1
   69 #define FEH_MENUITEM_PAD_BOTTOM 1
   70 
   71 #define FEH_MENU_SEP_MAX_H 5
   72 
   73 #define FEH_MENU_SUBMENU_H 14
   74 #define FEH_MENU_SUBMENU_W 9
   75 
   76 #define FEH_MENU_TOGGLE_H 7
   77 #define FEH_MENU_TOGGLE_W 7
   78 #define FEH_MENU_TOGGLE_PAD 3
   79 
   80 typedef feh_menu *(*menuitem_func_gen) (feh_menu * m);
   81 
   82 struct _feh_menu_list {
   83     feh_menu *menu;
   84     feh_menu_list *next;
   85 };
   86 
   87 struct _feh_menu_item {
   88     int state;
   89     char *text;
   90     char *submenu;
   91     int action;
   92     void (*func_free) (void *data);
   93     unsigned short data;
   94     feh_menu_item *next;
   95     feh_menu_item *prev;
   96     unsigned char is_toggle;
   97     int text_x, icon_x, sub_x, toggle_x;
   98     int x, y, w, h;
   99     menuitem_func_gen func_gen_sub;
  100 };
  101 
  102 struct _feh_menu {
  103     char *name;
  104     winwidget fehwin;
  105     Window win;
  106     Pixmap pmap;
  107     int x, y, w, h;
  108     int item_w, item_h;
  109     int visible;
  110     feh_menu_item *items;
  111     feh_menu *next;
  112     feh_menu *prev;
  113     Imlib_Updates updates;
  114     Imlib_Image bg;
  115     int needs_redraw;
  116     void *data;
  117     int calc;
  118     void (*func_free) (feh_menu * m);
  119 };
  120 
  121 feh_menu *feh_menu_new(void);
  122 
  123 feh_menu_item *feh_menu_find_selected(feh_menu * m);
  124 feh_menu_item *feh_menu_find_at_xy(feh_menu * m, int x, int y);
  125 void feh_menu_deselect_selected(feh_menu * m);
  126 void feh_menu_select(feh_menu * m, feh_menu_item * i);
  127 void feh_menu_show_at(feh_menu * m, int x, int y);
  128 void feh_menu_show_at_xy(feh_menu * m, winwidget winwin, int x, int y);
  129 void feh_menu_show_at_submenu(feh_menu * m, feh_menu * parent_m, feh_menu_item * i);
  130 void feh_menu_hide(feh_menu * m, int func_free);
  131 void feh_menu_show(feh_menu * m);
  132 feh_menu_item *feh_menu_add_entry(feh_menu * m, char *text,
  133     char *submenu,
  134     int action, unsigned short data, void (*func_free) (void *data));
  135 feh_menu_item *feh_menu_add_toggle_entry(feh_menu * m, char *text,
  136     char *submenu,
  137     int action, unsigned short data, void (*func_free) (void *data), int setting);
  138 void feh_menu_entry_get_size(feh_menu_item * i, int *w, int *h);
  139 void feh_menu_calc_size(feh_menu * m);
  140 void feh_menu_draw_item(feh_menu_item * i, Imlib_Image im, int ox, int oy);
  141 void feh_menu_redraw(feh_menu * m);
  142 void feh_menu_move(feh_menu * m, int x, int y);
  143 void feh_menu_slide_all_menus_relative(int dx, int dy);
  144 void feh_menu_init_main(void);
  145 void feh_menu_init_single_win(void);
  146 void feh_menu_init_common(void);
  147 void feh_menu_init_thumbnail_viewer(void);
  148 void feh_menu_init_thumbnail_win(void);
  149 void feh_menu_draw_to_buf(feh_menu * m, Imlib_Image im, int ox, int oy);
  150 void feh_menu_draw_menu_bg(feh_menu * m, Imlib_Image im, int ox, int oy);
  151 void feh_menu_draw_submenu_at(int x, int y, Imlib_Image dst, int ox, int oy);
  152 void feh_menu_draw_separator_at(int x, int y, int w, int h, Imlib_Image dst, int ox, int oy);
  153 void feh_menu_item_draw_at(int x, int y, int w, int h, Imlib_Image dst, int ox, int oy, int selected);
  154 void feh_menu_draw_toggle_at(int x, int y, int w, int h, Imlib_Image dst, int ox, int oy, int on);
  155 void feh_redraw_menus(void);
  156 feh_menu *feh_menu_find(char *name);
  157 void feh_redraw_menus(void);
  158 feh_menu *feh_menu_get_from_window(Window win);
  159 void feh_raise_all_menus(void);
  160 void feh_menu_free(feh_menu * m);
  161 feh_menu_item *feh_menu_find_selected_r(feh_menu * m, feh_menu ** parent);
  162 void feh_menu_select_prev(feh_menu * selected_menu, feh_menu_item * selected_item);
  163 void feh_menu_select_next(feh_menu * selected_menu, feh_menu_item * selected_item);
  164 void feh_menu_item_activate(feh_menu * selected_menu, feh_menu_item * selected_item);
  165 void feh_menu_select_parent(feh_menu * selected_menu);
  166 void feh_menu_select_submenu(feh_menu * selected_menu);
  167 
  168 extern feh_menu *menu_root;
  169 extern feh_menu *menu_single_win;
  170 extern feh_menu *menu_thumbnail_viewer;
  171 extern feh_menu *menu_thumbnail_win;
  172 extern Window menu_cover;
  173 
  174 #endif