TweetFollow Us on Twitter

Listbox in Dialog
Volume Number:1
Issue Number:7
Column Tag:C workshop

Listbox in a Dialog

By Robert B. Denny

I have often wanted to have the ability to put up a dialog box like that of “Standard File”, where the user could select from a list of strings.

Implementing such a function requires a combination of most of the Macintosh technology we have covered in the past several months, plus the services of the Dialog Manager. And not just the usual dialog services, we’ll need to implement a filter function to manage the selection box and scroll bar(s) within the dialog.

This month’s C Workshop makes up for past columns which showed relatively few C programming examples. Instead of explaining the theory of using the dialog manager and it’s filter function hooks, I am instead submitting a complete C function that can be used with most compilers which implements a single- selection dialog similar to that of Standard File.

The appearance of the dialog is completely controlled by resource data, including the dimensions of the selection box. Scroll bars are provided in both vertical and horizontal axes, and automatically size to the selection box dimensions. This particular example was used in a utility to perform name lookups on AppleTalk using the Name Binding Protocol (NBP), and allow selection of a particular object by name.

To use the function sel_dialog(), call it with 3 arguments: a “call-back” function name (explained below) and the address and size of a buffer to receive a copy of the selected string. Four buttons control its operation.

“Lookup” causes the “call-back” function to be called repeatedly for pointers to P-strings to put into the selection window. This action continues until the call-back function returns NULL. The strings do not have to be kept around after being passed to sel_dialog(), they are stored in the TERec’s linear text array. The Lookup button may be pressed repeatedly for many fill-in cycles.

If any of the strings are too long to fit in the selection box horizontally, the horizontal scroller is turned on and ranged for the longest string. It con- tinues to be ranged for the longest string as additional strings are added there- after. Likewise, the vertical scroller is turned on and continually ranged if there are more strings than will fit vertically in the selection box.

After a lookup cycle, the strings in the selector box are armed for mouse clicks and are highlighted when clicked. If any strings are highlighted, the “Accept” button is turned on.

Pressing “Accept” causes the selected string to be copied into the buffer supplied as an argument. “Cancel” causes sel_dialog() to return with a null string in the caller’s buffer. In either case the dialog and all associated data in memory is released and a return to the caller is made.

“Clear” causes the selector box to be cleared; all strings are erased and the scrollers are reset and turned off. This might be useful in preparation for a new lookup process.

Resources Control Appearance

Sel_dialog() is written to be controlled by a set of resources which completely determine the dialog’s layout, including the location and titles of the buttons and the location and dimensions of the selection window. The example here is very similar to the dialog used by Standard File, but it needn’t be. Just observe the correlation between the buttons’ DITL item numbers and their functions. Obviously, you can change the code to eliminate buttons, but you can do so as well by “placing” the buttons off- screen without loss of generality of the function.

Here is the RMAKER source for the example shown on the next pages, followed by some pictures of the dialog and the code for sel_dialog(). Note the homebrew ‘RECT’ resource which sets the location and dimensions of the selection box.

TYPE DLOG
  ,256

72 72 224 420
Invisible NoGoAway
1
0
256

TYPE DITL
  ,256
7

button
28 152 46 232
Accept

button
90 152 108 232
Cancel

button
59 256 77 336
Lookup

button
90 256 108 336
Clear

staticText Disabled
28 254 46 344
NBP Lookup

*Selector box Rect
TYPE RECT = GNRL
  ,256
.I
11 12 125 125

By any measure, this is an “advanced” programming example. Little explanation accompanies the code. I highly recommend you review the Dialog Manager section of Inside Macintosh before working through this example. Note how the filter function and modal dialog loops interact to provide the user interface with just a simple function call from the client application.

The dialog box looks like this when it first appears:

If the “Lookup” button is pressed, your routine gets called repeatedly for P-strings to be inserted in the list shown in the window, until it returns NULL. If one of the strings is longer than will fit in the window, the horizontal scroller will be turned on and ranged appropriately, like this:

If your routine returns enough strings to fill up the window vertically, the vertical scroller will be turned on, like this:

After your call-back function has finished, the mouse becomes active and may be used to push buttons and select text. If you click in one of the items in the select window, it will be highlighted and the “Accept” button will be activated like this:

The C code which makes up the rest of this article implements this general purpose selection dialog. Macintosh toolbox calls are italicized for emphasis. The assembly routines use the linkage conventions of Consulair Mac C, and will need minor changes for other C implementations. Other than these differences, the code below should be easy to use under any of the C systems available for the Mac. There are no “library” routines used at all, except those in the Macintosh ROM.

