Example #1
0
/**************************************************************************
 MUIM_Draw
**************************************************************************/
IPTR Numericbutton__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    IPTR  val;
    char *buf;
    int   width;

    DoSuperMethodA(cl,obj,(Msg)msg);

    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    DoMethod(obj,MUIM_DrawBackground,_mleft(obj),_mtop(obj),_mwidth(obj),_mheight(obj),
             _mleft(obj),_mtop(obj),0);

    SetFont(_rp(obj),_font(obj));
    SetABPenDrMd(_rp(obj),_pens(obj)[MPEN_TEXT],_pens(obj)[MPEN_BACKGROUND],JAM1);

    get(obj, MUIA_Numeric_Value, &val);
    buf = (char*)DoMethod(obj,MUIM_Numeric_Stringify,val);
    width = TextLength(_rp(obj),buf,strlen(buf));

    Move(_rp(obj), _mleft(obj) + (_mwidth(obj) - width) / 2,
         _mtop(obj) + _font(obj)->tf_Baseline);

    Text(_rp(obj), buf, strlen(buf));

    return TRUE;
}
Example #2
0
IPTR Colorfield__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Colorfield_DATA *data = INST_DATA(cl,obj);

    DoSuperMethodA(cl,obj,(Msg)msg);
    
    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    if (data->flags & FLAG_NO_PEN)
    {
    	static UWORD pat[] = {0x1111,0x2222,0x4444,0x8888};
	
    	SetAfPt(_rp(obj), pat, 2);
	SetABPenDrMd(_rp(obj), _pens(obj)[MPEN_SHADOW], _pens(obj)[MPEN_BACKGROUND],JAM2);

    }
    else
    {
	SetABPenDrMd(_rp(obj), data->pen, 0,JAM1);
    }
    
    RectFill(_rp(obj), _mleft(obj), _mtop(obj), _mright(obj), _mbottom(obj));
    
    SetAfPt(_rp(obj), NULL, 0);
    
    return 0;
}
Example #3
0
IPTR IconImage__MUIM_Draw
(
    Class *CLASS, Object *self, struct MUIP_Draw *message
)
{
    struct IconImage_DATA *data = INST_DATA(CLASS, self); 
    IPTR                   rc   = DoSuperMethodA(CLASS, self, (Msg) message);
    IPTR                   selected;
    
    DoMethod
    (
        self, MUIM_DrawParentBackground,  
        _mleft(self), _mtop(self), _mwidth(self), _mheight(self), 0, 0, 0
    );
    
    get(self, MUIA_Selected, &selected);
    
    DrawIconState
    (
        _rp(self), data->iid_DiskObject, NULL, 
        _mleft(self), _mtop(self), selected ? IDS_SELECTED : IDS_NORMAL, 
        
        ICONDRAWA_Frameless,       TRUE,
        ICONDRAWA_Borderless,      TRUE,
        ICONDRAWA_EraseBackground, FALSE,
        TAG_DONE
    );
    
    return rc;
}
Example #4
0
IPTR IconImage__MUIM_AskMinMax
(
    Class *CLASS, Object *self, struct MUIP_AskMinMax *message
)
{
    struct IconImage_DATA *data = INST_DATA(CLASS, self);
    IPTR                   rc   = DoSuperMethodA(CLASS, self, (Msg) message);
    struct Rectangle       size;
    
    memset(&size, 0, sizeof(struct Rectangle));
    
    if
    (
        GetIconRectangle
        (
            _rp(self), data->iid_DiskObject, NULL, &size, 
            
            ICONDRAWA_Borderless, TRUE, 
            TAG_DONE 
        )
    )
    {
    	WORD w = size.MaxX - size.MinX + 1;
	WORD h = size.MaxY - size.MinY + 1;
	
        message->MinMaxInfo->MinWidth  += w;
        message->MinMaxInfo->MaxWidth  += w;
        message->MinMaxInfo->DefWidth  += w;
        message->MinMaxInfo->MinHeight += h;
        message->MinMaxInfo->MaxHeight += h;
        message->MinMaxInfo->DefHeight += h;
    }

    return rc;
}
Example #5
0
IPTR mDraw(Class *cl, Object *obj, struct MUIP_Draw *msg) {
    mybug(0, ("mDraw gets called\n"));

    struct InstData *data = INST_DATA(cl, obj);

    WORD    	      y;
    IPTR    	      retval;

    static ULONG sec=0, mic=0, lastTick=0, currTick=0;
    
    retval = DoSuperMethodA(cl, obj, (Msg)msg);
    
    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE))) return 0;

    if(data->ps3eye_ep1pipe) {        
        for(y= 0; y < _mheight(obj); y++) {
            WORD col;
            col = ((y + data->pos) / 8) % 2;
            SetAPen(_rp(obj), _pens(obj)[col ? MPEN_SHADOW : MPEN_SHINE]);
            RectFill(_rp(obj), _mleft(obj), _mtop(obj) + y, _mright(obj), _mtop(obj) + y);
        }
        data->pos++;
    } else {
        /* Add static distortion or old crt-monitor effect */
        if(data->resolutionvga) {
            DoEffect(kitty640_pure, kitty, 640, 480);
            WritePixelArray(kitty, 0, 0, 640*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032);
//          WritePixelArray(kitty640_pure, 0, 0, 640*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032); //+(rand() % (10))
        } else {

            DoEffect(kitty320_pure, kitty, 320, 240);
            WritePixelArray(kitty, 0, 0, 320*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032);
        }
    }


    //lastTick = currTick;
    //CurrentTime(&sec, &mic);
    //currTick = ((sec * 1000) + (mic / 1000));
    //mybug(-1, ("Delta %d mS\n", currTick-lastTick));

    return retval;
}
Example #6
0
IPTR Pendisplay__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Pendisplay_DATA *data = INST_DATA(cl,obj);
    LONG    	    	       color;
    
    DoSuperMethodA(cl,obj,(Msg)msg);
    
    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    if (data->refobj)
    {
    	IPTR val;
	
	get(data->refobj, MUIA_Pendisplay_Pen, &val);	
    	color = (LONG)val;
    }
    else
    {
    	color = data->pen;
    }
    
    if (color == -1)
    {
    	static UWORD pat[] = {0x1111,0x2222,0x4444,0x8888};
	
    	SetAfPt(_rp(obj), pat, 2);
	SetABPenDrMd(_rp(obj), _pens(obj)[MPEN_SHADOW], _pens(obj)[MPEN_BACKGROUND],JAM2);

    }
    else
    {
	SetABPenDrMd(_rp(obj), MUIPEN(color), 0,JAM1);
    }
    
    RectFill(_rp(obj), _mleft(obj), _mtop(obj), _mright(obj), _mbottom(obj));
    
    SetAfPt(_rp(obj), NULL, 0);
    
    return 0;
}
Example #7
0
static IPTR mLampDraw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct lampData *data = INST_DATA(cl,obj);
    IPTR            res;

    res = DoSuperMethodA(cl,obj,(APTR)msg);

    if(hasFlag(msg->flags, (MADF_DRAWOBJECT|MADF_DRAWUPDATE)))
    {
        WORD l, t, r, b;

        /* Don't ask or modify ! */

        l = _mleft(obj);
        r = _mright(obj);
        t = _mtop(obj)+(_mheight(obj)+data->delta)/2-1;
        b = t-data->delta;

        if (r-l>2)
        {
            l += 1;
            r -= 1;
        }

        if (b-t>2)
        {
            t += 1;
            b -= 1;
        }

        SetAPen(_rp(obj), MUIPEN(isFlagSet(data->flags, FLG_LampDisabled) ? data->disabled : data->enabled));
        RectFill(_rp(obj),l,t,r,b);

        SetAPen(_rp(obj),MUIPEN(data->detail));
        Move(_rp(obj),l,t);
        Draw(_rp(obj),r,t);
        Draw(_rp(obj),r,b);
        Draw(_rp(obj),l,b);
        Draw(_rp(obj),l,t);
    }

    return res;
}
Example #8
0
/**************************************************************************
 MUIM_Draw
**************************************************************************/
IPTR Levelmeter__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Levelmeter_DATA *data = INST_DATA(cl, obj);
    struct RastPort *rp;
    WORD x1, y1, x2, y2;

    DoSuperMethodA(cl,obj,(Msg)msg);

    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    x1 = _mleft(obj);
    y1 = _mtop(obj);
    x2 = _mright(obj);
    y2 = _mbottom(obj);

    rp = _rp(obj);

    if (msg->flags & MADF_DRAWOBJECT)
    {
        /* Transparent edges */

        DoMethod(obj, MUIM_DrawParentBackground, x1, y1, 2, 1, x1, y1, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x1, y1 + 1, 1, 1, x1, y1 + 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x2 - 1, y1, 2, 1, x2 - 1, y1, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x2, y1 + 1, 1, 1, x2, y1 + 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x1, y2, 2, 1, x1, y2, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x1, y2 - 1, 1, 1, x1, y2 - 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x2 - 1, y2, 2, 1, x2 - 1, y2, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x2, y2 - 1, 1, 1, x2, y2 - 1, 0);

        /* Outer frame */

        SetABPenDrMd(rp, _pens(obj)[MPEN_SHINE], 0, JAM1);
        Move(rp, x1 + 1, y2 - 1);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2 - 1, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        Move(rp, x2, y1 + 2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x1 + 2, y2);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        Move(rp, x1 + 1, y2 - 2);
        Draw(rp, x1 + 1, y1 + 2);
        Draw(rp, x1 + 2, y1 + 1);
        Draw(rp, x2 - 2, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x2 - 1, y1 + 2);
        Draw(rp, x2 - 1, y2 - 2);
        Draw(rp, x2 - 2, y2 - 1);
        Draw(rp, x1 + 2, y2 - 1);

        /* Border */

        x1 += OUTERFRAME_X;
        x2 -= OUTERFRAME_X;
        y1 += OUTERFRAME_X;
        y2 -= OUTERFRAME_Y;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        RectFill(rp, x1, y1, x2, y1 + BORDERSIZE_Y - 1);
        RectFill(rp, x1, y1 + BORDERSIZE_Y, x1 + BORDERSIZE_X - 1, y2);
        RectFill(rp, x1 + BORDERSIZE_X - 1, y2 - BORDERSIZE_Y + 1, x2, y2);
        RectFill(rp, x2 - BORDERSIZE_X + 1, y1 + BORDERSIZE_Y, x2, y2 - BORDERSIZE_Y);

        /* Inner Frame */

        x1 += BORDERSIZE_X;
        x2 -= BORDERSIZE_X;
        y1 += BORDERSIZE_Y;
        y2 = y1 + LEVEL_HEIGHT + INNERFRAME_H - 1;

        Move(rp, x1, y1);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1, y1 + 1);

        Move(rp, x2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2, y1 + 2);
        Draw(rp, x2, y1 + 1);

        Move(rp, x1, y2);
        Draw(rp, x1 + 2, y2);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y2 - 1);

        Move(rp, x2, y2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2, y2 - 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x1 + 2, y2 - 1);
        Draw(rp, x1, y2 - 3);
        Draw(rp, x1, y1 + 3);
        Draw(rp, x1 + 3, y1);
        Draw(rp, x2 - 3, y1);
        Draw(rp, x2 - 1, y1 + 2);

        SetAPen(rp, _pens(obj)[MPEN_SHINE]);
        Move(rp, x2, y1 + 3);
        Draw(rp, x2, y2 - 3);
        Draw(rp, x2 - 3, y2);
        Draw(rp, x1 + 3, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        Move(rp, x1 + 3, y1 + 1);
        Draw(rp, x2 - 3, y1 + 1);
        Move(rp, x1 + 1, y1 + 3);
        Draw(rp, x1 + 1, y2 - 3);
        Move(rp, x1 + 3, y2 - 1);
        Draw(rp, x2 - 3, y2 - 1);
        Move(rp, x2 - 1, y1 + 3),
             Draw(rp, x2 - 1, y2 - 3);

        /* Levelmeter bg */

        x1 += INNERFRAME_X;
        x2 -= INNERFRAME_X;
        y1 += INNERFRAME_Y;
        y2 -= INNERFRAME_Y;

        SetAPen(rp, data->levelbgpen);
        RectFill(rp, x1 + 1, y1, x2 - 1, y1);
        RectFill(rp, x1, y1 + 1, x2, y2 - 1);
        RectFill(rp, x1 + 1, y2, x2 - 1, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        WritePixel(rp, x1, y1);
        WritePixel(rp, x2, y1);
        WritePixel(rp, x1, y2);
        WritePixel(rp, x2, y2);

        /* Levelmeter scale */

        DrawScale(rp, x1, y1, x2, y2, _pens(obj)[MPEN_SHINE]);

        /* Level-Label spacing */

        x1 -= INNERFRAME_X;
        x2 += INNERFRAME_X;
        y1 = y2 + INNERFRAME_Y + 1;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        RectFill(rp, x1, y1, x2, y1 + LEVEL_LABEL_SPACING - 1);

        /* Label Frame */

        y1 += LEVEL_LABEL_SPACING;
        y2 = _mbottom(obj) - OUTERFRAME_Y - BORDERSIZE_Y;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        Move(rp, x1, y1);
        Draw(rp, x1 + 1, y1);
        Draw(rp, x1, y1 + 1);
        Move(rp, x2, y1);
        Draw(rp, x2 - 1, y1);
        Draw(rp, x2, y1 + 1);
        Move(rp, x1, y2);
        Draw(rp, x1 + 1, y2);
        Draw(rp, x1, y2 - 1);
        Move(rp, x2, y2);
        Draw(rp, x2 - 1, y2);
        Draw(rp, x2, y2 - 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x1 + 1, y2 - 1);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2 - 1, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_SHINE]);
        Move(rp, x2, y1 + 2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x1 + 2, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        RectFill(rp, x1 + 1, y1 + 2, x1 + 1, y2 - 2);
        RectFill(rp, x2 - 1, y1 + 2, x2 - 1, y2 - 2);
        RectFill(rp, x1 + 2, y1 + 1, x2 - 2, y1 + 1);
        RectFill(rp, x1 + 2, y2 - 1, x2 - 2, y2 - 1);

        /* Label Bg */

        RectFill(rp, x1 + 2, y1 +2, x2 - 2, y2 - 2);

    }

    x1 = _mleft(obj) + OUTERFRAME_X + BORDERSIZE_X + INNERFRAME_X;
    x2 = _mright(obj) - OUTERFRAME_X - BORDERSIZE_X - INNERFRAME_X;
    y1 = _mtop(obj) + OUTERFRAME_Y + BORDERSIZE_Y + INNERFRAME_Y;
    y2 = y1 + LEVEL_HEIGHT - 1;

    if (msg->flags & MADF_DRAWUPDATE)
    {
        DrawNeedle(rp, x1, y1, x2, y2, data->prevangle, data->levelbgpen);
    }

    data->prevangle = (double)DoMethod(obj, MUIM_Numeric_ValueToScale, 0, 180);

    DrawNeedle(rp, x1, y1, x2, y2, data->prevangle, _pens(obj)[MPEN_SHINE]);

    return TRUE;
}
Example #9
0
/**************************************************************************
   Render tab bar
**************************************************************************/
static void RenderRegisterTab(struct IClass *cl, Object *obj, ULONG flags)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD tabx;

    /*
     * Erase / prepare for drawing
     */
    if (flags & MADF_DRAWOBJECT)
    {
        DoMethod(obj, MUIM_DrawParentBackground, data->left, data->top,
                 data->framewidth, data->tab_height - 1, data->left, data->top, 0);
    }
    else
    {
        /* draw parent bg over oldactive */
        IPTR method;
        WORD old_left, old_top, old_width, old_height;
        struct RegisterTabItem *ri = &data->items[data->oldactive];
        if (data->oldactive >= data->columns) method = MUIM_DrawBackground;
        else method = MUIM_DrawParentBackground;

        old_left = _left(obj) + ri->x1 - 2;
        old_top = _top(obj) + ri->y1;
        old_width = ri->x2 - ri->x1 + 5;
        old_height = data->tab_height - 1;
        DoMethod(obj, method, old_left, old_top,
                 old_width, old_height, old_left, old_top, 0);
        SetDrMd(_rp(obj), JAM1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        RectFill(_rp(obj), old_left, old_top + old_height, old_left + old_width, old_top + old_height);
    }

    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    SetFont(_rp(obj), _font(obj));
    SetSoftStyle(_rp(obj), FS_NORMAL, AskSoftStyle(_rp(obj)));


    /*
     * Draw new graphics
     */
    /* register frame */
    if (flags & MADF_DRAWOBJECT || (data->active / data->columns != data->oldactive / data->columns))
    {
        int i,y,tabs_on_bottom = 0;

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);

        RectFill(_rp(obj), data->left,
                 data->top + data->tab_height - 1,
                 data->left,
                 data->top + data->tab_height + data->frameheight - 1);

        y = data->top + data->tab_height - 1;

        for (i=0; i<data->rows; i++)
        {
            if (!tabs_on_bottom && (i > data->active/data->columns))
            {
                y = _bottom(obj) - muiAreaData(obj)->mad_InnerBottom + data->tab_height;
                tabs_on_bottom = 1;
            }

            RectFill(_rp(obj), data->left + 1, y, data->left + data->framewidth - 2, y);
            y += data->tab_height;
        }

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);

        RectFill(_rp(obj), data->left + data->framewidth - 1,
                 data->top + data->tab_height - 1,
                 data->left + data->framewidth - 1,
                 data->top + data->tab_height + data->frameheight - 1);

        RectFill(_rp(obj), data->left + 1,
                 data->top + data->tab_height + data->frameheight - 1,
                 data->left + data->framewidth - 2,
                 data->top + data->tab_height + data->frameheight - 1);
        for(i = 0, tabx = 0; i < data->numitems; i++)
        {
            RenderRegisterTabItem(cl, obj, i);
        }
    }
    else
    {
        /* If active register has been changed and is on same row we simply draw both registers only */
        RenderRegisterTabItem(cl, obj, data->active);
        RenderRegisterTabItem(cl, obj, data->oldactive);
    }

}
Example #10
0
/**************************************************************************
   Render one item
**************************************************************************/
static void RenderRegisterTabItem(struct IClass *cl, Object *obj,  WORD item)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    struct RegisterTabItem *ri = &data->items[item];
    struct TextExtent extent;
    WORD fitlen;  /* text len fitting in alloted space */
    WORD fitpix;  /* text pixels fitting in alloted space */
    WORD x, y;
    WORD top_item_bar_y;
    WORD bottom_item_bar_y;
    WORD left_item_bar_x;
    WORD right_item_bar_x;
    WORD item_bar_width;
    WORD text_y;
    WORD item_bg_height;
    WORD fitwidth;

    if ((item < 0) || (item >= data->numitems)) return;

    y = data->top + ri->y1;

    if (data->active == item)
    {
        top_item_bar_y = _top(obj) + ri->y1;
        bottom_item_bar_y = _top(obj) + ri->y2 - 2;
        left_item_bar_x = _left(obj) + ri->x1 - 1;
        right_item_bar_x = _left(obj) + ri->x2 + 1;
        item_bg_height = data->tab_height;
        text_y = y + data->ty;
        item_bar_width = right_item_bar_x - left_item_bar_x + 1;
        /* fill tab with register background */
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x, top_item_bar_y + 4,
                 item_bar_width, item_bg_height - 4,
                 left_item_bar_x, top_item_bar_y + 4, 0);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x + 2, top_item_bar_y + 2,
                 item_bar_width - (2 * 2), 2,
                 left_item_bar_x + 2, top_item_bar_y + 2, 0);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x + 4, top_item_bar_y + 1,
                 item_bar_width - (2 * 4), 1,
                 left_item_bar_x + 4, top_item_bar_y + 1, 0);
    }
    else
    {
        top_item_bar_y = _top(obj) + ri->y1 + 2;
        bottom_item_bar_y = _top(obj) + ri->y2 - 1;
        left_item_bar_x = _left(obj) + ri->x1;
        right_item_bar_x = _left(obj) + ri->x2;
        item_bg_height = data->tab_height - 3;
        text_y = y + data->ty + 1;
        item_bar_width = right_item_bar_x - left_item_bar_x + 1;
        SetAPen(_rp(obj), _pens(obj)[MPEN_BACKGROUND]);
        RectFill(_rp(obj), left_item_bar_x, top_item_bar_y + 4,
                 right_item_bar_x, bottom_item_bar_y);
        RectFill(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 2,
                 right_item_bar_x - 2, top_item_bar_y + 3);
        RectFill(_rp(obj), left_item_bar_x + 4, top_item_bar_y + 1,
                 right_item_bar_x - 4, top_item_bar_y + 1);
    }

    /* top horiz bar */
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    RectFill(_rp(obj), left_item_bar_x + 4, top_item_bar_y, right_item_bar_x - 4, top_item_bar_y);
    /* left vert bar */
    RectFill(_rp(obj), left_item_bar_x, top_item_bar_y + 4, left_item_bar_x, bottom_item_bar_y);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 1);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y + 1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_HALFSHINE]);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y);
    WritePixel(_rp(obj), left_item_bar_x + 4, top_item_bar_y + 1);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 4);

    if (data->active == item)
    {
        /* bottom horiz bar */
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        WritePixel(_rp(obj), left_item_bar_x - 1, bottom_item_bar_y + 1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);
        WritePixel(_rp(obj), right_item_bar_x + 1, bottom_item_bar_y + 1);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x - 1, bottom_item_bar_y + 2,
                 item_bar_width + (2 * 1), 1,
                 left_item_bar_x - 1, bottom_item_bar_y + 2, 0);

    }
    /* right vert bar */
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);
    WritePixel(_rp(obj), right_item_bar_x - 1, top_item_bar_y + 2);
    RectFill(_rp(obj), right_item_bar_x, top_item_bar_y + 4, right_item_bar_x, bottom_item_bar_y);
    SetAPen(_rp(obj), _pens(obj)[MPEN_HALFSHADOW]);
    WritePixel(_rp(obj), right_item_bar_x - 2, top_item_bar_y + 1);
    WritePixel(_rp(obj), right_item_bar_x - 1, top_item_bar_y + 3);
    WritePixel(_rp(obj), right_item_bar_x, top_item_bar_y + 3);
    SetAPen(_rp(obj), _pens(obj)[MPEN_BACKGROUND]);
    WritePixel(_rp(obj), right_item_bar_x - 3, top_item_bar_y + 1);

    /* text */
    fitwidth = item_bar_width - TEXTSPACING;
    fitlen = TextFit(_rp(obj), ri->text, ri->textlen, &extent, NULL, 1, fitwidth, data->tab_height);
    fitpix = extent.te_Width;
    /*      D(bug("extent for %s (len=%d) in %d pix = %d chars, %d pix [%x,%x,%x]\n", */
    /*  	  ri->text, ri->textlen, fitwidth, fitlen, fitpix, _rp(obj), _rp(obj)->Font, _font(obj))); */
    x = left_item_bar_x + (item_bar_width - fitpix) / 2;
    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_TEXT]);
    Move(_rp(obj), x, text_y);
    Text(_rp(obj), ri->text, fitlen);
}
Example #11
0
IPTR Colorfield__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg)
{
    struct Colorfield_DATA   *data;
    const struct TagItem   	*tags;
    struct TagItem  	    	*tag;
    ULONG   	    	    	*rgb;
    BOOL    	    	    	 newcol = FALSE;
    IPTR    	    	    	 retval;
    
    data = INST_DATA(cl, obj);

    for (tags = msg->ops_AttrList; (tag = NextTagItem(&tags)); )
    {
	switch (tag->ti_Tag)
	{
	    case MUIA_Colorfield_Red:
	    	data->rgb[0] = (ULONG)tag->ti_Data;
		newcol = TRUE;
		break;
		
	    case MUIA_Colorfield_Green:
	    	data->rgb[1] = (ULONG)tag->ti_Data;
		newcol = TRUE;
		break;
		
	    case MUIA_Colorfield_Blue:
	    	data->rgb[2] = (ULONG)tag->ti_Data;
		newcol = TRUE;
		break;
		
	    case MUIA_Colorfield_RGB:
	    	rgb = (ULONG *)tag->ti_Data;
		data->rgb[0] = *rgb++;
		data->rgb[1] = *rgb++;
		data->rgb[2] = *rgb++;
		newcol = TRUE;
		break;
		
	    case MUIA_Colorfield_Pen:
	    	if (data->flags & FLAG_PEN_ALLOCATED)
		{
		    ReleasePen(_screen(obj)->ViewPort.ColorMap, data->pen);
		    data->flags &= ~(FLAG_PEN_ALLOCATED | FLAG_NO_PEN);
		}
		data->pen = (UBYTE)data->pen;
		data->flags |= FLAG_FIXED_PEN;
		break;
		
    	}
    }

    retval = DoSuperMethodA(cl, obj, (Msg)msg);
    
    if (newcol && (_flags(obj) & MADF_SETUP) && !(data->flags & FLAG_NO_PEN))
    {
    	SetRGB32(&_screen(obj)->ViewPort, data->pen, data->rgb[0], data->rgb[1], data->rgb[2]);
	
	if (GetBitMapAttr(_rp(obj)->BitMap, BMA_DEPTH) > 8)
	{
	    MUI_Redraw(obj, MADF_DRAWUPDATE);
	}
    }
    
    return retval;
}
Example #12
0
static BOOL MakePopupWin(Object *obj, struct Numericbutton_DATA *data)
{
    const struct ZuneFrameGfx 	*zframe;
    struct RastPort 	    	*rp, *saverp;
    LONG    	    	    	 winx, winy, winw, winh;
    LONG    	    	    	 framew, frameh;
    LONG    	    	    	 min, max;

    zframe = zune_zframe_get_with_state(obj, &muiGlobalInfo(obj)->mgi_Prefs->frames[MUIV_Frame_Slider],
                                        muiGlobalInfo(obj)->mgi_Prefs->frames[MUIV_Frame_Slider].state);

    data->pop_innerx = zframe->ileft;
    data->pop_innery = zframe->itop;

    data->knob_width = data->max_text_width + 4;
    data->knob_height = data->text_height + 2;

    framew = data->pop_innerx + zframe->iright;
    frameh = data->pop_innery + zframe->ibottom;

    longget(obj, MUIA_Numeric_Min, &min);
    longget(obj, MUIA_Numeric_Max, &max);

    winw = max - min + data->knob_width + framew;
    winh = data->knob_height + frameh;

    if (winw > _screen(obj)->Width)
    {
        winw = _screen(obj)->Width;
    }

    if ((winw < data->knob_width + framew) || (winh > _screen(obj)->Height))
    {
        return FALSE;
    }

    data->pop_innerw = winw - framew;
    data->pop_innerh = winh - frameh;

    data->knob_left = DoMethod(obj, MUIM_Numeric_ValueToScale, 0, data->pop_innerw - data->knob_width);

    winx = _window(obj)->LeftEdge + _mleft(obj) -
           data->pop_innerx - 2 -
           data->knob_left;
    winy = _window(obj)->TopEdge + _mtop(obj) - 1-
           data->pop_innery;

    data->popwin = OpenWindowTags(NULL, WA_CustomScreen, (IPTR)_screen(obj),
                                  WA_Left, winx,
                                  WA_Top, winy,
                                  WA_Width, winw,
                                  WA_Height, winh,
                                  WA_AutoAdjust, TRUE,
                                  WA_Borderless, TRUE,
                                  WA_Activate, FALSE,
                                  WA_BackFill, (IPTR)LAYERS_NOBACKFILL,
                                  TAG_DONE);

    if (!data->popwin)
    {
        return FALSE;
    }

    rp = data->popwin->RPort;

    saverp = _rp(obj);
    _rp(obj) = rp;
    zframe->draw(zframe->customframe, muiRenderInfo(obj), 0, 0, winw, winh, 0, 0, winw, winh);

    DrawKnob(obj, data, TRUE);


    _rp(obj) = saverp;

    return TRUE;

}
Example #13
0
static void DrawKnob(Object *obj, struct Numericbutton_DATA *data, BOOL force)
{
    struct RastPort *rp, *saverp;
    LONG    	     x, val, pixeloffset, textlen, pixellen;
    STRPTR  	     text;

    pixeloffset = data->popwin->MouseX - data->pop_innerx - 2 - data->knob_clickoffset_x;

    val = DoMethod(obj, MUIM_Numeric_ScaleToValue, 0,
                   data->pop_innerw - data->knob_width, pixeloffset);

    data->knob_left = data->pop_innerx + pixeloffset;
    data->knob_top = data->pop_innery;
    data->knob_val = val;

    if (!force && (data->knob_left == data->knob_prev_left))
    {
        return;
    }
    data->knob_prev_left = data->knob_left;

    if (data->knob_left < data->pop_innerx)
    {
        data->knob_left = data->pop_innerx;
    }
    else if (data->knob_left > data->pop_innerx + data->pop_innerw - data->knob_width)
    {
        data->knob_left = data->pop_innerx + data->pop_innerw - data->knob_width;
    }

    saverp = _rp(obj);
    _rp(obj) = rp = data->popwin->RPort;

    SetABPenDrMd(rp, _pens(obj)[MPEN_SHINE], 0, JAM1);
    RectFill(rp, data->knob_left, data->knob_top,
             data->knob_left, data->knob_top + data->knob_height - 1);
    RectFill(rp, data->knob_left + 1, data->knob_top,
             data->knob_left + data->knob_width - 1, data->knob_top);
    SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
    RectFill(rp, data->knob_left + data->knob_width - 1, data->knob_top + 1,
             data->knob_left + data->knob_width - 1, data->knob_top + data->knob_height - 1);
    RectFill(rp, data->knob_left + 1, data->knob_top + data->knob_height - 1,
             data->knob_left + data->knob_width - 2, data->knob_top + data->knob_height - 1);

    if (data->knob_bg)
    {
#warning "Ugly hack?"

        struct IBox old_mad_Box = muiAreaData(obj)->mad_Box;

        muiAreaData(obj)->mad_Box.Left   = data->knob_left + 1;
        muiAreaData(obj)->mad_Box.Top    = data->knob_top +  1;
        muiAreaData(obj)->mad_Box.Width  = data->knob_width - 2;
        muiAreaData(obj)->mad_Box.Height = data->knob_height - 2;

        zune_imspec_draw(data->knob_bg, muiRenderInfo(obj),
                         data->knob_left + 1,
                         data->knob_top + 1,
                         data->knob_width - 2,
                         data->knob_height - 2,
                         0,
                         0,
                         0);

        muiAreaData(obj)->mad_Box = old_mad_Box;
    }
    else
    {
        SetAPen(rp, _pens(obj)[MPEN_BACKGROUND]);
        RectFill(rp, data->knob_left + 1, data->knob_top + 1,
                 data->knob_left + data->knob_width - 2,
                 data->knob_top + data->knob_height - 2);
    }

    SetFont(rp, _font(obj));

    text = (STRPTR)DoMethod(obj, MUIM_Numeric_Stringify, val);
    textlen = strlen(text);
    pixellen = TextLength(_rp(obj), text, textlen);

    SetAPen(rp, _pens(obj)[MPEN_TEXT]);
    Move(rp, data->knob_left + 2 + (data->knob_width - 4 - pixellen) / 2,
         data->knob_top + 1 + rp->TxBaseline);
    Text(rp, text, textlen);

    SetAPen(rp, _pens(obj)[MPEN_BACKGROUND]);

    if (data->knob_left - 1 >= data->pop_innerx)
    {
        RectFill(rp, data->pop_innerx, data->pop_innery,
                 data->knob_left - 1, data->pop_innery + data->pop_innerh - 1);
    }

    x = data->knob_left + data->knob_width;
    if (x <= data->pop_innerx + data->pop_innerw - 1)
    {
        RectFill(rp, x, data->pop_innery,
                 data->pop_innerx + data->pop_innerw - 1,
                 data->pop_innery + data->pop_innerh - 1);
    }

    _rp(obj) = saverp;
}