/****************************************************************
** Title  :!IntSoundapp main ** **
** Purpose: internal sound(s) level and bip test
** Version: 0.00 19.11.21 JMB
** fichier: iconbar.c
*****************************************************************/

#include "swis.h"
#include "kernel.h"
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

#define TOOLBOX_H   // #include "toolbox.h"
#define WIMP_H   // #include "wimp.h"
#define WINDOW_H
#define MESSAGETRANS_H

// **********  from Oslib support   **********
#include "OSLibSupport:SysTypes.h"
#include "OSLibSupport:Err.h"	// error handling library
#include "OSLibSupport:x.h"
#include "OSLibSupport:event.h"
#include "OSLibSupport:message.h"
#include "OSLibSupport:ToolBoxTypes.h"

// **********  from Oslib  **********

#include "OSLib/menu.h"
#include "OSLib/proginfo.h"
#include "OSLib/quit.h"


#include "debug.h"
#include "ResEventComps.h"
#include "Main.h"
#include "iconbar.h"
#include "iconbarmenu.h"


 /*  ==============   conctructeur  IconBar Menu ==============  */
IconBarMenu::IconBarMenu (toolbox_o IconBarMenu_id)
{
  x_exception xx;
  x_TRY( &xx )
  {
    //debug_printf("IconBarMenu Id: %0X", IconBarMenu_id);
    // ===========  tool box event  registration ================
    event_register_toolbox_handler(IconBarMenu_id, ICONBARMENU_QUIT_EVENT, IconBarMenuQuit_TBhandler, this );
    event_register_toolbox_handler(IconBarMenu_id, action_MENU_SELECTION, IconBarMenus_TBhandler, this );
    event_register_toolbox_handler(object_ANY, action_PROG_INFO_ABOUT_TO_BE_SHOWN, PrgInfo_AboutToBeShowTBhandler, this );
  }
  x_CATCH( &xx )
  {
    Err_ReportError( !Err_FATAL, "Unable to create IconBarMenu: %s", xx.error -> errmess );
  }
}


 /*  ==============   desctructeur  IconBar Menu ==============  */
IconBarMenu::~IconBarMenu()
{
}

       /*  ==============   ToolBox handlers   ==============  */

osbool IconBarMenu::IconBarMenuQuit_TBhandler(bits Event_code, toolbox_action *pxEvent, toolbox_block *TBblock,void *vhandle)
{
  IGNORE(Event_code);IGNORE(pxEvent);IGNORE(vhandle);IGNORE(TBblock);
  gQuit = TRUE;
  //debug_printf("IconBarMenuQuit_TBhandler");
  return TRUE ;
}

osbool  IconBarMenu::IconBarMenus_TBhandler(bits Event_code, toolbox_action *pxEvent, toolbox_block *TBblock,void *vhandle)
{
  IGNORE(Event_code);IGNORE(pxEvent);IGNORE(vhandle);IGNORE(TBblock);
  if (TBblock->self_component == HELP_MENU_BAR_ENTRY ) {
    sprintf(gbufMess, "filer_run %s.!help",APPDIR);
    system( gbufMess );
  }
   return TRUE;
}

osbool  IconBarMenu::PrgInfo_AboutToBeShowTBhandler(bits Event_code, toolbox_action *pxEvent, toolbox_block *TBblock, void *vhandle)
{
  IGNORE(Event_code);IGNORE(pxEvent);IGNORE(vhandle);IGNORE(TBblock);
   IconBarMenu *IBarMenu;
   IBarMenu = (IconBarMenu*) vhandle;
//debug_printf("PrgInfo_AboutToBeShow ProgInfo_id: %0X ", TBblock->self_id);
//debug_printf("PrgInfo_AboutToBeShow ProgInfo_id: %0X ", gIconBar->ProgInfo_id );
  proginfo_set_version(0,TBblock->self_id,Message_GetMessage(&gMessagesFD,"Version","Token pas trouv!"));

  return TRUE;
}

        /* =======    Messages handlers ============= */



