To: vim-dev@vim.org Subject: Patch 6.0.161 (extra) Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.161 Problem: Win32: Bitmaps don't work with signs. Solution: Make it possible to use bitmaps with signs. (Muraoka Taro) Files: src/ex_cmds.c, src/feature.h, src/gui_w32.c, src/gui_x11.c, src/proto/gui_w32.pro, src/proto/gui_x11.pro *** ../vim60.160/src/ex_cmds.c Thu Jan 10 20:17:24 2002 --- src/ex_cmds.c Sat Feb 2 21:55:07 2002 *************** *** 5064,5070 **** char_u *sn_name; /* name of sign */ char_u *sn_icon; /* name of pixmap */ #ifdef FEAT_SIGN_ICONS ! XImage *sn_image; /* icon image */ #endif char_u *sn_text; /* text used instead of pixmap */ int sn_line_hl; /* highlight ID for line */ --- 5064,5070 ---- char_u *sn_name; /* name of sign */ char_u *sn_icon; /* name of pixmap */ #ifdef FEAT_SIGN_ICONS ! void *sn_image; /* icon image */ #endif char_u *sn_text; /* text used instead of pixmap */ int sn_line_hl; /* highlight ID for line */ *************** *** 5565,5571 **** for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_typenr == typenr) ! return (void *)sp->sn_image; return NULL; } #endif --- 5565,5571 ---- for (sp = first_sign; sp != NULL; sp = sp->sn_next) if (sp->sn_typenr == typenr) ! return sp->sn_image; return NULL; } #endif *** ../vim60.160/src/feature.h Tue Jan 22 16:39:07 2002 --- src/feature.h Sat Feb 2 22:00:58 2002 *************** *** 1064,1071 **** */ #if defined(FEAT_BIG) || defined(FEAT_SUN_WORKSHOP) # define FEAT_SIGNS ! # if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \ ! && defined(HAVE_X11_XPM_H) # define FEAT_SIGN_ICONS # endif #endif --- 1064,1072 ---- */ #if defined(FEAT_BIG) || defined(FEAT_SUN_WORKSHOP) # define FEAT_SIGNS ! # if ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \ ! && defined(HAVE_X11_XPM_H)) \ ! || (defined(WIN32) && defined(FEAT_GUI)) # define FEAT_SIGN_ICONS # endif #endif *** ../vim60.160/src/gui_w32.c Tue Jan 1 23:08:31 2002 --- src/gui_w32.c Sat Feb 2 21:59:29 2002 *************** *** 3387,3390 **** --- 3387,3513 ---- } # endif + #endif + + #if defined(FEAT_SIGN_ICONS) || defined(PROTO) + typedef struct _signicon_t + { + HANDLE hImage; + UINT uType; + } signicon_t; + + void + gui_mch_drawsign(row, col, typenr) + int row; + int col; + int typenr; + { + signicon_t *sign; + int x, y, w, h; + + if (!gui.in_use || (sign = (signicon_t *)sign_get_image(typenr)) == NULL) + return; + + x = TEXT_X(col); + y = TEXT_Y(row); + w = gui.char_width * 2; + h = gui.char_height; + switch (sign->uType) + { + case IMAGE_BITMAP: + { + HDC hdcMem; + HBITMAP hbmpOld; + + hdcMem = CreateCompatibleDC(s_hdc); + hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hImage); + BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCCOPY); + SelectObject(hdcMem, hbmpOld); + DeleteDC(hdcMem); + } + break; + case IMAGE_ICON: + case IMAGE_CURSOR: + DrawIconEx(s_hdc, x, y, (HICON)sign->hImage, w, h, 0, NULL, DI_NORMAL); + break; + } + } + + static void + close_signicon_image(signicon_t *sign) + { + if (sign) + switch (sign->uType) + { + case IMAGE_BITMAP: + DeleteObject((HGDIOBJ)sign->hImage); + break; + case IMAGE_CURSOR: + DestroyCursor((HCURSOR)sign->hImage); + break; + case IMAGE_ICON: + DestroyIcon((HICON)sign->hImage); + break; + } + } + + void * + gui_mch_register_sign(signfile) + char_u *signfile; + { + signicon_t sign, *psign; + char_u *ext; + + if (is_winnt_3()) + { + /* TODO: May be changed this message */ + EMSG(_("E255: Couldn't read in sign data!")); + return NULL; + } + + sign.hImage = NULL; + ext = signfile + STRLEN(signfile) - 4; /* get extention */ + if (ext > signfile) + { + int do_load = 1; + + if (!STRICMP(ext, ".bmp")) + sign.uType = IMAGE_BITMAP; + else if (!STRICMP(ext, ".ico")) + sign.uType = IMAGE_ICON; + else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani")) + sign.uType = IMAGE_CURSOR; + else + do_load = 0; + + if (do_load) + sign.hImage = (HANDLE)LoadImage(NULL, signfile, sign.uType, + gui.char_width * 2, gui.char_height, + LR_LOADFROMFILE | LR_CREATEDIBSECTION); + } + + psign = NULL; + if (sign.hImage && (psign = (signicon_t *)alloc(sizeof(signicon_t)))) + *psign = sign; + + if (!psign) + { + if (sign.hImage) + close_signicon_image(&sign); + EMSG(_("E255: Couldn't read in sign data!")); + } + return (void *)psign; + + } + + void + gui_mch_destroy_sign(sign) + void *sign; + { + if (sign) + { + close_signicon_image((signicon_t *)sign); + vim_free(sign); + } + } #endif *** ../vim60.160/src/gui_x11.c Wed Sep 26 16:15:32 2001 --- src/gui_x11.c Sat Feb 2 21:52:29 2002 *************** *** 3210,3216 **** } } ! XImage * gui_mch_register_sign(signfile) char_u *signfile; { --- 3210,3216 ---- } } ! void * gui_mch_register_sign(signfile) char_u *signfile; { *************** *** 3259,3272 **** } } ! return sign; } void gui_mch_destroy_sign(sign) ! XImage *sign; { ! XFree(sign->data); vim_free(sign); } #endif --- 3259,3272 ---- } } ! return (void *)sign; } void gui_mch_destroy_sign(sign) ! void *sign; { ! XFree(((XImage *)sign)->data); vim_free(sign); } #endif *** ../vim60.160/src/proto/gui_w32.pro Tue Sep 25 21:49:31 2001 --- src/proto/gui_w32.pro Sat Feb 2 22:11:29 2002 *************** *** 74,77 **** --- 74,80 ---- void gui_mch_menu_grey __ARGS((vimmenu_T *menu, int grey)); int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield)); void gui_mch_set_foreground __ARGS((void)); + void gui_mch_drawsign __ARGS((int row, int col, int typenr)); + void *gui_mch_register_sign __ARGS((char_u *signfile)); + void gui_mch_destroy_sign __ARGS((void *sign)); /* vim: set ft=c : */ *** ../vim60.160/src/proto/gui_x11.pro Tue Sep 25 21:49:30 2001 --- src/proto/gui_x11.pro Sat Feb 2 22:06:55 2002 *************** *** 61,68 **** void gui_mch_setmouse __ARGS((int x, int y)); XButtonPressedEvent *gui_x11_get_last_mouse_event __ARGS((void)); void gui_mch_drawsign __ARGS((int row, int col, int typenr)); ! XImage *gui_mch_register_sign __ARGS((char_u *signfile)); ! void gui_mch_destroy_sign __ARGS((XImage *sign)); void gui_mch_mousehide __ARGS((int hide)); void mch_set_mouse_shape __ARGS((int shape)); void get_toolbar_pixmap __ARGS((vimmenu_T *menu, Pixmap *sen, Pixmap *insen)); --- 61,68 ---- void gui_mch_setmouse __ARGS((int x, int y)); XButtonPressedEvent *gui_x11_get_last_mouse_event __ARGS((void)); void gui_mch_drawsign __ARGS((int row, int col, int typenr)); ! void *gui_mch_register_sign __ARGS((char_u *signfile)); ! void gui_mch_destroy_sign __ARGS((void *sign)); void gui_mch_mousehide __ARGS((int hide)); void mch_set_mouse_shape __ARGS((int shape)); void get_toolbar_pixmap __ARGS((vimmenu_T *menu, Pixmap *sen, Pixmap *insen)); *** ../vim60.160/src/version.c Fri Feb 1 20:29:26 2002 --- src/version.c Sat Feb 2 22:12:13 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 161, /**/ -- hundred-and-one symptoms of being an internet addict: 164. You got out to buy software, instead of going out for a beer. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///