#define IMAGE_MCC_C

#include "common/extern.h"
#include "common/subtasksupp.h"
#include "common/asyncio.h"
#include "common/Grab_mcc.h"
#include "common/Subtask.h"

#include "loadsaveproj.h"

#include <graphics/gfxmacros.h>

#include <MUI/NListview_mcc.h>

extern struct ScanData scanhd;

extern void endfile (struct IFFHandle *iff);
extern BOOL saveproj2 (struct IFFHandle *iff, struct URLNode *nd);
extern struct URLNode *loadproj2 (struct IFFHandle *iff);

/* INTERNAL CLIPBOARD URL */

struct URLNode *clip_nd;

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

/// "Clipboard Hooks"

SAVEDS (LONG)
copy_url (void)
{
  struct WindowNode *wnd = NULL;

  if (oa->main_win)
    get (oa->main_win, MUIA_Main_CurrentProj, &wnd);

  if (wnd)
    DoMethod ((Object *) wnd->wnd_win, MUIM_ProjWin_CopyNode, NULL);

  return (NULL);
}

SAVEDS (LONG)
cut_url (void)
{
  struct WindowNode *wnd = NULL;

  if (oa->main_win)
    get (oa->main_win, MUIA_Main_CurrentProj, &wnd);

  if (wnd)
    {
      DoMethod ((Object *) wnd->wnd_win, MUIM_ProjWin_CopyNode, NULL);
      DoMethod ((Object *) wnd->wnd_win, MUIM_ProjWin_RemNode, NULL);
    }
  return (NULL);
}

SAVEDS (LONG)
paste_url (void)
{
  struct WindowNode *wnd = NULL;
  struct URLNode *tmpnd;

  if (oa->main_win)
    get (oa->main_win, MUIA_Main_CurrentProj, &wnd);

  if (wnd)
    {
      if ((tmpnd = newurlnodecopy (clip_nd)))
        {
          DoMethod ((Object *) wnd->wnd_win, MUIM_ProjWin_AddNode, tmpnd);
        }
    }

  return (NULL);
}

SAVEDS (LONG)
erase_url (void)
{
  struct WindowNode *wnd = NULL;

  if (oa->main_win)
    get (oa->main_win, MUIA_Main_CurrentProj, &wnd);

  if (wnd)
    DoMethod ((Object *) wnd->wnd_win, MUIM_ProjWin_RemNode, NULL);

  return (NULL);
}

///


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

/* MUI STUFF */

#define ID_LIST2_ACTIVE 1


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

/// "Image Object"
#define MUIA_NLIMG_Spec 0x9d51ffff

ULONG
mNLI_Draw (struct IClass * cl, Object * obj, struct MUIP_Draw * msg)
{
  register struct NLIData *data = (struct NLIData *) INST_DATA (cl, obj);
  DoSuperMethodA (cl, obj, (Msg) msg);
  if ((msg->flags & MADF_DRAWOBJECT) || (msg->flags & MADF_DRAWUPDATE))
    {
      WORD x1, x2, x3, x4, x5, y1, y2, y3, y4, y5;
      y1 = _top (obj);
      y2 = _bottom (obj);
      x1 = _left (obj);
      x2 = _right (obj);
      if ((data->special == 0) || (data->special == 1))
        {
          y3 = (y1 + y2) / 2;
          x3 = (x1 + x2) / 2;
          SetAPen (_rp (obj), _pens (obj)[MPEN_MARK]);
          SetBPen (_rp (obj), _pens (obj)[MPEN_SHADOW]);
          SetDrMd (_rp (obj), JAM2);
          SetDrPt (_rp (obj), (UWORD) ~ 0);
          if (data->special == 0)
            {
              Move (_rp (obj), x3 - 2, y1 + 1);
              Draw (_rp (obj), x3 - 2, y2 - 1);
              Move (_rp (obj), x3, y1 + 1);
              Draw (_rp (obj), x3, y2 - 1);
              Move (_rp (obj), x3 + 2, y1 + 1);
              Draw (_rp (obj), x3 + 2, y2 - 1);
            }
          else if (data->special == 1)
            {
              Move (_rp (obj), x1, y3 - 2);
              Draw (_rp (obj), x2, y3 - 2);
              Move (_rp (obj), x1, y3);
              Draw (_rp (obj), x2, y3);
              Move (_rp (obj), x1, y3 + 2);
              Draw (_rp (obj), x2, y3 + 2);
            }
          SetAPen (_rp (obj), _pens (obj)[MPEN_SHADOW]);
          Move (_rp (obj), x1, y2 - 1);
          Draw (_rp (obj), x1, y1 + 1);
          Draw (_rp (obj), x2, y1 + 1);
          SetAPen (_rp (obj), _pens (obj)[MPEN_SHINE]);
          Draw (_rp (obj), x2, y2 - 1);
          Draw (_rp (obj), x1, y2 - 1);
          SetDrMd (_rp (obj), JAM1);
        }
      else if (((x2 - x1) >= 10) && ((y2 - y1) >= 8))   /* and special==2 to 9 */
        {
          y3 = (y1 + y2) / 2;
          x3 = x1 + 1;
          x2--;
          SetAPen (_rp (obj), _pens (obj)[MPEN_SHADOW]);
          SetDrMd (_rp (obj), JAM1);

          y4 = y1;
          x4 = x3 + 2;
          y5 = y2;
          x5 = x2 - 6;
          if ((data->EntryHeight & 1) && (data->EntryCurrent & 1))
            y4++;
          if ((y4 & 1) != (y3 & 1))
            x4--;
          if (data->special > 5)
            x5 = x2;
          if (data->special & 1)
            y5 = y3;
          while (y4 <= y5)
            {
              WritePixel (_rp (obj), x3, y4);
              y4 += 2;
            }
          if (data->special <= 7)
            {
              while (x4 <= x5)
                {
                  WritePixel (_rp (obj), x4, y3);
                  x4 += 2;
                }
            }
          if (data->special <= 5)
            {
              Move (_rp (obj), x2 - 6, y3);
              Draw (_rp (obj), x2 - 6, y3 - 3);
              Draw (_rp (obj), x2, y3 - 3);
              Draw (_rp (obj), x2, y3 + 3);
              Draw (_rp (obj), x2 - 6, y3 + 3);
              Draw (_rp (obj), x2 - 6, y3);
              Move (_rp (obj), x2 - 4, y3);
              Draw (_rp (obj), x2 - 2, y3);
              if ((data->special == 2) || (data->special == 3))
                {
                  Move (_rp (obj), x2 - 3, y3 - 1);
                  Draw (_rp (obj), x2 - 3, y3 + 1);
                }
            }
        }
    }
  return (0);
}

