iter_type put_unit(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const { if (std::has_facet<duration_units<CharT> >(ios.getloc())) { duration_units<CharT> const&facet = std::use_facet<duration_units<CharT> >( ios.getloc()); return put_unit(facet, s, ios, fill, d); } else { duration_units_default<CharT> facet; return put_unit(facet, s, ios, fill, d); } }
/************************************************************************** Fill pixcomm with unit gfx **************************************************************************/ void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p) { struct canvas canvas_store = FC_STATIC_CANVAS_INIT; canvas_store.surface = gtk_pixcomm_get_surface(p); gtk_pixcomm_clear(p); put_unit(punit, &canvas_store, 1.0, 0, 0); }
/************************************************************************** ... **************************************************************************/ void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p) { struct canvas canvas_store; canvas_store.type = CANVAS_PIXCOMM; canvas_store.v.pixcomm = p; gtk_pixcomm_freeze(p); gtk_pixcomm_clear(p); put_unit(punit, &canvas_store, 0, 0); gtk_pixcomm_thaw(p); }
/************************************************************************** Set one of the unit icons in information area based on punit. Use punit==NULL to clear icon. Index 'idx' is -1 for "active unit", or 0 to (num_units_below-1) for units below. Also updates unit_ids[idx] for idx>=0. **************************************************************************/ void set_unit_icon(int idx, struct unit *punit) { Widget w; assert(idx>=-1 && idx<num_units_below); if (idx == -1) { w = unit_pix_canvas; } else { w = unit_below_canvas[idx]; unit_ids[idx] = punit ? punit->id : 0; } XawPixcommClear(w); if (punit) { struct canvas store = {XawPixcommPixmap(w)}; put_unit(punit, &store, 0, 0); xaw_expose_now(w); } }
iter_type put(duration_units<CharT> const& units_facet, iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d, const CharT* pattern, const CharT* pat_end) const { const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(ios.getloc()); for (; pattern != pat_end; ++pattern) { if (ct.narrow(*pattern, 0) == '%') { if (++pattern == pat_end) { *s++ = pattern[-1]; break; } char fmt = ct.narrow(*pattern, 0); switch (fmt) { case 'v': { s = put_value(s, ios, fill, d); break; } case 'u': { s = put_unit(units_facet, s, ios, fill, d); break; } default: BOOST_ASSERT(false && "Boost::Chrono internal error."); break; } } else *s++ = *pattern; } return s; }
/**************************************************************** popup the dialog 10% inside the main-window *****************************************************************/ void unit_select_dialog_popup(struct tile *ptile) { int i,n,r; char buffer[512]; Arg args[4]; int nargs; Widget unit_select_all_command, unit_select_close_command; Widget firstcolumn=0,column=0; Pixel bg; struct unit *unit_list[unit_list_size(ptile->units)]; XtSetSensitive(main_form, FALSE); unit_select_dialog_shell = I_T(XtCreatePopupShell("unitselectdialogshell", transientShellWidgetClass, toplevel, NULL, 0)); unit_select_form = XtVaCreateManagedWidget("unitselectform", formWidgetClass, unit_select_dialog_shell, NULL); XtVaGetValues(unit_select_form, XtNbackground, &bg, NULL); XSetForeground(display, fill_bg_gc, bg); n = MIN(MAX_SELECT_UNITS, unit_list_size(ptile->units)); r = number_of_rows(n); fill_tile_unit_list(ptile, unit_list); for(i=0; i<n; i++) { struct unit *punit = unit_list[i]; struct unit_type *punittemp=unit_type(punit); struct city *pcity; struct canvas store; if(!(i%r)) { nargs=0; if(i) { XtSetArg(args[nargs], XtNfromHoriz, column); nargs++;} column = XtCreateManagedWidget("column", formWidgetClass, unit_select_form, args, nargs); if(!i) firstcolumn=column; } unit_select_ids[i]=punit->id; pcity = player_city_by_number(client_player(), punit->homecity); fc_snprintf(buffer, sizeof(buffer), "%s(%s)\n%s", utype_name_translation(punittemp), pcity ? city_name(pcity) : "", unit_activity_text(punit)); unit_select_pixmaps[i]=XCreatePixmap(display, XtWindow(map_canvas), tileset_full_tile_width(tileset), tileset_full_tile_height(tileset), display_depth); XFillRectangle(display, unit_select_pixmaps[i], fill_bg_gc, 0, 0, tileset_full_tile_width(tileset), tileset_full_tile_height(tileset)); store.pixmap = unit_select_pixmaps[i]; put_unit(punit, &store, 0, 0); nargs=0; XtSetArg(args[nargs], XtNbitmap, (XtArgVal)unit_select_pixmaps[i]);nargs++; XtSetArg(args[nargs], XtNsensitive, can_unit_do_activity(punit, ACTIVITY_IDLE));nargs++; if(i%r) { XtSetArg(args[nargs], XtNfromVert, unit_select_commands[i-1]); nargs++; } unit_select_commands[i]=XtCreateManagedWidget("unitselectcommands", commandWidgetClass, column, args, nargs); nargs=0; XtSetArg(args[nargs], XtNlabel, (XtArgVal)buffer); nargs++; XtSetArg(args[nargs], XtNfromHoriz, unit_select_commands[i]); nargs++; if(i%r) { XtSetArg(args[nargs], XtNfromVert, unit_select_commands[i-1]); nargs++; } unit_select_labels[i]=XtCreateManagedWidget("unitselectlabels", labelWidgetClass, column, args, nargs); XtAddCallback(unit_select_commands[i], XtNdestroyCallback,free_bitmap_destroy_callback, NULL); XtAddCallback(unit_select_commands[i], XtNcallback, unit_select_callback, NULL); } unit_select_no=i; unit_select_close_command = I_L(XtVaCreateManagedWidget("unitselectclosecommand", commandWidgetClass, unit_select_form, XtNfromVert, firstcolumn, NULL)); unit_select_all_command = I_L(XtVaCreateManagedWidget("unitselectallcommand", commandWidgetClass, unit_select_form, XtNfromVert, firstcolumn, NULL)); XtAddCallback(unit_select_close_command, XtNcallback, unit_select_callback, NULL); XtAddCallback(unit_select_all_command, XtNcallback, unit_select_all_callback, NULL); xaw_set_relative_position(toplevel, unit_select_dialog_shell, 15, 10); XtPopup(unit_select_dialog_shell, XtGrabNone); }
// Encode a character and write it to the stream. void encode(boost::int_fast32_t ch) { put_unit(ch); }