home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / Procedural / Gadgets / TabbedPanel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-19  |  3.1 KB  |  154 lines  |  [TEXT/MMCC]

  1. /* TabbedPanel.c */
  2. /* Created 01/01/95 12:01 PM by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <Resources.h>
  12. #include <TextEdit.h>
  13. #include <ToolUtils.h>
  14. #include "ResourceDefs.h"
  15. #include "Globals.h"
  16. #include "Miscellany.h"
  17. #include "Scrolling.h"
  18. #include "WindowAids.h"
  19. #include "GadgetsData.h"
  20. #include "TabbedPanel.h"
  21.  
  22. #define TabPanelPanel        1
  23. #define DoomGloryLabel        2
  24. #define HotColdLabel        3
  25. #define BlueYellowLabel        4
  26.  
  27.  
  28. /*----------*/
  29. void OpenTabbedPanel    (FSSpec*    fileSpec,
  30.                          short        fRefNum)
  31. {
  32.     WindowPtr        newWindow;
  33.     Rect            bounds;
  34.  
  35.     newWindow = GetWindow (WIND_TabbedPanel);
  36.     if (fileSpec->name [0] != 0) {
  37.         SetWTitle (newWindow, fileSpec->name);
  38.     }
  39.     SetPort (newWindow);
  40.     SetNewInfo (newWindow);
  41.     cur->vScroll = nil;
  42.     cur->hScroll = nil;
  43.     cur->fileNum    = fRefNum;
  44.     cur->dirty        = false;
  45.     cur->filename    = NewString (fileSpec->name);
  46.     cur->windowKind = WTabbedPanel;
  47.     ((WindowPeek) curWindow)->windowKind = userKind + WTabbedPanel;
  48.     cur->witlHandle = GetResource ('Witl', WIND_TabbedPanel);
  49.     cur->wictHandle = GetResource ('Wict', WIND_TabbedPanel);
  50.  
  51.     cur->TabPanelHandle = GetNewControl (CNTL_TabPanel, newWindow);
  52.  
  53.         cur->TabPanelValue = 1;
  54.     cur->text = nil;
  55.  
  56.  
  57.     } /*OpenTabbedPanel*/
  58.  
  59.     /*----------*/
  60.     void CloseTabbedPanel    (void)
  61.     {
  62.  
  63.     DisposHandle ((Handle) cur->filename);
  64.     DiscardInfo (curWindow);
  65. } /*CloseTabbedPanel*/
  66.  
  67. /*----------*/
  68. void ControlTabbedPanel  (ControlHandle        whichControl,
  69.                          short                whichPart,
  70.                          Point                where)
  71. {
  72.     Rect            bounds;
  73.  
  74.     if (whichControl == cur->TabPanelHandle) {
  75.         if (TrackControl (cur->TabPanelHandle, where, NULL) != 0) {
  76.             cur->TabPanelValue = GetControlValue (cur->TabPanelHandle);
  77.             InvalRect (&curWindow->portRect);
  78.         }
  79.     }
  80.  
  81. } /*ControlTabbedPanel*/
  82.  
  83. /*----------*/
  84. void MouseInTabbedPanel    (Point        where,
  85.                          short        modifiers)
  86. {
  87.     Rect            bounds;
  88.  
  89.  
  90. } /*MouseInTabbedPanel*/
  91.  
  92. /*----------*/
  93. void TypeInTabbedPanel   (char        ch)
  94. {
  95.     if (cur->text == nil) {
  96.         SysBeep (1);
  97.     } else {
  98.         TEKey (ch, cur->text);
  99.         cur->dirty = true;
  100.     }
  101. } /*TypeInTabbedPanel*/
  102.  
  103. /*----------*/
  104. void UpdateTabbedPanel (void)
  105. {
  106.     Rect            bounds;
  107.  
  108.     SetWFont (TabPanelPanel);
  109.     Draw1Control (cur->TabPanelHandle);
  110.     switch (cur->TabPanelValue) {
  111.         case 1:
  112.             SetWFont (DoomGloryLabel);
  113.             GetWRect (DoomGloryLabel, &bounds);
  114.             TextIDBox (TEXT_DoomGlory, bounds);
  115.             break;
  116.  
  117.         case 2:
  118.             SetWFont (HotColdLabel);
  119.             GetWRect (HotColdLabel, &bounds);
  120.             TextIDBox (TEXT_HotCold, bounds);
  121.             break;
  122.  
  123.         case 3:
  124.             SetWFont (BlueYellowLabel);
  125.             GetWRect (BlueYellowLabel, &bounds);
  126.             TextIDBox (TEXT_BlueYellow, bounds);
  127.             break;
  128.  
  129.     } // switch
  130.     DrawClippedGrow (-15, -15);
  131. } /*UpdateTabbedPanel*/
  132.  
  133. /*----------*/
  134. void ActivateTabbedPanel    (Boolean    activate)
  135. {
  136.  
  137.     DrawClippedGrow (-15, -15);
  138. } /*ActivateTabbedPanel*/
  139.  
  140. /*----------*/
  141. void ResizeTabbedPanel    (void)
  142. {
  143.     /* application-specific code to resize items in window */
  144. } /*ResizeTabbedPanel*/
  145.  
  146. /*----------*/
  147. pascal void ScrollTabbedPanel    (short        newValue,
  148.                                  short        oldValue)
  149. {
  150.     /* application-specific code to scroll window */
  151. } /*ScrollTabbedPanel*/
  152.  
  153. /* TabbedPanel */
  154.