/* MDIFILEF.CLS - This descendant of MDIFrame handles
  command message processing that is specific to using
  MDI with the FileWindow. */!!

inherit(MDIFrame, #MDIFileFrame, nil, 2, nil)!!

now(class(MDIFileFrame))!!

now(MDIFileFrame)!!

/* Enable all items on the menu that can be used if a child window
  is present */
Def enableMenus(self)
{ enableMenus(self:ancestor);
  do(tuple(FILE_READ, FILE_SAVE, FILE_SAVEAS, EDIT_CUT, EDIT_COPY,
    EDIT_PASTE, EDIT_CLEAR, EDIT_SELALL, EDIT_SRCH, EDIT_RPLC, VK_F3),
  {using(menuItem) Call EnableMenuItem(hMenu, menuItem, MF_ENABLED bitOr MF_BYCOMMAND)
  });
}!!

/* Disable all items on the menu that can't be used if a child window
  is not present */
Def disableMenus(self)
{ disableMenus(self:ancestor);
  do(tuple(FILE_READ, FILE_SAVE, FILE_SAVEAS, EDIT_CUT, EDIT_COPY,
    EDIT_PASTE, EDIT_CLEAR, EDIT_SELALL, EDIT_SRCH, EDIT_RPLC, VK_F3),
  {using(menuItem) Call EnableMenuItem(hMenu, menuItem, MF_GRAYED bitOr MF_BYCOMMAND)
  });
}!!

Def init(self)
{ init(self:ancestor);
  Call DeleteMenu(hMenu, INSP_DOIT, MF_BYCOMMAND);
  Call DeleteMenu(hMenu, INSP_ISEL, MF_BYCOMMAND);
  addAbout(self);
}!!

/* An application specific command method must be created for each MDI
  application so that it knows how to handle creation of a new MDI child.
  Once the MDI child is created there should be no problems in passing
  command statements on to the child windows command method. */
Def command(self, wP, lP | theChild)
{ if (wP == FILE_OPEN) or (wP == FILE_NEW)
  then createMDIChild(clientWindow, MDIFileWindow, "(Untitled)", nil);
  endif;
  if theChild := activeChild(clientWindow)
  then command(theChild, wP, lP);
  endif;
  command(self:ancestor, wP, lP);
}!!
