int switchDebug( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { PtArg_t args[2]; int *value; extern int errprt; /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; /* get the value of the widget */ PtSetArg(&args[0], Pt_ARG_ONOFF_STATE, &value, 0); PtGetResources(widget, 1, &args[0]); /* change the text of the widget to reflect current state */ if(*value) { PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Debug\nOn", 0); PtSetArg(&args[1], Pt_ARG_FILL_COLOR, Pg_GREEN, 0); PtSetResources(widget, 2, args); errprt = 1; /* create a stateDebugWindow if switch is on */ if(!debugWindow) { debugWindow = ApCreateModule(ABM_stateDebugWindow, widget, cbinfo); } /* enable the debugging timer */ PtSetArg(&args[0], Pt_ARG_TIMER_INITIAL, 15, 0); PtSetResources(ABW_stateDebugTimer, 1, &args[0]); } else { PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Debug\nOff", 0); PtSetArg(&args[1], Pt_ARG_FILL_COLOR, Pg_RED, 0); PtSetResources(widget, 2, args); errprt = 0; /* destroy the stateDebugWindow if it is displayed */ if(debugWindow) { PtDestroyWidget(debugWindow); debugWindow = (PtWidget_t *)NULL; } if(debugDialog) { PtDestroyWidget(debugDialog); debugDialog = (PtWidget_t *)NULL; } /* disable the debugging timer */ PtSetArg(&args[0], Pt_ARG_TIMER_INITIAL, 0, 0); PtSetResources(ABW_stateDebugTimer, 1, &args[0]); } return( Pt_CONTINUE ); }
static void ph_VideoQuit(_THIS) { /* restore palette */ if (desktopbpp==8) { PgSetPalette(syspalph, 0, -1, 0, 0, 0); PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); PgFlush(); } ph_DestroyImage(this, SDL_VideoSurface); if (window) { PtUnrealizeWidget(window); PtDestroyWidget(window); window=NULL; } if (phevent!=NULL) { SDL_free(phevent); phevent=NULL; } }
NS_IMETHODIMP EmbedWindow::OnHideTooltip(void) { if (sTipWindow) PtDestroyWidget(sTipWindow); sTipWindow = NULL; return NS_OK; }
/* virtual */ void nsWidget::DestroyNative( void ) { if( mWidget ) { // prevent the widget from causing additional events mEventCallback = nsnull; //EnableDamage( mWidget, PR_FALSE ); PtDestroyWidget( mWidget ); //EnableDamage( mWidget, PR_TRUE ); mWidget = nsnull; } }
NS_IMETHODIMP EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) { nsAutoString tipText ( aTipText ); const char* tipString = ToNewCString(tipText), *font = "TextFont08"; PtArg_t args[10]; PhRect_t extent; PhDim_t dim; PhPoint_t pos = {0, 0}; int n = 0, w, h; if (sTipWindow) PtDestroyWidget(sTipWindow); // get the root origin for this content window nsCOMPtr<nsIWidget> mainWidget; mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget)); PtWidget_t *window; window = static_cast<PtWidget_t *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW)); PgExtentText(&extent, &pos, font, tipString, 0); w = extent.lr.x - extent.ul.x + 1; h = extent.lr.y - extent.ul.y + 1; n = 0; pos.x = aXCoords; pos.y = aYCoords + 10; /* we add 10 so that we don't position it right under the mouse */ dim.w = w + 6; dim.h = h + 6; PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0); PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0); PtSetArg( &args[n++], Pt_ARG_REGION_OPAQUE, Ph_EV_EXPOSE, Ph_EV_EXPOSE); sTipWindow = PtCreateWidget(PtRegion, Pt_NO_PARENT, n, args); n = 0; pos.x = pos.y = 0; dim.w = w; dim.h = h; PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0); PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0); PtSetArg(&args[n++], Pt_ARG_FLAGS, Pt_HIGHLIGHTED, -1 ); PtSetArg(&args[n++], Pt_ARG_FILL_COLOR, 0xfeffb1, 0); PtSetArg(&args[n++], Pt_ARG_TEXT_FONT, font, 0); PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, tipString, 0); PtSetArg(&args[n++], Pt_ARG_BASIC_FLAGS, Pt_STATIC_GRADIENT | Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE | Pt_RIGHT_OUTLINE | Pt_BOTTOM_OUTLINE, -1 ); PtCreateWidget(PtLabel, sTipWindow, n, args); // realize the widget PtRealizeWidget(sTipWindow); nsMemory::Free( (void*)tipString ); return NS_OK; }
int tblSetSize(PtWidget_t *scrollCon, int cols, int rows) { tblWidget_t *tbl = NULL; int i, j; assert(cols >= 0 && rows >= 0); if (PtGetResource(scrollCon, Pt_ARG_POINTER, &tbl, 0) != 0) return 0; /* destroy all sub-widgets */ for (i = 0; i < tbl->cols; i++) { for (j = 0; j < tbl->rows; j++) { PtDestroyWidget(tbl->m[i][j]); } free(tbl->m[i]); free(tbl->m_type[i]); } free(tbl->m); free(tbl->m_type); if ((tbl->cols = cols) == 0 || (tbl->rows = rows) == 0) return 1; if ((tbl->m = (PtWidget_t ***)malloc( sizeof(PtWidget_t **) * tbl->cols)) == NULL) PtExit(EXIT_FAILURE); if ((tbl->m_type = (PtWidgetClassRef_t ***)malloc( sizeof(PtWidgetClassRef_t **) * tbl->cols)) == NULL) PtExit(EXIT_FAILURE); for (i = 0; i < tbl->cols; i++) { if ((tbl->m[i] = (PtWidget_t **)calloc( tbl->rows, sizeof(PtWidget_t *))) == NULL) PtExit(EXIT_FAILURE); if ((tbl->m_type[i] = (PtWidgetClassRef_t **)calloc( tbl->rows, sizeof(PtWidgetClassRef_t *))) == NULL) PtExit(EXIT_FAILURE); } PtReRealizeWidget(scrollCon); return 1; }
void freeTableAndContent(PtWidget_t *tbl) { int col_max = tblLastCol(tbl); int x; /* free the structures in the first table line */ for (x = 0; x <= col_max; ++x) { t_xml_info *info = NULL; tblGetCellResource(tbl, x, 0, Pt_ARG_POINTER, &info, 0); assert(info != NULL); assert(info->source != NULL); xmlFree(info->source); free(info); } PtDestroyWidget(tbl); }
int closeDebugWindow( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { PhWindowEvent_t *winEvent; PtArg_t args[2]; int i, j; extern int errprt; /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; /* get pointer to the window event structure */ winEvent = (PhWindowEvent_t *)cbinfo->cbdata; /* check to see which type event evoked this callback */ if(winEvent->event_f == Ph_WM_CLOSE) { /* zero out the chainStates array */ for(i = 0; i < MAXCHAIN; i++) { for(j = 0; j < 64; j++) { chainStates[i][j].stateButton = (PtWidget_t *)NULL; chainStates[i][j].stateIndex = -1; } } /* set the debug button to off */ PtSetArg(&args[0], Pt_ARG_ONOFF_STATE, 0, 0); PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Debug\nOff", 0); PtSetResources(ABW_debugOnOffButton, 2, args); errprt = 0; debugWindow = (PtWidget_t *)NULL; if(debugDialog) { PtDestroyWidget(debugDialog); debugDialog = (PtWidget_t *)NULL; } } return( Pt_CONTINUE ); }
static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { const struct ColourMasks* mask; /* Lock the event thread, in multi-threading environments */ SDL_Lock_EventThread(); current->flags = flags; /* if we do not have desired fullscreen mode, then fallback into window mode */ if (((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && (ph_GetVideoMode(width, height, bpp)==0)) { current->flags &= ~SDL_FULLSCREEN; current->flags &= ~SDL_NOFRAME; current->flags &= ~SDL_RESIZABLE; } ph_SetupWindow(this, width, height, current->flags); mask = ph_GetColourMasks(bpp); if (mask != NULL) { SDL_ReallocFormat(current, mask->bpp, mask->red, mask->green, mask->blue, 0); } else { SDL_SetError("ph_SetVideoMode(): desired bpp is not supported by photon !\n"); return NULL; } #ifdef HAVE_OPENGL if ((current->flags & SDL_OPENGL)==SDL_OPENGL) { #else if ((current->flags & SDL_OPENGL)==SDL_OPENGL) /* if no built-in OpenGL support */ { SDL_SetError("ph_SetVideoMode(): no OpenGL support, try to recompile library.\n"); current->flags &= ~SDL_OPENGL; return NULL; #endif /* HAVE_OPENGL */ } else { /* Initialize internal variables */ if ((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { if (bpp==8) { desktoppal=SDLPH_PAL_SYSTEM; } current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */ current->flags |= SDL_HWSURFACE; } else { /* remove this if we'll support non-fullscreen sw/hw+doublebuf */ current->flags &= ~SDL_DOUBLEBUF; /* Use offscreen memory if SDL_HWSURFACE flag is set */ if ((current->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { if (desktopbpp!=bpp) { current->flags &= ~SDL_HWSURFACE; } } /* using palette emulation code in window mode */ if (bpp==8) { if (desktopbpp>=15) { desktoppal = SDLPH_PAL_EMULATE; } else { desktoppal = SDLPH_PAL_SYSTEM; } } else { desktoppal = SDLPH_PAL_NONE; } } } current->w = width; current->h = height; if (desktoppal==SDLPH_PAL_SYSTEM) { current->flags|=SDL_HWPALETTE; } /* Must call at least once for setup image planes */ if (ph_SetupUpdateFunction(this, current, current->flags)==-1) { return NULL; } /* finish window drawing, if we are not in fullscreen, of course */ if ((current->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { PtFlush(); } else { PgFlush(); } SDL_Unlock_EventThread(); /* We're done! */ return (current); } static void ph_VideoQuit(_THIS) { /* restore palette */ if (desktopbpp==8) { PgSetPalette(syspalph, 0, -1, 0, 0, 0); PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); PgFlush(); } ph_DestroyImage(this, SDL_VideoSurface); if (window) { PtUnrealizeWidget(window); PtDestroyWidget(window); window=NULL; } if (event!=NULL) { free(event); event=NULL; } } static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) { int i; SDL_Rect updaterect; updaterect.x = updaterect.y = 0; updaterect.w = this->screen->w; updaterect.h = this->screen->h; /* palette emulation code, using palette of the PhImage_t struct */ if (desktoppal==SDLPH_PAL_EMULATE) { if ((SDL_Image) && (SDL_Image->palette)) { for (i=firstcolor; i<firstcolor+ncolors; i++) { syspalph[i] = PgRGB(colors[i-firstcolor].r, colors[i-firstcolor].g, colors[i-firstcolor].b); SDL_Image->palette[i] = syspalph[i]; } /* image needs to be redrawn */ this->UpdateRects(this, 1, &updaterect); } } else { if (desktoppal==SDLPH_PAL_SYSTEM) { for (i=firstcolor; i<firstcolor+ncolors; i++) { syspalph[i] = PgRGB(colors[i-firstcolor].r, colors[i-firstcolor].g, colors[i-firstcolor].b); } if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { /* window mode must use soft palette */ PgSetPalette(&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0); /* image needs to be redrawn */ this->UpdateRects(this, 1, &updaterect); } else { /* fullscreen mode must use hardware palette */ PgSetPalette(&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0); } } else { /* SDLPH_PAL_NONE do nothing */ } } return 1; }
/***************************************************************************** * QNXCreateWnd: create and realize the main window *****************************************************************************/ static int QNXCreateWnd( vout_thread_t * p_vout ) { PtArg_t args[8]; PhPoint_t pos = { 0, 0 }; PgColor_t color = Pg_BLACK; if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY ) { if( p_vout->p_sys->i_vc_flags & Pg_SCALER_CAP_DST_CHROMA_KEY ) { color = PgGetOverlayChromaColor(); } } /* fullscreen, set dimension */ if( p_vout->b_fullscreen ) { p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w; p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h; p_vout->output.i_width = p_vout->p_sys->dim.w = p_vout->p_sys->screen_dim.w; p_vout->output.i_height = p_vout->p_sys->dim.h = p_vout->p_sys->screen_dim.h; } /* set window parameters */ PtSetArg( &args[0], Pt_ARG_POS, &pos, 0 ); PtSetArg( &args[1], Pt_ARG_DIM, &p_vout->p_sys->dim, 0 ); PtSetArg( &args[2], Pt_ARG_FILL_COLOR, color, 0 ); PtSetArg( &args[3], Pt_ARG_WINDOW_TITLE, "VLC media player", 0 ); PtSetArg( &args[4], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE ); PtSetArg( &args[5], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_CLOSE ); PtSetArg( &args[6], Pt_ARG_WINDOW_RENDER_FLAGS, p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE ); /* create window */ p_vout->p_sys->p_window = PtCreateWidget( PtWindow, Pt_NO_PARENT, 7, args); if( p_vout->p_sys->p_window == NULL ) { msg_Err( p_vout, "unable to create window" ); return( 1 ); } /* realize the window widget */ if( PtRealizeWidget( p_vout->p_sys->p_window ) != 0 ) { msg_Err( p_vout, "unable to realize window widget" ); PtDestroyWidget( p_vout->p_sys->p_window ); return( 1 ); } /* get window frame size */ if( PtWindowFrameSize( NULL, p_vout->p_sys->p_window, &p_vout->p_sys->frame ) != 0 ) { msg_Err( p_vout, "unable to get window frame size" ); PtDestroyWidget( p_vout->p_sys->p_window ); return( 1 ); } return( 0 ); }
main(int argc,char *argv[]) { CoolImage *image; int x,y; int i,j; PtWidget_t *win; PtArg_t args[3]; PhDim_t dim={m_W,m_H}; PhPoint_t pos={50,250}; int fd; //Bt878 driver file descriptor int fd_temp; int size_read; struct timeval tv; fd_set rfd; int n; int error; int counter = 0; int counter_mean = 0; int file = 0; //Timing calculation uint64_t cps, cycle1, cycle2, ncycles; float sec; float msec; // if a paramater was passed, grab it as the blit type if (argc>1) blittype=atoi(argv[1]); // initialize our connection to Photon, and create/realize a window //PtInit("/net/irene2/dev/photon"); PtInit("/dev/photon"); PtSetArg(&args[0],Pt_ARG_POS,&pos,0); PtSetArg(&args[1],Pt_ARG_DIM,&dim,0); win=PtCreateWidget(PtWindow,Pt_NO_PARENT,2,args); PtRealizeWidget(win); // Allocate and fill a series of NUMIMAGES images with a little // fading type animation. Put your own animation in here if you like. /* * Set a 5 second timeout. */ tv.tv_sec = 5; tv.tv_usec = 0; image = AllocBuffer(m_W,m_H,fd); assert(image!=0); if (file != 2) { init_bttvx(2,0, m_W,m_H,0,0); open_bttvx(); BttvxSetImageBuffer(0, image->buffer); } fd_temp = fd; FD_ZERO( &rfd ); FD_SET( fd, &rfd ); while(1) { //fd = open("/net/europa/dev/bttvx0",O_RDWR); //if ( fd > 0 ) //{ ///switch ( n = select( 1 + max( fd,0 ), /// &rfd, 0, 0, &tv ) ) ///{ /// case -1: /// perror( "select" ); /// return EXIT_FAILURE; /// case 0: /// puts( "select timed out" ); /// break; /// default: //printf( "descriptor ready ...\n"); //if( FD_ISSET( console, &rfd ) ) // puts( " -- console descriptor has data pending" ); //if( FD_ISSET( serial, &rfd ) ) // puts( " -- serial descriptor has data pending" ); /* Read the text */ cycle1=ClockCycles( ); //lseek(fd,0L,SEEK_SET); /// size_read = read( fd, image->buffer, W*H*deep ); if (file != 2) { BttvxWaitEvent(); BttvxAcquireBuffer(image->buffer); } switch(file) { case 0: BlitBuffer(win,image); break; case 1: SaveImage(counter,image); break; case 2: LoadImage(counter,image); BlitBuffer(win,image); getchar(); break; }; if (file!=2) BttvxReleaseBuffer(); cycle2=ClockCycles( ); counter++; counter_mean++; ncycles=cycle2-cycle1; //printf("%lld cycles elapsed \n", ncycles); /* find out how many cycles per second */ cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec; //printf( "This system has %lld cycles/sec.\n",cps ); sec=(float)ncycles/cps; msec +=sec; if (counter_mean == 250 ) { msec = msec/counter_mean; printf("The cycles in seconds is %f \n",msec); counter_mean = 0; msec = 0; } //}else //sleep(2); } //printf("Blitted %d frames using method %d\n",REPS*NUMIMAGES,blittype); // now free the images FreeBuffer(image); close( fd ); /// hide the window and destroy it. PtUnrealizeWidget(win); PtDestroyWidget(win); }