/***********************************************************************/
/*                                                                     */
/*      Implementation des fonctions du package button.pkg             */
/*                                                                     */
/***********************************************************************/

#include "x/Version.h"
#include "x/scolplugin.h"

#include <stdio.h>
#include <string.h>

#include "objstr.h"

#include "tests.h"
#include "objects/tooltip.h"
#include "objects/font.h"

#include "events.h"
#include "objects/bitmap.h"

  
WNDPROC ButtonProc = NULL ;




int ControlIdent = 100 ;





static MSG smsg ;

/*****************************************************************************************/
/*                                                                                       */
/*LRESULT CALLBACK ButtonProcBis ( HWND hwnd , unsigned msg , UINT wParam , LONG lParam )*/
/*                                                                                       */
/*  C'est la winproc pour les pushbutton basic de base de la mort                        */
/*                                                                                       */
/*****************************************************************************************/

LRESULT CALLBACK ButtonProcBis ( HWND hwnd , unsigned msg , UINT wParam , LONG lParam )
{
    NMHDR * pnmh ;

    switch ( msg )
    {
    
        case WM_NOTIFY : pnmh = (LPNMHDR) lParam ;
            if (pnmh->code == TTN_SHOW) MMechostr(MSKDEBUG,"Notify: SHOW TIP\n");
            if (pnmh->code == TTN_POP) MMechostr(MSKDEBUG,"Notify :POP TIP\n");
            if (pnmh->code == TTN_NEEDTEXT ) MMechostr(MSKDEBUG,"Notify : TIP Needed Text\n");
            break ;

        case WM_KEYUP:
           
            if ( wParam == 13 ) GRTestDefaultButton ( GetParent ( hwnd )) ;
            if ( wParam == 9 ) GRTestTabFocus ( hwnd , OBJTYPBUTTON ) ;
           
            tstscoldead(201);
             break ;

       case WM_DROPFILES : SCOLDropFiles ( mm,hwnd,(HANDLE)wParam,OBJTYPBUTTON,RFLBUTTON_DROPFILE);
            break; 

       case WM_LBUTTONDOWN :
       case WM_MOUSEMOVE :
       case WM_LBUTTONUP :
       case WM_RBUTTONDOWN :
       case WM_MBUTTONDOWN :
       case WM_RBUTTONUP :
       case WM_MBUTTONUP :
            if ( ToolTip ) 
            {
                MMechostr (1,"Send mouse relay to ToolTip passage 1\n");
                smsg.hwnd = hwnd ;
                smsg.message = msg ;
                smsg.wParam = wParam ;
                smsg.lParam = lParam ;

                /*
                smsg.time = time () ;*/
                GetCursorPos (&(smsg.pt) ) ;
            
                MMechostr(MSKDEBUG,"Send Mouse relay to tooltip %d\n",ToolTip);
                SendMessage ( ToolTip , TTM_ACTIVATE , TRUE , FALSE ) ;
                SendMessage ( ToolTip , TTM_RELAYEVENT , (WPARAM ) 0 , (LPARAM ) &smsg ) ;            
            }

        default : break ;
    }


    return CallWindowProc ( ButtonProc , hwnd , msg , wParam , lParam ) ;
}

/****************************************************************************************/
/*                                                                                      */
/* HWND NewObjPushButton ( PtrObjButton Psh , char * Name , HWND Parent )               */
/*                                                                                      */
/* Cree un bouton de type Push Button                                                   */
/*                                                                                      */
/****************************************************************************************/

HWND NewObjPushButton ( PtrObjButton Psh , char * Name , HWND Parent , int Dialog )
{
int Flags , Id;
HWND H ;
int Ex_Flag =  0 ;

        Flags = BS_PUSHBUTTON ;
        if ( Dialog  )
        {
            if ( Psh->Flags & PB_DEFAULT ) 
            {
                Flags = BS_DEFPUSHBUTTON ;              
            }
            Id = ControlIdent ++ ;
        } else Id = ( int ) NULL ;
        if ( Flags & PB_DOWN ) Ex_Flag |= WS_EX_CLIENTEDGE ;
        
        if ( Parent != NULL ) Flags |= WS_CHILD ;
        if (( Psh->Flags & PB_TABFOCUS ) && Dialog  ) Flags |= WS_TABSTOP ;
        if ( Psh->Flags & PB_DRAGDROP ) Ex_Flag |= WS_EX_ACCEPTFILES ;
        

        H =  CreateWindowEx ( Ex_Flag , "button" , Name , Flags ,
                                Psh->PosX , Psh->PosY ,
                                Psh->TailleW , Psh->TailleH ,
                                Parent , ( HMENU ) Id ,
                                (HINSTANCE)SCgetExtra("this_inst") , NULL ) ;
        if ( Flags & BS_DEFPUSHBUTTON )
        {           
            DefDlgProc ( Parent , DM_SETDEFID , GetDlgCtrlID ( H )  , 0 ) ;           
        }

        return H ;
}


