/*********************************************/
/*                                           */
/* load2d.c                                  */
/*                                           */
/*********************************************/


// Modifications History
//
//$ LB (19/06/2002) : added the SCOLloadCOLORS call
//


#define _WIN32_WINNT 0x0400
#include <windows.h>
#include "x/scolplugin.h"
#include "x/version.h"
#include "load/load2d.h"
#include "events.h"
//$ LB (19/06/2002)
#include "colors.h"



int WM_SCOLDRAWMENU = 1;
extern int SCOLInternaldrawMenu(mmachine m,HWND hwnd,unsigned int msg,UINT wParam, LONG lParam,int *ret);




int OBJTYPWINDOW;
int OBJTYPBUTTON;
int OBJTYPTEXT;
int OBJTYPFONT;
int OBJTYPCHECK;
int OBJTYPMENU;
int OBJTYPMENUITEM;
int OBJTYPCOMBOBOX;
int OBJTYPBITMAP;
int OBJTYPCURSOR;
int OBJTYPLISTBOX;
int OBJTYPRICHTEXT;
int OBJTYPTREE;
int OBJTYPLISTBITMAP;
int OBJTYPLISTTAB;
int OBJTYPHEADER;



int SCOLload2D(mmachine m)
{
	int k;

//***********************************
#if DEBUG_LIB2DOS
MMechostr (0, "SCOLload2D");
#endif
//***********************************

	OBJTYPWINDOW=OBJregister(RFLWINDOW_NB,1,D2WINDOW,"OBJTYPWINDOW");
	OBJTYPBUTTON=OBJregister(RFLBUTTON_NB,0,D2BUTTON,"OBJTYPBUTTON");
	OBJTYPTEXT=OBJregister(RFLTEXT_NB,0,D2TEXT,"OBJTYPTEXT");
	OBJTYPFONT=OBJregister(RFLFONT_NB,0,D2FONT,"OBJTYPFONT");
	OBJTYPCHECK=OBJregister(RFLCHECK_NB,0,D2CHECK,"OBJTYPCHECK");
	OBJTYPMENU=OBJregister(RFLMENU_NB,0,D2MENU,"OBJTYPMENU");
	OBJTYPMENUITEM=OBJregister(RFLMENUITEM_NB,0,D2MENUITEM,"OBJTYPMENUITEM");
	OBJTYPCOMBOBOX=OBJregister(RFLCOMBOBOX_NB,0,D2COMBOBOX,"OBJTYPCOMBOBOX");
	OBJTYPBITMAP=OBJregister(RFLBITMAP_NB,0,D2BITMAP,"OBJTYPBITMAP");
	OBJTYPCURSOR=OBJregister(RFLCURSOR_NB,0,D2CURSOR,"OBJTYPCURSOR");
	OBJTYPLISTBOX=OBJregister(RFLLISTBOX_NB,0,D2LISTBOX,"OBJTYPLISTBOX");
	OBJTYPRICHTEXT=OBJregister(RFLRICHTEXT_NB,0,D2RICHTEXT,"OBJTYPRICHTEXT");
	OBJTYPTREE=OBJregister(RFLTREE_NB,0,D2TREE,"OBJTYPTREE");
	OBJTYPLISTBITMAP=OBJregister(RFLLISTBITMAP_NB,0,D2LISTBITMAP,"OBJTYPLISTBITMAP");
	OBJTYPLISTTAB=OBJregister(RFLLISTTAB_NB,0,D2LISTTAB,"OBJTYPLISTTAB");
	OBJTYPHEADER=OBJregister(RFLHEADER_NB,0,D2HEADER,"OBJTYPHEADER");

	OBJdefEvent(WM_HSCROLL,D2events);
	OBJdefEvent(WM_VSCROLL,D2events);
	OBJdefEvent(WM_GETMINMAXINFO,D2events);
	OBJdefEvent(WM_DROPFILES,D2events);
	OBJdefEvent(WM_NOTIFY,D2events);
	OBJdefEvent(WM_SETFOCUS,D2events);
	OBJdefEvent(WM_KILLFOCUS,D2events);
	OBJdefEvent(WM_DESTROY,D2events);
	OBJdefEvent(WM_CLOSE,D2events);
	OBJdefEvent(WM_CHAR,D2events);
	OBJdefEvent(WM_KEYDOWN,D2events);
	OBJdefEvent(WM_KEYUP,D2events);
	OBJdefEvent(WM_COMMAND,D2events);
	OBJdefEvent(WM_LBUTTONUP,D2events);
	OBJdefEvent(WM_RBUTTONUP,D2events);
	OBJdefEvent(WM_LBUTTONDOWN,D2events);
	OBJdefEvent(WM_RBUTTONDOWN,D2events);
	OBJdefEvent(WM_LBUTTONDBLCLK,D2events);
	OBJdefEvent(WM_RBUTTONDBLCLK,D2events);
	OBJdefEvent(WM_MOUSEMOVE,D2events);
	OBJdefEvent(WM_PAINT,D2events);
	OBJdefEvent(WM_MOVE,D2events);
	OBJdefEvent(WM_SIZE,D2events);
	OBJdefEvent(WM_MOUSEWHEEL,D2events);
	OBJdefEvent(WM_POWERBROADCAST,D2events);
    
    WM_SCOLDRAWMENU=OBJgetUserEvent();
    OBJdefEvent(WM_SCOLDRAWMENU,SCOLInternaldrawMenu);

	k=PKhardpak(m,"types.pkg",TYPEPKGSIZE,typepkgname,typepkgfun,typepkgarg,typepkgtype) ;
    if ( k ) return k;
	k=PKhardpak(m,"const.pkg",CONSTPKGSIZE,constpkgname,constpkgfun,constpkgnarg,constpkgtype);
	if ( k ) return k ;

	k = PKhardpak ( m , "window.pkg" , WINPKGSIZE,winpkgname,winpkgfun,winpkgarg,winpkgtype ) ;
	if ( k ) return k ;

	k = PKhardpak ( m , "text.pkg" , TEXTPKGSIZE , textpkgname , textpkgfun , textpkgarg , textpkgtype ) ;
	if ( k ) return k ;

	k = PKhardpak ( m ,"button.pkg" , BUTTONPKGSIZE , buttonpkgname, buttonpkgfun, buttonpkgarg, buttonpkgtype) ;
	if ( k ) return k ;
	k = PKhardpak ( m , "menu.pkg" , MENUPKGSIZE , menupkgname, menupkgfun, menupkgarg, menupkgtype ) ;
	if ( k ) return k ;

	k = PKhardpak ( m,"box.pkg" , BOXPKGSIZE , boxpkgname , boxpkgfun,boxpkgarg,boxpkgtype ) ;
	if ( k ) return k ;

	k = PKhardpak ( m ,"bitmap.pkg" , BITMAPPKGSIZE , bitmappkgname , bitmappkgfun , bitmappkgarg , bitmappkgtype ) ;
	if ( k ) return k ;


	k = PKhardpak ( m , "font.pkg" , FONTPKGSIZE,fontpkgname,fontpkgfun,fontpkgarg,fontpkgtype) ;
	if ( k ) return k ;

    
	k = PKhardpak ( m , "cursor.pkg" , CURSORPKGSIZE,cursorpkgname,cursorpkgfun,cursorpkgarg,cursorpkgtype);
	if ( k ) return k ;     


	k = PKhardpak ( m , "listbox.pkg" , LISTBOXPKGSIZE,listboxpkgname,listboxpkgfun,listboxpkgarg,listboxpkgtype ) ;
	if ( k ) return k ;     

	k = PKhardpak ( m , "richtext.pkg" ,RICHTEXTPKGSIZE,richtextpkgname,richtextpkgfun,
		richtextpkgarg,richtextpkgtype ) ;
	if ( k ) return k ;     

	k=PKhardpak(m,"wtree.pkg",WTREEPKGSIZE,WtreePkgName,WtreePkgFun,
		WtreePkgArg,WtreePkgType);
	if ( k ) return k ;     

	k=PKhardpak(m,"listbitmap.pkg",LISTBITMAPPKGSIZE,ListBitmapPkgName,
		ListBitmapPkgFun,ListBitmapPkgArg,ListBitmapPkgType);
	if ( k ) return k ;     

	k=PKhardpak(m,"listtab.pkg",LISTTABPKGSIZE,ListTabPkgName,
		ListTabPkgFun,ListTabPkgArg,ListTabPkgType);
	if ( k ) return k ;     

	k=PKhardpak(m,"help.pkg",HELPTABPKGSIZE,HelpTabPkgName,
		HelpPkgFun,HelpTabPkgArg,HelpTabPkgType);
	if ( k ) return k ;     

	k=PKhardpak(m,"iwnhead.pkg",HEADPKGSIZE,HeadPkgName,
		HeadPkgFun,HeadPkgSize,HeadPkgType);
	if ( k ) return k ;


	IniTaskIcon(m);
	IniSound(m);
	IniMMEDIA(m);
	IniVIDEO(m);
	IniPrinter(m);

	//$LB (19/06/2002)
	if ((k=SCOLloadCOLORS(m))) return k;




	if (k=PKhardpak(m,"sound.pkg",NSOUNDPKG,soundname,soundfun
		,soundnarg,soundtype)) 
		return k;

	if (k=PKhardpak(m,"AudioCmp.pkg",NAUDIOCMPPKG,audiocmpname,audiocmpfun
		,audiocmpnarg,audiocmptype)) 
		return k;                                          

	if (k=PKhardpak(m,"PRINTER.pkg",NPRINTERPKG,printername,printerfun
		,printernarg,printertype)) 
		return k;                                          

	if (k=PKhardpak(m,"VIDEO.pkg",NVIDEOPKG,videoname,videofun
		,videonarg,videotype)) 
		return k;                                          

	if (k=PKhardpak(m,"VDOCODEC.pkg",NVDOCODECPKG,vdocodecname,vdocodecfun
		,vdocodecnarg,vdocodectype)) 
		return k;                                          

	if (k=PKhardpak(m,"TASKICON.pkg",NTASKICONPKG,taskiconname,taskiconfun
		,taskiconnarg,taskicontype)) 
		return k;                   


//***********************************
#if DEBUG_LIB2DOS
MMechostr (0, "SCOLload2D end");
#endif
//***********************************

	return 0;
}