TweetFollow Us on Twitter

Menu Definition
Volume Number:2
Issue Number:8
Column Tag:Pascal Procedures

Menu Definition Routines

By Darryl Lovato, TML Systems, Inc.

Introduction

Hello, as promised, we will cover Menu Definition Routines this month. What is a Menu Definition Routine? It is a procedure that defines a particular type of menu. The routine controls the way menus are drawn, and how items within it are selected. In general, Menu Definition routines define a given menu's appearance and behavior. The standard type of Macintosh menu is pre-defined for you and it is stored in the system file. You may however, want to define your own type of menu. The pattern selection menu in MacDraw is a good example of a non-standard menu.

The menu definition procedure I decided to use for an example doesn't create a non-standard menu but it shows exactly how the standard menu definition works! The standard definition routine was written in 68000 Assembler, by Andy Hertzsfield (my Hero) but ours will be written in TML Pascal (with the exception of one routine, which couldn't be written with Pascal, so I wrote it in 68000 Assembler). There isn't any noticeable speed difference between the standard Menu Def and our imitation.

An example of a non-standard Menu

The Pascal definition and general outline of a Menu definition procedure follows:

{1}

procedure MyMenu(message : integer;
 theMenu :  MenuHandle;
 var menuRect :  Rect;
 hitPt :  Point;
 var whichItem : Integer);

procedure DoDrawMessage(aMenu :   MenuHandle;
 aRect :  Rect);
  begin
  ...{draw the menu in menurect}
  end;

procedure DoChooseMessage(aMenu : MenuHandle;
 aRect :  Rect;
 aPt :  Point;
 var aItem :   Integer);
  begin
  ...{see what item aPt is in and select it}
  end;

procedure DoSizeMessage(aMenu : MenuHandle);
  begin
  ...{calculate the width and height of aMenu}
  end;

begin
  case message of
    mDrawMsg :
      DoDrawMessage(theMenu, menuRect);
    mChooseMsg :
      DoCooseMessage(theMenu, menuRect,
 hitPt, whichItem);
    mSizeMsg :
     DoSizeMessage(theMenu);
  end;
end;

The Parameters

The message parameter tells type of operation to perform. It can be one of the following values:

mDrawMsg - Draw the menu.

mChooseMsg - Choose a item.

mSizeMsg - Calculate the menu's height & width.

The 'theMenu' parameter is a MenuHandle to the menu we are to perform the action on.

The 'menuRect' is the rectangle in which the menu is in. It is in global coordinates.

The 'hitPt' parameter is the point (again, in global coordinates) that the mouse was pressed. It is only valid during a 'mChooseMsg'.

The 'whichItem' parameter holds the item number that is currently selected. You pass the result of your hit test back to the menu manager in this parameter.

The DoSizeMessage Procedure

When we are passed the mSizeMsg message, we need to calculate the width and height of the menu passed in theMenu parameter. The results are returned in the menu records Width and Height fields respectively. For a menu which has only one size, MacDraw's pattern selection menu, for example, this is real easy- just assign the width and height fields their constant values. For your example, which has variable widths and heights, it is a little harder.

The way we do this is have a variable that holds the cumulative vertical distance and another which holds the greatest horizontal distance. We loop through each item, first getting all its attributes (icon, text, cmd key...). Then we add the current items height to the cumulative height variable (36 if it has a icon, 16 otherwise). We must also find the items width; this is done by checking for icons, cmd keys, the items string width, etc. If this items width is greater than all others we have encountered so far, then we update the greatest width variable. When we have done this for all items in the menu, we return the results in the menu record fields Width and Height.

The DoDrawMessage Procedure

The DoDrawMessage is called when we receive a mDrawMsg from the menu manager. In response to this, we draw the menu items in theRect. When we are called, the current port will be the WindowMgrPort and the boarder around the menu will already be drawn. Again, we just go through a loop, looking at every item. If the item has an icon, we draw it and bump the location of where the text will go down half the size of the icon. We draw the markChar, if any. Then we draw the items text, and finally, the items keyboard equivalent, if any.