ULONG
mNLI_New (struct IClass * cl, Object * obj, struct opSet * msg)
{
  register struct NLIData *data;
  if (!(obj = (Object *) DoSuperMethodA (cl, obj, (Msg) msg)))
    return (0);
  data = (struct NLIData *) INST_DATA (cl, obj);
  data->special = 0;
  return ((ULONG) obj);
}

ULONG
mNLI_AskMinMax (struct IClass * cl, Object * obj, struct MUIP_AskMinMax * msg)
{
  DoSuperMethodA (cl, obj, (Msg) msg);
  msg->MinMaxInfo->MinWidth += 8;
  msg->MinMaxInfo->DefWidth += 18;      /* the only width def value really used by NList object */
  msg->MinMaxInfo->MaxWidth += MUI_MAXMAX;
  msg->MinMaxInfo->MinHeight += 7;      /* the only height def value really used by NList object */
  msg->MinMaxInfo->DefHeight += 12;
  msg->MinMaxInfo->MaxHeight += MUI_MAXMAX;
  return (0);
}

ULONG
mNLI_Set (struct IClass * cl, Object * obj, Msg msg)
{
  register struct NLIData *data = (struct NLIData *) INST_DATA (cl, obj);
  struct TagItem *tags, *tag;
  for (tags = ((struct opSet *) msg)->ops_AttrList; (tag = (struct TagItem *) NextTagItem (&tags));)
    {
      switch (tag->ti_Tag)
        {
        case MUIA_NLIMG_EntryCurrent:
          data->EntryCurrent = tag->ti_Data;
          break;
        case MUIA_NLIMG_EntryHeight:
          data->EntryHeight = tag->ti_Data;
          break;
        case MUIA_NLIMG_Spec:
          data->special = tag->ti_Data;
          break;
        }
    }
  return (0);
}


SAVEDS (ULONG)
NLI_Dispatcher (REG (a0, struct IClass * cl), REG (a2, Object * obj), REG (a1, Msg msg))
{
  switch (msg->MethodID)
    {
    case OM_NEW:
      return ((ULONG) mNLI_New (cl, obj, (struct opSet *) msg));
    case OM_SET:
      return ((ULONG) mNLI_Set (cl, obj, (Msg) msg));
    case MUIM_AskMinMax:
      return ((ULONG) mNLI_AskMinMax (cl, obj, (struct MUIP_AskMinMax *) msg));
    case MUIM_Draw:
      return ((ULONG) mNLI_Draw (cl, obj, (struct MUIP_Draw *) msg));
    }
  return (DoSuperMethodA (cl, obj, msg));
}

///

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

/// "DisplayLI_TextFunc"
void
DisplayLI_TextFunc (REG (a0, struct Hook *hook),
                    REG (a2, char **array),
                    REG (a1, struct URLNode *un))
{
/*  Object *obj = (Object *) hook->h_Data; */

  if (un)
    {
      switch (un->status)
        {
        case ST_CLEAR:
          array[0] = "\033o[1|0|0]";
          break;

        case ST_GRABBING:
          array[0] = "\033o[2|0|0]";
          break;

        case ST_GRABBED:
          array[0] = "\033o[3|0|0]";
          break;

        case ST_DECODING:
          array[0] = "\033o[4|0|0]";
          break;

        case ST_EDITING:
          array[0] = "\033o[5|0|0]";
          break;

        case ST_INTERRUPT:
          array[0] = "\033o[6|0|0]";
          break;

        case ST_ERROR:
          array[0] = "\033o[7|0|0]";
          break;

        default:
          un->status = ST_CLEAR;
          array[0] = "\033o[1|0|0]";
          break;
        }

      array[1] = un->url;
      array[2] = un->type;
      array[3] = un->buf_size;
      array[4] = un->buf_date;
      //array[5] = "0";


      array[0 + DISPLAY_ARRAY_MAX] = "\033c";
      array[1 + DISPLAY_ARRAY_MAX] = "\033l";
      array[2 + DISPLAY_ARRAY_MAX] = "\033c";
      array[3 + DISPLAY_ARRAY_MAX] = "\033c";
      array[4 + DISPLAY_ARRAY_MAX] = "\033c";
      //array[5 + DISPLAY_ARRAY_MAX] =  "\033c";
    }
  else
    {
      array[0] = STRING (Title_Status, " S ");
      array[1] = STRING (Title_Urls, "     URL Titles     ");
      array[2] = STRING (Title_Type, " Type ");
      array[3] = STRING (Title_Size, " Size ");
      array[4] = STRING (Title_Date, " Date ");
      //array[5] = STRING (Title_Age ,  " Age ");

      array[0 + DISPLAY_ARRAY_MAX] = "\033c";
      array[1 + DISPLAY_ARRAY_MAX] = "\033c";
      array[2 + DISPLAY_ARRAY_MAX] = "\033c";
      array[3 + DISPLAY_ARRAY_MAX] = "\033c";
      array[4 + DISPLAY_ARRAY_MAX] = "\033c";
      //array[5 + DISPLAY_ARRAY_MAX] = "\033c";
    }
}
///

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

Object *
openprojwin (struct EditNode *en)
{
  APTR win;

  en->gn_win = win = ProjectWinObject,
    MUIA_Window_Title, (ULONG) en->gn_title,
    End;

  return ((Object *) win);
}



