Back to index

plt-scheme  4.2.1
Defines | Typedefs | Functions | Variables
xwMenu.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/keysym.h>
#include <xwMenuP.h>
#include <xwTools3d.h>
#include <xwTabString.h>
#include <wxtimeout.h>
#include "wx_visual.h"
#include "wxAllocColor.h"
#include "xwGray.h"

Go to the source code of this file.

Defines

#define XtNtopShadowPixmap   "topShadowPixmap"
#define XtCTopShadowPixmap   "TopShadowPixmap"
#define XtNbottomShadowPixmap   "bottomShadowPixmap"
#define XtCBottomShadowPixmap   "BottomShadowPixmap"
#define XtNindicatorPixmap   "indicatorShadowPixmap"
#define XtCIndicatorPixmap   "IndicatorShadowPixmap"
#define offset(field)   XtOffset(MenuWidget, field)
#define VMARGIN   2
#define ISPACING   4
#define CHOICE_LEFT   1
#define CHOICE_RIGHT   13
#define SuperClass   ((CoreWidgetClass)&coreClassRec)
#define CHANGED_bg_   (new->core.background_pixel != old->core.background_pixel)
#define CHANGED(val)   (new->menu.val != old->menu.val)
#define NEW(val)   (new->menu.val)
#define OLD(val)   (old->menu.val)
#define TOO_TALL_SCROLL_HEIGHT   14
#define SET_MAX_VALUE(val)   if (val > max_##val) max_##val = val;

Typedefs

typedef void(* SizeFunction )(MenuWidget, menu_item *, Boolean, unsigned *, unsigned *, unsigned *, unsigned *)
typedef void(* DrawFunction )(MenuWidget, menu_state *, menu_item *, unsigned, unsigned)

Functions