/****************************************************************************************/
/*                                                                                      */
/* HWND NewObjPushButtonBitmap ( PtrObjPushButtonBitmap Pb , HWND Parent ) ;            */
/*                                                                                      */
/* cree un push button qui est affiche a l'aide de bitmap , au lieu de texte            */
/*                                                                                      */
/****************************************************************************************/

HWND NewObjPushButtonBitmap ( PtrObjPushButtonBitmap Pb , HWND Parent , int Dialog )
{

        int Style,Id ;
        HWND H ;
        int Ex_Flag = 0 ;

        Style = BS_PUSHBUTTON ;
        
        if ( Dialog  )
        {
            if ( Pb->Flags & PB_DEFAULT ) 
            {
                Style = BS_DEFPUSHBUTTON ;                
            }
            Id = ControlIdent ++ ;
            if ( Pb->Flags & PB_TABFOCUS ) Style |= WS_TABSTOP ;

        } else Id = ( int ) NULL ;

        Style |= BS_BITMAP ;
        if ( Parent != NULL ) Style |= WS_CHILD ;
        if ( Pb->Flags & PB_DOWN ) Ex_Flag |= WS_EX_CLIENTEDGE ;
        if ( Pb->Flags & PB_DRAGDROP ) Ex_Flag |= WS_EX_ACCEPTFILES ;
        
        H = CreateWindowEx ( Ex_Flag , "button" , "bidi" , Style ,
                        Pb->PosX , Pb->PosY , Pb->TailleW , Pb->TailleH ,
                        Parent , ( HMENU ) Id , (HINSTANCE)SCgetExtra("this_inst") , NULL ) ;

        if (( Pb->Flags & PB_DEFAULT ) && Dialog )
        {           
            DefDlgProc ( Parent , DM_SETDEFID , GetDlgCtrlID ( H )  , 0 ) ;                              
        }

        return H ;       
}










/*****************************************************************************/
/*                                                                           */
/* int GRCreatePushButtonBitmap ( mmachine m ) ;                             */
/*                                                                           */
/* correspond a la fonction magma Obj _create_push_button_bitmap  (          */
/* Obj Parent , Obj BitmapUp , Obj BitmapDown , I PosX , I PosY , I TailleW  */
/* I TailleH , I MHandler )                                                  */
/*                                                                           */
/*****************************************************************************/

int GRCreatePushButtonBitmap ( mmachine m )