/* *********************************************** */
/*                                                 */
/*  WinGrab MUI class.                             */
/*                                                 */
/* *********************************************** */

/// "New"
ULONG
mProjWin_New (struct IClass * cl, Object * obj, struct opSet * msg)
{
  APTR GR_ALL;
  APTR LI_Text, LI_ListView;
  APTR MN_inuse, PR_Horiz, PR_Vert;
  APTR BT_ADD, BT_EDIT, BT_REMOVE;

  static const struct Hook DisplayLI_TextHook =
  {
    {NULL, NULL}, (HOOKFUNC) DisplayLI_TextFunc, NULL, NULL};
// *INDENT-OFF*
  obj = (Object *) DoSuperNew (cl, obj,
    MUIA_Window_AppWindow, TRUE,
    MUIA_Window_SizeGadget, TRUE,
    MUIA_Window_Activate, TRUE,
    MUIA_Window_ID, MAKE_ID('P','R','O','J'),
    MUIA_HelpNode, "WIN_PROJECT",
    MUIA_Window_UseBottomBorderScroller, TRUE,
    MUIA_Window_UseRightBorderScroller, TRUE,
    WindowContents, GroupObject,
    Child, GR_ALL = VGroup,

        Child, HGroup,
               Child, BT_ADD = MUI_MakeObject(MUIO_Button, STRING (Label_Add, "Add"),
                               MUIA_ShortHelp, STRING (ShortHelp_Add, "\33cAdd a new url\nto current project"),
                               End,
               Child, BT_EDIT = SimpleButton(STRING (Label_Edit, "Edit")),
               Child, BT_REMOVE = SimpleButton(STRING (Label_Remove, "Remove")),
               Child, HVSpace,
        End,
   End,

        Child, LI_ListView = NListviewObject,
            MUIA_CycleChain, 1,
            MUIA_NListview_Horiz_ScrollBar, MUIV_NListview_HSB_None,
            MUIA_NListview_Vert_ScrollBar, MUIV_NListview_VSB_None,
            MUIA_NListview_NList, LI_Text = NListObject,
                MUIA_NList_DefaultObjectOnClick, TRUE,
                MUIA_NList_DisplayHook, &DisplayLI_TextHook,
                MUIA_NList_Format, "NOBAR NOTITLEBUTTON,BAR NOTITLEBUTTON,BAR COLWIDTH=10 NOTITLEBUTTON,BAR COLWIDTH=5,BAR COLWIDTH=8 NOTITLEBUTTON", //,BAR COLWIDTH=3 WEIGHT=0",
                MUIA_NList_AutoVisible, TRUE,              // MINWIDTH=-1
                MUIA_NList_TitleSeparator, TRUE,
                MUIA_NList_Title, TRUE,
                MUIA_NList_TitleClick, 2,
                MUIA_NList_EntryValueDependent, TRUE,
                //MUIA_NList_Pool, gd.gd_pool,  //I'd use a single task pool
                MUIA_NList_Active, MUIV_NList_Active_Top,
                MUIA_NList_DragSortable, TRUE,
                MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Shifted,
                MUIA_ContextMenu, MUIV_NList_ContextMenu_Never,
                MUIA_NList_AutoCopyToClip, TRUE,
                MUIA_NList_Exports, MUIV_NList_Exports_Cols,
                MUIA_NList_Imports, MUIV_NList_Imports_Cols,


            End,
        End,

        Child, PR_Horiz = ScrollbarObject,
            MUIA_Group_Horiz, TRUE,
            MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Bottom,
        End,
        Child, PR_Vert = ScrollbarObject,
            MUIA_Group_Horiz, TRUE,
            MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Right,
        End,
    End,

    TAG_MORE, msg->ops_AttrList);

// *INDENT-ON*






  if (obj)
    {
      register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
      // Data Init

      data->self = obj;
      data->all = GR_ALL;
      data->listview = LI_Text;
      data->dir = NULL;
      data->title = (STRPTR) xget (obj, MUIA_Window_Title);
      if ((data->wnd = (struct WindowNode *) GetTagData (MUIA_ProjWin_WinNode, NULL, msg->ops_AttrList)))
        data->wnd->wnd_win = (APTR) obj;

      data->grabwin = NULL;

      NewList ((struct List *) &data->list);
      NewList ((struct List *) &data->subwinlist);
      data->list.projwin = obj;

      InitSemaphore (&data->pprefs.sema);

      data->pprefs.strdowndir = newstrcpy (gd.gd_pool, "net/");
      //data->pprefs.downdir = Lock (data->pprefs.strdowndir, ACCESS_READ);
      data->pprefs.indexname = newstrcpy (gd.gd_pool, "index.html");
      #ifndef __DEMO__
      data->pprefs.socknum = 4;
      #else
      data->pprefs.socknum = 1;
      #endif


      if ((data->inuse = MN_inuse = MenuitemObject,
           MUIA_Menuitem_Title, data->title,
           End))
        {
          DoMethod ((Object *) oa->menu_inuse, OM_ADDMEMBER, MN_inuse);
          DoMethod ((Object *) MN_inuse,
                    MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
                    obj, 3,
                    MUIM_Set, MUIA_Window_Open, TRUE);
        }                       // End Add menu


      // Methods

      DoMethod ((Object *) obj,
                MUIM_Notify, MUIA_Application_Iconified, TRUE,
                obj,
                3,
                MUIM_Set, MUIA_Window_Open, FALSE);

      DoMethod ((Object *) obj, MUIM_Notify,
                MUIA_Window_InputEvent, "del", obj,
                2, MUIM_ProjWin_RemNode, NULL);


      DoMethod ((Object *) LI_Text, MUIM_Notify,
                MUIA_NList_DoubleClick, MUIV_EveryTime,
                obj, 2, MUIM_ProjWin_DClick, NULL);

      DoMethod ((Object *) BT_ADD, MUIM_Notify, MUIA_Pressed, FALSE,
                obj, 2, MUIM_ProjWin_SetUrl, NULL);

      DoMethod ((Object *) BT_EDIT, MUIM_Notify, MUIA_Pressed, FALSE,
                obj, 2, MUIM_ProjWin_DClick, NULL);

      DoMethod ((Object *) BT_REMOVE, MUIM_Notify, MUIA_Pressed, FALSE,
                obj, 2, MUIM_ProjWin_RemNode, NULL);


      //For scrollbars...
      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Horiz_Entries, MUIV_EveryTime,
       PR_Horiz, 3, MUIM_NoNotifySet, MUIA_Prop_Entries, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Horiz_Visible, MUIV_EveryTime,
       PR_Horiz, 3, MUIM_NoNotifySet, MUIA_Prop_Visible, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Horiz_First, MUIV_EveryTime,
         PR_Horiz, 3, MUIM_NoNotifySet, MUIA_Prop_First, MUIV_TriggerValue);

      DoMethod ((Object *) PR_Horiz, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime,
                LI_Text, 3, MUIM_NoNotifySet, MUIA_NList_Horiz_First, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_HorizDeltaFactor, MUIV_EveryTime,
                PR_Horiz, 3, MUIM_NoNotifySet, MUIA_Prop_DeltaFactor, MUIV_TriggerValue);



      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Prop_Entries, MUIV_EveryTime,
        PR_Vert, 3, MUIM_NoNotifySet, MUIA_Prop_Entries, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Prop_Visible, MUIV_EveryTime,
        PR_Vert, 3, MUIM_NoNotifySet, MUIA_Prop_Visible, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_Prop_First, MUIV_EveryTime,
          PR_Vert, 3, MUIM_NoNotifySet, MUIA_Prop_First, MUIV_TriggerValue);

      DoMethod ((Object *) PR_Vert, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime,
                LI_Text, 3, MUIM_NoNotifySet, MUIA_NList_Prop_First, MUIV_TriggerValue);

      DoMethod ((Object *) LI_Text, MUIM_Notify, MUIA_NList_VertDeltaFactor, MUIV_EveryTime,
                PR_Vert, 3, MUIM_NoNotifySet, MUIA_Prop_DeltaFactor, MUIV_TriggerValue);

      //                *

      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, NImageObject, 0, ~0L);         // for special rendering

      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[0], 1, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[1], 2, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[2], 3, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[3], 4, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[4], 5, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[5], 6, ~0L);
      DoMethod ((Object *) LI_Text, MUIM_NList_UseImage, oa->proj_stimg[6], 7, ~0L);


      DoMethod (obj,
                MUIM_Window_SetCycleChain,
                BT_ADD,
                BT_EDIT,
                BT_REMOVE,
                LI_Text,
                NULL);


      DoMethod ((Object *) oa->App, OM_ADDMEMBER, obj);
      set (obj, MUIA_Window_Open, TRUE);


      return ((ULONG) obj);
    }
  else
    error_req (STRING (MSG_OK, "*_OK"), "%s", STRING (ERR_NOMEM, "Out of Memory"));

  D (printf ("Class new error: ProjWin\n"));

  return (NULL);
}
///

