示例#1
0
void gui_window_stop_throbber(struct gui_window *g)
{
	struct IBox *bbox;
	ULONG cur_tab = 0;

	if(!g) return;
	if(nsoption_bool(kiosk_mode)) return;

	if(g->tab_node && (g->shared->tabs > 1))
	{
		GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS],
			(ULONG *)&cur_tab);
		SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, FALSE, TAG_DONE);
		RefreshGadgets((APTR)g->shared->objects[GID_TABS],
			g->shared->win, NULL);
	}

	g->throbbing = false;

	if((cur_tab == g->tab) || (g->shared->tabs <= 1))
	{
		GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER],
				(ULONG *)&bbox);

		BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left,
			bbox->Top, throbber_width, throbber_height, 0x0C0);
	}
//	g->shared->throbber_frame = 0;
}
示例#2
0
VOID BltMaskRPort (struct BitMap *source, WORD srcLeft,WORD srcTop, struct RastPort *destination, WORD dstLeft,WORD dstTop,WORD dstWidth,WORD dstHeight, PLANEPTR maskPlane)
{
  if(GetBitMapAttr(source, BMA_FLAGS) & BMF_INTERLEAVED)
  {
    struct BitMap mask;

    InitBitMap(&mask, 8, GetBitMapAttr(source, BMA_WIDTH), GetBitMapAttr(source, BMA_HEIGHT));

    for(UWORD i = 0; i < 8; i++)
       mask.Planes[i] = maskPlane;

    BltBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_EQUALS_C);
    BltBitMapRastPort(&mask, srcLeft,srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_OR_C);
    BltBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_EQUALS_C);
  }
  else
  {
    BltMaskBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, (ABC | ABNC | ANBC), maskPlane);
  }
}
示例#3
0
VOID LIClass::Render (struct RenderMessage &rmsg)
{
  if(Flags & FLG_Layouted)
  {
    if(!rmsg.TargetObj)
    {
      struct RastPort *rp = rmsg.RPort;
      if(Number)
      {
        char str[64];
        NumToStr(str, rmsg.OL_Type);
        struct TextFont *font = rmsg.Share->Fonts[Font_Normal];
        ULONG len = strlen(str);
        ULONG x = Left - MyTextLength(font, str, len) - rmsg.OffsetX;
        SetAPen(rp, rmsg.Colours[Col_Text]);
        SetFont(rp, font);
        Move(rp, x, Baseline - rmsg.OffsetY);
        Text(rp, str, len);
      }
      else
      {
        if(rmsg.Share->LI_BMp)
        {
          LONG x, y, width = rmsg.Share->LI_Width, height = rmsg.Share->LI_Height;
          x = Left - width - rmsg.OffsetX;
          y = Baseline - rmsg.OffsetY - height + 1;

          ULONG index = 0;
          if(rmsg.UL_Nesting > 1)
            index = width * min(rmsg.UL_Nesting-1, 2);

          if(rmsg.Share->LI_Mask)
              BltMaskRPort(rmsg.Share->LI_BMp, index, 0, rp, x, y, width, height, rmsg.Share->LI_Mask);
          else  BltBitMapRastPort(rmsg.Share->LI_BMp, index, 0, rp, x, y, width, height, 0x0c0);
        }
      }
    }
    TreeClass::Render(rmsg);
  }
}
void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);

	glob = &hw->gg;
	ami_clg(0xffffff);

	history_redraw_rectangle(history_current, xs, ys,
		bbox->Width + xs, bbox->Height + ys, 0, 0);

	glob = &browserglob;

	ami_clearclipreg(&hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg.bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);
}
示例#5
0
/* render a standard requester */
void render_requester(struct Requester *requester, struct IntuitionBase *IntuitionBase)
{
    struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
    struct RastPort *rp = requester->ReqLayer->rp;

    if ((requester->Flags & NOREQBACKFILL) == 0)
        SetRast(rp, requester->BackFill);

    if (requester->ImageBMap && requester->Flags & PREDRAWN)
        BltBitMapRastPort(requester->ImageBMap, 0, 0,
                          rp, 0, 0, requester->Width, requester->Height, 0xc0);

    if (requester->ReqImage && requester->Flags & USEREQIMAGE)
        DrawImage(rp, requester->ReqImage, 0, 0);

    if (requester->ReqBorder)
        DrawBorder(rp, requester->ReqBorder, 0, 0);

    if (requester->ReqGadget)
        RefreshGList(requester->ReqGadget, requester->RWindow, requester, -1);

    if (requester->ReqText)
        PrintIText(rp, requester->ReqText, 0, 0);
}
示例#6
0
void shutdownwnd_open(void)
{
	if ((scr = LockPubScreen(NULL)))
	{
		char *filename;

		/* get a white pen for the color of our text */
		pen = ObtainBestPenA(scr->ViewPort.ColorMap,0xffffffff,0xffffffff,0xffffffff,NULL);

		if ((filename = mycombinepath(gui_get_images_directory(),"shutdown")))
		{
			if ((obj = LoadAndMapPicture("PROGDIR:Images/shutdown",scr)))
			{
				struct BitMapHeader *bmhd = NULL;
				struct BitMap *bitmap = NULL;

				GetDTAttrs(obj,PDTA_BitMapHeader,&bmhd,TAG_DONE);
				GetDTAttrs(obj,PDTA_DestBitMap,&bitmap,TAG_DONE);
				if (!bitmap) GetDTAttrs(obj,PDTA_BitMap,&bitmap,TAG_DONE);

				if (bmhd && bitmap)
				{
					int width = bmhd->bmh_Width;
					int height = bmhd->bmh_Height;

					int wndleft,wndtop;

					wndleft = (scr->Width - width)/2;
					wndtop = (scr->Height - height)/2;

					if ((shutdown_wnd = OpenWindowTags(NULL,
						WA_SmartRefresh, TRUE,
						WA_NoCareRefresh, TRUE,
						WA_Borderless, TRUE,
						WA_Width, width,
						WA_Height, height,
						WA_PubScreen, scr,
						WA_Left, wndleft,
						WA_Top, wndtop,
						WA_BackFill, LAYERS_NOBACKFILL,
						TAG_DONE)))
					{
						BltBitMapRastPort(bitmap,0,0,
										  shutdown_wnd->RPort, 0, 0, width, height,
										  0xc0);

						if (!user.config.dont_show_shutdown_text)
						{
							struct TextExtent te;
							const char *txt = _("Shutting down...");

							SetDrMd(shutdown_wnd->RPort,JAM1);
							SetAPen(shutdown_wnd->RPort,pen);
							TextExtent(shutdown_wnd->RPort,txt,strlen(txt),&te);
							if ((te.te_Width < width) && (te.te_Height < height))
							{
								/* only draw the text if there is enought space for it */
								Move(shutdown_wnd->RPort,(width - te.te_Width)/2, height - te.te_Height - 4 + shutdown_wnd->RPort->TxBaseline);
								Text(shutdown_wnd->RPort,txt,strlen(txt));
							}
						}
					}
				}
			}
			free(filename);
		}
	}
}
示例#7
0
static void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &amiplot
	};

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	if(ami_gui_get_space_box(hw->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
		amiga_warn_user("NoMemory", "");
		return;
	}

	glob = hw->gg;

	SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
	RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);

	browser_window_history_redraw_rectangle(hw->gw->bw, xs, ys,
			bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);

	ami_gui_set_default_gg();

	ami_clearclipreg(hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg->bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);

	ami_gui_free_space_box(bbox);
}


