Lomse library. API documentation  0.30.0
CmdInsertStaffObj Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdInsertStaffObj:
CmdInsert DocCmdSimple DocCommand

Detailed Description

A command for inserting one staff object (e.g. a note, rest, clef, barline, etc.).

See constructor for details.

Public Member Functions

 CmdInsertStaffObj (const std::string &source, 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 CmdInsert
ImoId last_inserted_id ()
 
- 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

◆ CmdInsertStaffObj()

CmdInsertStaffObj::CmdInsertStaffObj ( const std::string &  source,
const std::string &  name = "" 
)

This command inserts one staff object (e.g. a note, rest, clef, barline, etc.) before object pointed by the cursor.

Parameters
sourceThe source code of the elements to insert. It must be in LDP format.
nameThe displayable name for the command. If not specified or empty will be replaced by the string "Insert " followed by the name of the inserted object.

Remarks

  • The new element will be inserted before the object currently pointed by the cursor.
  • The command will return a failure code if the cursor is not inside a music score.
  • After executing the command:
    • the selection will not be altered.
    • the cursor will not change its position. The inserted object will be just behind the cursor.

Example

void CommandHandler::insert_clef(int clefType, int staff)
{
//insert a Clef at current cursor position
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
stringstream src;
src << "(clef "
<< LdpExporter::clef_type_to_ldp(clefType)
<< " p"
<< staff+1
<< ")";
string name = gettext("Insert clef");
SpInteractor->exec_command( new CmdInsertStaffObj(src.str(), name) );
}
}

Member Function Documentation

◆ get_cursor_update_policy()

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

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

Implements DocCommand.