home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / MacApp / MacApp 2.0 CD Release / MacApp 2.0 (Many Libraries) / Examples / CPlusExamples / DemoDialogs / UDemoDialogs.h < prev   
Encoding:
Text File  |  1990-03-27  |  8.7 KB  |  295 lines  |  [TEXT/MPS ]

  1. //[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n+]
  2.  
  3. // UDemoDialogs.cp
  4. // Copyright © 1990 by Apple Computer, Inc. All rights reserved.
  5.  
  6. #ifndef __UDEMODIALOGS__
  7. #define __UDEMODIALOGS__
  8. #include "Sane.h"
  9. #include "UMacApp.h"
  10. #include "UPrinting.h"
  11. #include "UGridView.h"
  12. #include "UTEView.h"
  13. #include "UDialog.h"
  14. #include "ToolUtils.h"
  15. #include "Fonts.h"
  16. #include "Resources.h"
  17. #include "Packages.h"
  18. #include "StdIO.h"
  19. #include "StdLib.h"
  20. #include "Strings.h"
  21.  
  22. // Command numbers
  23. const short cMakePicture        = 1000;
  24.  
  25. // Miscellaneous constants
  26. const unsigned long kSignature    = 'SS01';         // Application signature
  27. const unsigned long kFileType    = 'SF01';        // File-type code used for document files
  28.                                                 // created by this application
  29. const short kTestWindowID        = 1001;            /* This is passed to NewSimpleWindow as the
  30.                                                  resource ID of the the WIND Resource which
  31.                                                  defines the window for this application's
  32.                                                  documents */
  33.  
  34. const short kMaxFonds            = 100;            // Max number of FONDs the FontList holds
  35.  
  36. // typdefs
  37. typedef short FontList[kMaxFonds];
  38.  
  39. typedef FontList *FontListPtr;
  40.  
  41. // class declarations
  42. class TTestApplication : public TApplication {
  43.   public:
  44.  
  45.     virtual pascal void ITestApplication(OSType itsMainFileType);
  46.         /* Initializes the application and globals. */
  47.  
  48.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  49.  
  50.     virtual pascal void DoSetupMenus(void);
  51.  
  52.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  53.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  54.  
  55. };
  56.  
  57. class TNumbersView : public TView {
  58.   public:
  59.  
  60.     virtual pascal void Draw(Rect *area);
  61.  
  62.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  63.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  64.  
  65. };
  66.  
  67. class TMonthlyDialog : public TDialogView {
  68.   public:
  69.  
  70.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  71.  
  72.     virtual pascal void DismissDialog(ResType dismisser);
  73.  
  74.     virtual pascal void StuffValues(void);
  75.  
  76.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  77.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  78.  
  79. };
  80.  
  81. class TModelessMarkDialog : public TDialogView {
  82.   public:
  83.  
  84.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  85.  
  86.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  87.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  88.  
  89. };
  90.  
  91. class TFontListView : public TTextListView {
  92.  
  93.   public:
  94.  
  95.     virtual pascal void InitFontList();
  96.     // Build an array of ids of font resources whose names are in alphabetical order
  97.     
  98.     virtual pascal void Free();
  99.     // Make sure the font list gets freed
  100.     
  101.     virtual pascal void GetItemText(short anItem, StringPtr aString);
  102.  
  103.     virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
  104.  
  105.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  106.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  107.  
  108.   private:
  109.             
  110.     FontListPtr    fFontList;
  111.  
  112. };
  113.  
  114. class TSizeListView : public TTextListView {
  115.  
  116.   public:
  117.  
  118.     virtual pascal void InitSizeList();
  119.     
  120.     virtual pascal void GetItemText(short anItem, StringPtr aString);
  121.  
  122.     virtual pascal void InstallFontFamily(short theFondIndex);
  123.  
  124.     virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean select);
  125.  
  126.     virtual pascal void SetNumberOfItems(short aNumber);
  127.  
  128.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  129.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  130.  
  131.   private:
  132.             
  133.     short fSelection;
  134.     short fSelectedSize;
  135.     short fFondIndex;
  136.  
  137. };
  138.  
  139. class TPageSetupDialog : public TDialogView {
  140.  
  141.   public:
  142.   
  143.       TPageSetupDialog();                                    // constructor to initialize fOrientation
  144.  
  145.     virtual pascal void TPageSetupDialog::GetOrientation(VHSelect *theOrientation);
  146.  
  147.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  148.  
  149.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  150.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  151.  
  152.   private:
  153.   
  154.     VHSelect fOrientation;
  155.  
  156. };
  157.  
  158. class TRadioIcon :public  TIcon {
  159.   public:
  160.  
  161.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  162.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  163.  
  164.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  165.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  166. };
  167.  
  168. class THomeBrewDialog : public TDialogView {
  169.   public:
  170.  
  171.     virtual pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
  172.  
  173.     virtual pascal TView *HandleCursor(VPoint *theMouse, RgnHandle cursorRgn);
  174.  
  175.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  176.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  177. };
  178.  
  179. class TArrowsControl : public TPicture {
  180.  
  181.   public:
  182.  
  183.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  184.  
  185.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  186.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  187.  
  188.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  189.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  190.  
  191.   private:
  192.  
  193.     long fLastChange;                            /* tick count of last call to DoChoice */
  194.  
  195. };
  196.  
  197. class TTemperatureCluster : public TCluster {
  198.   public:
  199.  
  200.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  201.  
  202.     virtual pascal long GetValue();
  203.     
  204.     virtual pascal void SetValue(long newValue, Boolean redraw);
  205.  
  206.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  207.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  208. };
  209.  
  210. class TTemperatureConversionCluster : public TCluster {
  211.   public:
  212.  
  213.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  214.  
  215.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  216.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  217. };
  218.  
  219. class TSlider : public TPicture {
  220.  
  221.   public:
  222.  
  223.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  224.  
  225.     virtual pascal Boolean ContainsMouse(VPoint *theMouse);
  226.  
  227.     virtual pascal void Draw(Rect *area);
  228.  
  229.     virtual pascal void DrawKnob(void);
  230.  
  231.     virtual pascal void GetKnobRect(Rect *knobRect);
  232.  
  233.     virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  234.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  235.  
  236.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  237.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  238.  
  239.   private:
  240.  
  241.       short fValue;                                // current value of slider
  242.     PicHandle fKnobPicture;                        // handle to the PICT rsrc
  243.     Rect fKnobRect;                                // rect within which we draw the knob
  244.     short fMinTop;
  245.     short fMaxTop;
  246.  
  247. };
  248.  
  249. class TSumStaticText : public TStaticText {
  250.   public:
  251.  
  252.     virtual pascal void Draw(Rect *area);
  253.  
  254.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, 
  255.         short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  256. };
  257.  
  258. class TCalcDialog : public TPicture {
  259.  
  260.   private: // since C++ allows enumerations with class scope, we'll take advantage of this:
  261.  
  262.     typedef enum {noOperator, divOperator, mulOperator, subOperator, addOperator} CalcOperator;
  263.  
  264.   public:
  265.  
  266.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  267.  
  268.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  269.  
  270.     virtual pascal void ClearSum(void);
  271.  
  272.     virtual pascal void FetchValue(long double *aValue);
  273.  
  274.     virtual pascal void SetValue(void);
  275.  
  276.     virtual pascal void TotalSum(CalcOperator newOperator);
  277.  
  278.     virtual pascal void NewDigit(short theNumber);
  279.  
  280.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  281.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  282.  
  283.   private:
  284.  
  285.     long double fSum;                            // note: the ANSI C standard "long double" is preferred 
  286.                                                 // over the IEEE standard "extended"
  287.     long double fArgument;                        // current argument to the calculator
  288.     CalcOperator fOperator;                        // operator for the equation
  289.     Boolean fDecimalPoint;                        // whether or not a decimal point is in the number
  290.     Boolean fRestart;                            // whether to restart entry of data (next number entered
  291.                                                 // corresponds to a new argument)
  292.  
  293. };
  294. #endif
  295.