/// "Dispose"
__inline void
FreeUrlList (struct List *ls)
{
  struct URLNode *nd;

  while ((nd = (struct URLNode *) RemHead (ls)))
    {
      FreeUrlNode (nd);
    }
}

ULONG
mProjWin_Dispose (struct IClass *cl, Object * obj, Msg msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  DoMethod (obj, MUIM_ProjWin_StopGrab, NULL);
  DoMethod ((Object *) data->listview, MUIM_NList_UseImage, NULL, -1, 0);

  FreeUrlList ((struct List *) &data->list);

  if (data->title)
    FreeVecPooled (gd.gd_pool, data->title);

  if (data->dir)
    FreeVecPooled (gd.gd_pool, data->dir);

  DoMethod ((Object *) oa->App, OM_REMMEMBER, obj);

  return (DoSuperMethodA (cl, obj, msg));
}
///

/// "ShutDown"
__inline void
FreeSubWindow (struct List *ls)
{
  struct EditWinNode *nd;

  while ((nd = (struct EditWinNode *) ls->lh_Head)->wnd_node.mln_Succ != NULL)
    {
      DoMethod ((Object *) nd->wnd_win, OM_DISPOSE, NULL);
    }
}

ULONG
mProjWin_ShutDown (struct IClass *cl, Object * obj, Msg msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  FreeSubWindow ((struct List *) &data->subwinlist);

  return (DoSuperMethodA (cl, obj, msg));
}
///

/// "Setup"
ULONG
mProjWin_Setup (struct IClass * cl, Object * obj, struct MUIP_HandleInput * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  if (!(DoSuperMethodA (cl, obj, (Msg) msg)))
    return (FALSE);

  MUI_RequestIDCMP (obj, IDCMP_RAWKEY);


  return (TRUE);
}
///

/// "Cleanup"
ULONG
mProjWin_Cleanup (struct IClass * cl, Object * obj, struct MUIP_HandleInput * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  MUI_RejectIDCMP (obj, IDCMP_RAWKEY);

  return (DoSuperMethodA (cl, obj, (Msg) msg));
}
///

