void elevator_system_drawer::draw_queue(size_t length, Wt::WPainter& painter, Wt::WRectF rc) { auto const person_height = get_person_height(SizeFormat::Pixels); auto const person_width = get_person_width(SizeFormat::Pixels); auto const gap_width = get_queue_gap_width(SizeFormat::Pixels); auto const margin = (rc.height() - person_height) * 0.5; rc = Wt::WRectF( rc.left(), rc.top() + margin, person_width, person_height ); double offset = person_width + gap_width; for(size_t i = 0; i < length; ++i) { draw_person(painter, rc); rc = Wt::WRectF( rc.left() + offset, rc.top(), rc.width(), rc.height() ); } }
void tree_print( int trunk ) { Tree_params tree_params ; Str_prt_params params ; short max_gens ; short x_offset ; char underlines[80] ; short sidestep ; short verts[MAX_GENS+1] ; short val, offset ; /* temporary values used in */ /* optimisation of x_offset */ short generation ; short i ; int x ; /* int needed as max lines returned for */ /* file is 7FFF, and extra 2 would go */ /* negative */ if( !trunk ) trunk = get_person_reference( NULL, FALSE ) ; if( !trunk ) return ; /* exit if nobody selected */ if( open_printer( ¶ms ) ) { start_print_checking( ¶ms ) ; params.ref1 = trunk ; params.ref2 = 0 ; /* Do not print second reference. */ busy( BUSY_MORE ) ; x = (int) params.chs_up + 2 ; /* calculate max generations vertically */ max_gens = 0 ; while( x > 3 && max_gens < MAX_GENS ) { x >>= 1 ; max_gens++ ; } tree_params.ref = trunk ; tree_params.generation = 1 ; tree_params.max_generations = max_gens ; /* temporary values */ tree_params.position = 1 ; tree_params.right_limit = params.chs_across * params.cell_width ; for( i=0; i<MAX_TREE_SIZE; i++ ) { tree_names[i][0] = '\0' ; tree_dates[i][0] = '\0' ; } load_tree_strings( tree_params ) ; /* For each generation find value of offset which */ /* would just allow name to fit. The offset is set */ /* to the minimum of these to ensure that all */ /* generations fit. Normally but not always it will */ /* be the last generation that is critical. */ /* Space allowed is width minus 2 to allow for */ /* spaces at start and end of print. */ offset = params.chs_across ; /* initialise to excessive value */ for( generation = 2; generation <= max_gens; generation++ ) { val = ( params.chs_across - 2 - name_max_found[generation] ) / ( generation - 1 ) ; if( val < offset ) offset = val ; } if( offset <= 0 ) offset = 1 ; x_offset = params.cell_width * offset ; tree_params.x_offsets = x_offset ; if( printing_ok( ¶ms ) && params.prn_handle ) { tree_params.ch_width = params.cell_width ; tree_params.x_position = params.cell_width + params.x_offset ; tree_params.ch_height = params.cell_height ; tree_params.y_min = 2 + params.y_offset ; tree_params.y_max = params.chs_up * params.cell_height - 2 + params.y_offset ; tree_params.line_start_x = 0 ; tree_params.line_start_y = 0 ; draw_person( params.prn_handle, tree_params ) ; } else if( printing_ok( ¶ms ) && params.fp ) { if( x_offset > 16 ) sidestep = 8 ; else sidestep = x_offset / 2 ; for( i=0; i < x_offset - sidestep - 1; i++ ) underlines[i] = '_' ; underlines[i] = '\0' ; for( i=0; i<MAX_GENS + 1; i++ ) verts[i] = 0 ; params.y_pos = 0 ; params.downlines = 1 ; params.tabpos = x_offset - sidestep - 1 ; params.align = LEFT ; params.x_pos = 0 ; params.last_x_end = 0 ; std_print_tree_person( tree_params, ¶ms, verts, underlines, sidestep ) ; } end_page( ¶ms, FALSE ) ; close_printer( ¶ms ) ; busy( BUSY_LESS ) ; }