/* exported interface documented in amiga/history_local.h */
void ami_history_open(struct gui_window *gw)
{
	struct history *history;
	int width, height;

	if (gw->bw == NULL)
		return;

	history = browser_window_get_history(gw->bw);
	if (history == NULL)
		return;

	if(!gw->hw)
	{
		gw->hw = ami_misc_allocvec_clear(sizeof(struct history_window), 0);
		gw->hw->gg = ami_misc_allocvec_clear(sizeof(struct gui_globals), 0);

		ami_init_layers(gw->hw->gg, scrn->Width, scrn->Height, false);

		gw->hw->gw = gw;
		browser_window_history_size(gw->bw, &width, &height);

		gw->hw->scrollerhook.h_Entry = (void *)ami_history_scroller_hook;
		gw->hw->scrollerhook.h_Data = gw->hw;

		gw->hw->objects[OID_MAIN] = WindowObj,
			WA_ScreenTitle, ami_gui_get_screen_title(),
			WA_Title, messages_get("History"),
			WA_Activate, TRUE,
			WA_DepthGadget, TRUE,
			WA_DragBar, TRUE,
			WA_CloseGadget, TRUE,
			WA_SizeGadget, TRUE,
			WA_PubScreen,scrn,
			WA_InnerWidth,width,
			WA_InnerHeight,height + 10,
			WINDOW_SharedPort,sport,
			WINDOW_UserData,gw->hw,
			WINDOW_IconifyGadget, FALSE,
			WINDOW_GadgetHelp, TRUE,
			WINDOW_Position, WPOS_CENTERSCREEN,
			WINDOW_HorizProp,1,
			WINDOW_VertProp,1,
			WINDOW_IDCMPHook,&gw->hw->scrollerhook,
			WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE,
//			WA_ReportMouse,TRUE,
			WA_IDCMP,IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE, // | IDCMP_MOUSEMOVE,
			WINDOW_ParentGroup, gw->hw->objects[GID_MAIN] = LayoutVObj,
				LAYOUT_AddChild, gw->hw->objects[GID_BROWSER] = SpaceObj,
					GA_ID,GID_BROWSER,
//					SPACE_MinWidth,width,
//					SPACE_MinHeight,height,
				SpaceEnd,
			EndGroup,
		EndWindow;

		gw->hw->win = (struct Window *)RA_OpenWindow(gw->hw->objects[OID_MAIN]);
		gw->hw->node = AddObject(window_list,AMINS_HISTORYWINDOW);
		gw->hw->node->objstruct = gw->hw;

		GetAttr(WINDOW_HorizObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_HSCROLL]);
		GetAttr(WINDOW_VertObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_VSCROLL]);

		RefreshSetGadgetAttrs((APTR)gw->hw->objects[OID_VSCROLL],gw->hw->win,NULL,
			GA_ID,OID_VSCROLL,
			SCROLLER_Top,0,
			ICA_TARGET,ICTARGET_IDCMP,
			TAG_DONE);

		RefreshSetGadgetAttrs((APTR)gw->hw->objects[OID_HSCROLL],gw->hw->win,NULL,
			GA_ID,OID_HSCROLL,
			SCROLLER_Top,0,
			ICA_TARGET,ICTARGET_IDCMP,
			TAG_DONE);
	}

	ami_history_redraw(gw->hw);
}


