Loading ...
Sorry, an error occurred while loading the content.

Motif XmFontList encapsulation function

Expand Messages
  • David Harrison
    Creation of an XmFontList varies from 1.1 to 1.2. Encapsulate this for code maintenance. Also, create the menuBar widget using a more self-documenting
    Message 1 of 1 , Mar 2 2:15 PM
    • 0 Attachment
      Creation of an XmFontList varies from 1.1 to 1.2. Encapsulate this for
      code maintenance.

      Also, create the "menuBar" widget using a more self-documenting method.
      (i.e. XmCreateMenuBar)

      --David Harrison

      *** ../vim60w/src/gui_motif.c Wed Feb 21 08:51:53 2001
      --- src/gui_motif.c Fri Mar 2 16:57:20 2001
      ***************
      *** 157,180 ****
      NULL);

      #ifdef FEAT_MENU
      ! menuBar = XtVaCreateManagedWidget("menuBar",
      ! xmRowColumnWidgetClass, vimForm,
      ! XmNrowColumnType, XmMENU_BAR,
      #ifndef FEAT_CDE_COLORS
      ! XmNforeground, gui.menu_fg_pixel,
      ! XmNbackground, gui.menu_bg_pixel,
      #endif
      #if (XmVersion >= 1002)
      ! XmNtearOffModel, tearoff_val,
      #endif
      ! XmNleftAttachment, XmATTACH_FORM,
      ! XmNtopAttachment, XmATTACH_FORM,
      ! XmNrightAttachment, XmATTACH_FORM,
      #ifndef FEAT_TOOLBAR
      ! /* XmNbottomAttachment, XmATTACH_OPPOSITE_FORM, */
      ! XmNrightOffset, 0, /* Always stick to rigth hand side */
      #endif
      ! NULL);
      #endif

      #ifdef FEAT_TOOLBAR
      --- 157,183 ----
      NULL);

      #ifdef FEAT_MENU
      ! {
      ! Arg al[7]; /* Make sure there is enough room for arguments! */
      ! int ac = 0;
      !
      #ifndef FEAT_CDE_COLORS
      ! XtSetArg(al[ac], XmNforeground, gui.menu_fg_pixel); ac++;
      ! XtSetArg(al[ac], XmNbackground, gui.menu_bg_pixel); ac++;
      #endif
      #if (XmVersion >= 1002)
      ! XtSetArg(al[ac], XmNtearOffModel, tearoff_val); ac++;
      #endif
      ! XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
      ! XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
      ! XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
      #ifndef FEAT_TOOLBAR
      ! /* Always stick to right hand side. */
      ! XtSetArg(al[ac], XmNrightOffset, 0); ac++;
      #endif
      ! menuBar = XmCreateMenuBar(vimForm,"menuBar",al,ac);
      ! XtManageChild(menuBar);
      ! }
      #endif

      #ifdef FEAT_TOOLBAR
      ***************
      *** 539,544 ****
      --- 542,576 ----
      if (parent == NULL)
      gui_mch_compute_menu_height(menu->id);
      }
      +
      +
      + /*
      + * Encapsulate the way an XmFontList is created.
      + */
      + XmFontList
      + gui_motif_create_fontlist(font)
      + XFontStruct *font;
      + {
      + XmFontList font_list;
      +
      + # if (XmVERSION >= 1)
      + # if (XmREVISION == 1)
      + /* Motif 1.1 method */
      + font_list = XmFontListCreate(font,STRING_TAG);
      + # else
      + /* Motif 1.2 method */
      + XmFontListEntry font_list_entry;
      +
      + font_list_entry = XmFontListEntryCreate(STRING_TAG,
      + XmFONT_IS_FONT,
      + (XtPointer)font);
      + font_list = XmFontListAppendEntry(NULL,font_list_entry);
      + XmFontListEntryFree(&font_list_entry);
      + # endif
      + # endif
      + return font_list;
      + }
      +

      /*
      * Add mnemonic and accelerator text to a menu button.
      *** ../vim60w/src/workshop.c Thu Feb 22 06:21:12 2001
      --- src/workshop.c Fri Mar 2 16:27:04 2001
      ***************
      *** 620,628 ****
      --- 620,631 ----
      #endif

      /* Pick the proper signs for this font size */
      + #if 0
      fle = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
      XmFONT_IS_FONT, (XtPointer) gui.norm_font);
      fontList = XmFontListAppendEntry(NULL, fle);
      + #endif
      + fontList = gui_motif_create_fontlist((XFontStruct *)gui.norm_font);
      h = 0;
      if (fontList != NULL)
      {
      ***************
      *** 631,640 ****
      XmStringFree(str);
      XmFontListFree(fontList);
      #if 0
      ! /* documentation says XmFontListEntryFree() doesn't free the
      ! * XFontStruct, but gvim crashes if the following call is made.
      ! */
      ! XmFontListEntryFree(fle);
      #endif
      }
      if (h)
      --- 634,640 ----
      XmStringFree(str);
      XmFontListFree(fontList);
      #if 0
      ! XmFontListEntryFree(&fle);
      #endif
      }
      if (h)
    Your message has been successfully submitted and would be delivered to recipients shortly.