/// "Set"
ULONG
mProjWin_Set (struct IClass * cl, Object * obj, Msg msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct TagItem *tags, *tag;
  for (tags = ((struct opSet *) msg)->ops_AttrList; (tag = (struct TagItem *) NextTagItem (&tags));)
    {
      switch (tag->ti_Tag)
        {
        case MUIA_ProjWin_Sleep:

          if (tag->ti_Data == TRUE)
            {
              set (data->all, MUIA_Disabled, TRUE);
              data->wnd->status |= PWST_REQ;
              set (oa->main_win, MUIA_Main_CurrentProj, data->wnd);
            }
          else if (tag->ti_Data == FALSE)
            {
              set (data->all, MUIA_Disabled, FALSE);
              data->wnd->status &= ~PWST_REQ;
              set (oa->main_win, MUIA_Main_CurrentProj, data->wnd);
            }

          break;

        case MUIA_ProjWin_Dir:
          data->dir = (STRPTR) tag->ti_Data;
          break;

        case MUIA_ProjWin_Grabwin:
          if ((data->grabwin = (APTR) tag->ti_Data) == NULL)
            {
              set (data->all, MUIA_Disabled, FALSE);
              //set (obj, MUIA_Window_Sleep, FALSE);
              data->wnd->status &= ~PWST_GRABBING;

              set (oa->main_win, MUIA_Main_CurrentProj, data->wnd);
            }
          break;


        case MUIA_Window_Activate:
          if (tag->ti_Data)
            {
              set (oa->main_win, MUIA_Main_CurrentProj, data->wnd);
            }
          break;

        case MUIA_Window_CloseRequest:
          if (tag->ti_Data == TRUE)
            {
              if (!(data->wnd->status & PWST_REQ))
                {

                  if ((prefs->closereq) ? (error_req (STRING (ERR_OKCANCEL, "*_OK|_Cancel"), STRING (MSG_CLOSEPROJ, "\033c Do you want really \nclose this window ?")) > 0) : TRUE)
                    {
                      set (oa->main_win, MUIA_Main_CloseProj, data->wnd);

                      if (data->inuse)
                        {
                          DoMethod ((Object *) oa->menu_inuse, OM_REMMEMBER, data->inuse);
                          MUI_DisposeObject ((Object *) data->inuse);

                          data->inuse = NULL;
                        }

                      DoMethod (obj, MUIM_ProjWin_ShutDown, NULL);
                      DoMethod ((Object *) oa->App, MUIM_Application_PushMethod, obj, 2, OM_DISPOSE, NULL);

                      return (NULL);
                    }
                }
              else
                error_req (STRING (MSG_OK, "*_OK"), "\033c%s", STRING (ERR_CLOSEREQ, " First close file requester! "));

            }
        }
    }

  return (DoSuperMethodA (cl, obj, msg));
}
///

/// "Get"
ULONG
mProjWin_Get (struct IClass * cl, Object * obj, struct opGet * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  switch (msg->opg_AttrID)
    {
    case MUIA_ProjWin_ProjPrefs:
      *(msg->opg_Storage) = (ULONG) & data->pprefs;
      return (TRUE);
    }

  return (DoSuperMethodA (cl, obj, (Msg) msg));
}
///

/// "AddNode"
ULONG
mProjWin_AddNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  AddTail ((struct List *) &data->list, (struct Node *) msg->nd);

  DoMethod ((Object *) data->listview,
            MUIM_NList_InsertSingle, msg->nd, MUIV_NList_Insert_Bottom);

  return (NULL);
}
///

/// "AddListNode"
ULONG
mProjWin_AddListNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddListNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct URLNode *und;
  struct URLNode *nd;
  int i, count = 0;

  set ((Object *) data->listview, MUIA_NList_Quiet, TRUE);

  ObtainSemaphore (msg->sema);
  und = (struct URLNode *) RemHead (msg->linklist);

  while (und)
    {
      for (i = 0;; i++)
        {
          DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, i, &nd);
          if (!nd)
            {
              i = 0;
              break;
            }
          else if (stricmp (nd->url, und->url) == 0)
            {
              i = -1;
              break;
            }

        }

      if (i > -1)
        {
          DoMethod (obj, MUIM_ProjWin_AddNode, und);
        }
      count++;

      und = (struct URLNode *) RemHead (msg->linklist);
    }

  ReleaseSemaphore (msg->sema);

  set ((Object *) data->listview, MUIA_NList_Quiet, FALSE);

  if (data->grabwin && (data->wnd->status == PWST_GRABBING))
    DoMethod ((Object *) data->grabwin, MUIM_WGrab_StartGrab, &data->list);

  return (NULL);
}
///

/// "RemNode"
ULONG
mProjWin_RemNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct URLNode *nd = NULL;

  if (msg->nd)
    {
      D (printf ("Nop!\n"));
    }
  else
    {
      DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &nd);

      if (nd)
        {
          if ((nd->status != ST_GRABBING) || (nd->status != ST_EDITING))
            {
              DoMethod ((Object *) data->listview, MUIM_NList_Remove, MUIV_NList_Remove_Active);

              Remove ((struct Node *) nd);
              FreeUrlNode (nd);
            }
        }
    }

  return (NULL);
}
///

/// "CopyNode"
ULONG
mProjWin_CopyNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct URLNode *nd = NULL;

  DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &nd);

  if (nd)
    {
      if ((nd->status != ST_GRABBING) || (nd->status != ST_EDITING))
        {
          FreeUrlNode (clip_nd);
          clip_nd = newurlnodecopy (nd);
        }
    }

  return (NULL);
}
///

/// "Redraw Node"
ULONG
mProjWin_Redraw (struct IClass * cl, Object * obj, struct MUIP_NList_RedrawEntry * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct URLNode *nd = (struct URLNode *) msg->entry;

  set ((Object *) data->listview, MUIA_NList_DisplayRecall, TRUE);

  if (nd)
    DoMethod ((Object *) data->listview, MUIM_NList_RedrawEntry, nd);
  else
    DoMethod ((Object *) data->listview, MUIM_NList_Redraw, MUIV_NList_Redraw_All);

  set ((Object *) data->listview, MUIA_NList_DisplayRecall, FALSE);

  return (NULL);
}
///

