Lomse library. API documentation  0.30.0
CmdInsertBlockLevelObj Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdInsertBlockLevelObj:
CmdInsert DocCmdSimple DocCommand

Detailed Description

A command for inserting a new block level object (e.g. paragraph, music score, header, etc.).

See constructors for details.

Public Member Functions

 CmdInsertBlockLevelObj (int type, const std::string &name="")
 
 CmdInsertBlockLevelObj (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

◆ CmdInsertBlockLevelObj() [1/2]

CmdInsertBlockLevelObj::CmdInsertBlockLevelObj ( int  type,
const std::string &  name = "" 
)

This command inserts a new block level object (e.g. paragraph, music score, header, etc.).

Parameters
typeType of block level object to insert. Must be one of the values for block level objects in enum #EImoObjType.
nameThe displayable name for the command. If not specified or empty will be replaced by the string "Insert " followed by the name of the object, as implied by param type.

Remarks

  • The new element will be inserted before the object currently pointed by the cursor.
  • 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

Consider an edition application in which the expected user interaction pattern is as follows:

  • First, user creates a new empty document. As the document is empty the cursor points to 'end of document'.
  • Then the user clicks on the "add music score" tool and execution arrives to the following code:
//insert a music score
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
src = "<ldpmusic>(score (vers 2.0)(instrument (musicData)))</ldpmusic>";
SpInteractor->exec_command( new CmdInsertBlockLevelObj(src, "Add empty music score") );
}

◆ CmdInsertBlockLevelObj() [2/2]

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

This command inserts a new block level object (e.g. paragraph, music score, header, image, etc.).

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

Remarks

  • The new element will be inserted before the object currently pointed by the cursor.
  • The new inserted object will be empty.
  • 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

Consider an edition application in which the expected user interaction pattern is as follows:

  • First, user creates a new empty document. As the document is empty the cursor points to 'end of document'.
  • Then the user clicks on the "add paragraph" tool and execution arrives to the following code:
//insert a paragraph
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
SpInteractor->exec_command( new CmdInsertBlockLevelObj(k_imo_para, "Add empty paragraph") );

Member Function Documentation

◆ get_cursor_update_policy()

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

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

Implements DocCommand.