static void winToggleDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem) { int width, height, border = 4, check; HDC hDC; iupwinBitmapDC bmpDC; width = drawitem->rcItem.right - drawitem->rcItem.left; height = drawitem->rcItem.bottom - drawitem->rcItem.top; hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, width, height); iupwinDrawParentBackground(ih, hDC, &drawitem->rcItem); check = SendMessage(ih->handle, BM_GETCHECK, 0, 0L); if (check) drawitem->itemState |= ODS_SELECTED; else drawitem->itemState |= ODS_DEFAULT; /* use default mark for NOT checked */ iupwinDrawButtonBorder(ih->handle, hDC, &drawitem->rcItem, drawitem->itemState); winToggleDrawImage(ih, hDC, width, height, border, drawitem->itemState); if (drawitem->itemState & ODS_FOCUS) { border--; iupdrvDrawFocusRect(ih, hDC, border, border, width-2*border, height-2*border); } iupwinDrawDestroyBitmapDC(&bmpDC); }
static void winButtonDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem) { HDC hDC; iupwinBitmapDC bmpDC; int border, draw_border; int width = drawitem->rcItem.right - drawitem->rcItem.left; int height = drawitem->rcItem.bottom - drawitem->rcItem.top; hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, width, height); iupwinDrawParentBackground(ih, hDC, &drawitem->rcItem); if ((drawitem->itemState & ODS_FOCUS) && !(drawitem->itemState & ODS_HOTLIGHT)) drawitem->itemState |= ODS_DEFAULT; if (iupAttribGet(ih, "_IUPWINBUT_SELECTED")) drawitem->itemState |= ODS_SELECTED; border = winButtonGetBorder(); if ((ih->data->type & IUP_BUTTON_IMAGE) && iupAttribGet(ih, "IMPRESS") && !iupAttribGetBoolean(ih, "IMPRESSBORDER")) draw_border = 0; else { if (iupAttribGetBoolean(ih, "FLAT")) { if (drawitem->itemState & ODS_HOTLIGHT || iupAttribGet(ih, "_IUPWINBUT_ENTERWIN")) draw_border = 1; else draw_border = 0; } else draw_border = 1; } if (draw_border) iupwinDrawButtonBorder(ih->handle, hDC, &drawitem->rcItem, drawitem->itemState); if (ih->data->type == IUP_BUTTON_IMAGE) winButtonDrawImage(ih, hDC, width, height, border, drawitem->itemState); else if (ih->data->type == IUP_BUTTON_TEXT) winButtonDrawText(ih, hDC, width, height, border, drawitem->itemState); else /* both */ winButtonDrawImageText(ih, hDC, width, height, border, drawitem->itemState); if (drawitem->itemState & ODS_FOCUS && !(drawitem->itemState & ODS_NOFOCUSRECT) && iupAttribGetBoolean(ih, "CANFOCUS")) { border--; iupdrvDrawFocusRect(ih, hDC, border, border, width-2*border, height-2*border); } iupwinDrawDestroyBitmapDC(&bmpDC); }
static void winToggleDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem) { /* called only when (ih->data->type==IUP_TOGGLE_IMAGE && (iupwin_comctl32ver6 || ih->data->flat)) */ int width, height, border = 4, check, draw_border; HDC hDC; iupwinBitmapDC bmpDC; width = drawitem->rcItem.right - drawitem->rcItem.left; height = drawitem->rcItem.bottom - drawitem->rcItem.top; hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, 0, 0, width, height); iupwinDrawParentBackground(ih, hDC, &drawitem->rcItem); if (!iupwin_comctl32ver6) { if (drawitem->itemState&ODS_SELECTED) iupAttribSet(ih, "_IUPWIN_PRESSED", "1"); } check = winToggleGetCheck(ih); if (check) drawitem->itemState |= ODS_SELECTED; else drawitem->itemState |= ODS_DEFAULT; /* use default mark for NOT checked */ if (!check && ih->data->flat) { if (drawitem->itemState & ODS_HOTLIGHT || iupAttribGet(ih, "_IUPWINTOG_ENTERWIN")) draw_border = 1; else draw_border = 0; } else draw_border = 1; /* when checked, even if flat thr border is drawn */ if (draw_border) iupwinDrawButtonBorder(ih->handle, hDC, &drawitem->rcItem, drawitem->itemState); winToggleDrawImage(ih, hDC, width, height, border, drawitem->itemState); if (drawitem->itemState & ODS_FOCUS && !(drawitem->itemState & ODS_NOFOCUSRECT) && iupAttribGetBoolean(ih, "CANFOCUS")) { border--; iupdrvDrawFocusRect(ih, hDC, border, border, width-2*border, height-2*border); } iupwinDrawDestroyBitmapDC(&bmpDC); }