/// "Grabbed Node"
ULONG
mProjWin_GrabbedNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_GrabbedNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct DateTime dt;
  struct URLNode *nd = (struct URLNode *) msg->nd;

  if (nd->size < 1000)
    sprintf (nd->buf_size, "%ld", nd->size);
  else if (nd->size < 1000000)
    sprintf (nd->buf_size, "%ld Kb", nd->size / 1000);
  else if (nd->size < 1000000000)
    sprintf (nd->buf_size, "%ld Mb", nd->size / 1000000);
  else
    sprintf (nd->buf_size, "n.a.");

  memcpy (&dt.dat_Stamp, &nd->date, sizeof (dt.dat_Stamp));

  dt.dat_Format = FORMAT_DOS;
  dt.dat_Flags = 0;
  dt.dat_StrDay = NULL;
  dt.dat_StrTime = NULL;
  dt.dat_StrDate = nd->buf_date;

  if (!DateToStr (&dt))
    nd->buf_date[0] = '\0';

  DoMethod ((Object *) data->listview, MUIM_NList_RedrawEntry, nd);

  if (data->grabwin && (data->wnd->status == PWST_GRABBING))
    DoMethod ((Object *) data->grabwin, MUIM_WGrab_StartGrab, &data->list);

  return (NULL);
}
///

/// "DClick"
ULONG
mProjWin_DClick (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  LONG pos;
  struct URLNode *nd;

  if (!(data->wnd->status & PWST_GRABBING))
    {
      get (data->listview, MUIA_NList_EntryClick, &pos);
      if (pos == -2)
        get (data->listview, MUIA_NList_Active, &pos);

      if (pos > -1)
        {
          DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, pos, &nd);

          if (nd)
            {
              if (is_st_free (nd->status))
                {
                  nd->status = ST_EDITING;

                  DoMethod ((Object *) data->listview, MUIM_NList_Redraw, pos);
                  DoMethod (obj, MUIM_ProjWin_SetUrl, nd);
                }
            }
        }
    }
  return (NULL);
}
///

/// "Grab"
ULONG
mProjWin_Grab (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  // Now I'm interest to interface...
  if (!data->grabwin)
    data->grabwin = WinGrabObject,
      MUIA_UrlEditWin_ProjWin, obj,
      End;

  if (data->grabwin)
    {
      DoMethod ((Object *) data->grabwin, MUIM_WGrab_StartGrab, &data->list);

      set (data->all, MUIA_Disabled, TRUE);
      //set (obj, MUIA_Window_Sleep, TRUE);

      if (!test_flag (data->wnd->status, PWST_GRABBING))
        {
          set_flag (data->wnd->status, PWST_GRABBING);
          set (oa->main_win, MUIA_Main_CurrentProj, data->wnd);
        }

      return (TRUE);
    }

  return (FALSE);
}
///

/// "Update"
ULONG
mProjWin_Update (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct URLNode *nd;
  int i;

  set ((Object *) data->listview, MUIA_NList_Quiet, TRUE);

  for (i = 0;; i++)
    {
      DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, i, &nd);

      if (!nd)
        break;
      else if (nd->status == ST_GRABBED)
        {
          nd->status = ST_CLEAR;
          DoMethod ((Object *) data->listview, MUIM_NList_RedrawEntry, nd);
        }
      else if (nd->status == ST_ERROR)
        {
          nd->status = ST_CLEAR;
          DoMethod ((Object *) data->listview, MUIM_NList_RedrawEntry, nd);
        }
    }

  set ((Object *) data->listview, MUIA_NList_Quiet, FALSE);

  DoMethod (obj, MUIM_ProjWin_Grab, NULL);

  return (NULL);
}
///

/// "StopGrab"
ULONG
mProjWin_RemUrl (struct IClass * cl, Object * obj, struct MUIP_WGrab_RemUrl * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  if (data->grabwin)
    {
      if (test_flag (data->wnd->status, PWST_GRABBING))
        {
          toggle_flag (data->wnd->status, PWST_GRABBING);

          set (data->grabwin, MUIA_Window_CloseRequest, TRUE);
          //DoMethod ((Object *) data->grabwin, MUIM_WGrab_RemUrl, NULL);
        }

      //set (data->grabwin, MUIA_Window_CloseRequest, TRUE);
    }

  return (NULL);
}
///

/// "SetUrl"
ULONG
mProjWin_SetUrl (struct IClass * cl, Object * obj, struct MUIP_ProjWin_AddNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct EditWinNode *worknode;

  if ((worknode = (struct EditWinNode *) AllocSPooled (gd.gd_pool, sizeof (struct EditWinNode))))
    {
      worknode->wnd_win = (char *) UrlEditWinObject,
        MUIA_UrlEditWin_ProjWin, obj,
        MUIA_UrlEditWin_URLNode, msg->nd,
        MUIA_UrlEditWin_WinNode, worknode,
        End;

      if (worknode->wnd_win)
        {
          AddTail (&data->subwinlist, (struct Node *) worknode);

          return ((ULONG) worknode);
        }

      FreeSPooled (gd.gd_pool, worknode, sizeof (struct EditWinNode));
    }

  return (NULL);
}
///

/// "ChangeNode"
ULONG
mProjWin_ChangeNode (struct IClass * cl, Object * obj, struct MUIP_ProjWin_ChangeNode * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct URLNode *nd;
  int i;

  Insert ((struct List *) &data->list, (struct Node *) msg->newnd, (struct Node *) msg->oldnd);
  Remove ((struct Node *) msg->oldnd);

  for (i = 0;; i++)
    {
      DoMethod ((Object *) data->listview, MUIM_NList_GetEntry, i, &nd);
      if (!nd)
        {
          i = -1;
          break;
        }
      else if (nd == msg->oldnd)
        break;
    }

  //set((Object *)data->listview, MUIA_NList_Quiet, TRUE);
  if (i > -1)
    {
      DoMethod ((Object *) data->listview, MUIM_NList_ReplaceSingle, msg->newnd, i, NOWRAP, ALIGN_LEFT);
      //DoMethod((Object*)data->listview, MUIM_NList_Remove, i);
    }
  else
    {
      DoMethod ((Object *) data->listview, MUIM_NList_InsertSingle, msg->newnd, MUIV_NList_Insert_Active);
      DoMethod ((Object *) data->listview, MUIM_NList_Remove, MUIV_NList_Remove_Active);
    }
  //set((Object *)data->listview, MUIA_NList_Quiet, FALSE);

  FreeUrlNode (msg->oldnd);

  return (NULL);
}
///

