fe::ActionGroupTrigger Class Reference
[Ferry Core library]

Helper to control grouping of text editing actions in editor. More...

List of all members.

Public Member Functions

 ActionGroupTrigger (FeHandle *editor, bool noRedraw)
void disable ()
 ~ActionGroupTrigger ()


Detailed Description

Helper to control grouping of text editing actions in editor.

Constructor & Destructor Documentation

fe::ActionGroupTrigger::ActionGroupTrigger ( FeHandle *  editor,
bool  noRedraw 
) [inline]

Calls fe::IEditorFacade::openActionGroup() on the given editor.

Parameters:
editor handle to the target editor;
noRedraw value of the parameter for fe::IEditorFacade::openActionGroup() function to call on the target editor.

fe::ActionGroupTrigger::~ActionGroupTrigger (  )  [inline]

Calls fe::IEditorFacade::closeActionGroup() on the encapsulated editor if disable() has not been called.

As it is illegal to throw exceptions from destructor there is no way to propagate error that may occur in fe::IEditorFacade::closeActionGroup() call. Thus caller can't know if opened action group get closed. The workaround is to use fe::IEditorFacade::groupActionsCounter() to detect error:

void
bar(fe::FeHandle* handle)
{
    fe::ActionGroupTrigger group(handle, true /* noRedraw */);

    // ...
}


void
foo(fe::FeHandle* handle)
{
    fe::EditorFacadePeer editor(handle);

    // Remember current group counter value.
    const unsigned counter = editor.groupActionsCounter();

    bar(handle);

    if(editor.groupActionsCounter() != counter)
    {   // bar() failed to restore editor's action group counter, i.e.
        // ~ActionGroupTrigger() failed, so report error:
        throw std::runtime_error("~ActionGroupTrigger failed");
    }
}


Member Function Documentation

void fe::ActionGroupTrigger::disable (  )  [inline]

Instructs ~ActionGroupTrigger() not to call fe::IEditorFacade::closeActionGroup() on the encapsulated editor.


The documentation for this class was generated from the following file:

Generated on Tue Nov 18 21:08:22 2008 for Ferry by doxygen 1.5.7.1
http://sourceforge.net