CXTPMarkupObject* CXTPMarkupKeyboardNavigation::GetNextTab(CXTPMarkupObject* e, CXTPMarkupObject* pContainer, BOOL goDownOnly)
{
	XTPMarkupKeyboardNavigationMode keyNavigationMode = GetKeyNavigationMode(pContainer);
	if (e == NULL)
	{
		if (IsTabStop(pContainer))
		{
			return pContainer;
		}
		CXTPMarkupObject* pActiveElement = GetActiveElement(pContainer);
		if (pActiveElement)
		{
			return GetNextTab(NULL, pActiveElement, TRUE);
		}
	}
	else if (((keyNavigationMode == xtpMarkupKeyboardNavigationOnce) || (keyNavigationMode == xtpMarkupKeyboardNavigationNone)) && (pContainer != e))
	{
		if (goDownOnly)
		{
			return NULL;
		}
		CXTPMarkupObject* groupParent = GetGroupParent(pContainer);
		return GetNextTab(pContainer, groupParent, goDownOnly);
	}
	CXTPMarkupObject* obj4 = NULL;
	CXTPMarkupObject* obj5 = e;
	XTPMarkupKeyboardNavigationMode tabbingType = keyNavigationMode;
	while ((obj5 = GetNextTabInGroup(obj5, pContainer, tabbingType)) != NULL)
	{
		if (obj4 == obj5)
		{
			break;
		}
		if (obj4 == NULL)
		{
			obj4 = obj5;
		}
		CXTPMarkupObject* obj6 = GetNextTab(NULL, obj5, TRUE);
		if (obj6 != NULL)
		{
			return obj6;
		}
		if (tabbingType == xtpMarkupKeyboardNavigationOnce)
		{
			tabbingType = xtpMarkupKeyboardNavigationContained;
		}
	}
	if ((!goDownOnly && (tabbingType != xtpMarkupKeyboardNavigationContained)) && (GetParent(pContainer) != NULL))
	{
		return GetNextTab(pContainer, GetGroupParent(pContainer), FALSE);
	}
	return NULL;
}
Exemplo n.º 2
0
void CTabBarClass::Switch(BOOL abForward, BOOL abAltStyle/*=FALSE*/)
{
	int nNewSel = GetNextTab(abForward, abAltStyle);

	if (nNewSel != -1)
	{
		// mh_Tabbar может быть и создан, Но отключен пользователем!
		if (gpSet->isTabLazy && mp_Rebar->IsTabbarCreated() && gpSet->isTabs)
		{
			mb_InKeySwitching = true;
			// Пока Ctrl не отпущен - только подсвечиваем таб, а не переключаем реально
			SelectTab(nNewSel);
		}
		else
		{
			mb_InKeySwitching = gpSet->isTabRecent;
			// Пока Ctrl не отпущен - подсвечиваем таб
			if (gpSet->isTabRecent)
				SelectTab(nNewSel);
			mp_Rebar->FarSendChangeTab(nNewSel);
		}
	}
}
void CXTPMarkupKeyboardNavigation::Navigate(CXTPMarkupInputElement* pCurrentElement, XTPMarkupFocusNavigationDirection direction)
{
	CXTPMarkupObject* pNextInDirection = NULL;
	switch (direction)
	{
	case xtpMarkupFocusNavigationDirectionNext:
		m_pNavigationProperty = m_pTabNavigationProperty;
		pNextInDirection = GetNextTab(pCurrentElement, GetGroupParent(pCurrentElement, TRUE), FALSE);
		break;

   /*case xtpMarkupFocusNavigationDirectionPrevious:
		m_pNavigationProperty = m_pTabNavigationProperty;
		pNextInDirection = GetPrevTab(pCurrentElement, NULL, FALSE);
		break;*/
	}

	if (pNextInDirection != NULL)
	{
		if (pNextInDirection->IsKindOf(MARKUP_TYPE(CXTPMarkupInputElement)))
		{
			((CXTPMarkupInputElement*)pNextInDirection)->Focus();
		}
	}
}
Exemplo n.º 4
0
void
RichTextBox::DrawRichText(Rect& text_rect)
{
    // clip the rect:
    Rect clip_rect = ClipRect(text_rect);
    clip_rect.h -= 8;

    if (clip_rect.w < 1 || clip_rect.h < 1)
    return;

    const char* t     = text.data();
    int count         = text.length();
    int nlines        = 0;

    int xpos          = 0;
    int block_start   = 0;
    int block_count   = 0;
    int curr_word_end = -1;
    int next_word_end = 0;
    int eol_index     = 0;

    int new_line      = 0;
    int x_offset      = 0;
    int y_offset      = 0;
    int length        = 0;

    Font* rich_font   = font;
    rich_font->SetColor(fore_color);

    if (smooth_scroll) {
        double fraction = smooth_offset - (int) smooth_offset;

        y_offset = (int) ((1-fraction) * (rich_font->Height() + leading));
    }

    // while there is still text:
    while (block_start < count) {
        bool found_tag = false;

        do {
            found_tag = false;

            if (t[block_start] == '<') {
                block_start = process_tag(t, block_start, rich_font);
                found_tag = true;
            }

            else if (t[block_start] == '\t') {
                block_start++;
                x_offset = GetNextTab(x_offset);

                if (x_offset > text_rect.w) {
                    nlines++;
                    if (nlines > top_index)
                    y_offset += rich_font->Height() + leading;
                    x_offset = 0;
                    new_line = false;
                }

                found_tag = true;
            }

            else if (t[block_start] == '\r') {
                block_start++;

                if (t[block_start] == '\n')
                block_start++;

                nlines++;
                if (nlines > top_index)
                y_offset += rich_font->Height() + leading;
                x_offset = 0;
                new_line = false;

                found_tag = true;
            }

            else if (t[block_start] == '\n') {
                block_start++;

                if (t[block_start] == '\r')
                block_start++;

                nlines++;
                if (nlines > top_index)
                y_offset += rich_font->Height() + leading;
                x_offset = 0;
                new_line = false;

                found_tag = true;
            }
        }
        while (found_tag);

        next_word_end = find_next_word_end(t, block_start);

        if (!next_word_end || next_word_end == curr_word_end) {
            new_line = true;
        }

        else if (t[next_word_end] == '\n') {
            eol_index = curr_word_end = next_word_end;
            new_line = true;
        }

        else {
            int word_len = next_word_end - block_start + 1;

            length = rich_font->StringWidth(t+block_start, word_len);

            // if this word was too long, wrap to next line:
            if (x_offset + length > text_rect.w) {
                nlines++;
                if (nlines > top_index)
                y_offset += rich_font->Height() + leading;
                x_offset = 0;
                new_line = false;
            }

            // is there a trailing newline?
            curr_word_end = next_word_end;

            // check for a newline in the next block of white space:
            eol_index = 0;
            const char* eol = &t[curr_word_end+1];
            while (*eol && isspace(*eol) && *eol != '\n')
            eol++;

            if (*eol == '\n') {
                eol_index = eol - t;
                new_line = true;
            }
        }

        block_count = curr_word_end - block_start + 1;

        if (block_count > 0) {
            length = rich_font->StringWidth(t+block_start, block_count);
        }

        // there was a single word longer than the entire line:
        else {
            block_count = next_word_end - block_start + 1;
            length = rich_font->StringWidth(t+block_start, block_count);
            curr_word_end = next_word_end;
        }

        if (length > 0 && nlines >= top_index && nlines < top_index+page_size) {
            int x1 = text_rect.x + x_offset + rect.x;
            int y1 = text_rect.y + y_offset + rect.y;

            rich_font->DrawString(t+block_start, block_count, x1, y1, clip_rect);
        }

        if (new_line) {
            nlines++;
            if (nlines > top_index)
            y_offset += rich_font->Height() + leading;
            x_offset = 0;
            new_line = false;
        }

        else if (length < 1 || text[next_word_end] == '-') {
            x_offset += length;
        }

        else {
            x_offset += length + rich_font->SpaceWidth();
        }

        if (eol_index > 0)
        curr_word_end = eol_index;

        block_start = find_next_word_start(t, curr_word_end+1);
    }

    line_count = nlines;
}