Example #1
0
void initCellButtons(PtWidget_t *thisModule, PAGE *thisPage, int newRasters)
{
	PtWidget_t *cellButton;
	PtArg_t args[2];
	CELL *thisCell;
	PLOT *thisPlot;
	int cellIndex;
	int cellButtonName;
	int i, j;
	char string[16];

	/* set the values on the cell buttons */
	/* first, disable all of the cell buttons
	 * and set the labels to ---
	 */
	strcpy(string, "------");
	PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_GHOST | Pt_BLOCKED);
	PtSetArg(&args[1], Pt_ARG_TEXT_STRING, &string, 0);
	for(i = 0; i < 64; i++) {
		cellButtonName = getCellButtonName(i);
		cellButton = ApGetWidgetPtr(thisModule, cellButtonName);
		if(!cellButton) continue; /* skip bad widgets */

		PtSetResources(cellButton, 2, args);
	}

	/* now enable only the buttons for the number of rows and columns
	 * that the user selected
	 */
	PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_GHOST | Pt_BLOCKED);
	for(i = 0; i < thisPage->nRows; i++) {
		for(j = 0; j < thisPage->nCols; j++) {
			cellIndex = (i * 8) + j;
			cellButtonName = getCellButtonName(cellIndex);
			cellButton = ApGetWidgetPtr(thisModule, cellButtonName);
			if(!cellButton) continue; /* skip bad widgets */

			PtSetResources(cellButton, 1, args);
		}
	}

	/* if the raster definition has been read from a root
	 * label the button with the set and ecode
	 */
	if(!newRasters) {
		for(i = 0; i < thisPage->nDefCells; i++) {
			thisCell = getRasterCell(thisPage->cellsInfo, i);
			thisPlot = &thisCell->plotInfo;
			cellButtonName = getCellButtonName(thisCell->RCindex);
			cellButton = ApGetWidgetPtr(thisModule, cellButtonName);
			if(!cellButton) continue;	/* skip bad widgets */

			sprintf(string, "%d:%d", thisPlot->setNum, thisPlot->cCode);
			PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &string, 0);
			PtSetResources(cellButton, 1, args);
		}
	}
	
	return;
}
Example #2
0
int setDir( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[1];
	char *string;

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

	/* get the directory */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &string, 0);
	PtGetResources(widget, 1, args);

	/* set the directory part of the file name */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, string, 0);
	PtSetResources(ABW_fileSelFileName, 1, args);

	/* set the root directory of the file selection widget */
	PtSetArg(&args[0], Pt_ARG_FS_ROOT_DIR, string, 0);
	PtSetResources(ABW_fileSelFileList, 1, args);

	/* save the new directory */
	strcpy(rootDir, string);

	return( Pt_CONTINUE );
}
Example #3
0
int initRootRead( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int fileFlag;
	char wd[PATH_MAX + 2];

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

	/* get the current working directory */
	getcwd(wd, PATH_MAX+1);

	if(!strlen(rootDir)) {
		strcpy(rootDir, wd);
		strcat(rootDir, "/rt");
	}
	PtSetArg(&args[0], Pt_ARG_FS_ROOT_DIR, rootDir, 0);
	PtSetResources(ABW_fileSelFileList, 1, args);

	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, rootDir, 0);
	PtSetResources(ABW_fileSelDirText, 1, args);
	PtSetResources(ABW_fileSelFileName, 1, args);

	/* set the user data to indicate a root file read */
	fileFlag = ROOT_FILE_READ;
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &fileFlag, sizeof(int));
	PtSetResources(ABW_fileSelFileName, 1, args);
	PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Open File", 0);
	PtSetResources(ABW_fileSelOpenBtn, 2, args);

	return( Pt_CONTINUE );
}
Example #4
0
int initRasterSave( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int fileFlag;
	char dir[80];

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

	strcpy(dir, "/");
	PtSetArg(&args[0], Pt_ARG_FS_ROOT_DIR, dir, 0);
	PtSetResources(ABW_fileSelFileList, 1, args);

	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, dir, 0);
	PtSetResources(ABW_fileSelDirText, 1, args);
	PtSetResources(ABW_fileSelFileName, 1, args);

	/* set the user data to indicate a root file write */
	fileFlag = RASTER_FILE_SAVE;
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &fileFlag, sizeof(int));
	PtSetResources(ABW_fileSelFileName, 1, args);
	PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Save Raster", 0);
	PtSetResources(ABW_fileSelOpenBtn, 2, args);

	return( Pt_CONTINUE );
}
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 );
}
Example #6
0
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 );
}
Example #7
0
int initStateDebugDialog( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *widget;
	PtArg_t arg;
	int stateIndex;

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

	/* get the widget that initiated the link callback */
	widget = ApWidget(cbinfo);

	/* make sure that the dialog has not been destroyed */
	if(PtWidgetFlags(widget) & Pt_DESTROYED) {
		return( Pt_CONTINUE );
	}

	/* get the state index from the buttons user data */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(widget, 1, &arg);
	stateIndex = *(int *)arg.value;

	/* set the text of the title widget */
	PtSetArg(&arg, Pt_ARG_WINDOW_TITLE, snames[stateIndex]->statename, 0);
	PtSetResources(ABW_stateDebugDialog, 1, &arg);

	/* initialize the widgets in the state dialog */
	stateDebugDialogSetUser(stateIndex);

	return( Pt_CONTINUE );
}
Example #8
0
int showRasterPage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[1];
	PtScrollbarCallback_t *scroll = cbinfo->cbdata;
	RASTER *rasters;
	PAGE *thisPage;
	char string[64];

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

	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* get the current page index from the scroll bar */
	rasters->curPageIndx = scroll->position;
	
	/* get pointer to the current raster page */
	thisPage = getRasterPage(rasters->curPageIndx);

	/* create a window label */
	sprintf(string, "Raster Page %d", rasters->curPageIndx + 1);
	PtSetArg(&args[0], Pt_ARG_WINDOW_TITLE, string, 0);
	PtSetResources(ABW_rastersPage, 1, args);

	/* unset the newRasters flag */
	rasters->newRasters = 0;

	/* set the widget values on the page being shown */
	initPageWidgets(ABW_rastersPage, thisPage, rasters->newRasters);

	return( Pt_CONTINUE );
}
int daConvDialogSet( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int *pDaNum;
	int *value;
	int daNum;

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

	/* get the status of the on-off switch */
	PtSetArg(&args[0], Pt_ARG_ONOFF_STATE, &value, 0);
	PtSetArg(&args[1], Pt_ARG_USER_DATA, &pDaNum, 0);
	PtGetResources(widget, 2, args);
	daNum = *pDaNum;

	if(*value) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Enabled", 0);
		da[daNum].m_da_menu = 1;
	}
	else {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Disabled", 0);
		da[daNum].m_da_menu = 0;
	}
	PtSetResources(widget, 1, args);

	daDialogItemEnable(daNum);

	da_cntrl_1(daNum, NULLI, NULLI);
	da_mode(daNum, NULLI);
	da_offset(daNum, NULLI);

	return( Pt_CONTINUE );
}
Example #10
0
int
timer_activate( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
  PtArg_t args[1];
  float diffsum;
  clock_t diff_time;
  
  isd_poll_all(isdx, &yaw, &pitch, &roll);
  
  iyaw = floor(yaw);
  ipitch = floor(pitch);
  iroll = floor(roll);
  
  PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, iyaw, 0);
  PtSetResources(ABW_yaw_meter, 1, args);
  PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, ipitch, 0);
  PtSetResources(ABW_pitch_meter, 1, args);
  PtSetArg(&args[0], Pt_ARG_GAUGE_VALUE, iroll, 0);
  PtSetResources(ABW_roll_meter, 1, args);
  
  sprintf(yaw_label, "%7.2f", yaw);
  sprintf(pitch_label, "%7.2f", pitch);
  sprintf(roll_label, "%7.2f", roll);
  
  PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &yaw_label, 1);
  PtSetResources(ABW_yaw_label, 1, args);
  
  PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &pitch_label, 1);
  PtSetResources(ABW_pitch_label, 1, args);

  PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &roll_label, 1);
  PtSetResources(ABW_roll_label, 1, args);
	   
  diffsum = abs(yaw - lastyaw);
  diffsum += abs(pitch - lastpitch);
  diffsum += abs(roll - lastroll);
  
  if (diffsum >= REDRAW_THRESHOLD)
    {
      lastyaw = yaw;
      lastpitch = pitch;
      lastroll = roll;
      PtDamageWidget(ABW_rawcube);
      PtFlush();
    }
  
  last_time = this_time;
  this_time = clock();
  
  diff_time = this_time - last_time;
  sprintf(timestring, "%d Hz", CLOCKS_PER_SEC/diff_time);
  PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &timestring, 1);
  PtSetResources(ABW_rate_label, 1, args);
  
  /* eliminate 'unreferenced' warnings */
  widget = widget, apinfo = apinfo, cbinfo = cbinfo;

  return( Pt_CONTINUE );
  
}
Example #11
0
int newPage(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[2];
	RASTER *rasters;
	PAGE *thisPage;
	PAGE *lastPage;
	char string[64];

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

	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* increment the current page index */
	rasters->curPageIndx++;
	
	/* create a window label */
	sprintf(string, "Raster Page %d", rasters->curPageIndx + 1);
	PtSetArg(&args[0], Pt_ARG_WINDOW_TITLE, string, 0);
	PtSetResources(ABW_rastersPage, 1, args);

	/* allocate space for a new page */
	rasters->nPages++;
	rasters->pages = addRasterPage(rasters->pages, rasters->nPages);

	/* set the newRasters flag because a new page has been added */
	rasters->newRasters = 1;
	
	/* initialize the new page with the values from the previous page */
	thisPage = getRasterPage(rasters->curPageIndx);
	lastPage = getRasterPage(rasters->curPageIndx - 1);
	initSubsequentPage(thisPage, lastPage);

	/* set the widget values on the new page */
	initPageWidgets(ABW_rastersPage, thisPage, rasters->newRasters);
	
	/* set the maximum value on the page scroll bar */
	PtSetArg(&args[0], Pt_ARG_MAXIMUM, rasters->nPages - 1, 0);
	PtSetArg(&args[1], Pt_ARG_SCROLL_POSITION, rasters->nPages - 1, 0);
	PtSetResources(ABW_pageScrollBar, 2, args);
	
	return( Pt_CONTINUE );
}
int ph_ShowWMCursor(_THIS, WMcursor* cursor)
{
    PtArg_t args[3];
    int nargs = 0;

    /* Don't do anything if the display is gone */
    if (window == NULL)
    {
        return (0);
    }

    /* looks like photon can't draw mouse cursor in direct mode */
    if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
         /* disable the fake mouse in the fullscreen OpenGL mode */
         if ((this->screen->flags & SDL_OPENGL) == SDL_OPENGL)
         {
             cursor=NULL;
         }
         else
         {
             return (0);
         }
    }

    /* Set the photon cursor, or blank if cursor is NULL */
    if (cursor!=NULL)
    {
        PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
        /* Could set next to any PgColor_t value */
        PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR , 0);
        PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)));
        nargs = 3;
    }
    else /* Ph_CURSOR_NONE */
    {
        PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
        nargs = 1;
    }

    SDL_Lock_EventThread();

    if (PtSetResources(window, nargs, args) < 0 )
    {
        return (0);
    }	

    SDL_Unlock_EventThread();

    return (1);
}
int resetVars( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t arg;
	int i;

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

	baseTime = i_b->i_time;

	/* set the timer widgets */
	PtSetArg(&arg, Pt_ARG_NUMERIC_VALUE, 0, 0);
	PtSetResources(ABW_userRtVarsMin, 1, &arg);
	PtSetArg(&arg, Pt_ARG_NUMERIC_VALUE, 0, 0);
	PtSetResources(ABW_userRtVarsSec, 1, &arg);

	i = 0;
	while(rtvars[i].rt_var) {
		*rtvars[i].rt_var = 0;
		i++;
	}
	return( Pt_CONTINUE );
}
int updateVars( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t arg;
	long msecTime;
	int mins;
	int secs;
	int i;

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

	/* increment the timer */
	msecTime = i_b->i_time - baseTime;

	/* convert to seconds */
	secs = msecTime / 1000;

	/* get minutes */
	mins = secs / 60;

	/* get seconds */
	secs = secs % 60;

	/* set the widgets */
	PtSetArg(&arg, Pt_ARG_NUMERIC_VALUE, mins, 0);
	PtSetResources(ABW_userRtVarsMin, 1, &arg);
	PtSetArg(&arg, Pt_ARG_NUMERIC_VALUE, secs, 0);
	PtSetResources(ABW_userRtVarsSec, 1, &arg);
	
	i = 0;
	while(rtVarList[i]) {
		PtSetArg(&arg, Pt_ARG_NUMERIC_VALUE, *rtvars[i].rt_var, 0);
		PtSetResources(rtVarList[i], 1, &arg);
		i++;
	}
	return( Pt_CONTINUE );
}
Example #15
0
int tblSetDim(PtWidget_t *scrollCon, PhPoint_t pos, PhDim_t dim)
{
  int c = 0;
  PtArg_t argsScrCon[2];
  tblWidget_t *tbl = NULL;

  if (PtGetResource(scrollCon, Pt_ARG_POINTER, &tbl, 0) != 0)
    return 0;

  tbl->geom = pos;
  tbl->dim = dim;

  PtSetArg(&argsScrCon[c++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&argsScrCon[c++], Pt_ARG_DIM, &dim, 0);
  PtSetResources(scrollCon, c, argsScrCon);

  return 1;
}
int
change_sample_rate( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
  PtArg_t args[1];
  PtNumericIntegerCallback_t *cb;
  int timer_rate;
  long timer_rate_long;
  
  /* eliminate 'unreferenced' warnings */
  widget = widget, apinfo = apinfo, cbinfo = cbinfo;
  cb = cbinfo->cbdata;
  timer_rate = cb->numeric_value;
  timer_rate_long = (long) timer_rate;
  
  PtSetArg(&args[0], Pt_ARG_TIMER_REPEAT, timer_rate_long, 0);
  PtSetResources(ABW_global_timer, 1, args);

  return( Pt_CONTINUE );
  
}
int
change_trend_min( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
  PtArg_t args[1];
  short int tmin;
  PtNumericIntegerCallback_t *cb;
  
  /* eliminate 'unreferenced' warnings */
  widget = widget, apinfo = apinfo, cbinfo = cbinfo;

  cb = cbinfo->cbdata;
  tmin = cb->numeric_value;

  // printf("min set to %d\n", tmin);

  PtSetArg(&args[0], Rt_ARG_TREND_MIN, tmin, 1);
  PtSetResources(ABW_position_trend, 1, args);

  return( Pt_CONTINUE );
}
int
file_change_filter( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
  char *newfilter;
  PtArg_t args[2];
  PtFileSelItem_t *rootitem;
  
  /* eliminate 'unreferenced' warnings */
  widget = widget, apinfo = apinfo, cbinfo = cbinfo;

  newfilter = read_text_from_widget(ABW_filter_input);
  // printf("new filter <%s>\n", newfilter);

  rootitem = PtFSRootItem(ABW_file_tree);

  PtSetArg(&args[0], Pt_ARG_FS_FILE_SPEC, newfilter, 0);
  PtSetArg(&args[1], Pt_ARG_FS_REFRESH, rootitem, 0);
  PtSetResources(ABW_file_tree, 2, args);
  
  return( Pt_CONTINUE );
  
}
Example #19
0
//-------------------------------------------------------------------------
//
// Set this component font
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetFont( const nsFont &aFont ) {

    nsIFontMetrics* mFontMetrics;
    mContext->GetMetricsFor(aFont, mFontMetrics);

    if( mFontMetrics ) {
        PtArg_t arg;

        nsFontHandle aFontHandle;
        mFontMetrics->GetFontHandle(aFontHandle);
        nsString *aString;
        aString = (nsString *) aFontHandle;
        char *str = ToNewCString(*aString);

        PtSetArg( &arg, Pt_ARG_TEXT_FONT, str, 0 );
        PtSetResources( mWidget, 1, &arg );

        delete [] str;
        NS_RELEASE(mFontMetrics);
    }
    return NS_OK;
}
Example #20
0
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 );
}
Example #21
0
int getFileName( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[1];
	PtFileSelItem_t *fileName;
	char file[80];

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

	// return immediately on mouse button press
	if(cbinfo->reason_subtype) return(Pt_CONTINUE);

	// process the file name on the mouse button release
	fileName = PtFSGetCurrent(widget);
	if(!fileName) strcpy(file, "invalid file name");
	else strcpy(file, fileName->fullpath);

	// set the text value of the file name text widget
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &file, 0);
	PtSetResources(ABW_fileSelFileName, 1, args);

	return( Pt_CONTINUE );
}
Example #22
0
int resetButtons(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[1];
	PtWidget_t *thisModule;
	PtWidget_t *cellButton;
	int cellButtonName;
	int i;

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

	/* get the module that contains this widget */
	thisModule = ApGetInstance(widget);

	/* reset the fill color of all buttons to grey */
	PtSetArg(&args[0], Pt_ARG_FILL_COLOR, Pg_GREY, 0);
	for(i = 0; i < 64; i++) {
		cellButtonName = getCellButtonName(i);
		cellButton = ApGetWidgetPtr(thisModule, cellButtonName);
		if(!cellButton) continue; /* skip bad widgets */
		PtSetResources(cellButton, 1, args);
	}
	return( Pt_CONTINUE );
}
Example #23
0
int swapColors( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	PtWidget_t *thisButton;
	long thisTime;
	int thisIndx;
	int i, j;
	char thisColor;
	char buttonLabel[128];
	char timeStamp[32];

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

	for(i = 0; i < MAXCHAIN; i++) {
		for(j = 0; j < 64; j++) {
			thisButton = chainStates[i][j].stateButton;
			thisIndx = chainStates[i][j].stateIndex;
			thisTime = stateDebug[thisIndx].time;
			thisColor = stateDebug[thisIndx].color;
			if(thisButton) {
				if(snames[thisIndx]->preset) strcpy(buttonLabel, "T");
				else strcpy(buttonLabel, "-");
				if(snames[thisIndx]->random) strcat(buttonLabel, "R");
				else strcat(buttonLabel, "-");
				strcat(buttonLabel, snames[thisIndx]->statename);
				sprintf(timeStamp, "        %ld", stateDebug[thisIndx].time);
				strcat(buttonLabel, timeStamp);
				PtSetArg(&args[0], Pt_ARG_TEXT_STRING, buttonLabel, 0);
				PtSetArg(&args[1], Pt_ARG_FILL_COLOR, stateButtonColors[thisColor], 0);
				PtSetResources(thisButton, 2, args);
			}
		}
	}
	return( Pt_CONTINUE );
}
Example #24
0
void initPageWidgets(PtWidget_t *link_instance, PAGE *thisPage, int newRasters)
{
	PtWidget_t *widget;
	PtArg_t args[1];

	/* set the values on the row and column widgets */
	widget = ApGetWidgetPtr(link_instance, ABN_pageRows);
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, thisPage->nRows, 0);
	PtSetResources(widget, 1, args);

	widget = ApGetWidgetPtr(link_instance, ABN_pageCols);
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, thisPage->nCols, 0);
	PtSetResources(widget, 1, args);

	/* set the values on the label widgets */
	widget = ApGetWidgetPtr(link_instance, ABN_pageLabelText);
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisPage->pageLabel.label, 0);
	PtSetResources(widget, 1, args);

	widget = ApGetWidgetPtr(link_instance, ABN_pageLabelLeft);
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, &thisPage->pageLabel.x, 0);
	PtSetResources(widget, 1, args);

	widget = ApGetWidgetPtr(link_instance, ABN_pageLabelBottom);
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, &thisPage->pageLabel.y, 0);
	PtSetResources(widget, 1, args);

	widget = ApGetWidgetPtr(link_instance, ABN_pageLabelSize);
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, thisPage->pageLabel.sz, 0);
	PtSetResources(widget, 1, args);

	switch(thisPage->pageLabel.font) {
	case 12:
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelDuplex);
		PtSetResources(widget, 1, args);
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelComplex);
		PtSetResources(widget, 1, args);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelItalic);
		PtSetResources(widget, 1, args);
		break;
	case 13:
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelComplex);
		PtSetResources(widget, 1, args);
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelDuplex);
		PtSetResources(widget, 1, args);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelItalic);
		PtSetResources(widget, 1, args);
		break;
	case 15:
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelItalic);
		PtSetResources(widget, 1, args);
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelComplex);
		PtSetResources(widget, 1, args);
		widget = ApGetWidgetPtr(link_instance, ABN_pageLabelDuplex);
		PtSetResources(widget, 1, args);
		break;
	}

	initCellButtons(link_instance, thisPage, newRasters);

	return;
}
static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
    PtArg_t     args[32];
    PhPoint_t   pos = {0, 0};
    PhDim_t     dim = {w, h};
    int         nargs = 0;
    const char* windowpos;
    const char* iscentered;
    int         x, y;

    PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);

    if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
    }

    if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
    {
       if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
       }
       else
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER);
       }
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE |
                                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN);
    }

    if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
        PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    }
    else
    {
        windowpos = getenv("SDL_VIDEO_WINDOW_POS");
	iscentered = getenv("SDL_VIDEO_CENTERED");

        if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
        {
            pos.x = (desktop_mode.width - w)/2;
            pos.y = (desktop_mode.height - h)/2;
            PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
	}
        else
        {
            if (windowpos)
            {
                if (sscanf(windowpos, "%d,%d", &x, &y) == 2 )
                {
                    pos.x=x;
                    pos.y=y;
                    PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
                }
	    }
        }


        PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    }

    PtSetResources(window, nargs, args);
    PtRealizeWidget(window);
    PtWindowToFront(window);

    return 0;
}
Example #26
0
void stateDebugDialogSetUser(int stateIndex)
{
	PtArg_t args[2];
	STATE *thisState;
	extern STATE *snames[];

	thisState = snames[stateIndex];

	PtSetResource(ABW_stateDebugDialog, Pt_ARG_WINDOW_TITLE, thisState->statename, 0);
	
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->preset, 0);
	PtSetResources(ABW_stateTime, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->random, 0);
	PtSetResources(ABW_stateRandom, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateRunLineToggleGroup, 1, args);

	/* set the state of the running line flag toggles */
	if(thisState->rlflag == 0) {
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_stateRunLineAbsToggle, 1, &args[1]);

		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_stateRunLineRelToggle, 1, &args[1]);

		PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
		PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->rlval, 0);
		PtSetResources(ABW_runningLine, 2, args);
	}
	if(thisState->rlflag == 1) {
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_stateRunLineAbsToggle, 1, &args[1]);

		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_stateRunLineRelToggle, 1, &args[1]);

		PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
		PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->rlval, 0);
		PtSetResources(ABW_runningLine, 2, args);
	}
	else if(thisState->rlflag == 2) {
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_stateRunLineAbsToggle, 1, &args[1]);

		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_stateRunLineRelToggle, 1, &args[1]);

		PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
		PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->rlval, 0);
		PtSetResources(ABW_runningLine, 2, args);
	}
	else if(thisState->rlflag == 3) {
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_stateRunLineAbsToggle, 1, &args[1]);

		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_stateRunLineRelToggle, 1, &args[1]);

		PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
		PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, -thisState->rlval, 0);
		PtSetResources(ABW_runningLine, 2, args);
	}

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg1ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_code, 0);
	PtSetResources(ABW_stateArg1, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg2ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_2code, 0);
	PtSetResources(ABW_stateArg2, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg3ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_3code, 0);
	PtSetResources(ABW_stateArg3, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg4ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_4code, 0);
	PtSetResources(ABW_stateArg4, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg5ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_5code, 0);
	PtSetResources(ABW_stateArg5, 2, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetResources(ABW_stateArg6ToggleGroup, 1, args);

	PtSetArg(&args[0], Pt_ARG_USER_DATA, &stateIndex, sizeof(int));
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, thisState->device.act_6code, 0);
	PtSetResources(ABW_stateArg6, 2, args);

	if(thisState->escape[0].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[0].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc1Button, 1, &args[0]);

	if(thisState->escape[1].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[1].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc2Button, 1, &args[0]);

	if(thisState->escape[2].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[2].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc3Button, 1, &args[0]);

	if(thisState->escape[3].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[3].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc4Button, 1, &args[0]);

	if(thisState->escape[4].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[4].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc5Button, 1, &args[0]);

	if(thisState->escape[5].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[5].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc6Button, 1, &args[0]);

	if(thisState->escape[6].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[6].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc7Button, 1, &args[0]);

	if(thisState->escape[7].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[7].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc8Button, 1, &args[0]);

	if(thisState->escape[8].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[8].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc9Button, 1, &args[0]);

	if(thisState->escape[9].stateptr) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, thisState->escape[9].stateptr->statename, 0);
	}
	else PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "", 0);
	PtSetResources(ABW_stateEsc10Button, 1, &args[0]);

	return;
}
Example #27
0
static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
    PtArg_t     args[32];
    PhPoint_t   pos = {0, 0};
    PhDim_t*    olddim;
    PhDim_t     dim = {w, h};
    PhRect_t    desktopextent;
    int         nargs = 0;
    const char* windowpos;
    const char* iscentered;
    int         x, y;

    /* check if window size has been changed by Window Manager */
    PtGetResource(window, Pt_ARG_DIM, &olddim, 0);
    if ((olddim->w!=w) || (olddim->h!=h))
    {
       PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
    }

    if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    }

    if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
    {
       if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
       }
       else
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER);
       }
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE |
                                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN);
    }

    if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
        PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_FFRONT | Ph_WM_CONSWITCH);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);

        if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE)
        {
            PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        }
        else
        {
            PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
        }
        if (!currently_maximized)
        {
            windowpos = SDL_getenv("SDL_VIDEO_WINDOW_POS");
            iscentered = SDL_getenv("SDL_VIDEO_CENTERED");

            if ((iscentered) || ((windowpos) && (SDL_strcmp(windowpos, "center")==0)))
            {
                PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
                if (desktop_mode.width>w)
                {
                    pos.x = (desktop_mode.width - w)/2;
                }
                if (desktop_mode.height>h)
                {
                    pos.y = (desktop_mode.height - h)/2;
                }

                pos.x+=desktopextent.ul.x;
                pos.y+=desktopextent.ul.y;
                PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
            }
            else
            {
                if (windowpos)
                {
                    if (SDL_sscanf(windowpos, "%d,%d", &x, &y) == 2)
                    {
                        if ((x<desktop_mode.width) && (y<desktop_mode.height))
                        {
                            PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
                            pos.x=x+desktopextent.ul.x;
                            pos.y=y+desktopextent.ul.y;
                        }
                        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
                    }
                }
            }
        }

        /* if window is maximized render it as maximized */
        if (currently_maximized)
        {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
        }
        else
        {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISMAX);
        }

        /* do not grab the keyboard by default */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);

        /* bring the focus to the window */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);

        /* allow to catch hide event */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    }

    PtSetResources(window, nargs, args);
    PtRealizeWidget(window);
    PtWindowToFront(window);