/* Resource IDs */
#define DLOG_ID  256 /* Dialog window itself */
#define BOX_ID 256 /* Selector box Rectangle */

/* DITL item numbers , also part codes */
#define  ACCEPT  1 /* The Accept button */
#define  CANCEL  2 /* The Cancel button */
#define  LOOKUP  3 /* The Lookup button */
#define  CLEAR 4 /* The Clear button */
#define  TITLE 5 /* static title (NBP Lookup) */

/* Local static variables */
static Rect box_rect;   /* Box rect (from resource) */
static ControlHandle v_scroll; /* ->-> V-Scroller */
static ControlHandle h_scroll;  /* ->-> H-Scroller */
static ControlHandle acc_button; /* ->-> Accept button */
static Rect dest_rect;  /* TextEdit’s destination rect */
static Rect view_rect;    /* Text Edit’s view Rect */
static short int vs_offs; /* destRect vertical offset */
static short int hs_offs; /* destRect horiz offset */
static TEHandle hTE; /* Handle to TextEdit record */
static unsigned short line_height;  /* Text line height, pixels */
static unsigned short lines_vis; /* No. of whole lines visible */
static unsigned short half_wid; /* half width of box in pixels */
static Point loc_pt;        /* Local coord of last mouse click */

/*
  *SEL_DIALOG() - MAIN DIALOG FUNCTION
  *
  *Inputs:
  *P1 procedure to call to add an item. Returns pointer to
  *P-string to add to the items in the box (no newline);
  *Must return NULL when no more to add.
  *P2 address of buffer to receive selection
  *   P3  length (bytes) of selection buffer
  *
  *  Outputs:
  *If Accept pressed, selected string is copied as a
  *C-string into the P2 buffer, up to P3-1 bytes. If Cancel 
  *pressed, a null C-string is placed into the P2 buffer
  */