/// "Open"
ULONG
mProjWin_Open (struct IClass * cl, Object * obj, struct MUIP_ProjWin_Open * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct IFFHandle *iff;
  struct URLNode *und;
  BPTR old = NULL, dir;

  if (msg->dirname)
    {
      if ((dir = Lock (msg->dirname, ACCESS_READ)))
        old = CurrentDir (dir);
      else
        error_req (STRING (MSG_OK, "*_OK"), "%s\"%s\"", STRING (ERR_NODIR, "\033cI can't find dir: \n"), msg->dirname);
    }

  if (msg->filename == NULL)
    msg->filename = data->title;

  iff = startread ((char *) msg->filename, &data->pprefs);

  if (msg->dirname && old)
    {
      CurrentDir (old);
      UnLock (dir);
    }

  if (iff)
    {

      set ((Object *) data->listview, MUIA_NList_Quiet, TRUE);

      while ((und = loadproj2 (iff)))
        {
          DoMethod ((Object *) obj,
                    MUIM_ProjWin_AddNode, und);
        }

      //CloseAsync (filein);
      CloseIFF (iff);
      Close (iff->iff_Stream);
      FreeIFF (iff);

      set ((Object *) data->listview, MUIA_NList_Quiet, FALSE);

      return (1);
    }

  return (NULL);
}
///

/// "Insert"
ULONG
mProjWin_Insert (struct IClass * cl, Object * obj, struct MUIP_ProjWin_Open * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct IFFHandle *iff;
  struct URLNode *und;
  BPTR old = NULL, dir;

  if (msg->dirname)
    {
      if ((dir = Lock (msg->dirname, ACCESS_READ)))
        old = CurrentDir (dir);
      else
        error_req (STRING (MSG_OK, "*_OK"), "%s\"%s\"", STRING (ERR_NODIR, "\033cI can't find dir: \n"), msg->dirname);
    }

  if (msg->filename == NULL)
    msg->filename = data->title;

  iff = startread ((char *) msg->filename, NULL);

  if (msg->dirname && old)
    {
      CurrentDir (old);
      UnLock (dir);
    }

  if (iff)
    {

      set ((Object *) data->listview, MUIA_NList_Quiet, TRUE);

      while ((und = loadproj2 (iff)))
        {
          DoMethod ((Object *) obj,
                    MUIM_ProjWin_AddNode, und);
        }

      //CloseAsync (filein);
      CloseIFF (iff);
      Close (iff->iff_Stream);
      FreeIFF (iff);

      set ((Object *) data->listview, MUIA_NList_Quiet, FALSE);

      return (1);
    }

  return (NULL);
}
///

/// "Inserthtml"
ULONG
mProjWin_Inserthtml (struct IClass * cl, Object * obj, struct MUIP_ProjWin_Open * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);
  struct ScanMessage *sm;
  char *filename;
  int size;

  if (msg->filename)
    if ((filename = (char *) AllocVecPooled (gd.gd_pool, size = strlen (msg->filename) + s_strlen (msg->dirname) + 4)))
      {
        if (msg->dirname)
          {
            strcpy (filename, msg->dirname);
            AddPart (filename, msg->filename, size);
          }
        else
          strcpy (filename, msg->filename);

        if ((sm = (struct ScanMessage *) AllocSPooled (gd.gd_pool, sizeof (struct ScanMessage))))
          {
            sm->proj = obj;
            sm->nd = NULL;
            sm->filename = filename;

            ObtainSemaphore (&scanhd.lsema);
            AddTail (&scanhd.scanlist, (struct Node *) sm);
            ReleaseSemaphore (&scanhd.lsema);

            Signal (&gd.gd_subtask->st_Task->pr_Task, SIGBREAKF_CTRL_C);

            return (NULL);
          }

        FreeVecPooled (gd.gd_pool, filename);
      }

  return (NULL);
}
///

/// "Save"
ULONG
mProjWin_Save (struct IClass * cl, Object * obj, struct MUIP_ProjWin_Open * msg)
{
  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);

  struct IFFHandle *iff;
  struct URLNode *nd;
  BPTR dir, old = NULL;


  if (msg->filename)
    {                           // if there is a new title

      char *filename = newstrcpy (gd.gd_pool, msg->filename);
      if (filename)
        {
          set (obj, MUIA_Window_Title, filename);
          set (data->inuse, MUIA_Menuitem_Title, filename);

          if (data->title)
            FreeVecPooled (gd.gd_pool, data->title);
          data->title = data->wnd->title = (char *) filename;

          if (msg->dirname)
            {                   // if there is a new dir

              if (data->dir)
                FreeVecPooled (gd.gd_pool, data->dir);
              data->dir = data->wnd->dir = newstrcpy (gd.gd_pool, msg->dirname);
            }
        }
    }

  if (data->dir)
    {
      if ((dir = Lock (data->dir, ACCESS_READ)))
        {
          old = CurrentDir (dir);
        }
    }

  iff = startwrite ((char *) data->title, &data->pprefs);

  if ((data->dir && old))
    {
      CurrentDir (old);
      UnLock (dir);
    }

  if (iff)
    {

      nd = (struct URLNode *) data->list.mlist.mlh_Head;
      while (nd->un_node.mln_Succ)
        {
          saveproj2 (iff, nd);
          nd = (struct URLNode *) nd->un_node.mln_Succ;
        }


      endfile (iff);
    }
  else
    error_req (STRING (MSG_OK, "*_OK"), STRING (ERR_Save, "Saving Error"));


  return (NULL);
}
///

