/* OCaml-Win32
 * win32_animation.c
 * Copyright (c) 2002-2004 by Harry Chomsky
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "win32.h"

/********************************************************************/
/* User Interface: Windows User Experience: Windows Shell: SDK: Windows Controls: Individual Control Information: Animation Controls */

/* Styles */

static DWORD animation_control_style_options[] = {
    ACS_AUTOPLAY,
    ACS_CENTER,
    ACS_TIMER,
    ACS_TRANSPARENT
};
Define_static_constants(animation_control_style_options);

CAMLprim value animation_control_style_of_option(value option)
{
    return copy_int64((int64)Constant_val(option, animation_control_style_options));
}

/* Messages */

CAMLprim value issue_acm_open(value sender, value inst, value name)
{
    CAMLparam3(sender, inst, name);
    LPTSTR n;
    CAMLlocal2(contents, result);

    if (Is_some(name))
        n = new_resname(Value_of(name));
    else
        n = NULL;
    contents = pack_message(ACM_OPEN, (WPARAM)Handle_val(inst), (LPARAM)n);
    result = callback(sender, contents);
    if (Is_some(name))
        free_resname(n);
    if (Int32_val(result) == 0)
        raise_win32_error(0);
    CAMLreturn(Val_unit);
}

CAMLprim value pack_acm_play(value repeat, value from_frame, value to_frame)
{
    return pack_message(ACM_PLAY, Int_val(repeat), MAKELPARAM(Int_val(from_frame), Int_val(to_frame)));
}

CAMLprim value unpack_acm_play(value result)
{
    if (Int32_val(result) == 0)
        raise_win32_error(0);
    return Val_unit;
}

CAMLprim value unpack_acm_stop(value result)
{
    if (Int32_val(result) == 0)
        raise_win32_error(0);
    return Val_unit;
}
