/*****************************************************************************\ FILE : UgTableColorChange.c PURPOSE : Pro/TOOLKIT User Guide Example HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 04-Dec-97 H-02-02 Philippe $$1 Created \*****************************************************************************/ /*-------------------------- Pro/Develop includes ---------------------------*/ #include #include /*-------------------------- Pro/Toolkit includes ---------------------------*/ #include #include #include /*-------------------------- Application includes ---------------------------*/ #include /*=================================================================*\ FUNCTION : UserTableColorChange PURPOSE : Change the color of the notes in a drawing table \*=================================================================*/ ProError UserTableColorChange () { int status; ProMdl p_draw; int table_id; int colorcl; int nrows, ncols, r, c, note_id; Prodtl_note *p_note; int win_id; int color; int i_range[2]= {0 , PRO_COLOR_MAX}; ProFileName WMSGFIL = {'m','s','g','_','u','g','d','w','g','.','t','x','t','\0'}; /*------------------------------------------------------------*\ Get the current model \*------------------------------------------------------------*/ status = ProMdlCurrentGet(&p_draw); ERROR_CHECK("UserTableColorChange","ProMdlCurrentGet",status); if (status != PRO_TK_NO_ERROR) return (status); /*------------------------------------------------------------*\ Ask the user the color of the notes \*------------------------------------------------------------*/ status = ProMessageDisplay(WMSGFIL, "USER %0s", "Enter the color index : "); ERROR_CHECK("UserTableColorChange","ProMessageDisplay",status); status = ProMessageIntegerRead(i_range, &color); ERROR_CHECK("UserTableColorChange","ProMessageIntegerRead",status); if (status != PRO_TK_NO_ERROR) return (status); /*------------------------------------------------------------*\ For each table in the drawing \*------------------------------------------------------------*/ for(table_id = prodrw_get_first_table_id((Prohandle) p_draw); table_id >= 0; table_id = prodrw_get_next_table_id((Prohandle) p_draw,table_id)) { /*--------------------------------------------------------*\ For each row and column in the table... \*--------------------------------------------------------*/ nrows = prodrw_count_table_rows ((Prohandle) p_draw, table_id); ERROR_CHECK("UserTableColorChange","prodrw_count_table_rows",(nrows<1)); if (nrows<1) return (PRO_TK_NOT_VALID); ncols = prodrw_count_table_cols ((Prohandle) p_draw, table_id); ERROR_CHECK("UserTableColorChange","prodrw_count_table_cols",(ncols<1)); if (ncols<1) return (PRO_TK_NOT_VALID); for (r = 1; r <= nrows; r++) { for (c = 1; c <= ncols; c++) { /*-----------------------------------------------*\ Get the identifier of the note in this cell. \*-----------------------------------------------*/ note_id = prodrw_get_table_cell_note_id ((Prohandle) p_draw, table_id, r, c); ERROR_CHECK("UserTableColorChange", "prodrw_get_table_cell_note_id", (note_id <0)); if (note_id < 0) continue; /*-----------------------------------------------*\ Get the data structure for the note. \*-----------------------------------------------*/ status = prodtl_get_item ((Prohandle) p_draw, NULL, PRODTL_NOTE, note_id, 0, (Prodtl_item**)&p_note); ERROR_CHECK("UserTableColorChange", "prodtl_get_item", (status <0)); /*-----------------------------------------------*\ Modify its color. \*-----------------------------------------------*/ p_note->color.type = PTC_COLOR_INDEX; p_note->color.color = color; /*-----------------------------------------------*\ Set the note to have the new color. \*-----------------------------------------------*/ status = prodtl_display ((Prohandle) p_draw, PRODTL_NOTE, note_id, PRODTL_REMOVE); ERROR_CHECK("UserTableColorChange", "prodtl_display", (status <=0)); status = prodtl_modify ((Prohandle) p_draw, NULL, (Prodtl_item*)p_note); ERROR_CHECK("UserTableColorChange", "prodtl_modify", (status <=0)); status = prodtl_display ((Prohandle) p_draw, PRODTL_NOTE, note_id, PRODTL_SHOW); ERROR_CHECK("UserTableColorChange", "prodtl_display", (status <=0)); } } } /*------------------------------------------------------------*\ Update the changes by repainting the window \*------------------------------------------------------------*/ status = ProWindowCurrentGet(&win_id); ERROR_CHECK("UserSheetAdd","ProWindowCurrentGet",status); status = ProWindowRepaint (win_id); ERROR_CHECK("UserSheetAdd","ProWindowRepaint",status); return (PRO_TK_NO_ERROR); }