//--------------------------------------------------------------------------------------- void TopLevelCaretPositioner::layout_caret(Caret* pCaret, DocCursor* pCursor) { m_pCursor = pCursor; m_state = m_pCursor->get_state(); ImoId id = m_state.get_parent_level_id(); GmoBox* pBox = m_pGModel->get_box_for_imo(id); URect pos; if (pBox) pos = pBox->get_bounds(); else { //at end of document pBox = get_box_for_last_element(); if (pBox) { pos.set_top_left( UPoint(pBox->get_left(), pBox->get_bottom()) ); pos.set_height(1000.0f); pos.set_width(1000.0f); } else { //empty document pos = URect(0.0f, 0.0f, 1000.0f, 1000.0f); } } pCaret->set_type(Caret::k_top_level); pCaret->set_top_level_box(pos); pCaret->set_position( pos.get_top_left() ); pCaret->set_size( USize(pos.get_width(), pos.get_height()) ); }
TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_DocPageHasBoxContent) { Document doc(m_libraryScope); doc.from_string("(lenmusdoc (vers 0.0) " "(pageLayout (pageSize 24000 35700)(pageMargins 1000 1500 3000 2500 4000) landscape) " "(content (score (vers 1.6) " "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" ); DocLayouter dl( doc.get_im_model(), m_libraryScope); dl.layout_document(); GraphicModel* pGModel = dl.get_graphic_model(); GmoBoxDocPage* pPage = pGModel->get_page(0); GmoBox* pBox = pPage->get_child_box(0); CHECK( pBox->is_box_doc_page_content() == true ); CHECK( pBox->get_width() == 16000.0f ); CHECK( pBox->get_height() == 2735.0f ); CHECK( pBox->get_left() == 1000.0f ); CHECK( pBox->get_top() == 1500.0f ); delete pGModel; }