📄 icon.c
字号:
/*
** $Id: icon.c,v 1.24 2003/09/04 03:09:52 weiym Exp $
**
** icon.c Icon operations of GDI.
**
** Copyright (C) 2003 Feynman Software.
** Copyright (C) 2000 ~ 2002 Wei Yongming.
**
** Current maintainer: Wei Yongming.
**
** Create date: 2000/06/12, derived from original gdi.c
*/
/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
** TODO:
*/
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "minigui.h"
#include "gdi.h"
#include "window.h"
#include "cliprect.h"
#include "gal.h"
#include "internals.h"
#include "ctrlclass.h"
#include "dc.h"
#include "icon.h"
#include "cursor.h"
#include "readbmp.h"
extern BOOL dc_GenerateECRgn(PDC pdc, BOOL fForce);
/************************* Icon support **************************************/
#include "loadicon.c"
void GUIAPI DrawIcon(HDC hdc, int x, int y, int w, int h, HICON hicon)
{
PCLIPRECT pClipRect;
PDC pdc;
PICON picon = (PICON)hicon;
int i;
int imagesize;
BYTE* iconimage;
BYTE* andbits = NULL;
BYTE* xorbits = NULL;
RECT rcOutput;
pdc = dc_HDC2PDC(hdc);
if (dc_IsGeneralHDC(hdc)) {
pthread_mutex_lock (&pdc->pGCRInfo->lock);
if (!dc_GenerateECRgn (pdc, FALSE)) {
pthread_mutex_unlock (&pdc->pGCRInfo->lock);
return;
}
}
if(w <= 0) w = picon->width;
if(h <= 0) h = picon->height;
// Transfer logical to device to screen here.
w += x; h += y;
coor_LP2SP(pdc, &x, &y);
coor_LP2SP(pdc, &w, &h);
rcOutput.left = x;
rcOutput.top = y;
rcOutput.right = w;
rcOutput.bottom = h;
NormalizeRect (&rcOutput);
w = RECTW (rcOutput); h = RECTH (rcOutput);
pthread_mutex_lock (&__mg_gdilock);
IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);
GAL_SetGC (pdc->gc);
imagesize = w * h * GAL_BytesPerPixel (pdc->gc);
if ((iconimage = malloc (imagesize)) == NULL)
goto free_ret;
if (w != picon->width || h != picon->height) {
andbits = malloc (imagesize);
xorbits = malloc (imagesize);
if (andbits == NULL || xorbits == NULL)
goto free_ret;
GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->AndBits, w, h, andbits);
GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->XorBits, w, h, xorbits);
}
else {
andbits = picon->AndBits;
xorbits = picon->XorBits;
}
GAL_GetBox (pdc->gc, x, y, w, h, iconimage);
for(i = 0; i < imagesize; i++) {
iconimage[i] &= andbits [i];
iconimage[i] ^= xorbits [i];
}
pClipRect = pdc->ecrgn.head;
while (pClipRect) {
if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);
GAL_PutBox(pdc->gc, x, y, w, h, iconimage);
}
pClipRect = pClipRect->next;
}
free_ret:
if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput);
pthread_mutex_unlock (&__mg_gdilock);
if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);
free (iconimage);
if (w != picon->width || h != picon->height) {
free (andbits);
free (xorbits);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -