/*****************************************************************************

GRAOUMF TRACKER 2

Copyright (c) 1996 - 2002 Laurent de Soras

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.

Contact the author : laurent@ohmforce.com
More information about this license : http://www.gnu.org/licenses/gpl.html

*****************************************************************************/



/*\\\ FICHIERS INCLUDE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

#include	<stdio.h>

#include	"base_ct.h"
#include	"log.h"
#include	"PatEdMenuSamples.h"
#include	"resource.h"
#include	"rsc01.h"



/*\\\ CONSTANTES PUBLIQUES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



/*\\\ CONSTANTES PRIVEES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

enum
{
	PatEdMenuSamples_SUBMENU_MAIN = 0,
	PatEdMenuSamples_SUBMENU_D2D,
	PatEdMenuSamples_SUBMENU_REC,

	PatEdMenuSamples_NBR_SUBMENUS
};



/*\\\ TYPES & STRUCTURES PRIVEES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



/*\\\ DEFINITION DES VARIABLES DE CLASSE PUBLIQUES \\\\\\\\\\\\\\\\\\\\\\\\\*/



/*\\\ DEFINITION DES VARIABLES DE CLASSE PRIVEES \\\\\\\\\\\\\\\\\\\\\\\\\\\*/



/*\\\ METHODES PUBLIQUES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



/*==========================================================================*/
/*      Nom: (constructeur)                                                 */
/*      Description: Initialise                                             */
/*      Parametres en entree:                                               */
/*      Parametres en sortie:                                               */
/*      Parametres en entree/sortie:                                        */
/*==========================================================================*/

PatEdMenuSamples::PatEdMenuSamples (void)
{
	set_submenu (PatEdMenuSamples_SUBMENU_MAIN);
}



/*==========================================================================*/
/*      Nom: check_ok                                                       */
/*      Description: Verifie l'intergrite de l'objet.                       */
/*      Retour: 0 si l'objet parait correct.                                */
/*==========================================================================*/

signed int	PatEdMenuSamples::check_ok (void) const
{
	if (this == NULL)
	{
		LOG_printf ("PatEdMenuSamples::check_ok: Error: \"this\" pointer is NULL.\n");
		return (-1);
	}

	return (0);
}



/*==========================================================================*/
/*      Nom: self_display                                                   */
/*      Description: Affiche "textuellement" le contenu courant de l'objet. */
/*==========================================================================*/

void	PatEdMenuSamples::self_display (void) const
{

	/*** A faire ***/

}



/*==========================================================================*/
/*      Nom: redraw                                                         */
/*      Description: Affiche la composante d'interface.                     */
/*==========================================================================*/

void	PatEdMenuSamples::redraw (void)
{
	switch (_submenu)
	{
	case	PatEdMenuSamples_SUBMENU_MAIN:
		_main.redraw ();
		break;
	case	PatEdMenuSamples_SUBMENU_D2D:
		_d2d.redraw ();
		break;
	case	PatEdMenuSamples_SUBMENU_REC:
		_record.redraw ();
		break;
	}
}



/*==========================================================================*/
/*      Nom: refresh                                                        */
/*      Description: Rafraichit l'affichage des donnees.                    */
/*==========================================================================*/

void	PatEdMenuSamples::refresh (void)
{
	switch (_submenu)
	{
	case	PatEdMenuSamples_SUBMENU_MAIN:
		_main.refresh ();
		break;
	case	PatEdMenuSamples_SUBMENU_D2D:
		_d2d.refresh ();
		break;
	case	PatEdMenuSamples_SUBMENU_REC:
		_record.refresh ();
		break;
	}
}



/*==========================================================================*/
/*      Nom: refresh_dynamic                                                */
/*      Description: Rafraichit l'affichage des donnees dynamiques.         */
/*        - force_flag: true indique qu'on doit forcer le rafraichissement. */
/*==========================================================================*/

void	PatEdMenuSamples::refresh_dynamic (bool force_flag)
{
	switch (_submenu)
	{
	case	PatEdMenuSamples_SUBMENU_MAIN:
		_main.refresh_dynamic (force_flag);
		break;
	case	PatEdMenuSamples_SUBMENU_D2D:
		_d2d.refresh_dynamic (force_flag);
		break;
	case	PatEdMenuSamples_SUBMENU_REC:
		_record.refresh_dynamic (force_flag);
		break;
	}
}



/*==========================================================================*/
/*      Nom: manage                                                         */
/*      Description: Gere la composante d'interface                         */
/*      Parametres en entree:                                               */
/*        - sel_object: objet detecte par le gestionnaire d'interface       */
/*        - sel_elder: aine de sel_object                                   */
/*==========================================================================*/

void	PatEdMenuSamples::manage (int sel_object, int sel_elder)
{
	switch (sel_object)
	{
	case	RSC_OBJ_MP_SUBM_SAMPLES_PICN_MAIN:
		set_submenu (PatEdMenuSamples_SUBMENU_MAIN);
		redraw ();
		break;
	case	RSC_OBJ_MP_SUBM_SAMPLES_PICN_D2D:
		set_submenu (PatEdMenuSamples_SUBMENU_D2D);
		redraw ();
		break;
	case	RSC_OBJ_MP_SUBM_SAMPLES_PICN_REC:
		set_submenu (PatEdMenuSamples_SUBMENU_REC);
		redraw ();
		break;

	default:
		switch (_submenu)
		{
		case	PatEdMenuSamples_SUBMENU_MAIN:
			_main.manage (sel_object, sel_elder);
			break;
		case	PatEdMenuSamples_SUBMENU_D2D:
			_d2d.manage (sel_object, sel_elder);
			break;
		case	PatEdMenuSamples_SUBMENU_REC:
			_record.manage (sel_object, sel_elder);
			break;
		}
	}
}



/*==========================================================================*/
/*      Nom: activate                                                       */
/*      Description: Active ou desactive le menu. Celui-ci n'est pas        */
/*                   reaffiche.                                             */
/*      Parametres en entree:                                               */
/*        - activated_flag: indique si le menu doit etre active ou          */
/*                          desactive.                                      */
/*==========================================================================*/

void	PatEdMenuSamples::activate (bool activated_flag)
{
	RSC_pos_flag (RSC_OBJ_MP_SUBM_SAMPLES, RSC_ATTR_NOTDISP, ! activated_flag);
	RSC_pos_flag (RSC_OBJ_MP_SMICN_SPL, RSC_ATTR_SELECTED, activated_flag);
}



int	PatEdMenuSamples::get_submenu (void) const
{
	return (_submenu);
}



void	PatEdMenuSamples::set_submenu (int submenu)
{
	int		menu_cnt;
	bool		activate_flag;

	_submenu = submenu;

	/* Activation des menus */
	for (menu_cnt = 0; menu_cnt < PatEdMenuSamples_NBR_SUBMENUS; menu_cnt ++)
	{
		activate_flag = (menu_cnt == _submenu);

		switch (menu_cnt)
		{
		case	PatEdMenuSamples_SUBMENU_MAIN:
			_main.activate (activate_flag);
			break;
		case	PatEdMenuSamples_SUBMENU_D2D:
			_d2d.activate (activate_flag);
			break;
		case	PatEdMenuSamples_SUBMENU_REC:
			_record.activate (activate_flag);
			break;
		}
	}
}



/*\\\ METHODES PRIVEES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



/****************************************************************************/
/*                                                                          */
/*                                                                          */
/*                                                                          */
/****************************************************************************/



/*==========================================================================*/
/*      Nom:                                                                */
/*      Description:                                                        */
/*      Parametres en entree:                                               */
/*      Parametres en sortie:                                               */
/*      Parametres en entree/sortie:                                        */
/*      Retour:                                                             */
/*==========================================================================*/
