home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / miscprog / actormdi / mdiframe.cls < prev   
Encoding:
Text File  |  1990-12-06  |  3.6 KB  |  104 lines

  1. /* MDIFRAME.CLS - This is a class that can be used for
  2.   the creation of an MDI Frame Window.  It has
  3.   redirected all necessary messages to it's default
  4.   window procedure and contains a list of child
  5.   windows that it contains.  In order to create an
  6.   application specific MDI Frame window one should
  7.   only need to create a descendant of this class that
  8.   contains a command method.  Whenever processing a
  9.   message that will create a new MDI Child window the
  10.   processMenu method should be called with the correct
  11.   caption so that the "Windows" menu in your frame
  12.   window will have a correct list of it's children. */!!
  13.  
  14. inherit(Window, #MDIFrame, #(clientWindow  /* point to client window space */), 2, nil)!!
  15.  
  16. now(class(MDIFrame))!!
  17.  
  18. /* Return the default window style. */
  19. Def style(self)
  20. { ^WS_OVERLAPPEDWINDOW bitOr WS_CLIPCHILDREN;
  21. }!!
  22.  
  23. now(MDIFrame)!!
  24.  
  25. /* Enable all items on the menu that can be used if a child window
  26.   is present */
  27. Def enableMenus(self)
  28. { do(tuple(IDM_CASCADE, IDM_TILE, IDM_ARRANGEICONS),
  29.   {using(menuItem) Call EnableMenuItem(hMenu, menuItem, MF_ENABLED bitOr MF_BYCOMMAND)
  30.   });
  31. }!!
  32.  
  33. /* Disable all items on the menu that can't be used if a child window
  34.   is not present */
  35. Def disableMenus(self)
  36. { do(tuple(IDM_CASCADE, IDM_TILE, IDM_ARRANGEICONS),
  37.   {using(menuItem) Call EnableMenuItem(hMenu, menuItem, MF_GRAYED bitOr MF_BYCOMMAND)
  38.   });
  39. }!!
  40.  
  41. /* Default for dialogs is to do nothing. Return 0
  42.   to let Windows do normal processing.
  43.   WARNING: Do not remove this method! May be redefined
  44.   in descendants if they register a private window
  45.   class with Windows for their dialogs. */
  46. Def defWndProc(self, msgNum, wP, lP)
  47. { ^if clientWindow
  48.    then Call DefFrameProc(getHWnd(self), getHWnd(clientWindow), msgNum, wP, lP);
  49.    else Call DefWindowProc(getHWnd(self), msgNum, wP, lP);
  50.    endif;
  51. }!!
  52.  
  53. /* Step through all of the applications child windows and make sure that
  54.   they are ready to be closed, before closing the MDI Frame Window. */
  55. Def close(self)
  56. { if closeAllMDIChildren(clientWindow)
  57.   then close(self:ancestor);
  58.   endif;
  59. }!!
  60.  
  61. /* Process all MDI Frame Window specific command messages. */
  62. Def command(self, wP, lP)
  63. { select
  64.     case wP == IDM_CASCADE
  65.     is Call SendMessage(getHWnd(clientWindow),
  66.       messageID(#WM_MDICASCADE), 0, 0L);
  67.     endCase
  68.     case wP == IDM_TILE
  69.     is Call SendMessage(getHWnd(clientWindow),
  70.       messageID(#WM_MDITILE), 0, 0L);
  71.     endCase
  72.     case wP == IDM_ARRANGEICONS
  73.     is Call SendMessage(getHWnd(clientWindow),
  74.       messageID(#WM_MDIICONARRANGE), 0, 0L);
  75.     endCase
  76.   endSelect;
  77.   execWindowProc(self, #WM_COMMAND, wP, lP);
  78. }!!
  79.  
  80. /* Process a WM_SIZE message and then pass it on to the default window
  81.   procedure so that Windows knows how to handle it.
  82.   NOTE: This message must be passed on to the default frame procedure */
  83. Def WM_SIZE(self, wP, lP)
  84. { WM_SIZE(self:ancestor, wP, lP);
  85.   execWindowProc(self, #WM_SIZE, wP, lP);
  86. }!!
  87.  
  88. /* Make sure that any messages not processed by an Actor method are passed
  89.   on to the DefFrameProc in Windows, so that the frame window is managed
  90.   properly. */
  91. Def execWindowProc(self, windMsg, wP, lP)
  92. { ^Call DefFrameProc(getHWnd(self), getHWnd(clientWindow),
  93.     messageID(windMsg), wP, lP);
  94. }!!
  95.  
  96. /* Set up the Frame Window so that it creates an MDIClient to go with it.
  97.   Also, dynamically create a "Windows" menu that is initialized with the
  98.   "Cascade", "Tile", and "Arrange Icons" menu choices, for MDI Child
  99.   management. */
  100. Def init(self)
  101. { show(clientWindow := newMDIClient(MDIClient, self, 1000), SW_SHOW);
  102.   disableMenus(self);
  103. }!!
  104.