#if 0 /* FIXME */
    PtGetResource(window, Pt_ARG_POS, &olddim, 0);
    fprintf(stderr, "POSITION: %d, %d\n", olddim->w, olddim->h);
#endif

    return 0;
}
Example #28
0
int initDADialog( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *dialog;
	PtWidget_t *toggle;
	PtArg_t args[3];
	PtListCallback_t *listData;
	int daNum;
	int toggleOverride;
	int i;
	char title[16];

	void daDialogItemEnable();

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

	/* if this function was called from the list widget */
	if(PtWidgetClass(link_instance) == PtList) {
		if(cbinfo->reason_subtype != Pt_LIST_SELECTION_FINAL) return(Pt_CONTINUE);

		listData = (PtListCallback_t *)cbinfo->cbdata;
		sscanf(listData->item, "DA %d", &daNum);
		dialog = ApGetInstance(link_instance);
	}
	else {
		daNum = 0;
		PtListSelectPos(ABW_daConvList, 1);
		dialog = link_instance;
	}

	/*set the module's title widget */
	sprintf(title, "DA %d", daNum);
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, title, 0);
	PtSetResources(ABW_daDialogLabel, 1, &args[0]);

	/* set the state of the dialog enable button */
	if(da[daNum].m_da_menu) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Enabled", 0);
	}
	else {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Disabled", 0);
	}
	PtSetArg(&args[1], Pt_ARG_ONOFF_STATE, da[daNum].m_da_menu, 0);
	PtSetResources(ABW_daMenuOnOffButton, 2, args);

	/* set the states of the source toggles */
	toggleOverride = -1;
	for(i = 0; i < 9; i++) {
		toggle = ApGetWidgetPtr(dialog, daSourceToggles[i]);
		if(i == da[daNum].m_da_source) {
			PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
			toggleOverride = i;
		}
		else {
			PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		}
		PtSetResources(toggle, 1, &args[0]);
	}
	/* set the states of the mode toggles */
	switch(da[daNum].m_da_mode) {
	case 0:
		toggleOverride = 0;
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_daDirectToggle, 1, &args[0]);

		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_daOffConToggle, 1, &args[0]);
		PtSetResources(ABW_daOffStbyToggle, 1, &args[0]);
		break;
	case 1:
		toggleOverride = 1;
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_daOffConToggle, 1, &args[0]);

		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_daDirectToggle, 1, &args[0]);
		PtSetResources(ABW_daOffStbyToggle, 1, &args[0]);
		break;
	case 2:
		toggleOverride = 2;
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(ABW_daOffStbyToggle, 1, &args[0]);

		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_daDirectToggle, 1, &args[0]);
		PtSetResources(ABW_daOffConToggle, 1, &args[0]);
		break;
	default:
		toggleOverride = -1;
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(ABW_daDirectToggle, 1, &args[0]);
		PtSetResources(ABW_daOffConToggle, 1, &args[0]);
		PtSetResources(ABW_daOffStbyToggle, 1, &args[0]);
		break;
	}

	/* set the states of the menu override buttons */
	if(daMenuOvrRides[daNum][0]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
	else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
	PtSetResources(ABW_daSourceNumOvrRide, 1, &args[0]);

	if(daMenuOvrRides[daNum][1]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
	else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
	PtSetResources(ABW_daOutputOvrRide, 1, &args[0]);
	
	if(daMenuOvrRides[daNum][2]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
	else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
	PtSetResources(ABW_daOffsetOvrRide, 1, &args[0]);

	/* set the numeric values of the override value widgets */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daSourceNumbs[daNum], 0);
	PtSetResources(ABW_daSourceNum, 1, &args[0]);

	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daOutputs[daNum], 0);
	PtSetResources(ABW_daOutput, 1, &args[0]);

	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daOffsets[daNum], 0);
	PtSetResources(ABW_daOffset, 1, &args[0]);

	/* set the values of the module's "actual" widgets */
	/* source name */
	i = da[daNum].da_source;
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, daSourceNames[i], 0);
	PtSetResources(ABW_daSourceAct, 1, args);

	/* mode */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].da_mode, 0);
	PtSetResources(ABW_daModeAct, 1, args);

	/* source number */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].da_src_num, 0);
	PtSetResources(ABW_daSourceNumAct, 1, args);

	/* output value */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].m_da_val, 0);
	PtSetResources(ABW_daOutputAct, 1, args);

	/* offset */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, (da[daNum].da_offset >> TEN_TO_IC), 0);
	PtSetResources(ABW_daOffsetAct, 1, args);
	
	/* set the da number in all of this module's widgets */
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &daNum, sizeof(int));
	PtSetResources(ABW_daMenuOnOffButton, 1, &args[0]);
	PtSetResources(ABW_daSourceGroup, 1, &args[0]);
	PtSetResources(ABW_daModeGroup, 1, &args[0]);
	PtSetResources(ABW_daSourceNumOvrRide, 1, &args[0]);
	PtSetResources(ABW_daSourceNum, 1, &args[0]);
	PtSetResources(ABW_daOutputOvrRide, 1, &args[0]);
	PtSetResources(ABW_daOutput, 1, &args[0]);
	PtSetResources(ABW_daOffsetOvrRide, 1, &args[0]);
	PtSetResources(ABW_daOffset, 1, &args[0]);
	
	daDialogItemEnable(daNum);

	return( Pt_CONTINUE );
}
Example #29
0
int setDAMode( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *parent;
	PtArg_t arg;
	long *flags;
	int daNum;

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

	/* get the widget's group */
	parent = PtWidgetParent(widget);

	/* get the da number from the group */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(parent, 1, &arg);
	daNum = *(int *)arg.value;

	/* get the state of this buttons flags */
	PtSetArg(&arg, Pt_ARG_FLAGS, &flags, 0);
	PtGetResources(widget, 1, &arg);

	/* get the name of the toggle button that was pressed */
	if(ApName(widget) == ABN_daDirectToggle) {
		if(*flags & Pt_SET) {
			da[daNum].m_da_mode = DA_DIRECT;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daOffConToggle, 1, &arg);
			PtSetResources(ABW_daOffStbyToggle, 1, &arg);
		}
		else {
			da[daNum].m_da_mode = NULLI;
		}
	}
	else if(ApName(widget) == ABN_daOffConToggle) {
		if(*flags & Pt_SET) {
			if(da[daNum].m_da_mode == NULLI) da[daNum].m_da_mode = DA_OFFSET_CONN;
			else da[daNum].m_da_mode |= DA_OFFSET_CONN;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daDirectToggle, 1, &arg);
		}
		else {
			if(da[daNum].m_da_mode == DA_OFFSET_CONN) da[daNum].m_da_mode = NULLI;
			else da[daNum].m_da_mode &= ~DA_OFFSET_CONN;
		}
	}
	else if(ApName(widget) == ABN_daOffStbyToggle) {
		if(*flags & Pt_SET) {
			if(da[daNum].m_da_mode == NULLI) da[daNum].m_da_mode = DA_OFFSET_STBY;
			else da[daNum].m_da_mode |= DA_OFFSET_STBY;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daDirectToggle, 1, &arg);
		}
		else {
			if(da[daNum].m_da_mode == DA_OFFSET_STBY) da[daNum].m_da_mode = NULLI;
			else da[daNum].m_da_mode &= ~DA_OFFSET_STBY;
		}
	}

	da_mode(daNum, NULLI);

	return( Pt_CONTINUE );
}
Example #30
0
void daDialogItemEnable(int daNum)
{
	PtArg_t args[2];

	/* enable dialog items if menu is enabled */
	if(da[daNum].m_da_menu) {
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_GHOST);
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_TRUE, Pt_SELECTABLE);
	}
	else {
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_GHOST);
		PtSetArg(&args[1], Pt_ARG_FLAGS, Pt_FALSE, Pt_SELECTABLE);
	}
	PtSetResources(ABW_daStandbyToggle, 2, args);
	PtSetResources(ABW_daRampXToggle, 2, args);
	PtSetResources(ABW_daRampYToggle, 2, args);
	PtSetResources(ABW_daJoyXToggle, 2, args);
	PtSetResources(ABW_daJoyYToggle, 2, args);
	PtSetResources(ABW_daSignalToggle, 2, args);
	PtSetResources(ABW_daWinXToggle, 2, args);
	PtSetResources(ABW_daWinYToggle, 2, args);
	PtSetResources(ABW_daMemToggle, 2, args);

	PtSetResources(ABW_daDirectToggle, 2, args);
	PtSetResources(ABW_daOffConToggle, 2, args);
	PtSetResources(ABW_daOffStbyToggle, 2, args);

	PtSetResources(ABW_daSourceNumOvrRide, 2, args);
	PtSetResources(ABW_daOutputOvrRide, 2, args);
	PtSetResources(ABW_daOffsetOvrRide, 2, args);

	return;
}