sel_dialog(add_item, sel_buf, buf_len)
char *(*add_item)(); /* User call-back to add item */
char *sel_buf;   /* Buffer to receive selection */
short buf_len;   /* Length of buffer to receive selection */
    {
   Ptr dp;  /* Dialog pointer */
   Rect **rh;    /* Handle to resource rect */
   Rect  scr_rect; /* Scratch rect */
   long il; /* Length of text from user */
   char *cp;/* Ptr for scanning user items */
   short scratch;/* Scratch word */
   unsigned short item_hit; /* Item number hit in dialog */
   unsigned short done;   /* Flag indicating he’s done */
   unsigned short sw;/* String width, pixels */
   unsigned short cv;/* Control value buffer */
   unsigned short max_wid;/* Max line width pixels */
   unsigned short sel_line; /* Line number of selected line */
   unsigned short sel_start;/* Index of 1st char of sel line */
   unsigned short sel_end;/* Index 1st char after sel line */
   unsigned short sel_len;/* Length of selected text */
   short hce, vce; /* Flags TRUE if scroller enabled */
   int user_Filt();/* Dialog filter */


   dp = (Ptr)GetNewDialog (DLOG_ID, 0, -1);  /* Load dialog */
   SetPort (dp); ‘ /* Hook QuickDraw  to dialog */
   /*
     * Dim the accept button & save it’s handle for later
     * Disable it until something is selected
     */
   GetDItem (dp, ACCEPT, &scratch, &acc_button, &scr_rect);
   HiliteControl (acc_button, 255);
 /* “part” 255 means dim & disable */
   /*
     * Get the box rect as a resource & copy it 
 locally, then release it
   */
   rh = (Rect *)GetResource (‘RECT’, BOX_ID);      /* Get rect*/
   box_rect.topLeft.all = (*rh)->topLeft.all;      
   box_rect.botRight.all = (*rh)->botRight.all;
   ReleaseResource (rh);  /* No need for this now */
   /*
     * Put up the scroll bars.  Compute their sizes from the   selector 
box rectangle.
     */
   scr_rect.top = box_rect.top; /* Vert scroll bar on right edge */
   scr_rect.left = box_rect.right - 1; /* Overlap wind box 1 pix */
   scr_rect.bottom = box_rect.bottom;
   scr_rect.right = scr_rect.left + 16; /* Standard 16-pix width */
   v_scroll = (ControlHandle)NewControl (dp, &scr_rect, 0, TRUE, 0, 0, 
0, scrollBarProc, 0);
   HiliteControl (v_scroll, 255);  /* Deactivate for now */
   vce = FALSE;
 
  scr_rect.top = box_rect.bottom - 1;/* Horiz. scroll bar  */
   scr_rect.left = box_rect.left;  /* Same overlap, width */
   scr_rect.bottom = scr_rect.top + 16;
   scr_rect.right = box_rect.right;
   h_scroll = (ControlHandle)NewControl (dp, &scr_rect, 0, TRUE, 0, 0, 
0, scrollBarProc, 0);
   HiliteControl (h_scroll, 255);  /* Deactivate for now */
   hce = FALSE;
 
  /*
     * Set up a TextEdit record for the items in the box. Leave 3 
 pixel bleed on left, none on the
     * right, 3 at the top of the destRect.  Must never wrap or go 
 off bottom. Calculate the number
     * of complete lines of text visible in the view_rect.
     */
   dest_rect.top = box_rect.top + 3;
   dest_rect.left = box_rect.left + 3;
   dest_rect.right = 1000;/* room for long text items */
   dest_rect.bottom = 2000;
   view_rect.top = box_rect.top + 1;  /* View area inset 1 pixel */
   view_rect.left = box_rect.left + 1;
   view_rect.bottom = box_rect.bottom - 1;
   view_rect.right = box_rect.right - 1;
   hTE = (TEHandle)TENew (&dest_rect, &view_rect); /* Start up TextEdit 
on the box */
   /*
     * Calculate scrolling parameters & initialize vars.  This 
 makes it possible to control
     * everything by changing the box Rect resource.
     */
   line_height = (*hTE)->lineHeight; /* Copy line height */
   hs_offs = vs_offs = 0; /* Viewing upper left corner */
   lines_vis = (view_rect.bottom - view_rect.top) / line_height;
   half_wid = (view_rect.right - view_rect.left) / 2;
   /*
     * Finally - Light up the dialog box all at once
     */
   #ShowWindow(dp);/* Make it visible suddenly */

   /*
    * MAIN DIALOG LOOP
    */
   done = FALSE; /* Not “done”, obviously */
   max_wid = 0;  /* Longest line (pixels) */
   hce = vce = FALSE;/* No scrollers needed now */
 
  while(!done)   /* “Done” if Accept or Cancel pressed */
      {
      ModalDialog (user_Filt, &item_hit);    
 /* Do dialog, return item # hit */

      switch(item_hit)    /* Take action from dialog */
         {
         /*
           * CANCEL pressed.  Axe everything and return an empty
           * item buffer.  Exit the dialog loop * clean up.
         */
         case  CANCEL:    /* Forget it, no returned item */
            done = TRUE;  /* We’re “done” */
            sel_buf[0] = ‘\0’;/* NULL string */
            break;

         /*
           * ACCEPT pressed. Grab the text of the selected line 
 and return it to the caller.
           * Exit the dialog loop.
           */
         case  ACCEPT:
            done = TRUE;  /* We’re “done”, all right */
            sel_len = sel_end - sel_start;   /* Length (bytes)  */
            if(sel_len > buf_len)  /* Don’t overrun buffer! */
               sel_len = buf_len;
            BlockMove (((char *)(*((*hTE)->hText)))[sel_start], sel_buf, 
sel_len);
            break;

         /*
           * LOOKUP pressed.  This is the most complex:
           *
           *   1.Deselect currently selected item, if any, and 
 dim Accept button.
           *   2.Repeatedly do call-back for P-strings to add to 
 items in selection box.
           *Stop when call-back returns NULL.  Keep track of   
 size of longest item 
           *(in pixels).
           *   3.When all new items have been added, turn on   
 required scrollers.  H-scroller
           *   is needed if longest item exceeds view_rect width.  
 V-scroller is needed  if 
           *total number of items exceeds the number of lines  
 visible in the box.
           *   4.For each live scroller, adjust it’s range to just 
 cover the live area.  For the
           *V-scroller, set it’s max so that the last item will be at 
 the bottom of the 
           *box when the control is at max.  For the H-scroller, 
 set it’s max so that
           *the longest item’s last character will be st the right 
 edge of the box when 
           *the control is at max.
           *
           * NOTE: The Lookup button may be repeatedly pressed.
           */
         case  LOOKUP:  /* Call user proc till we get NULL */
            TEDeactivate (hTE);    /* Hide selection */
            TESetSelect (32767, 32767, hTE); /* Deselect  */
            sel_start = sel_end = sel_line = 0;    /* Nothing selected 
*/
            HiliteControl (acc_button, 255); /*Dim accept button */
            while((cp = (*add_item)()) != 0) /* Call user for items */
               {
               il = (long)(*cp); /* il = length of this item (chars) 
*/
               max_wid = ((sw = (short)StringWidth (cp++)) > max_wid) 
? sw : max_wid;
               TEInsert (cp, il, hTE); /* Insert item in box */
               TEKey (‘\r’, hTE);  /* Start a new line */
               }
            /*
              * Check if we need h-scroller.  If so, activate it. 
              * If active, set its range per longest string.  Adjust
              * range in units of page scroll amount.
              */
         if(!hce && max_wid > (view_rect.right - view_rect.left - 3))
               {
               hce = TRUE;/* Turn on the scroller if needed */
               HiliteControl (h_scroll, 0);
               }
            if(hce)/* If it’s on, range it to longest line */
               SetCtlMax (h_scroll, max_wid - (view_rect.right - view_rect.left));
            /*
              * Same for the vertical scroller. Activate it if number
              * of lines is greater than will fit on the screen.  Always
              * set controlMax to number of lines x  line height less
              * lines visible.
              */
            if((*hTE)->nLines > lines_vis && !vce)
               {
               vce = TRUE;/* Turn on scroller if needed */
               HiliteControl (v_scroll, 0);
               }
            if(vce)/* If it’s on, range it to # of lines */
               SetCtlMax (v_scroll, (((*hTE)->nLines) - lines_vis) * 
line_height);
            break;

         /*
           * CLEAR pressed.  Axe everything, delete all items from 
 the list, turn off the scrollers 
           * and accept button.  Bash the TERecord’s view_rect 
 back to the original to remove scroll
           * effects.  Reset state vars.
           */
         case  CLEAR:/* Axe all data in selection box */
            sel_start = sel_end = sel_line = 0;    /* No more selection 
*/
            TEDeactivate (hTE);    /* Hide selection */
            TESetSelect (0, 32767, hTE);     /* Select everything */
            TEDelete (hTE); /* Axe it */
            HiliteControl (acc_button, 255); /* Dim button */
            hce = vce = FALSE;/* Deactivate & reset scrollers */
            hs_offs = vs_offs = 0; /* Back to upper left corner */
            (*hTE)->destRect.topLeft.all = dest_rect.topLeft.all;
            (*hTE)->destRect.botRight.all = dest_rect.botRight.all;
            SetCtlValue (v_scroll, 0); /* Reset controls */
            SetCtlMax (v_scroll, 0);
            HiliteControl (v_scroll, 255);
            SetCtlValue (h_scroll, 0);
            SetCtlMax (h_scroll, 0);
            HiliteControl (h_scroll, 255);
            max_wid = 0;  /* Reset longest line */
            break;

         /*
           * Click in selector box.  Highlight the item (line of text) 
in which the click occurred.  
           * This turns out to be rather easy.  The line index can be 
 determined by calculating
           * the distance of the click from the top of the TERec’s 
 destRect and dividing by the line
           * height.  Then use the “lineStarts” array to get the 
 starting and ending indexes for
           * the line and calling TESetSelect to highlight the 
 selection. Now call TEActivate 
           * to show the highlighting.  Finally, turn on the Accept 
 button.
           */
         case  SELBOX:    /* Click in the selector box */
            if((*hTE)->nLines == 0)/* (skip it if no lines) */
               break;

          /* Calculate line index */
          sel_line = (loc_pt.v - (*hTE)->destRect.top) / line_height;

            /* Deselect if click below last line. */
            if(sel_line >= (*hTE)->nLines)   /* Beyond last line */
               {
               TEDeactivate (hTE); /* Hide selection */
               TESetSelect (32767, 32767, hTE);    /* Deselect */
               sel_start = sel_end = sel_line = 0;       /* No select 
*/
               HiliteControl (acc_button, 255);          /* Dim button 
*/
               break;
               }

            /* Highlight selected text & turn on the Accept button */
            sel_start = (*hTE)->lineStarts[sel_line];    /*1st char */
            sel_end = (*hTE)->lineStarts[sel_line + 1];  
 /* Index of char following sel’d line */
            TESetSelect (sel_start, sel_end, hTE);  /* Set select */
            TEActivate (hTE); /* Highlight selected line */
            HiliteControl (acc_button, 0);   /* Activate button */
            break;

         default:
         }
      } /* END OF MAIN DIALOG LOOP ... */
   #TEDispose(hTE);/* Junk TextEdit stuff */
   #DisposeDialog(dp);    /* Close & free heap space */
   }

