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; }
/* * Function - btn_turnoff_callback() * * Callback function for the "Turn Off" button */ sint32_t btn_turnoff_callback(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo) { // Eliminate 'unreferenced' warnings widget = widget, apinfo = apinfo, cbinfo = cbinfo; // Exit application PtExit(0); return( Pt_CONTINUE ); }
int tblLastIndex(PtWidget_t *scrollCon, bool row) { tblWidget_t *tbl = NULL; if (PtGetResource(scrollCon, Pt_ARG_POINTER, &tbl, 0) != 0) PtExit(EXIT_FAILURE); if (row) return tbl->rows -1; else return tbl->cols -1; }
int exit_viewer( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; freeze = true; m_exit = true; if (vv!=NULL) delete []vv; if (uu!=NULL) delete []uu; t1.End(0); delay(1000); //Wait a little so the thread exits from the current loop PtExit( EXIT_SUCCESS ); return( Pt_CONTINUE ); }
PtWidget_t *tblInit(PtWidget_t *parent, PhPoint_t pos, PhDim_t dim) { int c = 0; PtArg_t argsScrCon[6]; tblWidget_t *tbl; PtCallback_t callbacks[1]; assert(parent); if ((tbl = (tblWidget_t *)malloc(sizeof(tblWidget_t))) == NULL) PtExit(EXIT_FAILURE); memset(tbl, 0, sizeof(tblWidget_t)); tbl->geom = pos; tbl->dim = dim; /* automatically scroll container resize both X and Y */ PtSetArg(&argsScrCon[c++], Pt_ARG_SCROLLCONT_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0); PtSetArg(&argsScrCon[c++], Pt_ARG_BASIC_FLAGS, Pt_FLAT_FILL | Pt_TOP_OUTLINE | Pt_BOTTOM_OUTLINE | Pt_LEFT_OUTLINE | Pt_RIGHT_OUTLINE, 0); PtSetArg(&argsScrCon[c++], Pt_ARG_POS, &pos, 0); PtSetArg(&argsScrCon[c++], Pt_ARG_DIM, &dim, 0); /* save the table into "data" in this container */ PtSetArg(&argsScrCon[c++], Pt_ARG_POINTER, tbl, 0); callbacks[0].event_f = tblDestructionCB; callbacks[0].data = NULL; PtSetArg(&argsScrCon[c++], Pt_CB_DESTROYED, callbacks, sizeof(callbacks)/sizeof(callbacks[0])); /* another widget as a child of a parent */ return PtCreateWidget(PtScrollContainer, parent, c, argsScrCon); }