コード例 #1
0
ファイル: f_disposeregion.cpp プロジェクト: moggen/emumiga
int lib_graphics_f_DisposeRegion_2(emumsg_syscall_t *msg)
{
	/* Make real syscall */
	DisposeRegion(
		(struct Region *)msg->arg[0]._aptr
	);

	return HOOK_DONE;
}
コード例 #2
0
ファイル: backdrop.c プロジェクト: MrZammler/opus_magellan
// Free backdrop info stuff
void backdrop_free_info(BackdropInfo *info)
{
	// Free boopsi objects
	BOOPSIFree(&info->boopsi_list);

	// Free regions
	if (info->clip_region)
	{
		DisposeRegion(info->clip_region);
		info->clip_region=0;
	}
	if (info->temp_region)
	{
		DisposeRegion(info->temp_region);
		info->temp_region=0;
	}

	// Clear gadget pointers
	info->horiz_scroller=0;
	info->vert_scroller=0;
	info->window=0;

	// Free notification port
	if (info->notify_port)
	{
		struct Message *msg;

		// Remove request
		if (info->notify_req)
		{
			RemoveNotifyRequest(info->notify_req);
			info->notify_req=0;
		}

		// Clear port of messages
		while (msg=GetMsg(info->notify_port))
			ReplyFreeMsg(msg);

		// Delete port
		DeleteMsgPort(info->notify_port);
		info->notify_port=0;
	}
}
コード例 #3
0
static void cleanup(char *msg)
{
    if (msg)
    {
        printf("roundshape: %s\n",msg);
    }

    if (win) CloseWindow(win);
    if (shape) DisposeRegion(shape);    
    if (scr) UnlockPubScreen(0, scr);
    
    if (GfxBase) CloseLibrary((struct Library *)GfxBase);
    if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
    
    exit(0);
}
コード例 #4
0
ファイル: font.c プロジェクト: timofonic/dopus5allamigas
// Show font example
void font_show_font(font_data *data,BOOL refresh)
{
	struct Rectangle rect;
	struct Region *region;
	struct RastPort rp;

	// Get display rectangle
	GetObjectRect(data->list,GAD_FONT_DISPLAY,&rect);

	// Move rectangle in
	rect.MinX+=3;
	rect.MinY+=3;
	rect.MaxX-=3;
	rect.MaxY-=3;

	// Copy rastport
	rp=*data->window->RPort;

	// Refresh?
	if (refresh)
	{
		LockLayerInfo(&data->window->WScreen->LayerInfo);
		BeginRefresh(data->window);
	}

	// Clear background
	SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[SHINEPEN]);
	RectFill(&rp,rect.MinX-1,rect.MinY-1,rect.MaxX+1,rect.MaxY+1);

	// Refreshing?
	if (refresh) EndRefresh(data->window,FALSE);

	// Create region
	if ((region=NewRegion()))
	{
		// Set rectangle
		OrRectRegion(region,&rect);

		// Install region
		InstallClipRegion(data->window->WLayer,region);
	}

	// Refreshing?
	if (refresh) BeginRefresh(data->window);

	// Got a font?
	if (data->font)
	{
		ULONG flags;
		short y;
		struct TextExtent extent;
		char *ptr,*end;

		// Set pen and font
		SetAPen(&rp,DRAWINFO(data->window)->dri_Pens[TEXTPEN]);
		SetDrMd(&rp,JAM1);
		SetFont(&rp,data->font);

		// Get style flags
		flags=0;
		if (GetGadgetValue(data->list,GAD_FONT_BOLD)) flags|=FSF_BOLD;
		if (GetGadgetValue(data->list,GAD_FONT_ITALIC)) flags|=FSF_ITALIC;
		if (GetGadgetValue(data->list,GAD_FONT_ULINE)) flags|=FSF_UNDERLINED;

		// Set styles
		SetSoftStyle(&rp,flags,FSF_BOLD|FSF_ITALIC|FSF_UNDERLINED);

		// Valid font to draw?
		if (data->font_text[0])
		{
			// Get end of the string
			end=data->font_text+strlen(data->font_text);

			// Initial coordinates
			y=rect.MinY;

			// Initialise position
			if (!(ptr=strchr(data->font_text,'A')))
				ptr=data->font_text;
			Move(&rp,rect.MinX,y+rp.TxBaseline);

			// Draw until we reach the bottom
			while (y<rect.MaxY)
			{
				// New line
				if (rp.cp_x>rect.MaxX)
				{
					// Bump position
					y+=rp.TxHeight+1;
					Move(&rp,rect.MinX,y+rp.TxBaseline);
				}

				// Otherwise
				else
				{
					short len,maxlen;

					// Get text that will fit
					len=
						TextFit(
							&rp,
							ptr,
							(maxlen=strlen(ptr)),
							&extent,
							0,1,
							rect.MaxX-rp.cp_x+1,
							rp.TxHeight);

					// Check against length, add extra character if ok
					if (len<maxlen) ++len;

					// Draw text
					Text(&rp,ptr,len);

					// Bump text position
					ptr+=len;

					// End of the string?
					if (ptr>=end) ptr=data->font_text;
				}
			}
		}
	}

	// Finished refreshing?
	if (refresh) EndRefresh(data->window,TRUE);

	// Remove region
	if (region)
	{
		InstallClipRegion(data->window->WLayer,0);
		DisposeRegion(region);
	}

	// Unlock layers if we refreshed
	if (refresh) UnlockLayerInfo(&data->window->WScreen->LayerInfo);
}
コード例 #5
0
static struct Region *shapefunc(struct Hook *hook, struct Layer *lay, struct ShapeHookMsg *msg)
{
    struct Region *newshape, *retregion = msg->ActualShape;
    WORD x2, y2;
  