/*
  * USER_FILT - Filter dialog events to handle scroller and    select 
box
  *
  * This sets up for Consulair Mac C.  Your compiler’s linkage 
 may differ.
  */
user_filt()
   {
#asm
;
; Inputs:
;      4(SP)      Address of word to fill in with item number
;      8(SP)      Address of the event record
;     12(SP)      Dialog (window) pointer
;
      Link       a6,#0    ; No local automatics
      Movem.L    d1-d2,-(sp); Save regs
      Move.L     8(a6),d0 ; D0 -> Item number word
      Move.L     12(a6),d1; D1 -> Event record
      Move.L     16(a6),d2; D2 -> Window record
      Jsr        __filt   ; Call C for dirty work
      Movem.L    (sp)+,d1-d2; Restore regs
      Unlk       a6; “standard” Pascal routine exit ...
      Move.L    (sp)+,a0  ; A0 -> return point
      Addq.L     #6,sp    ; Pop args
      Addq.L     #6,sp    ; (don’t ask why ...)
      Move.B     d0,(sp)  ; Copy C result to Pascal return
      Jmp        (a0); Return
#endasm
   }

/*
  * This is the “real” filter function
  *
  * We must handle activating & updating of the scroller and the 
 box area, but pass FALSE back
  * so dialog manager does his thing on the other items.  We   must handle 
mouse downs in the
  * scroller and text box, passing back TRUE, and pass FALSE   back for 
everything else.
  *
  *
  * Inputs:
  *P1 -> word to receive item code
  *P2 -> Event record
  *P3 -> WindowRecord for dialog
  */
