SimpleMenu.c File Reference

#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xaw3d/XawInit.h>
#include <X11/Xaw3d/SimpleMenP.h>
#include <X11/Xaw3d/SmeBSB.h>
#include <X11/Xaw3d/Cardinals.h>
#include <X11/Xmu/Initer.h>
#include <X11/Xmu/CharSet.h>

Include dependency graph for SimpleMenu.c:

Go to the source code of this file.

Defines

#define streq(a, b)   ( strcmp((a), (b)) == 0 )
#define offset(field)   XtOffsetOf(SimpleMenuRec, simple_menu.field)
#define superclass   (&overrideShellClassRec)
#define ForAllChildren(smw, childP)

Functions

static void Redisplay ()
static void Realize ()
static void Resize ()
static void ChangeManaged ()
static void Initialize ()
static void ClassInitialize ()
static void ClassPartInitialize ()
static Boolean SetValues ()
static Boolean SetValuesHook ()
static XtGeometryResult GeometryManager ()
static void Highlight ()
static void Unhighlight ()
static void Notify ()
static void PositionMenuAction ()
static void MakeSetValuesRequest ()
static void CreateLabel ()
static void Layout ()
static void AddPositionAction ()
static void PositionMenu ()
static void ChangeCursorOnGrab ()
static Dimension GetMenuWidth ()
static Dimension GetMenuHeight ()
static Widget FindMenu ()
static SmeObject GetEventEntry ()
static void MoveMenu ()
static void ClassPartInitialize (WidgetClass wc)
static void Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
static void Redisplay (Widget w, XEvent *event, Region region)
static void Realize (Widget w, XtValueMask *mask, XSetWindowAttributes *attrs)
static void Resize (Widget w)
static Boolean SetValues (Widget current, Widget request, Widget new, ArgList args, Cardinal *num_args)
static Boolean SetValuesHook (Widget w, ArgList arglist, Cardinal *num_args)
static XtGeometryResult GeometryManager (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
static void ChangeManaged (Widget w)
static void PositionMenuAction (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Unhighlight (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Highlight (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void Notify (Widget w, XEvent *event, String *params, Cardinal *num_params)
void XawSimpleMenuAddGlobalActions (XtAppContext app_con)
Widget XawSimpleMenuGetActiveEntry (Widget w)
void XawSimpleMenuClearActiveEntry (Widget w)
static void CreateLabel (Widget w)
static void Layout (Widget w, Dimension *width_ret, Dimension *height_ret)
static void AddPositionAction (XtAppContext app_con, XPointer data)
static Widget FindMenu (Widget widget, String name)
static void PositionMenu (Widget w, XPoint *location)
static void MoveMenu (Widget w, Position x, Position y)
static void ChangeCursorOnGrab (Widget w, XtPointer junk, XtPointer garbage)
static void MakeSetValuesRequest (Widget w, Dimension width, Dimension height)
static Dimension GetMenuWidth (Widget w, Widget w_ent)
static Dimension GetMenuHeight (Widget w)
static SmeObject GetEventEntry (Widget w, XEvent *event)

Variables

static XtResource resources []
static char defaultTranslations []
static XtActionsRec actionsList []
static CompositeClassExtensionRec extension_rec
SimpleMenuClassRec simpleMenuClassRec
WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec


Define Documentation

#define ForAllChildren ( smw,
childP   ) 

Value:

for ( (childP) = (SmeObject *) (smw)->composite.children ; \
        (childP) < (SmeObject *) ( (smw)->composite.children + \
                                 (smw)->composite.num_children ) ; \
        (childP)++ )

Definition at line 195 of file SimpleMenu.c.

#define offset ( field   )     XtOffsetOf(SimpleMenuRec, simple_menu.field)

Definition at line 52 of file SimpleMenu.c.

#define streq ( a,
b   )     ( strcmp((a), (b)) == 0 )

Definition at line 50 of file SimpleMenu.c.

#define superclass   (&overrideShellClassRec)

Definition at line 142 of file SimpleMenu.c.


Function Documentation

static void AddPositionAction ( XtAppContext  app_con,
XPointer  data 
) [static]

Definition at line 970 of file SimpleMenu.c.

References PositionMenuAction().

00973 {
00974     static XtActionsRec pos_action[] = {
00975         { "XawPositionSimpleMenu", PositionMenuAction },
00976     };
00977 
00978     XtAppAddActions(app_con, pos_action, XtNumber(pos_action));
00979 }

Here is the call graph for this function:

static void AddPositionAction (  )  [static]

static void ChangeCursorOnGrab ( Widget  w,
XtPointer  junk,
XtPointer  garbage 
) [static]

Definition at line 1107 of file SimpleMenu.c.

References _SimpleMenuPart::cursor, and _SimpleMenuRec::simple_menu.

01110 {
01111     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01112     
01113     /*
01114      * The event mask here is what is currently in the MIT implementation.
01115      * There really needs to be a way to get the value of the mask out
01116      * of the toolkit (CDP 5/26/89).
01117      */
01118     
01119     XChangeActivePointerGrab(XtDisplay(w), ButtonPressMask|ButtonReleaseMask,
01120                              smw->simple_menu.cursor, 
01121                              XtLastTimestampProcessed(XtDisplay(w)));
01122 }

static void ChangeCursorOnGrab (  ) 

Referenced by Initialize().

Here is the caller graph for this function:

static void ChangeManaged ( Widget  w  )  [static]

Definition at line 582 of file SimpleMenu.c.

References Layout().

00584 {
00585     Layout(w, (Dimension *)NULL, (Dimension *)NULL);
00586 }

Here is the call graph for this function:

static void ChangeManaged (  ) 

static void ClassInitialize (  ) 

Definition at line 573 of file Box.c.

References NULL, XawInitializeWidgetSet(), XmuCvtStringToColorCursor(), XmuCvtStringToOrientation(), XtNpointerColor, XtNpointerColorBackground, and XtRColorCursor.

00574 {
00575     XawInitializeWidgetSet();
00576     XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
00577                     (XtConvertArgList)NULL, (Cardinal)0 );
00578 }

Here is the call graph for this function:

static void ClassPartInitialize ( WidgetClass  wc  )  [static]

Definition at line 231 of file SimpleMenu.c.

References _SimpleMenuClassRec::composite_class.

00233 {
00234     SimpleMenuWidgetClass smwc = (SimpleMenuWidgetClass) wc;
00235 
00236 /*
00237  * Make sure that our subclass gets the extension rec too.
00238  */
00239 
00240     extension_rec.next_extension = smwc->composite_class.extension;
00241     smwc->composite_class.extension = (XtPointer) &extension_rec;
00242 }

static void ClassPartInitialize (  ) 

static void CreateLabel ( Widget  w  )  [static]

Definition at line 837 of file SimpleMenu.c.

References args, _SimpleMenuRec::composite, i, _SimpleMenuPart::label, _SimpleMenuPart::label_class, _SimpleMenuPart::label_string, _SimpleMenuRec::simple_menu, TWO, void(), XtJustifyCenter, and XtNlabel.

00839 {
00840     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00841     Widget * child, * next_child;
00842     int i;
00843     Arg args[2];
00844 
00845     if ( (smw->simple_menu.label_string == NULL) ||
00846          (smw->simple_menu.label != NULL) ) {
00847         char error_buf[BUFSIZ];
00848 
00849         (void) sprintf(error_buf, "Xaw Simple Menu Widget: %s or %s, %s",
00850                 "label string is NULL", "label already exists", 
00851                 "no label is being created.");
00852         XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
00853         return;
00854     }
00855 
00856     XtSetArg(args[0], XtNlabel, smw->simple_menu.label_string);
00857     XtSetArg(args[1], XtNjustify, XtJustifyCenter);
00858     smw->simple_menu.label = (SmeObject) 
00859                               XtCreateManagedWidget("menuLabel", 
00860                                             smw->simple_menu.label_class, w,
00861                                             args, TWO);
00862 
00863     next_child = NULL;
00864     for (child = smw->composite.children + smw->composite.num_children,
00865          i = smw->composite.num_children ; i > 0 ; i--, child--) {
00866         if (next_child != NULL)
00867             *next_child = *child;
00868         next_child = child;
00869     }
00870     *child = (Widget) smw->simple_menu.label;
00871 }

Here is the call graph for this function:

static void CreateLabel (  ) 

Referenced by Initialize(), and SetValues().

Here is the caller graph for this function:

static Widget FindMenu ( Widget  widget,
String  name 
) [static]

Definition at line 989 of file SimpleMenu.c.

00992 {
00993     Widget w, menu;
00994     
00995     for ( w = widget ; w != NULL ; w = XtParent(w) )
00996         if ( (menu = XtNameToWidget(w, name)) != NULL )
00997             return(menu);
00998     return(NULL);
00999 }

static Widget FindMenu (  )  [static]

Referenced by PositionMenuAction().

Here is the caller graph for this function:

static XtGeometryResult GeometryManager ( Widget  w,
XtWidgetGeometry *  request,
XtWidgetGeometry *  reply 
) [static]

Definition at line 512 of file SimpleMenu.c.

References Layout(), mode, and _SmeRec::rectangle.

00515 {
00516     SimpleMenuWidget smw = (SimpleMenuWidget) XtParent(w);
00517     SmeObject entry = (SmeObject) w;
00518     XtGeometryMask mode = request->request_mode;
00519     XtGeometryResult answer;
00520     Dimension old_height, old_width;
00521 
00522     if ( !(mode & CWWidth) && !(mode & CWHeight) )
00523         return(XtGeometryNo);
00524 
00525     reply->width = request->width;
00526     reply->height = request->height;
00527 
00528     old_width = entry->rectangle.width;
00529     old_height = entry->rectangle.height;
00530 
00531     Layout(w, &(reply->width), &(reply->height) );
00532 
00533 /*
00534  * Since we are an override shell and have no parent there is no one to
00535  * ask to see if this geom change is okay, so I am just going to assume
00536  * we can do whatever we want.  If you subclass be very careful with this
00537  * assumption, it could bite you.
00538  *
00539  * Chris D. Peterson - Sept. 1989.
00540  */
00541 
00542     if ( (reply->width == request->width) &&
00543          (reply->height == request->height) ) {
00544 
00545         if ( mode & XtCWQueryOnly ) { /* Actually perform the layout. */
00546             entry->rectangle.width = old_width;
00547             entry->rectangle.height = old_height;       
00548         }
00549         else {
00550             Layout(( Widget) smw, (Dimension *)NULL, (Dimension *)NULL);
00551         }
00552         answer = XtGeometryDone;
00553     }
00554     else {
00555         entry->rectangle.width = old_width;
00556         entry->rectangle.height = old_height;   
00557 
00558         if ( ((reply->width == request->width) && !(mode & CWHeight)) ||
00559               ((reply->height == request->height) && !(mode & CWWidth)) ||
00560               ((reply->width == request->width) && 
00561                (reply->height == request->height)) )
00562             answer = XtGeometryNo;
00563         else {
00564             answer = XtGeometryAlmost;
00565             reply->request_mode = 0;
00566             if (reply->width != request->width)
00567                 reply->request_mode |= CWWidth;
00568             if (reply->height != request->height)
00569                 reply->request_mode |= CWHeight;
00570         }
00571     }
00572     return(answer);
00573 }

Here is the call graph for this function:

static XtGeometryResult GeometryManager (  )  [static]

static SmeObject GetEventEntry ( Widget  w,
XEvent *  event 
) [static]

Definition at line 1232 of file SimpleMenu.c.

References _SimpleMenuRec::core, ForAllChildren, _SimpleMenuPart::label, and _SimpleMenuRec::simple_menu.

01235 {
01236     Position x_loc = 0, y_loc = 0;
01237     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01238     SmeObject * entry;
01239     
01240     switch (event->type) {
01241     case MotionNotify:
01242         x_loc = event->xmotion.x;
01243         y_loc = event->xmotion.y;
01244         break;
01245     case EnterNotify:
01246     case LeaveNotify:
01247         x_loc = event->xcrossing.x;
01248         y_loc = event->xcrossing.y;
01249         break;
01250     case ButtonPress:
01251     case ButtonRelease:
01252         x_loc = event->xbutton.x;
01253         y_loc = event->xbutton.y;
01254         break;
01255     default:
01256         XtAppError(XtWidgetToApplicationContext(w),
01257                    "Unknown event type in GetEventEntry().");
01258         break;
01259     }
01260     
01261     if ( (x_loc < 0) || (x_loc >= (int)smw->core.width) || (y_loc < 0) ||
01262         (y_loc >= (int)smw->core.height) )
01263         return(NULL);
01264     
01265     ForAllChildren(smw, entry) {
01266         if (!XtIsManaged ((Widget) *entry)) continue;
01267 
01268         if ( ((*entry)->rectangle.y < y_loc) &&
01269             ((*entry)->rectangle.y + (int) (*entry)->rectangle.height > y_loc) )
01270             if ( *entry == smw->simple_menu.label )
01271                 return(NULL);   /* cannot select the label. */
01272             else
01273                 return(*entry);
01274     }
01275     
01276     return(NULL);
01277 }

static SmeObject GetEventEntry (  )  [static]

Referenced by Highlight().

Here is the caller graph for this function:

static Dimension GetMenuHeight ( Widget  w  )  [static]

Definition at line 1202 of file SimpleMenu.c.

References _SimpleMenuPart::bottom_margin, _SimpleMenuRec::composite, _SimpleMenuRec::core, ForAllChildren, height, _SimpleMenuPart::menu_height, _SimpleMenuPart::row_height, _SimpleMenuRec::simple_menu, and _SimpleMenuPart::top_margin.

01204 {
01205     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01206     SmeObject * entry;
01207     Dimension height;
01208     
01209     if (smw->simple_menu.menu_height)
01210         return(smw->core.height);
01211 
01212     height = smw->simple_menu.top_margin + smw->simple_menu.bottom_margin;
01213     
01214     if (smw->simple_menu.row_height == 0) {
01215         ForAllChildren(smw, entry) 
01216             if (XtIsManaged ((Widget) *entry)) 
01217                 height += (*entry)->rectangle.height;
01218     } else 
01219         height += smw->simple_menu.row_height * smw->composite.num_children;
01220         
01221     return(height);
01222 }

static Dimension GetMenuHeight (  ) 

Referenced by Initialize().

Here is the caller graph for this function:

static Dimension GetMenuWidth ( Widget  w,
Widget  w_ent 
) [static]

Definition at line 1161 of file SimpleMenu.c.

References _SimpleMenuRec::core, cur_entry, ForAllChildren, _SimpleMenuPart::menu_width, _SimpleMenuRec::simple_menu, and width.

01163 {
01164     SmeObject cur_entry = (SmeObject) w_ent;
01165     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01166     Dimension width, widest = (Dimension) 0;
01167     SmeObject * entry;
01168     
01169     if ( smw->simple_menu.menu_width ) 
01170         return(smw->core.width);
01171 
01172     ForAllChildren(smw, entry) {
01173         XtWidgetGeometry preferred;
01174 
01175         if (!XtIsManaged( (Widget) *entry)) continue;
01176         
01177         if (*entry != cur_entry) {
01178             XtQueryGeometry((Widget) *entry, (XtWidgetGeometry *)NULL, &preferred);
01179             
01180             if (preferred.request_mode & CWWidth)
01181                 width = preferred.width;
01182             else
01183                 width = (*entry)->rectangle.width;
01184         }
01185         else
01186             width = (*entry)->rectangle.width;
01187         
01188         if ( width > widest )
01189             widest = width;
01190     }
01191     
01192     return(widest);
01193 }

static Dimension GetMenuWidth (  )  [static]

Referenced by Initialize(), and Layout().

Here is the caller graph for this function:

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

Definition at line 701 of file SimpleMenu.c.

References _SimpleMenuPart::entry_set, GetEventEntry(), _SimpleMenuRec::simple_menu, and Unhighlight().

00706 {
00707     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00708     SmeObject entry;
00709     SmeObjectClass class;
00710     
00711     if ( !XtIsSensitive(w) ) return;
00712     
00713     entry = GetEventEntry(w, event);
00714 
00715     if (entry == smw->simple_menu.entry_set) return;
00716 
00717     Unhighlight(w, event, params, num_params);  
00718 
00719     if (entry == NULL) return;
00720 
00721     if ( !XtIsSensitive( (Widget) entry)) {
00722         smw->simple_menu.entry_set = NULL;
00723         return;
00724     }
00725 
00726     smw->simple_menu.entry_set = entry;
00727     class = (SmeObjectClass) entry->object.widget_class;
00728 
00729     (class->sme_class.highlight) ( (Widget) entry);
00730 }

Here is the call graph for this function:

static void Highlight (  )  [static]

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

Definition at line 254 of file SimpleMenu.c.

References ChangeCursorOnGrab(), _SimpleMenuRec::core, CreateLabel(), _SimpleMenuPart::entry_set, FALSE, GetMenuHeight(), GetMenuWidth(), _SimpleMenuPart::label, _SimpleMenuPart::label_class, _SimpleMenuPart::label_string, _SimpleMenuPart::menu_height, _SimpleMenuPart::menu_width, _SimpleMenuPart::recursive_set_values, _SimpleMenuRec::simple_menu, smeBSBObjectClass, TRUE, and XmuCallInitializers().

00258 {
00259   SimpleMenuWidget smw = (SimpleMenuWidget) new;
00260 
00261   XmuCallInitializers(XtWidgetToApplicationContext(new));
00262 
00263   if (smw->simple_menu.label_class == NULL) 
00264       smw->simple_menu.label_class = smeBSBObjectClass;
00265 
00266   smw->simple_menu.label = NULL;
00267   smw->simple_menu.entry_set = NULL;
00268   smw->simple_menu.recursive_set_values = FALSE;
00269 
00270   if (smw->simple_menu.label_string != NULL)
00271       CreateLabel(new);
00272 
00273   smw->simple_menu.menu_width = TRUE;
00274 
00275   if (smw->core.width == 0) {
00276       smw->simple_menu.menu_width = FALSE;
00277       smw->core.width = GetMenuWidth(new, (Widget)NULL);
00278   }
00279 
00280   smw->simple_menu.menu_height = TRUE;
00281 
00282   if (smw->core.height == 0) {
00283       smw->simple_menu.menu_height = FALSE;
00284       smw->core.height = GetMenuHeight(new);
00285   }
00286 
00287 /*
00288  * Add a popup_callback routine for changing the cursor.
00289  */
00290   
00291   XtAddCallback(new, XtNpopupCallback, ChangeCursorOnGrab, (XtPointer)NULL);
00292 }

Here is the call graph for this function:

static void Initialize ( void   )  [static]

static void Layout ( Widget  w,
Dimension *  width_ret,
Dimension *  height_ret 
) [static]

Definition at line 891 of file SimpleMenu.c.

References ForAllChildren, GetMenuWidth(), height, MakeSetValuesRequest(), and width.

00894 {
00895     SmeObject current_entry, *entry;
00896     SimpleMenuWidget smw;
00897     Dimension width, height;
00898     Boolean do_layout = ((height_ret == NULL) || (width_ret == NULL));
00899     Boolean allow_change_size;
00900     height = 0;
00901 
00902     if ( XtIsSubclass(w, simpleMenuWidgetClass) ) {
00903         smw = (SimpleMenuWidget) w;
00904         current_entry = NULL;
00905     }
00906     else {
00907         smw = (SimpleMenuWidget) XtParent(w);
00908         current_entry = (SmeObject) w;
00909     }
00910 
00911     allow_change_size = (!XtIsRealized((Widget)smw) ||
00912                          (smw->shell.allow_shell_resize));
00913 
00914     if ( smw->simple_menu.menu_height )
00915         height = smw->core.height;
00916     else
00917         if (do_layout) {
00918             height = smw->simple_menu.top_margin;
00919             ForAllChildren(smw, entry) {
00920                 if (!XtIsManaged( (Widget) *entry)) continue;
00921 
00922                 if ( (smw->simple_menu.row_height != 0) && 
00923                     (*entry != smw->simple_menu.label) ) 
00924                     (*entry)->rectangle.height = smw->simple_menu.row_height;
00925                 
00926                 (*entry)->rectangle.y = height;
00927                 (*entry)->rectangle.x = 0;
00928                 height += (*entry)->rectangle.height;
00929             }
00930             height += smw->simple_menu.bottom_margin;
00931         }
00932         else {
00933             if ((smw->simple_menu.row_height != 0) && 
00934                 (current_entry != smw->simple_menu.label) )
00935                 height = smw->simple_menu.row_height;
00936         }
00937     
00938     if (smw->simple_menu.menu_width)
00939         width = smw->core.width;
00940     else if ( allow_change_size )
00941         width = GetMenuWidth((Widget) smw, (Widget) current_entry);
00942     else
00943         width = smw->core.width;
00944 
00945     if (do_layout) {
00946         ForAllChildren(smw, entry)
00947             if (XtIsManaged( (Widget) *entry)) 
00948                 (*entry)->rectangle.width = width;
00949 
00950         if (allow_change_size)
00951             MakeSetValuesRequest((Widget) smw, width, height);
00952     }
00953     else {
00954         *width_ret = width;
00955         if (height != 0)
00956             *height_ret = height;
00957     }
00958 }

Here is the call graph for this function:

static void Layout (  ) 

static void MakeSetValuesRequest ( Widget  w,
Dimension  width,
Dimension  height 
) [static]

Definition at line 1133 of file SimpleMenu.c.

References _SimpleMenuRec::core, FALSE, _SimpleMenuPart::recursive_set_values, Redisplay(), _SimpleMenuRec::simple_menu, and TRUE.

01136 {
01137     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01138     Arg arglist[2];
01139     Cardinal num_args = (Cardinal) 0;
01140     
01141     if ( !smw->simple_menu.recursive_set_values ) {
01142         if ( (smw->core.width != width) || (smw->core.height != height) ) {
01143             smw->simple_menu.recursive_set_values = TRUE;
01144             XtSetArg(arglist[num_args], XtNwidth, width);   num_args++;
01145             XtSetArg(arglist[num_args], XtNheight, height); num_args++;
01146             XtSetValues(w, arglist, num_args);
01147         }
01148         else if (XtIsRealized( (Widget) smw))
01149             Redisplay((Widget) smw, (XEvent *) NULL, (Region) NULL);
01150     }
01151     smw->simple_menu.recursive_set_values = FALSE;
01152 }

Here is the call graph for this function:

static void MakeSetValuesRequest (  )  [static]

Referenced by Layout(), and SetValuesHook().

Here is the caller graph for this function:

static void MoveMenu ( Widget  w,
Position  x,
Position  y 
) [static]

Definition at line 1063 of file SimpleMenu.c.

References height, _SimpleMenuPart::menu_on_screen, _SimpleMenuRec::simple_menu, and width.

01066 {
01067     Arg arglist[2];
01068     Cardinal num_args = 0;
01069     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01070     
01071     if (smw->simple_menu.menu_on_screen) {
01072         int width = w->core.width + 2 * w->core.border_width;
01073         int height = w->core.height + 2 * w->core.border_width;
01074         
01075         if (x >= 0) {
01076             int scr_width = WidthOfScreen(XtScreen(w));
01077             if (x + width > scr_width)
01078                 x = scr_width - width;
01079         }
01080         if (x < 0) 
01081             x = 0;
01082         
01083         if (y >= 0) {
01084             int scr_height = HeightOfScreen(XtScreen(w));
01085             if (y + height > scr_height)
01086                 y = scr_height - height;
01087         }
01088         if (y < 0)
01089             y = 0;
01090     }
01091     
01092     XtSetArg(arglist[num_args], XtNx, x); num_args++;
01093     XtSetArg(arglist[num_args], XtNy, y); num_args++;
01094     XtSetValues(w, arglist, num_args);
01095 }

static void MoveMenu (  )  [static]

Referenced by PositionMenu().

Here is the caller graph for this function:

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

Definition at line 742 of file SimpleMenu.c.

References _SimpleMenuPart::entry_set, and _SimpleMenuRec::simple_menu.

00747 {
00748     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00749     SmeObject entry = smw->simple_menu.entry_set;
00750     SmeObjectClass class;
00751     
00752     if ( (entry == NULL) || !XtIsSensitive((Widget) entry ) ) return;
00753     
00754     class = (SmeObjectClass) entry->object.widget_class;
00755     (class->sme_class.notify)( (Widget) entry );
00756 }

static void Notify (  ) 

static void PositionMenu ( Widget  w,
XPoint *  location 
) [static]

Definition at line 1009 of file SimpleMenu.c.

References FALSE, _SimpleMenuPart::label, MoveMenu(), _SimpleMenuPart::popup_entry, _SmeRec::rectangle, _SimpleMenuRec::simple_menu, and void().

01012 {
01013     SimpleMenuWidget smw = (SimpleMenuWidget) w;
01014     SmeObject entry;
01015     XPoint t_point;
01016     
01017     if (location == NULL) {
01018         Window junk1, junk2;
01019         int root_x, root_y, junkX, junkY;
01020         unsigned int junkM;
01021         
01022         location = &t_point;
01023         if (XQueryPointer(XtDisplay(w), XtWindow(w), &junk1, &junk2, 
01024                           &root_x, &root_y, &junkX, &junkY, &junkM) == FALSE) {
01025             char error_buf[BUFSIZ];
01026             (void) sprintf(error_buf, "%s %s", "Xaw Simple Menu Widget:",
01027                     "Could not find location of mouse pointer");
01028             XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
01029             return;
01030         }
01031         location->x = (short) root_x;
01032         location->y = (short) root_y;
01033     }
01034     
01035     /*
01036      * The width will not be correct unless it is realized.
01037      */
01038     
01039     XtRealizeWidget(w);
01040     
01041     location->x -= (Position) w->core.width/2;
01042     
01043     if (smw->simple_menu.popup_entry == NULL)
01044         entry = smw->simple_menu.label;
01045     else
01046         entry = smw->simple_menu.popup_entry;
01047 
01048     if (entry != NULL)
01049         location->y -= entry->rectangle.y + entry->rectangle.height/2;
01050 
01051     MoveMenu(w, (Position) location->x, (Position) location->y);
01052 }

Here is the call graph for this function:

static void PositionMenu (  ) 

Referenced by PositionMenuAction().

Here is the caller graph for this function:

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

Definition at line 608 of file SimpleMenu.c.

References FindMenu(), PositionMenu(), and void().

00613 { 
00614   Widget menu;
00615   XPoint loc;
00616 
00617   if (*num_params != 1) {
00618     char error_buf[BUFSIZ];
00619     (void) sprintf(error_buf, "%s %s",
00620             "Xaw - SimpleMenuWidget: position menu action expects only one",
00621             "parameter which is the name of the menu.");
00622     XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
00623     return;
00624   }
00625 
00626   if ( (menu = FindMenu(w, params[0])) == NULL) {
00627     char error_buf[BUFSIZ];
00628     (void) sprintf(error_buf, "%s '%s'",
00629             "Xaw - SimpleMenuWidget: could not find menu named: ", params[0]);
00630     XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
00631     return;
00632   }
00633   
00634   switch (event->type) {
00635   case ButtonPress:
00636   case ButtonRelease:
00637     loc.x = event->xbutton.x_root;
00638     loc.y = event->xbutton.y_root;
00639     PositionMenu(menu, &loc);
00640     break;
00641   case EnterNotify:
00642   case LeaveNotify:
00643     loc.x = event->xcrossing.x_root;
00644     loc.y = event->xcrossing.y_root;
00645     PositionMenu(menu, &loc);
00646     break;
00647   case MotionNotify:
00648     loc.x = event->xmotion.x_root;
00649     loc.y = event->xmotion.y_root;
00650     PositionMenu(menu, &loc);
00651     break;
00652   default:
00653     PositionMenu(menu, (XPoint *)NULL);
00654     break;
00655   }
00656 }  

Here is the call graph for this function:

static void PositionMenuAction (  ) 

Referenced by AddPositionAction().

Here is the caller graph for this function:

static void Realize ( Widget  w,
XtValueMask *  mask,
XSetWindowAttributes *  attrs 
) [static]

Definition at line 350 of file SimpleMenu.c.

References _SimpleMenuPart::backing_store, _SimpleMenuPart::cursor, _SimpleMenuRec::simple_menu, and superclass.

00354 {
00355     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00356 
00357     attrs->cursor = smw->simple_menu.cursor;
00358     *mask |= CWCursor;
00359     if ((smw->simple_menu.backing_store == Always) ||
00360         (smw->simple_menu.backing_store == NotUseful) ||
00361         (smw->simple_menu.backing_store == WhenMapped) ) {
00362         *mask |= CWBackingStore;
00363         attrs->backing_store = smw->simple_menu.backing_store;
00364     }
00365     else
00366         *mask &= ~CWBackingStore;
00367 
00368     (*superclass->core_class.realize) (w, mask, attrs);
00369 }

static void Realize (  ) 

static void Redisplay ( Widget  w,
XEvent *  event,
Region  region 
) [static]

Definition at line 304 of file SimpleMenu.c.

References ForAllChildren.

00308 {
00309     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00310     SmeObject * entry;
00311     SmeObjectClass class;
00312 
00313     if (region == NULL)
00314         XClearWindow(XtDisplay(w), XtWindow(w));
00315 
00316     /*
00317      * Check and Paint each of the entries - including the label.
00318      */
00319 
00320     ForAllChildren(smw, entry) {
00321         if (!XtIsManaged ( (Widget) *entry)) continue;
00322 
00323         if (region != NULL) 
00324             switch(XRectInRegion(region, (int) (*entry)->rectangle.x,
00325                                  (int) (*entry)->rectangle.y,
00326                                  (unsigned int) (*entry)->rectangle.width,
00327                                  (unsigned int) (*entry)->rectangle.height)) {
00328             case RectangleIn:
00329             case RectanglePart:
00330                 break;
00331             default:
00332                 continue;
00333             }
00334         class = (SmeObjectClass) (*entry)->object.widget_class;
00335 
00336         if (class->rect_class.expose != NULL)
00337             (class->rect_class.expose)( (Widget) *entry, NULL, NULL);
00338     }
00339 }

static void Redisplay (  )  [static]

static void Resize ( Widget  w  )  [static]

Definition at line 378 of file SimpleMenu.c.

References _SimpleMenuRec::core, ForAllChildren, and Redisplay().

00380 {
00381     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00382     SmeObject * entry;
00383 
00384     if ( !XtIsRealized(w) ) return;
00385 
00386     ForAllChildren(smw, entry)  /* reset width of all entries. */
00387         if (XtIsManaged( (Widget) *entry))
00388             (*entry)->rectangle.width = smw->core.width;
00389     
00390     Redisplay(w, (XEvent *) NULL, (Region) NULL);
00391 }

Here is the call graph for this function:

static void Resize (  ) 

static Boolean SetValues ( Widget  current,
Widget  request,
Widget  new,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 403 of file SimpleMenu.c.

References _SimpleMenuPart::bottom_margin, _SimpleMenuRec::core, CreateLabel(), _SimpleMenuPart::cursor, FALSE, _SimpleMenuPart::label, _SimpleMenuPart::label_class, _SimpleMenuPart::label_string, Layout(), _SimpleMenuPart::menu_height, _SimpleMenuPart::menu_width, ONE, _SimpleMenuPart::recursive_set_values, _SimpleMenuRec::simple_menu, _SimpleMenuPart::top_margin, TRUE, and XtNlabel.

00407 {
00408     SimpleMenuWidget smw_old = (SimpleMenuWidget) current;
00409     SimpleMenuWidget smw_new = (SimpleMenuWidget) new;
00410     Boolean ret_val = FALSE, layout = FALSE;
00411     
00412     if (!XtIsRealized(current)) return(FALSE);
00413     
00414     if (!smw_new->simple_menu.recursive_set_values) {
00415         if (smw_new->core.width != smw_old->core.width) {
00416             smw_new->simple_menu.menu_width = (smw_new->core.width != 0);
00417             layout = TRUE;
00418         }
00419         if (smw_new->core.height != smw_old->core.height) {
00420             smw_new->simple_menu.menu_height = (smw_new->core.height != 0);
00421             layout = TRUE;
00422         }
00423     }
00424 
00425     if (smw_old->simple_menu.cursor != smw_new->simple_menu.cursor)
00426         XDefineCursor(XtDisplay(new),
00427                       XtWindow(new), smw_new->simple_menu.cursor);
00428     
00429     if (smw_old->simple_menu.label_string !=smw_new->simple_menu.label_string) 
00430         if (smw_new->simple_menu.label_string == NULL)         /* Destroy. */
00431             XtDestroyWidget((Widget) smw_old->simple_menu.label);
00432         else if (smw_old->simple_menu.label_string == NULL)    /* Create. */
00433             CreateLabel(new);
00434         else {                                                 /* Change. */
00435             Arg arglist[1];
00436             
00437             XtSetArg(arglist[0], XtNlabel, smw_new->simple_menu.label_string);
00438             XtSetValues((Widget) smw_new->simple_menu.label, arglist, ONE);
00439         }
00440     
00441     if (smw_old->simple_menu.label_class != smw_new->simple_menu.label_class)
00442         XtAppWarning(XtWidgetToApplicationContext(new),
00443                      "No Dynamic class change of the SimpleMenu Label.");
00444     
00445     if ((smw_old->simple_menu.top_margin != smw_new->simple_menu.top_margin) ||
00446         (smw_old->simple_menu.bottom_margin != 
00447          smw_new->simple_menu.bottom_margin) /* filler.................  */ ) {
00448         layout = TRUE;
00449         ret_val = TRUE;
00450     }
00451 
00452     if (layout)
00453         Layout(new, (Dimension *)NULL, (Dimension *)NULL);
00454 
00455     return(ret_val);
00456 }

Here is the call graph for this function:

static Boolean SetValues (  )  [static]

static Boolean SetValuesHook ( Widget  w,
ArgList  arglist,
Cardinal *  num_args 
) [static]

Definition at line 474 of file SimpleMenu.c.

References FALSE, height, i, MakeSetValuesRequest(), name, streq, value, and width.

00478 {
00479     Cardinal i;
00480     Dimension width, height;
00481     
00482     width = w->core.width;
00483     height = w->core.height;
00484     
00485     for ( i = 0 ; i < *num_args ; i++) {
00486         if ( streq(arglist[i].name, XtNwidth) )
00487             width = (Dimension) arglist[i].value;
00488         if ( streq(arglist[i].name, XtNheight) )
00489             height = (Dimension) arglist[i].value;
00490     }
00491 
00492     if ((width != w->core.width) || (height != w->core.height))
00493         MakeSetValuesRequest(w, width, height);
00494     return(FALSE);
00495 }

Here is the call graph for this function:

static Boolean SetValuesHook (  ) 

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

Definition at line 674 of file SimpleMenu.c.

References _SimpleMenuPart::entry_set, and _SimpleMenuRec::simple_menu.

00679 { 
00680     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00681     SmeObject entry = smw->simple_menu.entry_set;
00682     SmeObjectClass class;
00683  
00684     if ( entry == NULL) return;
00685 
00686     smw->simple_menu.entry_set = NULL;
00687     class = (SmeObjectClass) entry->object.widget_class;
00688     (class->sme_class.unhighlight) ( (Widget) entry);
00689 }

static void Unhighlight (  ) 

void XawSimpleMenuAddGlobalActions ( XtAppContext  app_con  ) 

Definition at line 774 of file SimpleMenu.c.

References XmuCallInitializers().

Referenced by main_sci().

00777 {
00778     XtInitializeWidgetClass(simpleMenuWidgetClass);
00779     XmuCallInitializers( app_con );
00780 } 

Here is the call graph for this function:

Here is the caller graph for this function:

void XawSimpleMenuClearActiveEntry ( Widget  w  ) 

Definition at line 812 of file SimpleMenu.c.

References _SimpleMenuPart::entry_set, and _SimpleMenuRec::simple_menu.

00815 {
00816     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00817 
00818     smw->simple_menu.entry_set = NULL;
00819 } 

Widget XawSimpleMenuGetActiveEntry ( Widget  w  ) 

Definition at line 793 of file SimpleMenu.c.

References _SimpleMenuPart::entry_set, and _SimpleMenuRec::simple_menu.

Referenced by Redisplay().

00796 {
00797     SimpleMenuWidget smw = (SimpleMenuWidget) w;
00798 
00799     return( (Widget) smw->simple_menu.entry_set);
00800 } 

Here is the caller graph for this function:


Variable Documentation

XtActionsRec actionsList[] [static]

Initial value:

{
  {"notify",            Notify},
  {"highlight",         Highlight},
  {"unhighlight",       Unhighlight},
}

Definition at line 127 of file SimpleMenu.c.

char defaultTranslations[] [static]

Initial value:

    ":<EnterWindow>:     highlight()             \n\
     :<LeaveWindow>:     unhighlight()           \n\
     :<BtnMotion>:       highlight()             \n\
     :<BtnUp>:           MenuPopdown() notify() unhighlight()"

Definition at line 95 of file SimpleMenu.c.

CompositeClassExtensionRec extension_rec [static]

Initial value:

 {
      NULL,
         NULLQUARK,
             XtCompositeExtensionVersion,
         sizeof(CompositeClassExtensionRec),
     TRUE,
}

Definition at line 134 of file SimpleMenu.c.

XtResource resources[] [static]

Definition at line 54 of file SimpleMenu.c.

SimpleMenuClassRec simpleMenuClassRec

Definition at line 144 of file SimpleMenu.c.

WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec

Definition at line 193 of file SimpleMenu.c.


Generated on Sun Mar 4 16:01:50 2007 for Scilab [trunk] by  doxygen 1.5.1