    switch(msg->Action)
    {
    	case SHAPEHOOKACTION_CREATELAYER:
	case SHAPEHOOKACTION_SIZELAYER:
	case SHAPEHOOKACTION_MOVESIZELAYER:
	    x2 = msg->NewBounds.MaxX - msg->NewBounds.MinX;
	    y2 = msg->NewBounds.MaxY - msg->NewBounds.MinY;
	    
	    if ((newshape = NewRegion()))
	    {
	    	struct Rectangle rect;
		BOOL success = TRUE;
		
		rect.MinX = 9;
		rect.MinY = 0;
		rect.MaxX = x2 - 9;
		rect.MaxY = y2;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 6;
		rect.MinY = 1;
		rect.MaxX = x2 - 6;
		rect.MaxY = y2 - 1;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 4;
		rect.MinY = 2;
		rect.MaxX = x2 - 4;
		rect.MaxY = y2 - 2;		
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 3;
		rect.MinY = 3;
		rect.MaxX = x2 - 3;
		rect.MaxY = y2 - 3;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 2;
		rect.MinY = 4;
		rect.MaxX = x2 - 2;
		rect.MaxY = y2 - 4;
		success &= OrRectRegion(newshape, &rect);
		
		rect.MinX = 1;
		rect.MinY = 6;
		rect.MaxX = x2 - 1;
		rect.MaxY = y2 - 6;
		success &= OrRectRegion(newshape, &rect);

		rect.MinX = 0;
		rect.MinY = 9;
		rect.MaxX = x2;
		rect.MaxY = y2 - 9;
		success &= OrRectRegion(newshape, &rect);
		
		if (success)
		{
	    	    if (msg->ActualShape) DisposeRegion(msg->ActualShape);
	    	    retregion = shape = newshape;
		}
		else
		{
		    DisposeRegion(newshape);
		}
		
	    } /* if ((newshape = NewRegion())) */
	    
    } /* switch(msg->Action) */
    
