#endif
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* SimpleMenu.c - Source code file for SimpleMenu widget.
*
* Date: April 3, 1989
*
* By: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*/
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <./Xaw3_1XawInit.h>
#include <./Xaw3_1SimpleMenP.h>
#include <./Xaw3_1SmeBSB.h>
#include <./Xaw3_1Cardinals.h>
/*
* Label Resources.
*/
/*
* Layout Resources.
*/
/*
* Misc. Resources
*/
};
static char defaultTranslations[] =
"<EnterWindow>: highlight() \n\
<LeaveWindow>: unhighlight() \n\
<BtnMotion>: highlight() \n\
<BtnUp>: MenuPopdown() notify() unhighlight()";
/*
* Semi Public function definitions.
*/
static XtGeometryResult GeometryManager();
/*
* Action Routine Definitions
*/
/*
* Private Function Definitions.
*/
static SmeObject GetEventEntry();
{
{"notify", Notify},
{"highlight", Highlight},
{"unhighlight", Unhighlight},
};
/* next_extension */ NULL,
/* record_type */ NULLQUARK,
/* version */ XtCompositeExtensionVersion,
/* record_size */ sizeof(CompositeClassExtensionRec),
/* accepts_objects */ TRUE,
};
{
/* class_name */ "SimpleMenu",
/* size */ sizeof(SimpleMenuRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize*/ ClassPartInitialize,
/* Class init'ed */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ Realize,
/* actions */ actionsList,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave*/ TRUE,
/* visible_interest */ FALSE,
/* destroy */ NULL,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ SetValuesHook,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* intrinsics version */ XtVersion,
/* callback offsets */ NULL,
/* tm_table */ defaultTranslations,
/* query_geometry */ NULL,
/* display_accelerator*/ NULL,
/* extension */ NULL
},{
/* geometry_manager */ GeometryManager,
/* change_managed */ ChangeManaged,
/* insert_child */ XtInheritInsertChild,
/* delete_child */ XtInheritDeleteChild,
/* extension */ NULL
},{
/* Shell extension */ NULL
},{
/* Override extension */ NULL
},{
/* Simple Menu extension*/ NULL
}
};
/************************************************************
*
* Semi-Public Functions.
*
************************************************************/
/* Function Name: ClassInitialize
* Description: Class Initialize routine, called only once.
* Arguments: none.
* Returns: none.
*/
static void
{
NULL, 0 );
}
/* Function Name: ClassInitialize
* Description: Class Part Initialize routine, called for every
* subclass. Makes sure that the subclasses pick up
* the extension record.
* Arguments: wc - the widget class of the subclass.
* Returns: none.
*/
static void
{
/*
* Make sure that our subclass gets the extension rec too.
*/
}
/* Function Name: Initialize
* Description: Initializes the simple menu widget
* Arguments: request - the widget requested by the argument list.
* new - the new widget with both resource and non
* resource values.
* Returns: none.
*/
/* ARGSUSED */
static void
{
}
}
/*
* Add a popup_callback routine for changing the cursor.
*/
}
/* Function Name: Redisplay
* Description: Redisplays the contents of the widget.
* Arguments: w - the simple menu widget.
* event - the X event that caused this redisplay.
* region - the region the needs to be repainted.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
{
/*
* Check and Paint each of the entries - including the label.
*/
case RectangleIn:
case RectanglePart:
break;
default:
continue;
}
}
}
/* Function Name: Realize
* Description: Realizes the widget.
* Arguments: w - the simple menu widget.
* mask - value mask for the window to create.
* attrs - attributes for the window to create.
* Returns: none
*/
static void
Widget w;
XtValueMask * mask;
{
*mask |= CWBackingStore;
}
else
*mask &= ~CWBackingStore;
}
/* Function Name: Resize
* Description: Handle the menu being resized bigger.
* Arguments: w - the simple menu widget.
* Returns: none.
*/
static void
Resize(w)
Widget w;
{
if ( !XtIsRealized(w) ) return;
}
/* Function Name: SetValues
* Description: Relayout the menu when one of the resources is changed.
* Arguments: current - current state of the widget.
* request - what was requested.
* new - what the widget will become.
* Returns: none
*/
/* ARGSUSED */
static Boolean
{
}
}
}
else { /* Change. */
}
"No Dynamic class change of the SimpleMenu Label.");
}
if (layout)
return(ret_val);
}
/* Function Name: SetValuesHook
* Description: To handle a special case, this is passed the
* actual arguments.
* Arguments: w - the menu widget.
* arglist - the argument list passed to XtSetValues.
* num_args - the number of args.
* Returns: none
*/
/*
* If the user actually passed a width and height to the widget
* then this MUST be used, rather than our newly calculated width and
* height.
*/
static Boolean
Widget w;
{
register Cardinal i;
for ( i = 0 ; i < *num_args ; i++) {
}
return(FALSE);
}
/************************************************************
*
* Geometry Management routines.
*
************************************************************/
/* Function Name: GeometryManager
* Description: This is the SimpleMenu Widget's Geometry Manager.
* Arguments: w - the Menu Entry making the request.
* request - requested new geometry.
* reply - the allowed geometry.
* Returns: XtGeometry{Yes, No, Almost}.
*/
static XtGeometryResult
Widget w;
{
return(XtGeometryNo);
/*
* Since we are an override shell and have no parent there is no one to
* ask to see if this geom change is okay, so I am just going to assume
* we can do whatever we want. If you subclass be very careful with this
* assumption, it could bite you.
*
* Chris D. Peterson - Sept. 1989.
*/
}
else {
}
}
else {
else {
reply->request_mode = 0;
}
}
return(answer);
}
/* Function Name: ChangeManaged
* Description: called whenever a new child is managed.
* Arguments: w - the simple menu widget.
* Returns: none.
*/
static void
Widget w;
{
}
/************************************************************
*
* Global Action Routines.
*
* These actions routines will be added to the application's
* global action list.
*
************************************************************/
/* Function Name: PositionMenuAction
* Description: Positions the simple menu widget.
* Arguments: w - a widget (no the simple menu widget.)
* event - the event that caused this action.
* params, num_params - parameters passed to the routine.
* we expect the name of the menu here.
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
if (*num_params != 1) {
"Xaw - SimpleMenuWidget: position menu action expects only one",
"parameter which is the name of the menu.");
return;
}
"Xaw - SimpleMenuWidget: could not find menu named: ", params[0]);
return;
}
case ButtonPress:
case ButtonRelease:
break;
case EnterNotify:
case LeaveNotify:
break;
case MotionNotify:
break;
default:
break;
}
}
/************************************************************
*
* Widget Action Routines.
*
************************************************************/
/* Function Name: Unhighlight
* Description: Unhighlights current entry.
* Arguments: w - the simple menu widget.
* event - the event that caused this action.
* params, num_params - ** NOT USED **
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
}
/* Function Name: Highlight
* Description: Highlights current entry.
* Arguments: w - the simple menu widget.
* event - the event that caused this action.
* params, num_params - ** NOT USED **
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
if ( !XtIsSensitive(w) ) return;
return;
}
}
/* Function Name: Notify
* Description: Notify user of current entry.
* Arguments: w - the simple menu widget.
* event - the event that caused this action.
* params, num_params - ** NOT USED **
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
}
/************************************************************
*
* Public Functions.
*
************************************************************/
/* Function Name: XawSimpleMenuAddGlobalActions
* Description: adds the global actions to the simple menu widget.
* Arguments: app_con - the appcontext.
* Returns: none.
*/
void
{
}
/* Function Name: XawSimpleMenuGetActiveEntry
* Description: Gets the currently active (set) entry.
* Arguments: w - the smw widget.
* Returns: the currently set entry or NULL if none is set.
*/
Widget w;
{
}
/* Function Name: XawSimpleMenuClearActiveEntry
* Description: Unsets the currently active (set) entry.
* Arguments: w - the smw widget.
* Returns: none.
*/
void
Widget w;
{
}
/************************************************************
*
* Private Functions.
*
************************************************************/
/* Function Name: CreateLabel
* Description: Creates a the menu label.
* Arguments: w - the smw widget.
* Returns: none.
*
* Creates the label object and makes sure it is the first child in
* in the list.
*/
static void
CreateLabel(w)
Widget w;
{
register int i;
"label string is NULL", "label already exists",
"no label is being created.");
return;
}
XtCreateManagedWidget("menuLabel",
next_child = NULL;
if (next_child != NULL)
*next_child = *child;
next_child = child;
}
}
/* Function Name: Layout
* Description: lays the menu entries out all nice and neat.
* Arguments: w - See below (+++)
* width_ret, height_ret - The returned width and
* height values.
* Returns: none.
*
* if width == NULL || height == NULL then it assumes the you do not care
* about the return values, and just want a relayout.
*
* if this is not the case then it will set width_ret and height_ret
* to be width and height that the child would get if it were layed out
* at this time.
*
* +++ "w" can be the simple menu widget or any of its object children.
*/
static void
Widget w;
{
height = 0;
if ( XtIsSubclass(w, simpleMenuWidgetClass) ) {
smw = (SimpleMenuWidget) w;
}
else {
current_entry = (SmeObject) w;
}
else
if (do_layout) {
}
}
else {
}
else if ( allow_change_size )
else
if (do_layout) {
if (allow_change_size)
}
else {
if (height != 0)
*height_ret = height;
}
}
/* Function Name: AddPositionAction
* Description: Adds the XawPositionSimpleMenu action to the global
* action list for this appcon.
* Arguments: app_con - the application context for this app.
* data - NOT USED.
* Returns: none.
*/
/* ARGSUSED */
static void
{
{ "XawPositionSimpleMenu", PositionMenuAction },
};
}
/* Function Name: FindMenu
* Description: Find the menu give a name and reference widget.
* Arguments: widget - reference widget.
* name - the menu widget's name.
* Returns: the menu widget or NULL.
*/
static Widget
{
return(menu);
return(NULL);
}
/* Function Name: PositionMenu
* Description: Places the menu
* Arguments: w - the simple menu widget.
* location - a pointer the the position or NULL.
* Returns: none.
*/
static void
Widget w;
{
static void MoveMenu();
unsigned int junkM;
"Could not find location of mouse pointer");
return;
}
}
/*
* The width will not be correct unless it is realized.
*/
XtRealizeWidget(w);
else
}
/* Function Name: MoveMenu
* Description: Actually moves the menu, may force it to
* to be fully visable if menu_on_screen is TRUE.
* Arguments: w - the simple menu widget.
* x, y - the current location of the widget.
* Returns: none
*/
static void
MoveMenu(w, x, y)
Widget w;
Position x, y;
{
if (x < 0)
x = 0;
else {
}
if (y < 0)
y = 0;
else {
if (y + height > scr_height)
y = scr_height - height;
}
}
}
/* Function Name: ChangeCursorOnGrab
* Description: Changes the cursor on the active grab to the one
* specified in out resource list.
* Arguments: w - the widget.
* junk, garbage - ** NOT USED **.
* Returns: None.
*/
/* ARGSUSED */
static void
Widget w;
{
/*
* The event mask here is what is currently in the MIT implementation.
* There really needs to be a way to get the value of the mask out
* of the toolkit (CDP 5/26/89).
*/
}
/* Function Name: MakeSetValuesRequest
* Description: Makes a (possibly recursive) call to SetValues,
* I take great pains to not go into an infinite loop.
* Arguments: w - the simple menu widget.
* width, height - the size of the ask for.
* Returns: none
*/
static void
Widget w;
{
}
}
}
/* Function Name: GetMenuWidth
* Description: Sets the length of the widest entry in pixels.
* Arguments: w - the simple menu widget.
* Returns: width of menu.
*/
static Dimension
{
else
}
else
}
return(widest);
}
/* Function Name: GetMenuHeight
* Description: Sets the length of the widest entry in pixels.
* Arguments: w - the simple menu widget.
* Returns: width of menu.
*/
static Dimension
Widget w;
{
else
return(height);
}
/* Function Name: GetEventEntry
* Description: Gets an entry given an event that has X and Y coords.
* Arguments: w - the simple menu widget.
* event - the event.
* Returns: the entry that this point is in.
*/
static SmeObject
Widget w;
{
case MotionNotify:
break;
case EnterNotify:
case LeaveNotify:
break;
case ButtonPress:
case ButtonRelease:
break;
default:
"Unknown event type in GetEventEntry().");
break;
}
return(NULL);
return(NULL); /* cannot select the label. */
else
return(*entry);
}
return(NULL);
}