home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / PennyWise™ Framework / PennyView / Source / DefaultHandlers.c < prev    next >
Encoding:
Text File  |  1994-08-11  |  4.7 KB  |  111 lines  |  [TEXT/KAHL]

  1. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2. //                                                                                //
  3. //                                                                                //
  4. //                    Copyright PennyWise Software, 1994.                            //
  5. //                                                                                //
  6. //            Part of the PennyWise Software Application Framework                //
  7. //                                                                                //
  8. //                                                                                //
  9. //            DefaultHandlers.c        Written by Peter Kaplan                        //
  10. //                                                                                //
  11. //                                                                                //
  12. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  13. //                                                                                //
  14. //        This file contains the default handlers. The default handlers are the    //
  15. //        handlers that get called when no window is present.                     //
  16. //                                                                                //
  17. //        The only default that is not in this file is the menu default.            //
  18. //        It is in the file “HandleMenus.c” and is called “GlobalMenuDispatch”    //
  19. //                                                                                //
  20. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  21. // Default handlers
  22. #include "DefaultHandlers.h"
  23. #include "HandleMenus.h"
  24. #include <PWFramework.h>
  25. #include <PWWindowList.h>
  26. #include "WindowID.h"
  27. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  28. void InitDefaultHandlers()
  29. {
  30.     // Even though most of these routines don't need to do anything
  31.     // we still have to pass in a routine. 
  32.     PWInstallWindowType    (kWINDOW_ID_NONE, kWINDOW_TYPE_APPLICATION);
  33.     PWInstallCreate        (kWINDOW_ID_NONE, defaultWindowNothing);
  34.     PWInstallDispose    (kWINDOW_ID_NONE, defaultWindowClose);
  35.     PWInstallZoomIn        (kWINDOW_ID_NONE, defaultWindowNothing);
  36.     PWInstallZoomOut    (kWINDOW_ID_NONE, defaultWindowNothing);
  37.     PWInstallResize        (kWINDOW_ID_NONE, defaultWindowNothing);
  38.     PWInstallClick        (kWINDOW_ID_NONE, defaultWindowNothing);
  39.     PWInstallUpdate        (kWINDOW_ID_NONE, defaultWindowNothing);
  40.     PWInstallActivate    (kWINDOW_ID_NONE, defaultWindowNothing);
  41.     PWInstallDeactivate    (kWINDOW_ID_NONE, defaultWindowNothing);
  42.     PWInstallIdle        (kWINDOW_ID_NONE, defaultWindowNothing);
  43.     PWInstallCursor        (kWINDOW_ID_NONE, defaultWindowCursor);
  44.     PWInstallKeyDown    (kWINDOW_ID_NONE, defaultKeyDown);
  45.     PWInstallDrag        (kWINDOW_ID_NONE, defaultWindowNothing);
  46.     PWInstallPreMenu    (kWINDOW_ID_NONE, defaultPreMenu);
  47.     PWInstallMenu        (kWINDOW_ID_NONE, GlobalMenuDispatch);
  48.     PWInstallPostMenu    (kWINDOW_ID_NONE, defaultPostMenu);
  49.     PWInstallGrowRect    (kWINDOW_ID_NONE, defaultWindowNothing);
  50.     PWInstallBackground    (kWINDOW_ID_NONE, NULL);
  51.     PWInstallScrap2Appl    (kWINDOW_ID_NONE, defaultWindowNothing);
  52.     PWInstallAppl2Scrap    (kWINDOW_ID_NONE, defaultWindowNothing);
  53. }
  54. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  55. void defaultWindowNothing(EventRecord* theEvent, WindowPtr theWindow)
  56. {
  57. // Do nothing. This will be used as filler for the unused functions
  58. }
  59. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  60. short defaultWindowClose(EventRecord* theEvent, WindowPtr theWindow)
  61. {
  62. return TRUE;    // We have nothing to close, so its closed
  63. }
  64. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  65. void defaultWindowCursor(EventRecord* theEvent, WindowPtr theWindow)
  66. {
  67.     // Make the gMouseMovedRgn the whole qd coord system
  68.     // and then set cursor to arrow
  69.     SetRectRgn(gMouseMovedRgn,-32768,-32768,32767,32767);
  70.     SetCursor(&qd.arrow);
  71. }
  72. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  73. void defaultPreMenu(EventRecord* theEvent, WindowPtr theWindow)
  74. {
  75.     // We have no window, so we can Disable these
  76.     DisableItem( gMenuFile, kFILE_CLOSE);
  77.     DisableItem( gMenuFile, kFILE_SAVE);
  78.     DisableItem( gMenuFile, kFILE_SAVEAS);
  79.     DisableItem( gMenuFile, kFILE_PRINT);
  80.     DisableItem( gMenuFile, kFILE_PONE);
  81.     
  82.     DisableItem( gMenuEdit, kEDIT_UNDO);
  83.     DisableItem( gMenuEdit, kEDIT_CUT);
  84.     DisableItem( gMenuEdit, kEDIT_COPY);
  85.     DisableItem( gMenuEdit, kEDIT_PASTE);
  86.     DisableItem( gMenuEdit, kEDIT_CLEAR);
  87.     DisableItem( gMenuEdit, kEDIT_SEL_ALL);
  88. }
  89. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  90. void defaultPostMenu(EventRecord* theEvent, WindowPtr theWindow)
  91. {
  92.     // we must Enable what we Disabled
  93.     EnableItem( gMenuFile, kFILE_CLOSE);
  94.     EnableItem( gMenuFile, kFILE_PRINT);
  95.     EnableItem( gMenuFile, kFILE_SAVE);
  96.     EnableItem( gMenuFile, kFILE_SAVEAS);
  97.     EnableItem( gMenuFile, kFILE_PONE);
  98.     
  99.     EnableItem( gMenuEdit, kEDIT_UNDO);
  100.     EnableItem( gMenuEdit, kEDIT_CUT);
  101.     EnableItem( gMenuEdit, kEDIT_COPY);
  102.     EnableItem( gMenuEdit, kEDIT_PASTE);
  103.     EnableItem( gMenuEdit, kEDIT_CLEAR);
  104.     EnableItem( gMenuEdit, kEDIT_SEL_ALL);
  105. }
  106. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  107. void defaultKeyDown(EventRecord* theEvent, WindowPtr theWindow)
  108. {
  109. SysBeep(1);    // They pressed a key, Beep at 'em
  110. }
  111. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••