Mercurial > dwindows
comparison win/dw.c @ 1721:8c98c8525918
Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 14 May 2012 09:07:49 +0000 |
parents | 47e322354293 |
children | d9849833e535 |
comparison
equal
deleted
inserted
replaced
1720:47e322354293 | 1721:8c98c8525918 |
---|---|
750 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); | 750 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); |
751 | 751 |
752 if(oldbitmap) | 752 if(oldbitmap) |
753 DeleteObject(oldbitmap); | 753 DeleteObject(oldbitmap); |
754 } | 754 } |
755 #ifdef TOOLBAR | |
756 /* Bitmap Buttons */ | |
757 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) | |
758 { | |
759 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0); | |
760 | |
761 if(imlist) | |
762 ImageList_Destroy(imlist); | |
763 } | |
764 #endif | |
755 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) | 765 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0) |
756 { | 766 { |
757 Box *box = (Box *)thiscinfo; | 767 Box *box = (Box *)thiscinfo; |
758 | 768 |
759 if(box && box->count && box->items) | 769 if(box && box->count && box->items) |
4604 { | 4614 { |
4605 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); | 4615 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); |
4606 thiswidth = 50; | 4616 thiswidth = 50; |
4607 extraheight = 6; | 4617 extraheight = 6; |
4608 } | 4618 } |
4619 #ifdef TOOLBAR | |
4620 /* Bitmap Buttons */ | |
4621 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) | |
4622 { | |
4623 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0); | |
4624 | |
4625 if(imlist) | |
4626 ImageList_GetIconSize(imlist, &thiswidth, &thisheight); | |
4627 } | |
4628 #endif | |
4609 /* Listbox */ | 4629 /* Listbox */ |
4610 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0) | 4630 else if(_tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1) == 0) |
4611 { | 4631 { |
4612 char buf[1025] = {0}; | 4632 char buf[1025] = {0}; |
4613 int x, count = dw_listbox_count(handle); | 4633 int x, count = dw_listbox_count(handle); |
6121 HWND API dw_bitmapbutton_new(char *text, ULONG id) | 6141 HWND API dw_bitmapbutton_new(char *text, ULONG id) |
6122 { | 6142 { |
6123 HWND tmp; | 6143 HWND tmp; |
6124 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 6144 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
6125 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0); | 6145 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0); |
6126 #ifdef GDIPLUS1 | 6146 #ifdef TOOLBAR |
6127 HBITMAP hbitmap; | 6147 HIMAGELIST imlist; |
6128 TBADDBITMAP tbBitmaps = {0}; | 6148 BITMAP bmi = { 0 }; |
6129 TBBUTTON tbButtons[] = { | 6149 TBBUTTON tbButtons[] = { |
6130 { 0, id, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, 0} | 6150 { MAKELONG(0, 0), id, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, 0} |
6131 }; | 6151 }; |
6132 | 6152 |
6133 /* Get the bitmap from either the icon or bitmap itself */ | 6153 /* Get the bitmap from either the icon or bitmap itself */ |
6134 if(!icon) | 6154 if(!icon) |
6135 hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); | 6155 { |
6156 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); | |
6157 | |
6158 GetObject(hbitmap, sizeof(BITMAP), &bmi); | |
6159 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLORDDB | ILC_MASK, 1, 0); | |
6160 ImageList_Add(imlist, hbitmap, NULL); | |
6161 } | |
6136 else | 6162 else |
6137 { | 6163 { |
6138 ICONINFO iconinfo; | 6164 ICONINFO iconinfo; |
6139 | 6165 |
6140 GetIconInfo(icon, &iconinfo); | 6166 GetIconInfo(icon, &iconinfo); |
6141 hbitmap = iconinfo.hbmColor; | 6167 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi); |
6168 imlist = ImageList_Create(bmi.bmWidth, bmi.bmHeight, ILC_COLORDDB | ILC_MASK, 1, 0); | |
6169 ImageList_AddIcon(imlist, icon); | |
6142 } | 6170 } |
6143 | 6171 |
6144 /* Create the toolbar */ | 6172 /* Create the toolbar */ |
6145 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_NORESIZE | CCS_NOPARENTALIGN, | 6173 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_NORESIZE | CCS_NOPARENTALIGN, |
6146 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)id, DWInstance, NULL); | 6174 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)id, DWInstance, NULL); |
6147 | 6175 |
6148 cinfo->fore = cinfo->back = -1; | 6176 cinfo->fore = cinfo->back = -1; |
6149 | 6177 |
6150 /* Insert the single bitmap and button into the toolbar */ | 6178 /* Insert the single bitmap and button into the toolbar */ |
6151 SendMessage(tmp, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); | 6179 SendMessage(tmp, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); |
6152 tbBitmaps.nID = (UINT_PTR)hbitmap; | 6180 SendMessage(tmp, TB_SETIMAGELIST, 0, (LPARAM)imlist); |
6153 SendMessage(tmp, TB_ADDBITMAP, 1, (LONG) &tbBitmaps); | |
6154 SendMessage(tmp, TB_ADDBUTTONS, 1, (LONG) &tbButtons); | 6181 SendMessage(tmp, TB_ADDBUTTONS, 1, (LONG) &tbButtons); |
6155 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | 6182 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); |
6156 | 6183 |
6157 _create_tooltip(tmp, text); | 6184 _create_tooltip(tmp, text); |
6158 #else | 6185 #else |
6159 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); | 6186 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); |
6160 | 6187 |
6161 tmp = CreateWindow(BUTTONCLASSNAME, | 6188 tmp = CreateWindow(BUTTONCLASSNAME, |
7464 GetClassName(handle, tmpbuf, 99); | 7491 GetClassName(handle, tmpbuf, 99); |
7465 | 7492 |
7466 currentstyle = GetWindowLong(handle, GWL_STYLE); | 7493 currentstyle = GetWindowLong(handle, GWL_STYLE); |
7467 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 7494 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
7468 | 7495 |
7496 #ifdef TOOLBAR | |
7497 /* Bitmap Buttons */ | |
7498 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0) | |
7499 { | |
7500 ULONG thisstyle = (TBSTYLE_FLAT | TBSTYLE_TRANSPARENT); | |
7501 | |
7502 if(mask & DW_BS_NOBORDER) | |
7503 { | |
7504 SetWindowLong(handle, GWL_STYLE, (style & DW_BS_NOBORDER) ? (currentstyle | thisstyle) : (currentstyle & ~thisstyle)); | |
7505 return; | |
7506 } | |
7507 } | |
7508 #endif | |
7509 | |
7469 tmp = currentstyle | mask; | 7510 tmp = currentstyle | mask; |
7470 tmp ^= mask; | 7511 tmp ^= mask; |
7471 tmp |= style; | 7512 tmp |= style; |
7472 | 7513 |
7473 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) | 7514 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) |