Exemplo n.º 1
0
Widget
XtNativePopupMenu::build(
  Widget parent)
{
  MenuRecord * root = this->getMenuRecord(0);
  assert(root != NULL);

#if SOXT_POPUPMENU_DEBUG
  setbuf(stderr, NULL);
  fprintf(stderr, "building popup menu\n");
#endif // SOXT_POPUPMENU_DEBUG

  Display * dpy = SoXt::getDisplay();
  const int screen = DefaultScreen(dpy);
  Visual * visual = DefaultVisual(dpy, screen);
  Colormap colormap = DefaultColormap(dpy, screen);
  int depth = DefaultDepth(dpy, screen);

  Arg args[10];
  int argc = 0;
  XtSetArg(args[argc], XmNvisual, visual); argc++;
  XtSetArg(args[argc], XmNdepth, depth); argc++;
  XtSetArg(args[argc], XmNcolormap, colormap); argc++;
  Widget popup = XmCreatePopupMenu(parent, root->name, args, argc);

#if SOXT_POPUPMENU_DEBUG
  fprintf(stderr, "%s {\n", root->name);
#endif // SOXT_POPUPMENU_DEBUG
  (void) this->traverseBuild(popup, root, 2);
#if SOXT_POPUPMENU_DEBUG
  fprintf(stderr, "}\n");
#endif // SOXT_POPUPMENU_DEBUG
  return popup;
} // build()
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel, drawingArea, button, m;

  toplevel = XtVaAppInitialize(&theApp, "drawingArea", NULL, 0,
			       &argc, argv, NULL, NULL);

  drawingArea= XtVaCreateManagedWidget("drawingArea", xmDrawingAreaWidgetClass, toplevel,
	NULL);

  m = XmCreatePopupMenu(drawingArea, "popup", NULL, 0);
  
  button = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, m,
	NULL);

  XtAddCallback(drawingArea, XmNinputCallback, incb, (XtPointer)m);
  XtAddCallback(button, XmNactivateCallback, print, NULL);

  XtRealizeWidget(toplevel);
  
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,  506,  322,    1,    1, 0,0,0, /* drawingArea */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}

  LessTifTestMainLoop(toplevel);

  exit(0);
}
Exemplo n.º 3
0
MenuBar::MenuBar ( Widget parent, char *name, unsigned char type ) 
: UIComponent ( name )
{
    // Base widget is a Motif menu bar widget
    
    if(parent == NULL)
	return;

    if( type == XmMENU_POPUP) {
	Arg args[1];
	int i = 0;

	XtSetArg(args[i], XmNwhichButton, theApplication->bMenuButton()); i++;
    	_w = XmCreatePopupMenu( parent, _name, args, i );
//        XtVaSetValues(_w, XmNwhichButton, theApplication->bMenuButton(), NULL);
    } else {
	type = XmMENU_BAR; // Force it to menu bar
    	_w = XmCreateMenuBar ( parent, _name, NULL, 0 );
    }

    printHelpId("_w", _w);
    /* install callback */
    // XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
    
    installDestroyHandler();
}
Exemplo n.º 4
0
//
//  Modifies the popupmenu.
//
int WFoeMotif::modify_popup( unsigned long popupmenu_mask, int x, int y)
{
  static char buttontext[][40] = { "ObjectEditor", "SubWindow", "Connect", "Delete",
				   "Paste", "Copy", "Cut", "PrintSelect", "HelpClass"};
  static XtCallbackProc callback[] = { (void (*)(Widget,void *,void*))activate_attribute,
				       (void (*)(Widget,void *,void*))activate_subwindow,
				       (void (*)(Widget,void *,void*))activate_getobj,
				       (void (*)(Widget,void *,void*))activate_delete,
				       (void (*)(Widget,void *,void*))activate_paste,
				       (void (*)(Widget,void *,void*))activate_copy,
				       (void (*)(Widget,void *,void*))activate_cut,
				       (void (*)(Widget,void *,void*))activate_printselect,
				       (void (*)(Widget,void *,void*))activate_helpclass};

  Widget Menu, w;
  XEvent event;
  int i;
  Arg ArgList[5]; 
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  popupmenu_mask = popupmenu_mask;

  event.xbutton.x_root = x + 5;
  event.xbutton.y_root = y;
  event.xbutton.x = 0;
  event.xbutton.y = 0;

  // Set default fontlist
  font = XLoadQueryFont( flow_Display( widgets.pane),
			 "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i = 0;
  XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
  Menu = XmCreatePopupMenu( widgets.pane, (char*) "_popup", ArgList, i);  
  XtAddCallback( Menu, XmNunmapCallback, 
		 (XtCallbackProc)popup_unmap_cb, this);

  XmFontListFree( fontlist);

  for ( i = 0; i < 9; i++) {
    if ( popupmenu_mask & (1 << i)) {
      w = XtVaCreateManagedWidget( buttontext[i], xmPushButtonGadgetClass, 
			       Menu, NULL);

      XtAddCallback( w, XmNactivateCallback, (XtCallbackProc) callback[i], 
		    (XtPointer) this);
    }
  }
  widgets.popupmenu = Menu;
  XmMenuPosition( widgets.popupmenu, &event.xbutton);
  XtManageChild( widgets.popupmenu);
  return FOE__SUCCESS ;
}
Exemplo n.º 5
0
int
main(int argc,
     char **argv)
{
  String menuPost = NULL;

  toplevel = XtAppInitialize(&theApp,
			     "test12",
			     NULL, 0,
			     &argc, argv,
			     NULL, NULL, 0);

  label = XtVaCreateManagedWidget("label",
				  xmLabelWidgetClass,
				  toplevel,
				  NULL);

  XtAddEventHandler(label, ButtonPressMask, False,
		    buttonPressEventHandler, NULL);

  popup = XmCreatePopupMenu(label,
			    "popup",
			    NULL, 0);

  XtVaSetValues(popup, XmNwhichButton, 3, NULL);

  button1 = XtVaCreateManagedWidget("button1",
				    xmPushButtonWidgetClass,
				    popup,
				    NULL);

  button2 = XtVaCreateManagedWidget("button2",
				    xmPushButtonWidgetClass,
				    popup,
				    NULL);

  XtRealizeWidget(toplevel);

  {
    static XtWidgetGeometry Expected[] = {
      CWWidth | CWHeight            ,   57,   73,   34,   17, 0,0,0, /* label */
    };
    /* toplevel should be replaced with to correct applicationShell */
    PrintDetails(toplevel, Expected);
  }
  LessTifTestMainLoop(toplevel);

  exit(0);
}
Exemplo n.º 6
0
Arquivo: Menu.C Projeto: juddy/edcde
void Menu::CreateMenu(Widget parent, char *name, char * /*category*/,
		      char *mnemonic, MenuType menu_type)
{
   XmString xm_string = StringCreate(name);

   _title = NULL;
   _sep = NULL;
   switch (_menu_type = menu_type)
   {
   case PULLDOWN_MENU:
      _w = XmCreatePulldownMenu(parent, "pulldown_menu", NULL, 0);
      break;
   case OPTION_MENU:
      _w = XmCreateOptionMenu(parent, "option_menu", NULL, 0);
      break;
   case POPUP_MENU:
      _w = XmCreatePopupMenu(parent, "popup_menu", NULL, 0);
      XtVaSetValues(_w, XmNwhichButton, MotifUI::bMenuButton, NULL);
      break;
   }
   if (_menu_type != POPUP_MENU)
    {
      _cascadeButton = XtVaCreateManagedWidget("cascadeButton",
					       xmCascadeButtonWidgetClass,
					       parent,
					       XmNlabelString, xm_string,
					       XmNsubMenuId, _w, NULL);
      if (depth == 1)
       {
	 Pixel bg;
	 XtVaGetValues(_cascadeButton, XmNbackground, &bg, NULL);
	 if (bg == white)
	  {
	    XtVaSetValues(_w, XmNuserData, (XtPointer)this, NULL);
	    XtAddCallback(_w, XmNmapCallback, &(Menu::MapCB), NULL);
	    XtAddCallback(_w, XmNunmapCallback, &(Menu::MapCB), NULL);
	  }
       }
    }
   StringFree(xm_string);
   if (mnemonic)
      XtVaSetValues(_cascadeButton,
		    XmNmnemonic, XStringToKeysym(mnemonic), NULL);
   InstallHelpCB();
}
Exemplo n.º 7
0
Arquivo: motif.c Projeto: E-LLP/QuIP
void make_menu(QSP_ARG_DECL  Screen_Obj *sop, Screen_Obj *mip)
{
#ifdef HAVE_MOTIF
	Arg al[10];
	int ac = 0;
	Widget post_button;
	char buf[8];

	sop->so_frame = generic_frame(curr_panel->po_panel_obj,
		sop, XmSHADOW_OUT);

	strcpy(buf,"Popup");	/* all this to elim a compiler warning */

#ifdef FOOBAR
	if(popups_supported)
	{
		/* XmCreatePopupMenu works on SGI and X, but not with
		OPENWIN */
		sop->so_obj = XmCreatePopupMenu(sop->so_frame,
			buf, al, ac);
		XtAddEventHandler(sop->so_frame,
			ButtonPressMask, FALSE,
			(XtEventHandler) post_menu_handler,
			(XtPointer)  sop->so_obj);
	}
	else
#endif /* FOOBAR */
	{
		dialog_y = 1;
		sop->so_obj = XmCreateBulletinBoardDialog(sop->so_frame,
			buf, al, ac);
		XtSetArg(al[ac], XmNuserData, sop); ac++;
		/* BUG?  should this be so_action_text??? */
		post_button = XmCreatePushButton(sop->so_frame,
			(char *)sop->so_action_text, al, ac);
		XtManageChild(post_button);
		XtAddCallback(post_button, XmNactivateCallback, post_func, NULL);
	}
#endif /* HAVE_MOTIF */
}
Exemplo n.º 8
0
Widget 
XmCreateSimplePopupMenu(
        Widget parent,
        String name,
        ArgList args,
        Cardinal arg_count )
{
	Widget rc;
	XmSimpleMenuRec mr;
	_XmWidgetToAppContext(parent);

	_XmAppLock(app);

	XtGetSubresources(parent, &mr, name, XmCSimplePopupMenu,
		SimpleMenuResources, XtNumber(SimpleMenuResources), 
		args, arg_count);

	rc = XmCreatePopupMenu(parent, name, args, arg_count);

	EvaluateConvenienceStructure( rc, &mr);

	_XmAppUnlock(app);
	return(rc);
}
Exemplo n.º 9
0
int main(int argc, char **argv)
{
    register int  n;
    Arg args[MAX_ARGS];
    XmString tcs;
    void PostPopup();
    void ButtonCB();

    CommonTestInit(argc, argv);
    
    n = 0;
    XtSetArg(args[n], XmNwidth,  200);  n++;
    XtSetArg(args[n], XmNheight, 40);   n++;
    XtSetValues(Shell1, args, n);

    XtRealizeWidget(Shell1);

    Label = CreateLabel("Press MB3 to dismiss PopupMenu", Shell1);

    /*
    **  PopupMenu1
    */

    n = 0;
    XtSetArg(args[n], XmNx,  100);  n++;
    XtSetArg(args[n], XmNy, 100);   n++;
    XtSetArg(args[n], XmNmenuAccelerator, NULL); n++;
    PopupMenu1 = XmCreatePopupMenu(Label, "popupMenu", args, n);

    /*
    **  Menu1
    */

    Label1 = CreateLabel("Menu1", PopupMenu1);
    Separator1 = CreateSeparator(PopupMenu1, "Separator1");
    PushBtn1 = CreatePushButton("PushButton1", PopupMenu1);
    ToggleBtn1 = CreateToggle("Toggle1", PopupMenu1);
    XtManageChild(PopupMenu1);

    CommonPause();
    XtDestroyWidget(PopupMenu1);
    
    n =0;
    XtSetArg(args[n], XmNrowColumnType, XmMENU_POPUP); n++;
    PopupMenu2 = XmCreateRowColumn(Shell1, "popupMenu2", args, n);

    /*
    **  Menu2
    */

    Label2 = CreateLabel("Menu2", PopupMenu2);
    Separator2 = CreateSeparator(PopupMenu2, "Separator2");
    PushBtn2 = CreatePushButton("PushButton2", PopupMenu2);
    ToggleBtn2 = CreateToggle("Toggle2", PopupMenu2);
    XtManageChild(PopupMenu2);

    CommonPause();

    XtDestroyWidget(Label);
    XtDestroyWidget(PopupMenu2);

    /*
     *  Test 3 for PIR 2669
     */

    n = 0;
    testingArea = XmCreateBulletinBoard(Shell1, "PushButtonHere", args, n);

    n = 0;
    XtSetArg(args[n], XmNx, 10); n++;
    XtSetArg(args[n], XmNy, 30); n++;
    MainButton = XmCreatePushButton(testingArea, "button0", args, n);
    XtAddCallback(MainButton, XmNactivateCallback, ButtonCB, (XtPointer) 0); 
    XtManageChild(MainButton);

    popup = XmCreatePopupMenu(testingArea, "Popups", NULL, 0);
    XtAddEventHandler(testingArea, ButtonPressMask, FALSE, PostPopup, popup);
    
    XmAddToPostFromList(popup, MainButton);
    
    push = XmCreatePushButton(popup, "button1", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 1);
    XtManageChild(push);

    push = XmCreatePushButton(popup, "button2", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 2);
    XtManageChild(push);

    push = XmCreatePushButton(popup, "button3", NULL, 0);
    XtAddCallback(push, XmNactivateCallback, ButtonCB, (XtPointer) 3);
    XtManageChild(push);
    
    XtManageChild(testingArea);
    
    CommonPause();

    XtDestroyWidget(testingArea);

    CommonPause();

    XtAppMainLoop(app_context);
}
Exemplo n.º 10
0
Widget CreateMenu ( MenuType         menuType,
                    char            *name,
                    Widget           parent,
                    MenuDescription *desc,
                    XtPointer        defaultClientData ) 
{
    Widget w;

   /*
    * Create the basic menu widget, based on the type of
    * menu requested. Do any special setup required
    * and then call CreateMenuChildren() to populate the menu.
    */

    switch ( menuType ) 
    {
      case POPUP:

       /*
        * Popups must have an event handler registered with the
        * parent to display the menu when button 3 is pressed.
        */

        w = XmCreatePopupMenu ( parent, name, NULL, 0 );
    
        AttachPopup ( parent, w );

        CreateMenuChildren ( w, desc, defaultClientData );

        return ( w );

      case MENUBAR:

        /*
         * For menu bars, just create the menu bar, and then
         * add children. All direct children are expected
         * to be pulldown menus.
         */

         w = XmCreateMenuBar ( parent, name, NULL, 0 );

         CreateMenuChildren ( w, desc, defaultClientData );

         XtManageChild ( w );

         return ( w );
    
      case OPTION:
      {
        /*
         * All option menus have a pulldown, but it is nicer to hide
         * this, allowing the programmer to just specify the contents
         * of the pane. So, create the option menu, create and attach
         * a pulldown pane, and then call CreateMenuChildren() to
         * populate the pulldown menu pane.
         */

         Widget option = XmCreateOptionMenu ( parent, name, NULL, 0 );

         w = XmCreatePulldownMenu ( parent, name, NULL, 0 );

         XtVaSetValues ( option, XmNsubMenuId, w, NULL );

         CreateMenuChildren ( w, desc, defaultClientData );

         XtManageChild ( option );

         return ( option );
     }

      default:
        XtError ( "Invalid Menu Type" );
        return ( NULL );
    }
}
Exemplo n.º 11
0
Widget
ui_build_menu(
	Widget		parent,
	int		menu_type,
	int		num_columns,
	char		*menu_title,
	char		*menu_name,
	MenuItem	*menu_items
)
{
    Widget	menu,
   		cascade,
		widget;
    Arg		args[4];
    int 	i;
    XmString	xmlabel;
    int		n = 0;

    if (num_columns > 1)
    {
    	XtSetArg(args[n], XmNpacking, XmPACK_COLUMN);    n++;
    	XtSetArg(args[n], XmNnumColumns, num_columns);   n++;
    }
    if (menu_type == XmMENU_PULLDOWN)
	menu = XmCreatePulldownMenu(parent, "pulldown_menu", args, n);
    else
    {
	XtSetArg(args[n], XmNwhichButton, AB_BMenu); n++;
        menu = XmCreatePopupMenu(parent, "popup_menu", args, n);
    }

    if (menu_type == XmMENU_PULLDOWN)
    {
        cascade = XtVaCreateManagedWidget(menu_name,
			xmCascadeButtonWidgetClass, parent,
			XmNsubMenuId,	menu,
			NULL);

	if (menu_title)
        {
	    xmlabel = XmStringCreateLocalized(menu_title);
	    XtVaSetValues(cascade, XmNlabelString, xmlabel, NULL);
	    XmStringFree(xmlabel);
	}
    }

    for (i = 0; menu_items[i].label != NULL; i++)
    {
        if (menu_items[i].subitems)
	{
	    widget = ui_build_menu(menu, XmMENU_PULLDOWN, 
				       menu_items[i].num_columns,
			               menu_items[i].label, 
				       menu_items[i].name,
				       (MenuItem *)menu_items[i].subitems);

	    XtVaSetValues(widget, XmNuserData, (XtArgVal)menu_items[i].user_data, NULL);
	}
	else
	{
	    widget = XtVaCreateManagedWidget(menu_items[i].name,
			         *menu_items[i].wclass, 
				  menu, 
                                  XmNuserData,    (XtArgVal)menu_items[i].user_data,
				  NULL);

	    if (menu_items[i].label != NULL)
	    {
		xmlabel = XmStringCreateLocalized(menu_items[i].label);
	  	XtVaSetValues(widget, XmNlabelString, xmlabel, NULL);
	    	XmStringFree(xmlabel);
	    }
	
	    /* If label is glyph type, then change type and call
	     * routine to set glyph.
	     */
	    if (menu_items[i].label_type == AB_LABEL_GLYPH)
	    {
        	XtVaSetValues(widget, XmNlabelType, XmPIXMAP, NULL);
		dtb_set_label_from_bitmap_data(widget,
				menu_items[i].pixwidth,
				menu_items[i].pixheight,
				menu_items[i].bits);

	    }
	}

	if (menu_items[i].active == FALSE)
	    XtSetSensitive(widget, FALSE);
 	else if (menu_items[i].callback != NULL)
	    XtAddCallback(widget, XmNactivateCallback, 
				menu_items[i].callback, 
				menu_items[i].client_data);
   }

   if (menu_type == XmMENU_POPUP)
	return menu;
   else
	return cascade;
}
Exemplo n.º 12
0
void NxmPushBtnMenu_create ( Widget pushb, long interval, char *items[],
                             int nitems, XtCallbackProc callback )
/************************************************************************
 * NxmPushBtnMenu_create                                                *
 *                                                                      *
 * This function creates a popup menu attached to a push button.        *
 *                                                                      *
 * NxmPushBtnMenu_create(pushb, interval, items, nitems, callback)      *
 *                                                                      *
 * Input parameters:                                                    *
 *  pushb               Widget       the push button id                 *
 *  interval		long	     elapsed time to pop up menu	*
 *  *items[]            char         menu items name 		        *
 *  nitems              int          number of items in the menu        *
 *  *callback()         void         callback function for the menu     *
 *                                                                      *
 * Output parameters:                                                   *
 *          NONE                                                        *
 *                                                                      *
 * Return parameters:                                                   *
 *          NONE                                                        *
 *                                                                      *
 **                                                                     *
 * Log:                                                                 *
 * R. Tian/SAIC		10/02						*
 ***********************************************************************/
{
    long	ii;
    Widget	menu_pane, menu_item;
    Widget	parent;
/*---------------------------------------------------------------------*/
/*
 * make sure at least 0.5 second interval.
 */
    if(interval > _interval) {
	_interval = interval;
    }

/*
 * the menu and push button will have the same parent.
 */
    parent = XtParent(pushb);

/*
 * create the pop up menu.
 */
    menu_pane = XmCreatePopupMenu(parent, "a_menu_pane", NULL, 0);

    for(ii = 0; ii < nitems; ++ii) {
	menu_item = XmCreatePushButtonGadget(menu_pane, items[ii], NULL, 0);
        XtManageChild(menu_item);
	XtAddCallback(menu_item, XmNactivateCallback,
                      (XtCallbackProc)callback,(XtPointer)ii);
    }

/*
 * attach the menu to the push button.
 */
    XtAddCallback(pushb, XmNarmCallback, 
                  (XtCallbackProc)NxmPushBtnMenu_poseCb, menu_pane);
    XtAddCallback(pushb, XmNdisarmCallback,
                  (XtCallbackProc)NxmPushBtnMenu_unPoseCb, menu_pane);
    XtAddEventHandler(pushb, LeaveWindowMask, FALSE,
                      (XtEventHandler)NxmPushBtnMenu_unPoseCb, menu_pane);
}
Exemplo n.º 13
0
Widget XNavMotif::build_menu( Widget Parent,
			      int   MenuType,
			      const char *MenuTitle,
			      void *MenuUserData,
			      void (*Callback)( Widget, XNav *, XmAnyCallbackStruct *),
			      void *CallbackData,
			      xmenu_sMenuItem *Items,
			      int *idx)
{
  Widget Menu, Cascade, W;
  int i;
  unsigned int Level;
  XmString Str;
  WidgetClass Class;
  Arg ArgList[5]; 
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  // Set default fontlist
  font = XLoadQueryFont( flow_Display(Parent),
  	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i = 0;
  XtSetArg(ArgList[i], XmNuserData, MenuUserData); i++;
  XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
  if (MenuType == MENU_PULLDOWN || MenuType == MENU_OPTION)
    Menu = XmCreatePulldownMenu(Parent, (char*) "_pulldown", ArgList, i);
  else if (MenuType == MENU_POPUP)
    Menu = XmCreatePopupMenu(Parent, (char*) "_popup", ArgList, i);  
  else  {
    XtWarning("Invalid menu type passed to BuildMenu().");
    return NULL;
  }

  if (MenuType == MENU_PULLDOWN) {
    Str = XmStringCreateSimple((char*) MenuTitle);	
    Cascade = XtVaCreateManagedWidget(MenuTitle,
	    xmCascadeButtonGadgetClass, Parent,
	    XmNsubMenuId,   Menu,
	    XmNlabelString, Str,
	    NULL);
    XmStringFree(Str);
  } 
  else if (MenuType == MENU_OPTION) {
    Str = XmStringCreateSimple((char*) MenuTitle);
    XtSetArg(ArgList[0], XmNsubMenuId, Menu);
    XtSetArg(ArgList[1], XmNlabelString, Str);
    Cascade = XmCreateOptionMenu(Parent, (char*) MenuTitle, ArgList, 2);
    XmStringFree(Str);
  }

  XmFontListFree( fontlist);

  Level = Items[*idx].Level;

  for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
    if (Items[*idx].Item == xmenu_eMenuItem_Cascade ||
      Items[*idx].Item == xmenu_eMenuItem_Ref) {
      if (MenuType == MENU_OPTION) {
        XtWarning("You can't have submenus from option menu items.");
        return NULL;
      } 
      else {
        i = *idx;
        (*idx)++;	
        build_menu(Menu, MENU_PULLDOWN, 
		   Lng::translate( Items[i].Name), MenuUserData, 
		   Callback, CallbackData, Items, idx);
        (*idx)--;
      }
    }
    else {
      if (Items[*idx].Item == xmenu_eMenuItem_Separator)
        Class = xmSeparatorGadgetClass;
      else
        Class = xmPushButtonGadgetClass;
 
      W = XtVaCreateManagedWidget(Lng::translate( Items[*idx].Name), 
		    Class, Menu,
		    XmNuserData, *idx,
		    XmNsensitive, (Boolean)(Items[*idx].Flags.f.Sensitive == 1),
		    NULL);

      if (Callback && Class == xmPushButtonGadgetClass)
        XtAddCallback(W, XmNactivateCallback, (XtCallbackProc) Callback, 
		      (XtPointer) CallbackData);
    }
  }

  return MenuType == MENU_POPUP ? Menu : Cascade;
}
Exemplo n.º 14
0
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar,
                             WXWidget parent,
                             wxMenu * topMenu,
                             size_t menuIndex,
                             const wxString& title,
                             bool pullDown)
{
    Widget menu = (Widget) 0;
    Widget buttonWidget = (Widget) 0;
    Display* dpy = XtDisplay((Widget)parent);
    Arg args[5];
    XtSetArg (args[0], XmNnumColumns, m_numColumns);
    XtSetArg (args[1], XmNpacking, (m_numColumns > 1) ? XmPACK_COLUMN : XmPACK_TIGHT);

    if ( !m_font.IsOk() )
    {
        if ( menuBar )
            m_font = menuBar->GetFont();
        else if ( GetInvokingWindow() )
            m_font = GetInvokingWindow()->GetFont();
    }

    XtSetArg (args[2], (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) );

    if (!pullDown)
    {
        menu = XmCreatePopupMenu ((Widget) parent, wxMOTIF_STR("popup"), args, 3);
#if 0
        XtAddCallback(menu,
                      XmNunmapCallback,
                      (XtCallbackProc)wxMenuPopdownCallback,
                      (XtPointer)this);
#endif
    }
    else
    {
        char mnem = wxFindMnemonic (title);
        menu = XmCreatePulldownMenu ((Widget) parent, wxMOTIF_STR("pulldown"), args, 3);

        wxString title2(wxStripMenuCodes(title));
        wxXmString label_str(title2);
        buttonWidget = XtVaCreateManagedWidget(title2,
#if wxUSE_GADGETS
                                               xmCascadeButtonGadgetClass, (Widget) parent,
#else
                                               xmCascadeButtonWidgetClass, (Widget) parent,
#endif
                                               XmNlabelString, label_str(),
                                               XmNsubMenuId, menu,
                                               (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
                                               XmNpositionIndex, menuIndex,
                                               NULL);

        if (mnem != 0)
            XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
    }

    m_menuWidget = (WXWidget) menu;

    m_topLevelMenu = topMenu;

    size_t i = 0;
    for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
            node;
            node = node->GetNext(), ++i )
    {
        wxMenuItem *item = node->GetData();

        item->CreateItem(menu, menuBar, topMenu, i);
    }

    ChangeFont();

    return buttonWidget;
}
Exemplo n.º 15
0
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar,
                             WXWidget parent,
                             wxMenu * topMenu,
                             size_t WXUNUSED(index),
                             const wxString& title,
                             bool pullDown)
{
    Widget menu = (Widget) 0;
    Widget buttonWidget = (Widget) 0;
    Arg args[5];
    XtSetArg (args[0], XmNnumColumns, m_numColumns);
    XtSetArg (args[1], XmNpacking, (m_numColumns > 1) ? XmPACK_COLUMN : XmPACK_TIGHT);

    if (!pullDown)
    {
        menu = XmCreatePopupMenu ((Widget) parent, wxMOTIF_STR("popup"), args, 2);
#if 0
        XtAddCallback(menu,
            XmNunmapCallback,
            (XtCallbackProc)wxMenuPopdownCallback,
            (XtPointer)this);
#endif
    }
    else
    {
        char mnem = wxFindMnemonic (title);
        menu = XmCreatePulldownMenu ((Widget) parent, wxMOTIF_STR("pulldown"), args, 2);

        wxString title2(wxStripMenuCodes(title));
        wxXmString label_str(title2);
        buttonWidget = XtVaCreateManagedWidget(title2,
#if wxUSE_GADGETS
            xmCascadeButtonGadgetClass, (Widget) parent,
#else
            xmCascadeButtonWidgetClass, (Widget) parent,
#endif
            XmNlabelString, label_str(),
            XmNsubMenuId, menu,
            NULL);

        if (mnem != 0)
            XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
    }

    m_menuWidget = (WXWidget) menu;

    m_topLevelMenu = topMenu;

    size_t i = 0;
    for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
          node;
          node = node->GetNext(), ++i )
    {
        wxMenuItem *item = node->GetData();

        item->CreateItem(menu, menuBar, topMenu, i);
    }

    SetBackgroundColour(m_backgroundColour);
    SetForegroundColour(m_foregroundColour);
    SetFont(m_font);

    return buttonWidget;
}
Exemplo n.º 16
0
static void CreateMenuButtons(Widget parent)
{
    Widget menuButton, submenu, titleLabel, button;
    Pixmap cascadePixmap;
    Pixel fg, bg;
    Cardinal depth;
    XmString labelString;
    Arg args[20];
    int i, n;

    /* Create title label */

    labelString = XmStringCreateLocalized("MenuButton Widget");
    n = 0;
    XtSetArg(args[n], XmNlabelString, labelString); n++;
    titleLabel = XmCreateLabel(parent, "title", args, n);
    XtManageChild(titleLabel);
    XmStringFree(labelString);


    /*
     * Create a MenuButton.
     * Add push buttons to the built-in popup menu.
     */

    labelString = XmStringCreateLocalized("Action");
    n = 0;
    XtSetArg(args[n], XmNlabelString, labelString); n++;
    menuButton = DtCreateMenuButton(parent, "menuButton1", args, n);
    XtManageChild(menuButton);
    XmStringFree(labelString);

    XtVaGetValues(menuButton, DtNsubMenuId, &submenu, NULL);
    button = XmCreatePushButton(submenu, "Push", NULL, 0);
    XtManageChild(button);
    button = XmCreatePushButton(submenu, "Pull", NULL, 0);
    XtManageChild(button);
    button = XmCreatePushButton(submenu, "Turn", NULL, 0);
    XtManageChild(button);


    /*
     * Create a MenuButton.
     * Replace the built-in popup menu with a tear-off menu.
     * Add a custom pixmap in the colors of the MenuButton.
     */

    labelString = XmStringCreateLocalized("Movement");
    n = 0;
    XtSetArg(args[n], XmNlabelString, labelString); n++;
    menuButton = DtCreateMenuButton(parent, "menuButton1", args, n);
    XtManageChild(menuButton);
    XmStringFree(labelString);

    /* Create a tear-off menu */

    n = 0;
    XtSetArg(args[0], XmNtearOffModel, XmTEAR_OFF_ENABLED); n++;
    submenu = XmCreatePopupMenu(menuButton, "submenu", args, n);
    button = XmCreatePushButton(submenu, "Run", NULL, 0);
    XtManageChild(button);
    button = XmCreatePushButton(submenu, "Jump", NULL, 0);
    XtManageChild(button);
    button = XmCreatePushButton(submenu, "Stop", NULL, 0);
    XtManageChild(button);

    XtVaSetValues(menuButton, DtNsubMenuId, submenu, NULL);

    /* Create a pixmap using the menu button's colors and depth */

    XtVaGetValues(menuButton,
			XmNforeground, &fg,
			XmNbackground, &bg,
			XmNdepth, &depth,
			NULL);

    cascadePixmap = XCreatePixmapFromBitmapData(XtDisplay(menuButton),
				DefaultRootWindow(XtDisplay(menuButton)),
				(char*)menu_glyph_bits,
				menu_glyph_width, menu_glyph_height,
				fg, bg, depth);
    XtVaSetValues(menuButton, DtNcascadePixmap, cascadePixmap, NULL);
}
Exemplo n.º 17
0
Widget XmCreatePopupMenu_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreatePopupMenu(parent, name, arglist, argcount);}
Exemplo n.º 18
0
Widget *XbrMenu(Widget parent, char *title, int menu_type,
  XbrMenuData menu_data[], int n)
{
    XtAppContext app_context = XtWidgetToApplicationContext(parent);
    Widget *widgets;
    Boolean radio_behaviour = False;
    int i, extras;
    Arg args[10];
    Cardinal num;
    XmString string;
    char name[256];

    /* Number of extra widgets to create - for a popup this is just the popup
       menu but for pulldowns there is the menu and the cascade button.
    */
    if(menu_type == XbrMENU_POPUP)
        extras = 1;
    else
        extras = 2; 
                      
    /* Allocate memory for widgets */
    if((widgets = (Widget *) malloc(sizeof(Widget) * (n+extras))) == NULL) {
        XtAppError(app_context, "Error - out of memory!\n");
        return(NULL);
    }

    /* Create menu */
    switch(menu_type) {
        case XbrMENU_POPUP:
            sprintf(name, "%sPopup", title);
            widgets[MENU] = XmCreatePopupMenu(parent, name, NULL, 0);
            break;
        case XbrMENU_OPTION:
            sprintf(name, "%sPane", title);
            widgets[MENU] = XmCreatePulldownMenu(parent, name, NULL,0);
            num = 0; 
            string = XmStringCreateLocalized(title);
            XtSetArg(args[num], XmNsubMenuId, widgets[MENU]); num++;
            XtSetArg(args[num], XmNlabelString, string); num++;
            sprintf(name, "%sOption", title);
            widgets[CASCADE] = XmCreateOptionMenu(parent, name, args, num);
            XmStringFree(string);
            XtManageChild(widgets[CASCADE]);
            break;
        case XbrMENU_PULLDOWN_RADIO:
            radio_behaviour = True;
        case XbrMENU_PULLDOWN:
            sprintf(name, "%sPulldown", title);
            widgets[MENU] = XmCreatePulldownMenu(parent, name, NULL,0);
            XtVaSetValues(widgets[MENU], XmNradioBehavior, radio_behaviour,
              NULL);

            /* Create menu title */
            sprintf(name, "%sCascade", title);
            widgets[CASCADE]  = XtVaCreateManagedWidget(name,
                          xmCascadeButtonWidgetClass, parent,
                          XmNsubMenuId, widgets[MENU],
                          XtVaTypedArg, XmNlabelString, XmRString,
                          title, sizeof(char *),
                          NULL);
            break;
        default:
            XtAppError(app_context, "Unknown menu type!\n");
    }

    /* Add desired widgets */
    for(i = 0; i < n; i++) {
        sprintf(name, "%s%d", title, i);
        switch(menu_data[i].type) {
            /* Label widget - easy */
            case XbrLABEL:
                string = XmStringCreateLocalized(menu_data[i].label);
                widgets[i+extras] = XtVaCreateManagedWidget(name,
                                        xmLabelWidgetClass, widgets[MENU],
                                        XmNlabelString, string,
                                        NULL);
                XmStringFree(string);
                break;

            /* Push button gadget - include activate callback & data */
            case XbrPB:
                string = XmStringCreateLocalized(menu_data[i].label);
                widgets[i+extras] = XtVaCreateManagedWidget(name,
                          xmPushButtonWidgetClass, widgets[MENU],
                          XmNlabelString, string,
                          NULL);
                XmStringFree(string);
                if(menu_data[i].callback)
                    XtAddCallback(widgets[i+extras], XmNactivateCallback,
                      menu_data[i].callback, menu_data[i].data);
                if(menu_data[i].set && menu_type == XbrMENU_OPTION)
                    XtVaSetValues(widgets[CASCADE], XmNmenuHistory, 
                        widgets[i+extras], NULL);
                break;

            /* Toggle button - include value changed callback & data */
            case XbrTOGGLE:
                num = 0;
                string = XmStringCreateLocalized(menu_data[i].label);
                XtSetArg(args[num], XmNlabelString, string); num++;
                XtSetArg(args[num], XmNindicatorType, XmONE_OF_MANY); num++;
                if(menu_data[i].set != XbrNOSET) {
                    XtSetArg(args[num], XmNset, menu_data[i].set); num++;
                } 
                widgets[i+extras] = XmCreateToggleButton(widgets[MENU], name,
                  args, num);
                XtManageChild(widgets[i+extras]);
                XmStringFree(string);
                if(menu_data[i].callback)
                    XtAddCallback(widgets[i+extras], XmNvalueChangedCallback,
                      menu_data[i].callback, menu_data[i].data);
                break;

            /* Separator to make menu look pretty! */
            case XbrSEPARATOR:
                widgets[i+extras] = XtVaCreateManagedWidget(name,
                           xmSeparatorWidgetClass, widgets[MENU],
                           NULL);
                break;

            /* A sub menu */
            case XbrSUBMENU:
                widgets[i+extras] = (Widget)XbrMenu(widgets[MENU], menu_data[i].title, menu_data[i].stype,
                  menu_data[i].submenu, menu_data[i].n);
                break;
            default:
                XtAppError(app_context, "Unknown menu item!\n");
                break;
        }
    }

    return(widgets);
}
Exemplo n.º 19
0
/**********************************************************************************
 * FUNCTIONS
 **********************************************************************************/