/**
 * Handle mouse clicks in the history window.
 *
 * \return true if the event was handled, false to pass it on
 */

static bool ami_history_click(struct history_window *hw, uint16 code)
{
	int x, y;
	struct IBox *bbox;
	ULONG xs, ys;

	if(ami_gui_get_space_box(hw->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
		amiga_warn_user("NoMemory", "");
		return false;
	}

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	x = hw->win->MouseX - bbox->Left +xs;
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	y = hw->win->MouseY - bbox->Top + ys;

	ami_gui_free_space_box(bbox);

	switch(code)
	{
		case SELECTUP:
			browser_window_history_click(hw->gw->bw, x, y, false);
			ami_history_redraw(hw);
			ami_schedule_redraw(hw->gw->shared, true);
		break;

		case MIDDLEUP:
			browser_window_history_click(hw->gw->bw, x, y, true);
			ami_history_redraw(hw);
		break;
	}

	return true;
}
示例#8
0
void _ClearBobAndFollowClearPath(struct VSprite * CurVSprite, 
                                 struct RastPort * rp,
                                 struct GfxBase * GfxBase)
{
	/*
	 * If the bob has not been drawn, yet, then don't do anything.
	 * If the bob has already been cleared, then also leave here!
	 * It does happen that this routine gets called for 
	 * a sprite that has been cleared already.
	 */
	if (0 != (CurVSprite->VSBob->Flags & (BWAITING|BOBNIX))) {
		CurVSprite->VSBob->Flags &= ~BWAITING;
		return;
	}

	if (NULL != CurVSprite->ClearPath) {
		/*
		 * Clear the next one first. (recursion!!!)
		 */
		_ClearBobAndFollowClearPath(CurVSprite->ClearPath, 
		                            rp,
		                            GfxBase);
		CurVSprite->ClearPath = NULL;
	}


	/*
	 * Only restore the background if the bob image
	 * that is currently there is to be replaced by
	 * the background. If SAVEBOB is set the user
	 * might want some kind of a brush effect.
	 */
	
	if (0 == (CurVSprite->Flags & SAVEBOB)) {
		if (0 != (CurVSprite->Flags & BACKSAVED)) {
			BltBitMapRastPort(CurVSprite->IntVSprite->SaveBuffer,
			                  0,
			                  0,
			                  rp,
			                  CurVSprite->OldX,
			                  CurVSprite->OldY,
			                  CurVSprite->Width << 4,
			                  CurVSprite->Height,
			                  0x0c0);
			CurVSprite->Flags &= ~BACKSAVED;
			
		} /* if (0 != (CurVSprite->Flags & BACKSAVED)) */
		  else {
			/*
			 * No background was saved. So let's restore the
			 * standard background!
			 */
			EraseRect(rp,
			          CurVSprite->OldX,
			          CurVSprite->OldY,
			          CurVSprite->OldX + ( CurVSprite->Width << 4 ) - 1,
			          CurVSprite->OldY +   CurVSprite->Height	- 1);
		}
		/*
		 * Mark the BOB as cleared.
		 */
		CurVSprite->VSBob->Flags |= BOBNIX;
	} /* if (0 == (CurVSprite->Flags & SAVEBOB)) */
}
示例#9
0
文件: Draw.c 项目: amiga-mui/toolbar
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);
    }
  }
}
示例#10
0
// 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);
			}
		}
