Esempio n. 1
0
//---------------------------------------------------------------------------------------
void HyperlinkCtrl::handle_event(SpEventInfo pEvent)
{
    LOMSE_LOG_DEBUG(Logger::k_events, str(boost::format("label: %s") % m_label));

    if (m_fEnabled)
    {
        if (pEvent->is_mouse_in_event())
        {
            m_currentColor = m_hoverColor;
            m_pMainBox->set_dirty(true);
        }
        else if (pEvent->is_mouse_out_event())
        {
            m_currentColor = m_prevColor;
            m_pMainBox->set_dirty(true);
        }
        else if (pEvent->is_on_click_event())
        {
            m_visited = true;
            m_prevColor = m_visitedColor;
        }

        LOMSE_LOG_DEBUG(Logger::k_events, "Asking Document to notify observers");
        m_pDoc->notify_observers(pEvent, this);
    }
}
Esempio n. 2
0
//=======================================================================================
// GmoBoxLink
//=======================================================================================
void GmoBoxLink::notify_event(SpEventInfo pEvent)
{
    if (pEvent->is_mouse_in_event())
    {
        LOMSE_LOG_DEBUG(Logger::k_events, "set hover true");
        set_hover(true);
        set_dirty(true);
    }
    else if (pEvent->is_mouse_out_event())
    {
        LOMSE_LOG_DEBUG(Logger::k_events, "set hover false");
        set_hover(false);
        set_dirty(true);
    }
    else if (pEvent->is_on_click_event())
    {
        LOMSE_LOG_ERROR("is_on_click_event: TODO");
        //TODO: GmoBoxLink::notify_event, on_click_event
//        m_visited = true;
//        m_prevColor = m_visitedColor;
    }
    else
    {
        LOMSE_LOG_DEBUG(Logger::k_events, "event ignored");
    }
}
Esempio n. 3
0
//---------------------------------------------------------------------------------------
void ScorePlayerCtrl::handle_event(SpEventInfo pEvent)
{
    SpEventMouse pEv( static_pointer_cast<EventMouse>(pEvent) );
    if (!pEv->is_still_valid())
        return;

    if (m_fEnabled)
    {
        if (pEvent->is_mouse_in_event())
        {
            LOMSE_LOG_DEBUG(Logger::k_events | Logger::k_score_player,
                            "Mouse in event received");
            m_currentColor = m_hoverColor;
            m_fFullView = true;
            m_pMainBox->set_dirty(true);
        }
        else if (pEvent->is_mouse_out_event())
        {
            LOMSE_LOG_DEBUG(Logger::k_events | Logger::k_score_player,
                            "Mouse out event received");
            m_fFullView = false;
            m_currentColor = m_normalColor;
            m_pMainBox->set_dirty(true);
        }
        else if (pEvent->is_on_click_event())
        {
            LOMSE_LOG_DEBUG(Logger::k_events | Logger::k_score_player,
                            "Mouse on-click event received");
            m_fFullView = true;
            bool fPlay = (m_playButtonState == k_play );
            if (fPlay)
            {
                set_play_button_state(k_stop);
            }
            else
            {
                set_play_button_state(k_play);
            }

            //create event for user app
            EEventType evType = (fPlay ? k_do_play_score_event : k_stop_playback_event); //k_pause_score_event);
            WpInteractor wpIntor = pEv->get_interactor();
            if (SpInteractor p = wpIntor.lock())
            {
                ImoScore* pScore = m_pOwnerImo->get_score();
                SpEventPlayScore event(
                    LOMSE_NEW EventPlayScore(evType, wpIntor, pScore, this) );

                //AWARE: we notify directly to user app. (to observers of Interactor)
                p->notify_observers(event, p.get());
            }
        }
        else
        {
            LOMSE_LOG_WARN(str(boost::format("Unknown event received. Type=%d")
                               % pEvent->get_event_type()) );
        }
    }
}
Esempio n. 4
0
//---------------------------------------------------------------------------------------
void Layouter::layout_item(ImoContentObj* pItem, GmoBox* pParentBox)
{
    LOMSE_LOG_DEBUG(Logger::k_layout, str(boost::format(
        "Laying out id %d %s") % pItem->get_id() % pItem->get_name() ));

    m_pCurLayouter = create_layouter(pItem);

    m_pCurLayouter->prepare_to_start_layout();
    while (!m_pCurLayouter->is_item_layouted())
    {
        m_pCurLayouter->create_main_box(pParentBox, m_pageCursor,
                                        m_availableWidth, m_availableHeight);
        m_pCurLayouter->layout_in_box();
        m_pCurLayouter->set_box_height();

        if (!m_pCurLayouter->is_item_layouted())
        {
            pParentBox = start_new_page();
        }
    }
    m_pCurLayouter->add_end_margins();

    //update cursor and available space
    GmoBox* pChildBox = m_pCurLayouter->get_item_main_box();
    if (pChildBox)  //AWARE: NullLayouter does not create a box
    {
        m_pageCursor.y = pChildBox->get_bottom();
        m_availableHeight -= pChildBox->get_height();
    }

    if (!pItem->is_score())
        delete m_pCurLayouter;
}
Esempio n. 5
0
//---------------------------------------------------------------------------------------
bool EventNotifier::notify_observers(SpEventInfo pEvent, Observable* target)
{
    //returns true if event is dispatched to an observer

    std::list<Observer*>::iterator it;
    for (it = m_observers.begin(); it != m_observers.end(); ++it)
    {
        Observable* observedTarget = (*it)->target();
        bool fNotify = (observedTarget == target);

        //bubbling phase. This observer is not observing target but might be
        //observing its parents
        if (!fNotify)
        {
            ImoObj* pImo = dynamic_cast<ImoObj*>(target);
            Observable* pObs = target;
            if (pImo && pObs)
            {
                while(pImo && pObs && pObs != observedTarget)
                {
                    pObs = pImo->get_observable_parent();
                    pImo = dynamic_cast<ImoObj*>( pObs );
                }
                fNotify = (pObs == observedTarget);
                //TODO: do notification and continue bubbling.
            }
        }

        if (fNotify)
        {
            LOMSE_LOG_DEBUG(Logger::k_events, "Posting event.");
            m_pDispatcher->post_event((*it), pEvent);
//            (*it)->notify(pEvent);
            return true;
            //TODO: remove 'return' when following problem is fixed:
            //    Object receiving notification might modify the document (i.e. link
            //    'new problem') and this will invalidate target and all remaining
            //    objects in m_observers (!!!!)
        }
    }
    LOMSE_LOG_DEBUG(Logger::k_events, "No observers. Event ignored");
    return false;
}
Esempio n. 6
0
//---------------------------------------------------------------------------------------
void Layouter::set_cursor_and_available_space()
{
    m_pageCursor.x = m_pItemMainBox->get_content_left();
    m_pageCursor.y = m_pItemMainBox->get_content_top();

    m_availableWidth = m_pItemMainBox->get_content_width();
    m_availableHeight = m_pItemMainBox->get_content_height();

    LOMSE_LOG_DEBUG(Logger::k_layout, str(boost::format(
        "cursor at(%.2f, %.2f), available space(%.2f, %.2f)")
        % m_pageCursor.x % m_pageCursor.y % m_availableWidth % m_availableHeight ));
}
Esempio n. 7
0
//---------------------------------------------------------------------------------------
GmoBox* Layouter::start_new_page()
{
    LOMSE_LOG_DEBUG(Logger::k_layout, "");

    GmoBox* pParentBox = m_pParentLayouter->start_new_page();

    m_pageCursor = m_pParentLayouter->get_cursor();
    m_availableWidth = m_pParentLayouter->get_available_width();
    m_availableHeight = m_pParentLayouter->get_available_height();

    create_main_box(pParentBox, m_pageCursor, m_availableWidth, m_availableHeight);

    return m_pItemMainBox;
}
Esempio n. 8
0
//---------------------------------------------------------------------------------------
void TableRowLayouter::layout_in_box()
{
    LOMSE_LOG_DEBUG(Logger::k_layout, string(""));

    set_cursor_and_available_space();
    LUnits yPos = m_pageCursor.y;

    //loop to layout the cells in this rows group range
    vector<LUnits> cellHeights;
    cellHeights.assign(m_cellLayouters.size(), 0.0f);

    int iRow = m_iFirstRow;
    for (int i=0; i < m_numRows; ++i, ++iRow)
    {
        LUnits xPos = m_pItemMainBox->get_content_left();
        for (int iCol=0; iCol < m_numColumns; ++iCol)
        {
            int iCell = iRow * m_numColumns + iCol;
            if (m_cellLayouters[iCell] != nullptr)
            {
                LUnits height = layout_cell(m_cellLayouters[iCell], m_pItemMainBox,
                                            UPoint(xPos, m_pageCursor.y));
                cellHeights[iCell] = height;
            }
            xPos += m_columnsWidth[iCol];
        }
    }

    //set height and final position of cells
    TableCellSizer sizer(m_cellLayouters, cellHeights, m_iFirstRow,
                         m_numRows, m_numColumns);
    sizer.assign_height_and_reposition_cells();
    yPos += sizer.get_total_height();

    //update cursor and available space
    LUnits height = yPos - m_pageCursor.y;
    m_pageCursor.y = yPos;
    m_availableHeight -= height;

    set_layout_is_finished(true);
}
Esempio n. 9
0
//---------------------------------------------------------------------------------------
void TableLayouter::layout_in_box()
{
    LOMSE_LOG_DEBUG(Logger::k_layout, string(""));

    //AWARE: This method is invoked to layout a page. If there are more pages to
    //layout, it will be invoked more times. Therefore, this method must not initialize
    //anything. All initializations must be done in 'prepare_to_start_layout()'.
    //layout_in_box() method must always continue laying out from current state.

    set_cursor_and_available_space();

    add_head();       //TO_FIX: It is assumed that head always fit in current page

    if (m_bodyLayouter)
    {
        m_bodyLayouter->set_origin(m_pageCursor);

        if (!is_body_row_ready())
            prepare_body_row();

        if (!is_body_row_ready())
        {
            //problem or empty body. Terminate table laying out
            set_layout_is_finished(true);
            return;
        }

        //loop to add rows
        while(is_body_row_ready() && enough_space_in_box())
        {
            add_body_row();
            prepare_body_row();
        }
    }

    bool fMoreRows = (m_bodyLayouter && m_bodyLayouter->is_row_ready());
    set_layout_is_finished( !fMoreRows );
}
Esempio n. 10
0
//---------------------------------------------------------------------------------------
void TableSectionLayouter::create_main_box(GmoBox* UNUSED(pParentBox),
                                           UPoint UNUSED(pos), LUnits UNUSED(width),
                                           LUnits UNUSED(height))
{
    LOMSE_LOG_DEBUG(Logger::k_layout, string(""));
}
Esempio n. 11
0
//---------------------------------------------------------------------------------------
void TableSectionLayouter::layout_in_box()
{
    LOMSE_LOG_DEBUG(Logger::k_layout, string(""));
}