/*----------------------------------------------------------------------*/ /* 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; }
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); } } }
/*----------------------------------------------------------------------*/ /* 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); }
/*----------------------------------------------------------------------*/ /* 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); }
/*----------------------------------------------------------------------*/ /* 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; }
/*----------------------------------------------------------------------*/ /* 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; }
/*----------------------------------------------------------------------*/ /* extern */ unsigned char XfeMenuType(Widget menu) { assert( _XfeIsAlive(menu) ); assert( XmIsRowColumn(menu) ); return RC_Type(menu); }
/*----------------------------------------------------------------------*/ /* 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; }
/*----------------------------------------------------------------------*/ /* 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); }
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); }
/*----------------------------------------------------------------------*/ /* 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; }
/*----------------------------------------------------------------------* * * 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; }
/*----------------------------------------------------------------------*/ 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); }
/*----------------------------------------------------------------------*/ /* extern */ Boolean XfeMenuIsOptionMenu(Widget menu) { return (XmIsRowColumn(menu) && (RC_Type(menu) == XmMENU_OPTION)); }
boolean MotifUI::SetOrder(int new_position) { if (XmIsRowColumn(((MotifUI *)Parent())->InnerWidget())) XtVaSetValues(BaseWidget(), XmNpositionIndex, new_position, NULL); return true; }