Beispiel #1
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;
}
Beispiel #2
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;
}
Beispiel #3
0
static VOID DrawGhosted(struct TB_Element *tool, struct Toolbar_Data *data, Object *obj, BOOL selected)
{
  switch(data->GhostEffect)
  {
    case GHOST_LIGHT:
    case GHOST_HEAVY:
    {
      DrawButton(tool, data, obj, selected, !data->ToolImages);

      if(data->ToolImages)
      {
        struct RastPort *rport = &data->RP;
        USHORT ditherData[2];

        if(data->GhostEffect == GHOST_LIGHT)
        {
          ditherData[0] = 0x8888;
          ditherData[1] = 0x2222;
        }
        else
        {
          ditherData[0] = 0x5555;
          ditherData[1] = 0xAAAA;
        }

        SetAPen(rport, _pens(obj)[MPEN_SHADOW]);
        SetAfPt(rport, ditherData, 1);
        RectFill(rport, tool->DstX, tool->DstY, tool->DstX+data->ButtonWidth-1, tool->DstY + data->ButtonHeight-1);
        SetAfPt(rport, NULL, 0);
      }
    }
    break;
    case GHOST_SUPERLIGHT:
    {
      DrawButton(tool, data, obj, selected, THREE_D);

      if(data->ToolImages)
      {
        struct RastPort *rport = &data->RP;
        USHORT ditherData[] = {0x5555, 0xAAAA};
        SetAPen(rport, _pens(obj)[MPEN_HALFSHINE]);
        SetAfPt(rport, ditherData, 1);
        RectFill(rport, tool->DstX+2, tool->DstY+2, tool->DstX+data->ButtonWidth-3, tool->DstY+1+data->InnerSpace+data->IconHeight);
        SetAfPt(rport, NULL, 0);
      }
    }
    break;
    case GHOST_BITMAP:
//    case GHOST_DIMMED:
    {
      DrawButton(tool, data, obj, selected, THREE_D);
    }
    break;
  }
}
Beispiel #4
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;
}
Beispiel #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;
}
Beispiel #6
0
ULONG ConvertPen (UWORD color, BOOL highlight, struct InstData *data)
{
  return(color ? (ULONG)(data->colormap ? (ULONG)data->colormap[color-1] : (ULONG)((color <= 8) ? _pens(data->object)[color-1] : color-9)) : (ULONG)(highlight ? (ULONG)data->highlightcolor : (ULONG)data->textcolor));
}
Beispiel #7
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;
}
Beispiel #8
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);
    }

}
Beispiel #9
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);
}
Beispiel #10
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;
}
Beispiel #11
0
static VOID DrawButton(struct TB_Element *tool, struct Toolbar_Data *data, Object *obj, BOOL selected, BOOL three_d)
{
  // This routine depends heavily on selected being either 0 or 1.
  WORD x = tool->DstX, y  = tool->DstY;
  ULONG delta = (data->ButtonWidth - data->IconWidth)/2;
  struct RastPort *rport = &data->RP;
  UBYTE number = tool->Number;
  Object *par;
  ULONG back;

  LONG trans = selected ? data->SelectTrans : data->NormalTrans;
  struct BitMap *bitmap = selected ? data->SelectBM : data->NormalBM;
  PLANEPTR mask =  three_d ? data->GhostMask : ( selected ? data->SelectMask : data->NormalMask );

  // Clear background
  SetAPen(rport, three_d ? data->GhostTrans : trans);
//rf  RectFill(rport,  x+1, y+1, x+data->ButtonWidth-2+selected, y+data->ButtonHeight-2+selected);
  if (data->BorderType == BORDERTYPE_OLD) {
    RectFill(rport,  x+1, y+1, x+data->ButtonWidth-1, y+data->ButtonHeight-1);
  } else if (data->BorderType == BORDERTYPE_OFF) {
    get(obj, MUIA_Parent, (ULONG)&par);
    if (par) {
      get(par, MUIA_Background, &back);
      set(obj, MUIA_Background, back);
    }
    DoMethod(obj, MUIM_DrawBackground, x,   y, data->ButtonWidth, data->ButtonHeight, x, y);
  } else if (data->BorderType == BORDERTYPE_NEW) {
    RectFill(rport,  x+1, y+1, x+data->ButtonWidth-1, y+data->ButtonHeight-1);
  }

  // Borders

  if (data->BorderType == BORDERTYPE_OLD) {
    UpperFrame(rport, x,   y, x+data->ButtonWidth-2, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHADOW]);
    LowerFrame(rport, x+1, y, x+data->ButtonWidth-1, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHADOW]);
  } else  if (data->BorderType == BORDERTYPE_NEW) {
    UpperFrame(rport, x,   y, x+data->ButtonWidth-2, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHINE]);
    LowerFrame(rport, x+1, y, x+data->ButtonWidth-1, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHADOW]);
  }

  if (data->SelectionMode != SELECTIONMODE_OFF) {
    if(selected)
    {
      if (data->SelectionMode == SELECTIONMODE_OLD) {
        UpperFrame(rport, x+1, y+1, x+data->ButtonWidth-2, y+data->ButtonHeight-2, _pens(obj)[MPEN_HALFSHADOW]);
        UpperFrame(rport, x+2, y+2, x+data->ButtonWidth-2, y+data->ButtonHeight-2, _pens(obj)[MPEN_BACKGROUND]);
      } else {
        UpperFrame(rport, x, y, x+data->ButtonWidth-2, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHADOW]);
        LowerFrame(rport, x+1, y, x+data->ButtonWidth-1, y+data->ButtonHeight-1, _pens(obj)[MPEN_SHINE]);
      }
    } else  {
      if (data->BorderType == BORDERTYPE_OLD) {
        UpperFrame(rport, x+1, y+1, x+data->ButtonWidth-3, y+data->ButtonHeight-3, _pens(obj)[MPEN_SHINE]);
        LowerFrame(rport, x+2, y+2, x+data->ButtonWidth-2, y+data->ButtonHeight-2, _pens(obj)[MPEN_HALFSHADOW]);
      }
    }
  } else  {
    if (data->BorderType == BORDERTYPE_OLD) {
      UpperFrame(rport, x+1, y+1, x+data->ButtonWidth-3, y+data->ButtonHeight-3, _pens(obj)[MPEN_SHINE]);
      LowerFrame(rport, x+2, y+2, x+data->ButtonWidth-2, y+data->ButtonHeight-2, _pens(obj)[MPEN_HALFSHADOW]);
    }
  }

  if(data->ToolTexts)
  {
    BOOL parse = tool->ParseUnderscore;
    STRPTR tooltext = data->Desc[number].ToolText;
//    SetFont(rport, data->ToolFont); Flyttet til MUIM_Show
    ULONG width = TextLength(rport, tooltext, strlen(tooltext)) - (parse ? data->UnderscoreSize : 0);

    UWORD horiz_offset = selected + (data->ButtonWidth - width)/2;
    UWORD vert_offset  = selected + data->IconHeight + data->InnerSpace + 3;
    if(three_d)
      Draw3DText(rport, x + horiz_offset, y + vert_offset, tooltext, data->Desc[number].Key, data->HalfShadow, data->HalfShine, parse);
    else
      DrawText(rport, x + horiz_offset, y + vert_offset, tooltext, data->Desc[number].Key, MUIPEN(data->TextPen), parse);
  }

  if(data->ToolImages)
  {
    if(bitmap)
    {
      if(mask && (data->BorderType != BORDERTYPE_OLD))
      {
        MyBltMaskBitMapRastPort((three_d ? data->GhostBM : bitmap), tool->SrcOffset, 0, rport, x+delta+selected, y+data->InnerSpace+2+selected, data->IconWidth, data->IconHeight, 0xc0, mask);
      }
      else
      {
        BltBitMapRastPort((three_d ? data->GhostBM : bitmap), tool->SrcOffset, 0, rport, x+delta+selected, y+data->InnerSpace+2+selected, data->IconWidth, data->IconHeight, 0xc0);
      }
    }
    else
    {
      x += data->ButtonWidth/2 + selected - 3;
      y += data->InnerSpace + data->IconHeight/2 + selected;
      SetAPen(rport, _pens(obj)[MPEN_HALFSHADOW]);
      RectFill(rport, x, y, x+4, y+4);
    }
  }
}