{
    int su  ;
    int dialog = 0 ;
    PtrObjVoid O , OBU , OP ;
    PtrObjPushButtonBitmap P ;
    PtrObjBitmap BU ;
    PtrObjWindow WP ;
    HWND Parent ;
    
    int s , s2 , l , res ;

    /********************** DEBUG 2D *********************************/
    #ifdef TRACE2D
        MMechostr ( 1 , "DBG _create_push_button_bitmap\n" ) ;
        FDebug2D (m  ) ;
    #endif
    /*****************************************************************/

    /* test channel NIL */
    if (MMget(m,7)==NIL)
    {
        MMechostr(MSKDEBUG,"_CRbuttonBitmap : channel NIL\n");
        m->pp+=7;
        return 0;
    }

    /* test parent NIL */
    if ( MMget(m,6)==NIL)
    {
        MMechostr(MSKDEBUG,"_CRbuttonBitmap : parent NIL\n");
        m->pp+=7;
        MMset(m,0,NIL);
        return 0;
    }

  
    l = ( sizeof ( struct ObjVoid ) + 3 ) >> 2 ;
    s = MMmallocCLR (m,l,TYPETAB) ;
    if ( s == NIL ) return MERRMEM ;
    if ( MMpush(m,(s<<1)+1)) return MERRMEM  ;
    l = ( sizeof ( struct ObjPushButtonBitmap ) + 3 ) >> 2 ;
    s2 = MMmalloc ( m,l,TYPEBUF ) ;
    if ( s2 == NIL ) return MERRMEM ;
    s = MMpull(m) ;

    O = ( PtrObjVoid ) MMstart(m, (s>>1) ) ;
    P = ( PtrObjPushButtonBitmap ) MMstart(m, s2 ) ;

    O->Type = OBJ_TYPE_PUSH_BUTTON_BITMAP << 1 ;
    O->Buffer = ( s2<<1)+1 ;
    P->Flags = MMpull(m)>>1 ;
    P->TailleH = MMpull(m)>> 1 ;
    P->TailleW = MMpull(m) >> 1 ;
    P->PosY = MMpull(m) >> 1 ;
    P->PosX = MMpull(m) >> 1 ;
 
    O->Tab = MMget(m,0);  
   
    su = MMpull (m) ;    
    if ( su != NIL )
    {
        OBU = ( PtrObjVoid ) MMstart(m, (su>>1) ) ;
        BU = ( PtrObjBitmap ) MMstart(m, (OBU->Buffer>>1) ) ;

		//$ LB (13/06/2002) : create DIBSection from bitmap buffer
		if (!BU->DIBhandler) ObjBitmap_CreateDIBSection (BU);

    } else BU = NULL ;

    if ( BU ) P->Up = BU->DIBhandler; else P->Up = NULL ;    
    
    O->Father = MMpull(m) ;
    if ( O -> Father == NIL ) Parent = NULL ;
    else
    {
        OP = ( PtrObjVoid ) MMstart(m, (O->Father>>1) ) ;
        if ( OP->Type != OBJ_TYPE_WINDOW << 1 )
        {
            MMechostr ( 1 , "CreatePushButtonBitmap : Parent object must be a window\n" ) ;
			MMpull(m);
            return MMpush(m,NIL);
        }
        WP = ( PtrObjWindow ) MMstart(m, (OP->Buffer>>1)) ;
        if ( WP->Flags & WN_DIALOG ) dialog = 1 ;
        Parent = WP->WHandler ;
    }
  
    P->WHandler = NewObjPushButtonBitmap ( P , Parent , dialog ) ;
    if ( P == NULL )
    {
        MMechostr ( 1 ,"Error in _create_push_button_bitmap : WIN95 can't create the button.\n" );
        MMpull(m);
		return MMpush(m,NIL ) ;
    }
    MMpush(m,s) ;
    res = OBJcreate(m,OBJTYPBUTTON,(int)P->WHandler,OBJTYPWINDOW,(int)Parent) ;    

    SendMessage ( P->WHandler , BM_SETIMAGE , 0 , ( LPARAM ) P->Up ) ;

    if ( !ButtonProc ) ButtonProc  = ( WNDPROC ) GetWindowLong ( P->WHandler, GWL_WNDPROC ) ;
    SetWindowLong ( P->WHandler , GWL_WNDPROC , ( long ) ButtonProcBis ) ;

    ShowWindow ( P->WHandler , SW_SHOW ) ;
    UpdateWindow ( P->WHandler ) ;

    /************************ DEBUG 2D **************************/
    #ifdef TRACE2D
        FDebug2D( m ) ;
        MMechostr( 1 , "DBG _create_push_button_bitmap done\n" ) ;
    #endif
    /****************************************************************/

     
    return res ;
}


/*****************************************************************************/
/*                                                                           */
/*  fonction int GRSetButtonBitmap ( mmachine m ) ;                          */
/*                                                                           */
/*  correspond a la fonction magma ObjButton _SETbuttonBitmap                */
/*  laquelle change le bitmap d'un bouton bitmap                             */
/*                                                                           */
/*****************************************************************************/

