Lomse library. API documentation  0.30.0
CmdChangeAttribute Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdChangeAttribute:
DocCmdSimple DocCommand

Detailed Description

A command for changing the value of an attribute.

See constructors for details. There is a constructor for each type of value (string, double, int or colour).

Public Member Functions

 CmdChangeAttribute (ImoObj *pImo, EImoAttribute attrb, const std::string &value, const std::string &cmdName="")
 
 CmdChangeAttribute (ImoObj *pImo, EImoAttribute attrb, double value, const std::string &cmdName="")
 
 CmdChangeAttribute (ImoObj *pImo, EImoAttribute attrb, int value, const std::string &cmdName="")
 
 CmdChangeAttribute (ImoObj *pImo, EImoAttribute attrb, Color value, const std::string &cmdName="")
 
virtual ~CmdChangeAttribute ()
 
int get_cursor_update_policy () override
 
int get_undo_policy () override
 
int get_selection_update_policy () override
 
 CmdChangeAttribute (EImoAttribute attrb, const std::string &value, const std::string &cmdName="")
 
 CmdChangeAttribute (EImoAttribute attrb, double value, const std::string &cmdName="")
 
 CmdChangeAttribute (EImoAttribute attrb, int value, const std::string &cmdName="")
 
 CmdChangeAttribute (EImoAttribute attrb, Color value, const std::string &cmdName="")
 
- Public Member Functions inherited from DocCmdSimple
virtual ~DocCmdSimple ()
 
bool is_composite () override
 
- Public Member Functions inherited from DocCommand
virtual ~DocCommand ()
 
std::string get_name ()
 
bool is_reversible ()
 
bool is_recordable ()
 
std::string get_error ()
 

Additional Inherited Members

- Public Types inherited from DocCommand
enum  ECmdCursorPolicy
 
enum  ECmdUndoPolicy
 
enum  ECmdSelectionPolicy
 

Constructor & Destructor Documentation

◆ CmdChangeAttribute() [1/8]

CmdChangeAttribute::CmdChangeAttribute ( EImoAttribute  attrb,
const std::string &  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute on cursor pointed object.

Parameters
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueThe new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

◆ CmdChangeAttribute() [2/8]

CmdChangeAttribute::CmdChangeAttribute ( EImoAttribute  attrb,
double  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute on cursor pointed object.

Parameters
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueThe new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

◆ CmdChangeAttribute() [3/8]

CmdChangeAttribute::CmdChangeAttribute ( EImoAttribute  attrb,
int  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute on cursor pointed object.

Parameters
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueThe new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

◆ CmdChangeAttribute() [4/8]

CmdChangeAttribute::CmdChangeAttribute ( EImoAttribute  attrb,
Color  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute on cursor pointed object.

Parameters
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueThe new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

◆ CmdChangeAttribute() [5/8]

CmdChangeAttribute::CmdChangeAttribute ( ImoObj *  pImo,
EImoAttribute  attrb,
const std::string &  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute in the passed object.

Parameters
pImoPointer to the object whose attribute is going to be changed.
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueAn string with the new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

Example

Todo:
Replace parameter pImo to use object ID instead of a pointer (?)
void CommandHandler::change_attribute(ImoObj* pImo, int attrb, const string& newValue)
{
//change attribute value in given object
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
string name = gettext("Change string property");
SpInteractor->exec_command( new CmdChangeAttribute(pImo, EImoAttribute(attrb), newValue) );
}
}

◆ CmdChangeAttribute() [6/8]

CmdChangeAttribute::CmdChangeAttribute ( ImoObj *  pImo,
EImoAttribute  attrb,
double  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute in the passed object.

Parameters
pImoPointer to the object whose attribute is going to be changed.
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueA double number with the new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.
Todo:
Replace parameter pImo to use object ID instead of a pointer (?)

◆ CmdChangeAttribute() [7/8]

CmdChangeAttribute::CmdChangeAttribute ( ImoObj *  pImo,
EImoAttribute  attrb,
int  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute in the passed object.

Parameters
pImoPointer to the object whose attribute is going to be changed.
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueAn int number with the new value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.
Todo:
Replace parameter pImo to use object ID instead of a pointer (?)

◆ CmdChangeAttribute() [8/8]

CmdChangeAttribute::CmdChangeAttribute ( ImoObj *  pImo,
EImoAttribute  attrb,
Color  value,
const std::string &  cmdName = "" 
)

This command changes the value of an attribute in the passed object.

Parameters
pImoPointer to the object whose attribute is going to be changed.
attrbThe attribute whose value is going to be changed. It must be a value from enum EImoAttribute.
valueThe new Color value for the attribute.
cmdNameThe displayable name for the command. If not specified or empty will default to "Change attribute".

Remarks

  • If target object is not valid (e.g. nullptr), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.
Todo:
Replace parameter pImo to use object ID instead of a pointer (?)

◆ ~CmdChangeAttribute()

virtual CmdChangeAttribute::~CmdChangeAttribute ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ get_cursor_update_policy()

int CmdChangeAttribute::get_cursor_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdCursorPolicy that indicates the update policy followed by this command.

Implements DocCommand.

◆ get_selection_update_policy()

int CmdChangeAttribute::get_selection_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdSelectionPolicy that indicates the undo policy followed by this command.

Implements DocCommand.

◆ get_undo_policy()

int CmdChangeAttribute::get_undo_policy ( )
inlineoverridevirtual

Returns a value from ECmdUndoPolicy that indicates the undo policy followed by this command.

Implements DocCommand.