__filt(ip, ep, wp)
short *ip;
EventRecord *ep;
WindowPtr wp;
   {
   short part;
   ControlHandle ch;
   int scroll_up();
   int scroll_down();

   SetPort (wp); /* We shouldn’t have to but ... */

   switch(ep->what)/* Dispatch on event type */
      {
      /*
        * MOUSE CLICK
        */
      case mouseDown:
         loc_pt.all = ep->where.all; /* Preserve event point  */
         GlobalToLocal (&loc_pt);  /* We need local coord*/
         part = (short)FindControl (&loc_pt, wp, &ch);   /* Where?*/
         /*
           * Try for one of our scrollers (ignore other controls)
           */
  
       if(part != 0 && (ch == v_scroll || ch == h_scroll))
            {
            /*
              * CLICK IN ONE OF OUR SCROLL BARS
              */
            switch(part)  /* Clicked in our scroller */
               {
               case inUpButton:  /* Up: Track w/action proc */
                  TrackControl (ch, &loc_pt, scroll_up);
                  return(TRUE);
               case inDownButton:  /* Down: Track w/action proc */
                  TrackControl (ch, &loc_pt, scroll_down);
                  return(TRUE);
               case inPageUp: /* PageUp: Jump per Mac Interface */
                  page_scroll(part, ch, -1);
                  return(TRUE);
               case inPageDown:    /* PageDown: Do Mac interface */
                  page_scroll(part, ch, 1);
                  return(TRUE);
               case inThumb:/* Thumb: Track w/no action proc */
                  TrackControl (ch, &loc_pt, 0);
                  box_scroll();  /* Jump to new scroller setting */
                  return(TRUE);
               default:
                  return(FALSE); /* ????? Shouldn’t happen (ha) */
               }
            }
         else if(PtInRect (&loc_pt, &box_rect))    
 /* Click in our selector box? */
            {
            /*
              * CLICK IN SELECTOR BOX.   Handled by            
 ModalDialog() caller, not here!
              */
            *ip = SELBOX; /* Fill in item code */
            return(TRUE); /* Return to caller for action */
            }
         else
            /*
              * CLICK SOMEWHERE ELSE - LET MODAL-DIALOG        
 DO IT
              */
            return(FALSE);

      /*
        * UPDATE - Notice no BeginUpdate() & EndUpdate()? Why  
 not?  You figure that one out.
        */
      case updateEvt:
         SetPort (wp);    /* (really needed?) */
         DrawControls (wp); /* Crude, double-draws buttons */
         PenNormal ();    /* Too bad if user needs pen */
         FrameRect (&box_rect);    /* Draw box */
         TEUpdate (&view_rect, hTE); /* Draw text */
         return(FALSE);   /* Let dialog manager do the rest */

      /*
        * ACTIVATE/DEACTIVATE - Is this needed? (yes, but      
 why?)
        */
      case activateEvt:
         SetPort (wp);    /* (really needed?) */
         if(ep->modifiers & 1)/* Activate */
            {
            ShowControl (v_scroll);/* Draw scrollers */
            ShowControl (h_scroll);
            }
         else
            {
            HideControl (v_scroll);/* Erase scrollers */
            HideControl (h_scroll);
            }
         return(FALSE);   /* Let dialog manager do the rest */

      /*
        * EVENTS WE DON’T TRAP
        */
      default:
         return(FALSE);   /* Dialog manager does it */
      }
   }