The DoChooseMessage Procedure

When we receive a mChooseMsg we call the DoChooseMessage and pass it the following parameters. The 'aPt' parameter is the mouse location that we need to check for. The 'whichItem' parameter is the item number of the last item that was choosen from this menu (initially 0). First we check to see if the point is in the menus rect, if not, we return 0. Otherwise, we see if the point is in an enabled item, if not, we return 0. If it was in an enabled item, we need to unhilite the old item (unless they are the same), hilite the new item (again, unless they are the same), and return the item it was in.

Getting the Menu Manager to Use our Def

Now that we have our definition routine defined, how do we get the Menu Manager to use our definition routine instead of the standard one (even thought they act the same)? One method of doing this follows:

1. Get the handle to the menu by calling NewMenu or GetNewMenu.

2. Put a new handle in the menuProc field of the menu record.

3. Make that point to the address of our MenuDefRoutine.

myMenuHdl := GetNewMenu(...);
myMenuHdl^^.menuProc := NewHandle(0);
myMenuHdl^^.menuProc^ := Ptr(@TheMenuProc);

Other Points of Interest

The assembly routine we use in this example simply returns the keyboard equivalent of a menu item. Since there is no standard trap to do this, and it can't be done with Pascal, no- wait a minuite...it can be done with Pascal. But it is a lot easier with assembly, so there! Anyway, it simply walks through the menu record until it finds 'theItem', and it gets its keyboard equivalent and returns it. It's Pascal declaration is :

procedure GetItemKey(theMenu : MenuHandle;
 theItem : Integer;
 var theChar : Char); external;

This is only one type of menu def, the number of possible menu definition routines that can be made are as big as your imagination, and, of course, available memory. For example, in addition to the MacDraw type MDEF I have done for the TML Examples Disks, I have done a Hierarchical Menu Definition routine. The way it works is this: to define a sub-menu in a menu, you simply add the string '|XXX' to the item you want to have the sub-menu. The XXX is the resource id of the menu you want to be the sub menu of the item. So, when I am supposed to draw the menu or calculate the menu's size, I strip out the '|XXX' string. Where it gets fancy is when you get the choose message, and you move onto an item that has a submenu ('|XXX' in its string). When this happens, I call a Pascal version of Mike Shuster's PopUpSelect routine [published in MacTutor December 1985 issue and available as a back issue for $4] for the menu with the res ID XXX. If the same conditions occur in the PopUpSelect routine, which calls the Definition Routine, I call it again. Can you say RECURSION ? I knew you could.

A good use for this type of Menu Def is a Character Menu, its items are Font, Size, and Style. When you move the mouse over one of these items, a list of fonts, a list of available sizes, or a list of styles appear in the sub menu. The advantage of this is that it only took one place in the menu bar to implement 3 separate menus.

Next Month...

Next month we will cover the wonderful world of Window Definition Routines. We will go through an example that shows how the standard window definition routine works. I would suggest reading the Window Manager section of Inside Macintosh, especially the section on "Defining Your Own Windows". If you have any questions/suggestions or other form of abuse, drop me a line in care of MacTutor. Or better yet, buy the TML Examples Disks, there is 3 MDEF Examples in them. Its been real...

