Пример #1
0
void CLogMotif::set_clock_cursor()
{
  if ( !clock_cursor)
    clock_cursor = XCreateFontCursor( flow_Display(toplevel), XC_watch);

  XDefineCursor( flow_Display(toplevel), flow_Window(toplevel), clock_cursor);
  XFlush( flow_Display(toplevel));
}
Пример #2
0
void CoWowMotif::GetAtoms( Widget w, Atom *graph_atom, Atom *objid_atom, Atom *attrref_atom)
{
  if ( graph_atom)
    *graph_atom = XInternAtom( flow_Display(w), "PWR_GRAPH", False); 
  if ( objid_atom)
    *objid_atom = XInternAtom( flow_Display(w), "PWR_OBJID", False); 
  if ( attrref_atom)
    *attrref_atom = XInternAtom( flow_Display(w), "PWR_ATTRREF", False); 
}
Пример #3
0
static Boolean nav_sel_convert_cb(
    Widget  w,
    Atom    *selection,
    Atom    *target,
    Atom    *type_return,
    XtPointer	*value_return,
    unsigned long   *length_return,
    int	    *format_return)
{
  NavMotif      *nav;
  brow_tCtx	browctx;
  char		name[200];
  int 		sts;

  BrowCtxFromWidget( w, (void **) &browctx);
  brow_GetCtxUserData( browctx, (void **) &nav);

  if (*target == XA_TARGETS(flow_Display(nav->brow_widget))) {
    Atom *targetP;
    Atom *std_targets;
    unsigned long std_length;
    XSelectionRequestEvent *req = XtGetSelectionRequest( w, *selection, 
       (XtRequestId)NULL);

    XmuConvertStandardSelection( w, req->time, selection, target, type_return,
		(caddr_t *)&std_targets, &std_length, format_return);

    *value_return = XtMalloc( sizeof(Atom) * (std_length + 2));
    targetP = *(Atom **) value_return;
    *targetP++ = XA_STRING;
    *targetP++ = XA_TEXT(flow_Display(nav->brow_widget));
    *length_return = std_length + (targetP - (*(Atom **) value_return));
    bcopy((char *)std_targets, (char *)targetP, sizeof(Atom) * std_length);
    XtFree( (char *)std_targets);
    *type_return = XA_ATOM;
    *format_return = 32;
    return True;
  }

  if (*target == XA_STRING)
  {
    if ( !nav->get_plant_select_cb)
      return FALSE;

    sts = nav->get_plant_select_cb( nav->parent_ctx, name, sizeof(name));
    if ( EVEN(sts)) return FALSE;
    *value_return = XtNewString(name);      
    *length_return = strlen(name) + 1;

    *type_return = XA_STRING;
    *format_return = 8;

    return TRUE;
  }
  return FALSE;
}
Пример #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 ;
}
Пример #5
0
void PalMotif::set_selection_owner()
{
  int sts;

  sts = XtOwnSelection( brow_widget, XA_PRIMARY, 
	XtLastTimestampProcessed(flow_Display(brow_widget)),  
	pal_sel_convert_cb, pal_sel_lose_cb , NULL);
  if ( !sts) {
     brow_SelectClear( brow_ctx);
     return;
  }	
  selection_owner = 1;
}
Пример #6
0
void WNavMotif::set_selection_owner()
{
    int sts;

    sts = XtOwnSelection( brow_widget, XA_PRIMARY,
                          XtLastTimestampProcessed(flow_Display(brow_widget)),
                          WNavMotif::sel_convert_cb, WNavMotif::sel_lose_cb , NULL);
    if ( !sts)
    {
        message('E', "Failed attempting to become primary selection owner");
        brow_SelectClear( brow->ctx);
        return;
    }
    selection_owner = 1;
}
Пример #7
0
void NavMotif::set_selection_owner( int set)
{
  int sts;

  if ( set) {
    sts = XtOwnSelection( brow_widget, XA_PRIMARY, 
			  XtLastTimestampProcessed(flow_Display(brow_widget)),  
			  nav_sel_convert_cb, nav_sel_lose_cb , NULL);
    if ( !sts) {
      brow_SelectClear( brow_ctx);
      return;
    }	
  }
  else {
    // Todo...
  }
}
Пример #8
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;
}
Пример #9
0
void XNavMotif::bell( int time)
{
  XBell( flow_Display( brow_widget), time);
}
Пример #10
0
//
// Input from motif text-widget with recall
// Returns 1 if return i pressed, else 0.
//
int mrm_TextInput( Widget w, XEvent *event, char *recall, int line_size, 
	int recall_size, int *current_recall_line)
{
  KeySym keysym;
  Modifiers mod;
  int 	pos;
  char 	*text;
  char 	newtext[160];
  int	i;
  XmTextPosition   left, right;
  char  *s, *t;

  text = XmTextGetString( w);
  XtTranslateKeycode( flow_Display(w), event->xkey.keycode, event->xkey.state, 
	&mod, &keysym);
  keysym &= 0xFFFF;
  switch ( keysym) 
  {
    case XK_Return:
    case XK_Linefeed:
      // Insert in recall buffer
      if ( strcmp( text, "") != 0)
      {
        for ( i = recall_size - 2; i >= 0; i--)
          strcpy( recall + (i+1) * line_size, recall + i * line_size);
        strncpy( recall, text, line_size);
        recall[line_size-1] = 0;
      }
      *current_recall_line = 0;
      return 1;
    case XK_Up:
      (*current_recall_line)++;
      if ( *current_recall_line > recall_size - 1)
        *current_recall_line = recall_size - 1;
      XmTextSetString( w, recall + (*current_recall_line - 1) * line_size);
      XmTextSetCursorPosition( w, 
		strlen(recall + (*current_recall_line - 1) * line_size));
      break;
    case XK_Down:
      if ( *current_recall_line == 0)
        XmTextSetString( w, "");
      else if ( *current_recall_line == 1)
      {
        XmTextSetString( w, "");
        (*current_recall_line)--;
      }
      else
      {
        (*current_recall_line)--;
        XmTextSetString( w, recall + (*current_recall_line - 1) * line_size);
        XmTextSetCursorPosition( w, 
		strlen(recall + (*current_recall_line - 1) * line_size));
      }
      break;
    case XK_Left:
      XmTextClearSelection( w, CurrentTime);
      pos = XmTextGetCursorPosition( w);
      if ( pos == 0)
        break;
      pos--;
      XmTextSetCursorPosition( w, pos);
      break;
    case XK_Right:
      XmTextClearSelection( w, CurrentTime);
      pos = XmTextGetCursorPosition( w);
      if ( pos >= line_size - 1)
        break;
      pos++;
      if ( pos > strlen(text))
        break;
      XmTextSetCursorPosition( w, pos);
      break;
    case XK_BackSpace:
    case 65535:
      if ( XmTextGetSelectionPosition( w, &left, &right)) {
        for ( s = text + left, t = text + right; *t; s++,t++)
	  *s = *t; 
        *s = 0;
        XmTextSetString( w, text);
        XmTextSetCursorPosition( w, left);
      }
      else {
        pos = XmTextGetCursorPosition( w);
        if ( pos == 0)
          break;
        if ( pos == 1)
          strcpy( newtext, "");
        else
          strncpy( newtext, text, pos-1);
        newtext[pos-1] = 0;
        strncat( newtext, &text[pos], sizeof( newtext));
        XmTextSetString( w, newtext);
        XmTextSetCursorPosition( w, pos-1);
      }
      break;
    default:
      if ( event->xkey.state & ControlMask)
        return 0;
      if ( keysym > 256)
        return 0;

      if ( XmTextGetSelectionPosition( w, &left, &right)) {
        for ( s = text + left, t = text + right; *t; s++,t++)
	  *s = *t; 
        *s = 0;
        XmTextSetCursorPosition( w, left);
      }
      pos = XmTextGetCursorPosition( w);
      if ( pos >= line_size - 1)
        break;
      if ( pos == 0)
        strcpy( newtext, "");
      else
        strncpy( newtext, text, pos);
      newtext[pos] = keysym;
      newtext[pos+1] = 0;
      strncat( newtext, &text[pos], sizeof( newtext));
      XmTextSetString( w, newtext);
      XmTextSetCursorPosition( w, pos+1);
  }
  return 0;
}
Пример #11
0
Boolean WNavMotif::sel_convert_cb(
    Widget  w,
    Atom    *selection,
    Atom    *target,
    Atom    *type_return,
    XtPointer	*value_return,
    unsigned long   *length_return,
    int	    *format_return)
{
    WNavMotif    	*wnav;
    brow_tCtx	browctx;
    int 		sts;
    int		size;
    WItem		*item;
    pwr_tAName   	attr_str;
    pwr_sAttrRef attrref;
    char          name[200];
    char		*buffp;

    BrowCtxFromWidget( w, (void **) &browctx);
    brow_GetCtxUserData( browctx, (void **) &wnav);

    if (*target == XA_TARGETS(flow_Display(wnav->brow_widget))) {
        Atom *targetP;
        Atom *std_targets;
        unsigned long std_length;
        XSelectionRequestEvent *req = XtGetSelectionRequest( w, *selection,
                                      (XtRequestId)NULL);

        XmuConvertStandardSelection( w, req->time, selection, target, type_return,
                                     (caddr_t *)&std_targets, &std_length, format_return);

        *value_return = XtMalloc( sizeof(Atom) * (std_length + 2));
        targetP = *(Atom **) value_return;
        *targetP++ = XA_STRING;
        *targetP++ = XA_TEXT(flow_Display(wnav->brow_widget));
        *length_return = std_length + (targetP - (*(Atom **) value_return));
        bcopy((char *)std_targets, (char *)targetP, sizeof(Atom) * std_length);
        XtFree( (char *)std_targets);
        *type_return = XA_ATOM;
        *format_return = 32;
        return True;
    }

    if (*target == XA_STRING ||
            *target == XA_TEXT(flow_Display(wnav->brow_widget)) ||
            *target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)) ||
            *target == wnav->graph_atom ||
            *target == wnav->objid_atom ||
            *target == wnav->attrref_atom)
    {
        brow_tNode	*node_list;
        int		node_count;
        wnav_eSelectionFormat format;

        if ( *target == wnav->graph_atom)
            format = wnav_eSelectionFormat_Graph;
        else if ( *target == wnav->objid_atom)
            format = wnav_eSelectionFormat_Objid;
        else if ( *target == wnav->attrref_atom)
            format = wnav_eSelectionFormat_Attrref;
        else
            format = wnav_eSelectionFormat_User;


        brow_GetSelectedNodes( wnav->brow->ctx, &node_list, &node_count);
        if ( !node_count)
            return FALSE;

        brow_GetUserData( node_list[0], (void **)&item);

        switch( item->type) {
        case wnav_eItemType_Attr:
        case wnav_eItemType_AttrInput:
        case wnav_eItemType_AttrInputInv:
        case wnav_eItemType_AttrInputF:
        case wnav_eItemType_AttrOutput:
        case wnav_eItemType_AttrArray:
        case wnav_eItemType_AttrArrayOutput:
        case wnav_eItemType_AttrArrayElem:
        case wnav_eItemType_AttrObject: {
            WItemBaseAttr *aitem = (WItemBaseAttr *)item;

            sts = ldh_ObjidToName( wnav->ldhses, item->objid, ldh_eName_Hierarchy,
                                   attr_str, sizeof(attr_str), &size);
            if ( EVEN(sts)) return FALSE;

            strcat( attr_str, ".");
            strcat( attr_str, aitem->name);
            sts = ldh_NameToAttrRef( wnav->ldhses, attr_str, &attrref);
            if ( EVEN(sts)) return FALSE;
            sts = (wnav->format_selection_cb)( wnav->parent_ctx, attrref,
                                               &buffp, 0, 1, format);
            *value_return = XtNewString(buffp);
            *length_return = strlen(buffp) + 1;
            if ( !sts) return FALSE;
            break;
        }
        case wnav_eItemType_Object:
            memset( &attrref, 0, sizeof(attrref));
            attrref.Objid = item->objid;
            sts = (wnav->format_selection_cb)( wnav->parent_ctx, attrref,
                                               &buffp, 0, 0, format);
            *value_return = XtNewString(buffp);
            *length_return = strlen(buffp) + 1;
            if ( !sts) return FALSE;
            break;
        default:
            brow_GetAnnotation( node_list[0], 0, name, sizeof(name));
            *value_return = XtNewString(name);
            *length_return = strlen(name) + 1;
        }
        free( node_list);

        if ( *target == XA_COMPOUND_TEXT(flow_Display(wnav->brow_widget)) ||
                *target == wnav->graph_atom ||
                *target == wnav->objid_atom ||
                *target == wnav->attrref_atom)
            *type_return = *target;
        else
            *type_return = XA_STRING;
        *format_return = 8;

        return TRUE;
    }
    return FALSE;
}
Пример #12
0
static Boolean pal_sel_convert_cb(
    Widget  w,
    Atom    *selection,
    Atom    *target,
    Atom    *type_return,
    XtPointer	*value_return,
    unsigned long   *length_return,
    int	    *format_return)
{
  PalMotif     	*pal;
  brow_tCtx	browctx;
  char		name[200];
  PalItem	*item;

  BrowCtxFromWidget( w, (void **) &browctx);
  brow_GetCtxUserData( browctx, (void **) &pal);

  if (*target == XA_TARGETS(flow_Display(pal->brow_widget))) {
    Atom *targetP;
    Atom *std_targets;
    unsigned long std_length;
    XSelectionRequestEvent *req = XtGetSelectionRequest( w, *selection, 
       (XtRequestId)NULL);

    XmuConvertStandardSelection( w, req->time, selection, target, type_return,
		(caddr_t *)&std_targets, &std_length, format_return);

    *value_return = XtMalloc( sizeof(Atom) * (std_length + 2));
    targetP = *(Atom **) value_return;
    *targetP++ = XA_STRING;
    *targetP++ = XA_TEXT(flow_Display(pal->brow_widget));
    *length_return = std_length + (targetP - (*(Atom **) value_return));
    bcopy((char *)std_targets, (char *)targetP, sizeof(Atom) * std_length);
    XtFree( (char *)std_targets);
    *type_return = XA_ATOM;
    *format_return = 32;
    return True;
  }

  if (*target == XA_STRING ||
      *target == XA_TEXT(flow_Display(pal->brow_widget)) ||
      *target == XA_COMPOUND_TEXT(flow_Display(pal->brow_widget))) {
    brow_tNode	*node_list;
    int		node_count;
  
    brow_GetSelectedNodes( pal->brow_ctx, &node_list, &node_count);
    if ( !node_count)
      return FALSE;

    brow_GetUserData( node_list[0], (void **)&item);

    switch( item->type) {
      case pal_ePalItemType_ClassVolume: 
      case pal_ePalItemType_Class: 
      case pal_ePalItemType_Object: 
      default:
        brow_GetAnnotation( node_list[0], 0, name, sizeof(name));
        *value_return = XtNewString(name);      
        *length_return = strlen(name) + 1;
    }
    free( node_list);

    *type_return = XA_STRING;
    *format_return = 8;

    return TRUE;
  }
  return FALSE;
}
Пример #13
0
void CLogMotif::free_cursor()
{
  if (clock_cursor)
    XFreeCursor( flow_Display(toplevel), clock_cursor);
}
Пример #14
0
void CLogMotif::reset_cursor()
{
  XUndefineCursor( flow_Display(toplevel), flow_Window(toplevel));
}