Back to index

lightning-sunbird  0.9+nobinonly
Defines | Enumerations | Functions | Variables
mac_xpidl_panel.cpp File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <AERegistry.h>
#include <Drag.h>
#include <Palettes.h>
#include <Resources.h>
#include <Scrap.h>
#include <TextUtils.h>
#include <Sound.h>
#include <DropInPanel.h>
#include "mac_xpidl_panel.h"

Go to the source code of this file.

Defines

#define CW_STRICT_DIALOGS   1

Enumerations

enum  {
  kFactoryPrefsID = 128, kCW7ItemListID = 128, kCW8ItemListID = 129, kXPIDLModeItem = 1,
  kXPIDLWarningsItem, kXPIDLVerboseItem, kXPTLinkerOutputItem = 4
}

Functions

static short InitDialog (PanelParameterBlock *pb)
static void TermDialog (PanelParameterBlock *pb)
static void PutData (PanelParameterBlock *pb, Handle options)
static short GetData (PanelParameterBlock *pb, Handle options, Boolean noisy)
static void ByteSwapData (XPIDLSettingsHandle options)
static short Filter (PanelParameterBlock *pb, EventRecord *event, short *itemHit)
static void ItemHit (PanelParameterBlock *pb)
static void Validate (Handle original, Handle current, Boolean *recompile, Boolean *relink, Boolean *reset)
static short GetPref (AEKeyword keyword, AEDesc *prefsDesc, Handle settings)
static short SetPref (AEKeyword keyword, const AEDesc *prefsDesc, Handle settings)
static short GetFactory (Handle settings)
static short UpdatePref (Handle settings)
static Boolean ComparePrefs (Handle prefsHand1, Handle prefsHand2)
static Boolean ComparePrefs (XPIDLSettings &prefs1, XPIDLSettings &prefs2)
static void OutlineRect (const Rect *focusRect, Boolean outlineOn)
static OSErr DragEnter (PanelParameterBlock *pb)
static void DragWithin (PanelParameterBlock *pb)
static void DragExit (PanelParameterBlock *pb)
static void DragDrop (PanelParameterBlock *pb)
pascal short xpidl_panel (PanelParameterBlock *pb)
Boolean hasLinkerOutput (short mode)
static void ByteSwapShort (short *x)

Variables

static RgnHandle sDragRgn
static Boolean sHighlightOn

Define Documentation

Definition at line 41 of file mac_xpidl_panel.cpp.


Enumeration Type Documentation

anonymous enum
Enumerator:
kFactoryPrefsID 
kCW7ItemListID 
kCW8ItemListID 
kXPIDLModeItem 
kXPIDLWarningsItem 
kXPIDLVerboseItem 
kXPTLinkerOutputItem 

Definition at line 63 of file mac_xpidl_panel.cpp.


Function Documentation

static void ByteSwapData ( XPIDLSettingsHandle  options) [static]

Definition at line 343 of file mac_xpidl_panel.cpp.