示例#11
0
void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i)
{BltBitMapRastPort(a,b,c,d,e,f,g,h,i);}
示例#12
0
void ami_history_redraw(struct history_window *hw)
{
	struct IBox *bbox;
	ULONG xs,ys;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &amiplot
	};

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);

	glob = &hw->gg;

	SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
	RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);

	history_redraw_rectangle(history_current, xs, ys,
			bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);

	glob = &browserglob;

	ami_clearclipreg(&hw->gg);
	ami_history_update_extent(hw);

	BltBitMapRastPort(hw->gg.bm, 0, 0, hw->win->RPort,
				bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);
}

/**
 * Handle mouse clicks in the history window.
 *
 * \return true if the event was handled, false to pass it on
 */

bool ami_history_click(struct history_window *hw,uint16 code)
{
	int x, y;
	struct IBox *bbox;
	ULONG width,height,xs,ys;

	GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);	

	GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
	x = hw->win->MouseX - bbox->Left +xs;
	GetAttr(SCROLLER_Top,hw->objects[OID_VSCROLL],(ULONG *)&ys);
	y = hw->win->MouseY - bbox->Top + ys;

	width=bbox->Width;
	height=bbox->Height;

	switch(code)
	{
		case SELECTUP:
			history_click(hw->bw,history_current,x,y,false);
			ami_history_redraw(hw);
			ami_do_redraw(hw->bw->window->shared);
		break;

		case MIDDLEUP:
			history_click(hw->bw,history_current,x,y,true);
			ami_history_redraw(hw);
		break;

	}

	return true;
}