// Render an object to the main window void backdrop_render_object( BackdropInfo *info, BackdropObject *object, UWORD flags) { // Lock window GetSemaphore(&info->window_lock,SEMF_EXCLUSIVE,0); // Window open? if (info->window) { // Install clip? if (flags&BRENDERF_CLIP && info->clip_region) InstallClipRegion(info->window->WLayer,info->clip_region); // Draw object backdrop_draw_object( info, object, flags|BRENDERF_REAL, &info->rp, object->pos.Left, object->pos.Top); // Remove clip region if (flags&BRENDERF_CLIP && info->clip_region) InstallClipRegion(info->window->WLayer,0); } // Unlock window FreeSemaphore(&info->window_lock); }
int lib_layers_f_InstallClipRegion_2(emumsg_syscall_t *msg) { /* Make real syscall */ msg->arg[0]._aptr = (APTR)InstallClipRegion( (struct Layer *)msg->arg[0]._aptr, (struct Region *)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); }
// 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); }
// Show the backdrop objects void backdrop_show_objects(BackdropInfo *info,UWORD flags) { BackdropObject *object; // Lock backdrop list lock_listlock(&info->objects,0); // Lock window GetSemaphore(&info->window_lock,SEMF_EXCLUSIVE,0); // Window open? if (info->window) { // Are we in a refresh? if (flags&BDSF_IN_REFRESH) { // Lock layers #ifdef LOCKLAYER_OK LockScreenLayer(info->window->WScreen); #else Forbid(); #endif // End refresh temporarily EndRefresh(info->window,FALSE); // Install new clip region if we have it if (info->clip_region) InstallClipRegion(info->window->WLayer,info->clip_region); // Continue refresh BeginRefresh(info->window); } // Or, are we meant to be refreshing? else if (flags&BDSF_REFRESH) { // Start refresh here? if ((flags&BDSF_REFRESH_DONE)==BDSF_REFRESH_DONE) { // Lock layers #ifdef LOCKLAYER_OK LockScreenLayer(info->window->WScreen); #else Forbid(); #endif } // And our region with damagelist if (info->clip_region) AndRegionRegion(info->clip_region,info->window->WLayer->DamageList); // Begin the refresh BeginRefresh(info->window); } // Install clip region if we have it else if (!(flags&BDSF_NO_CLIP) && info->clip_region) InstallClipRegion(info->window->WLayer,info->clip_region); // Clear backdrop window if (flags&BDSF_CLEAR) { EraseRect(&info->rp, info->size.MinX, info->size.MinY, info->size.MaxX, info->size.MaxY); } // Not just clearing? if ((flags&BDSF_CLEAR_ONLY)!=BDSF_CLEAR_ONLY) { // Go through backdrop list (backwards) for (object=(BackdropObject *)info->objects.list.lh_TailPred; object->node.ln_Pred; object=(BackdropObject *)object->node.ln_Pred) { // Reset? if (flags&BDSF_RESET) { // Need to get masks? if (!backdrop_icon_border(object) && !object->image_mask[0]) { // Get masks for this icon backdrop_get_masks(object); } } // Valid position? if (!(object->flags&BDOF_NO_POSITION)) { // Render this object backdrop_draw_object( info, object, BRENDERF_REAL, &info->rp, object->pos.Left, object->pos.Top); } } } // Refresh? if (flags&BDSF_REFRESH) { EndRefresh(info->window,((flags&BDSF_REFRESH_DONE)==BDSF_REFRESH_DONE)?TRUE:FALSE); // End refresh here? if ((flags&BDSF_REFRESH_DONE)==BDSF_REFRESH_DONE) { // Unlock layers #ifdef LOCKLAYER_OK UnlockScreenLayer(info->window->WScreen); #else Permit(); #endif } } // In refresh? else if (flags&BDSF_IN_REFRESH) { // End refresh temporarily EndRefresh(info->window,FALSE); // Remove clip region if (info->clip_region) InstallClipRegion(info->window->WLayer,0); // Continue refresh BeginRefresh(info->window); // Unlock layers #ifdef LOCKLAYER_OK UnlockScreenLayer(info->window->WScreen); #else Permit(); #endif } // Remove clip region else if (!(flags&BDSF_NO_CLIP) && info->clip_region) InstallClipRegion(info->window->WLayer,0); // Update virtual size if (flags&BDSF_RECALC) backdrop_calc_virtual(info); } // Unlock window FreeSemaphore(&info->window_lock); // Unlock backdrop list unlock_listlock(&info->objects); }
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); }
// Select all objects within an area void backdrop_select_area(BackdropInfo *info,short state) { BackdropObject *object; // Dragging? if (GUI->flags2&GUIF2_ICONPOS && info->flags&BDIF_MAIN_DESKTOP) return; // Lock backdrop list lock_listlock(&info->objects,0); // Install clip if (info->clip_region) InstallClipRegion(info->window->WLayer,info->clip_region); // Go through backdrop list for (object=(BackdropObject *)info->objects.list.lh_Head; object->node.ln_Succ; object=(BackdropObject *)object->node.ln_Succ) { // Valid icon? if (object->icon) { // Icon temporarily selected? if (object->state==2) { // Turn it on? if (state==1) { // Select object object->state=1; // Is this a tool? if (object->type!=BDO_APP_ICON && object->icon->do_Type==WBTOOL) { // If no tools selected, remember this one if (!info->first_sel_tool) info->first_sel_tool=object; } } // See if it needs to be turned off else if (state==0 || !(geo_box_intersect(&object->image_rect,&info->select))) { // Deselect this object object->state=0; object->flags|=BDOF_STATE_CHANGE; backdrop_render_object(info,object,0); } } // Currently off? else if (!object->state && state==2) { // See if icon is in select area if (geo_box_intersect(&object->image_rect,&info->select)) { // Select this object object->state=2; object->flags|=BDOF_STATE_CHANGE; backdrop_render_object(info,object,0); } } } } // Fix selection count backdrop_fix_count(info,1); // Remove clip if (info->clip_region) InstallClipRegion(info->window->WLayer,0); // Unlock backdrop list unlock_listlock(&info->objects); }
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); }