/******************* ** HandleEvents ** *******************/ VOID HandleEvents(struct Window *win, UBYTE *buffer, LONG bufsize) { struct IntuiMessage *imsg; struct MsgPort *port = win->UserPort; BOOL terminated = FALSE; WORD written; struct InputEvent ie ={0,}; ie.ie_Class = IECLASS_RAWKEY; while (!terminated) { if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL) { switch (imsg->Class) { case IDCMP_REFRESHWINDOW: BeginRefresh(win); EndRefresh(win, TRUE); break; case IDCMP_RAWKEY: ie.ie_Code = imsg->Code; ie.ie_Qualifier = imsg->Qualifier; printf("rawkey: code=$%04x, qual=$%04x\n", ie.ie_Code, ie.ie_Qualifier); ie.ie_EventAddress = imsg->IAddress; written = MapRawKey(&ie, buffer, bufsize, NULL); if (written == -1) printf("Buffer owerflow !!\n"); else if (written) { printf("Map:"); Write(Output(), buffer, written); printf("\n"); } if (ie.ie_Code == 197) terminated = TRUE; break; } /* switch (imsg->Class) */ ReplyMsg((struct Message *)imsg); } /* if ((imsg = GetMsg(port)) != NULL) */ else { Wait(1L << port->mp_SigBit); } } /* while (!terminated) */ return; } /* HandleEvents() */
int main(int argc, char **argv) { ULONG DisplayID,Depth; struct Screen *CyberScreen; struct Window *WriteWindow; LONG done; struct IntuiMessage *IntMsg; IMAGE image; LONG src_x,src_y, old_src_x,old_src_y; ULONG argarray[2]; struct RDArgs *rdargs; char *file; rdargs = ReadArgs((STRPTR)arg_template, (LONG*)argarray, NULL); if(!rdargs) return 20; file = (char*)argarray[0]; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39L); if(!IntuitionBase) return 20; CyberGfxBase = OpenLibrary(CYBERGFXNAME,CYBERGFXVERSION); if(!CyberGfxBase) { ErrorF ("Can't open \"%s\" version %ld or newer.", CYBERGFXNAME,CYBERGFXVERSION); CloseLibrary (&IntuitionBase->LibNode); return 10; } if(!Load(file, &image)) { ErrorF ("Can't load image."); FreeArgs(rdargs); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); return 10; } /* Let CyberGraphX search a display mode for us! */ if(argarray[1]) Depth = 16; else Depth = 24; FreeArgs(rdargs); while (Depth) { DisplayID = BestCModeIDTags(CYBRBIDTG_NominalWidth, image.width, CYBRBIDTG_NominalHeight, image.height, CYBRBIDTG_Depth, Depth, TAG_DONE); if(DisplayID != INVALID_ID) { /* Because older version of the "cybergraphics.library" don't handle */ /* CYBRBIDTG_Depth properly we query the real depth of the mode. */ Depth = GetCyberIDAttr(CYBRIDATTR_DEPTH,DisplayID); break; } /* retry with less bits per pixel */ Depth = NextDepth(Depth); } if (Depth < SCREEN_MIN_DEPTH) { ErrorF ("Can't find suitable display mode for %ldx%ldx.", image.width, image.height); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* open screen, but let Intuition choose the actual dimensions */ CyberScreen = OpenScreenTags( NULL, SA_Title,"RayStorm Image Viewer (C) 1998 Andreas Heumann", SA_DisplayID,DisplayID, SA_Depth,Depth, TAG_DONE); if(!CyberScreen) { ErrorF ("Can't open screen."); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* create Write window */ WriteWindow = OpenWindowTags( NULL, WA_Title,"Viewer", WA_Flags, WFLG_ACTIVATE|WFLG_SIMPLE_REFRESH|WFLG_RMBTRAP, WA_IDCMP, IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS, WA_Borderless, TRUE, WA_Left, 0, WA_Top, 0, WA_Width, image.width, WA_Height, image.height, WA_CustomScreen,CyberScreen, TAG_DONE); if(!WriteWindow) { ErrorF ("Can't open write window."); CloseScreen (CyberScreen); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } src_x = 0; src_y = 0; WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); /* event loop */ done = FALSE; while (!done) { (void)Wait(SIGMASK(WriteWindow)); while (IntMsg=GETIMSG(WriteWindow)) { switch (IntMsg->Class) { case IDCMP_REFRESHWINDOW: BeginRefresh(WriteWindow); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); EndRefresh(WriteWindow,TRUE); break; case IDCMP_VANILLAKEY: switch(IntMsg->Qualifier & 0x7fff) { case 0: switch (IntMsg->Code) { case 27: done = TRUE; break; } break; } break; case IDCMP_RAWKEY: old_src_x = src_x; old_src_y = src_y; switch(IntMsg->Code) { case CURSORRIGHT: if(src_x + WriteWindow->Width + WriteWindow->LeftEdge < image.width) { src_x += 8; if(src_x + WriteWindow->Width + WriteWindow->LeftEdge > image.width) src_x = image.width - WriteWindow->Width - WriteWindow->LeftEdge; } break; case CURSORLEFT: if(src_x > 0) { src_x -= 8; if(src_x < 0) src_x = 0; } break; case CURSORDOWN: if(src_y + WriteWindow->Height + WriteWindow->TopEdge < image.height) { src_y += 8; if(src_y + WriteWindow->Height + WriteWindow->TopEdge > image.height) src_y = image.height - WriteWindow->Height - WriteWindow->TopEdge; } break; case CURSORUP: if(src_y > 0) { src_y -= 8; if(src_y < 0) src_y = 0; } break; } if((old_src_x != src_x) || (old_src_y != src_y)) { if(old_src_x < src_x) { ClipBlit( WriteWindow->RPort, src_x - old_src_x, 0, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, old_src_x + WriteWindow->Width + WriteWindow->LeftEdge, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), 0, src_x - old_src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_x > src_x) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, old_src_x - src_x, 0, WriteWindow->Width + WriteWindow->LeftEdge - (old_src_x - src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, old_src_x - src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_y < src_y) { ClipBlit( WriteWindow->RPort, 0, src_y - old_src_y, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), 0xc0); WritePixelArray( image.colormap, src_x, old_src_y + WriteWindow->Height + WriteWindow->TopEdge, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), WriteWindow->Width + WriteWindow->LeftEdge, src_y - old_src_y, RECTFMT_RGBA); } else if(old_src_y > src_y) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, 0, old_src_y - src_y, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (old_src_y - src_y), 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, old_src_y - src_y, RECTFMT_RGBA); } } break; case IDCMP_MOUSEBUTTONS: done = TRUE; break; } ReplyMsg (&IntMsg->ExecMessage); } } /* cleanup */ CloseWindow(WriteWindow); CloseScreen(CyberScreen); CloseLibrary(CyberGfxBase); CloseLibrary(&IntuitionBase->LibNode); Cleanup(&image); return 0; }
// 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); }
int main(int argc,char **argv) { font_data *data; // Need dopus library if (!(DOpusBase=OpenLibrary("dopus5.library",LIB_VERSION))) if (!(DOpusBase=OpenLibrary("dopus5:libs/dopus5.library",55))) return(10); #ifdef __amigaos4__ if (!(IDOpus = (struct DOpusIFace *)GetInterface(DOpusBase, "main", 1, NULL))) { CloseLibrary(DOpusBase); return(10); } #endif // Allocate data if (!(data=AllocVec(sizeof(font_data),MEMF_CLEAR))) { font_free(0); return(5); } // Parse arguments data->args= ReadArgs( "FONT,SIZE/N,B=BOLD/S,I=ITALIC/S,U=ULINE/S,PUBSCREEN/K", (APTR)data->arg_array, NULL); // Default to topaz 8 #ifdef __AROS__ strcpy(data->font_name,"ttcourier.font"); #else strcpy(data->font_name,"topaz.font"); #endif data->font_size=8; // Got font name? if (data->arg_array[ARG_FONT]) font_get_name(data,(char *)data->arg_array[ARG_FONT]); // Got a font size? if (data->arg_array[ARG_SIZE] && *((long *)data->arg_array[ARG_SIZE])) { data->font_size=*((long *)data->arg_array[ARG_SIZE]); data->first=TRUE; } // Initialise locale init_locale_data(&data->locale); // Got locale library? if (LocaleBase) { BPTR lock; // Change PROGDIR: to dopus5: if ((lock=Lock("dopus5:",ACCESS_READ))) #ifdef __AROS__ // the lock returned here is the initial PROGDIR: which belongs to the system, // so it's not a very good idea to just UnLock it SetProgramDir(lock); #else UnLock(SetProgramDir(lock)); #endif // Initialise data->locale.li_LocaleBase=LocaleBase; data->locale.li_Catalog=OpenCatalogA(0,"viewfont.catalog",0); data->locale.li_Locale=OpenLocale(0); } // Create message port data->appport=CreateMsgPort(); // Open window if (!(font_open(data))) { font_free(data); return(5); } // Initial gadget settings if (data->arg_array[ARG_BOLD]) SetGadgetValue(data->list,GAD_FONT_BOLD,1); if (data->arg_array[ARG_ITALIC]) SetGadgetValue(data->list,GAD_FONT_ITALIC,1); if (data->arg_array[ARG_ULINE]) SetGadgetValue(data->list,GAD_FONT_ULINE,1); // Show font font_show_font(data,FALSE); // Initialise refresh hook data->refresh_hook.h_Entry=(ULONG (*)())font_refresh; data->refresh_hook.h_Data=data; // Event loop FOREVER { struct IntuiMessage *msg; BOOL quit_flag=FALSE; // AppWindow? if (data->appwindow) { struct AppMessage *amsg; // Get messages while ((amsg=(struct AppMessage *)GetMsg(data->appport))) { // Got file? if (amsg->am_NumArgs>0) { char buf[256]; // Get name DevNameFromLockDopus(amsg->am_ArgList[0].wa_Lock,buf,256); if (amsg->am_ArgList[0].wa_Name && *amsg->am_ArgList[0].wa_Name) AddPart(buf,amsg->am_ArgList[0].wa_Name,256); // Get font name font_get_name(data,buf); // Get new font font_get_font(data); font_show_font(data,FALSE); } // Reply to message ReplyMsg((struct Message *)amsg); } } // Requester? if (data->about) { // Handle requester if (SysReqHandler(data->about,0,0)>=0) { // Close requester FreeSysRequest(data->about); data->about=NULL; } } // Intuition messages if (data->window) { while ((msg=GetWindowMsg(data->window->UserPort))) { struct IntuiMessage msg_copy; UWORD id=0; // Copy message and reply msg_copy=*msg; ReplyWindowMsg(msg); // Get gadget ID if (msg_copy.Class==IDCMP_GADGETUP) id=((struct Gadget *)msg_copy.IAddress)->GadgetID; // Look at message switch (msg_copy.Class) { // Close window case IDCMP_CLOSEWINDOW: quit_flag=TRUE; break; // New size case IDCMP_NEWSIZE: // Redraw font font_show_font(data,FALSE); // Set flag to say we resized data->resized=TRUE; break; // Menu case IDCMP_MENUPICK: { struct MenuItem *item; // Get item if (!(item=ItemAddress(data->window->MenuStrip,msg_copy.Code))) break; // Get ID id=GTMENUITEM_USERDATA(item); // Fall through } // Gadget case IDCMP_GADGETUP: switch (id) { // Show requester case GAD_FONT_FONT_POPUP: case MENU_OPEN_FONT: // Ask for name font_ask_name(data); break; // Font name typed case GAD_FONT_FONT: // Get name font_get_name(data,(char *)GetGadgetValue(data->list,GAD_FONT_FONT)); // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Font size up/down case GAD_FONT_UP: case GAD_FONT_DOWN: { short size; // Get next size size=font_get_size(data,(id==GAD_FONT_UP)?1:-1); // No change? if (size==data->font_size) break; // Use this size data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,size); } // Font size given case GAD_FONT_CYCLE: // Check id if (id==GAD_FONT_CYCLE) { short size; // Get size if (!(size=atoi(data->size_labels[msg_copy.Code]))) break; // Refresh gadget data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,data->font_size); } // Font size case GAD_FONT_SIZE: // Entered size if (id==GAD_FONT_SIZE) { // Bounds check gadget data->font_size= BoundsCheckGadget( data->list, GAD_FONT_SIZE, 4, 255); } // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Styles changed case GAD_FONT_BOLD: case GAD_FONT_ITALIC: case GAD_FONT_ULINE: // Redraw font font_show_font(data,FALSE); break; // Save settings case MENU_SAVE_SETTINGS: font_save_settings(data); break; // Quit case MENU_QUIT: quit_flag=TRUE; break; // About case MENU_ABOUT: font_show_about(data); break; } break; // Rawkey case IDCMP_RAWKEY: // Help? if (msg_copy.Code==0x5f) font_show_about(data); // Key case IDCMP_VANILLAKEY: // Escape does quit if (msg_copy.Code==0x1b) quit_flag=TRUE; break; // Refresh case IDCMP_REFRESHWINDOW: // Have we just resized? if (data->resized) { // Don't need to refresh BeginRefresh(data->window); EndRefresh(data->window,TRUE); data->resized=FALSE; break; } // Refresh font display font_show_font(data,TRUE); break; } // Check window is still valid if (!data->window) break; } } if (quit_flag) break; // Wait for signal (ctrl-c breaks) if ((Wait(SIGBREAKF_CTRL_C| ((data->window)?(1<<data->window->UserPort->mp_SigBit):0)| ((data->about)?(1<<data->about->UserPort->mp_SigBit):0)| ((data->appwindow)?(1<<data->appport->mp_SigBit):0)))&SIGBREAKF_CTRL_C) break; } // Free stuff font_free(data); return(0); }
static int _glfwProcessEvents( void ) { struct IntuiMessage message, *tmp_message = NULL; struct MsgPort *msg_port; int win_closed = GL_FALSE, action; int x, y; // Examine pending messages msg_port = _glfwWin.Window->UserPort; while( (tmp_message = (struct IntuiMessage *) GetMsg( msg_port )) ) { // Copy contents of message structure message = *tmp_message; // Now reply to the message (we don't need it anymore) ReplyMsg( (struct Message *) tmp_message ); // Handle different messages switch( message.Class ) { // Was the window activated? case IDCMP_ACTIVEWINDOW: _glfwWin.Active = GL_TRUE; break; // Was the window deactivated? case IDCMP_INACTIVEWINDOW: _glfwWin.Active = GL_FALSE; _glfwInputDeactivation(); break; // Did we get a keyboard press or release? case IDCMP_RAWKEY: action = (message.Code & 0x80) ? GLFW_RELEASE : GLFW_PRESS; message.Code &= 0x7F; _glfwInputKey( _glfwTranslateKey( &message ), action ); _glfwInputChar( _glfwTranslateChar( &message ), action ); break; // Was the mouse moved? case IDCMP_MOUSEMOVE: x = message.MouseX; y = message.MouseY; if( _glfwWin.PointerHidden ) { // When pointer is hidden, we get delta moves x += _glfwInput.MousePosX; y += _glfwInput.MousePosY; } else if( x < 0 || x >= _glfwWin.Width || y < 0 || y >= _glfwWin.Height ) { // Only report mouse moves that are INSIDE client area break; } if( x != _glfwInput.MousePosX || y != _glfwInput.MousePosY ) { _glfwInput.MousePosX = x; _glfwInput.MousePosY = y; if( _glfwWin.MousePosCallback ) { _glfwWin.MousePosCallback( x, y ); } } break; // Did we get a mouse button event? case IDCMP_MOUSEBUTTONS: switch( message.Code ) { case SELECTUP: _glfwInputMouseClick( GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE ); break; case SELECTDOWN: _glfwInputMouseClick( GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS ); break; case MENUUP: _glfwInputMouseClick( GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE ); break; case MENUDOWN: _glfwInputMouseClick( GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS ); break; default: break; } break; // Was the window size changed? case IDCMP_NEWSIZE: _glfwWin.Width = message.IDCMPWindow->GZZWidth; _glfwWin.Height = message.IDCMPWindow->GZZHeight; if( _glfwWin.WindowSizeCallback ) { _glfwWin.WindowSizeCallback( _glfwWin.Width, _glfwWin.Height ); } break; // Was the window contents damaged? case IDCMP_REFRESHWINDOW: // Intuition wants us to do this... BeginRefresh( _glfwWin.Window ); EndRefresh( _glfwWin.Window, TRUE ); // Call user callback function if( _glfwWin.WindowRefreshCallback ) { _glfwWin.WindowRefreshCallback(); } break; // Was the window closed? case IDCMP_CLOSEWINDOW: win_closed = GL_TRUE; break; default: break; } } // Return GL_TRUE if window was closed return( win_closed ); }
// 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); }
// 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); }
// Progress window task void __saveds progress_task(void) { IPCData *ipc; ProgressWindow *prog; IPCMessage *msg; // Do startup if (!(ipc=L_IPC_ProcStartup((ULONG *)&prog,0))) return; // Fix A4 pointer putreg(REG_A4,prog->pw_A4); /* // Debug? if (prog->pw_Flags&PWF_DEBUG) KPrintF("progress task : code entry %lx\n",(ULONG)progress_task); */ // Open invisibly? if (prog->pw_Flags&PWF_INVISIBLE) prog->pw_Flags&=~PWF_INVISIBLE; // Open progress window else progress_open(prog); // Loop for messages FOREVER { BOOL quit=0; // Window open? if (prog->pw_Window) { struct IntuiMessage *msg; // Look for messages while (msg=(struct IntuiMessage *)GetMsg(prog->pw_Window->UserPort)) { // Look at message switch (msg->Class) { // Key press case IDCMP_RAWKEY: // If not escape, break if (msg->Code!=0x45) break; // Abort case IDCMP_CLOSEWINDOW: case IDCMP_GADGETUP: // Task to signal? if (prog->pw_SigTask) Signal(prog->pw_SigTask,1<<prog->pw_SigBit); // Set flag prog->pw_Flags|=PWF_ABORTED; break; // Refresh case IDCMP_REFRESHWINDOW: // Refresh window BeginRefresh(prog->pw_Window); progress_draw(prog,PWF_ALL); EndRefresh(prog->pw_Window,TRUE); break; } // Reply the message ReplyMsg((struct Message *)msg); } } // Any messages? while (msg=(IPCMessage *)GetMsg(ipc->command_port)) { // Look at message switch (msg->command) { // Hide case IPC_HIDE: progress_close(prog); break; // Show case IPC_SHOW: progress_open(prog); break; // Quit case IPC_QUIT: quit=1; break; // Set parameters case PROGRESS_SET: progress_set(prog,(struct TagItem *)msg->data); break; // Get parameters case PROGRESS_GET: progress_get(prog,(struct TagItem *)msg->data); break; } // Reply to the message IPC_Reply(msg); } // Quit? if (quit) break; // Wait for messages Wait( 1<<ipc->command_port->mp_SigBit| ((prog->pw_Window)?1<<prog->pw_Window->UserPort->mp_SigBit:0)); } // Close window progress_close(prog); // Free IPC data IPC_Free(ipc); // Free control structure FreeVec(prog); }