{
       ByteSwapShort(&(**options).version);
       ByteSwapShort(&(**options).mode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ByteSwapShort ( short *  x) [static]

Definition at line 325 of file mac_xpidl_panel.cpp.

{
       union {
              short  s;
              char   c[2];
       }      from,to;

       from.s=*x;
       to.c[0]=from.c[1];
       to.c[1]=from.c[0];
       *x = to.s;
}

Here is the caller graph for this function:

static Boolean ComparePrefs ( Handle  prefsHand1,
Handle  prefsHand2 
) [static]

Definition at line 586 of file mac_xpidl_panel.cpp.

{
       XPIDLSettings& prefs1       = **(XPIDLSettingsHandle) prefsHand1;
       XPIDLSettings& prefs2       = **(XPIDLSettingsHandle) prefsHand2;
       
       return ((prefs1.mode  == prefs2.mode) && 
                     (prefs1.warnings == prefs2.warnings) && 
                     (prefs1.verbose == prefs2.verbose) &&
                     (EqualString(prefs1.output, prefs2.output, true, true)));
}

Here is the caller graph for this function:

static Boolean ComparePrefs ( XPIDLSettings prefs1,
XPIDLSettings prefs2 
) [static]

Definition at line 597 of file mac_xpidl_panel.cpp.

{
       return ((prefs1.mode  == prefs2.mode) && 
                     (prefs1.warnings == prefs2.warnings) && 
                     (prefs1.verbose == prefs2.verbose) &&
                     (EqualString(prefs1.output, prefs2.output, true, true)));
}
static void DragDrop ( PanelParameterBlock *  pb) [static]

SysBreakStr("\preqDragDrop");

Definition at line 686 of file mac_xpidl_panel.cpp.

{
#if 0
       Rect   itemRect;
#endif
       
       
       DragExit(pb);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static OSErr DragEnter ( PanelParameterBlock *  pb) [static]

Definition at line 639 of file mac_xpidl_panel.cpp.

{
#if 0
       short                theItem       = pb->itemHit - pb->baseItems;
       unsigned short       itemCount;
       Rect                 itemRect;
       OSErr                err;
#endif
       
       /* Return paramErr if the user is on a item that can't be dropped on */
       return (paramErr);
}

Here is the caller graph for this function:

static void DragExit ( PanelParameterBlock *  pb) [static]

SysBreakStr("\preqDragExit");

Definition at line 669 of file mac_xpidl_panel.cpp.

{
       OSErr  err;
       
       
       if (sHighlightOn) {
              err = HideDragHilite(pb->dragref);
              if (err == noErr)
                     sHighlightOn = false;
       }
}

Here is the caller graph for this function:

static void DragWithin ( PanelParameterBlock *  pb) [static]

SysBreakStr("\preqDragWithin");

Definition at line 656 of file mac_xpidl_panel.cpp.

{
#pragma unused(pb)

       /* there's nothing to do */
       
}

Here is the caller graph for this function:

static short Filter ( PanelParameterBlock *  pb,
EventRecord *  event,
short *  itemHit 
) [static]

Definition at line 353 of file mac_xpidl_panel.cpp.

{
#pragma unused(pb, event, itemHit)
       
       return (noErr);
}

Here is the caller graph for this function:

static short GetData ( PanelParameterBlock *  pb,
Handle  options,
Boolean  noisy 
) [static]

Definition at line 305 of file mac_xpidl_panel.cpp.

{
       XPIDLSettings prefsData     = **(XPIDLSettingsHandle) options;
       long mode, warnings, verbose;
       
       CWPanlGetItemValue(pb, kXPIDLModeItem, &mode);
       CWPanlGetItemValue(pb, kXPIDLWarningsItem, &warnings);
       CWPanlGetItemValue(pb, kXPIDLVerboseItem, &verbose);
       
       prefsData.mode = (short) mode;
       prefsData.warnings = (Boolean) warnings;
       prefsData.verbose = (Boolean) verbose;
       
       CWPanlGetItemText(pb, kXPTLinkerOutputItem, prefsData.output, sizeof(Str32));
       
       ** (XPIDLSettingsHandle) options = prefsData;
       
       return (noErr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static short GetFactory ( Handle  settings) [static]

Definition at line 546 of file mac_xpidl_panel.cpp.

{
       Handle factory;
       Size   size;
       OSErr  err;
       
       factory = Get1Resource('pref', kFactoryPrefsID);
       if (factory == NULL) {
              err = ResError();
              if (err == noErr)
                     err = resNotFound;
              return (err);
       }
       
       size = GetHandleSize(factory);
       SetHandleSize(settings, size);
       err = MemError();
       
       if (err == noErr) {
              BlockMoveData(*factory, *settings, size);
       }
       
       return (err);
}

Here is the caller graph for this function:

static short GetPref ( AEKeyword  keyword,
AEDesc *  prefsDesc,
Handle  settings 
) [static]

Definition at line 408 of file mac_xpidl_panel.cpp.

{
#if 0  
       XPIDLSettings prefsData     = ** (XPIDLSettingsHandle) settings;
       DescType      anEnum;
       OSErr         err;

       switch (keyword)  {
       case prefsLN_GenerateSymFile:
              err = AECreateDesc(typeBoolean, &prefsData.linksym, sizeof(Boolean), prefsDesc);
              break;
              
       case prefsPR_ProjectType:
              switch (prefsData.projtype)
              {
              case kProjTypeApplication:  anEnum = enum_Project_Application;        break;
              case kProjTypeLibrary:             anEnum = enum_Project_Library;                   break;
              case kProjTypeSharedLib:    anEnum = enum_Project_SharedLibrary;      break;
              case kProjTypeCodeResource: anEnum = enum_Project_CodeResource;              break;
              case kProjTypeMPWTool:             anEnum = enum_Project_MPWTool;                   break;
              default:                                  return (paramErr);
              }
              err = AECreateDesc(typeEnumeration, &anEnum, sizeof(anEnum), prefsDesc);
              break;
              
       case prefsPR_FileName:
              err = AECreateDesc(typeChar, prefsData.outfile+1, StrLength(prefsData.outfile), prefsDesc);
              break;

       default:
              err = errAECantHandleClass;
              break;
       }
       
       return (err);
#else
       return (errAECantHandleClass);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Boolean hasLinkerOutput ( short  mode) [inline]

Definition at line 275 of file mac_xpidl_panel.cpp.

Here is the caller graph for this function:

static short InitDialog ( PanelParameterBlock *  pb) [static]

Definition at line 248 of file mac_xpidl_panel.cpp.

{
       OSErr  err;
       
       // The library function will call the IDE to append the dialog items 
       // if possible;  else it will call AppendDITL itself.  This way, you 
       // don't have to worry about it.
       
       err = CWPanlAppendItems(pb, kCW8ItemListID);
       if (err != noErr)
              return (err);
       
       sDragRgn = NewRgn();
       
       return (err);
}

Here is the caller graph for this function:

static void ItemHit ( PanelParameterBlock *  pb) [static]

Definition at line 365 of file mac_xpidl_panel.cpp.

{
       short  theItem       = pb->itemHit - pb->baseItems;
       long   oldValue;
       
       switch (theItem) {
       case kXPIDLModeItem:
              CWPanlGetItemValue(pb, theItem, &oldValue);
              CWPanlEnableItem(pb, kXPTLinkerOutputItem, hasLinkerOutput(oldValue));
              break;
              
       case kXPIDLWarningsItem:
       case kXPIDLVerboseItem:
              CWPanlGetItemValue(pb, theItem, &oldValue);
              break;
       }
       
       GetData(pb, pb->currentPrefs, false);

       pb->canRevert = !ComparePrefs(pb->originalPrefs, pb->currentPrefs);
       pb->canFactory       = !ComparePrefs(pb->factoryPrefs,  pb->currentPrefs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void OutlineRect ( const Rect *  focusRect,
Boolean  outlineOn 
) [static]

Definition at line 609 of file mac_xpidl_panel.cpp.

{
       ColorSpec     savedForeColor, backColor;
       PenState      savedPen;
       
       GetPenState(&savedPen);
       PenNormal();
       
       if (!outlineOn)
       {
              SaveFore(&savedForeColor);
              SaveBack(&backColor);
              RestoreFore(&backColor);
       }
       
       PenSize(2, 2);
       FrameRect(focusRect);
       
       SetPenState(&savedPen);
       
       if (!outlineOn)
       {
              RestoreFore(&savedForeColor);
       }
}
static void PutData ( PanelParameterBlock *  pb,
Handle  options 
) [static]

Definition at line 285 of file mac_xpidl_panel.cpp.

{
       // make sure the options are the right size.
       UpdatePref(options);
       
       XPIDLSettings prefsData = **(XPIDLSettingsHandle) options;

       CWPanlSetItemValue(pb, kXPIDLModeItem, prefsData.mode);
       CWPanlSetItemValue(pb, kXPIDLWarningsItem, prefsData.warnings);
       CWPanlSetItemValue(pb, kXPIDLVerboseItem, prefsData.verbose);

       CWPanlEnableItem(pb, kXPTLinkerOutputItem, hasLinkerOutput(prefsData.mode));
       CWPanlSetItemText(pb, kXPTLinkerOutputItem, prefsData.output);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static short SetPref ( AEKeyword  keyword,
const AEDesc *  prefsDesc,
Handle  settings 
) [static]

Definition at line 453 of file mac_xpidl_panel.cpp.

{
#if 0
       XPIDLSettings prefsData     = ** (XPIDLSettingsHandle) settings;
       AEDesc               toDesc = { typeNull, NULL };
       OSErr                err           = noErr;
       Handle               dataHand;
       Size                 textLength;
       DescType             anEnum;
       
       switch (keyword)
       {
       case prefsLN_GenerateSymFile:
              if (prefsDesc->descriptorType == typeBoolean)
              {
                     dataHand = prefsDesc->dataHandle;
              }
              else
              {
                     err = AECoerceDesc(prefsDesc, typeBoolean, &toDesc);
                     if (err == noErr)
                            dataHand = toDesc.dataHandle;
              }
              if (err == noErr)
              {
                     prefsData.linksym = ** (Boolean **) dataHand;
              }
              break;
              
       case prefsPR_ProjectType:
              if (prefsDesc->descriptorType != typeEnumeration)
              {
                     err = errAETypeError;
                     break;
              }

              anEnum = ** (DescType **) prefsDesc->dataHandle;
              
              switch (anEnum)
              {
              case enum_Project_Application:            prefsData.projtype = kProjTypeApplication;       break;
              case enum_Project_Library:                prefsData.projtype = kProjTypeLibrary;           break;
              case enum_Project_SharedLibrary:   prefsData.projtype = kProjTypeSharedLib;  break;
              case enum_Project_CodeResource:           prefsData.projtype = kProjTypeCodeResource;      break;
              case enum_Project_MPWTool:                prefsData.projtype = kProjTypeMPWTool;           break;
              default:                                                return (errAECoercionFail);
              }
              break;
              
       case prefsPR_FileName:
              if (prefsDesc->descriptorType == typeChar)
              {
                     dataHand = prefsDesc->dataHandle;
              }
              else
              {
                     err = AECoerceDesc(prefsDesc, typeChar, &toDesc);
                     if (err == noErr)
                            dataHand = toDesc.dataHandle;
              }
              if (err == noErr)
              {
                     textLength = GetHandleSize(dataHand);
                     if (textLength > sizeof(prefsData.outfile) - 1)
                            textLength = sizeof(prefsData.outfile) - 1;
                     BlockMoveData(*dataHand, prefsData.outfile+1, textLength);
                     prefsData.outfile[0] = textLength;
              }
              break;

       default:
              err = errAECantHandleClass;
              break;
       }
       
       if (err == noErr)
       {
              ** (XPIDLSettingsHandle) settings = prefsData;
       }
       
       AEDisposeDesc(&toDesc);
       
       return (err);
#else
       return (errAECantHandleClass);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TermDialog ( PanelParameterBlock *  pb) [static]

Definition at line 270 of file mac_xpidl_panel.cpp.

{
       DisposeRgn(sDragRgn);
}

Here is the caller graph for this function:

static short UpdatePref ( Handle  settings) [static]

Definition at line 574 of file mac_xpidl_panel.cpp.

{
       if (GetHandleSize(settings) != sizeof(XPIDLSettings))
              GetFactory(settings);

       return (noErr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Validate ( Handle  original,
Handle  current,
Boolean recompile,
Boolean relink,
Boolean reset 
) [static]

Definition at line 393 of file mac_xpidl_panel.cpp.

{
#pragma unused(original, current)
       XPIDLSettings& origSettings = **(XPIDLSettingsHandle) original;
       XPIDLSettings& currentSettings = **(XPIDLSettingsHandle) current;
       
       *recompile    = currentSettings.mode != origSettings.mode;
       *relink              = *recompile && hasLinkerOutput(currentSettings.mode);
       *reset        = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pascal short xpidl_panel ( PanelParameterBlock *  pb)

Definition at line 113 of file mac_xpidl_panel.cpp.

{
       short  result;
              
       result = noErr;
                     
       switch (pb->request)
       {
       case reqInitPanel:
              /* panel has just been loaded into memory */
              break;

       case reqTermPanel:
              /* panel is about to be unloaded from memory */
              break;

       case reqFirstLoad:
              /* first time panel was loaded. */
              break;

       case reqInitDialog:
              /* hook our dialog item list into the preferences dialog */
              result = InitDialog(pb);
              break;
       
       case reqTermDialog:
              /* unhook our dialog item list from the preferences dialog */
              TermDialog(pb);
              break;
       
       case reqPutData:
              /* put the data in the given handle into our dialog items */
              PutData(pb, pb->currentPrefs);
              break;

       case reqGetData:
              /* fill in the given handle with our dialog items */
              result = GetData(pb, pb->currentPrefs, true);
              break;

       case reqByteSwapData:
              /* byte swap the data in the handle */
              ByteSwapData((XPIDLSettingsHandle)pb->currentPrefs);
              break;
              
       case reqFilter:
              /* filter an event in the dialog */
              result = Filter(pb, pb->event, &pb->itemHit);
              break;
              
       case reqItemHit:
              /* handle a hit on one of our dialog items */
              ItemHit(pb);
              break;
              
       case reqDrawCustomItem:
              /* handle a request to draw one of our user items (CW/8 and later) */
              break;
              
       case reqActivateItem:
              break;
              
       case reqDeactivateItem:
              break;
              
       case reqHandleKey:
              break;
              
       case reqHandleClick:
              break;
              
       case reqFindStatus:
              break;
              
       case reqObeyCommand:
              break;
              
       case reqAEGetPref:
              /* return one item in the given handle as an Apple Event descriptor */
              result = GetPref(pb->prefsKeyword, &pb->prefsDesc, pb->currentPrefs);
              break;

       case reqAESetPref:
              /* change one item in the given handle according to the given Apple Event descriptor */
              result = SetPref(pb->prefsKeyword, &pb->prefsDesc, pb->currentPrefs);
              break;

       case reqValidate:
              /* determine if we need to reset paths, recompile, or relink */
              Validate(pb->originalPrefs, pb->currentPrefs, &pb->recompile, &pb->relink, &pb->reset);
              break;

       case reqGetFactory:
              /* return our factory settings */
              result = GetFactory(pb->factoryPrefs);
              break;

       case reqUpdatePref:
              /* update the given handle to use the current format for our prefs data */
              result = UpdatePref(pb->currentPrefs);
              break;
              
       case reqDragEnter:
              /* determine if we can accept the drag and, if so, start tracking */
              result = DragEnter(pb);
              break;
       
       case reqDragWithin:
              /* continue tracking */
              DragWithin(pb);
              break;
       
       case reqDragExit:
              /* stop tracking */
              DragExit(pb);
              break;
       
       case reqDragDrop:
              /* the user has dropped in our panel */
              DragDrop(pb);
              break;
       
       default:
              result = paramErr;
              break;
       }
              
       return (result);
}

Here is the call graph for this function:


Variable Documentation

RgnHandle sDragRgn [static]

Definition at line 77 of file mac_xpidl_panel.cpp.

Definition at line 78 of file mac_xpidl_panel.cpp.