int GRSetButtonBitmap ( mmachine m )
{
    int s , s2 ;
    PtrObjVoid O , O2 ;
    PtrObjPushButtonBitmap PB ;
    PtrObjBitmap B ;

    /******************** DEBUG 2D *******************************************/
    #ifdef TRACE2D
        MMechostr ( 1 , "DBG _set_button_bitmap\n" ) ;
        FDebug2D ( m ) ;
    #endif
    /*************************************************************************/

    s2 = MMpull(m) ;
    s = MMpull(m) ;

    if ( s == NIL ||s2 == NIL )
        MMechostr ( 1 , "_SETbuttonBitmap : one of the parameter is NIL\n" ) ;
    else
    {
        O2 = ( PtrObjVoid ) MMstart(m,(s2>>1) ) ;
        O = ( PtrObjVoid ) MMstart(m,(s>>1) ) ;
		O->Tab=s2;
        B = ( PtrObjBitmap ) MMstart(m,(O2->Buffer>>1) ) ;

		//$ LB (13/06/2002) : create DIBSection from bitmap buffer
		if (!B->DIBhandler) ObjBitmap_CreateDIBSection (B);

        PB = ( PtrObjPushButtonBitmap ) MMstart(m,(O->Buffer>>1)) ;
        
            PB->Up = B->DIBhandler ;
            SendMessage ( PB->WHandler , BM_SETIMAGE , 0 , ( LPARAM ) PB->Up ) ;
            UpdateWindow ( PB->WHandler ) ;
        
    }

    s = MMpush(m,s) ;

    /************************* DEBUG 2D *************************************/
    #ifdef TRACE2D
        FDebug2D ( m ) ;
        MMechostr ( 1 , "DBG _set_button_bitmap done\n" ) ;
    #endif
    /***************************************************************************/

    return  s ;


}


/*****************************************************************************/
/*                                                                           */
/* fonction int GRCreatePushButton ( mmachine m ) ;                          */
/*                                                                           */
/*  cette fonction C correspond a la fonction magma                          */
/*  Obj _create_push_button ( Obj Parent , int PosX , int PosY , int TailleW,*/
/*     int TailleH , int Flags , int MHandler , char * Libelle ) ;           */
/*  laquelle cree un push button dont on indique le libelle                  */
/*                                                                           */
/*****************************************************************************/
    
int GRCreatePushButton ( mmachine m )
{
int s,l,dummy,s2,res;
int dialog = 0 ;
PtrObjVoid O , OP ;
PtrObjButton Psh ;
PtrObjWindow PW ;
HWND Parent , HW ;
char Name [ 512 ] ;

    /**************************** DEBUG 2D ************************************/
    #ifdef TRACE2D
        MMechostr ( 1 , "DBG _create_push_button\n") ;
        FDebug2D ( m ) ;
    #endif
    /**************************************************************************/

    /* test channel NIL */
    if (MMget(m,7)==NIL)
    {
        MMechostr(MSKDEBUG,"_CRbutton : channel NIL\n");
        m->pp+=7;
        return 0;
    }

    /* test parent NIL */
    if ( MMget(m,6)==NIL)
    {
        MMechostr(MSKDEBUG,"_CRbutton : parent NIL\n");
        m->pp+=7;
        MMset(m,0,NIL);
        return 0;
    }
        
    dummy       = MMpull(m)  ;
    /* Ici ajouter avant le strcpy un test sur la taille du texte envoye    */
    if ( dummy == NIL ) strcpy ( Name , "" ) ;
    strcpy ( Name , ( char * ) MMstart(m, ( dummy >> 1 ) + 1) ) ;
    
    /* creation de la zone memoire de l'objet general */
    l = ( sizeof ( struct ObjVoid ) + 3 ) >> 2 ;
    s = MMmallocCLR (m,l,TYPETAB) ;
    if ( s == NIL )
    {
        MMechostr(MSKDEBUG," _create_push_buttonn : Error in alloc MAGMA Memory\n" ) ;
        return MERRMEM ;        
   }    
    if ( MMpush(m,(s<<1)+1)) return MERRMEM ;
    /* on rempile l'addresse au cas ou il y aurait un GC par la suite */

    /* creation de la zone memoire pour les donnees relatives aux objets textes */
    l = ( sizeof ( struct ObjText ) + 3 ) >> 2 ;
    s2 = MMmalloc ( m,l,TYPEBUF ) ;
    if ( s2 == NIL )
    {
        MMechostr(MSKDEBUG,"_create_ push_button : Error in alloc MAGMA Memory\n" ) ;
        return MERRMEM ;
    }


    Psh = ( PtrObjButton ) MMstart(m, s2 ) ;
    s = MMpull (m ) ; /* recupere l'addresse de l'objet de base */
    O = ( PtrObjVoid ) MMstart(m, (s>>1) ) ;

    O->Type     = OBJ_TYPE_PUSHBUTTON << 1 ;   
    Psh -> Flags          = MMpull(m) >> 1 ;
    Psh -> TailleH        = MMpull(m) >> 1 ;
    Psh -> TailleW        = MMpull(m) >> 1 ;
    Psh -> PosY           = MMpull(m) >> 1 ;
    Psh -> PosX           = MMpull(m) >> 1 ;
    O -> Father           = MMpull(m) ;
    O -> Buffer           = ( s2 << 1 ) + 1 ;
    O -> Tab              = NIL ;

    /* recuperation du handler window du parent, si parent il y a */
    if ( O -> Father == NIL ) Parent = NULL ;
    else
    {
        OP = ( PtrObjVoid ) MMstart(m, (O->Father>>1) ) ;
        if ( OP->Type != OBJ_TYPE_WINDOW << 1 )
        {
            MMechostr ( 1 , "CreatePushButton : Parent must be a Window\n" ) ;
			MMpull(m);
			return MMpush(m,NIL);
        }
        PW = ( PtrObjWindow ) MMstart(m, (OP->Buffer >>1) ) ;
        if ( PW->Flags & WN_DIALOG ) dialog = 1 ;
        Parent = PW->WHandler ;
    }

    HW = NewObjPushButton ( Psh , Name , Parent , dialog  ) ;    
    if ( ! HW )
    {
        MMechostr(MSKDEBUG,"_create_push_button : Error in creating the WIN Object-Check the values\n" ) ;
		MMpull(m);
		return MMpush(m,NIL);
    }
    Psh->WHandler = HW ;

    if ( !ButtonProc ) ButtonProc  = ( WNDPROC ) GetWindowLong ( HW , GWL_WNDPROC ) ;
    SetWindowLong ( HW , GWL_WNDPROC , ( long ) ButtonProcBis ) ;
    if ( DefaultFont != NULL ) 
      SendMessage ( HW , WM_SETFONT , ( WPARAM ) DefaultFont , ( LPARAM ) TRUE ) ;      


    ShowWindow(HW,SW_SHOW);
    UpdateWindow(HW);
    MMpush(m,s) ;
    res = OBJcreate(m,OBJTYPBUTTON,(int)HW,OBJTYPWINDOW,(int)Parent) ;    

    /************************************ DEBUG 2D ********************************/
    #ifdef TRACE2D
        FDebug2D ( m ) ;
        MMechostr ( 1 , "DBG _create_push_button done\n" ) ;
    #endif
    /*******************************************************************************/

    return res ;
}

