Lomse library. API documentation  0.30.0
CmdSelection Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdSelection:
DocCmdSimple DocCommand CmdClearSelection

Detailed Description

A command for modifying current set of selected objects.

See constructor for details.

Public Types

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

Public Member Functions

 CmdSelection (int cmd, const std::string &name="")
 
 CmdSelection (int cmd, ImoId id, const std::string &name="")
 
int get_cursor_update_policy () override
 
int get_undo_policy () override
 
int get_selection_update_policy () override
 
- 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 ()
 

Member Enumeration Documentation

◆ ESelectionAction

This enum describes the possible actions for CmdSelection commands.

Enumerator
k_set 

Set selection: clear current selection and add the objects in the command.

k_add 

Increment the selection by adding the objects in the command.

k_remove 

Remove the objects in the command from the selection.

k_clear 

Empty the selection set.

Constructor & Destructor Documentation

◆ CmdSelection() [1/2]

CmdSelection::CmdSelection ( int  cmd,
const std::string &  name = "" 
)

This command clears the set of selected objects.

Parameters
cmdThe type of action to do on the selection set. Must be CmdSelection::k_clear
nameThe displayable name for the command. If not specified or empty will be replaced by "Selection: clear selection".

Remarks

  • After executing the command:
    • the selection will be empty.
    • the cursor will not change its position.

As parameter cmd must be always k_clear, a convenience class CmdClearSelection(const string& name="") has been defined.

◆ CmdSelection() [2/2]

CmdSelection::CmdSelection ( int  cmd,
ImoId  id,
const std::string &  name = "" 
)

This command changes the content of the set of selected objects.

Parameters
cmdThe type of action to do on the selection set. Must be a value from enum ESelectionAction.
idThe ID of the object to add to or remove from the selection set.
nameThe displayable name for the command. If not specified or empty will be replaced by one of the following strings, depending on value for parameter cmd:
  • k_set: "Selection: set selection".
  • k_add: "Selection: add obj. to selection".
  • k_remove: "Selection: remove obj. from selection".
  • k_clear: "Selection: clear selection"

Remarks

  • After executing the command:
    • the selection will be modified as implied by the command.
    • the cursor will not change its position.

Example

void CommandHandler::select_object(ImoId id, bool fClearSelection)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
string name = gettext("Select object");
int op = fClearSelection ? CmdSelection::k_set : CmdSelection::k_add;
SpInteractor->exec_command( new CmdSelection(op, id, name) );
}
}

Member Function Documentation

◆ get_cursor_update_policy()

int CmdSelection::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 CmdSelection::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 CmdSelection::get_undo_policy ( )
inlineoverridevirtual

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

Implements DocCommand.