/// "Handle Input"
ULONG
mProjWin_HandleInput (struct IClass * cl, Object * obj, struct MUIP_HandleInput * msg)
{
#define _between(a,x,b) ((x)>=(a) && (x)<=(b))
#define _isinobject(x,y) (_between(_mleft(obj),(x),_mright(obj)) && _between(_mtop(obj),(y),_mbottom(obj)))

  register struct ProjWinData *data = (struct ProjWinData *) INST_DATA (cl, obj);


  /*if (msg->muikey!=MUIKEY_NONE)
     {
     switch (msg->muikey)
     {
     //case MUIKEY_LEFT : data->sx=-1; MUI_Redraw(obj,MADF_DRAWUPDATE); break;
     //case MUIKEY_RIGHT: data->sx= 1; MUI_Redraw(obj,MADF_DRAWUPDATE); break;
     //case MUIKEY_UP   : data->sy=-1; MUI_Redraw(obj,MADF_DRAWUPDATE); break;
     //case MUIKEY_DOWN : data->sy= 1; MUI_Redraw(obj,MADF_DRAWUPDATE); break;
     }
     } */

  if (msg->imsg)
    {
      switch (msg->imsg->Class)
        {
        case IDCMP_RAWKEY:
          D (printf ("Rwakey : %d\n", msg->imsg->Code));


          break;

          /*case IDCMP_MOUSEBUTTONS:
             {
             if (msg->imsg->Code==SELECTDOWN)
             {
             if (_isinobject(msg->imsg->MouseX,msg->imsg->MouseY))
             {
             //data->x = msg->imsg->MouseX;
             //data->y = msg->imsg->MouseY;
             MUI_Redraw(obj,MADF_DRAWUPDATE);
             MUI_RequestIDCMP(obj,IDCMP_MOUSEMOVE);
             }
             }
             else
             MUI_RejectIDCMP(obj,IDCMP_MOUSEMOVE);
             }
             break;

             case IDCMP_MOUSEMOVE:
             {
             if (_isinobject(msg->imsg->MouseX,msg->imsg->MouseY))
             {
             //data->x = msg->imsg->MouseX;
             //data->y = msg->imsg->MouseY;
             MUI_Redraw(obj,MADF_DRAWUPDATE);
             }
             }
             break; */
        }
    }

  return (DoSuperMethodA (cl, obj, (Msg) msg));
}

///

/// "Dispatcher"
SAVEDS (ULONG)
ProjWin_Dispatcher (REG (a0, struct IClass * cl), REG (a2, Object * obj), REG (a1, Msg msg))
{
  switch (msg->MethodID)
    {
    case OM_NEW:
      return ((ULONG) mProjWin_New (cl, obj, (struct opSet *) msg));
    case OM_DISPOSE:
      return ((ULONG) mProjWin_Dispose (cl, obj, (Msg) msg));
    case OM_SET:
      return ((ULONG) mProjWin_Set (cl, obj, (Msg) msg));
    case OM_GET:
      return ((ULONG) mProjWin_Get (cl, obj, (struct opGet *) msg));

    case MUIM_Setup:
      return ((ULONG) mProjWin_Setup (cl, obj, (struct MUIP_HandleInput *) msg));
    case MUIM_Cleanup:
      return ((ULONG) mProjWin_Cleanup (cl, obj, (struct MUIP_HandleInput *) msg));

    case MUIM_HandleInput:
      return ((ULONG) mProjWin_HandleInput (cl, obj, (struct MUIP_HandleInput *) msg));

    case MUIM_ProjWin_SetUrl:
      return ((ULONG) mProjWin_SetUrl (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));

    case MUIM_ProjWin_AddNode:
      return ((ULONG) mProjWin_AddNode (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));
    case MUIM_ProjWin_AddListNode:
      return ((ULONG) mProjWin_AddListNode (cl, obj, (struct MUIP_ProjWin_AddListNode *) msg));
    case MUIM_ProjWin_RemNode:
      return ((ULONG) mProjWin_RemNode (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));
    case MUIM_ProjWin_ChangeNode:
      return ((ULONG) mProjWin_ChangeNode (cl, obj, (struct MUIP_ProjWin_ChangeNode *) msg));
    case MUIM_ProjWin_CopyNode:
      return ((ULONG) mProjWin_CopyNode (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));

    case MUIM_ProjWin_Grab:
      return ((ULONG) mProjWin_Grab (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));
    case MUIM_ProjWin_Update:
      return ((ULONG) mProjWin_Update (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));

    case MUIM_ProjWin_Open:
      return ((ULONG) mProjWin_Open (cl, obj, (struct MUIP_ProjWin_Open *) msg));

    case MUIM_ProjWin_Insert:
      return ((ULONG) mProjWin_Insert (cl, obj, (struct MUIP_ProjWin_Open *) msg));
    case MUIM_ProjWin_Inserthtml:
      return ((ULONG) mProjWin_Inserthtml (cl, obj, (struct MUIP_ProjWin_Open *) msg));
    case MUIM_ProjWin_Save:
      return ((ULONG) mProjWin_Save (cl, obj, (struct MUIP_ProjWin_Open *) msg));
    case MUIM_ProjWin_DClick:
      return ((ULONG) mProjWin_DClick (cl, obj, (struct MUIP_ProjWin_AddNode *) msg));

    case MUIM_NList_RedrawEntry:
      return ((ULONG) mProjWin_Redraw (cl, obj, (struct MUIP_NList_RedrawEntry *) msg));
    case MUIM_ProjWin_GrabbedNode:
      return ((ULONG) mProjWin_GrabbedNode (cl, obj, (struct MUIP_ProjWin_GrabbedNode *) msg));

    case MUIM_ProjWin_StopGrab:
    case MUIM_WGrab_RemUrl:
      return ((ULONG) mProjWin_RemUrl (cl, obj, (struct MUIP_WGrab_RemUrl *) msg));

    case MUIM_ProjWin_ShutDown:
      return ((ULONG) mProjWin_ShutDown (cl, obj, (Msg) msg));


    }
  return (DoSuperMethodA (cl, obj, msg));
}
///





/* */
