Esempio n. 1
0
/* Create our toolbar */
void init_call_info(void) {
  pghandle bArrowMask,bArrow;
    
  /* Set up a bitmap/bitmask for the keypad button up arrow.
   * We have the mask stored in PNM format, and we paint
   * the arrow bitmap itself solid black. If we wanted another
   * color for the arrow, we could paint it that other color,
   * then apply the bitmask to it with the PG_LGOP_INVERT_AND
   * logical operation to mask out only the arrow part.
   */
  bArrowMask = pgNewBitmap(pgFromMemory(arrow_bits,arrow_len));
  bArrow = pgCreateBitmap(11,6);
  pgRender(bArrow,PG_GROP_SETCOLOR,0x000000);
  pgRender(bArrow,PG_GROP_RECT,0,0,15,8);

  /* Create a toolbar that starts out hidden */
  wInfoBar = pgRegisterApp(PG_APP_TOOLBAR,"pgtuxphone/call_info",
			   PG_APPSPEC_SIDE, PG_S_BOTTOM,
			   0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIZE,0,
	      0);
  
  /* Create widgets within the toolbar */
  
  wKeypadBtn = pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_BITMAP, bArrow,
	      PG_WP_BITMASK, bArrowMask,
	      PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE,
	      PG_WP_TEXT,pgNewString("Keypad"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnKeypad,NULL);
  
  pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_TEXT,pgNewString("Redial"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnRedial,NULL);

  /* Make the connect time opaque and fixed-width to minimize the
   * amount of redrawing necessary to update it */
  wConnectTime = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TRANSPARENT,0,
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_FONT,pgNewFont(NULL,0,PG_FSTYLE_FIXED),
	      0);
  wCallStatus = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  wName = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_FONT,pgNewFont(NULL,12,0),
	      0);

  wPhoneNumber = pgNewWidget(PG_WIDGET_CANVAS,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_ALL,
	      0);
  new_vfd_label(wPhoneNumber);

}
Esempio n. 2
0
SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	if ( this->hidden->bitmap ) {
	  /* Free old bitmap */
	  if (current->pixels) {
	    shmdt(current->pixels);
	    current->pixels = NULL;
	  }
	  pgDelete(this->hidden->bitmap);
	}

	/* Allocate the new pixel format for the screen */
	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
		SDL_SetError("Couldn't allocate new pixel format for requested mode");
		return(NULL);
	}

	/* Create a new picogui bitmap */
	this->hidden->bitmap = pgCreateBitmap(width,height);
	this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap);
	current->pixels = shmat(shmget(this->hidden->shm.shm_key,
				       this->hidden->shm.shm_length,0),NULL,0);

	/* Reset the canvas, and draw persistent and incremental grops.
	 * Use mapping and offsets to center it.
	 */

	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0);

	/* 0. Set the source position during incremental rendering
	 */
	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC,0,0,0,0);
	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);

	/* 1. Incremental bitmap rendering
	 */
	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
		   0,0,0,0,this->hidden->bitmap);
	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);

	/* 2. Normal bitmap rendering
	 */
	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
		   0,0,this->hidden->shm.width,this->hidden->shm.height,this->hidden->bitmap);
     
	/* Set up the new mode framebuffer */
	current->flags = 0;
	current->w = this->hidden->shm.width;
	current->h = this->hidden->shm.height;
	current->pitch = this->hidden->shm.pitch;

	/* Set up pixel format */
	current->format->BitsPerPixel = this->hidden->shm.bpp;
	current->format->BytesPerPixel = this->hidden->shm.bpp >> 3;
	if (this->hidden->shm.bpp & 7)
	  current->format->BytesPerPixel++;
	current->format->palette = NULL;
	current->format->Rmask = this->hidden->shm.red_mask;
	current->format->Gmask = this->hidden->shm.green_mask;
	current->format->Bmask = this->hidden->shm.blue_mask;
	current->format->Amask = this->hidden->shm.alpha_mask;
	current->format->Rshift = this->hidden->shm.red_shift;
	current->format->Gshift = this->hidden->shm.green_shift;
	current->format->Bshift = this->hidden->shm.blue_shift;
	current->format->Ashift = this->hidden->shm.alpha_shift;
	current->format->Rloss = 8 - this->hidden->shm.red_length;
	current->format->Gloss = 8 - this->hidden->shm.green_length;
	current->format->Bloss = 8 - this->hidden->shm.blue_length;
	current->format->Aloss = 8 - this->hidden->shm.alpha_length;

	/* Draw the app */
	pgUpdate();

	/* We're done */
	return(current);
}