    return retregion;
}
コード例 #6
0
ファイル: clippingtest.c プロジェクト: michalsc/AROS
static void Action(void)
{
    struct Region *clip, *oldclip;
    struct Rectangle rect1;
    struct Rectangle rect2;
    struct IntuiMessage *msg;
    WORD col = 1;
    BOOL installed = TRUE;
    BOOL quitme = FALSE;

    rect1.MinX =  20;rect1.MinY = 80;
    rect1.MaxX = 180;rect1.MaxY = 120;
    rect2.MinX =  80;rect2.MinY = 20;
    rect2.MaxX = 120;rect2.MaxY = 180;

    Move(rp, 20, 20);
    Draw(rp, 180, 180);

    clip = NewRegion();
    if (!clip) Cleanup("Can't create clip region!");

    OrRectRegion(clip, &rect1);
    OrRectRegion(clip, &rect2);

    oldclip = InstallClipRegion(lay, clip);

    SetAPen(rp,col);
    RectFill(rp,0,0,1000,1000);

    while(!quitme)
    {
	WaitPort(win->UserPort);
	while ((msg = (struct IntuiMessage *)GetMsg(win->UserPort)))
	{
	    switch(msg->Class)
	    {
	    case IDCMP_CLOSEWINDOW:
		quitme = TRUE;
		break;

	    case IDCMP_VANILLAKEY:
	        switch (msg->Code)
	        {
	        case 'c':
	        case 'C':
	        if (installed)
	        {
	            InstallClipRegion(lay, oldclip);
	            installed = FALSE;
	        }
	        else
	        {
	            oldclip = InstallClipRegion(lay, clip);
	            installed = TRUE;
	        }    
		/* Fallthrough */

	        default:
		    col = 3 - col;
		    SetAPen(rp,col);
		    RectFill(rp,0,0,1000,1000);
		    break;
		}

	    case IDCMP_REFRESHWINDOW:
		BeginRefresh(win);
		SetAPen(rp,col);
		RectFill(rp,0,0,1000,1000);					
		EndRefresh(win,TRUE);
		break;
	    }

	    ReplyMsg((struct Message *)msg);
	}
    }

    if (installed)
	InstallClipRegion(lay, oldclip);
    DisposeRegion(clip);
}
コード例 #7
0
void DoMoveSizeWindow(struct Window *targetwindow, LONG NewLeftEdge, LONG NewTopEdge,
                      LONG NewWidth, LONG NewHeight, BOOL send_newsize, struct IntuitionBase *IntuitionBase)
{
    struct IIHData  	*iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data;
  //struct IntWindow  	*w       = (struct IntWindow *)targetwindow;
    struct Layer    	*targetlayer = WLAYER(targetwindow)/*, *L*/;
    struct Requester    *req;
    struct InputEvent   *ie;
    LONG            	 OldLeftEdge  = targetwindow->LeftEdge;
    LONG            	 OldTopEdge   = targetwindow->TopEdge;
    LONG            	 OldWidth     = targetwindow->Width;
    LONG            	 OldHeight    = targetwindow->Height;
    LONG            	 pos_dx, pos_dy, size_dx, size_dy;

    /* correct new window coords if necessary */

    FixWindowCoords(targetwindow, &NewLeftEdge, &NewTopEdge, &NewWidth, &NewHeight,IntuitionBase);

    D(bug("DoMoveSizeWindow to %d,%d %d x %d\n", NewLeftEdge, NewTopEdge, NewWidth, NewHeight));

    pos_dx  = NewLeftEdge - OldLeftEdge;
    pos_dy  = NewTopEdge  - OldTopEdge;
    size_dx = NewWidth    - OldWidth;
    size_dy = NewHeight   - OldHeight;

    LOCK_REFRESH(targetwindow->WScreen);

/* jDc: intuition 68k doesn't care about that */
//    if (pos_dx || pos_dy || size_dx || size_dy)
//    {

        if (size_dx || size_dy)
        {
            WindowSizeWillChange(targetwindow, size_dx, size_dy, IntuitionBase);
        }

        targetwindow->LeftEdge    += pos_dx;
        targetwindow->TopEdge     += pos_dy;
#ifndef __MORPHOS__
        targetwindow->RelLeftEdge += pos_dx;
        targetwindow->RelTopEdge  += pos_dy;
#endif

        targetwindow->Width     = NewWidth;
        targetwindow->Height    = NewHeight;
        targetwindow->GZZWidth  = targetwindow->Width  - targetwindow->BorderLeft - targetwindow->BorderRight;
        targetwindow->GZZHeight = targetwindow->Height - targetwindow->BorderTop  - targetwindow->BorderBottom;

        /* check for GZZ window */
        if (BLAYER(targetwindow))
        {
            /* move outer window first */
            MoveSizeLayer(BLAYER(targetwindow), pos_dx, pos_dy, size_dx, size_dy);
        }

        MoveSizeLayer(targetlayer, pos_dx, pos_dy, size_dx, size_dy);

        for (req = targetwindow->FirstRequest; req; req = req->OlderRequest)
        {
            struct Layer *layer = req->ReqLayer;

            if (layer)
            {
                int dx, dy, dw, dh;
                int left, top, right, bottom;

                left = NewLeftEdge + req->LeftEdge;
                top = NewTopEdge + req->TopEdge;
                right = left + req->Width - 1;
                bottom = top + req->Height - 1;

                if (left > NewLeftEdge + NewWidth - 1)
                    left = NewLeftEdge + NewWidth - 1;

                if (top > NewTopEdge + NewHeight - 1)
                    top = NewTopEdge + NewHeight - 1;

                if (right > NewLeftEdge + NewWidth - 1)
                    right = NewLeftEdge + NewWidth - 1;

                if (bottom > NewTopEdge + NewHeight - 1)
                    bottom = NewTopEdge + NewHeight - 1;

                dx = left - layer->bounds.MinX;
                dy = top - layer->bounds.MinY;
                dw = right - left - layer->bounds.MaxX + layer->bounds.MinX;
                dh = bottom - top - layer->bounds.MaxY + layer->bounds.MinY;

                MoveSizeLayer(layer, dx, dy, dw, dh);
            }
        }

#if 0
        if (w->ZipLeftEdge != ~0) w->ZipLeftEdge = OldLeftEdge;
        if (w->ZipTopEdge  != ~0) w->ZipTopEdge  = OldTopEdge;
        if (w->ZipWidth    != ~0) w->ZipWidth    = OldWidth;
        if (w->ZipHeight   != ~0) w->ZipHeight   = OldHeight;
#endif

        if (pos_dx || pos_dy)
        {
            UpdateMouseCoords(targetwindow);
#ifndef __MORPHOS__
            if (HAS_CHILDREN(targetwindow))
                move_family(targetwindow, pos_dx, pos_dy);
#endif
        }

//    } /* if (pos_dx || pos_dy || size_dx || size_dy) */

    if (size_dx || size_dy)
    {
        WindowSizeHasChanged(targetwindow, size_dx, size_dy, FALSE, IntuitionBase);
    }

    ih_fire_intuimessage(targetwindow,
                 IDCMP_CHANGEWINDOW,
                 CWCODE_MOVESIZE,
                 targetwindow,
                 IntuitionBase);

    if (send_newsize)
    {
        /* Send IDCMP_NEWSIZE and IDCMP_CHANGEWINDOW to resized window, even
           if there was no resizing/position change at all. BGUI for example
           relies on this! */

        ih_fire_intuimessage(targetwindow,
                     IDCMP_NEWSIZE,
                     0,
                     targetwindow,
                     IntuitionBase);

        if ((ie = AllocInputEvent(iihdata)))
        {
            ie->ie_Class = IECLASS_EVENT;
            ie->ie_Code = IECODE_NEWSIZE;
            ie->ie_EventAddress = targetwindow;
            CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro);
        }
    }

    // jDc: CheckLayers calls LOCK_REFRESH, so there's no reason to UNLOCK here!
    //    UNLOCK_REFRESH(targetwindow->WScreen);

    CheckLayers(targetwindow->WScreen, IntuitionBase);

    UNLOCK_REFRESH(targetwindow->WScreen);
    
