/*** Display cursor of project p ***/ void inv_curs(Project p, BYTE state) { if(p->ccp.select) { /* Just draw a simple vert bart for selection */ WORD y = p->ycurs - BASEL; RectFill(RP,p->xcurs, y, p->xcurs+1, y+YSIZE-1); } else { UBYTE thechar, oldmask = RP->Mask; /* Fully highlight character */ RP->Mask = gui.selmask; if(state) SetABPenDrMd(RP,pen.fgfill,pen.bgfill,JAM2); if(state != 0 && p->cursmode) { /* Draw the replacement cursor */ SetAPen(RP, pen.bgfill); RectFill(RP,p->xcurs, p->ycurs, p->xcurs+XSIZE-1, p->ycurs-BASEL+YSIZE-1); } else { /* Normal cursor */ thechar = (p->nbc < p->edited->size ? p->edited->stream[p->nbc] : ' '); if(thechar == '\t') thechar = ' '; Move(RP,p->xcurs,p->ycurs); Text(RP,&thechar,1); } SetABPenDrMd(RP,pen.fg,pen.bg,JAM2); RP->Mask = oldmask; } }
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; }
/************************************************************************** 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; }
IPTR FillRectClass__IM_DRAW(Class *cl, Object *obj, struct impDraw *msg) { struct FillRectData *data = INST_DATA(cl, obj); struct RastPort rp; WORD x1, y1, x2, y2; if (!((struct impDraw *)msg)->imp_RPort) return 0; memcpy(&rp,((struct impDraw *)msg)->imp_RPort,sizeof (struct RastPort)); SetABPenDrMd(&rp, IM_FGPEN((struct Image *)obj), IM_BGPEN((struct Image *)obj), data->mode); SetAfPt(&rp, (APTR)((struct Image *)obj)->ImageData, data->apatsize); x1 = ((struct Image *)obj)->LeftEdge + ((struct impDraw *)msg)->imp_Offset.X; y1 = ((struct Image *)obj)->TopEdge + ((struct impDraw *)msg)->imp_Offset.Y; if (msg->MethodID == IM_DRAW) { x2 = x1 + ((struct Image *)obj)->Width - 1; y2 = y1 + ((struct Image *)obj)->Height - 1; } else { x2 = x1 + msg->imp_Dimensions.Width - 1; y2 = y1 + msg->imp_Dimensions.Height - 1; } RectFill(&rp, x1, y1, x2, y2); return 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; }
/*** Refresh display, according to new window size ***/ void new_size(UBYTE Flags) { inv_curs(edit, FALSE); adjust_win(Wnd,NbProject>1); /* Adjust internal variables */ SetABPenDrMd(RP, pen.fg, pen.bg, JAM2); clear_brcorner(); prop_adj(edit); edit->left_pos = curs_visible(edit, edit->top_line); edit->xcurs = (edit->nbrc - edit->left_pos)*XSIZE + gui.left; if(Flags & EDIT_GUI) reshape_panel(edit); if(Flags & EDIT_AREA) redraw_content(edit,edit->show,gui.topcurs,gui.nbline); inv_curs(edit,TRUE); }
static void action(void) { int x, y; for(y = 0; y < SCREENHEIGHT; y++) { for(x = 0; x < SCREENWIDTH; x++) { buf[y * SCREENWIDTH + x] = (y + x) & 255; } } SetABPenDrMd(rp, 1, 2, JAM1); BltTemplateAlpha(buf, 0, SCREENWIDTH, rp, win->BorderLeft, win->BorderTop, SCREENWIDTH, SCREENHEIGHT); WaitPort(win->UserPort); }
static void DrawNeedle(struct RastPort *rp, LONG x1, LONG y1, LONG x2, LONG y2, double angle, LONG pen) { LONG cx = (x1 + x2 + 1) / 2; LONG cy = y2 - 1; LONG rx = cx - x1 - 4; LONG ry = cy - y1 - 4; LONG a, b; SetABPenDrMd(rp, pen, 0, JAM1); Move(rp, cx, cy); if ((angle < 0.0) | (angle > 180.0)) angle = 0.0; angle = 180.0 - angle; a = cx + (LONG)(cos(angle * 3.14159265358979323846 / 180.0) * rx); b = cy - (LONG)(sin(angle * 3.14159265358979323846 / 180.0) * ry); Draw(rp, a, b); }
static void DrawScale(struct RastPort *rp, LONG x1, LONG y1, LONG x2, LONG y2, LONG pen) { LONG cx = (x1 + x2 + 1) / 2; LONG cy = y2 - 1; LONG rx = cx - x1 - 1; LONG ry = cy - y1 - 1; LONG a, b, g; SetABPenDrMd(rp, pen, 0, JAM1); for(g = 0; g <= 180; g += 15) { double angle = ((double)g) * 3.14159265358979323846 / 180.0; a = cx + (LONG)(cos(angle) * rx); b = cy - (LONG)(sin(angle) * ry); WritePixel(rp, a, b); if ((g % 45) == 0) { static WORD offtable[][2] = { {-1,0 }, {-1,1 }, {0 ,1 }, { 1,1 }, { 1,0 } }; WritePixel(rp, a + offtable[g / 45][0], b + offtable[g / 45][1]); } } }
/************************************************************************** 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; }
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; }
// Draw an object void backdrop_draw_object( BackdropInfo *info, BackdropObject *object, UWORD flags, struct RastPort *rp, short left, short top) { UBYTE fpen=1,bpen=0,drawmode=JAM2,opus_drawmode=JAM2; UWORD *imagedata=0; struct Image *image=0; struct Rectangle rect; short len; BOOL comp=0,draw=1,state=0; short has_border; // No icon? if (!object->icon) return; // See if icon has no border has_border=backdrop_icon_border(object); // Not just clearing image? if (!(flags&BRENDERF_CLEAR)) { // Get image to render if ((image=(struct Image *)object->icon->do_Gadget.GadgetRender)) imagedata=image->ImageData; // Is icon selected? if (object->state) { // Is there a select image? if (object->icon->do_Gadget.SelectRender && (object->icon->do_Gadget.Flags&GFLG_GADGHIMAGE)) { if ((image=(struct Image *)object->icon->do_Gadget.SelectRender)) imagedata=image->ImageData; state=1; } else comp=1; } } #ifdef USE_DRAWICONSTATE if (GetIconRectangle( rp, object->icon, NULL, &rect, ICONDRAWA_Borderless, TRUE, TAG_DONE)) { object->pos.Width = rect.MaxX - rect.MinX + 1; object->pos.Height = rect.MaxY - rect.MinY + 1; } #elif defined(__MORPHOS__) if (ISOWN(object->icon)) { struct OwnDiskObject *o = (APTR)object->icon; object->pos.Width = o->pngimage_width; object->pos.Height = o->pngimage_height; } #endif // Get object position if (flags&BRENDERF_REAL) { short border_x=0,border_y_top=0,border_y_bottom=0; // Border? if (has_border) { // Use default border border_x=ICON_BORDER_X; border_y_top=ICON_BORDER_Y_TOP; border_y_bottom=ICON_BORDER_Y_BOTTOM; } // Calculate full size object->full_size.MinX=left-border_x; object->full_size.MinY=top-border_y_top; object->full_size.MaxX=left+object->pos.Width+border_x-1; object->full_size.MaxY=top+object->pos.Height+border_y_bottom-1; // Get image rectangle rect.MinX=object->full_size.MinX+(info->size.MinX-info->offset_x); rect.MinY=object->full_size.MinY+(info->size.MinY-info->offset_y); rect.MaxX=object->full_size.MaxX+(info->size.MinX-info->offset_x); rect.MaxY=object->full_size.MaxY+(info->size.MinY-info->offset_y); // Store position object->show_rect=rect; object->image_rect=rect; // Is object offscreen? if (rect.MaxX<info->size.MinX || rect.MaxY<info->size.MinY || rect.MinX>info->size.MaxX || rect.MinY>info->size.MaxY) draw=0; // Offset by coordinates left+=info->size.MinX-info->offset_x; top+=info->size.MinY-info->offset_y; } else { rect.MinX=left; rect.MinY=top; rect.MaxX=left+object->pos.Width-1; rect.MaxY=top+object->pos.Height-1; } // Clear area? if (flags&BRENDERF_CLEAR) { // Ok to draw? if (draw) { // Clear whole icon? if (!(flags&BRENDERF_LABEL)) { EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); } } // Can't draw else flags&=~BRENDERF_CLEAR; } // Object state changed? else if (object->flags&BDOF_STATE_CHANGE) { #ifndef USE_DRAWICONSTATE // Need to clear if transparent #if !defined(__MORPHOS__) if (!has_border) #endif EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); #endif object->flags&=~BDOF_STATE_CHANGE; } // Draw as normal if (!(flags&BRENDERF_CLEAR)) { // Not drawing if no image if (!imagedata) draw=0; // Ok to draw? if (draw) { struct BitMap bitmap; BOOL use_mask=0; // Full icon? if (flags&BRENDERF_REAL) { // Want border? if (has_border) { // Draw border around icon DrawBox(rp,&rect,GUI->draw_info,object->state); // Get background colour #ifdef USE_64BIT SetAPen( rp, (object->flags&BDOF_BACKGROUND)? object->pen: GUI->draw_info->dri_Pens[BACKGROUNDPEN]); #else SetAPen( rp, (object->flags&BDOF_BACKGROUND)? object->size: GUI->draw_info->dri_Pens[BACKGROUNDPEN]); #endif // Clear boundary around image #ifdef USE_DRAWICONSTATE RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MaxX-1,rect.MaxY-1); #else RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MaxX-1,rect.MinY+2); RectFill(rp,rect.MinX+1,rect.MinY+1,rect.MinX+3,rect.MaxY-1); RectFill(rp,rect.MinX+4,rect.MaxY-3,rect.MaxX-1,rect.MaxY-1); RectFill(rp,rect.MaxX-3,rect.MinY+3,rect.MaxX-1,rect.MaxY-4); #endif } #ifdef USE_DRAWICONSTATE else { EraseRect(rp,rect.MinX,rect.MinY,rect.MaxX,rect.MaxY); } #endif } #ifdef USE_DRAWICONSTATE DrawIconState( rp, object->icon, NULL, left, top, object->state ? IDS_SELECTED : IDS_NORMAL, ICONDRAWA_Frameless, TRUE, ICONDRAWA_Borderless, TRUE, ICONDRAWA_EraseBackground, FALSE, TAG_DONE); #else #if defined(__MORPHOS__) if (ISOWN(object->icon)) { IPTR tags[] = { BLTBMA_USESOURCEALPHA, TRUE, TAG_DONE }; struct OwnDiskObject *o = (APTR)object->icon; BltBitMapRastPortAlpha(o->pngimage, 0, 0, rp, left, top, o->pngimage_width, o->pngimage_height, (struct TagItem *)&tags); if (object->state) { ProcessPixelArray(rp, left, top, o->pngimage_width, o->pngimage_height, POP_TINT, 0x5082ff, NULL); } } else { #endif // Get image as a bitmap backdrop_image_bitmap(info,image,imagedata,&bitmap); // Using a mask (no border)? if (!has_border && object->image_mask[state]) { // Draw using a mask BltMaskBitMapRastPort( &bitmap,0,0, rp,left,top, image->Width,image->Height, 0xe0, (PLANEPTR)object->image_mask[state]); use_mask=1; } // Draw normally else { // Draw image BltBitMapRastPort( &bitmap,0,0, rp,left,top, image->Width,image->Height, 0xc0); } // Complement? if (comp) { DragInfo *drag_info; UBYTE mask; // Only complement to image depth mask=rp->Mask; SetWrMsk(rp,image->PlanePick); // Need backfill? if ((object->icon->do_Gadget.Flags&GFLG_GADGBACKFILL) && (drag_info=GetDragInfo(info->window,0,-object->pos.Width,-object->pos.Height,0))) { // Draw icon into drag buffer BltBitMapRastPort( &bitmap,0,0, &drag_info->drag_rp,0,0, image->Width,image->Height, 0xc0); // Build mask GetDragMask(drag_info); // Complement area with mask BltMaskBitMapRastPort( &drag_info->drag_bm, 0,0, rp, left,top, image->Width, image->Height, 0x20, (PLANEPTR)drag_info->bob.ImageShadow); // Free temporary drag info FreeDragInfo(drag_info); } // Just complement image else { ClipBlit( rp, left,top, rp, left,top, image->Width, image->Height, 0x50); } // Restore mask SetWrMsk(rp,mask); } #if defined(__MORPHOS__) } #endif #endif // Left out (on desktop), or a link? if (!(environment->env->desktop_flags&DESKTOPF_NO_ARROW) && ((object->type==BDO_LEFT_OUT && !(object->flags&BDOF_DESKTOP_FOLDER) && info->flags&BDIF_MAIN_DESKTOP) || object->flags&BDOF_LINK_ICON)) { struct Image *image; // Get correct image for this resolution image=(GUI->screen_info&SCRI_LORES)?&arrow_image[1]:&arrow_image[0]; // Is object big enough for the 'shortcut arrow'? if (object->pos.Width>(image->Width<<1) && object->pos.Height>image->Height+4) { // Draw arrow in bottom-left corner DrawImage(rp,image,rect.MinX,rect.MaxY-image->Height+1); } } // Ghosted icon? if (object->flags&BDOF_GHOSTED) { // Draw ghosting over the icon backdrop_draw_icon_ghost(rp,&rect,(use_mask)?(PLANEPTR)object->image_mask[state]:0); } } // Get pens from configuration fpen=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_fpen:environment->env->iconw_fpen; bpen=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_bpen:environment->env->iconw_bpen; drawmode=(info->flags&BDIF_MAIN_DESKTOP)?environment->env->icon_style:environment->env->iconw_style; opus_drawmode=drawmode; // Shadow/Outline? if (drawmode==MODE_SHADOW || drawmode==MODE_OUTLINE) { UBYTE temp; // Set back to JAM1 drawmode=JAM1; // Swap the pens temp=fpen; fpen=bpen; bpen=temp; } // Fix pens for user colours if (fpen>=4 && fpen<252) fpen=GUI->pens[fpen-4]; if (bpen>=4 && bpen<252) bpen=GUI->pens[bpen-4]; // Use fast call under 39 if(((struct Library *)GfxBase)->lib_Version>=39) { SetABPenDrMd(rp,fpen,bpen,drawmode); } else { SetAPen(rp,fpen); SetBPen(rp,bpen); SetDrMd(rp,drawmode); } } // Full icon? if (flags&BRENDERF_REAL && !(object->flags&BDOF_NO_LABEL)) { char *name,namebuf[40]; // Bad disk? if (object->type==BDO_BAD_DISK) { // Get bad disk name backdrop_bad_disk_name(object,namebuf); name=namebuf; } // Custom label? else if (object->flags&BDOF_CUSTOM_LABEL) name=object->device_name; // Get name pointer else name=object->name; // Get text length if ((len=strlen(name))) { struct TextExtent extent; short max_width=0,loop,textx,texty; // Splitting long labels? if (environment->env->desktop_flags&DESKTOPF_SPLIT_LABELS) { // Calculate maximum text width (minimum 6 chars) max_width=RECTWIDTH(&rect)+(RECTWIDTH(&rect)>>1); if (max_width<rp->Font->tf_XSize*6) max_width=rp->Font->tf_XSize*6; } // Position for text textx=rect.MinX+(RECTWIDTH(&rect)>>1); texty=rect.MaxY+ICON_LABEL_SPACE+rp->TxBaseline+((opus_drawmode==MODE_OUTLINE)?1:0); Move(rp,textx,texty); // Get text pixel size TextMultiLine(rp,name,len,max_width,TMLF_CENTER|TMLF_EXTENT,&extent); // Fix extent for shadow/outline if (opus_drawmode==MODE_SHADOW) { extent.te_Extent.MaxX++; extent.te_Width++; extent.te_Height++; } else if (opus_drawmode==MODE_OUTLINE) { extent.te_Extent.MinX--; extent.te_Extent.MaxX++; extent.te_Width+=2; extent.te_Height+=2; } // Stretch out rectangle sides if necessary if (extent.te_Extent.MinX<rect.MinX) object->full_size.MinX-=rect.MinX-extent.te_Extent.MinX; if (extent.te_Extent.MaxX>rect.MaxX) object->full_size.MaxX+=extent.te_Extent.MaxX-rect.MaxX; if (object->show_rect.MinX>extent.te_Extent.MinX) object->show_rect.MinX=extent.te_Extent.MinX; if (object->show_rect.MaxX<extent.te_Extent.MinX+extent.te_Width-1) object->show_rect.MaxX=extent.te_Extent.MinX+extent.te_Width-1; // Save bottom of text object->show_rect.MaxY+=ICON_LABEL_SPACE+extent.te_Height; // +((opus_drawmode==MODE_OUTLINE)?1:0); object->full_size.MaxY+=ICON_LABEL_SPACE+extent.te_Height; // +((opus_drawmode==MODE_OUTLINE)?1:0); // Clear? if (flags&BRENDERF_CLEAR) { EraseRect(rp, extent.te_Extent.MinX,rect.MaxY+ICON_LABEL_SPACE+((opus_drawmode==MODE_OUTLINE)?1:0), extent.te_Extent.MinX+extent.te_Width-1,rect.MaxY+ICON_LABEL_SPACE+extent.te_Height-1); } // Draw text else { // Is object selected? if (object->flags&BDOF_SELECTED) { if (drawmode==JAM2) SetDrMd(rp,INVERSVID|JAM2); else if (fpen!=GUI->draw_info->dri_Pens[HIGHLIGHTTEXTPEN]) SetAPen(rp,GUI->draw_info->dri_Pens[HIGHLIGHTTEXTPEN]); else SetAPen(rp,GUI->draw_info->dri_Pens[BACKGROUNDPEN]); } // Shadow if (opus_drawmode==MODE_SHADOW) { // Draw shadow text first Move(rp,textx+1,texty+1); TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); // Draw text SetAPen(rp,bpen); Move(rp,textx,texty); TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); } // Normal text else if (opus_drawmode!=MODE_OUTLINE) { // Render text TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); } // Outline else { Move(rp,textx+1,texty+1); for (loop=0;loop<5;loop++) { // Render text TextMultiLine(rp,name,len,max_width,TMLF_CENTER,0); // Doing shadow? if (loop<4) { short s_x=0,s_y=0; // Switch to other pen? if (loop==3) SetAPen(rp,bpen); // Get the new offsets else if (loop==0) { s_x=-1; s_y=1; } else if (loop==1) { s_x=-1; s_y=-1; } else if (loop==2) { s_x=1; s_y=-1; } // Position for text Move(rp,textx+s_x,texty+s_y); } } } // Reset draw mode if necessary if (object->flags&BDOF_SELECTED) SetDrMd(rp,drawmode); } }
IPTR GTText__GM_RENDER(Class *cl, struct Gadget *g, struct gpRender *msg) { UWORD *pens = msg->gpr_GInfo->gi_DrInfo->dri_Pens; UBYTE textbuf[256], *str; struct TextData *data = INST_DATA(cl, g); WORD left, left2, top, width, height, numchars, tlength; struct TextFont *oldfont; struct RastPort *rp = msg->gpr_RPort; EnterFunc(bug("Text::Render()\n")); left = g->LeftEdge; top = g->TopEdge; width = g->Width; height = g->Height; if (msg->gpr_Redraw == GREDRAW_REDRAW) { if (data->frame) { DrawImageState(msg->gpr_RPort, (struct Image *)data->frame, left, top, IDS_NORMAL, msg->gpr_GInfo->gi_DrInfo); } renderlabel(GadToolsBase, g, msg->gpr_RPort, data->labelplace); } if (data->toprint || (data->gadgetkind != TEXT_KIND)) { /* preserve font */ oldfont = rp->Font; SetFont(rp, data->font); str = textbuf; if (data->gadgetkind == TEXT_KIND) { strncpy(str, (char *)data->toprint, sizeof(textbuf)); textbuf[sizeof(textbuf) - 1] = '\0'; } else /* NUMERIC_KIND or label of SLIDER_KIND */ { RawDoFmt(data->format, &(data->toprint), (VOID_FUNC)AROS_ASMSYMNAME(puttostr), &str); } D(bug("Text formatted into: %s\n", textbuf)); numchars = strlen(textbuf); if (data->flags & TEXTF_BORDER) { left += VBORDER + 1; top += HBORDER + 1; width = g->Width - (VBORDER + 1) * 2; height = g->Height - (HBORDER + 1) * 2; } if (data->flags & TEXTF_CLIPPED) { struct TextExtent te; /* See how many chars fits into the display area */ numchars = TextFit(rp, textbuf, numchars, &te, NULL, 1, width, g->Height); } tlength = TextLength(rp, textbuf, numchars); left2 = left; switch (data->justification) { case GTJ_LEFT: break; case GTJ_RIGHT: left2 += (width - tlength); break; case GTJ_CENTER: left2 += ((width - tlength) / 2); break; } /* Render text */ D(bug("Rendering text of lenghth %d at (%d, %d)\n", numchars, left, top)); SetABPenDrMd(rp, pens[data->backpen], pens[data->backpen], JAM2); RectFill(rp, left, top, left + width - 1, top + height - 1); SetAPen(rp, pens[data->frontpen]); Move(rp, left2, top + ((height - data->font->tf_YSize) / 2) + data->font->tf_Baseline); Text(rp, textbuf, numchars); SetFont(rp, oldfont); } /* if (data->toprint || (data->gadgetkind != TEXT_KIND)) */ ReturnInt("Text::Render", IPTR, 0); }