/*****************************************************************************/
/*                                                                           */
/*  int GRReflexButtonEvent ( mmachine m ) ;                                 */
/*                                                                           */
/* Correspond a la fonction magma ObjButton _reflex_button_event             */
/* ( ObjButton, Fun, u0 )  laquelle definit le callback pour l'evenement     */
/*                                                                           */
/*****************************************************************************/

int GRReflexButtonEvent ( mmachine m )
{
    return OBJaddreflex (m,OBJTYPBUTTON,RFLBUTTON_EVENT ) ;
}

/*****************************************************************************/
/*                                                                           */
/*  int GRReflexCheckEvent ( mmachine m ) ;                                  */
/*                                                                           */
/* correspond a la fonction magma ObjCheck _reflex_check_event               */
/*  ( Objcheck , Fun , U0 ) laquelle definit le callback pour l'evenement    */
/* event d'une check box                                                     */
/*                                                                           */
/*****************************************************************************/

int GRReflexCheckEvent ( mmachine m )
{
    return OBJaddreflex (m,OBJTYPCHECK,RFLCHECK_EVENT ) ;
}


/*****************************************************************************/ 
/*                                                                           */ 
/*  int GRReflexButtonDropFile ( mmachine m ) ;                              */ 
/*                                                                           */ 
/*   correspond a la fonction ObjButton _CBbuttonDropFile (ObjButton,fun,u0) */ 
/*  qui permet de definir le callback dans le cas d'un drag et drop sur      */ 
/*  un objet button                                                          */ 
/*                                                                           */ 
/*****************************************************************************/ 

int GRReflexButtonDropFile ( mmachine m )
{
    return OBJaddreflex (m,OBJTYPBUTTON,RFLBUTTON_DROPFILE);
}