/*
  *LOCAL UTILITIES
  */

/*
  * PAGE_SCROLL() - Scroll a page per indicator
  *
  * Inputs:
  *part     Part code where first clicked down
  *ch       control handle
  *dir      direction (-1 = up, +1 = down)
  *
  * Outputs:
  *none
  */
static page_scroll(part, ch, dir)
short part; /* Part where mouse first clicked */
ControlHandle ch;/* ->-> Control where mouse first clicked */
short dir;/* Direction code (see above) */
   {
   Point cur_pt; /* Where is mouse now? */
   short amount;

   /*
     * First, calculate the “page size” in pixels.  For V scroll, it 
is the viewRect height less the 
     * line height.  For H scroll, it is half the width of the viewRect.
     */
 
  if(ch == v_scroll)
      amount = view_rect.bottom - view_rect.top - line_height;
   else
      amount = half_wid;

   amount *= dir;/* Change sign per requirements */

   /*
     * Now we must locally handle the mouse per the Macintosh  Interface
     * Guidelines.  Look closely at this code and note what it 
 really does ...
     */
   do   /* Do this once even if mouse is */
      { /*   up by now ... */
      GetMouse (&cur_pt); /* Get current mouse location */
      if((short)TestControl (ch, &cur_pt) != part) 
 /* If out of original part , then */
         continue; /*   don’t do anything .*/
      #SetCtlValue(ch, GetCtlValue (ch) + amount); /* Page */
      box_scroll();/* Page the text */
      } while(StillDown ());/* Keep it up till mouse released */
   }


/*
  * SCROLL_UP() - Scroll up the selector box
  *
  * This routine is called back from the toolbox with (naturally) 
 Pascal-flavored arguments 
  * on the stack.  This routine should work with any compiler  supporting 
inline assembler.
  * If yours doesn’t, just code the routine in “real” assembler & 
 link it in.   It’s not compiler-
  * dependent. Note the limits on _SetSctValue() to prevent    “rattling 
against the stops”.
  */
static scroll_up()
   {
#asm
;
; Inputs:
;        4(sp)       Part code (int)
;        6(sp)       Control handle (address)
;
controlMin     EQU   20

      Link       a6,#0
      Move.W     8(a6),d0 ; D0 = part code (W)
      Beq        @1; (0 means out of part region)
      Move.L     10(a6),-(sp) ; Push control handle (for later)
      Clr.W     -(sp); Gets control value
      Move.L    10(a6),-(sp); Push control handle
      _GetCtlValue ; (SP) = current control value
      jsr        get_lh   ; D0 = line height
      Sub.W      d0,(sp)  ; (SP) = new control value
      Move.W     (sp),d0  ; D0 = new value
      Move.L     2(sp),a0 ; A0 = Control Handle
      Move.L     (a0),a0  ; A0 -> scroller record
      Cmp.W     controlMin(a0),d0  ; Compare with controlMin
      Bge         @0 ; (in range)
      Move.W     controlMin(a0),(sp) ; Limit it to min
@0:   _SetCtlValue
      Jsr        box_scroll ; call C text scroller
@1:
      Unlk       a6; “standard” Pascal routine exit
      Move.l    (sp)+,a0
      Addq.l     #6,sp
      Jmp         (a0)
#endasm
   }

/*
  * SCROLL_DOWN() - Scroll down the selector box
  *
  * This routine is called back from the toolbox with (naturally) 
 Pascal-flavored arguments 
  * on the stack.  This routine should work with any compiler  supporting 
inline assembler.
  * If yours doesn’t, just code the routine in “real” assembler & 
 link it in.   It’s not compiler-
  * dependent.
  */
