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

[vim-multibyte] Tearoff Menu use font given from System.

Expand Messages
  • Yasuhiro Matsumoto
    If vim user want to use multibyte tearoff menu then they must change source gui_w32.c . Example.... From: #define DLG_FONT_NAME MS Sans Serif To: #define
    Message 1 of 4 , Jan 23, 2000
    • 0 Attachment
      If vim user want to use multibyte tearoff menu
      then they must change source "gui_w32.c".

      Example....

      From:
      #define DLG_FONT_NAME "MS Sans Serif"
      To:
      #define DLG_FONT_NAME .... (possible font)

      see screenshot

      Original tearoff menu (japanesed)
      http://www.cis-net.co.jp/matsu/vim/work/original.jpg
      Patched tearoff menu (japanesed)
      http://www.cis-net.co.jp/matsu/vim/work/patched.jpg

      So I made patch.
      I think that this patch support multilingual.
      And if you change the system property of menu
      then vim change too.
      (but you must tear off the menu.)

      ----------------------------------------
      Problem: Tearoff menu possible use font that everyone doesn't have.
      Solution: Tearoff menu use font given from system.
      Files: src/gui_w32.c src/proto/gui_w32.pro

      *** src/gui_w32.c.orig Mon Jan 17 01:42:02 2000
      --- src/gui_w32.c Mon Jan 24 12:53:04 2000
      ***************
      *** 162,167 ****
      --- 162,169 ----
      static LOGFONT norm_logfont;
      #endif
      #endif
      + /* Use System Menu Font */
      + #define USE_SYSMENU_FONT

      /* Local variables: */
      static int s_button_pending = -1;
      ***************
      *** 2641,2647 ****
      if (font_name == NULL)
      font_name = lf.lfFaceName;
      #ifdef MULTI_BYTE_IME
      ! get_logfont(&norm_logfont, font_name);
      #endif
      gui_mch_free_font(gui.norm_font);
      gui.norm_font = font;
      --- 2643,2650 ----
      if (font_name == NULL)
      font_name = lf.lfFaceName;
      #ifdef MULTI_BYTE_IME
      ! //get_logfont(&norm_logfont, font_name);
      ! mch_memmove(&norm_logfont, &lf, sizeof(LOGFONT));
      #endif
      gui_mch_free_font(gui.norm_font);
      gui.norm_font = font;
      ***************
      *** 4613,4618 ****
      --- 4616,4635 ----
      "IDR_VIM_QUESTION"
      };

      + #ifdef USE_SYSMENU_FONT
      + /*
      + * Get Menu Font
      + */
      + LOGFONT*
      + gui_w32_get_menu_font()
      + {
      + static NONCLIENTMETRICS nm;
      + nm.cbSize = sizeof (NONCLIENTMETRICS);
      + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(
      NONCLIENTMETRICS ), &nm, 0);
      + return &(nm.lfMenuFont);
      + }
      + #endif
      +
      int
      gui_mch_dialog(
      int type,
      ***************
      *** 4643,4648 ****
      --- 4660,4668 ----
      int vertical;
      int dlgPaddingX;
      int dlgPaddingY;
      + #ifdef USE_SYSMENU_FONT
      + LOGFONT *sysmenu_logfont = NULL;
      + #endif

      #ifndef NO_CONSOLE
      /* Don't output anything in silent mode ("ex -s") */
      ***************
      *** 4700,4707 ****
      --- 4720,4732 ----
      */
      hwnd = GetDesktopWindow();
      hdc = GetWindowDC(hwnd);
      + #ifndef USE_SYSMENU_FONT
      font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0,
      VARIABLE_PITCH , DLG_FONT_NAME);
      + #else
      + sysmenu_logfont = gui_w32_get_menu_font();
      + font = CreateFontIndirect(sysmenu_logfont);
      + #endif
      if (s_usenewlook)
      {
      oldFont = SelectFont(hdc, font);
      ***************
      *** 4837,4845 ****
      --- 4862,4877 ----
      if (s_usenewlook)
      {
      /* do the font, since DS_3DLOOK doesn't work properly */
      + #ifndef USE_SYSMENU_FONT
      *p++ = DLG_FONT_POINT_SIZE; //point size
      nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
      p += nchar;
      + #else
      + /* point size */
      + *p++ = -MulDiv(sysmenu_logfont->lfHeight, 72, GetDeviceCaps(hdc,
      LOGPIXELSY));
      + nchar = nCopyAnsiToWideChar (p, TEXT(sysmenu_logfont->lfFaceName));
      + p += nchar;
      + #endif
      }

      pstart = tbuffer;
      ***************
      *** 5182,5187 ****
      --- 5214,5222 ----
      char_u *label, *text, *end, *acEnd;
      int padding0, padding1, padding2;
      int sepPadding=0;
      + #ifdef USE_SYSMENU_FONT
      + LOGFONT *sysmenu_logfont = NULL;
      + #endif

      /*
      * If this menu is already torn off, then don't
      ***************
      *** 5215,5222 ****
      --- 5250,5262 ----

      hwnd = GetDesktopWindow();
      hdc = GetWindowDC(hwnd);
      + #ifndef USE_SYSMENU_FONT
      font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0,
      VARIABLE_PITCH , DLG_FONT_NAME);
      + #else
      + sysmenu_logfont = gui_w32_get_menu_font();
      + font = CreateFontIndirect(sysmenu_logfont);
      + #endif
      if (s_usenewlook)
      oldFont = SelectFont(hdc, font);
      else
      ***************
      *** 5315,5323 ****
      --- 5355,5370 ----
      if (s_usenewlook)
      {
      /* do the font, since DS_3DLOOK doesn't work properly */
      + #ifndef USE_SYSMENU_FONT
      *p++ = DLG_FONT_POINT_SIZE; //point size
      nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
      p += nchar;
      + #else
      + /* point size */
      + *p++ = -MulDiv(sysmenu_logfont->lfHeight, 72, GetDeviceCaps(hdc,
      LOGPIXELSY));
      + nchar = nCopyAnsiToWideChar (p, TEXT(sysmenu_logfont->lfFaceName));
      + p += nchar;
      + #endif
      }

      /* Don't include tearbar in tearoff menu */
      ***************
      *** 5447,5452 ****
      --- 5494,5502 ----
      HFONT hfontTools = 0;
      DWORD dlgFontSize;
      SIZE size;
      + #ifdef USE_SYSMENU_FONT
      + LOGFONT *sysmenu_logfont = NULL;
      + #endif

      s_usenewlook = FALSE;

      ***************
      *** 5456,5463 ****
      --- 5506,5518 ----
      */
      if (!is_winnt_3())
      {
      + #ifndef USE_SYSMENU_FONT
      hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME);
      + #else
      + sysmenu_logfont = gui_w32_get_menu_font();
      + hfontTools = CreateFontIndirect(sysmenu_logfont);
      + #endif

      if (hfontTools)
      {
      *** src/proto/gui_w32.pro.orig Mon Jan 24 12:59:07 2000
      --- src/proto/gui_w32.pro Mon Jan 24 12:59:53 2000
      ***************
      *** 67,69 ****
      --- 67,70 ----
      void gui_mch_find_dialog __ARGS((char_u *arg));
      void gui_mch_replace_dialog __ARGS((char_u *arg));
      void gui_mch_mousehide __ARGS((int hide));
      + LOGFONT* gui_get_sysmenu_logfont __ARGS((void));
    • Bram Moolenaar
      ... This is quite a big patch. It looks OK to me, but I can t test it properly on my USA Windows. Please let me know if this works OK for you and perhaps
      Message 2 of 4 , Jan 24, 2000
      • 0 Attachment
        Yasuhiro Matsumoto wrote:
        > If vim user want to use multibyte tearoff menu
        > then they must change source "gui_w32.c".
        >
        > Example....
        >
        > From:
        > #define DLG_FONT_NAME "MS Sans Serif"
        > To:
        > #define DLG_FONT_NAME .... (possible font)
        >
        > see screenshot
        >
        > Original tearoff menu (japanesed)
        > http://www.cis-net.co.jp/matsu/vim/work/original.jpg
        > Patched tearoff menu (japanesed)
        > http://www.cis-net.co.jp/matsu/vim/work/patched.jpg
        >
        > So I made patch.
        > I think that this patch support multilingual.
        > And if you change the system property of menu
        > then vim change too.
        > (but you must tear off the menu.)

        This is quite a big patch. It looks OK to me, but I can't test it properly on
        my USA Windows. Please let me know if this works OK for you and perhaps
        suggest improvements.

        --
        FATHER: Did you kill all those guards?
        LAUNCELOT: Yes ... I'm very sorry ...
        FATHER: They cost fifty pounds each!
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /-/-- Bram Moolenaar --- Bram@... --- http://www.moolenaar.net --\-\
        \ \ Vim: http://www.vim.org ICCF Holland: http://www.vim.org/iccf / /
      • Taro Muraoka
        I tested it. It is nice. But I have three questions. First. Is this a problem of only multibyte users? It seems be a more global problem that tear-off menu is
        Message 3 of 4 , Jan 24, 2000
        • 0 Attachment
          I tested it. It is nice. But I have three questions.

          First. Is this a problem of only multibyte users? It seems be a more global
          problem that tear-off menu is not affected by system property. But I don't
          know user (not only multibyte) would want to change font of tear-off menu.

          Yasuhiro Matsumoto wrote:
          > + LOGFONT*
          > + gui_w32_get_menu_font()
          > + {
          > + static NONCLIENTMETRICS nm;

          Second. Why is this function declared 'global'. It is OK to declare 'static'
          isn't it?. If there is no need to declare global, nor be necessary to
          change src/proto/gui_w32.pro.

          Third. Why is 'nm' static. It seems better to take one argument pointer of
          LOGFONT and to copy value of LOGFONT to that pointer.

          I revise patch below. It make from 5.6.08 source code. How about this?.
          ----
          Taro Muraoka <koron@...>


          *** gui_w32.c.orig Mon Jan 24 07:38:16 2000
          --- gui_w32.c Tue Jan 25 00:23:38 2000
          ***************
          *** 155,160 ****
          --- 155,161 ----
          #ifndef WM_MOUSEWHEEL
          #define WM_MOUSEWHEEL 0x20a
          #endif
          + #define USE_SYSMENU_FONT

          #ifdef MULTI_BYTE
          static int sysfixed_width = 0;
          ***************
          *** 4638,4643 ****
          --- 4639,4664 ----
          "IDR_VIM_QUESTION"
          };

          + #ifdef USE_SYSMENU_FONT
          + /*
          + * Get Menu Font
          + */
          + static int
          + gui_w32_get_menu_font(LOGFONT *lf)
          + {
          + NONCLIENTMETRICS nm;
          + nm.cbSize = sizeof(NONCLIENTMETRICS);
          + if (!SystemParametersInfo(
          + SPI_GETNONCLIENTMETRICS,
          + sizeof(NONCLIENTMETRICS),
          + &nm,
          + 0))
          + return 0;
          + *lf = nm.lfMenuFont;
          + return 0;
          + }
          + #endif
          +
          int
          gui_mch_dialog(
          int type,
          ***************
          *** 4668,4673 ****
          --- 4689,4697 ----
          int vertical;
          int dlgPaddingX;
          int dlgPaddingY;
          + #ifdef USE_SYSMENU_FONT
          + LOGFONT lfSysmenu;
          + #endif

          #ifndef NO_CONSOLE
          /* Don't output anything in silent mode ("ex -s") */
          ***************
          *** 4725,4732 ****
          --- 4749,4761 ----
          */
          hwnd = GetDesktopWindow();
          hdc = GetWindowDC(hwnd);
          + #ifdef USE_SYSMENU_FONT
          + gui_w32_get_menu_font(&lfSysmenu);
          + font = CreateFontIndirect(&lfSysmenu);
          + #else
          font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          VARIABLE_PITCH , DLG_FONT_NAME);
          + #endif
          if (s_usenewlook)
          {
          oldFont = SelectFont(hdc, font);
          ***************
          *** 4862,4869 ****
          --- 4891,4905 ----
          if (s_usenewlook)
          {
          /* do the font, since DS_3DLOOK doesn't work properly */
          + #ifdef USE_SYSMENU_FONT
          + /* point size */
          + *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
          + GetDeviceCaps(hdc, LOGPIXELSY));
          + nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
          + #else
          *p++ = DLG_FONT_POINT_SIZE; //point size
          nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
          + #endif
          p += nchar;
          }

          ***************
          *** 5207,5212 ****
          --- 5243,5251 ----
          char_u *label, *text, *end, *acEnd;
          int padding0, padding1, padding2;
          int sepPadding=0;
          + #ifdef USE_SYSMENU_FONT
          + LOGFONT lfSysmenu;
          + #endif

          /*
          * If this menu is already torn off, then don't
          ***************
          *** 5240,5247 ****
          --- 5279,5291 ----

          hwnd = GetDesktopWindow();
          hdc = GetWindowDC(hwnd);
          + #ifdef USE_SYSMENU_FONT
          + gui_w32_get_menu_font(&lfSysmenu);
          + font = CreateFontIndirect(&lfSysmenu);
          + #else
          font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          VARIABLE_PITCH , DLG_FONT_NAME);
          + #endif
          if (s_usenewlook)
          oldFont = SelectFont(hdc, font);
          else
          ***************
          *** 5340,5347 ****
          --- 5384,5398 ----
          if (s_usenewlook)
          {
          /* do the font, since DS_3DLOOK doesn't work properly */
          + #ifdef USE_SYSMENU_FONT
          + /* point size */
          + *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
          + GetDeviceCaps(hdc, LOGPIXELSY));
          + nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
          + #else
          *p++ = DLG_FONT_POINT_SIZE; //point size
          nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
          + #endif
          p += nchar;
          }

          ***************
          *** 5472,5477 ****
          --- 5523,5531 ----
          HFONT hfontTools = 0;
          DWORD dlgFontSize;
          SIZE size;
          + #ifdef USE_SYSMENU_FONT
          + LOGFONT lfSysmenu;
          + #endif

          s_usenewlook = FALSE;

          ***************
          *** 5481,5488 ****
          */
          if (!is_winnt_3())
          {
          hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
          ! 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME);

          if (hfontTools)
          {
          --- 5535,5547 ----
          */
          if (!is_winnt_3())
          {
          + #ifdef USE_SYSMENU_FONT
          + gui_w32_get_menu_font(&lfSysmenu);
          + hfontTools = CreateFontIndirect(&lfSysmenu);
          + #else
          hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
          ! 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME);
          ! #endif

          if (hfontTools)
          {
        • Yasuhiro Matsumoto
          Hi Taro , Bram , All - ... I thought so. But already Vim is not a program for only singlebyte users. You should know the mean of existing vim-multibyte . ...
          Message 4 of 4 , Jan 24, 2000
          • 0 Attachment
            Hi Taro , Bram , All -

            Taro Muraoka wrote:
            > First. Is this a problem of only multibyte users?

            I thought so.
            But already Vim is not a program for only singlebyte users.
            You should know the mean of existing "vim-multibyte".

            > It seems be a more global problem that tear-off menu is not
            > affected by system property.
            > But I don't know user (not only multibyte) would want to change
            > font of tear-off menu.

            So I leaved original source.( used USE_SYSMENU_FONT )
            I don't mind that Bram change the define to comment.

            > Second. Why is this function declared 'global'. It is OK to declare 'static'
            > isn't it?. If there is no need to declare global, nor be necessary to
            > change src/proto/gui_w32.pro.

            I misstaked.

            > Third. Why is 'nm' static. It seems better to take one argument pointer of
            > LOGFONT and to copy value of LOGFONT to that pointer.

            I would declare 'sysmenu_font' to 'global'.
            and call only once.

            Thanks your advice. :-)
          Your message has been successfully submitted and would be delivered to recipients shortly.