static void show_color(MBLOCK *mblk, int col_id) { int save_win_id; char *label; int colornamecount; char **arraydata; int win_id = mblk->info->colorwin_id; int block_id = mblk->info->colorblock_id; int array_id = mblk->info->colorarray_id; g_push_gc(); save_win_id=g_get_windownr(); g_select_window(win_id); g_delete_object(mblk->spar[S_COLORMAP].obj_id+1); g_open_object(mblk->spar[S_COLORMAP].obj_id+1); g_select_viewport(mblk->spar[S_COLORMAP].vp_id); g_set_foreground(col_id); g_fillrectangle(0,MAXROW,MAXCOLUMN,MAXROW+1); g_moveto(0.2,MAXROW+0.2); if (col_id == G_WHITE ) g_set_foreground(G_BLACK); else g_set_foreground(G_WHITE); g_set_font(G_FONT_HELVETICA_BOLD,G_RELATIVE_FONTSCALING); g_set_charsize(1.0); arraydata = psnd_get_colornames(&colornamecount); label = psnd_sprintf_temp("Block%d:%s:Color=%d", block_id+1, arraydata[array_id], col_id); g_label(label); g_close_object(mblk->spar[S_COLORMAP].obj_id+1); g_call_object(mblk->spar[S_COLORMAP].obj_id+1); g_flush(); g_pop_gc(); g_select_window(save_win_id); }
void begin_tab(int *pln, int *pcode, int *cp) { vector<int> delta; int cjust, save_fnt; double zzz, save_hei, base_owidth; (*pln)++; string line; stringstream tab_buf; g_get_font(&save_fnt); g_get_hei(&save_hei); g_get_just(&cjust); g_textfindend("o",&base_owidth,&zzz); int save_pln = *pln; while (begin_line_norep(pln, line)) { tab_line_delta(line, tab_buf, delta); } *pln = save_pln; while (begin_line_norep(pln, line)) { tab_line(line, tab_buf, base_owidth, delta); } // cout << "tab buf '" << tab_buf.str() << "'" << endl; g_set_font(save_fnt); g_set_hei(save_hei); text_block(tab_buf.str(),0.0,cjust); }
/* * Display the color map in a window */ void psnd_show_colormap(MBLOCK *mblk, int numcol) { float x0,y0,dx,dy,box_height,box_width; int nx,ny,win_id, save_win_id,bar_id; char string[5]; int i,ix,iy,color=0; int colornamecount; char **arraydata; if (mblk->info->colorwin_id) { g_raise_window(mblk->info->colorwin_id); return; } arraydata = psnd_get_colornames(&colornamecount); box_width = 60.0; box_height = 30.0; nx = sqrt(numcol); if (nx>MAXCOLUMN) nx=MAXCOLUMN; ny = numcol/nx; if (nx*ny < numcol) ny++; x0 = 0.0; y0 = 0.0; dx = box_width*(nx); dy = box_height*(ny); g_push_gc(); save_win_id=g_get_windownr(); mblk->info->colorwin_id = g_open_window(G_SCREEN, x0, y0, dx, dy, "Colormap", G_WIN_BUFFER| G_WIN_BUTTONBAR2); /* g_popup_follow_cursor(TRUE); */ g_delete_object(mblk->spar[S_COLORMAP].obj_id); g_open_object(mblk->spar[S_COLORMAP].obj_id); g_set_viewport(mblk->spar[S_COLORMAP].vp_id, 0, 0, 1, 1); g_set_world(mblk->spar[S_COLORMAP].vp_id, 0, 0, nx+0.01, 1+ny+0.01); g_select_viewport(mblk->spar[S_COLORMAP].vp_id); g_set_clipping(FALSE); g_set_font(G_FONT_HELVETICA_BOLD,G_RELATIVE_FONTSCALING); g_set_charsize(1.0); for (iy=0;iy<ny;iy++) { for(ix=0;ix<nx;ix++) { g_set_foreground(color); g_fillrectangle(ix,ny-iy-1,ix+1,ny-iy); g_moveto((float)ix+0.25,(float)(ny-iy-1)+0.25); if ((color%(numcol)) == G_WHITE ) g_set_foreground(G_BLACK); else g_set_foreground(G_WHITE); sprintf(string,"%d",color); g_label(string); color++; } } g_close_object(mblk->spar[S_COLORMAP].obj_id); g_call_object(mblk->spar[S_COLORMAP].obj_id); bar_id = g_menu_create_buttonbox2(mblk->info->colorwin_id, 1); mblk->info->colorbar_id = bar_id; g_menu_append_button(bar_id, "Quit", COL_QUIT); g_menu_append_button(bar_id, "Reset", COL_DEF); g_menu_append_button(bar_id, "Save", COL_WRITE); g_menu_append_button(bar_id, "Retrieve", COL_READ); #ifdef _WIN32 g_menu_append_button(bar_id, "Item", COL_ITEM); #else { char *data[MAX_BLOCK] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }; assert(mblk->info->colorblock_id <= 12); g_menu_append_optionmenu(bar_id, "Block", COL_BLOCK, MAXBLK, mblk->info->colorblock_id, data); } g_menu_append_optionmenu(bar_id, "Item", COL_ARRAY, colornamecount, mblk->info->colorarray_id, arraydata); #endif g_menu_create_buttonbox2(mblk->info->colorwin_id, -1); g_flush(); g_pop_gc(); g_select_window(save_win_id); color = psnd_get_colorvalue(mblk,mblk->info->colorarray_id, mblk->info->colorblock_id); show_color(mblk, color); }