本文整理汇总了C++中FramePtr::line_of_word方法的典型用法代码示例。如果您正苦于以下问题:C++ FramePtr::line_of_word方法的具体用法?C++ FramePtr::line_of_word怎么用?C++ FramePtr::line_of_word使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FramePtr
的用法示例。
在下文中一共展示了FramePtr::line_of_word方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjust_words
ERRORCODE TextFlow::adjust_words(DB_RECORD_NUMBER p_record,
DB_RECORD_NUMBER f_record,
CHARACTER_DELTA cdelta, WORD_DELTA_PTR wdelta)
{
ParagraphPtr paragraph;
W_INDEX w_index;
TEXT_WORD_PTR wp;
ERRORCODE error;
/* Redisplay vars */
LINE_PTR lp;
FramePtr frame;
PCOORD erase_xmin, erase_xmax;
W_INDEX old_windex;
L_INDEX l_index;
BOOL deleted_something;
/*
// Initialize the word delta structure first.
*/
wdelta->w_start = -1;
wdelta->count = 0;
/* Make sure we avoid busy work. */
if (cdelta.count == 0)
{
return ERRORCODE_None;
}
/* Lock the paragraph so we can access it. */
if ((paragraph = (ParagraphPtr)database->get_record(p_record, &error, RECORD_TYPE_Paragraph)) == NULL)
{
return error;
}
/* Get the frame object. */
if ((frame = (FramePtr)database->get_record(f_record, &error, RECORD_TYPE_Frame)) == NULL)
{
paragraph->release();
return error;
}
/*
// Run through the word array and update all words which need it.
// We must be careful using a pointer into the word array data since any
// deletions can cause the array data to change locations.
*/
/* Initialize redisplay variables */
deleted_something = FALSE;
lp = NULL;
old_windex = 0;
l_index = frame->line_of_word(0, NULL);
lp = (LINE_PTR)frame->line.get_element(l_index);
for (wp = (TEXT_WORD_PTR)paragraph->word.get_element(0), w_index = 0;
w_index < paragraph->word.count();
old_windex++,
w_index++, wp++)
{
C_INDEX this_start;
if ((this_start = wp->c_start) >= cdelta.c_start)
{
/* This has moved. Move it now. */
/* If deleting, see if the array is still valid. */
if ((this_start += cdelta.count) <= cdelta.c_start)
{
this_start = cdelta.c_start;
if (!deleted_something)
{
deleted_something = TRUE;
erase_xmin = wp->x_offset + wp->draw_left;
erase_xmax = wp->x_offset + wp->draw_width;
}
/*
// Update the word delta.
// This makes the (valid) assumption that words which get
// deleted are all contiguous.
*/
if (wdelta->w_start == -1)
{
wdelta->w_start = w_index;
/* Start updating w1 (last word to erase) */
l_index = frame->line_of_word(w_index, NULL);
lp = (LINE_PTR)frame->line.get_element(l_index);
erase_xmax = __max(erase_xmax, wp->x_offset + wp->draw_width);
erase_xmin = __min(erase_xmin, wp->x_offset + wp->draw_left);
}
else
//.........这里部分代码省略.........
示例2: rebuild_words
//.........这里部分代码省略.........
/* Get the first index of the next word. */
if ((c_index = paragraph->get_word(w_end+1)->c_start-1) > crange.c_end)
{
/* Move forward to end of word. */
crange.c_end = c_index;
}
#ifdef DEBUG_RW
printf("End offset moves to %d\n", crange.c_end);
#endif
/*
// Delete the existing range if we have one.
// Perhaps this should be optimized someday to do all at once!
*/
if (w_end >= w_start)
{
/* Redisplay variables */
BOOL new_line = TRUE;
L_INDEX l_index;
LINE_PTR lp;
TEXT_WORD_PTR wp0;
PCOORD erase_xmin, erase_xmax;
if ((frame = (FramePtr)database->get_record(f_record, &error, RECORD_TYPE_Frame)) == NULL)
{
paragraph->release();
return error;
}
/* Get line pointer for redisplay purposes */
l_index = frame->line_of_word(w_end, NULL);
lp = frame->get_line(l_index);
erase_xmin = 0x7fffffff;
erase_xmax = -erase_xmin;
wdelta->count = -(w_end - w_start + 1);
while (w_end >= w_start)
{
#ifdef DEBUG_RW
printf("Delete word %d\n", w_end);
#endif
wp0 = paragraph->get_word(w_end);
if (!new_line && w_end < lp->w_start)
{
new_line = TRUE;
add_width_refresh_extent(frame, lp,
erase_xmin, erase_xmax, REFRESH_ERASE);
lp--;
}
if (new_line)
{
new_line = FALSE;
erase_xmin = wp0->x_offset + wp0->draw_left;
erase_xmax = wp0->x_offset + wp0->draw_width;
}
else
{
erase_xmin = __min(erase_xmin, wp0->x_offset + wp0->draw_left);
erase_xmax = __max(erase_xmax, wp0->x_offset + wp0->draw_width);
}
示例3: refresh_frame
ERRORCODE TextFlow::refresh_frame(DB_RECORD_NUMBER f_record, CHARACTER_RANGE crange)
{
ERRORCODE error;
DB_RECORD_NUMBER p_record;
WORD_RANGE wrange;
FramePtr frame;
ParagraphPtr paragraph;
LINE line;
PBOX pbox;
/* Get the frame. */
if ((frame = (FramePtr)database->get_record(f_record, &error, RECORD_TYPE_Frame)) == NULL)
{
return error;
}
p_record = frame->get_paragraph();
/* Get the paragraph of the frame. */
if ((paragraph = (ParagraphPtr)database->get_record(p_record, &error, RECORD_TYPE_Paragraph)) == NULL)
{
frame->release();
return error;
}
/* Fix the character range if special values were used. */
if (crange.c_start < 0)
{
crange.c_start = 0;
}
if (crange.c_end < 0)
{
crange.c_end = paragraph->number_of_characters();
}
/* Get the word range. */
paragraph->crange_to_wrange(crange, &wrange);
paragraph->release();
/* Get the top (and possibly bottom) line.*/
frame->line_of_word(wrange.w_start, &line);
pbox.y0 = line.baseline - line.ascend;
/* Now see if the words differ. If not, we must be on the same line. */
if (wrange.w_end != wrange.w_start)
{
/* Get the bottom line. */
frame->line_of_word(wrange.w_end, &line);
}
pbox.y1 = line.baseline + line.descend;
/* Get the frame so we can get the bound. */
PBOX bound = frame->get_bound();
FLAGS object_flags = frame_object->get_flags();
pbox.x0 = bound.x0;
pbox.x1 = bound.x1;
if (object_flags & OBJECT_FLAG_yflipped)
{
PCOORD y0 = pbox.y0;
pbox.y0 = bound.y1 - pbox.y1;
pbox.y1 = bound.y1 - y0;
}
else
{
pbox.y0 += bound.y0;
pbox.y1 += bound.y0;
}
frame->release();
/* Do the actual refresh add. */
database->do_refresh_notify(&pbox, REFRESH_ALL, NULL);
return ERRORCODE_None;
}