static scroll_down()
   {
#asm
;
; Inputs:
;        4(sp)       Part code (int)
;        6(sp)       Control handle (address)
;
controlMax     EQU   22

      Link       a6,#0    ; no local automatics
      Move.W     8(a6),d0 ; D0 = part code (W)
      Beq         @1 ; (0 means out of part region)
      Move.L     10(a6),-(sp) ; Push control handle (for later)
      Clr.W      -(sp)    ; Gets control value
      Move.L     10(a6),-(sp) ; Push control handle
      _GetCtlValue ; (SP) = current value
      Jsr        get_lh ; D0 = text line height(**SICKO**)
      Add.W      d0,(sp)  ; (SP) = new control value
      Move.W     (sp),d0  ; D0 = new value
      Move.L     2(sp),a0 ; A0 = Control Handle
      Move.L     (a0),a0  ; A0 -> scroller record
      Cmp.W      controlMax(a0),d0 ; Compare with controlMax
      Ble        @0; (in range)
      Move.w     controlMax(a0),(sp) ; Limit it to max
@0:   _SetCtlValue
      Jsr         box_scroll; call C text scroller
@1:
      Unlk       a6; “standard” Pascal routine exit ...
      Move.l     (sp)+,a0
      Addq.l     #6,sp
      Jmp         (a0)
#endasm
   }

/*
  * BOX_SCROLL() - Scroll text in selector box
  *
  * Changes TERec’s destRect per current scroller values.  The 
 scroller’s value is equal to the
  * number of pixels that the dest_rect has been offset upward 
 relative to the view_rect. 
  * If both scrollers  are at 0, you see the upper left of the 
 destRect.
  */
static box_scroll()
   {
   short int dh, dv;

   dh = hs_offs - (short)GetCtlValue (h_scroll);   
 /* Get scroll changes for X & Y */
   dv = vs_offs - (short)GetCtlValue (v_scroll);

   TEScroll (dh, dv, hTE);/* Scroll the destRect */
   hs_offs -= dh;/* Update the offset values */
   vs_offs -= dv;
   }

/*
  * This is just a cheap way to get at this C global from      assembly 
language without knowing its
  * R5 offset as generated by the compiler’s static access     mechanism.
  */
get_lh()/* Get text line height */
   {
   return(line_height);
   }

 
AAPL
$119.00
Apple Inc.
+1.40
MSFT
$47.75
Microsoft Corpora
+0.28
GOOG
$540.37
Google Inc.
-0.71

MacTech Search:
Community Search:

Software Updates via MacUpdate

