int lib_graphics_f_OrRectRegion_2(emumsg_syscall_t *msg) { /* Make real syscall */ msg->arg[0]._bool = OrRectRegion( (struct Region *)msg->arg[0]._aptr, (struct Rectangle *)msg->arg[1]._aptr ); return HOOK_DONE; }
// 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); }
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; }
// Show list selector void show_list_selector(Lister *lister,short line,BOOL erase) { short left,top,width,height,image_width,image_height,fpen=1,bpen=0; unsigned short *image; DirEntry *entry; // Get width and height width=KEY_SEL_OFFSET; height=lister->text_area.rast.TxHeight; // Get position left=lister->text_area.rect.MinX-KEY_SEL_OFFSET; top=lister->text_area.rect.MinY+line*height; // Small font? if (height<BIG_ARROW_HEIGHT) { image=small_arrow; image_width=SMALL_ARROW_WIDTH; image_height=SMALL_ARROW_HEIGHT; } // Big font else { image=big_arrow; image_width=BIG_ARROW_WIDTH; image_height=BIG_ARROW_HEIGHT; } // Center in area left+=(width-image_width)>>1; top+=(height-image_height)>>1; // Is lister in damage refresh mode? if (lister->window->Flags&WFLG_WINDOWREFRESH) { struct Rectangle rect; // Forbid for this Forbid(); // End refresh temporarily EndRefresh(lister->window,FALSE); // Get rectangle for arrow rect.MinX=left; rect.MinY=top; rect.MaxX=left+image_width-1; rect.MaxY=top+image_height-1; // Add to damage list OrRectRegion(lister->window->WLayer->DamageList,&rect); // Continue with refresh BeginRefresh(lister->window); // Enable now we've done our dirty work Permit(); } // Get selector line entry, and set correct colours if (entry=get_entry_ord(&lister->cur_buffer->entry_list,line+lister->cur_buffer->buf_VertOffset)) getdispcol(entry,lister,&fpen,&bpen); // Erase? if (erase || lister->cur_buffer->buf_TotalEntries[0]<1) { // Get correct background colour SetAPen(&lister->list_area.rast,(entry)?bpen:0); // Erase image RectFill( &lister->list_area.rast, left,top, left+image_width-1,top+image_height-1); return; } // Draw arrow-like thing SetAPen(&lister->list_area.rast,(entry && bpen==lister->drawinfo->dri_Pens[TEXTPEN])?fpen:lister->drawinfo->dri_Pens[TEXTPEN]); SetDrMd(&lister->list_area.rast,JAM1); BltTemplate( (char *)image, 0,2, &lister->list_area.rast, left,top, image_width,image_height); }
// Scroll the icons void backdrop_scroll_objects(BackdropInfo *info,short off_x,short off_y) { // Lock window GetSemaphore(&info->window_lock,SEMF_EXCLUSIVE,0); // Window open? if (info->window) { short damage=0,clear=0; // Bounds-check the deltas if (off_x<0 && off_x<-RECTWIDTH(&info->size)) clear=1; else if (off_x>0 && off_x>RECTWIDTH(&info->size)) clear=1; else if (off_y<0 && off_y<-RECTHEIGHT(&info->size)) clear=1; else if (off_y>0 && off_y>RECTHEIGHT(&info->size)) clear=1; // Clear instead of scrolling? if (clear) { // Clear the whole window EraseRect( info->window->RPort, info->size.MinX, info->size.MinY, info->size.MaxX, info->size.MaxY); } // Scroll else { // Check for 39 if(((struct Library *)GfxBase)->lib_Version>=39) { // Scroll backdrop window ScrollRasterBF( info->window->RPort, off_x,off_y, info->size.MinX, info->size.MinY, info->size.MaxX, info->size.MaxY); } // No backfills else { // Scroll backdrop window ScrollRaster( info->window->RPort, off_x,off_y, info->size.MinX, info->size.MinY, info->size.MaxX, info->size.MaxY); } // Damaged simple-refresh? if (info->window->Flags&WFLG_SIMPLE_REFRESH && info->window->WLayer->Flags&LAYERREFRESH) { // Forbid #ifdef LOCKLAYER_OK LockScreenLayer(info->window->WScreen); #else Forbid(); #endif // Begin refreshing BeginRefresh(info->window); // Clear the new bits EraseRect( info->window->RPort, info->size.MinX, info->size.MinY, info->size.MaxX, info->size.MaxY); // End refreshing for the moment EndRefresh(info->window,FALSE); damage=1; } } // Got temporary region? if (info->temp_region) { struct Rectangle rect; // Get refresh region rect.MinX=(off_x==0)?info->size.MinX:((off_x>0)?info->size.MaxX-off_x:info->size.MinX); rect.MaxX=(off_x==0)?info->size.MaxX:((off_x>0)?info->size.MaxX:info->size.MinX-off_x); rect.MinY=(off_y==0)?info->size.MinY:((off_y>0)?info->size.MaxY-off_y:info->size.MinY); rect.MaxY=(off_y==0)?info->size.MaxY:((off_y>0)?info->size.MaxY:info->size.MinY-off_y); // Bounds check region if (rect.MinX<info->size.MinX) rect.MinX=info->size.MinX; if (rect.MinY<info->size.MinY) rect.MinY=info->size.MinY; if (rect.MaxX>info->size.MaxX) rect.MaxX=info->size.MaxX; if (rect.MaxY>info->size.MaxY) rect.MaxY=info->size.MaxY; // Add to damage list? if (damage) { // Or rectangle in OrRectRegion(info->window->WLayer->DamageList,&rect); } // Manually refresh else { // Set refresh region ClearRegion(info->temp_region); OrRectRegion(info->temp_region,&rect); // Install region InstallClipRegion(info->window->WLayer,info->temp_region); } } // Manual refresh? if (!damage) { // Refresh backdrop_show_objects(info,BDSF_NO_CLIP); // Remove clip region InstallClipRegion(info->window->WLayer,0); } // Automatic refresh else { // Lister? if (info->lister) lister_refresh_callback(IDCMP_REFRESHWINDOW,info->window,info->lister); // Other type else { struct IntuiMessage msg; // Fake IntuiMessage msg.Class=IDCMP_REFRESHWINDOW; // Handle refresh backdrop_idcmp(info,&msg,0); } // Enable multi-tasking #ifdef LOCKLAYER_OK UnlockScreenLayer(info->window->WScreen); #else Permit(); #endif } } // Unlock window FreeSemaphore(&info->window_lock); }
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); }
void WindowSizeHasChanged(struct Window *targetwindow, WORD dx, WORD dy, BOOL is_sizewindow, struct IntuitionBase *IntuitionBase) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; struct Layer *lay; D(bug("********* WindowSizeHasChanged ********\n")); lay = (BLAYER(targetwindow)) ? BLAYER(targetwindow) : WLAYER(targetwindow); /* Fix GadgetInfo domain if there is an active gadget in window which was resized */ if ((iihdata->ActiveGadget) && (targetwindow == iihdata->GadgetInfo.gi_Window)) { GetGadgetDomain(iihdata->ActiveGadget, iihdata->GadgetInfo.gi_Screen, iihdata->GadgetInfo.gi_Window, NULL, &iihdata->GadgetInfo.gi_Domain); } /* Relayout GFLG_REL??? gadgets */ DoGMLayout(targetwindow->FirstGadget, targetwindow, NULL, -1, FALSE, IntuitionBase); /* Add the new area of all GFLG_REL??? gadgets to the damagelist, but don't EraseRect() as the gadgets will be re-rendered at their new position anyway */ { struct Rectangle innerrect; innerrect.MinX = targetwindow->BorderLeft; innerrect.MinY = targetwindow->BorderTop; innerrect.MaxX = targetwindow->Width - 1 - targetwindow->BorderRight; innerrect.MaxY = targetwindow->Height - 1 - targetwindow->BorderBottom; EraseRelGadgetArea(targetwindow, AVOID_WINBORDERERASE ? &innerrect : NULL, TRUE, IntuitionBase); } /* If new size is smaller than old size add right/bottom frame to damagelist */ if ( ((dx < 0) && (targetwindow->BorderRight > 0)) || ((dx > 0) && (targetwindow->BorderTop > 0)) || ((dy < 0) && (targetwindow->BorderBottom > 0)) ) { struct Rectangle rect; LockLayer(0, lay); if ((dx < 0) && (targetwindow->BorderRight > 0)) { rect.MinX = targetwindow->Width - targetwindow->BorderRight; rect.MinY = 0; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } if ((dx > 0) && (targetwindow->BorderTop > 0)) { rect.MinX = 0; rect.MinY = 0; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->BorderTop - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } if ((dy < 0) && (targetwindow->BorderBottom > 0)) { rect.MinX = 0; rect.MinY = targetwindow->Height - targetwindow->BorderBottom; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(lay->DamageList, &rect); lay->Flags |= LAYERREFRESH; } UnlockLayer(lay); } /* if ( ((dx < 0) && (targetwindow->BorderRight > 0)) || ((dy < 0) && (targetwindow->BorderBottom > 0)) ) */ ((struct IntWindow *)(targetwindow))->specialflags |= SPFLAG_LAYERRESIZED; #if 0 if (IS_GZZWINDOW(targetwindow)) { lay = targetwindow->BorderRPort->Layer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); RefreshWindowFrame(targetwindow); lay->Flags &= ~LAYERREFRESH; Gad_EndUpdate(lay, TRUE, IntuitionBase); } lay = targetwindow->WLayer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); int_refreshglist(targetwindow->FirstGadget, targetwindow, NULL, -1, 0, REFRESHGAD_BORDER, IntuitionBase); Gad_EndUpdate(lay, IS_NOCAREREFRESH(targetwindow), IntuitionBase); } } else { lay = targetwindow->WLayer; if (lay->Flags & LAYERREFRESH) { Gad_BeginUpdate(lay, IntuitionBase); RefreshWindowFrame(targetwindow); int_refreshglist(targetwindow->FirstGadget, targetwindow, NULL, -1, 0, REFRESHGAD_BORDER, IntuitionBase); Gad_EndUpdate(lay, IS_NOCAREREFRESH(targetwindow), IntuitionBase); } } lay = targetwindow->WLayer; if (IS_NOCAREREFRESH(targetwindow)) { LockLayer(0, lay); lay->Flags &= ~LAYERREFRESH; UnlockLayer(lay); } #endif #if 0 //if (is_sizewindow) { /* Send IDCMP_NEWSIZE to resized window */ 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); } /* Send IDCMP_CHANGEWINDOW to resized window */ ih_fire_intuimessage(targetwindow, IDCMP_CHANGEWINDOW, CWCODE_MOVESIZE, targetwindow, IntuitionBase); #endif }
void WindowSizeWillChange(struct Window *targetwindow, WORD dx, WORD dy, struct IntuitionBase *IntuitionBase) { struct Rectangle *clipto = NULL; struct Rectangle final_innerrect; /* Erase the old frame on the right/lower side if new size is bigger than old size */ D(bug("********* WindowSizeWillChange ******** dx = %d dy = %d\n", dx, dy)); if (AVOID_WINBORDERERASE) { final_innerrect.MinX = targetwindow->BorderLeft; final_innerrect.MinY = targetwindow->BorderTop; final_innerrect.MaxX = targetwindow->Width + dx - 1 - targetwindow->BorderRight; final_innerrect.MaxY = targetwindow->Height + dy - 1 - targetwindow->BorderBottom; clipto = &final_innerrect; } if ( ((dx > 0) && (targetwindow->BorderRight > 0)) || ((dy > 0) && (targetwindow->BorderBottom > 0)) ) { struct RastPort *rp = targetwindow->BorderRPort; struct Layer *L = (BLAYER(targetwindow)) ? BLAYER(targetwindow) : WLAYER(targetwindow); struct Rectangle rect; struct Region *oldclipregion; WORD ScrollX; WORD ScrollY; /* ** In case a clip region is installed then I have to ** install the regular cliprects of the layer ** first. Otherwise the frame might not get cleared correctly. */ LockLayer(0, L); oldclipregion = InstallClipRegion(L, NULL); ScrollX = L->Scroll_X; ScrollY = L->Scroll_Y; L->Scroll_X = 0; L->Scroll_Y = 0; if ((dx > 0) && (targetwindow->BorderRight > 0)) { rect.MinX = targetwindow->Width - targetwindow->BorderRight; rect.MinY = 0; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(L->DamageList, &rect); L->Flags |= LAYERREFRESH; if (!AVOID_WINBORDERERASE || AndRectRect(&rect, &final_innerrect, &rect)) { EraseRect(rp, rect.MinX, rect.MinY, rect.MaxX, rect.MaxY); } } if ((dy > 0) && (targetwindow->BorderBottom > 0)) { rect.MinX = 0; rect.MinY = targetwindow->Height - targetwindow->BorderBottom; rect.MaxX = targetwindow->Width - 1; rect.MaxY = targetwindow->Height - 1; OrRectRegion(L->DamageList, &rect); L->Flags |= LAYERREFRESH; if (!AVOID_WINBORDERERASE || AndRectRect(&rect, &final_innerrect, &rect)) { EraseRect(rp, rect.MinX, rect.MinY, rect.MaxX, rect.MaxY); } } /* ** Reinstall the clipregions rectangles if there are any. */ if (NULL != oldclipregion) { InstallClipRegion(L, oldclipregion); } L->Scroll_X = ScrollX; L->Scroll_Y = ScrollY; UnlockLayer(L); } /* if ( ((dx > 0) && (targetwindow->BorderRight > 0)) || ((dy > 0) && (targetwindow->BorderBottom > 0)) ) */ /* Before resizing the layers eraserect the area of all GFLG_REL??? gadgets and add the area to the damagelist */ EraseRelGadgetArea(targetwindow, clipto, FALSE, IntuitionBase); }