/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com

Copyright (c) 2011 I-maginer

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser 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, or go to
http://www.gnu.org/copyleft/lesser.txt
-----------------------------------------------------------------------------
*/

#ifndef _SCOL_EMBEDDED_WEB_NAVIGATOR_LIFE_SPAN_
#define _SCOL_EMBEDDED_WEB_NAVIGATOR_LIFE_SPAN_

#include "embeddedWebNavigatorPrerequisites.h"

/** \defgroup grpWebNavigatorLifeSpan Web navigator life span reflexives functions
 *  Callbacks related to browser life span
 *  @{
 */
/** @} */

/** \ingroup grpWebNavigatorLifeSpan
 * \brief WebNavigatorCbOnPopup : Called when a request for a new popup window (a new web navigator) occurs.
 *
 * <b>Prototype:</b> fun [ObjWebNavigator fun [ObjWebNavigator u0 I I I I S] u1 u0] ObjWebNavigator
 * \param ObjWebNavigator : The object on which we want to catch the event
 * \param fun [ObjWebNavigator u0 I I I I S] u1 : Scol function to call
 * \param u0 : Optionnal user parameter
 * \param I : X position of the popup
 * \param I : Y position of the popup
 * \param I : Width of the popup
 * \param I : Height of the popup
 * \param S : Target url of the popup
 *
 * \return ObjWebNavigator : Web navigator object if success
 */
int WebNavigatorCbOnPopup(mmachine m);

/**
 * Execute the WEB_NAVIGATOR_LIFESPAN_ON_POPUP_CB reflexive function
 * \param m : Current machine
 * \param hwnd : Main scol window
 * \param msg : Window message
 * \param wParam : WebNavigator pointer
 * \param lParam : data pointer
 * \param ret : user parameter
 */
int FireWebNavigatorReflexiveOnPopup(mmachine m, ScolWindowHandle hwnd, unsigned int msg, UINT wParam, LONG lParam, int* ret);

/** \ingroup grpWebNavigatorLifeSpan
 * \brief WebNavigatorCbOnAfterCreated : Called after a new window is created.
 *
 * <b>Prototype:</b> TODO ObjWebNavigator
 * \param ObjWebNavigator : The object on which we want to catch the event
 * \param fun [ObjWebNavigator u0] u1 : Scol function to call
 * \param u0 : Optionnal user parameter
 *
 * \return ObjWebNavigator : Web navigator object if success
 */
// TODO DELETE int WebNavigatorCbOnAfterCreated(mmachine m);

/** \ingroup grpWebNavigatorLifeSpan
 * \brief WebNavigatorCbRunModal : Called when a modal window is about to display and the modal loop should begin running.
 * Return false to use the default modal loop implementation or true to use a custom implementation.
 *
 * <b>Prototype:</b> fun [ObjWebNavigator fun [ObjWebNavigator u0] u1 u0] ObjWebNavigator
 * \param ObjWebNavigator : The object on which we want to catch the event
 * \param fun [ObjWebNavigator u0] u1 : Scol function to call
 * \param u0 : Optionnal user parameter
 *
 * \return ObjWebNavigator : Web navigator object if success
 */
int WebNavigatorCbRunModal(mmachine m);

/**
 * Execute the WEB_NAVIGATOR_LIFESPAN_RUN_MODAL_CB reflexive function
 * \param m : Current machine
 * \param hwnd : Main scol window
 * \param msg : Window message
 * \param wParam : WebNavigator pointer
 * \param lParam : data pointer
 * \param ret : user parameter
 */
int FireWebNavigatorReflexiveRunModal(mmachine m, ScolWindowHandle hwnd, unsigned int msg, UINT wParam, LONG lParam, int* ret);

/** \ingroup grpWebNavigatorLifeSpan
 * \brief WebNavigatorCbOnBeforeClose : Called just before a window is closed.
 * If this is a modal window and a custom modal loop implementation was provided in RunModal()
 * this callback should be used to exit the custom modal loop.
 *
 * <b>Prototype:</b> TODO : NOT implemented
 * \param ObjWebNavigator : The object on which we want to catch the event
 * \param fun [ObjWebNavigator u0] u1 : Scol function to call
 * \param u0 : Optionnal user parameter
 *
 * \return ObjWebNavigator : Web navigator object if success
 */
int WebNavigatorCbOnBeforeClose(mmachine m);

/**
 * Execute the WEB_NAVIGATOR_LIFESPAN_ON_BEFORE_CLOSE_CB reflexive function
 * \param m : Current machine
 * \param hwnd : Main scol window
 * \param msg : Window message
 * \param wParam : WebNavigator pointer
 * \param lParam : data pointer
 * \param ret : user parameter
 */
int FireWebNavigatorReflexiveOnBeforeClose(mmachine m, ScolWindowHandle hwnd, unsigned int msg, UINT wParam, LONG lParam, int* ret);

// Everything inside _cond and _endcond is ignored by doxygen
//! \cond

/**
 * \brief Load the WebNavigatorLifeSpan package in Scol virtual machine
 * \param mmachine : the scol machine
 */
int LoadWebNavigatorLifeSpan(mmachine m);

//! \endcond

#endif
