Lomse library. API documentation  0.30.0
EventPaint Class Reference

#include <lomse_events.h>

Inheritance diagram for EventPaint:
EventInfo

Detailed Description

An event to inform user application about the need to repaint the screen.

The View content (the buffer bitmap) has been updated by Lomse and the user application is not aware of this update. Therefore, Lomse sends this event to inform the user application that it must immediately update the content of the window associated to the lomse View, by displaying the current bitmap. User application must put immediately the content of the currently rendered buffer into the window without calling any Lomse methods (e.g., force_redraw) or generating application events. .

For receiving these events you will have to register a callback when the View is created. For processing these events take into account that this event is decoupled by design: user must do repaint immediately, without more delays; your application should just blit the new bitmap onto the window.

Example

For instance, in an application written using the wxWidgets framework you could do something as:

class DocumentWindow : public wxWindow
{
public:
...
//callback wrappers
static void wrapper_update_window(void* pThis, SpEventInfo pEvent);
...
};
void DocumentWindow::display_document(const string& filename, ostringstream& reporter)
{
...
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
//register to receive desired events
spInteractor->add_event_handler(k_update_window_event, this, wrapper_update_window);
...
}
void DocumentWindow::wrapper_update_window(void* pThis, SpEventInfo pEvent)
{
if (pEvent->get_event_type() == k_update_window_event)
{
SpEventPaint pEv( static_pointer_cast<EventPaint>(pEvent) );
static_cast<DocumentWindow*>(pThis)->update_window(pEv->get_damaged_rectangle());
}
}
void DocumentWindow::update_window(VRect damagedRect)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
if (!m_buffer || !m_buffer->IsOk() || m_buffer->GetSize() != GetClientSize() )
return;
wxClientDC dc(this);
wxBitmap bitmap(*m_buffer);
dc.DrawBitmap(bitmap, 0, 0, false);
SetFocus();
}
}

Public Member Functions

 EventPaint (WpInteractor wpInteractor, VRect damagedRectangle)
 
virtual ~EventPaint ()
 
WpInteractor get_interactor ()
 
VRect get_damaged_rectangle ()
 
- Public Member Functions inherited from EventInfo
virtual ~EventInfo ()
 
virtual Observableget_source ()
 
EEventType get_event_type ()
 
bool is_doc_modified_event ()
 
bool is_update_window_event ()
 
bool is_mouse_in_event ()
 
bool is_mouse_out_event ()
 
bool is_on_click_event ()
 
bool is_link_clicked_event ()
 
bool is_show_contextual_menu_event ()
 
bool is_control_point_moved_event ()
 
bool is_selection_set_change ()
 
bool is_pointed_object_change ()
 
bool is_do_play_score_event ()
 
bool is_pause_score_event ()
 
bool is_stop_playback_event ()
 
bool is_tracking_event ()
 
bool is_update_viewport_event ()
 
bool is_end_of_playback_event ()
 

Constructor & Destructor Documentation

◆ EventPaint()

EventPaint::EventPaint ( WpInteractor  wpInteractor,
VRect  damagedRectangle 
)
inline

Constructor.

◆ ~EventPaint()

virtual EventPaint::~EventPaint ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ get_damaged_rectangle()

VRect EventPaint::get_damaged_rectangle ( )
inline

Returns the damaged rectangle, that is, the rectangle that needs repaint.

◆ get_interactor()

WpInteractor EventPaint::get_interactor ( )
inline

Returns a weak pointer to the Interactor object managing the View in which the event is generated.