#if 0    
    if (size_dx || size_dy)
    {
        if (!(((struct IntWindow *)targetwindow)->CustomShape))
        {
            struct wdpWindowShape       shapemsg;
            struct Region               *shape;
            shapemsg.MethodID           = WDM_WINDOWSHAPE;
            shapemsg.wdp_Width      = targetwindow->Width;
            shapemsg.wdp_Height     = targetwindow->Height;
            shapemsg.wdp_Window = targetwindow;
            shapemsg.wdp_TrueColor      = (((struct IntScreen *)targetwindow->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
            shapemsg.wdp_UserBuffer     = ((struct IntWindow *)targetwindow)->DecorUserBuffer;
            shape = DoMethodA(((struct IntScreen *)(targetwindow->WScreen))->WinDecorObj, (Msg)&shapemsg);	

            if (((struct IntWindow *)targetwindow)->OutlineShape) DisposeRegion(((struct IntWindow *)targetwindow)->OutlineShape);
            ((struct IntWindow *)targetwindow)->OutlineShape = shape;
            ChangeWindowShape(targetwindow, shape, NULL);
            ((struct IntWindow *)targetwindow)->CustomShape = FALSE;
        }
    }
#endif
    
}
コード例 #8
0
// Cleanup a lister
void lister_cleanup(Lister *lister,BOOL bye)
{
	struct Node *node;

	// Send goodbye message?
	if (bye)
	{
		// Update our position
		if (!(environment->env->lister_options&LISTEROPTF_SNAPSHOT))
			PositionUpdate(lister,0);

		// Send goodbye message
		IPC_Goodbye(lister->ipc,&main_ipc,WINDOW_LISTER);
	}

	// Is lister iconified?
	if (lister->appicon)
	{
		// Remove AppIcon
		RemoveAppIcon(lister->appicon);

		// Free icon
		FreeDiskObjectCopy(lister->appicon_icon);
	}

	// If we still have a progress window, close it
	lister_progress_off(lister);

	// Showing a special buffer?
	if (lister->cur_buffer==lister->special_buffer)
	{
		// Return to normal
		lister->cur_buffer=lister->old_buffer;
	}

	// Remove buffer lock
	if (lister->cur_buffer)
	{
		// Get buffer list lock
		lock_listlock(&GUI->buffer_list,TRUE);

		// Unlock buffer
		buffer_clear_lock(lister->cur_buffer,1);

		// If buffer is empty or buffer count exceeds maximum, free it
		if (lister->cur_buffer->buf_TotalEntries[0]==0 ||
			GUI->buffer_count>environment->env->settings.max_buffer_count ||
			(environment->env->settings.dir_flags&DIRFLAGS_DISABLE_CACHING))
		{
			// Free buffer
			lister_free_buffer(lister->cur_buffer);
		}

		// Unlock buffer list
		unlock_listlock(&GUI->buffer_list);
	}

	// Free user data
	while ((node=lister->user_data_list.list.lh_Head)->ln_Succ)
	{
		Remove(node);
		FreeMemH(node);
	}

	// Free ports
	if (lister->app_port)
	{
		DOpusAppMessage *msg;
		while ((msg=(DOpusAppMessage *)GetMsg(lister->app_port)))
			ReplyAppMessage(msg);
		DeleteMsgPort(lister->app_port);
	}

	// Close font
	if (lister->font)
		CloseFont(lister->font);	

	// Free signals
	if (lister->abort_signal!=-1)
		FreeSignal(lister->abort_signal);
	if (lister->hot_name_bit!=-1)
		FreeSignal(lister->hot_name_bit);

	// Free timer stuff
	if (lister->timer_port)
	{
		// Close timers
		FreeTimer(lister->foo_timer);
		FreeTimer(lister->icon_drag_timer);
		FreeTimer(lister->busy_timer);
		FreeTimer(lister->edit_timer);
		FreeTimer(lister->scroll_timer);

		// Delete timer port
		DeleteMsgPort(lister->timer_port);
	}

	// Free regions
	if (lister->title_region) DisposeRegion(lister->title_region);
	if (lister->refresh_extra) DisposeRegion(lister->refresh_extra);

	// Free special buffer
	if (lister->special_buffer) buffer_free(lister->special_buffer);

	// Free reselection
	FreeReselect(&lister->reselect);

	// Free history
	Att_RemList(lister->path_history,0);

	// Free popup menu
	PopUpFreeHandle(lister->lister_tool_menu);

	// Free toolbar
	FreeToolBar(lister->toolbar_alloc);

	// Free IPC data
	IPC_Free(lister->ipc);

	// Free lister data
	lister_free(lister);

	// Decrement count
	--main_lister_count;
}