int wxUseMenuHiliteBorder ()
static void MenuClassInitialize ()
static void MenuDestroy ()
static void MenuInitialize ()
static void MenuRealize ()
static void MenuRedisplay ()
static void MenuResize ()
static Boolean MenuSetValues ()
static void Start ()
static void Drag ()
static void Select ()
static void Motion ()
static void Key ()
void FreeTimer (long timer)
static int HasHotKey (char *l, int key)
static void CreateGCs (MenuWidget mw)
static void CreateShadowGCs (MenuWidget mw)
static void ReleaseGCs (MenuWidget mw)
static void ReleaseShadowGCs (MenuWidget mw)
static void ComputeMenuSize (MenuWidget mw, menu_state *ms)
static void DisplayMenu (MenuWidget mw, menu_state *ms)
static void MenuInitialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
static void MenuRealize (Widget w, Mask *value_mask, XSetWindowAttributes *window_attributes)
static void MenuRedisplay (Widget w, XEvent *ev, Region region)
static void MenuDestroy (Widget w)
static Boolean MenuSetValues (Widget gcurrent, Widget grequest, Widget gnew)
static void MenuResize (Widget w)
static int HandleMotionEvent (MenuWidget mw, XMotionEvent *ev, int is_click)
static void UnhighlightItem (MenuWidget mw, menu_state *ms, menu_item *item)
static void HighlightItem (MenuWidget mw, menu_state *ms, menu_item *item)
static void MoveSelection (MenuWidget mw, int direction)
static void DoSelect (Widget w, Time time, int force)
void wxAddGrab (Widget)
void wxRemoveGrab (Widget)
static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params)
static void Drag (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Select (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Motion (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Key (Widget w, XEvent *event, String *params, Cardinal *num_params)
Boolean get_scaled_color (Widget, float, Pixel, Pixel *)
static unsigned StringWidth (MenuWidget mw, char *s)
static void GetResourceName (char *in, char *out)
char * ResourcedText (MenuWidget mw, menu_item *item, Subresource type)
static void MenuTextSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void MenuButtonSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void MenuToggleSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void MenuCascadeSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void MenuPushrightSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void MenuSeparatorSize (MenuWidget mw, menu_item *item, Boolean in_menubar, unsigned *l, unsigned *m, unsigned *r, unsigned *h)
static void DrawTextItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawButtonItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawRadioItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawToggleItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawCascadeItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawSeparatorItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void DrawPushrightItem (MenuWidget mw, menu_state *ms, menu_item *item, unsigned x, unsigned y)
static void ComputeItemPos (MenuWidget mw, menu_state *ms, menu_item *item, unsigned *x, unsigned *y)
static void MakeNewMenuWindow (MenuWidget mw, menu_state *prev, menu_item *item, unsigned x, unsigned y)
static void timer_callback (XtPointer client_data, XtIntervalId *timer)
void Xaw3dPopupMenu (MenuWidget mw, Widget calling_widget)
void Xaw3dPopupMenuAtPos (MenuWidget mw, int x, int y)
int xwMenuIsPoppedUp (Widget w)

Variables

static XtResource MenuResources []
static XtActionsRec MenuActionsList []
static char MenuTranslations []
MenuClassRec menuClassRec
WidgetClass menuWidgetClass = (WidgetClass) &menuClassRec
static SizeFunction SizeFunctionList []
static DrawFunction DrawFunctionList []

Define Documentation

#define CHANGED (   val)    (new->menu.val != old->menu.val)

Definition at line 377 of file xwMenu.c.

#define CHANGED_bg_   (new->core.background_pixel != old->core.background_pixel)

Definition at line 376 of file xwMenu.c.

#define CHOICE_LEFT   1

Definition at line 156 of file xwMenu.c.

#define CHOICE_RIGHT   13

Definition at line 157 of file xwMenu.c.

#define ISPACING   4

Definition at line 155 of file xwMenu.c.

#define NEW (   val)    (new->menu.val)

Definition at line 378 of file xwMenu.c.

#define offset (   field)    XtOffset(MenuWidget, field)

Definition at line 57 of file xwMenu.c.

#define OLD (   val)    (old->menu.val)

Definition at line 379 of file xwMenu.c.

#define SET_MAX_VALUE (   val)    if (val > max_##val) max_##val = val;
#define SuperClass   ((CoreWidgetClass)&coreClassRec)

Definition at line 191 of file xwMenu.c.

#define TOO_TALL_SCROLL_HEIGHT   14

Definition at line 971 of file xwMenu.c.

#define VMARGIN   2

Definition at line 154 of file xwMenu.c.

#define XtCBottomShadowPixmap   "BottomShadowPixmap"

Definition at line 53 of file xwMenu.c.

#define XtCIndicatorPixmap   "IndicatorShadowPixmap"

Definition at line 55 of file xwMenu.c.

#define XtCTopShadowPixmap   "TopShadowPixmap"

Definition at line 51 of file xwMenu.c.

#define XtNbottomShadowPixmap   "bottomShadowPixmap"

Definition at line 52 of file xwMenu.c.

#define XtNindicatorPixmap   "indicatorShadowPixmap"

Definition at line 54 of file xwMenu.c.

#define XtNtopShadowPixmap   "topShadowPixmap"

Definition at line 50 of file xwMenu.c.


Typedef Documentation

typedef void(* DrawFunction)(MenuWidget, menu_state *, menu_item *, unsigned, unsigned)

Definition at line 1252 of file xwMenu.c.

typedef void(* SizeFunction)(MenuWidget, menu_item *, Boolean, unsigned *, unsigned *, unsigned *, unsigned *)

Definition at line 956 of file xwMenu.c.


Function Documentation

static void ComputeItemPos ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned *  x,
unsigned *  y 
) [static]

Definition at line 1353 of file xwMenu.c.

{
    if (!ms->prev && mw->menu.horizontal) { /* in menubar ? */
       menu_item  *i;
       Dimension  pushright = 0;
       for (i=ms->menu; i && i!=item; i=i->next)
           if (!pushright && i->type==MENU_PUSHRIGHT)
              pushright = ms->w - i->end - i->start;
       *x = item->start + pushright;
       *y = mw->menu.shadow_width;
    } else {
       *x = mw->menu.shadow_width;
       *y = item->start + ms->delta;
    }
}

Here is the caller graph for this function:

static void ComputeMenuSize ( MenuWidget  mw,
menu_state ms 
) [static]

Definition at line 973 of file xwMenu.c.

{
    unsigned  left_width, label_width, right_width, height;
    unsigned  max_left_width, max_label_width, max_right_width, max_height;
    unsigned  screen_h, usable_h, vis_count = 0, item_count = 0;
    Boolean   in_menubar = (mw->menu.horizontal && !ms->prev);
    menu_item *item, *pushright_item=NULL;

    screen_h = HeightOfScreen(XtScreen(mw));
    usable_h = screen_h - (2*mw->menu.shadow_width + 2*TOO_TALL_SCROLL_HEIGHT);

    ms->too_tall = 0;

    max_left_width = max_label_width = max_right_width = max_height = 0;
    for (item=ms->menu; item; item=item->next) {
       SizeFunctionList[item->type](mw, item, in_menubar, &left_width,
                                 &label_width, &right_width, &height);
#       define SET_MAX_VALUE(val) if (val > max_##val) max_##val = val;      
       if (in_menubar) {
           if (!pushright_item && item->type == MENU_PUSHRIGHT)
              pushright_item = item;
           if ((item->type == MENU_HELP) && !item->next 
              && (mw->core.parent->core.parent->core.width > max_label_width + left_width + label_width + right_width)) {
             item->start      = mw->core.parent->core.parent->core.width - (left_width + label_width + right_width) - mw->menu.shadow_width;
             item->end        = item->start + left_width + label_width + right_width;
             max_label_width  = mw->core.parent->core.parent->core.width;
           } else {
             item->start      = max_label_width + mw->menu.shadow_width;
             max_label_width += left_width + label_width + right_width;
             item->end        = max_label_width + mw->menu.shadow_width;
           }
           SET_MAX_VALUE(height);
       } else {
           SET_MAX_VALUE(left_width);
           SET_MAX_VALUE(label_width);
           SET_MAX_VALUE(right_width);
           if ((max_height + height) < usable_h) {
             vis_count++;
           } else if (!ms->too_tall) {
             screen_h = max_height + 2*TOO_TALL_SCROLL_HEIGHT;
             ms->too_tall = 1;
           }
           item->start  = max_height + mw->menu.shadow_width;
           max_height  += height;
           item->end    = max_height + mw->menu.shadow_width;
           item_count++;
       }
#       undef SET_MAX_VALUE
    }

    if (ms->too_tall)
      max_height = screen_h;

    if (!max_height && in_menubar) {
      /* For menu bar: make it at least as tall as with an item */
      max_height = (wx_ASCENT(mw->menu.font, mw->menu.xft_font) 
                  + wx_DESCENT(mw->menu.font, mw->menu.xft_font)
                  + 2*VMARGIN + 2*mw->menu.shadow_width);
    }
    ms->w       = max_left_width + max_label_width + max_right_width
                 + 2*mw->menu.shadow_width;
    if (ms->w < mw->menu.requested_width)
      ms->w = mw->menu.requested_width;
    ms->h       = max_height + 2*mw->menu.shadow_width;
    ms->wLeft   = max_left_width;
    ms->wMiddle = max_label_width;
    if (in_menubar) {
       if (pushright_item)  pushright_item->end = ms->w - pushright_item->end;
       ms->wLeft = mw->menu.hmargin + mw->menu.shadow_width;
    }
}

Here is the caller graph for this function:

static void CreateGCs ( MenuWidget  mw) [static]

Definition at line 707 of file xwMenu.c.

{
    Display    *dpy = XtDisplay((Widget)mw);
    Screen     *scr = XtScreen((Widget)mw);
    Window     win  = RootWindowOfScreen(DefaultScreenOfDisplay(dpy));
    XGCValues  xgcv;
    int        gcf_flag = 0;

    mw->menu.stipple_pxmap = XCreatePixmapFromBitmapData(dpy, win,
                             wx_gray_bits, wx_gray_width, wx_gray_height, 1, 0, 1);

    if (mw->menu.font) {
      xgcv.font = mw->menu.font->fid;
      gcf_flag = GCFont;
    }

    xgcv.foreground = mw->core.background_pixel;
    xgcv.background = mw->menu.foreground;
    mw->menu.erase_GC = XtGetGC((Widget)mw,
                            gcf_flag|GCForeground|GCBackground,
                            &xgcv);

    xgcv.foreground = mw->menu.foreground;
    xgcv.background = mw->core.background_pixel;
    mw->menu.normal_GC = XtGetGC((Widget)mw,
                             gcf_flag|GCForeground|GCBackground,
                             &xgcv);
    
    if (wx_enough_colors(scr)) {
      Pixel r;
      get_scaled_color((Widget)mw, 0.6, xgcv.background, &r);
      xgcv.foreground = r;
      mw->menu.inactive_GC = XtGetGC((Widget)mw,
                                 gcf_flag|GCForeground|GCBackground,
                                 &xgcv);
    } else {
      xgcv.fill_style = FillStippled;
      xgcv.stipple    = mw->menu.stipple_pxmap;
      mw->menu.inactive_GC = XtGetGC((Widget)mw,
                                 gcf_flag|GCForeground|GCBackground|
                                 GCFillStyle|GCStipple,
                                 &xgcv);
    }

    if (DefaultDepthOfScreen(scr) == 1) {
       mw->menu.indicator_pxmap = Xaw3dAllocPixmap((Widget)mw,
                                              mw->core.background_pixel,
                                              GRAY);
    } else {
       if (mw->menu.indicator_pixel == -1) {
         Pixel res;
         get_scaled_color((Widget)mw, 
                        mw->menu.indicator_contrast/100.0, 
                        mw->core.background_pixel, &res);
         mw->menu.indicator_pixel = res;
         mw->menu.indicator_pxmap = (Pixmap)0;
       }
       if (mw->menu.highlight_pixel == -1) {
         XColor color;
         color.red = 0;
         color.green = 0;
         color.blue = 180 << 8;
         wxAllocColor(XtDisplay(mw), wx_default_colormap, &color);
         mw->menu.highlight_pixel = color.pixel;
       }
       if (mw->menu.highlight_top_pixel == -1) {
         Pixel res;
         get_scaled_color((Widget)mw, 1.35, mw->menu.highlight_pixel, &res);
         mw->menu.highlight_top_pixel = res;
       }
    }
    mw->menu.indicator_GC = Xaw3dGetGC((Widget)mw, 0,
                                   mw->menu.indicator_pxmap,
                                   mw->menu.indicator_pixel);
    mw->menu.highlight_GC = Xaw3dGetGC((Widget)mw, 0,
                                   0,
                                   mw->menu.highlight_pixel);
    mw->menu.highlight_top_GC = Xaw3dGetGC((Widget)mw, 0,
                                      0,
                                      mw->menu.highlight_top_pixel);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void CreateShadowGCs ( MenuWidget  mw) [static]

Definition at line 789 of file xwMenu.c.

{
    Screen  *scr = XtScreen((Widget)mw);
    Pixel   bg   = mw->core.background_pixel, res;

    if (DefaultDepthOfScreen (scr) == 1) {
       mw->menu.top_shadow_pxmap = Xaw3dAllocPixmap((Widget)mw, bg, LIGHTER);
       mw->menu.bot_shadow_pxmap = Xaw3dAllocPixmap((Widget)mw, bg, DARKER);
    } else {
       if (mw->menu.top_shadow_pixel == -1) {
         get_scaled_color((Widget)mw, mw->menu.top_shadow_contrast/100.0, bg, &res);
         mw->menu.top_shadow_pixel = res;
         mw->menu.top_shadow_pxmap = (Pixmap)0;
       }
       if (mw->menu.bot_shadow_pixel == -1) {
         get_scaled_color((Widget)mw, mw->menu.bot_shadow_contrast/100.0, bg, &res);
         mw->menu.bot_shadow_pixel = res;
         mw->menu.bot_shadow_pxmap = (Pixmap)0;
       }
    }
    mw->menu.top_shadow_GC = Xaw3dGetGC((Widget)mw, 0,
                                   mw->menu.top_shadow_pxmap,
                                   mw->menu.top_shadow_pixel);
    mw->menu.bot_shadow_GC = Xaw3dGetGC((Widget)mw, 0,
                                   mw->menu.bot_shadow_pxmap,
                                   mw->menu.bot_shadow_pixel);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void DisplayMenu ( MenuWidget  mw,
menu_state ms 
) [static]

Definition at line 1267 of file xwMenu.c.

{
    menu_item *item;
    unsigned  x, y;
    int s, final;
    Boolean   in_menubar = (mw->menu.horizontal && !ms->prev);

    x = y = mw->menu.shadow_width;
    item = ms->menu;
    if (ms->too_tall) {
      if (ms->scrolled) {
       Xaw3dDrawArrow(XtDisplay((Widget)mw), ms->win,
                     mw->menu.top_shadow_GC,
                     mw->menu.bot_shadow_GC,
                     mw->menu.normal_GC,
                     mw->menu.normal_GC,
                     x + ((ms->w - TOO_TALL_SCROLL_HEIGHT) / 2),
                     y + 2,
                     TOO_TALL_SCROLL_HEIGHT - 4, TOO_TALL_SCROLL_HEIGHT - 4,
                     0,
                     UP,
                     0);
      }
      y += TOO_TALL_SCROLL_HEIGHT;
      for (s = ms->scrolled; s--; ) {
       if (item) {
         y = item->end + ms->delta;
         item = item->next;
       }
      }
      final = (ms->h - (TOO_TALL_SCROLL_HEIGHT + mw->menu.shadow_width)) - ms->delta;
    } else
      final = 35000;
    for (; item && (item->end < final); item=item->next) {
        if (item->type == MENU_HELP)
         x = item->start;
       DrawFunctionList[item->type](mw, ms, item, x, y);
       if (in_menubar) {
           if (item->type == MENU_PUSHRIGHT) {
              if (x+item->end <= ms->w)
                  x = ms->w - item->end;
           } else
              x = item->end;
       } else {
         y = item->end + ms->delta;
       }
    }

    ms->arrow_start = y;
    if (ms->too_tall && item) {
      y = ms->h - (TOO_TALL_SCROLL_HEIGHT + mw->menu.shadow_width);
      Xaw3dDrawArrow(XtDisplay((Widget)mw), ms->win,
                   mw->menu.top_shadow_GC,
                   mw->menu.bot_shadow_GC,
                   mw->menu.normal_GC,
                   mw->menu.normal_GC,
                   x + ((ms->w - TOO_TALL_SCROLL_HEIGHT) / 2),
                   y + 2,
                   TOO_TALL_SCROLL_HEIGHT - 4, TOO_TALL_SCROLL_HEIGHT - 4,
                   0,
                   DOWN,
                   0);
      ms->can_go_down = 1;
    } else
      ms->can_go_down = 0;

    Xaw3dDrawRectangle(
       XtDisplay((Widget)mw), ms->win,
       mw->menu.top_shadow_GC,
       mw->menu.bot_shadow_GC,
       mw->menu.erase_GC,
       mw->menu.indicator_GC,
       0, 0, ms->w, ms->h, 
       in_menubar ? 1 : mw->menu.shadow_width,
       in_menubar ? XAW3D_OUT : XAW3D_OUT_HARD);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void DoSelect ( Widget  w,
Time  time,
int  force 
) [static]

Definition at line 529 of file xwMenu.c.

{
    MenuWidget  mw = (MenuWidget)w;
    menu_item   *selected_item = mw->menu.state->selected;
    menu_state  *ms;

    if (!force && !selected_item)
      return;

    if (mw->menu.grabbed) {
      XtUngrabPointer(w,time);
      XtUngrabKeyboard(w, time);
      wxRemoveGrab(w);
      mw->menu.grabbed = FALSE;
    }

    for (ms=mw->menu.state; ms->prev!=NULL; ms=ms->prev)
       ;
    UnhighlightItem(mw, ms, ms->selected);
    ms->selected = NULL;
    ms->delta = 0;
    if (mw->menu.popped_up) {
       mw->menu.popped_up = FALSE;
       XtPopdown(XtParent(mw));
    }

    XFlush(XtDisplay(mw));

    if (selected_item
       && selected_item->enabled 
       && selected_item->type != MENU_TEXT
       && selected_item->type != MENU_SEPARATOR
       && selected_item->type != MENU_PUSHRIGHT)
      XtCallCallbackList(w, mw->menu.on_select, (XtPointer)selected_item);
    else
      XtCallCallbackList(w, mw->menu.on_no_select, (XtPointer)NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Drag ( ) [static]

Here is the caller graph for this function:

static void Drag ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 501 of file xwMenu.c.

{
    MenuWidget    mw    = (MenuWidget)w;
    XMotionEvent  *ev   = &event->xmotion;
    int           x     = ev->x_root;
    int           y     = ev->y_root;
    int           state = ev->state;

    HandleMotionEvent(mw, ev, 0);
    XSync(XtDisplay(mw), FALSE);
    /* allow motion events to be generated again */
    if ((!ev->is_hint
        || XQueryPointer(XtDisplay(mw), ev->window,
                       &ev->root, &ev->subwindow,
                       &ev->x_root, &ev->y_root,
                       &ev->x, &ev->y, &ev->state))
       && ev->state == state
       && (ev->x_root != x || ev->y_root != y)) {
      HandleMotionEvent(mw, ev, 0);
      XSync(XtDisplay(mw), FALSE);
    }
}

Here is the call graph for this function:

static void DrawButtonItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1118 of file xwMenu.c.

{
    char *key;

    DrawTextItem(mw, ms, item, x, y);
    if ((!mw->menu.horizontal || ms->prev)
       && (key=ResourcedText(mw, item, SUBRESOURCE_KEY))) {
      int on;
      on = ((ms->selected==item) && (item->enabled));
      XfwfDrawString(XtDisplay(mw), ms->win,
                   (wxEXT_FONT(mw->menu.xft_font)
                    ? (on
                      ? mw->menu.highlight_GC 
                      : mw->menu.erase_GC)
                    : (item->enabled 
                      ? (on
                         ? mw->menu.erase_GC 
                         : mw->menu.normal_GC)
                      : mw->menu.inactive_GC)),
                   x+ms->wLeft+ms->wMiddle+(3 * ISPACING),
                   y+mw->menu.shadow_width+VMARGIN+wx_ASCENT(mw->menu.font,
                                                        mw->menu.xft_font),
                   key, strlen(key), NULL, mw->menu.font, 
                   wxEXT_FONT(mw->menu.xft_font),
                   (on ? -1 : item->enabled), 1, NULL, 1);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void DrawCascadeItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1206 of file xwMenu.c.

{
    DrawTextItem(mw, ms, item, x, y);
    if (!mw->menu.horizontal || ms->prev) {
      int on, size;
      on = item->enabled && ms->selected==item;
      size = mw->menu.indicator_size;
      if (size & 0x1) size--;
      Xaw3dDrawArrow(XtDisplay((Widget)mw), ms->win,
                   mw->menu.top_shadow_GC,
                   mw->menu.bot_shadow_GC,
                   (on ? mw->menu.top_shadow_GC : mw->menu.normal_GC),
                   (on ? mw->menu.top_shadow_GC : mw->menu.normal_GC),
                   x+ms->w
                   -(3*mw->menu.shadow_width
                     +mw->menu.hmargin
                     +mw->menu.indicator_size),
                   y+mw->menu.shadow_width+VMARGIN
                   +(wx_ASCENT(mw->menu.font,
                             mw->menu.xft_font)
                     + wx_DESCENT(mw->menu.font,
                                mw->menu.xft_font)
                     - size)/2,
                   size, size, 0,
                   RIGHT, 0);
    }
}

Here is the call graph for this function:

static void DrawPushrightItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1247 of file xwMenu.c.

{
}
static void DrawRadioItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1147 of file xwMenu.c.

{
    DrawButtonItem(mw, ms, item, x, y);
    Xaw3dDrawRadio(XtDisplay((Widget)mw), ms->win,
                 mw->menu.top_shadow_GC,
                 mw->menu.bot_shadow_GC,
                 mw->menu.indicator_GC,
                 mw->menu.erase_GC,
                 item->enabled ? mw->menu.normal_GC : mw->menu.inactive_GC,
                 x+mw->menu.shadow_width+mw->menu.hmargin,
                 y+mw->menu.shadow_width+VMARGIN
                 +(wx_ASCENT(mw->menu.font,
                            mw->menu.xft_font)
                   +wx_DESCENT(mw->menu.font,
                             mw->menu.xft_font)
                   -mw->menu.indicator_size)/2,
                 mw->menu.indicator_size, mw->menu.shadow_width, 
                 item->set);
}

Here is the call graph for this function:

static void DrawSeparatorItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1235 of file xwMenu.c.

{
    if (!mw->menu.horizontal ||ms->prev)
       Xaw3dDrawLine(
           XtDisplay((Widget)mw), ms->win,
           mw->menu.top_shadow_GC,
           mw->menu.bot_shadow_GC,
           mw->menu.normal_GC,
           x, y, ms->w, mw->menu.shadow_width, FALSE, XAW3D_ETCHED_IN);
}

Here is the call graph for this function:

static void DrawTextItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1054 of file xwMenu.c.

{
    Boolean    in_menubar = (mw->menu.horizontal && !ms->prev);
    Dimension  extra_x = 0;
    char       *label;
    int on, width, height;

    if (in_menubar) {
       if (item->type == MENU_TOGGLE || item->type == MENU_RADIO) {
           extra_x = mw->menu.indicator_size + ISPACING;
       }
    }

    on = ((ms->selected==item) && (item->enabled));

    width = (in_menubar? item->end-item->start : ms->w-2*mw->menu.shadow_width);
    height = (in_menubar? ms->h-2*mw->menu.shadow_width : item->end-item->start);

    XFillRectangle(XtDisplay(mw), ms->win, 
                 (on ? mw->menu.highlight_GC : mw->menu.erase_GC), 
                 x, y, width, height);

    if ((label=ResourcedText(mw, item, SUBRESOURCE_LABEL))) {
      XfwfDrawString(XtDisplay(mw), ms->win,
                   (wxEXT_FONT(mw->menu.xft_font)
                    ? (on
                      ? mw->menu.highlight_GC
                      : mw->menu.erase_GC)
                    : ((item->enabled || item->type==MENU_TEXT) 
                      ? (on
                         ? mw->menu.erase_GC 
                         : mw->menu.normal_GC)
                      : mw->menu.inactive_GC)),
                   x+ms->wLeft+extra_x,
                   y+mw->menu.shadow_width+VMARGIN+wx_ASCENT(mw->menu.font,
                                                        mw->menu.xft_font),
                   label, strlen(label), NULL,
                   mw->menu.font, wxEXT_FONT(mw->menu.xft_font), 
                   (on ? -1 : (item->enabled || item->type==MENU_TEXT)), 
                   1, NULL, 1);
    }

    if (wxUseMenuHiliteBorder()) {
      if (item->enabled && item->type!=MENU_TEXT)
       Xaw3dDrawRectangle(
           XtDisplay((Widget)mw), ms->win,
           (on
            ? mw->menu.highlight_top_GC
            : mw->menu.top_shadow_GC),
           mw->menu.bot_shadow_GC,
           (on
            ? mw->menu.highlight_GC
            : mw->menu.erase_GC),
           mw->menu.indicator_GC,
           x,
           y,
           width,
           height,
           mw->menu.shadow_width,
           (ms->selected==item) ? XAW3D_OUT_HARD : XAW3D_BACKGROUND);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void DrawToggleItem ( MenuWidget  mw,
menu_state ms,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1168 of file xwMenu.c.

{
    DrawButtonItem(mw, ms, item, x, y);
    if (item->set) {
      Display *dpy = XtDisplay((Widget)mw);
      Window win = ms->win;
      GC gc;
      int h, h2, h4, h34;

      x += mw->menu.shadow_width + mw->menu.hmargin;
      y += (mw->menu.shadow_width + VMARGIN
           + (wx_ASCENT(mw->menu.font,
                      mw->menu.xft_font)
              + wx_DESCENT(mw->menu.font,
                        mw->menu.xft_font)
              - mw->menu.indicator_size)/2) + 1;
      h = mw->menu.indicator_size - 2;
      h2 = h / 2;
      h4 = h / 4;
      h34 = h - h4;

      gc = (item->enabled 
           ? ((ms->selected==item)
              ? mw->menu.erase_GC 
              : mw->menu.normal_GC)
           : mw->menu.inactive_GC);

      XDrawLine(dpy, win, gc, x + h4, y + h34, x + h2, y + h);
      XDrawLine(dpy, win, gc, x + h2, y + h, x + h, y);

      x++;

      XDrawLine(dpy, win, gc, x + h4, y + h34, x + h2, y + h);
      XDrawLine(dpy, win, gc, x + h2, y + h, x + h, y);
    }
}

Here is the call graph for this function:

void FreeTimer ( long  timer)

Definition at line 237 of file xwMenu.c.

{
  if (timer) {
    wxRemoveTimeOut(timer);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Boolean get_scaled_color ( Widget  ,
float  ,
Pixel  ,
Pixel  
)

Definition at line 1145 of file xwCommon.c.

{
  /* These two must be mutually prime: */
#define CACHE_SIZE 29
#define CACHE_STEP 10
  static struct {
    int set;
    float scale;
    Pixel in, out;
  } cache[CACHE_SIZE];
  static int reset = 0;
  int i;

  for (i = 0; i < CACHE_SIZE; i++) {
    if (cache[i].set 
       && (cache[i].scale == scale)
       && (cache[i].in == base)) {
      *result = cache[i].out;
      return TRUE;
    }
  }

  if (!XfwfChooseColor(self, scale, base, result))
    return FALSE;
  
  cache[reset].scale = scale;
  cache[reset].in = base;
  cache[reset].out = *result;
  cache[reset].set = 1;

  if (!cache[reset].set) {
    cache[reset].set = 1;
    reset++;
  } else
    reset += CACHE_STEP;

  reset = (reset % CACHE_SIZE);

  return TRUE;
}
static void GetResourceName ( char *  in,
char *  out 
) [static]

Definition at line 853 of file xwMenu.c.

{
    char *first = out;

    while (*in)
       if (isalnum((unsigned char)*in) || (*in)=='_')
           *out++ = *in++;
       else
           in++;
    *first = tolower(*first);
    *out   = '\0';
}

Here is the caller graph for this function:

static int HandleMotionEvent ( MenuWidget  mw,
XMotionEvent *  ev,
int  is_click 
) [static]

Definition at line 1491 of file xwMenu.c.

{
    menu_state *ms = NULL;
    menu_item  *item = NULL;
    Dimension  pushright = 0;
    Boolean    foundone = 0;
    int        scroll = 0, in_extra_region = 0;

    if (mw->menu.state->timer) {
      FreeTimer(mw->menu.state->timer);
      mw->menu.state->timer = 0;
    }

    /* find menu_state belonging to event */
    if (ev) {
      for (ms = mw->menu.state; ms; ms = ms->prev) {
       if (ms->x <= ev->x_root && ev->x_root <= ms->x + ms->w
           &&  ms->y <= ev->y_root && ev->y_root <= ms->y + ms->h) {
         if (ms->too_tall) {
           if (ev->y_root <= (ms->y + TOO_TALL_SCROLL_HEIGHT + mw->menu.shadow_width))
             scroll = -1;
           else if (ev->y_root >= ms->arrow_start)
             scroll = 1;
         }

         if (!scroll) {
           foundone = 1;
           /* find menu_item belonging to event */
           for (item = ms->menu; item; item = item->next)
             if (mw->menu.horizontal && !ms->prev) {
              if (!pushright && item->type == MENU_PUSHRIGHT)
                pushright = ms->w - item->end - item->start;
              else if (ms->x + pushright + item->start <= ev->x_root
                      && ev->x_root < ms->x + pushright + item->end)
                break;
             } else {
              if (ms->y + item->start + ms->delta <= ev->y_root
                  &&  ev->y_root < ms->y + item->end + ms->delta)
                break;
             }
         }
         break;
       }
      }      
    }

    {
      menu_state *tms = NULL;
      for (tms = mw->menu.state; tms && tms->prev; tms = tms->prev) {
      }
      if (tms && ev) {
       if (!(tms->x <= ev->x_root 
             && ev->x_root <= tms->x + tms->w
             && tms->y <= ev->y_root 
             && ev->y_root <= tms->y + tms->h)) {
         if (tms->x - mw->menu.extra_left <= ev->x_root 
             && ev->x_root <= tms->x + tms->w + mw->menu.extra_right
             && tms->y - mw->menu.extra_top <= ev->y_root 
             && ev->y_root <= tms->y + tms->h + mw->menu.extra_bottom) {
           in_extra_region = 1;
         }
       }
      }
    }
    
    if (!foundone)
      mw->menu.moused_out = !in_extra_region;

    if (!mw->menu.forPopup 
        && (is_click && ms && (item == ms->selected))) { /* pointer on the same item and a click */
      return 0;
    }

    if (!item) { /* if pointer not on menu_item unhighlight last selected */
      UnhighlightItem(mw, mw->menu.state, mw->menu.state->selected);
      if (scroll) {
       if (scroll < 0) {
         if (ms->scrolled) {
           ms->scrolled -= 1;
           ms->scroll_top = ms->scroll_top->prev;
           ms->delta += (ms->scroll_top->end - ms->scroll_top->start);
         } else
           scroll = 0;
       } else {
         if (ms->can_go_down) {
           ms->scrolled += 1;
           ms->delta -= (ms->scroll_top->end - ms->scroll_top->start);
           ms->scroll_top = ms->scroll_top->next;
         }  else
           scroll = 0;
       }

       if (scroll) {
         XFillRectangle(XtDisplay((Widget)mw), ms->win, 
                      mw->menu.erase_GC,
                      0, 0, ms->w, ms->h);
         DisplayMenu(mw, mw->menu.state);

         ms->timer = wxAppAddTimeOut(XtWidgetToApplicationContext((Widget)mw),
                                  100, timer_callback, mw, (Widget)mw);
       }
      }
      return in_extra_region;
    }

    if (item == ms->selected) { /* pointer on the same item (and not a click) */
      return 1;
    }

    /* unhighlight old item on same level (ms!) and highlight new item */
    UnhighlightItem(mw, ms, ms->selected);
    HighlightItem(mw, ms, item);
    if (item->enabled 
       && item->type != MENU_TEXT
       && item->type != MENU_SEPARATOR
       && item->type != MENU_PUSHRIGHT)
       XtCallCallbackList((Widget)mw, mw->menu.on_new_item, (XtPointer)item);
        /* XtCallCallbackList((Widget)mw, mw->menu.on_new_item,
          (XtPointer)ResourcedText(mw, item, SUBRESOURCE_HELP)); */

    return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int HasHotKey ( char *  l,
int  key 
) [static]

Definition at line 244 of file xwMenu.c.

{
  int i;

  if (!l)
    return 0;

  for (i = 0; l[i]; i++) {
    if ((l[i] == '&') 
       && (((l[i+1] > 0)
            && (key > 0)
            && (key < 128)
            && (tolower(l[i+1]) == tolower(key)))
           || (l[i+1] == key)))
      return 1;
  }

  return 0;
}

Here is the caller graph for this function:

static void HighlightItem ( MenuWidget  mw,
menu_state ms,
menu_item item 
) [static]

Definition at line 1438 of file xwMenu.c.

{
    unsigned x, y;

    if (!item) /* nothing to highlight */
       return;
    ms->selected = item;
    ComputeItemPos(mw, ms, item, &x, &y);
    DrawFunctionList[item->type](mw, ms, item, x, y);
    if (((item->type == MENU_CASCADE) || (item->type == MENU_HELP)) && item->enabled) {
       MakeNewMenuWindow(mw, ms, item, x, y);
       XClearWindow(XtDisplay(mw), mw->menu.state->win);
       XMapRaised(XtDisplay(mw), mw->menu.state->win);
       DisplayMenu(mw, mw->menu.state);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Key ( ) [static]
static void Key ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 605 of file xwMenu.c.

{
  MenuWidget  mw = (MenuWidget)w;
  XKeyEvent  *ev   = &event->xkey;
  KeySym         keysym;

  (void)XLookupString(ev, NULL, 0, &keysym, NULL);

  switch (keysym) {
  case XK_Right:
  case XK_Left:
    if (mw->menu.state && mw->menu.state->prev && mw->menu.state->prev->prev) {
      /* In a submenu */
      if (keysym == XK_Right) {
       if (!mw->menu.state->selected) {
         /* select first in submenu */
         if (mw->menu.state->menu)
           HighlightItem(mw, mw->menu.state, mw->menu.state->menu);
       }
      } else {
       if (mw->menu.state->selected) {
         UnhighlightItem(mw, mw->menu.state, mw->menu.state->selected);
       }
      }
    } else {
      /* Change top-level menu: */
      if (mw->menu.state && mw->menu.state->prev && mw->menu.state->prev->selected) {
       menu_item *item, *orig_item;
       item = orig_item = mw->menu.state->prev->selected;
       do {
         if (keysym == XK_Right) {
           if (item->next)
             item = item->next;
           else
             item = mw->menu.state->prev->menu;
         } else {
           if (item->prev)
             item = item->prev;
           else {
             while (item->next)
              item = item->next;
           }
         }
       } while (item && (item != orig_item) && !item->enabled);
       if (item && (item != orig_item)) {
         UnhighlightItem(mw, mw->menu.state->prev, mw->menu.state->prev->selected);
         HighlightItem(mw, mw->menu.state, item);
       }
      }
    }
    break;
  case XK_Down:
    MoveSelection(mw, 1);
    break;
  case XK_Up:
    MoveSelection(mw, -1);
    break;
  case XK_Escape:
    if (mw->menu.state->selected)
      UnhighlightItem(mw, mw->menu.state, mw->menu.state->selected);
    DoSelect(w, event ? event->xkey.time : 0L, 1);
    break;
  case XK_Return:
    DoSelect(w, event ? event->xkey.time : 0L, 1);
    break;
  default:
    /* Look for menu to select */
    {
      menu_item *item;
      if (mw->menu.state->prev)
       item = mw->menu.state->prev->selected->contents;
      else
       item = NULL;
      for (; item; item = item->next) {
       if (item->enabled && HasHotKey(item->label, keysym)) {
         if (mw->menu.state->selected != item) {
           UnhighlightItem(mw, mw->menu.state, mw->menu.state->selected);
           HighlightItem(mw, mw->menu.state, item);
         }
         if (!item->contents)
           DoSelect(w, event ? event->xkey.time : 0L, 1);
         break;
       }
      }
    }
    break;
  }
}

Here is the call graph for this function:

static void MakeNewMenuWindow ( MenuWidget  mw,
menu_state prev,
menu_item item,
unsigned  x,
unsigned  y 
) [static]

Definition at line 1370 of file xwMenu.c.

{
    int        scr_width  = WidthOfScreen(XtScreen(mw));
    int        scr_height = HeightOfScreen(XtScreen(mw));
    menu_state *new       = (menu_state*)XtMalloc(sizeof(menu_state));
    int        mask;
    XSetWindowAttributes xswa;

    if (mw->menu.state->timer) {
      FreeTimer(mw->menu.state->timer);
      mw->menu.state->timer = 0;
    }

    /* Create new menu_state, initialize it and compute menu size */
    new->menu      = item->contents;
    new->selected  = NULL;
    new->prev      = prev;
    new->timer     = 0;
    mw->menu.state = new;
    ComputeMenuSize(mw, new);
    new->delta     = (new->too_tall ? TOO_TALL_SCROLL_HEIGHT : 0);
    new->scrolled  = 0;
    new->scroll_top = new->menu;

    /* position window on screen */
    if (mw->menu.horizontal && !prev->prev) { /* item in menubar? */
       new->x = prev->x + x;
       if (new->x + new->w > scr_width)
           new->x = scr_width -  new->w;
       new->y = prev->y + prev->h - mw->menu.shadow_width;
       if (new->y + new->h > scr_height) /* menu doesn't below menubar -> */
           if (new->y > scr_height/2) /* is more place above the menubar ?*/
              new->y = prev->y - new->h +mw->menu.shadow_width;
    } else {
       if (prev->x + prev->w + new->w < scr_width) /* place right of menu? */
           new->x = prev->x + prev->w;
       else if (prev->x - new->w > 0)              /* place left of menu? */
           new->x = prev->x - new->w;
       else                                     /* place on screen border*/
           new->x = scr_width - new->w;

       new->y = prev->y + y - mw->menu.shadow_width;
       if (new->y + new->h > scr_height)
           new->y = scr_height - new->h;
    }

    /* Create new window */
    xswa.save_under        = TRUE;
    xswa.override_redirect = TRUE;
    xswa.background_pixel  = mw->core.background_pixel;
    xswa.border_pixel      = mw->core.background_pixel;
    xswa.event_mask        = ExposureMask | ButtonMotionMask | 
                            PointerMotionMask | ButtonReleaseMask |
                            ButtonPressMask;
    xswa.cursor            = mw->menu.cursor;
    xswa.colormap          = wx_default_colormap;
    mask                   = (CWSaveUnder | CWOverrideRedirect | CWBackPixel
                           | CWBorderPixel | CWEventMask | CWCursor
                           | CWColormap);

    new->win = XCreateWindow(XtDisplay(mw),
                          RootWindowOfScreen(DefaultScreenOfDisplay(XtDisplay(mw))),
                          new->x, new->y, new->w, new->h, 0,
                          wx_visual_depth, InputOutput, wxAPP_VISUAL,
                          mask, &xswa);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void MenuButtonSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 916 of file xwMenu.c.

{
    MenuTextSize(mw, item, in_menubar, l, m, r, h);
    if (!in_menubar && item->key_binding)
       *r += StringWidth(mw, ResourcedText(mw, item, SUBRESOURCE_KEY)) 
             + (3 * ISPACING);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void MenuCascadeSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 932 of file xwMenu.c.

{
    MenuTextSize(mw, item, in_menubar, l, m, r, h);
    if (!in_menubar)
       *r += mw->menu.indicator_size + ISPACING;
}

Here is the call graph for this function:

static void MenuClassInitialize ( ) [static]

Definition at line 311 of file xwMenu.c.

{
}
static void MenuDestroy ( ) [static]
static void MenuDestroy ( Widget  w) [static]

Definition at line 354 of file xwMenu.c.

{
    MenuWidget  mw  = (MenuWidget)w;
    menu_state  *ms = mw->menu.state,
               *last;

    ReleaseGCs(mw);
    ReleaseShadowGCs(mw);
    while (ms != mw->menu.state) { /* don't destroy the widget's window! */
       XDestroyWindow(XtDisplay(mw), ms->win);
       last = ms;
       ms   = ms->prev;
       FreeTimer(last->timer);
       XtFree((char*)last);
    }
    FreeTimer(ms->timer);
    XtFree((char*)ms); /* free menu_state of widget's window */

    XtCallCallbackList(w, mw->menu.on_destroy, (XtPointer)NULL);
}

Here is the call graph for this function:

static void MenuInitialize ( ) [static]
static void MenuInitialize ( Widget  request,
Widget  new,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 279 of file xwMenu.c.

{
    MenuWidget mw   = (MenuWidget)new;

    CreateGCs(mw);
    CreateShadowGCs(mw);

    if (!mw->menu.indicator_size
       ||  mw->menu.indicator_size > wx_ASCENT(mw->menu.font, mw->menu.xft_font))
      mw->menu.indicator_size = wx_ASCENT(mw->menu.font, mw->menu.xft_font);

    mw->menu.popped_up       = FALSE;
    mw->menu.state           = (menu_state*)XtMalloc(sizeof(menu_state));
    mw->menu.state->menu     = mw->menu.contents;
    mw->menu.state->selected = NULL;
    mw->menu.state->prev     = NULL;
    mw->menu.state->delta    = 0;
    mw->menu.state->scrolled = 0;
    mw->menu.state->timer    = 0;

    mw->menu.moused_out = 0;
    mw->menu.grabbed = FALSE;

    ComputeMenuSize(mw, mw->menu.state);
    mw->core.width  = mw->menu.state->w;
    mw->core.height = mw->menu.state->h;
}

Here is the call graph for this function:

static void MenuPushrightSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 940 of file xwMenu.c.

{
    *l = *m =  *r = *h = 0;
}
static void MenuRealize ( ) [static]
static void MenuRealize ( Widget  w,
Mask *  value_mask,
XSetWindowAttributes *  window_attributes 
) [static]

Definition at line 316 of file xwMenu.c.

{
    MenuWidget mw             = (MenuWidget)w;
    XSetWindowAttributes xswa;

    (*menuWidgetClass->core_class.superclass->core_class.realize)
       (w, value_mask, window_attributes);
    xswa.save_under = TRUE;
    xswa.cursor     = mw->menu.cursor;
    XChangeWindowAttributes(XtDisplay(w), XtWindow(w),
                         CWSaveUnder|CWCursor, &xswa);
    mw->menu.state->win = XtWindow(w);
    mw->menu.state->w   = w->core.width;
    mw->menu.state->h   = w->core.height;
}
static void MenuRedisplay ( ) [static]
static void MenuRedisplay ( Widget  w,
XEvent *  ev,
Region  region 
) [static]

Definition at line 336 of file xwMenu.c.

{
    MenuWidget  mw = (MenuWidget)w;
    menu_state  *ms;

/* MATTHEW: Only translate menu bar.
    for (ms=mw->menu.state; ms->prev; ms=ms->prev);
    XtTranslateCoords(w, w->core.x, w->core.y, &ms->x, &ms->y);
*/

    for (ms=mw->menu.state; ms; ms=ms->prev)
       DisplayMenu(mw, ms);
}

Here is the call graph for this function:

static void MenuResize ( ) [static]
static void MenuResize ( Widget  w) [static]

Definition at line 437 of file xwMenu.c.

{
    MenuWidget  mw = (MenuWidget)w;

    ComputeMenuSize(mw, mw->menu.state);
    mw->menu.state->w = mw->core.width;
    mw->menu.state->h = mw->core.height;
}

Here is the call graph for this function:

static void MenuSeparatorSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 946 of file xwMenu.c.

{
    *l = *m =  *r = *h = 0;
    if (!in_menubar) {
       *h = mw->menu.shadow_width;
       *m = 1;
    }
}
static Boolean MenuSetValues ( ) [static]
static Boolean MenuSetValues ( Widget  gcurrent,
Widget  grequest,
Widget  gnew 
) [static]

Definition at line 382 of file xwMenu.c.

{
    MenuWidget  old = (MenuWidget)gcurrent;
    MenuWidget  new = (MenuWidget)gnew;
    Boolean     redisplay;

    redisplay = (*SuperClass->core_class.set_values)(gcurrent, grequest, gnew, NULL, 0);

    {
      int ow, oh;
      ow = new->menu.state->w;
      oh = new->menu.state->h;
      new->menu.state->menu = new->menu.contents;
      ComputeMenuSize(new, new->menu.state);
      new->menu.state->w = new->core.width;
      new->menu.state->h = new->core.height;
      if ((ow != new->menu.state->w)
         || (oh != new->menu.state->h)) {
       redisplay = TRUE;
      }
    }

    if (new->menu.refresh) {
      new->menu.refresh = 0;
      redisplay = TRUE;
    }

    if (CHANGED_bg_
       || CHANGED(top_shadow_pixel) || CHANGED(top_shadow_contrast)
       || CHANGED(bot_shadow_pixel) || CHANGED(bot_shadow_contrast)) {
       ReleaseShadowGCs(new);
       CreateShadowGCs(new);
       redisplay = TRUE;
    }
    if (CHANGED_bg_
       || CHANGED(foreground) || CHANGED(font)
#ifdef WX_USE_XFT
       || CHANGED(xft_font)
#endif
       || CHANGED(indicator_pixel)  || CHANGED(indicator_contrast)) {
       ReleaseGCs(new);
       CreateGCs(new);
       redisplay = TRUE;
    }

    return redisplay;
}

Here is the call graph for this function:

static void MenuTextSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 902 of file xwMenu.c.

{
  *h = (wx_ASCENT(mw->menu.font, mw->menu.xft_font) 
       + wx_DESCENT(mw->menu.font, mw->menu.xft_font)
       + 2*VMARGIN + 2*mw->menu.shadow_width);
  *l = *r = mw->menu.hmargin + mw->menu.shadow_width;
  if (mw->menu.forChoice) {
    *l += CHOICE_LEFT;
    *r += CHOICE_RIGHT;
  }
  *m = StringWidth(mw, ResourcedText(mw, item, SUBRESOURCE_LABEL));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void MenuToggleSize ( MenuWidget  mw,
menu_item item,
Boolean  in_menubar,
unsigned *  l,
unsigned *  m,
unsigned *  r,
unsigned *  h 
) [static]

Definition at line 925 of file xwMenu.c.

{
    MenuButtonSize(mw, item, in_menubar, l, m, r, h);
    *l += mw->menu.indicator_size + ISPACING;
}

Here is the call graph for this function:

static void Motion ( ) [static]
static void Motion ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 593 of file xwMenu.c.

{
  MenuWidget  mw = (MenuWidget)w;

  if (mw->menu.grabbed)
    Drag(w, event, params, num_params);
}

Here is the call graph for this function:

static void MoveSelection ( MenuWidget  mw,
int  direction 
) [static]

Definition at line 1614 of file xwMenu.c.

{
  menu_state *ms = mw->menu.state;

  if (!ms)
    return;

  if (!ms->selected && ms->prev && ms->prev->prev) {
    /* Submenu popped up, nothing selected. */
    ms = ms->prev;
  }

  if (ms->selected) {
    menu_item  *item = ms->selected;

    do {
      if (direction > 0)
       item = item->next;
      else
       item = item->prev;
    } while (item && ((item->type == MENU_SEPARATOR)
                    || !item->enabled));

    if (!item) {
      /* Wraparound: highlight first/last: */
      if (direction > 0)
       item = ms->menu;
      else {
       item = ms->menu;
       while (item->next)
         item = item->next;
      }

      while (item && ((item->type == MENU_SEPARATOR)
                    || !item->enabled)) {
       if (direction > 0)
         item = item->next;
       else
         item = item->prev;
      }
    }

    if (item) {
      UnhighlightItem(mw, ms, ms->selected);
      HighlightItem(mw, ms, item);
    }
  } else if (direction > 0) {
    menu_item  *item = ms->menu;

    while (item && ((item->type == MENU_SEPARATOR)
                  || !item->enabled))
      item = item->next;

    if (item)
      HighlightItem(mw, ms, item);
  } else {
    menu_item  *item = ms->menu;
    if (item) {
      while (item->next)
       item = item->next;
      while (item && ((item->type == MENU_SEPARATOR)
                    || !item->enabled))
       item = item->prev;
      
      if (item)
       HighlightItem(mw, ms, item);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ReleaseGCs ( MenuWidget  mw) [static]

Definition at line 817 of file xwMenu.c.

{
    XtReleaseGC((Widget)mw, mw->menu.erase_GC);
    XtReleaseGC((Widget)mw, mw->menu.normal_GC);
    XtReleaseGC((Widget)mw, mw->menu.inactive_GC);
    XFreePixmap(XtDisplay(mw), mw->menu.stipple_pxmap);
    Xaw3dReleaseGC(mw, mw->menu.indicator_GC);
    Xaw3dFreePixmap(mw, mw->menu.indicator_pxmap);
    Xaw3dReleaseGC(mw, mw->menu.highlight_GC);
}

Here is the caller graph for this function:

static void ReleaseShadowGCs ( MenuWidget  mw) [static]

Definition at line 828 of file xwMenu.c.

Here is the caller graph for this function:

char* ResourcedText ( MenuWidget  mw,
menu_item item,
Subresource  type 
)

Definition at line 876 of file xwMenu.c.

{
    static XtResource labelResource[] = {
       { "label", "Label", XtRString, sizeof(String), 0, XtRImmediate, 0 },
       { "help",  "Help",  XtRString, sizeof(String), 0, XtRImmediate, 0 },
       { "key",   "Key",   XtRString, sizeof(String), 0, XtRImmediate, 0 },
    };

    char resource_name[1024];
    char *resourced_text=NULL;

    GetResourceName(item->label, resource_name);
    XtGetSubresources((Widget)mw, (XtPointer)(&resourced_text),
                    resource_name, resource_name, &labelResource[type],
                    1, NULL, 0);
    if (!resourced_text)
       switch (type) {
       case SUBRESOURCE_LABEL:  return item->label;
       case SUBRESOURCE_HELP:   return item->help_text;
       case SUBRESOURCE_KEY:    return item->key_binding;
       }
    return (resourced_text);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Select ( ) [static]

Here is the caller graph for this function:

static void Select ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 570 of file xwMenu.c.

{
  MenuWidget  mw = (MenuWidget)w;
  XMotionEvent  *ev   = event ? &event->xmotion : NULL;
  int force;

  mw->menu.moused_out = 0;

  if (!mw->menu.forPopup 
      && (!mw->menu.state || !mw->menu.state->selected))
    return;

  force = !HandleMotionEvent(mw, ev, 0);
  if (!force)
    force = mw->menu.moused_out;
  
  DoSelect(w, event ? event->xmotion.time : 0L, force);
}

Here is the call graph for this function:

static void Start ( ) [static]

Here is the caller graph for this function:

static void Start ( Widget  w,
XEvent *  ev,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 465 of file xwMenu.c.

{
    MenuWidget  mw = (MenuWidget)w;

    XSync(XtDisplay(mw), FALSE);

    if (!mw->menu.state->prev) {
      mw->menu.state->x        = ev->xmotion.x_root - ev->xmotion.x;
      mw->menu.state->y        = ev->xmotion.y_root - ev->xmotion.y;
    }

    if (!mw->menu.grabbed) {
      XtGrabPointer((Widget)mw, FALSE,
                  (ButtonMotionMask | PointerMotionMask |
                   ButtonReleaseMask | ButtonPressMask),
                  GrabModeAsync, GrabModeAsync,
                  None, mw->menu.cursor, 
                  /* ev->xmotion.time */ CurrentTime);
      XtGrabKeyboard((Widget)mw, FALSE,
                   GrabModeAsync, GrabModeAsync,
                   /* ev->xmotion.time */ CurrentTime);
      wxAddGrab((Widget)mw);
      mw->menu.grabbed = TRUE;
    }

    if (!HandleMotionEvent(mw, &ev->xmotion, 1)
        /* *num_params is positive when called to start a popup menu */
        && !*num_params)
      DoSelect(w, CurrentTime, 1);
}

Here is the call graph for this function:

static unsigned StringWidth ( MenuWidget  mw,
char *  s 
) [static]

Definition at line 846 of file xwMenu.c.

{
    return XfwfTextWidth(XtDisplay(mw),
                      mw->menu.font, wxEXT_FONT(mw->menu.xft_font), 
                      s, strlen(s), NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void timer_callback ( XtPointer  client_data,
XtIntervalId *  timer 
) [static]

Definition at line 1478 of file xwMenu.c.

{
  MenuWidget mw = (MenuWidget)client_data;
  XMotionEvent ev;

  XQueryPointer(XtDisplay(mw), XtWindow(mw),
              &ev.root, &ev.subwindow,
              &ev.x_root, &ev.y_root,
              &ev.x, &ev.y, &ev.state);

  HandleMotionEvent(mw, &ev, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void UnhighlightItem ( MenuWidget  mw,
menu_state ms,
menu_item item 
) [static]

Definition at line 1455 of file xwMenu.c.

{
    unsigned   x, y;
    menu_state *state, *last;

    if (!item) /* nothing to unhighlight */
       return;
    ms->selected = NULL;
    ComputeItemPos(mw, ms, item, &x, &y);
    DrawFunctionList[item->type](mw, ms, item, x, y);
    if (((item->type == MENU_CASCADE) || (item->type == MENU_HELP)) && item->enabled) {
       state = mw->menu.state;
       while (state != ms) {
           XDestroyWindow(XtDisplay(mw), state->win);
           last  = state;
           state = state->prev;
           FreeTimer(last->timer);
           XtFree((char*)last);
       }
       mw->menu.state = ms;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wxAddGrab ( Widget  )

Definition at line 44 of file mredx.cxx.

    {
      if (!grab_stack_pos) {
       Widget *naya;
       if (!grab_stack)
         wxREGGLOB(grab_stack);
       grab_stack_size += WSTACK_INC;
       naya = (Widget *)scheme_malloc(grab_stack_size * sizeof(Widget));
       memcpy(naya + WSTACK_INC, grab_stack, (grab_stack_size - WSTACK_INC) * sizeof(Widget));
       grab_stack = naya;
       grab_stack_pos = WSTACK_INC;
      }

      grabber = grab_stack[--grab_stack_pos] = w;
    }

Here is the caller graph for this function:

void wxRemoveGrab ( Widget  )

Definition at line 60 of file mredx.cxx.

    {
      if (w != grabber)
       return;

      if (++grab_stack_pos < grab_stack_size)
       grabber = grab_stack[grab_stack_pos];
      else
       grabber = NULL;
    }

Here is the caller graph for this function:

Definition at line 497 of file AppMain.cc.

{
  if (hilite_border < 0) {
    int on;
    hilite_border = 0;
    if (wxGetBoolPreference("hiliteMenuBorder", &on)) {
      if (on)
       hilite_border = 1;
    }
  }
  return hilite_border;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Xaw3dPopupMenu ( MenuWidget  mw,
Widget  calling_widget 
)

Definition at line 1691 of file xwMenu.c.

{
    XButtonPressedEvent ev;

    /* get position of pointer in calling widget */
    ev.type = ButtonPress;
    ev.serial = 0;
    ev.send_event = 0;
    ev.display = XtDisplay(calling_widget);
    ev.window = XtWindow(calling_widget);
    ev.time = CurrentTime;
    ev.button = 0;
    XQueryPointer(ev.display, ev.window, &ev.root,
                  &ev.subwindow, &ev.x_root, &ev.y_root,
                  &ev.x, &ev.y, &ev.state);
    Xaw3dPopupMenuAtPos(mw, ev.x_root, ev.y_root);
}

Here is the call graph for this function:

void Xaw3dPopupMenuAtPos ( MenuWidget  mw,
int  x,
int  y 
)

Definition at line 1709 of file xwMenu.c.

{
    Screen  *scr         = XtScreen(mw);
    Widget  popup_shell  = XtParent(mw);
    int     border_width = popup_shell->core.border_width;
    int     w, h;
    XMotionEvent ev;

    /* compute size and position of popup menu */
    mw->menu.popped_up = TRUE;
    mw->menu.horizontal = FALSE;
    ComputeMenuSize(mw, mw->menu.state);
    mw->menu.state->delta     = (mw->menu.state->too_tall ? TOO_TALL_SCROLL_HEIGHT : 0);
    mw->menu.state->scrolled  = 0;
    mw->menu.state->scroll_top = mw->menu.state->menu;
    w = mw->menu.state->w;
    h = mw->menu.state->h;
    if (x + w > WidthOfScreen(scr))
       x = WidthOfScreen(scr) - w - 2*border_width;
    if (y + h > HeightOfScreen(scr))
       y = HeightOfScreen(scr) - h - 2*border_width;
    x = (x > border_width ? x - border_width : border_width);
    y = (y > border_width ? y - border_width : border_width);
    XtConfigureWidget(popup_shell, x, y, w, h, border_width);
    /* popup, display and handle menu */
    XtPopup(popup_shell, XtGrabNone);
    DisplayMenu(mw, mw->menu.state);
    mw->menu.state->x = x+border_width;
    mw->menu.state->y = y+border_width;
    /* init first motion event */
    ev.x_root = x; ev.y_root = y;
    HandleMotionEvent(mw, (XMotionEvent*)&ev, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int xwMenuIsPoppedUp ( Widget  w)

Definition at line 1743 of file xwMenu.c.

{
  return ((MenuWidget)w)->menu.grabbed;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:

Definition at line 1254 of file xwMenu.c.

XtActionsRec MenuActionsList[] [static]
Initial value:
 {
    {"start", Start  },
    {"drag",  Drag   },
    {"select",       Select },
    {"motion",       Motion },
    {"key",   Key }
}

Definition at line 173 of file xwMenu.c.

Definition at line 193 of file xwMenu.c.

XtResource MenuResources[] [static]

Definition at line 58 of file xwMenu.c.

char MenuTranslations[] [static]
Initial value:
"<BtnDown>:          start()\n\
<Motion>:             motion()\n\
Button1 <Motion>:    drag()\n\
Button2 <Motion>:    drag()\n\
Button3 <Motion>:    drag()\n\
<BtnUp>:             select()\n\
<KeyPress>:          key()\n\
"

Definition at line 181 of file xwMenu.c.

WidgetClass menuWidgetClass = (WidgetClass) &menuClassRec

Definition at line 235 of file xwMenu.c.

Initial value:

Definition at line 958 of file xwMenu.c.