コード例 #1
0
ファイル: callGraphDisplay.C プロジェクト: dyninst/paradyn
bool callGraphDisplay::set_scrollbars(int absolute_x, int relative_x,
			       int absolute_y, int relative_y,
			       bool warpPointer) {
   // Sets the scrollbars s.t. (absolute_x, absolute_y) will appear
   // at window (relative) location (relative_x, relative_y).
   // May need to take into account the current scrollbar setting...

   bool anyChanges = true;

   horizScrollBarOffset = -set_scrollbar(interp, horizSBName,
					 rootPtr->entire_width(consts),
					 absolute_x, relative_x);
      // relative_x will be updated
   
   vertScrollBarOffset = -set_scrollbar(interp, vertSBName,
					rootPtr->entire_height(consts),
					absolute_y, relative_y);
#if !defined(i386_unknown_nt4_0)
   if (warpPointer)
      XWarpPointer(Tk_Display(consts.theTkWindow),
		   Tk_WindowId(consts.theTkWindow), // src win
		   Tk_WindowId(consts.theTkWindow), // dest win
		   0, 0, // src x,y
		   0, 0, // src height, width
		   relative_x, relative_y
		   );
#else // !defined(i386_unknown_nt4_0)
	// TODO - implement warping behavior (?)
#endif // !defined(i386_unknown_nt4_0)
   return anyChanges;
}
コード例 #2
0
// ----------------------------------------------------------------------
// display a list of armies
// ----------------------------------------------------------------------
void t_army_list_window::inserted( int index )
{
	if (index < m_first_army)
		m_first_army++;
	if (index < m_selected_army)
		m_selected_army++;
	set_scrollbar();
}
コード例 #3
0
// ----------------------------------------------------------------------
// display a list of armies
// ----------------------------------------------------------------------
void t_army_list_window::attach( t_scrollbar* scrollbar )
{
	m_scrollbar = scrollbar;
	if (scrollbar == 0)
		return;

 	scrollbar->set_handler( bound_handler( *this, &t_army_list_window::on_scroll ) );
	set_scrollbar();
}
コード例 #4
0
// ----------------------------------------------------------------------
// display a list of armies
// ----------------------------------------------------------------------
void t_army_list_window::removed( int index )
{
	if (index <= m_first_army && m_first_army > 0)
		m_first_army--;
	if (index == m_selected_army)
		m_selected_army = -1;
	if (index <= m_selected_army && m_selected_army >= 0)
		m_selected_army--;
	set_scrollbar();
}
コード例 #5
0
void t_army_list_window::update()
{
	int item_index;
	int army_index;
	int value;
	int maximum;
	std::string text;

	army_index = m_first_army;
	item_index = 0;
	t_help_block const&		shared_help = get_help_block( "shared" );

	while (army_index < m_armies->size() && item_index < m_items.size())
	{
		t_army* army			       = (*m_armies)[army_index];

		t_creature_stack const& leader = army->get_creatures().get_leader();
		t_item& item = m_items[item_index];

		item.army = army;
		item.portrait->set_bitmap( leader.get_portrait() );
		item.portrait->set_help_balloon_text( leader.get_name() );

		// create the right click help
		t_hero const * hero = leader.get_hero();
		if( hero )
		{
			std::string first_part;
			first_part = replace_keywords( k_text_right_click_hero, "%name", hero->get_name(), 
										"%level", format_string( "%i", hero->get_level() ), "%class", hero->get_class_name() );
			text = replace_keywords( first_part, "%align", get_alignment_name( hero->get_alignment() ) );
		} else
			text = replace_keywords( k_text_right_click_creature, "%number", format_string( "%i", leader.get_number() ),
										"%name", leader.get_name() );
		item.portrait->set_right_click_text( text );

		if (item.portrait->get_bitmap())
			item.empty_background->set_visible( false );
		else
			item.empty_background->set_visible( true );

		value = army->get_movement();
		if (value < army->get_next_step_cost())
			value = 0;
		text = replace_keywords( shared_help.get_name("army_ring_distance"), "%distance", 
			                     format_string( "%i", value / 100 ));
		set_bar_height( value, 1500, item.move_bar, item.move_clipper,
			            item.move_background, text );
		item.move_bar->set_right_click_text( shared_help.get_help( "army_ring_distance" ) );

		value = army->get_creatures().get_experience_value();
		value = (log( (double)value ) - log( (double)k_minimum_army_value )) * k_log_multiplier;
		maximum = (log( (double)k_maximum_army_value ) - log( (double)k_minimum_army_value)) * k_log_multiplier;
		set_bar_height( value, maximum, item.strength_bar, item.strength_clipper,
						item.strength_background, shared_help.get_name("army_ring_strength") );
		item.strength_bar->set_right_click_text( shared_help.get_help("army_ring_strength") );

		item.button->set_visible( true );
		item.move_background->set_visible( true );
		item.strength_background->set_visible( true );

		item_index++;
		army_index++;
	}

	// Deal with any empty items
	while (item_index < m_items.size())
	{
		t_item& item = m_items[item_index];

		item.army = 0;
		item.button->set_visible( false );
		item.move_background->set_visible( false );
		item.strength_background->set_visible( false );

		if (m_hide_unused && item_index > 0)
		{
			// Hide the rings entirely if this isn't the very first ring
			item.normal_border->set_visible( false );
			item.highlight_border->set_visible( false );
			item.empty_background->set_visible( false );
		}
		else
		{
			item.empty_background->set_visible( true );
		}

		item_index++;
	}

	set_scrollbar();
	set_highlight( m_selected_army );
}