mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
a396029270
standard Windows names.
336 lines
6.4 KiB
C
336 lines
6.4 KiB
C
/*
|
|
* Animation control
|
|
*
|
|
* Copyright 1998 Eric Kohl
|
|
*
|
|
* NOTES
|
|
* This is just a dummy control. An author is needed! Any volunteers?
|
|
* I will only improve this control once in a while.
|
|
* Eric <ekohl@abo.rhein-zeitung.de>
|
|
*
|
|
* TODO:
|
|
* - All messages.
|
|
* - All notifications.
|
|
*/
|
|
|
|
|
|
#include "win.h"
|
|
#include "commctrl.h"
|
|
#include "animate.h"
|
|
#include "debug.h"
|
|
|
|
#define ANIMATE_GetInfoPtr(wndPtr) ((ANIMATE_INFO *)wndPtr->wExtra[0])
|
|
|
|
|
|
static BOOL
|
|
ANIMATE_LoadResA (ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName)
|
|
{
|
|
HRSRC hrsrc;
|
|
HGLOBAL handle;
|
|
|
|
hrsrc = FindResourceA (hInst, lpName, "AVI");
|
|
if (!hrsrc)
|
|
return FALSE;
|
|
|
|
handle = LoadResource (hInst, hrsrc);
|
|
if (!handle)
|
|
return FALSE;
|
|
|
|
infoPtr->lpAvi = LockResource (handle);
|
|
if (!infoPtr->lpAvi)
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static BOOL
|
|
ANIMATE_LoadFileA (ANIMATE_INFO *infoPtr, LPSTR lpName)
|
|
{
|
|
HANDLE handle;
|
|
|
|
infoPtr->hFile =
|
|
CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
|
|
FILE_ATTRIBUTE_NORMAL, 0);
|
|
if (!infoPtr->hFile)
|
|
return FALSE;
|
|
|
|
handle =
|
|
CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT,
|
|
0, 0, NULL);
|
|
if (!handle) {
|
|
CloseHandle (infoPtr->hFile);
|
|
infoPtr->hFile = 0;
|
|
return FALSE;
|
|
}
|
|
|
|
infoPtr->lpAvi = MapViewOfFile (handle, FILE_MAP_READ, 0, 0, 0);
|
|
if (!infoPtr->lpAvi) {
|
|
CloseHandle (infoPtr->hFile);
|
|
infoPtr->hFile = 0;
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static VOID
|
|
ANIMATE_Free (ANIMATE_INFO *infoPtr)
|
|
{
|
|
if (infoPtr->hFile) {
|
|
UnmapViewOfFile (infoPtr->lpAvi);
|
|
CloseHandle (infoPtr->hFile);
|
|
infoPtr->lpAvi = NULL;
|
|
}
|
|
else {
|
|
GlobalFree ((HGLOBAL)infoPtr->lpAvi);
|
|
infoPtr->lpAvi = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
static VOID
|
|
ANIMATE_GetAviInfo (infoPtr)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
ANIMATE_OpenA (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
|
|
HINSTANCE hInstance = (HINSTANCE)wParam;
|
|
|
|
ANIMATE_Free (infoPtr);
|
|
|
|
if (!lParam) {
|
|
TRACE (animate, "closing avi!\n");
|
|
return TRUE;
|
|
}
|
|
|
|
if (HIWORD(lParam)) {
|
|
FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
|
|
|
|
if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) {
|
|
|
|
FIXME (animate, "AVI resource found!\n");
|
|
|
|
}
|
|
else {
|
|
FIXME (animate, "No AVI resource found!\n");
|
|
if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) {
|
|
FIXME (animate, "AVI file found!\n");
|
|
}
|
|
else {
|
|
FIXME (animate, "No AVI file found!\n");
|
|
return FALSE;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
|
|
|
|
if (ANIMATE_LoadResA (infoPtr, hInstance,
|
|
MAKEINTRESOURCEA((INT)lParam))) {
|
|
FIXME (animate, "AVI resource found!\n");
|
|
}
|
|
else {
|
|
FIXME (animate, "No AVI resource found!\n");
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
ANIMATE_GetAviInfo (infoPtr);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/* << ANIMATE_Open32W >> */
|
|
|
|
|
|
static LRESULT
|
|
ANIMATE_Play (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
/* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
|
|
INT nFrom = (INT)LOWORD(lParam);
|
|
INT nTo = (INT)HIWORD(lParam);
|
|
INT nRepeat = (INT)wParam;
|
|
|
|
#if 0
|
|
/* nothing opened */
|
|
if (...)
|
|
return FALSE;
|
|
#endif
|
|
|
|
if (nRepeat == -1) {
|
|
|
|
FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
|
|
nFrom, nTo);
|
|
|
|
}
|
|
else {
|
|
|
|
FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
|
|
nRepeat, nFrom, nTo);
|
|
|
|
}
|
|
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
ANIMATE_Stop (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
/* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
|
|
|
|
#if 0
|
|
/* nothing opened */
|
|
if (...)
|
|
return FALSE;
|
|
#endif
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
|
ANIMATE_Create (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
ANIMATE_INFO *infoPtr;
|
|
|
|
/* allocate memory for info structure */
|
|
infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO));
|
|
wndPtr->wExtra[0] = (DWORD)infoPtr;
|
|
|
|
if (infoPtr == NULL) {
|
|
ERR (animate, "could not allocate info memory!\n");
|
|
return 0;
|
|
}
|
|
|
|
if ((ANIMATE_INFO*)wndPtr->wExtra[0] != infoPtr) {
|
|
ERR (animate, "pointer assignment error!\n");
|
|
return 0;
|
|
}
|
|
|
|
/* set default settings */
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
static LRESULT
|
|
ANIMATE_Destroy (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
|
|
|
|
|
|
/* free avi data */
|
|
ANIMATE_Free (infoPtr);
|
|
|
|
/* free animate info data */
|
|
COMCTL32_Free (infoPtr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
#if 0
|
|
static LRESULT
|
|
ANIMATE_EraseBackground (WND *wndPtr, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
|
|
/*
|
|
HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
|
|
RECT32 rect;
|
|
|
|
GetClientRect32 (wndPtr->hwndSelf, &rect);
|
|
FillRect32 ((HDC32)wParam, &rect, hBrush);
|
|
DeleteObject32 (hBrush);
|
|
*/
|
|
return TRUE;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
LRESULT WINAPI
|
|
ANIMATE_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
WND *wndPtr = WIN_FindWndPtr(hwnd);
|
|
|
|
switch (uMsg)
|
|
{
|
|
case ACM_OPENA:
|
|
return ANIMATE_OpenA (wndPtr, wParam, lParam);
|
|
|
|
/* case ACM_OPEN32W: */
|
|
/* return ANIMATE_Open32W (wndPtr, wParam, lParam); */
|
|
|
|
case ACM_PLAY:
|
|
return ANIMATE_Play (wndPtr, wParam, lParam);
|
|
|
|
case ACM_STOP:
|
|
return ANIMATE_Stop (wndPtr, wParam, lParam);
|
|
|
|
|
|
case WM_CREATE:
|
|
return ANIMATE_Create (wndPtr, wParam, lParam);
|
|
|
|
case WM_DESTROY:
|
|
return ANIMATE_Destroy (wndPtr, wParam, lParam);
|
|
|
|
/* case WM_ERASEBKGND: */
|
|
/* return ANIMATE_EraseBackground (wndPtr, wParam, lParam); */
|
|
|
|
/* case WM_NCCREATE: */
|
|
/* case WM_NCHITTEST: */
|
|
/* case WM_PAINT: */
|
|
/* case WM_SIZE: */
|
|
/* case WM_STYLECHANGED: */
|
|
/* case WM_TIMER: */
|
|
|
|
default:
|
|
if (uMsg >= WM_USER)
|
|
ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
|
|
uMsg, wParam, lParam);
|
|
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
VOID
|
|
ANIMATE_Register (VOID)
|
|
{
|
|
WNDCLASSA wndClass;
|
|
|
|
if (GlobalFindAtomA (ANIMATE_CLASSA)) return;
|
|
|
|
ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
|
wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
|
|
wndClass.lpfnWndProc = (WNDPROC)ANIMATE_WindowProc;
|
|
wndClass.cbClsExtra = 0;
|
|
wndClass.cbWndExtra = sizeof(ANIMATE_INFO *);
|
|
wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
|
wndClass.lpszClassName = ANIMATE_CLASSA;
|
|
|
|
RegisterClassA (&wndClass);
|
|
}
|
|
|
|
|
|
VOID
|
|
ANIMATE_Unregister (VOID)
|
|
{
|
|
if (GlobalFindAtomA (ANIMATE_CLASSA))
|
|
UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
|
|
}
|
|
|