Example #1
0
WORD gr_slidebox(LONG tree, WORD parent, WORD obj, WORD isvert)
{
        GRECT           t, c;
        WORD            divnd, divis;

        ob_actxywh(tree, parent, &c);
        ob_relxywh(tree, obj, &t);
        gr_dragbox(t.g_w, t.g_h, t.g_x + c.g_x, t.g_y + c.g_y, 
                        &c, &t.g_x, &t.g_y); 

        if ( isvert )
        {
          divnd = t.g_y - c.g_y;
          divis = c.g_h - t.g_h;
        }
        else
        {
          divnd = t.g_x - c.g_x;
          divis = c.g_w - t.g_w;
        }
        if (divis)
          return( mul_div( divnd, 1000, divis) );
        else
          return(0);
}
Example #2
0
WORD insa_dial(LONG tree, WORD nicon, WORD numics)
{
	WORD	firstslot, nstate, ystate, i;
	WORD	touchob, oicon, value;
	WORD	mx, my, kret, bret, cont;
	BYTE	*pstr, doctype[4];
	GRECT	pt;

	/* draw the form */
	show_hide(FMD_START, tree);
	/* init for while loop by forcing initial fs_newdir call */
	cont = TRUE;
	while ( cont )
	{
		firstslot = 6;
		for (i = 0; i < firstslot; i++)
		{
			pstr = &doctype[0];
			inf_sget(tree, APDFTYPE+i, pstr);
			if (*pstr == '\0')
				firstslot = i;
		}
		touchob = form_do((OBJECT FAR *)tree, APDFTYPE+firstslot);
		graf_mkstate(&mx, &my, &kret, &bret);

		value = nstate = ystate = 0;
		touchob &= 0x7fff;
		switch ( touchob )
		{
			case APINST:
			case APREMV:
			case APCNCL:
				cont = FALSE;
				break;
			case APFUPARO:
				value = -1;
				break;
			case APFDNARO:
				value = 1;
				break;
			case APGEM:
				nstate = SELECTED;
				ystate = DISABLED;
				break;
			case APDOS:
			case APPARMS:
				nstate = LWGET(OB_STATE(APNMEM));
				ystate = LWGET(OB_STATE(APYMEM));
				if ( ystate == DISABLED )
				{
					nstate = SELECTED;
					ystate = NORMAL;
				}
				break;
			case APFSVSLI:
				ob_actxywh(tree, APFSVELE, &pt);
				pt.g_x -= 3;
				pt.g_w += 6;
				if ( rc_inside(&pt, mx, my) )
					goto dofelev;
				value = (my <= pt.g_y) ? -1 : 1;
				break;
			case APFSVELE:
dofelev:		wind_update(3);
				ob_relxywh(tree, APFSVSLI, &pt);
				pt.g_x += 3;
				pt.g_w -= 6;
				LWSET(OB_X(APFSVSLI), pt.g_x);
				LWSET(OB_WIDTH(APFSVSLI), pt.g_w);
				value = graf_slidebox((OBJECT FAR *)tree, APFSVSLI, APFSVELE, TRUE);
				pt.g_x -= 3;
				pt.g_w += 6;
				LWSET(OB_X(APFSVSLI), pt.g_x);
				LWSET(OB_WIDTH(APFSVSLI), pt.g_w);
				wind_update(2);
#if M68000
				value = (WORD)((LONG)value * (LONG)(numics-1) / 1000) - nicon;
#else
				value = mul_div(value, numics-1, 1000) - nicon;
#endif
				break;
		}
		if (nstate != ystate)
		{
			LWSET(OB_STATE(APNMEM), nstate);
			LWSET(OB_STATE(APYMEM), ystate);
			draw_fld(tree, APMEMBOX);
		}
		if (value)
		{
			oicon = nicon;
			nicon += value;
			if (nicon < 0)
				nicon = 0;
			if (nicon >= numics)
				nicon = numics - 1;	
			if (oicon != nicon)
			{
				insa_elev(tree, nicon, numics);
				draw_fld(tree, APFTITLE);
				draw_fld(tree, APFSVSLI);
				draw_fld(tree, APFILEBO);
			}
		}
	}
	/* undraw the form	*/
	show_hide(FMD_FINISH, tree);
	return(nicon);
}