Ejemplo n.º 1
0
int initUserRtVarsDialog( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	ApDBase_t *userRtVarsdbase;
	PhPoint_t loc;
	PtArg_t args[2];
	int y;
	int i;

	/* eliminate 'unreferenced' warnings */
	link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;

	/* get the absolute position of the base widget,
	 * place the dialog 100 pixels below the base widget
	 * set the name of the dialog
	 */
	PtGetAbsPosition(ABW_base, &loc.x, &loc.y);
	loc.y += 100;
	PtSetArg(&args[0], Pt_ARG_POS, &loc, 0);
	PtSetArg(&args[1], Pt_ARG_WINDOW_TITLE, cbinfo->cbdata, 0);
	PtSetResources(link_instance, 2, args);

	/* initialize the base timer */
	baseTime = i_b->i_time;

	/* open the user real-time variables data base */
	userRtVarsdbase = ApOpenDBase(ABM_userRtVarsPictures);

	/* set the parent for the widgets */
	PtSetParentWidget(ABW_userRtVarsScrollArea);

	/* create the widget sets for the user real-time variables */
	y = 0;
	i = 0;
	while(strlen(rtvars[i].rt_name)) {
		/* create the label widget for this variable */
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, rtvars[i].rt_name, 0);
		ApCreateWidget(userRtVarsdbase, "userRtVarLabel", 5, y, 1, &args[0]);

		/* create the value widget for this variable */
		rtVarList[i] = ApCreateWidget(userRtVarsdbase, "userRtVarsInt", 200, y, 0, NULL);

		y += 30;
		i++;
	}

	/* set the maximum range of the scroll widget */
	PtSetArg(&args[0], Pt_ARG_SCROLL_AREA_MAX_Y, y, 0);
	PtSetResources(ABW_userRtVarsScrollArea, 1, &args[0]);

	/* close the widget data base */
	ApCloseDBase(userRtVarsdbase);

	return( Pt_CONTINUE );
}
Ejemplo n.º 2
0
int initDASummary( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	ApDBase_t *daSumdbase;
	PtArg_t args[2];
	int y;
	int i;
	int j;
	char label[4];

	/* eliminate 'unreferenced' warnings */
	link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;

	/* open the d to a converter summary data base */
	daSumdbase = ApOpenDBase(ABM_daSumPictures);

	/* set the parent for the widgets */
	PtSetParentWidget(ABW_daSumScrollArea);

	/* create 16 sets of widgets for the da summary */
	y = 0;
	for(i = 0; i < 16; i++) {

		/* create the label widget for this da converter */
		sprintf(label, "%d", i);
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, label, 0);
		ApCreateWidget(daSumdbase, "daSumDAlabel", 10, y, 2, args);

		/* create the source name text widget for this da converter */
		j = da[i].da_source;
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, daSourceNames[j], 0);
		ApCreateWidget(daSumdbase, "daSumDAname", 50, y, 2, args);

		/* create the source number widget for this da converter */
		PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[i].da_src_num, 0);
		ApCreateWidget(daSumdbase, "daSumDAnumber", 138, y, 2, args);

		/* create the mode widget for this da converter */
		PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[i].da_mode, 0);
		ApCreateWidget(daSumdbase, "daSumDAmode", 216, y, 2, args);

		/* create the offset widget for this da converter */
		PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[i].da_offset, 0);
		ApCreateWidget(daSumdbase, "daSumDAoffset", 271, y, 2, args);

		/* crement the y value for widget placement */
		y += 30;
	}

	/* close the widget data base */
	ApCloseDBase(daSumdbase);
	return( Pt_CONTINUE );
}
Ejemplo n.º 3
0
int ph_window_create_display (int bitmap_depth)
{
	PtArg_t arg[9];
	PhRect_t rect;
    PhRegion_t region_info;
    
    // Only image_height??!!
    int image_height;
    int window_width, window_height;

	// Create the Photon Window

	view_size.w = widthscale * visual_width;
	view_size.h = heightscale * visual_height;
	
    image_width      = widthscale  * visual_width;
    image_height     = heightscale * visual_height;
    
    // TODO: Finish always ontop (Make phearbear happy)
	PtSetArg( &arg[0], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
	PtSetArg( &arg[1], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_MAX | Ph_WM_RESIZE | Ph_WM_MENU | Ph_WM_CLOSE | Ph_WM_HIDE );
	PtSetArg( &arg[2], Pt_ARG_DIM, &view_size, 0 );
	PtSetArg( &arg[3], Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_FOCUS, Ph_WM_FOCUS | Ph_WM_RESIZE | Ph_WM_CLOSE );
	PtSetArg( &arg[4], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_MENU | Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_MIN | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RESIZE );
	PtSetArg( &arg[5], Pt_ARG_WINDOW_TITLE, title, 0);
	//PtSetArg( &arg[6], Pt_ARG_WINDOW_STATE, 0, Ph_WM_STATE_ISFRONT );
	
	PtSetParentWidget(NULL);
	if((P_mainWindow = PtCreateWidget(PtWindow, NULL, 6, arg)) == NULL)
		fprintf(stderr,"error: could not create main photon window.\n");

	/* add raw callback handler */
	PtAddEventHandler( P_mainWindow,
		Ph_EV_BUT_PRESS |
		Ph_EV_BUT_RELEASE |
		Ph_EV_BOUNDARY |
		Ph_EV_EXPOSE |
		Ph_EV_PTR_MOTION |
		Ph_EV_KEY |
		Ph_EV_INFO,
		I_GetEvent,
		NULL );

	/* set draw buffer size */
	PgSetDrawBufferSize( 0xFF00 );

	PtRealizeWidget( P_mainWindow );

	if (show_cursor == FALSE)
	{
    	region_info.cursor_type = Ph_CURSOR_NONE;
    	region_info.rid = PtWidgetRid(P_mainWindow);
    	PhRegionChange (Ph_REGION_CURSOR, 0, &region_info, NULL, NULL); // turn off cursor
	}


	/* create and setup the image */
	switch (ph_window_update_method)
	{
		case PH_NORMAL:

//		image = PdCreateOffscreenContext(0, ((view_size.w+7) & ~7), view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
		image = PdCreateOffscreenContext(0, view_size.w, view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
	 	if (image == NULL)
	 	{
			fprintf(stderr_file, "error: failed to create offscreen context\n");
			return OSD_NOT_OK;
		}

		scaled_buffer_ptr = PdGetOffscreenContextPtr (image);
		if (!scaled_buffer_ptr)
		{
			fprintf (stderr_file, "error: failed get a pointer to offscreen context.\n");
			PhDCRelease (image);
			return OSD_NOT_OK;
		}

		depth = 0;

		switch (image->format)
		{
			case Pg_IMAGE_PALETTE_BYTE   :
			// TODO :
			break;
			case Pg_IMAGE_DIRECT_565  :
				depth = 16;
				pixels_per_line = image->pitch >> 1;
			break;
			case Pg_IMAGE_DIRECT_555  :
			// TODO:
			break;
			case Pg_IMAGE_DIRECT_888  :
				depth = 24;
				pixels_per_line = image->pitch / 3;
			break;	
			case Pg_IMAGE_DIRECT_8888 :
				depth = 32;
				pixels_per_line = image->pitch >> 2;
			break;
		}
		break;
	
		default:
			fprintf (stderr_file, "error: unknown photon update method, this shouldn't happen\n");
		return OSD_NOT_OK;
	}

	/* setup the palette_info struct now we have the depth */
	if (ph_init_palette_info() != OSD_OK)
	return OSD_NOT_OK;

	fprintf(stderr_file, "Actual bits per pixel = %d...\n", depth);
    if (bitmap_depth == 32)
   {
      if (depth == 32)
         ph_window_update_display_func = ph_window_update_32_to_32bpp_direct;
   }
	else if (bitmap_depth == 16)
	{
		switch(depth)
		{
			case 16:
				ph_window_update_display_func = ph_window_update_16_to_16bpp;
			break;
			case 24:
				ph_window_update_display_func = ph_window_update_16_to_24bpp;
			break;
			case 32:
				ph_window_update_display_func = ph_window_update_16_to_32bpp;
			break;
		}
	}

	if (ph_window_update_display_func == NULL)
	{
		fprintf(stderr_file, "error: unsupported\n");
		return OSD_NOT_OK;
	}

	fprintf(stderr_file, "Ok\n");

	return OSD_OK;
}