Skype 7.2.0.412 - Voice-over-internet ph...
Skype allows you to talk to friends, family and co-workers across the Internet without the inconvenience of long distance telephone charges. Using peer-to-peer data transmission technology, Skype... Read more
HoudahSpot 3.9.6 - Advanced file search...
HoudahSpot is a powerful file search tool built upon MacOS X Spotlight. Spotlight unleashed Create detailed queries to locate the exact file you need Narrow down searches. Zero in on files Save... Read more
RapidWeaver 6.0.3 - Create template-base...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
iPhoto Library Manager 4.1.10 - Manage m...
iPhoto Library Manager lets you organize your photos into multiple iPhoto libraries. Separate your high school and college photos from your latest summer vacation pictures. Or keep some photo... Read more
iExplorer 3.5.1.9 - View and transfer al...
iExplorer is an iPhone browser for Mac lets you view the files on your iOS device. By using a drag and drop interface, you can quickly copy files and folders between your Mac and your iPhone or... Read more
MacUpdate Desktop 6.0.3 - Discover and i...
MacUpdate Desktop 6 brings seamless 1-click installs and version updates to your Mac. With a free MacUpdate account and MacUpdate Desktop 6, Mac users can now install almost any Mac app on macupdate.... Read more
SteerMouse 4.2.2 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
iMazing 1.1 - Complete iOS device manage...
iMazing (was DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and from... Read more
PopChar X 7.0 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more
OneNote 15.4 - Free digital notebook fro...
OneNote is your very own digital notebook. With OneNote, you can capture that flash of genius, that moment of inspiration, or that list of errands that's too important to forget. Whether you're at... Read more

Latest Forum Discussions

See All

Lucha Amigos (Games)
Lucha Amigos 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Forget Ninja Turtles, and meet Wrestlers Turtles! Crazier, Spicier and…Bouncier! Sling carapaces of 7 Luchadores to knock all... | Read more »
Raby (Games)
Raby 1.0.3 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.3 (iTunes) Description: ***WARNING - Raby runs on: iPhone 5, iPhone 5C, iPhone 5S, iPhone 6, iPhone 6 Plus, iPad Mini Retina, iPad Mini 3, iPad 4, iPad Air,... | Read more »
Oddworld: Stranger's Wrath (Games)
Oddworld: Stranger's Wrath 1.0 Device: iOS Universal Category: Games Price: $5.99, Version: 1.0 (iTunes) Description: ** PLEASE NOTE: Oddworld Stranger's Wrath requires at least an iPhone 4S, iPad 2, iPad Mini or iPod Touch 5th gen... | Read more »
Bounce On Back (Games)
Bounce On Back 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: | Read more »
Dwelp (Games)
Dwelp 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: === 50% off for a limited time, to celebrate release === Dwelp is an elegant little puzzler with a brand new game mechanic. To complete a... | Read more »
Make Way for Fat Chicken, from the Maker...
Make Way for Fat Chicken, from the Makers of Scrap Squad Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Relevant Games has announced they will be releasing their reverse tower defense game, | Read more »
Tripnary Review
Tripnary Review By Jennifer Allen on November 26th, 2014 Our Rating: :: TRAVEL BUCKET LISTiPhone App - Designed for the iPhone, compatible with the iPad Want to create a travel bucket list? Tripnary is a fun way to do exactly that... | Read more »
Ossian Studios’ RPG, The Shadow Sun, is...
Ossian Studios’ RPG, The Shadow Sun, is Now Available for $4.99 Posted by Jessica Fisher on November 26th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Mmmm, Tasty – Having the Angry Birds for...
The very first Angry Birds debuted on iOS back in 2009. When you sit back and tally up the number of Angry Birds games out there and the impact they’ve had on pop culture as a whole, you just need to ask yourself: “How would the birds taste... | Read more »
Rescue Quest Review
Rescue Quest Review By Jennifer Allen on November 26th, 2014 Our Rating: :: PATH BASED MATCH-3Universal App - Designed for iPhone and iPad Guide a wizard to safety by matching gems. Rescue Quest might not be an entirely original... | Read more »

Price Scanner via MacPrices.net

Apple Store Black Friday sale for 2014: $100...
BLACK FRIDAY The Apple Store has posted their Black Friday deals for 2014. Receive a $100 PRODUCT(RED) branded iTunes gift card with the purchase of select Macs, $50 with iPads, and $25 with iPods,... Read more
Black Friday: 15% off iTunes Gift Cards
Staples is offering 15% off $50 and $100 iTunes Gift Cards on their online store as part of their Black Friday sale. Click here for more information. Shipping is free. Best Buy is offering $100... Read more
BEVL Releases Dock Tailored for iPhone 6 and...
Seattle based BEVL has released their first product: an iPhone dock that is divergent in build quality, rock-solid function and visual simplicity to complement the iPhone. BEVL is now accepting... Read more
Black Friday: $150 off 13-inch Retina MacBook...
 Best Buy has 13-inch 2.6GHz Retina MacBook Pros on sale for $150 off MSRP on their online store as part of their Black Friday sale. Choose free shipping or free local store pickup (if available).... Read more
Black Friday: $300 off 15-inch Retina MacBook...
 B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for $300 off MSRP as part of their Black Friday sale. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina... Read more
Black Friday: Up to $140 off MacBook Airs, fr...
 B&H Photo has 2014 MacBook Airs on sale for up to $140 off MSRP as part of their Black Friday sale. Shipping is free, and B&H charges NY sales tax only: - 11″ 128GB MacBook Air: $799 $100... Read more
Black Friday: 13-inch 2.5GHz MacBook Pro on s...
 Best Buy has the 13″ 2.5GHz MacBook Pro on sale for $899.99 on their online store as part of their Black Friday sale. Choose free shipping or free instant local store pickup (if available). Their... Read more
Black Friday: 21-inch 1.4GHz iMac on sale for...
 Best Buy has the 21″ 1.4GHz iMac on sale for $899.99 on their online store as part of their Black Friday sale. Their price is $200 off MSRP. Choose free shipping or free local store pick up. Price... Read more
Black Friday iPad Air 2 sale prices, $100 off...
 Best Buy has iPad Air 2s on sale for $100 off MSRP on their online store for Black Friday. Choose free shipping or free local store pickup (if available). Sale prices available for online orders... Read more
2014 1.4GHz Mac mini on sale for $449, save $...
 B&H Photo has the new 1.4GHz Mac mini on sale for $449.99 including free shipping plus NY tax only. Their price is $50 off MSRP, and it’s the lowest price available for this new model. Adorama... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.