/*****************************************************************************/
/*                                                                           */
/* int GRDestroyObjButton ( mmachine m ) ;                                   */
/*                                                                           */
/* Correspond a la fonction magma I _destroy_obj_button ( ObjButton )        */
/* et a I _destroy_obj_check ( ObjCheck )                                    */
/* laquelle detruit un push button                                           */
/*                                                                           */
/*****************************************************************************/

int GRDestroyObjButton ( mmachine m )
{
    int s , type ;
    PtrObjVoid O ;
    HWND h ;

    /******************* DEBUG 2D ***************************/
    #ifdef TRACE2D
        MMechostr ( 1 , "DBG _destroy_obj_button\n" ) ;
        FDebug2D ( m ) ;
    #endif
    /********************************************************/

    s = MMget(m,0) ;
    if ( s != NIL )
    {
        O = ( PtrObjVoid ) MMstart(m,(s>>1) ) ;
        if ( O->Type == ( OBJ_TYPE_CHECK_BOX << 1 ))
        {
            type = OBJTYPCHECK ; 
            h = ( ( PtrObjButton ) ( MMstart(m, ( O->Buffer >> 1 ) ) )) -> WHandler ;                
            OBJdelTH(m,type,(int)h);  
        }
        else if ( O->Type == ( OBJ_TYPE_PUSHBUTTON << 1 ))
        {
            type = OBJTYPBUTTON ;
            h = ( ( PtrObjButton ) ( MMstart(m, ( O->Buffer >> 1 ) ) )) -> WHandler ; 
            OBJdelTH(m,type,(int)h);  
        }
        else if ( O->Type == ( OBJ_TYPE_PUSH_BUTTON_BITMAP << 1 ))
        {
            type = OBJTYPBUTTON ;
            h = (( PtrObjPushButtonBitmap ) ( MMstart(m,(O->Buffer>>1) ))) ->WHandler ;
            OBJdelTH(m,type,(int)h);  
        }
        
    }

    /*********************** DEBUG 2D ***************************/
    #ifdef TRACE2D
        FDebug2D ( m );
        MMechostr ( 1 , "DBG _destroy_obj_button DONE\n" ) ;
    #endif
    /***************************************************************/

    MMset(m,0,0) ; return  0 ;
}

/*****************************************************************************/
/*                                                                           */
/* int GRPaintObjButton ( mmachine m )                                       */
/*                                                                           */
/* correspond a la fonction magma ObjButton _paint_obj_button ( ObjButton)   */
/* laquelle repaint un objet de type pushbutton                              */
/*                                                                           */
/*****************************************************************************/

int GRPaintObjButton ( mmachine m )
{
    int s ; 
    PtrObjVoid  O ;
    PtrObjButton B ;
    PtrObjPushButtonBitmap Pb ;

    /************************ DEBUG 2D **********************/
    #ifdef TRACE2D
        MMechostr ( 1 , "DBG _paint_obj_button\n" ) ;
        FDebug2D ( m ) ;
    #endif
    /*******************************************************/

    s = MMpull(m) ;
    if ( s == NIL ) return MMpush(m,NIL ) ;
    O = ( PtrObjVoid ) MMstart(m, (s>>1) ) ;

    switch (O->Type >> 1 )
    {

        case OBJ_TYPE_PUSHBUTTON :
        case OBJ_TYPE_CHECK_BOX :   

                B = ( PtrObjButton ) MMstart(m,(O->Buffer>>1)) ;
                if ( GetUpdateRect ( B->WHandler  , NULL , TRUE ))
                {
                        InvalidateRect ( B->WHandler , NULL , TRUE ) ;
                        SendMessage ( B->WHandler , WM_PAINT , 0 , 0 ) ;
                }
                break ;

        case OBJ_TYPE_PUSH_BUTTON_BITMAP :

                Pb = ( PtrObjPushButtonBitmap ) MMstart(m,(O->Buffer>>1) ) ;
                if ( GetUpdateRect ( Pb->WHandler , NULL , TRUE ))
                {
                    InvalidateRect ( Pb->WHandler , NULL , TRUE ) ;
                    SendMessage ( Pb->WHandler , WM_PAINT , 0 , 0 ) ;
                }    
                break ;

    }

    s = MMpush(m,s) ;

    /************************ DEBUG 2D *******************************/
    #ifdef TRACE2D
        FDebug2D ( m ) ;
        MMechostr ( 1 , "_paint_obj_button done\n" ) ;
    #endif
    /****************************************************************/

    return s ;
}


