#include <libsswf.h>
Public Member Functions | |
Vectors & | Actions (void) |
Returns a reference to the actions array. | |
bool | AddEvent (Event *event) |
Add the specified event to the button tag. | |
virtual ErrorManager::error_code_t | Save (Data &data) |
Saves a button in the Data buffer. | |
void | SetAction (const Action &action) |
Append an action to the button. | |
void | SetMenu (bool menu=true) |
Set the menu flag. | |
bool | SetState (const State &state) |
Add a state to a button object. | |
TagButton (TagBase *parent) | |
Initializes a button tag object. | |
virtual swf_type_t | TypeFlags (void) const |
The flags representing the button tag type. | |
Private Member Functions | |
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data) |
Parse data from a file into a Button tag. | |
virtual ErrorManager::error_code_t | PreSave (void) |
Check that a button can be saved. | |
Private Attributes | |
Vectors | f_actions |
Vectors | f_events |
bool | f_menu |
bool | f_save_button2 |
Vectors | f_states |
To fully create a button, one can add actions (what happens when the user clicks on the button), events (what happens, in more details, when the user clicks) and different states (what happens when the mouse moves over and clicks on the button or not.)
TagButton::TagButton | ( | TagBase * | parent | ) |
This function initializes the button tag with an empty list of actions and states.
[in] | parent | The TagHeader where the button is added |
Vectors & TagButton::Actions | ( | void | ) |
This function returns a Vector reference to the internal array of actions.
This can be used to save the actions in any order as you need.
References f_actions.
bool TagButton::AddEvent | ( | Event * | event | ) |
This function adds the specified event to the TagButton object.
An event is a set of flags determining the event triggers and a set of actions to execute when it happens.
As many events as you need can be added. However, the first event matching has its ActionScript executed and then the process stops (to be confirmed!)
[in] | event | The event to add to this TagPlace object |
References sswf::Event::Events(), f_events, sswf::Vectors::Set(), and SSWF_EVENT_CONDITIONS.
Referenced by ParseTag().
ErrorManager::error_code_t TagButton::ParseTag | ( | swf_tag_t | tag, | |
const Data & | data | |||
) | [private, virtual] |
This function reads the password saved in the Button tag.
Note that the password is kept encrypted.
[in] | tag | The tag that generated this call |
[in] | data | The Data buffer from the Flash file being loaded |
Implements sswf::TagBase.
References sswf::Event::Actions(), AddEvent(), sswf::ErrorManager::ERROR_CODE_END_OF_STATES, sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_menu, f_save_button2, sswf::Data::GetByte(), sswf::Data::GetShort(), sswf::TagBase::Header(), sswf::Data::IsEndOfData(), sswf::MemoryManager::MemAttach(), sswf::State::Parse(), sswf::TagScalingGrid::ParseGridTag(), sswf::TagBaseID::ParseID(), sswf::Action::ParseList(), sswf::Event::SetConditions(), SetState(), sswf::TagBase::SWF_TAG_DEFINE_BUTTON2, and sswf::TagBase::SWF_TAG_DEFINE_SCALING_GRID.
ErrorManager::error_code_t TagButton::PreSave | ( | void | ) | [private, virtual] |
This function traverse the list of events and actions to determine the minimum version and make sure that the events are valid.
Reimplemented from sswf::TagBase.
References sswf::Event::Actions(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NO_STATES, sswf::ErrorManager::ERROR_CODE_UNEXPECTED_EVENT_FLAG, sswf::Event::Events(), f_actions, f_events, f_menu, f_save_button2, f_states, sswf::Vectors::Get(), sswf::TagScalingGrid::GridPreSave(), sswf::State::HasColorTransform(), sswf::Action::MinimumListVersion(), sswf::TagBase::MinimumVersion(), sswf::TagBase::OnError(), and SSWF_EVENT_CONDITIONS.
ErrorManager::error_code_t TagButton::Save | ( | Data & | data | ) | [virtual] |
This function saves the button in the specified data buffer.
It can save button version 1 and 2.
The function will generate an error if it detects an invalid event (i.e. an event with all flags set at zero or invalid flags set.) If no event has the hit test bit set, an error is generated, but the save goes on.
[in] | data | The data buffer where the button is saved |
Implements sswf::TagBase.
References sswf::Action::ACTION_END, sswf::Event::Actions(), sswf::Data::Append(), sswf::Data::ByteSize(), sswf::Event::CONDITION_POINTER_RELEASE_INSIDE, sswf::Event::Conditions(), sswf::Vectors::Count(), sswf::Data::Empty(), sswf::ErrorManager::ERROR_CODE_BUTTON_MISSING_STATE, sswf::ErrorManager::ERROR_CODE_NONE, f_actions, f_events, f_menu, f_save_button2, f_states, sswf::Vectors::Get(), sswf::State::GetFlags(), sswf::TagScalingGrid::GridSave(), sswf::TagBaseID::Identification(), sswf::TagBase::OnError(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::State::Save(), sswf::TagBaseID::SaveID(), sswf::Action::SaveList(), sswf::TagBase::SaveTag(), sswf::State::STATE_FLAG_HIT_TEST, sswf::TagBase::SWF_TAG_DEFINE_BUTTON, and sswf::TagBase::SWF_TAG_DEFINE_BUTTON2.
void TagButton::SetAction | ( | const Action & | action | ) |
This function adds one action at the end of the list of actions of the button. If you want to manage the list better, use the Actions() function to get access to the array of actions.
The input action is copied and thus it can be modified on return.
[in] | action | The action to append; it is copied in the array |
References sswf::Action::Duplicate(), f_actions, sswf::MemoryManager::MemAttach(), and sswf::Vectors::Set().
void TagButton::SetMenu | ( | bool | menu = true |
) |
This function is used to set the menu flag of the button.
A button with the menu flag turned on can be used to select an entry as if it were a menu.
[in] | menu | The new state of the menu flag (true or false) |
References f_menu.
bool TagButton::SetState | ( | const State & | state | ) |
This function adds a state to a button object.
Multiple states with the same flags can be added to the same button. In that case, they all become active at the time the states are satisfied.
[in] | state | The state to add to this button object |
References sswf::ErrorManager::ERROR_CODE_BAD_STATE_FLAGS, f_states, sswf::State::GetFlags(), sswf::MemoryManager::MemAttach(), sswf::TagBase::OnError(), and sswf::Vectors::Set().
Referenced by ParseTag().
TagBase::swf_type_t TagButton::TypeFlags | ( | void | ) | const [virtual] |
A button is of type:
SWF_TYPE_DEFINE SWF_TYPE_REFERENCE SWF_TYPE_SCRIPT SWF_TYPE_HAS_ID
Implements sswf::TagBase.
References SWF_TYPE_DEFINE, SWF_TYPE_HAS_ID, SWF_TYPE_REFERENCE, and SWF_TYPE_SCRIPT.
Vectors sswf::TagButton::f_actions [private] |
Referenced by Actions(), ParseTag(), PreSave(), Save(), and SetAction().
Vectors sswf::TagButton::f_events [private] |
Referenced by AddEvent(), PreSave(), and Save().
bool sswf::TagButton::f_menu [private] |
Referenced by ParseTag(), PreSave(), Save(), and SetMenu().
bool sswf::TagButton::f_save_button2 [private] |
Referenced by ParseTag(), PreSave(), and Save().
Vectors sswf::TagButton::f_states [private] |
Referenced by PreSave(), Save(), and SetState().