示例#1
0
BOOL RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk)
{
	MWHOTKEY *pHotkey;

	if (MwFindHotkey (id) || !(pHotkey = GdItemNew (MWHOTKEY)))
		return FALSE;
	pHotkey->hWnd        = hWnd;
	pHotkey->id          = id;
	pHotkey->fsModifiers = fsModifiers;
	pHotkey->vk          = vk;
	GdListAdd(&mwHotkeyHead, &pHotkey->link);

	return TRUE;
}
示例#2
0
BOOL WINAPI
SetProp(HWND hWnd, LPCSTR lpString, HANDLE hData)
{
	MWPROP *pProp;

	if (!(pProp = GdItemNew(MWPROP)))
		return FALSE;
	if (HIWORD(lpString))
		pProp->Atom = GlobalAddAtom(lpString);
	else
		pProp->Atom = LOWORD((DWORD)lpString);
	pProp->hData = hData;

	GdListAdd (&hWnd->props, &pProp->link);
	return TRUE;
}
示例#3
0
BOOL WINAPI
PostMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	MSG *	pMsg;

#if PAINTONCE
	/* don't queue paint msgs, set window paint status instead*/
	if(Msg == WM_PAINT) {
		hwnd->gotPaintMsg = PAINT_NEEDSPAINT;
		return TRUE;
	}
#endif
#if MOUSETEST
	/* replace multiple mouse messages with one for better mouse handling*/
	if(Msg == WM_MOUSEMOVE) {
		PMWLIST	p;
		for(p=mwMsgHead.head; p; p=p->next) {
			pMsg = GdItemAddr(p, MSG, link);
			if(pMsg->hwnd == hwnd && pMsg->message == Msg) {
				pMsg->wParam = wParam;
				pMsg->lParam = lParam;
				pMsg->time = GetTickCount();
				pMsg->pt.x = cursorx;
				pMsg->pt.y = cursory;
				return TRUE;
			}
		}
	}
#endif
	pMsg = GdItemNew(MSG);
	if(!pMsg)
		return FALSE;
	pMsg->hwnd = hwnd;
	pMsg->message = Msg;
	pMsg->wParam = wParam;
	pMsg->lParam = lParam;
	pMsg->time = GetTickCount();
	pMsg->pt.x = cursorx;
	pMsg->pt.y = cursory;
	GdListAdd(&mwMsgHead, &pMsg->link);
	return TRUE;
}
示例#4
0
ATOM WINAPI
RegisterClass(CONST WNDCLASS *lpWndClass)
{
	PWNDCLASS	pClass;

	/* check if already present*/
	pClass = MwFindClassByName(lpWndClass->lpszClassName);
	if(pClass)
		return 0;
	
	/* copy class into new struct*/
	pClass = GdItemNew(WNDCLASS);
	if(!pClass)
		return 0;
	*pClass = *lpWndClass;
	strcpy(pClass->szClassName, lpWndClass->lpszClassName);
	GdListAdd(&mwClassHead, &pClass->link);

	return 1;
}
示例#5
0
/*
 * GdDecodeImage:
 * @psd: Drawing surface.
 * @src: The image data.
 * @flags: If nonzero, JPEG images will be loaded as grayscale.  Yuck!
 *
 * Load an image.
 */
static int
GdDecodeImage(PSD psd, buffer_t * src, char *path, int flags)
{
        int         loadOK = 0;
        PMWIMAGEHDR pimage;
        PIMAGEITEM  pItem;

	/* allocate image struct*/
	pimage = (PMWIMAGEHDR)malloc(sizeof(MWIMAGEHDR));
	if(!pimage) {
		return 0;
	}
	pimage->imagebits = NULL;
	pimage->palette = NULL;
	pimage->transcolor = MWNOCOLOR;

#if defined(HAVE_TIFF_SUPPORT)
	/* must be first... no buffer support yet*/
	if (path)
		loadOK = GdDecodeTIFF(path, pimage);
#endif
#if defined(HAVE_BMP_SUPPORT)
	if (loadOK == 0) 
		loadOK = GdDecodeBMP(src, pimage);
#endif
#if defined(HAVE_GIF_SUPPORT)
	if (loadOK == 0) 
		loadOK = GdDecodeGIF(src, pimage);
#endif
#if defined(HAVE_JPEG_SUPPORT)
	if (loadOK == 0) 
		loadOK = GdDecodeJPEG(src, pimage, psd, flags);
#endif
#if defined(HAVE_PNG_SUPPORT)
	if (loadOK == 0) 
		loadOK = GdDecodePNG(src, pimage);
#endif
#if defined(HAVE_PNM_SUPPORT)
	if(loadOK == 0)
		loadOK = GdDecodePNM(src, pimage);
#endif
#if defined(HAVE_XPM_SUPPORT)
	if (loadOK == 0) 
		loadOK = GdDecodeXPM(src, pimage, psd);
#endif

	if (loadOK == 0) {
		EPRINTF("GdLoadImageFromFile: unknown image type\n");
		goto err;		/* image loading error*/
	}
	if (loadOK != 1)
		goto err;		/* image loading error*/

	/* allocate id*/
	pItem = GdItemNew(IMAGEITEM);
	if (!pItem)
		goto err;
	pItem->id = nextimageid++;
	pItem->pimage = pimage;
	pItem->psd = psd;
	if(!imagehead_initialized) {
		imagehead_initialized=1;
		memset(&imagehead,0,sizeof(imagehead));
	}
	GdListAdd(&imagehead, &pItem->link);

	return pItem->id;

err:
	free(pimage);
	return 0;			/* image loading error*/
}