Example #1
0
/*----------------------------------------------------------------------*/
/* extern */ Widget
XfeMenuItemPreviousItem(Widget item)
{
	int			position_index;
	Widget		parent;
	Cardinal	num_children;
	Widget		previous = NULL;

    assert( _XfeIsAlive(item) );
    assert( XtIsObject(item) );

	parent = _XfeParent(item);

    assert( XmIsRowColumn(_XfeParent(item)) );

	position_index = XfeMenuItemPositionIndex(item);

	num_children = _XfemNumChildren(parent);

	if (position_index > 0)
	{
		previous = _XfeChildrenIndex(parent,position_index - 1);
	}

	return previous;
}
Example #2
0
File: DrawnB.c Project: att/uwin
static void
Activate(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    XmDrawnButtonCallbackStruct cbs;

    DB_ClickCount(w) = 1;

    DB_Armed(w) = False;

    if (XtIsRealized(w))
	XtClass(w)->core_class.expose(w, event, NULL);

    if (event->xany.type == KeyPress || event->xany.type == KeyRelease ||
	(event->xbutton.x >= 0 && event->xbutton.x < XtWidth(w) &&
	 event->xbutton.y >= 0 && event->xbutton.y < XtHeight(w)))
    {
	cbs.reason = XmCR_ACTIVATE;
	cbs.event = event;
	cbs.window = XtWindow(w);
	cbs.click_count = DB_ClickCount(w);
	if (XmIsRowColumn(XtParent(w)))
	{
	    RC_MenuMenuCallback(w, &cbs);
	}
	if (!Lab_SkipCallback(w) && DB_ActivateCallback(w))
	{
	    XFlush(XtDisplay(w));

	    XtCallCallbackList(w,
			       DB_ActivateCallback(w),
			       (XtPointer)&cbs);
	}
    }
}
Example #3
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemEraseAccent(Widget			item,
					   unsigned char	accent_type,
					   Dimension		offset_left,
					   Dimension		offset_right,
					   Dimension		shadow_thickness,
					   Dimension		accent_thickness)
{
	Widget		pw;
	GC			gc;
	XGCValues	values;
	int			subwindow_mode;

	/* duh */
	if (accent_type == XmACCENT_NONE)
	{
		return;
	}

	assert( _XfeIsAlive(item) );
	assert( XmIsPushButton(item) || XmIsCascadeButton(item) );

	pw = _XfeParent(item);

	assert( XmIsRowColumn(pw) );

	gc = _XfemBackgroundGC(pw);

	/* Remember the old wubwindow mode values */
	XGetGCValues(XtDisplay(item),gc,GCSubwindowMode,&values);

	subwindow_mode = values.subwindow_mode;

	/* Force the subwindow mode to IncludeInferiors */
	XSetSubwindowMode(XtDisplay(item),gc,IncludeInferiors);

	switch(accent_type)
	{
	case XmACCENT_BOTTOM:
		AccentBottom(item,gc,None,offset_left,offset_right,
					 shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_ALL:
		AccentAll(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	case XmACCENT_TOP:
		AccentTop(item,gc,None,offset_left,offset_right,
				  shadow_thickness,accent_thickness,ACCENT_ERASE);
		break;

	default:
		break;
	}

	/* Restore the old subwindow mode */
	XSetSubwindowMode(XtDisplay(item),gc,subwindow_mode);
}
Example #4
0
/*----------------------------------------------------------------------*/
/* extern */ Widget
XfeMenuFindLastMoreMenu(Widget menu,String more_button_name)
{
	Widget more_button;
	Widget submenu;

    assert( _XfeIsAlive(menu) );
    assert( XmIsRowColumn(menu) );
    assert( more_button_name != NULL );

	/* First check if this menu is not full */
	if (!XfeMenuIsFull(menu))
	{
		return menu;
	}

	/* Look for the "More..." button */
	more_button = XfeMenuGetMoreButton(menu,more_button_name);

	/* If no more button is found, then this menu is the last one */
	if (!more_button)
	{
		return menu;
	}

	/* Get the submenu for the more button */
	submenu = XfeCascadeGetSubMenu(more_button);

	assert( _XfeIsAlive(submenu) );

	/* Recurse into the submenu */
	return XfeMenuFindLastMoreMenu(submenu,more_button_name);
}
Example #5
0
/*----------------------------------------------------------------------*/
/* extern */ Widget
XfeMenuItemNextItem(Widget item)
{
	int			position_index;
	Widget		parent;
	Cardinal	num_children;
	Widget		next = NULL;

    assert( _XfeIsAlive(item) );
    assert( XtIsObject(item) );

	parent = _XfeParent(item);

    assert( XmIsRowColumn(_XfeParent(item)) );

	position_index = XfeMenuItemPositionIndex(item);

	num_children = _XfemNumChildren(parent);

	if (position_index < (num_children - 1))
	{
		next = _XfeChildrenIndex(parent,position_index + 1);
	}

	return next;
}
Example #6
0
/*----------------------------------------------------------------------*/
/* extern */ Boolean
XfeMenuIsFull(Widget menu)
{
	Dimension	screen_height;
	Widget		last;

    assert( _XfeIsAlive(menu) );
    assert( XmIsRowColumn(menu) );

	screen_height = XfeScreenHeight(menu);

	last = XfeChildrenGetLast(menu);

	if (!last)
	{
		return False;
	}

	/*
	 * The menu is "full" if its height plus that of a potential new child
	 * are longer than the screen height.  Assume the new child will be
	 * the same height as the last child in the menu.
	 */
	if ((_XfeHeight(menu) + (3 * _XfeHeight(last))) > XfeScreenHeight(menu))
	{
		return True;
	}

	return False;
}
Example #7
0
/*----------------------------------------------------------------------*/
/* extern */ unsigned char
XfeMenuType(Widget menu)
{
    assert( _XfeIsAlive(menu) );
    assert( XmIsRowColumn(menu) );

	return RC_Type(menu);
}
Example #8
0
/*----------------------------------------------------------------------*/
/* extern */ int
XfeMenuItemPositionIndex(Widget item)
{
	XmRowColumnConstraintRec * rccp;

    assert( _XfeIsAlive(item) );
    assert( XmIsRowColumn(_XfeParent(item)) );
    assert( XtIsObject(item) );

	rccp = (XmRowColumnConstraintRec *) (item -> core . constraints);

	return (int) rccp -> row_column . position_index;
}
Example #9
0
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuPositionXY(Widget menu,Position x_root,Position y_root)
{
	XButtonPressedEvent be;

    assert( _XfeIsAlive(menu) );
    assert( XmIsRowColumn(menu) );

	/* In the motif source code, only the x_root and y_root members are used */
	be.x_root = x_root;
	be.y_root = y_root;

	XmMenuPosition(menu,&be);
}
Example #10
0
static void geometry_hook(Widget wid, Widget hooked_widget, XtGeometryHookData call_data) {
    XtWidgetGeometry *request;
    JNIEnv *env;
    struct ChoiceData *cdata;
    struct WidgetInfo *winfo = NULL;

    jobject target;
    jobject parent;
    jint y, height;

    if ((call_data->widget == hooked_widget) &&
        (call_data->type == XtHpostGeometry) &&
        (call_data->result == XtGeometryYes)) {

        request = call_data->request;

        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
        DASSERT(env != NULL);

        winfo=findWidgetInfo(hooked_widget);

        if (winfo != NULL && XmIsRowColumn(hooked_widget)) {
            target = (*env)->GetObjectField(env, (jobject)winfo->peer, mComponentPeerIDs.target);
            cdata = (struct ChoiceData *) JNU_GetLongFieldAsPtr(env, (jobject)winfo->peer, mComponentPeerIDs.pData);
            DASSERT(target != NULL);
            DASSERT(cdata != NULL && cdata->comp.widget != NULL)
            if (request->request_mode & CWHeight) {
                height = (*env)->GetIntField(env, target, componentIDs.height);
                if (request->height > 0 && request->height != height) {
                  parent = (*env)->CallObjectMethod(env, target, componentIDs.getParent);
                  if ((parent != NULL) && ((*env)->GetObjectField(env, parent, containerIDs.layoutMgr) != NULL)) {
                      y = cdata->bounds_y;
                      if (request->height < cdata->bounds_height) {
                          y += (cdata->bounds_height - request->height) / 2;
                      }
                      XtVaSetValues(hooked_widget, XmNy, y, NULL);
                      (*env)->SetIntField(env, target, componentIDs.y, y);
                  }
                  if (parent != NULL) {
                      (*env)->DeleteLocalRef(env, parent);
                  }
                }
                (*env)->SetIntField(env, target, componentIDs.height, request->height);
            }
            if (request->request_mode & CWWidth) {
                (*env)->SetIntField(env, target, componentIDs.width, request->width);
            }
            (*env)->DeleteLocalRef(env, target);
        }
Example #11
0
/*----------------------------------------------------------------------*/
/* extern */ Widget
XfeMenuItemAtPosition(Widget menu,int position)
{
	Widget item = NULL;
#if 0
	XmRowColumnConstraintRec * rccp;

    assert( _XfeIsAlive(item) );
    assert( XmIsRowColumn(_XfeParent(item)) );

	rccp = (XmRowColumnConstraintRec *) (item -> core . constraints);

	return (int) rccp -> row_column . position_index;
#endif

	return item;
}
Example #12
0
/*----------------------------------------------------------------------*
 *
 * Traverse a menu hierarchy 
 *
 *
 *																	
 *----------------------------------------------------------------------*/
/* extern */ Widget
XfeMenuGetMoreButton(Widget menu,String more_button_name)
{
	Widget last;

    assert( _XfeIsAlive(menu) );
    assert( XmIsRowColumn(menu) );
    assert( more_button_name != NULL );

	last = XfeChildrenGetLast(menu);

	if (_XfeIsAlive(last) && 
		(XmIsCascadeButton(last) || XmIsCascadeButtonGadget(last)) &&
		(strcmp(XtName(last),more_button_name) == 0))
	{
		return last;
	}

	return NULL;
}
Example #13
0
/*----------------------------------------------------------------------*/
static void
Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
{
    XfeBmButtonPart *		bmp = _XfeBmButtonPart(nw);
	XmLabelPart *			lp = _XfeXmLabelPart(nw);

	assert( XmIsRowColumn(XtParent(nw)) );

	/* Force the type to be string always */
	lp->label_type = XmSTRING;

	bmp->pixmap_GC = XfeAllocateTransparentGc(nw);

	_XfePixmapPrepare(nw,
					  &lp->pixmap,
					  &bmp->pixmap_width,
					  &bmp->pixmap_height,
					  XmNlabelPixmap);

	XfeOverrideTranslations(nw,_XfeBmButtonExtraTranslations);
}
Example #14
0
/*----------------------------------------------------------------------*/
/* extern */ Boolean
XfeMenuIsOptionMenu(Widget menu)
{
	return (XmIsRowColumn(menu) && (RC_Type(menu) == XmMENU_OPTION));
}
Example #15
0
boolean MotifUI::SetOrder(int new_position)
{
   if (XmIsRowColumn(((MotifUI *)Parent())->InnerWidget()))
       XtVaSetValues(BaseWidget(), XmNpositionIndex, new_position, NULL);
   return true;
}