int video_open(PLOT *plot)
{
	struct videodata *plotdata;
	Display *dpy;
	Screen *scr;
	Widget w, mw, m0, m1, m2, m3;
	int status = SUCCESS;
	Dimension width, height;
	int depth;
    XGCValues values;
	unsigned long foreground, background;
	XmString xmstr, xmstr1;
	Arg args[10];
	int n;

	plot->plotdata = (void *)calloc(1, sizeof(struct videodata));
	plotdata = (struct videodata *)plot->plotdata;
	plotdata->image = (XImage *)calloc(sizeof(XImage), 1);
	plotdata->framedata = NULL;
	plotdata->width = 0;
	plotdata->height = 0;
	plotdata->ncomps = 0;
	plotdata->microsecs_per_frame = 0;
	plotdata->colormap = defaults.colormap;
	plotdata->framenum = 0;
	plotdata->loadedframenum = -1;

	plot->plot_widget = XtVaCreateManagedWidget("video", xmDrawingAreaWidgetClass, plot->panel->panel_container,
		XmNheight, defaults.video_height,
		XmNwidth, defaults.width,
		XmNmarginHeight, 0,
		XmNmarginWidth, 0,
		NULL);
	XtAddCallback(plot->plot_widget, XmNexposeCallback, video_expose_callback, (XtPointer)plot);
	XtAddCallback(plot->plot_widget, XmNresizeCallback, video_resize_callback, (XtPointer)plot);

	w = (Widget)plot->plot_widget;
	dpy = XtDisplay(w);
	scr = XtScreen(w);

	XtVaGetValues(w,
		XmNheight, &height,
		XmNwidth, &width,
		XmNdepth, &depth,
		XmNforeground, &foreground,
		XmNbackground, &background,
		NULL);

	/*
	** Get the font;  also, calculate the margins for the axes (this depends on the font size!).
	** Store these margins for use later (we might start off without axes, and turn them on later.
	*/
	plot->ticklblfont = XmFontListCopy(_XmGetDefaultFontList(w, XmLABEL_FONTLIST));
	plot->minoffx = 6 + XmStringWidth(plot->ticklblfont, xmstr = XmStringCreateSimple("-32768")); XmStringFree(xmstr);
	plot->minoffx2 = 0;
	plot->minoffy = 0;
	plot->minoffy2 = 6 + XmStringHeight(plot->ticklblfont, xmstr = XmStringCreateSimple("1")); XmStringFree(xmstr);

	plot->offx = 0;
	plot->offy = 0;
	plot->offx2 = 0;
	plot->offy2 = 0;
	plot->width = width;
	plot->height = height;
	plot->depth = depth;

	/*
	** Allocate our colors.  We use the XCC code that is:
	** Copyright 1994,1995 John L. Cwikla
	** This allows us to work on any visual, etc.   The danger is that
	** we may not get the exact colors we ask for... meaning that things
	** may not really be as we see them.  This is unfortunate, but the
	** alternative is to not run at all (the old code crashed).  So...
	*/
	plotdata->ncolors = MIN(SONO_DEFAULT_MAX_COLORS, MIN(XDisplayCells(dpy, XDefaultScreen(dpy)), MAXCOLORS - RESERVED_COLORS));
	plotdata->xcc = XCCCreate(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), TRUE, TRUE, XA_RGB_GRAY_MAP, &(plotdata->cmap));
	if (XCCGetNumColors(plotdata->xcc) < plotdata->ncolors)
	{
		plotdata->ncolors = XCCGetNumColors(plotdata->xcc);
		printf("Warning.  Using only %d colors.\n", plotdata->ncolors);
	}
	(*((colormap[plotdata->colormap]).cmap))(dpy, plotdata->ncolors, plotdata->colors, NULL);

	/*
	** Create the Graphics contexts.
	** drawing_GC is for the picture itself.  inverse_GC is for erasing.  mark_GC is for the subregion marks.
	*/
	values.font = getFontStruct(plot->ticklblfont)->fid;
	values.function = GXcopy;
	values.plane_mask = AllPlanes;
	values.foreground = foreground;
	values.background = background;
	plotdata->drawing_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFont, &values);
	values.foreground = background;
	values.background = background;
	plotdata->inverse_GC = XtGetGC(w, GCForeground | GCBackground, &values);
	values.function = GXxor;
	values.plane_mask = foreground ^ background;
	values.foreground = 0xffffffff;
	values.background = 0x0;
	values.line_style = LineSolid;
	plotdata->mark_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineStyle, &values);

	plotdata->pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), width, height, depth);
	plotdata->pixmapalloced = TRUE;
	XFillRectangle(dpy, plotdata->pixmap, plotdata->inverse_GC, 0, 0, width, height);

	/*
	** Create the popup menu
	** 
	*/
	n = 0;
	XtSetArg(args[n], XmNmenuPost, "<Btn3Down>"); n++;
	mw = plot->plot_popupmenu_widget = XmCreatePopupMenu(w, "popupmenu", args, n);

	m0 = XtVaCreateManagedWidget("m0", xmLabelGadgetClass, mw,
		XmNlabelString, xmstr1 = XmStringCreateSimple("Options"),
		NULL);
	XmStringFree(xmstr1);

	m1 = XtVaCreateManagedWidget("m1", xmSeparatorGadgetClass, mw,
		NULL);

	CreateMenuButton(m2, mw, "save", "Save", "Save");
	CreateMenuButton(m3, mw, "print", "Print EPS", "Print EPS");

	/*
	** Register an event handler
	*/
	XtAddEventHandler(w, KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask,
		FALSE, (XtEventHandler) video_event_handler, (XtPointer)plot);

	plot->plot_display = video_display;
	plot->plot_set = video_set;
	plot->plot_close = video_close;
	plot->plot_print = video_print;

	plot->plot_playmarker = NULL;
	plot->plot_showvideoframe = video_showvideoframe;
	plot->plot_clearmarks = NULL;
	plot->plot_drawstartmark = NULL;
	plot->plot_drawstopmark = NULL;
	plot->plot_conv_pixel_to_time = NULL;

	plot->plot_save = video_save;

	plot->plot_event_handler = video_event_handler;
	plot->plot_play = video_play;

	plotdata->butgrabbed = FALSE;
	plot->playmark = -1;
	plot->markx1 = -1;
	plot->markx2 = -1;

	plot->group->needpcm = 1;

	return status;
}