Pascal Source Code
{################################################
#
#RegMDEF.Pas
#
#     (Regular Menu Definition Routine Example)    
#      ( just like apples, except in Pascal )
#
#This program was written by Darryl Lovato.              
#Copyright (c) 1986 by TML Systems.   
#
#################################################}

program RegMDEF;

{------------------------- Compiler Directives ---------------------------}

  {$B+    } { Tell the linker to set the bundle bit}
  {$T APPL RMDF  } {  type to Appl and creator to RMDF}
  {$I MemTypes.ipas} { Include the Memory Declarations}
  {$I QuickDraw.ipas}{ Include  QuickDraw Declarations}
  {$I OSIntf.ipas} { Include the OS Declarations}
  {$I ToolIntf.ipas} { Include the Toolbox Declarations}
  {$L RegMDEFRsrc} { Tell the linker to link the resources}
  {$U RegMDEFGlue} { link our assembly code in too...}
 
{--------------------------- Global Constants ----------------------------}

  const
    appleMenu = 300; { Resource ID of the Apple menu}
    fileMenu = 301;{ Resource ID of the File menu}
    editMenu = 302;{ Resource ID of the Edit menu}    
    
    beginMenu = 300; { Res ID of first menu in menu bar}
    endMenu = 302; { Res ID of last menu in menu bar}
    RegMenu = 500; { Res ID of our regular menu}

{--------------------------- Global Variables ------------------------------}

  var
   { The menus in menu bar}
    myMenus : array[beginMenu..endMenu] of MenuHandle;
    Finished : Boolean; { Set to true when were done}
    screenPort : GrafPtr; { the window mngr port}
    MyRegMenu : MenuHandle; { my regular menu handle}

{--------------------- Assembly Procedures ----------------------------}

procedure GetItemKey(theMenu : MenuHandle;
 theItem : Integer;
 var theChar : Char); external;

{------------------- ChkOnOffItem procedure --------------------------}

procedure ChkOnOffItem(MenuHdl:MenuHandle; item, first,        
 last:Integer);
var
  i: integer;
begin
  for i := first to last do
    begin
      if item = i then
        CheckItem(MenuHdl, i, true) {check it on in menu}
      else
        CheckItem(MenuHdl, i, false); {check it off in menu}
    end;
end;
    
{----------------------- MenuDef Procedure -----------------------------}

procedure MyMenuDef(message : Integer; { what do  we do?}
 theMenu : MenuHandle;    { what menu ?}
 var menuRect : Rect;{ in what rect?}
 hitPt : Point;  { where's mouse?}
 var whichItem : Integer);{ what item is it?}

{--------------------- semi-global constants ----------------------------}

  const
    MBarHeight = 20;

{----------------------- DimRect procedure ------------------------------}

  procedure DimRect(theRect : Rect);
    begin
      PenPat(gray);
      PenMode(patBic);
      PaintRect(theRect);
      PenNormal;
    end;

{--------------------- GetItemsRect Function ---------------------------}
 
   function GetItemsRect(myMenu : MenuHandle;
       myRect : Rect;
       theItem : Integer) : Rect;
    var
      Index : Integer;
      currentRect : Rect;
      itemIcon : Byte;
    begin
      currentRect.bottom := myRect.top; { initialize current rect}
      currentRect.left := myRect.left;
      currentRect.right := myRect.right;
      for index := 1 to theItem do
 begin
   GetItemIcon(myMenu,index,itemIcon);

   currentRect.top := currentRect.bottom; { update rect }
   if itemIcon <> 0 then
     currentRect.bottom := currentRect.top + 36
   else 
     currentRect.bottom := currentRect.top + 16;
 end;
      GetItemsRect := currentRect; { return result}
    end;
 
{--------------- DoDrawMessage Procedure -----------------------}

  procedure DoDrawMessage(myMenu : MenuHandle;
   myRect : Rect);
    const
      MBarHeight = 20;
    var
      currentItem : Integer;
      currentRect : Rect;
      itemString : str255;
      itemIcon : Byte;
      itemMark : Char;
      itemStyle : Style;
      itemKey : Char;
      thePoint : Point;
      theIcon : Handle;
      iconRect : Rect;
      NewVert : Integer;

    begin
      currentRect.bottom := myRect.top; { initialize  current rect}
      currentRect.left := myRect.left;
      currentRect.right := myRect.right;
      for currentItem := 1 to CountMItems(myMenu) do{ all  items}
        begin
   GetItem(myMenu,currentItem,itemString);{ get info }
   GetItemIcon(myMenu,currentItem,itemIcon);
   GetItemMark(myMenu,currentItem,itemMark);
   GetItemStyle(myMenu,currentItem,itemStyle);
   GetItemKey(myMenu,currentItem,itemKey);

   currentRect.top := currentRect.bottom; { update rect }
   if itemIcon <> 0 then
     currentRect.bottom := currentRect.top + 36
   else 
     currentRect.bottom := currentRect.top + 16;
   
   if itemString = '-' then { special case '-' item}
     begin
       PenPat(Gray);
       moveTo(currentRect.left,currentRect.top + 8);
       Line(currentRect.right,0);
       PenPat(Black);
     end
   else { draw the other item stuff}
     begin  {get baseline}
       NewVert := ((currentRect.bottom - currentRect.top)
 DIV 2);
       NewVert := currentRect.top + 4 + NewVert; 
       MoveTo(currentRect.left + 2,newVert);
       
       if itemMark <> Chr(0) then
         DrawChar(itemMark);
       
       if itemIcon <> 0 then { draw the icon}
         begin
   iconRect.top := currentRect.top + 2;
   iconRect.bottom := iconRect.top + 32;
   iconRect.left := currentRect.left + 13;
   iconRect.right := iconRect.left + 32;
   theIcon := GetIcon(256 + itemIcon);
   PlotIcon(iconRect,theIcon);
   GetPen(thePoint);
              MoveTo(currentRect.left + 47,thePoint.v); 
 end
       else { otherwise, just move over a bit}
         begin
   GetPen(thePoint);
   MoveTo(currentRect.left + 13,thePoint.v); 
 end;

      TextFace(itemStyle);
      DrawString(itemString);
      TextFace([]);
      
      if itemKey <> Chr(0) then { draw key equiv}
        begin
  GetPen(thePoint);
  MoveTo(currentRect.right - 24,thePoint.v);
  DrawChar(Chr($11)); { draw cmd char symbol}
  DrawChar(itemKey); { and the cmd key}
        end;
 
      if (BitAnd(myMenu^^.enableFlags,1) = 0) then{disabled!}
        DimRect(currentRect);
      if (BitAnd(BitShift(
 myMenu^^.enableFlags,-currentItem),1) = 0) then
        DimRect(currentRect);
 
    end; { of if itemString = '-' then..else..}
 end;
    end; { of DoDrawMessage}

{------------- DoChooseMessage Procedure ---------------------}
  
  function DoChooseMessage(myMenu : MenuHandle;
   myRect : Rect;
 myPoint : Point;
 oldItem : Integer) : Integer;
    var
      theItem : Integer;
      ItemsRect : Rect;
    begin
      if PtInRect(myPoint,myRect) then
        begin
   theItem := 1;
   repeat
            ItemsRect := GetItemsRect(myMenu, myRect, theItem);
     theItem := theItem + 1;
   until PtInRect(myPoint,itemsRect);
   theItem := theItem - 1; { undo last increment}

   if (BitAnd(myMenu^^.enableFlags,1) = 0) or 
     (BitAnd(BitShift(
 myMenu^^.enableFlags,-theItem),1) = 0) then
       begin
         theItem := 0;
       end;

   if theItem <> oldItem then {de-select old, select new}
     begin
       if oldItem <> 0 then { deselect old}
 InvertRect(GetItemsRect(
 myMenu, myRect,oldItem));
       if theItem <> 0 then
    InvertRect(GetItemsRect(myMenu, myRect,theItem));
     end;
   DoChooseMessage := theItem; { return result}
 end
      else { it was not in our menu}
        begin
   if oldItem <> 0 then { we need to de-select old item}
     InvertRect(GetItemsRect(myMenu, myRect,oldItem));
   DoChooseMessage := 0; { return result}
 end;
    end;

{----------------- DoSizeMessage Procedure -----------------------}

  procedure DoSizeMessage(var myMenu : MenuHandle);
    var
      MaxWidth : integer; { keep track of the maximum width}
      TotalHeight : integer;{ keep track of the total height}
      currentItem : integer;{ the menu item we are looking at}
      itemString : Str255;{ text of the curren menu item}
      itemIcon : Byte;  { resource id of the menu items icon}
      itemMark : char;  { the items mark}
      itemStyle : Style;  { the items character style}
      itemKey : Char;{ the keyboard equiv}
      tempWidth : Integer;{ the current items width}
      
    begin
      MaxWidth := 0; { initailize width}
      TotalHeight := 0; { initialize height}
      for currentItem := 1 to CountMItems(myMenu) do 
 begin
   GetItem(myMenu,currentItem,itemString); { get text}
   GetItemIcon(myMenu,currentItem,itemIcon); {get icon}
   GetItemMark(myMenu,currentItem,itemMark); { char}
   GetItemStyle(myMenu,currentItem,itemStyle); { style}
   GetItemKey(myMenu,currentItem,itemKey); { get key}
   
   tempWidth := 13; { indent a bit}
   if itemIcon <> 0 then
     tempWidth := tempWidth + 35; { make room for  icon}
   TextFace(itemStyle); { set to items style}
   tempWidth := tempWidth + StringWidth(itemString) + 4;
   TextFace([]); {return to normal}
   if itemKey <> Chr(0) then
     tempWidth := tempWidth + 30;

   if tempWidth > MaxWidth then
     MaxWidth := tempWidth;
   if itemKey <> chr(0) then
     tempWidth := tempWidth + 20;
   
   if itemIcon <> 0 then
     TotalHeight := totalHeight + 36 { add lots of space}
   else
     TotalHeight := totalHeight + 16; { add enough for text}
 end;
      with myMenu^^ do
        begin
   menuWidth := MaxWidth; { save result in menu record}
   menuHeight := TotalHeight; { ditto...}
 end;
    end;

{----------- Case on message and call procedure ------------------}

begin
  case message of
    mSizeMsg :
      begin
        DoSizeMessage(theMenu);
      end;
    mDrawMsg : 
      begin
        DoDrawMessage(theMenu,menuRect);
      end;
    mChooseMsg :
      begin
        whichItem := DoChooseMessage(
 theMenu,menuRect,hitPt,whichItem);
      end;
  end;
end;

{---------------- process the menu selection ------------------------}

  procedure ProcessMenu(CodeWord : LongInt);

    var
      menuNum : Integer; { Res ID of the menu Selected}
      itemNum : Integer;{ The item number selected}
      nameHolder : str255; { the name of the desk acc.}
      dummy : Integer; { just a dummy}
      AboutRecord : DialogRecord;{ the actual object}
      AboutDlog : DialogPtr; { a pointer to my dialog}

    begin
      menuNum := HiWord(CodeWord); { get the menu number}
      itemNum := LoWord(CodeWord); { get the item number}
      if itemNum > 0 then { ok to handle the menu?}
        begin
   case MenuNum of
     appleMenu :
       begin
         case ItemNum of
   1:
     begin
       AboutDlog := GetNewDialog(
 3000,@AboutRecord,Pointer(-1));
       ModalDialog(nil,dummy);
       CloseDialog(AboutDlog);
     end;
   2:begin
     end;
   otherwise
     begin
       GetItem(myMenus[appleMenu],
 ItemNum,NameHolder);
       dummy := OpenDeskAcc(NameHolder);
     end;
 end;
       end;
     fileMenu :
       begin
         Finished := true;
       end;
     editMenu :
       begin
         if not SystemEdit(ItemNum - 1) then
   begin
     {we dont support any other editing}
   end;
       end;
     RegMenu : 
       begin
         if ItemNum <> 0 then
   begin
     if itemNum > 3 then
       ChkOnOffItem(MyRegMenu, ItemNum, 4, 9);
   end;
       end;
   end; { of case menuNum of}
 end;   { of if CodeWord...}
   HiliteMenu(0);
    end;{ of process menu}

{-------------------------- Main Event loop -------------------------------}

  procedure MainEventLoop;

    type
      trickType = packed record{ to get around pascal's typing }
        case boolean of
   true :
     (I : LongInt);
   false :
     (chr3, chr2, chr1, chr0 : Char);
 end;

    var
      Event : EventRecord;{ Filled by Get next event}
      windowLoc : integer;{ the mouse location}
      mouseLoc : point; { the area it was in }
      theWindow : WindowPtr;{ Dummy, have no windows}
      trickVar : trickType; { because of pascal's typing}
      CharCode : Char;  { for command keys}
    begin
      repeat{ do this until we selected quit}
 SystemTask;{ Take care of desk accessories}
 if GetNextEvent(everyEvent,Event) then
   begin
     case event.what of { case out on the event type}
       mouseDown : { we had a mouse-down event     }
 begin
   mouseLoc := Event.where;{ wheres the mouse}
   windowLoc := FindWindow(mouseLoc,
 theWindow); 
   case windowLoc of { now case on the location}
     inMenuBar :
       ProcessMenu(MenuSelect(MouseLoc)); 
     inSysWindow:
       SystemClick(Event,theWindow); {In desk acc}
   end;
 end;
       keyDown,AutoKey :  { we had the user hit a key}
         begin
   trickVar.I := Event.Message;  { fill the longWord     }
   CharCode := trickVar.chr0;{ and pull off low-byte}
  if BitAnd(Event.modifiers,CmdKey) = CmdKey then 
     ProcessMenu(MenuKey(CharCode));
 end;
     end; { of case event.what...}
   end; { end of if Get Next event}
      until(Finished);    { end of repeat statement}
    end;{ of main event loop}

{----------------- SetUp Everything -------------------------------}

  procedure SetUpThings;

    type
      ProcHdl = ^ProcPtr;

    var
      index : integer;    { used in a for loop     }
     
    begin
      for index := beginMenu to endMenu do
        begin
   myMenus[index] := GetMenu(index);{ Get next menu}
 end;
      AddResMenu(myMenus[appleMenu],'DRVR'); 
      for index := beginMenu to endMenu do
 InsertMenu(myMenus[index],0);{ Insert the menu    }

    { #*#*#*#*#* here is the non-standard menu*#*#*#*#*#*#*# }

      MyRegMenu := GetMenu(500); { make a new Menu}
      MyRegMenu^^.menuProc := NewHandle(0);
      MyRegMenu^^.menuProc^ := Ptr(@MyMenuDef);

      Insertmenu(MyRegMenu,0);{ and add it to the menu list}
      CalcMenuSize(MyRegMenu);{ and calculate its size}
      DrawMenuBar; { Now draw the menu bar   }
      ChkOnOffItem(MyRegMenu, 4, 4, 9);{check  item in  menu}
    end;

{-------------------- Initialize Everything ----------------------------}

  procedure InitThings;
    begin
      InitGraf(@thePort); { create grafPort for screen}
      MoreMasters; { create bunch of master Ptr's}
      MoreMasters; {  wont need to worry about}
      MoreMasters; { heap fragmentation later!}
      MaxApplZone; { make sure we have lots!}
      InitFonts; { Startup the Font manager}
      InitWindows; { Startup the Window manager}
      InitMenus; { Startup the Menu manager}
      TEInit;    { initialize text edit}
      InitDialogs(nil);   { initialize dialogs     }
      InitCursor;{ make the cursor an arrow}
    end;

{--------------------- Main Program Seg ------------------------------}

begin
  InitThings;
  SetUpThings;
  Finished := false;
  MainEventLoop;
end.
Assembly Source Code
;###############################################
;#
;# procedure GetItemKey(theMenu : MenuHandle;
;# theItem : Integer;
;# var theChar : Char);
;#
;#------------------------------------------------------------------------------
;#
;# This assembly proc returns the current command key 
;# which is assigned to theItem.
;#
;################################################

;--------------------------- Equates -----------------------------------

; menuinfo data structure

menuID  equ 0  ; unique id for menu bar [word]
menuWidth equ  2 ; menu Width [word]
menuHeightequ  4 ; menu Height [word]
menuDefHandle  equ 6 ; menu definition proc [handle]
menuEnableequ  $A; enable flgs, one bit/item [long]
menuDataequ $E ; menu item string [string]
menuBlkSize equ  $E; menu block plus dataString

; menu string data structure

itemIconequ 0  ; icon byte
itemCmd equ 1  ; command key byte
itemMarkequ 2  ; checkmark character byte
itemStyle equ  3 ; style byte

.Trap _CountMItems $A950 ; trap word 

;--------------------------- XREF's ------------------------------------

 xdef GetItemKey ; so the linker will find us

;------------------------ Entrance -----------------------------------

GetItemKey
 link A6,#0 ; create new stack frame
 movem.l A0-A4/D0-D3,-(SP) ; save registers

;---------------------- Pop Parameters -------------------------------

 clr.l  D2; make sure it is empty
 clr.l  D1; ditto...
 clr.l  D0; ditto...

 clr.w  -(SP)    ; make room for result
 move.l 14(A6),-(SP); push MenuHandle
 _CountMItems    ; how many are in this menu?
 move.w (SP)+,D3 ; pop result

 move.l 14(A6),A4; fetch the menu handle
 move.w 12(A6),D1; fetch the item number
 movea.l8(A6),A3 ; fetch ptr to the char Ptr(word)

 cmp.w  D1,D3  ; num of Menu Items < theItem?
 blt  BadItem    ; yep, exit

;-------------------- Find the Cmd Key --------------------------------

 move.l (A4),A4  ; get menu ptr
 lea  menuData(A4),A4; now A4 points to menu title
 move.b (A4),D2  ; get length of menu title
 add.b  #1,D2    ; skip length byte

; (A4,D2) now points to the first menu items title (length byte)

nextItem
 sub.b  #1,D1    ; decrement count
 beq    GotItem  ; if 0, return its cmd char
 move.b (A4,D2),D0 ; get length of the title
 add    D0,D2  ; and skip it
 add    #5,D2    ; skipe item attrib& length byte
 bra    nextItem ; and look at the next item

;------------------------ Got the Item ----------------------------------

GotItem
 move.b (A4,D2),D0 ; get length of title
 add    D0,D2  ; and skip it
 add    #1,D2    ; skip length byte, too...
 clr.w  D0; make sure its empty
 move.b  itemCmd(A4,D2),D0
  ; get the key equivalent
 move.w D0,(A3)  ; and return it
 bra    Exit; and exit

;------------------- No Item Found ---------------------------------

BadItem
 clr.w  (A3); return no cmd char and exit
 
;-------------------- Clean Up & Exit --------------------------------

Exit
 movem.l(SP)+,A0-A4/D0-D3 ; restore registers
 unlk   A6; restore stack frame
 movea.l(SP)+,A0 ; save return address
 adda.l #10,SP ; clean up stack
 jmp    (A0); ... and return
Link File For TML Pascal
!PAS$Xfer

/Globals -4
RegMDEF
Pascal System:PAS$Library
OSTraps
ToolTraps
Pascal System:RegMDEFGlue
/Resources
Pascal System:RegMDEFRsrc
/Bundle
/Type 'APPL' 'RMDF'
$ 
Resource File For RMaker
*
*   Resource listing: "RegMDEFRsrc".
*

RegMDEFRsrc


TYPE RMDF=STR 
 ,0
Window Definition Procedure 

TYPE BNDL      ,128
RMDF  0
ICN#
0 128  1 129
FREF
0 128  

Type DLOG
     ,3000 (4)
New Dialog
56 74 312 444
Visible GoAway 
1
0
3000

Type DITL
     ,3000
8
*   1
BtnItem Enabled
200 239 237 324
Okay

*   2
StatText Disabled
16 83 34 284
MacLanguage Series™ Pascal

*   3
StatText Disabled
34 69 50 293
Advanced Programming Examples

*   4
StatText Disabled
61 52 77 307
- Standard Menu Definition Example -

*   5
StatText Disabled
90 6 139 368
Written by Darryl Lovato.++
\0DSpecial thanks to Robert Ulrich.++
\0DCopyright © 1986 by TML Systems. ++
All rights reserved. 

*   6
StatText Disabled
147 7 180 364
Complete source code for this example ++
(and others) is available from:

*   7
StatText Disabled
183 60 250 198
TML Systems, Inc. ++
\0DP.O. Box 361626 ++
\0DMelbourne, Fl 32936\0D(305) 242-1873

*   8
IconItem Enabled
14 21 46 53
3000

Type MENU
     ,500 (4)
Junk
Icon Item^1
(Disabled Item
(-
keyboard Equiv Item/K
Shadowed Item<S
Outlined Item<O
Underlined Item<U
Italic Item<I
Bold Item<B

     ,300 (4)
\14
About Regular MDEF...
(-

     ,301 (4)
File
Quit/Q

     ,302 (4)
Edit
Undo/Z
(-
Cut/X
Copy/C
Paste/V
Clear

Type ICON = GNRL
     ,257 (4)
FF7FFFFF
816AAAAB
E7555555
247EAAAB
24015555
247CAAAB
24827F55
250101AB
25391C55
2527633F
E7208080
812088E7
FF271465
01392255
F9011455
E482888D
E47C80A5
9A0063A1
99FE1D31
E6678129
E66679E7
99999C00
99999BFF
E6666667
E6666667
99999999
99999999
E6666667
E6666667
99999999
99999999
FFFFFFFF

     ,3000 (36)
3FFFFFFC
40000002
81C1FFC1
82210041
FE3F007F
92290049
91C9FFC9
90080009
90081C09
90C82209
9127E3F9
9F302201
91281C01
90C80001
90081F01
90086081
93C18041
94223020
9C2FC810
94247F0F
93C23007
90010007
90008007
90006007
93C01FE7
9420001F
9C3FE007
84200000
83C00000
80000001
40000002
3FFFFFFC

Type ICN# = GNRL
     ,128
2
00000000
7FFFFFFE
47E00002
47E00002
7FFFFFFE
54001556
6DC01AAA
55DF9556
6DC01AAA
54001556
6DC01AAA
555ED556
6DC01AAA
54001556
6EAABAAA
54001556
6FFFFAAA
56073556
6FFFFAAA
54001556
6DEEDAAA
54001556
6DF81AAA
54001556
6FFFFAAA
55555556
6AAAAAAA
55555556
6AAAAAAA
55555556
7FFFFFFE
00000000
*
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »

Price Scanner via MacPrices.net

Apple Watch Ultra 2 now available at Apple fo...
Apple has, for the first time, begun offering Certified Refurbished Apple Watch Ultra 2 models in their online store for $679, or $120 off MSRP. Each Watch includes Apple’s standard one-year warranty... Read more
AT&T has the iPhone 14 on sale for only $...
AT&T has the 128GB Apple iPhone 14 available for only $5.99 per month for new and existing customers when you activate unlimited service and use AT&T’s 36 month installment plan. The fine... Read more
Amazon is offering a $100 discount on every M...
Amazon is offering a $100 instant discount on each configuration of Apple’s new 13″ M3 MacBook Air, in Midnight, this weekend. These are the lowest prices currently available for new 13″ M3 MacBook... Read more
You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more

Jobs Board

*Apple* Systems Administrator - JAMF - Syste...
Title: Apple Systems Administrator - JAMF ALTA is supporting a direct hire opportunity. This position is 100% Onsite for initial 3-6 months and then remote 1-2 Read more
Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.