Table of Contents

 
ChangeIcon
 

Purpose

Changes the icon of a button or many buttons

 

Protoype

void CButtonMngr::ChangeIcon (string str_icon, string str_button, exclude ex_list = exclude(), int i_flag = LIST_IN)
 

Parameters

icon the ID of the image object to assign
button the ID of the button to affect, ALL_BUTTONS if changing more than one button object
list the list of sprite objects to exclude or include in function
flag whether to exclude objects not in the list (LIST_OUT) or objects in the list (LIST_IN)
 

Description

This function changes the icon of a button. If the button previously had no icon, then this will assign one to it. The parameter str_icon takes a CImageMngr object that will then be assigned and displayed on the button, but only if icon visibility is enabled. You must also pass in for str_id the ID of the button that this new icon will be assigned to.

Changing Multiple Objects

If you want to change more than one button object at once, then you can use the last two parameters of the function. First you must compile a list (an STL vector) of objects that you want to either exclude or include. If you want to change all button objects except certain ones, pass those in for ex_list along with the flag LIST_IN. If you want to change only a certain set of objects, pass those in for ex_list along with the flag LIST_OUT. You should also pass ALL_BUTTONS for str_button.

 

Use

CButtonMngr button;
// change one button object
button.ChangeCaption("new_caption", "my_button");
// change ALL button objects except "my_button"
exclude ex_list;
ex_list.push_back("my_button");
button.ChangeCaption("my_caption", ALL_BUTTONS, ex_list, LIST_IN);
// change ONLY these three button objects
exclude ex_list;
ex_list.push_back("my_button1");
ex_list.push_back("my_button2");
ex_list.push_back("my_button3");
button.ChangeCaption("my_caption", ALL_BUTTONS, ex_list, LIST_OUT);
 

Prev: ChangeCaption