예제 #1
0
void VideoRendererItem::setChromaUpscaler(InterpolatorType type) {
	if (_Change(d->chromaUpscaler, type)) {
		if (d->shader)
			d->shader->setChromaInterpolator(d->chromaUpscaler);
		rerender();
	}
}
예제 #2
0
 virtual void
 onResize( const QSize & size ) override
 {
     m_clientSize = size;
     m_center = QPointF( size.width() - m_radius, size.height() - m_radius );
     rerender();
 }
예제 #3
0
파일: html.c 프로젝트: grobe0ba/plan9front
void
rendertext(URLwin *u, Bytes *b)
{
	Rune *rurl;

	rurl = toStr((uchar*)u->url, strlen(u->url), UTF_8);
	u->items = parsehtml(b->b, b->n, rurl, u->type, UTF_8, &u->docinfo);
//	free(rurl);

	rerender(u);
}
예제 #4
0
 virtual void
 onInputEvent( const Carta::Lib::InputEvent & ev ) override
 {
     qDebug() << "Bouncy layer received event" << ev.json()["type"];
     Carta::Lib::InputEvents::TouchEvent touch( ev );
     if ( touch.valid() ) {
         qDebug() << "Bouncy touch:" << touch.pos();
         m_center = touch.pos();
         rerender();
     }
 }
예제 #5
0
파일: html.c 프로젝트: 00001/plan9port
void
rendertext(URLwin *u, Bytes *b)
{
	Rune *rurl;

	rurl = toStr((uchar*)u->url, strlen(u->url), ISO_8859_1);
	u->items = parsehtml(b->b, b->n, rurl, u->type, charset((char*)b->b), &u->docinfo);
/*	free(rurl); */

	rerender(u);
}
CKJVBrowser::CKJVBrowser(CVerseListModel *pModel, CBibleDatabasePtr pBibleDatabase, QWidget *parent) :
	QWidget(parent),
	m_pBibleDatabase(pBibleDatabase),
	m_ndxCurrent(0),
	m_SearchResultsHighlighter(pModel, false),
	m_ExcludedSearchResultsHighlighter(pModel, true),
	m_bShowExcludedSearchResults(CPersistentSettings::instance()->showExcludedSearchResultsInBrowser()),
	m_bDoingUpdate(false),
#ifndef PLASTIQUE_STATIC
	m_pPlastiqueStyle(NULL),
#endif
	m_bDoingPassageReference(false),
	m_pScriptureBrowser(NULL)
{
	assert(!m_pBibleDatabase.isNull());
	assert(!g_pUserNotesDatabase.isNull());

	ui.setupUi(this);

#ifndef PLASTIQUE_STATIC
	m_pPlastiqueStyle = new QProxyStyle(QStyleFactory::create("plastique"));
#endif

	initialize();

	assert(m_pScriptureBrowser != NULL);

	ui.lblBibleDatabaseName->setText(m_pBibleDatabase->description());

	setNavigationActivationDelay(CPersistentSettings::instance()->navigationActivationDelay());
	setPassageReferenceActivationDelay(CPersistentSettings::instance()->passageReferenceActivationDelay());
	setBrowserNavigationPaneMode(CPersistentSettings::instance()->browserNavigationPaneMode());

	connect(CPersistentSettings::instance(), SIGNAL(changedNavigationActivationDelay(int)), this, SLOT(setNavigationActivationDelay(int)));
	connect(CPersistentSettings::instance(), SIGNAL(changedPassageReferenceActivationDelay(int)), this, SLOT(setPassageReferenceActivationDelay(int)));
	connect(CPersistentSettings::instance(), SIGNAL(changedChapterScrollbarMode(CHAPTER_SCROLLBAR_MODE_ENUM)), this, SLOT(en_changedChapterScrollbarMode()));
	connect(CPersistentSettings::instance(), SIGNAL(changedBrowserNavigationPaneMode(BROWSER_NAVIGATION_PANE_MODE_ENUM)), this, SLOT(setBrowserNavigationPaneMode(BROWSER_NAVIGATION_PANE_MODE_ENUM)));

// Data Connections:
	connect(pModel, SIGNAL(verseListAboutToChange()), this, SLOT(en_SearchResultsVerseListAboutToChange()));
	connect(pModel, SIGNAL(verseListChanged()), this, SLOT(en_SearchResultsVerseListChanged()));

// UI Connections:
	connect(m_pScriptureBrowser, SIGNAL(gotoIndex(const TPhraseTag &)), &m_dlyGotoIndex, SLOT(trigger(const TPhraseTag &)));
	connect(&m_dlyGotoIndex, SIGNAL(triggered(const TPhraseTag &)), this, SLOT(gotoIndex(const TPhraseTag &)));
	connect(this, SIGNAL(en_gotoIndex(const TPhraseTag &)), m_pScriptureBrowser, SLOT(en_gotoIndex(const TPhraseTag &)));
	connect(m_pScriptureBrowser, SIGNAL(sourceChanged(const QUrl &)), this, SLOT(en_sourceChanged(const QUrl &)));
	connect(m_pScriptureBrowser, SIGNAL(cursorPositionChanged()), this, SLOT(en_selectionChanged()));

	connect(ui.btnHideNavigation, SIGNAL(clicked()), this, SLOT(en_clickedHideNavigationPane()));

	connect(ui.comboBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBkComboIndexChanged(int)));
	connect(ui.comboBkChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBkChpComboIndexChanged(int)));
	connect(ui.comboTstBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayTstBkComboIndexChanged(int)));
	connect(ui.comboTstChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayTstChpComboIndexChanged(int)));
	connect(ui.comboBibleBk, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBibleBkComboIndexChanged(int)));
	connect(ui.comboBibleChp, SIGNAL(currentIndexChanged(int)), this, SLOT(delayBibleChpComboIndexChanged(int)));

	connect(ui.widgetPassageReference, SIGNAL(passageReferenceChanged(const TPhraseTag &)), this, SLOT(delayPassageReference(const TPhraseTag &)));
	connect(ui.widgetPassageReference, SIGNAL(enterPressed()), this, SLOT(PassageReferenceEnterPressed()));

	connect(&m_dlyBkCombo, SIGNAL(triggered(int)), this, SLOT(BkComboIndexChanged(int)));
	connect(&m_dlyBkChpCombo, SIGNAL(triggered(int)), this, SLOT(BkChpComboIndexChanged(int)));
	connect(&m_dlyTstBkCombo, SIGNAL(triggered(int)), this, SLOT(TstBkComboIndexChanged(int)));
	connect(&m_dlyTstChpCombo, SIGNAL(triggered(int)), this, SLOT(TstChpComboIndexChanged(int)));
	connect(&m_dlyBibleBkCombo, SIGNAL(triggered(int)), this, SLOT(BibleBkComboIndexChanged(int)));
	connect(&m_dlyBibleChpCombo, SIGNAL(triggered(int)), this, SLOT(BibleChpComboIndexChanged(int)));

	connect(&m_dlyPassageReference, SIGNAL(triggered(const TPhraseTag &)), this, SLOT(PassageReferenceChanged(const TPhraseTag &)));

	connect(m_pScriptureBrowser, SIGNAL(activatedScriptureText()), this, SLOT(en_activatedScriptureText()));
	connect(ui.widgetPassageReference, SIGNAL(activatedPassageReference()), this, SLOT(en_activatedPassageReference()));

	// Set Outgoing Pass-Through Signals:
	connect(m_pScriptureBrowser, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
	connect(m_pScriptureBrowser, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
	connect(m_pScriptureBrowser, SIGNAL(historyChanged()), this, SIGNAL(historyChanged()));

	// Set Incoming Pass-Through Signals:
	connect(this, SIGNAL(backward()), m_pScriptureBrowser, SLOT(backward()));
	connect(this, SIGNAL(forward()), m_pScriptureBrowser, SLOT(forward()));
	connect(this, SIGNAL(home()), m_pScriptureBrowser, SLOT(home()));
	connect(this, SIGNAL(reload()), m_pScriptureBrowser, SLOT(reload()));
	connect(this, SIGNAL(rerender()), m_pScriptureBrowser, SLOT(rerender()));

	// Highlighting colors changing:
	connect(CPersistentSettings::instance(), SIGNAL(changedColorSearchResults(const QColor &)), this, SLOT(en_SearchResultsColorChanged(const QColor &)));
	connect(CPersistentSettings::instance(), SIGNAL(changedColorWordsOfJesus(const QColor &)), this, SLOT(en_WordsOfJesusColorChanged(const QColor &)));
	connect(CPersistentSettings::instance(), SIGNAL(changedShowExcludedSearchResultsInBrowser(bool)), this, SLOT(en_ShowExcludedSearchResultsChanged(bool)));

	connect(g_pUserNotesDatabase.data(), SIGNAL(highlighterTagsAboutToChange(CBibleDatabasePtr, const QString &)), this, SLOT(en_highlighterTagsAboutToChange(CBibleDatabasePtr, const QString &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(highlighterTagsChanged(CBibleDatabasePtr, const QString &)), this, SLOT(en_highlighterTagsChanged(CBibleDatabasePtr, const QString &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(aboutToChangeHighlighters()), this, SLOT(en_highlightersAboutToChange()));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedHighlighters()), this, SLOT(en_highlightersChanged()));

	// User Notes changing:
	connect(g_pUserNotesDatabase.data(), SIGNAL(addedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(removedUserNote(const CRelIndex &)), this, SLOT(en_userNoteEvent(const CRelIndex &)));

	// Cross Refs changing:
	connect(g_pUserNotesDatabase.data(), SIGNAL(addedCrossRef(const CRelIndex &, const CRelIndex &)), this, SLOT(en_crossRefsEvent(const CRelIndex &, const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(removedCrossRef(const CRelIndex &, const CRelIndex &)), this, SLOT(en_crossRefsEvent(const CRelIndex &, const CRelIndex &)));
	connect(g_pUserNotesDatabase.data(), SIGNAL(changedAllCrossRefs()), this, SLOT(en_allCrossRefsChanged()));
}
예제 #7
0
sdl::timage ttext::render_as_texture() const
{
	rerender();
	return texture_;
}
예제 #8
0
surface ttext::render() const
{
	rerender();
	return surface_;
}
예제 #9
0
 void
 timerCB()
 {
     rerender();
 }
/* **************************************** *
* Event loop
* **************************************** */
int PonscripterLabel::eventLoop()
{
    SDL_Event event, tmp_event;

    /* Note, this rate can change if the window is dragged to a new
       screen or the monitor settings are changed while running.
       We do not handle either of these cases */
    Uint32 refresh_delay = getRefreshRateDelay();
    Uint32 last_refresh = 0, current_time;
    timer_event_flag = false;
#ifdef WIN32
    Uint32 win_flags;
#endif

    queueRerender();

    advancePhase();

    // when we're on the first of a button-waiting frame (menu, etc), we snap mouse cursor to button when
    //   using keyboard/gamecontroller to vastly improve the experience when using not using a mouse directly
    bool using_buttonbased_movement = true;  // true to snap to main menu when it loads
    first_buttonwait_mode_frame = false;  // if it's the first frame of a buttonwait (menu/choice), snap to default button
    SDL_GetMouseState(&last_mouse_x, &last_mouse_y);

    while (SDL_WaitEvent(&event)) {
        // ignore continous SDL_MOUSEMOTION
        while (event.type == SDL_MOUSEMOTION) {
            if (SDL_PeepEvents(&tmp_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 0) break;

            // improve using keyboard/gamecontroller controls
            if ((last_mouse_x != ( (SDL_MouseButtonEvent *) &event)->x) || (last_mouse_y != ( (SDL_MouseButtonEvent *) &event)->y)) {
                using_buttonbased_movement = false;

                last_mouse_x = ( (SDL_MouseButtonEvent *) &event)->x;
                last_mouse_y = ( (SDL_MouseButtonEvent *) &event)->y;
            }

            if (tmp_event.type != SDL_MOUSEMOTION) break;

            SDL_PeepEvents(&tmp_event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
            event = tmp_event;
        }

        switch (event.type) {
        case SDL_MOUSEMOTION:
            mouseMoveEvent((SDL_MouseMotionEvent*) &event);
            break;

        case SDL_MOUSEBUTTONDOWN:
            current_button_state.down_x = ( (SDL_MouseButtonEvent *) &event)->x;
            current_button_state.down_y = ( (SDL_MouseButtonEvent *) &event)->y;
            current_button_state.ignore_mouseup = false;
            if (!btndown_flag) break;

        case SDL_MOUSEBUTTONUP:
            mousePressEvent((SDL_MouseButtonEvent*) &event);
            break;

        case SDL_MOUSEWHEEL:
            mouseWheelEvent(&event.wheel);
            break;

        // NOTE: we reverse KEYUP and KEYDOWN for controller presses, because otherwise it feels really slow and junky
        // If necessary, we can make keyPressEvent actually interpret controller keys but this works fine for now
        case SDL_CONTROLLERBUTTONDOWN:
            using_buttonbased_movement = true;
            event.key.type = SDL_KEYUP;
            // printf("Controller button press: %s\n", SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button));
            event.key.keysym.sym = transControllerButton(event.cbutton.button);
            if (event.key.keysym.sym == SDLK_UNKNOWN)
                break;

            event.key.keysym.sym = transKey(event.key.keysym.sym);

            keyDownEvent((SDL_KeyboardEvent*) &event);
            keyPressEvent((SDL_KeyboardEvent*) &event);

            break;

        case SDL_CONTROLLERBUTTONUP:
            using_buttonbased_movement = true;
            event.key.type = SDL_KEYDOWN;
            // printf("Controller button release: %s\n", SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button));
            event.key.keysym.sym = transControllerButton(event.cbutton.button);
            if (event.key.keysym.sym == SDLK_UNKNOWN)
                break;

            event.key.keysym.sym = transKey(event.key.keysym.sym);

            keyUpEvent((SDL_KeyboardEvent*) &event);
            if (btndown_flag)
                keyPressEvent((SDL_KeyboardEvent*) &event);

            break;

        case SDL_JOYBUTTONDOWN:
            using_buttonbased_movement = true;
            event.key.type = SDL_KEYDOWN;
            event.key.keysym.sym = transJoystickButton(event.jbutton.button);
            if (event.key.keysym.sym == SDLK_UNKNOWN)
                break;

        case SDL_KEYDOWN:
            if ((event.key.keysym.sym == SDLK_UP) || (event.key.keysym.sym == SDLK_DOWN) ||
                (event.key.keysym.sym == SDLK_LEFT) || (event.key.keysym.sym == SDLK_RIGHT))
                using_buttonbased_movement = true;
            event.key.keysym.sym = transKey(event.key.keysym.sym);
            keyDownEvent((SDL_KeyboardEvent*) &event);
            if (btndown_flag)
                keyPressEvent((SDL_KeyboardEvent*) &event);

            break;

        case SDL_JOYBUTTONUP:
            using_buttonbased_movement = true;
            event.key.type = SDL_KEYUP;
            event.key.keysym.sym = transJoystickButton(event.jbutton.button);
            if (event.key.keysym.sym == SDLK_UNKNOWN)
                break;

        case SDL_KEYUP:
            event.key.keysym.sym = transKey(event.key.keysym.sym);
            keyUpEvent((SDL_KeyboardEvent*) &event);
            keyPressEvent((SDL_KeyboardEvent*) &event);
            break;

        case SDL_JOYAXISMOTION:
        {
            SDL_KeyboardEvent ke = transJoystickAxis(event.jaxis);
            if (ke.keysym.sym != SDLK_UNKNOWN) {
                if (ke.type == SDL_KEYDOWN) {
                    keyDownEvent(&ke);
                    if (btndown_flag)
                        keyPressEvent(&ke);
                }
                else if (ke.type == SDL_KEYUP) {
                    keyUpEvent(&ke);
                    keyPressEvent(&ke);
                }
            }

            break;
        }

        case ONS_SOUND_EVENT:
        case ONS_FADE_EVENT:
        case ONS_MIDI_EVENT:
        case ONS_MUSIC_EVENT:
            flushEventSub(event);
            break;

        case INTERNAL_REDRAW_EVENT:
            /* Handle cursor shifting for controller/keyboard button-based movement */
            if (first_buttonwait_mode_frame && using_buttonbased_movement && buttons.size() > 1) {
                shiftCursorOnButton(0);
            }

            if (event_mode & WAIT_BUTTON_MODE)
                first_buttonwait_mode_frame = true;
            else if (first_buttonwait_mode_frame)
                first_buttonwait_mode_frame = false;

            /* Stop rerendering while minimized; wait for the restore event + queueRerender */
            if(minimized_flag) {
                break;
            }

            current_time = SDL_GetTicks();
            if((current_time - last_refresh) >= refresh_delay || last_refresh == 0) {
                /* It has been longer than the refresh delay since we last started a refresh. Start another */

                last_refresh = current_time;
                rerender();

                /* Refresh time since rerender does take some odd ms */
                current_time = SDL_GetTicks();
            }

            SDL_PumpEvents();
            /* Remove all pending redraw events on the queue */
            while(SDL_PeepEvents(&tmp_event, 1, SDL_GETEVENT, INTERNAL_REDRAW_EVENT, INTERNAL_REDRAW_EVENT) == 1)
                ;

            /* If there are any events on the queue, re-add us and let it get those events asap.
             * It'll then come back to us with no events and we'll just sleep until it's time to redraw again.
             * If there are no events, sleep right away
             */
            if(SDL_PeepEvents(&tmp_event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 0) {
                if(timer_event_flag && timer_event_time <= current_time) {
                    timer_event_flag = false;

                    timerEvent();
                } else if(last_refresh <= current_time && refresh_delay >= (current_time - last_refresh)) {
                    SDL_Delay(std::min(refresh_delay / 3, refresh_delay - (current_time - last_refresh)));
                }
            }
            tmp_event.type = INTERNAL_REDRAW_EVENT;
            SDL_PushEvent(&tmp_event);

            break;

        case ONS_WAVE_EVENT:
            flushEventSub(event);
            //printf("ONS_WAVE_EVENT %d: %x %d %x\n", event.user.code, wave_sample[0], automode_flag, event_mode);
            if (event.user.code != 0
                || !(event_mode & WAIT_VOICE_MODE)) break;

            if (remaining_time <= 0) {
                event_mode &= ~WAIT_VOICE_MODE;
                if (automode_flag)
                    current_button_state.button = 0;
                else if (usewheel_flag)
                    current_button_state.button = -5;
                else
                    current_button_state.button = -2;

                stopAnimation(clickstr_state);
                advancePhase();
            }

            break;

        case SDL_WINDOWEVENT:
            switch(event.window.event) {
              case SDL_WINDOWEVENT_FOCUS_LOST:
                break;
              case SDL_WINDOWEVENT_FOCUS_GAINED:
                /* See comment below under RESIZED */
                SDL_PumpEvents();
                SDL_PeepEvents(&tmp_event, 1, SDL_GETEVENT, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN);
                current_button_state.ignore_mouseup = true;
#ifdef WIN32
                win_flags = SDL_GetWindowFlags(screen);
                /* Work around: https://bugzilla.libsdl.org/show_bug.cgi?id=2510
                 *
                 * On windows, the RESTORED event does not occur when you restore a
                 * maximized event. The only events you get are a ton of exposes and
                 * this one. The screen also remains black if it was maximized until
                 * the window is "restored".
                 */
                SDL_RestoreWindow(screen);
                if(win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
                    SDL_SetWindowFullscreen(screen, SDL_WINDOW_FULLSCREEN_DESKTOP);
                } else if(win_flags & SDL_WINDOW_FULLSCREEN) {
                    SDL_SetWindowFullscreen(screen, SDL_WINDOW_FULLSCREEN);
                } else if(win_flags & SDL_WINDOW_MAXIMIZED) {
                    SDL_MaximizeWindow(screen);
                }
#endif
                break;
              case SDL_WINDOWEVENT_MAXIMIZED:
              case SDL_WINDOWEVENT_RESIZED:
                /* Due to what I suspect is an SDL bug, you get a mosuedown +
                 * mouseup event when you maximize the window by double
                 * clicking the titlebar in windows. These events both have
                 * coordinates inside of the screen, and I can't see any way
                 * to tell them apart from legitimate clicks. (it even triggers
                 * a mouse move event).
                 * To fix this bug, we kill any mousedown events when we maximize.
                 * Note, we do this under RESIZED too because if you do a
                 * "vertical maximize" (double click with the upper resize arrow)
                 * that doesn't trigger a maximized event
                 */
                SDL_PumpEvents();
                SDL_PeepEvents(&tmp_event, 1, SDL_GETEVENT, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN);
                current_button_state.ignore_mouseup = true;
              case SDL_WINDOWEVENT_RESTORED:
              case SDL_WINDOWEVENT_SHOWN:
              case SDL_WINDOWEVENT_EXPOSED:
                /* If we weren't minimized, a rerender is already queued */
                if(minimized_flag) {
                    minimized_flag = false;
                    queueRerender();
                }
                break;
              case SDL_WINDOWEVENT_MINIMIZED:
              case SDL_WINDOWEVENT_HIDDEN:
                minimized_flag = true;
                break;
            }
            break;

        case SDL_QUIT:
            endCommand("end");
            break;

        default:
            break;
        }
    }
    return -1;
}
예제 #11
0
파일: test_json.c 프로젝트: chenz/libusual
static void test_json_basic(void *p)
{
	str_check(simple_value("1"), "INT:1");
	str_check(simple_value("  10000 "), "INT:10000");
	str_check(simple_value("true"), "TRUE");
	str_check(simple_value(" true "), "TRUE");
	str_check(simple_value("false"), "FALSE");
	str_check(simple_value(" false "), "FALSE");
	str_check(simple_value("null"), "NULL");
	str_check(simple_value(" null "), "NULL");
	str_check(simple_value("1.5"), "FLOAT:1.5");
	str_check(simple_value(" 1.5 "), "FLOAT:1.5");
	str_check(simple_value("\"abc\""), "STR:abc");
	str_check(simple_value("\"\""), "STR:");
	str_check(simple_value(" \"qq\\\"zz\\\\qq\" "), "STR:qq\"zz\\qq");

	str_check(rerender("1"), "1");
	str_check(rerender("[]"), "[]");
	str_check(rerender("[1]"), "[1]");
	str_check(rerender("[null, true, false]"), "[null,true,false]");
	str_check(rerender("[1,2,[3,[],[4]]]"), "[1,2,[3,[],[4]]]");
	str_check(rerender("[\"\", \"a\", \"\\\"\", \"a\\\"b\"]"), "[\"\",\"a\",\"\\\"\",\"a\\\"b\"]");

	str_check(rerender("{}"), "{}");
	str_check(rerender("{\"key\": \"val\"}"), "{\"key\":\"val\"}");
	str_check(xrerender("{'key': 'val|'qqq'}"), "{'key':'val|'qqq'}");
	str_check(xrerender("{'k': [1,2,-3], 'k2': {}}"), "{'k':[1,2,-3],'k2':{}}");

	str_check(xrerender("'|b|f|n|r|t|/'"), "'|b|f|n|r|t/'");
	str_check(xrerender("'|a'"), "EPARSE: Line #1: Invalid escape code");

	str_check(xrerender("'𝄞'"), "'𝄞'");
	str_check(xrerender("'|u0034'"), "'4'");
	str_check(xrerender("'|u003'"), "EPARSE: Line #1: Invalid hex escape");
	str_check(xrerender("'|u'"), "EPARSE: Line #1: Invalid hex escape");
	str_check(xrerender("'|uD834|uDD1E'"), "'𝄞'");
	str_check(xrerender("'|uD834 |uDD1E'"), "EPARSE: Line #1: Invalid UTF16 escape");
	str_check(xrerender("'|uD834|uD834'"), "EPARSE: Line #1: Invalid UTF16 escape");
	str_check(xrerender("'|uD834|u0100'"), "EPARSE: Line #1: Invalid UTF16 escape");
	str_check(xrerender("'|uD834|uF000'"), "EPARSE: Line #1: Invalid UTF16 escape");
	str_check(xrerender("'|uDD34|uDD00'"), "EPARSE: Line #1: Invalid UTF16 escape");
	str_check(xrerender("'|uD834'"), "EPARSE: Line #1: Invalid UTF16 escape");

	// check for \u2028 \u2029 special handling
	{
		const char utfesc[] = {'\'', 0xe2, 0x80, 0xa7, '|', 'u', '2', '0', '2', '8', '|', 'u', '2', '0', '2', '9', 0xe2, 0x80, 0xaa, '\'', 0};
		str_check(xrerender("'|u2027|u2028|u2029|u202a'"), utfesc);
	}

	str_check(xrerender("["), "EPARSE: Line #1: Container still open");
	str_check(xrerender("[{"), "EPARSE: Line #1: Container still open");
	str_check(xrerender("\""), "EPARSE: Line #1: Unexpected end of string");
	str_check(xrerender("[\""), "EPARSE: Line #1: Unexpected end of string");
	str_check(xrerender("[,"), "EPARSE: Line #1: Unexpected symbol: ','");
	str_check(xrerender("[]]"), "EPARSE: Line #1: Unexpected symbol: ']'");
	str_check(xrerender("tr"), "EPARSE: Line #1: Unexpected end of token");
	str_check(xrerender("treu"), "EPARSE: Line #1: Invalid token");
	str_check(xrerender("999999999999999999999999"), "EPARSE: Line #1: Number parse failed");
	str_check(xrerender("99999999999999999999999999999999999999999999999999999999999999999999"), "EPARSE: Line #1: Number parse failed");
	str_check(xrerender("99.999.999"), "EPARSE: Line #1: Number parse failed");
	str_check(xrerender("[\n\"ln\n\","), "EPARSE: Line #3: Container still open");
	str_check(xrerender("!"), "EPARSE: Line #1: Invalid symbol: '!'");

	{
	const char badenc1[] = {'"', 0xc1, 0xbf, '"', 0};
	const char badenc2[] = {'"', 0xe0, 0x9f, 0xbf, '"', 0};
	const char badenc3[] = {'"', 0xf0, 0x8f, 0xbf, 0xbf, '"'};
	const char badenc4[] = {'"', 0xf4, 0x90, 0x80, 0x80, '"', 0};

	str_check(xrerender(badenc1), "EPARSE: Line #1: Invalid UTF8 sequence");
	str_check(xrerender(badenc2), "EPARSE: Line #1: Invalid UTF8 sequence");
	str_check(xrerender(badenc3), "EPARSE: Line #1: Invalid UTF8 sequence");
	str_check(xrerender(badenc4), "EPARSE: Line #1: Invalid UTF8 sequence");
	}
end:;
}
예제 #12
0
WbWidget::WbWidget(SxeSession* session, QWidget *parent) : QGraphicsView(parent) {
	newWbItem_ = 0;
	adding_ = 0;
	addVertex_ = false;
	strokeColor_ = Qt::black;
	fillColor_ = Qt::transparent;
	strokeWidth_ = 1;
	session_ = session;

//	setCacheMode(CacheBackground);
	setRenderHint(QPainter::Antialiasing);
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	// Make the scroll bars always stay on because otherwise the resize event can cause
	// an infinite loop as the effective size of the widget changes when scroll bars are
	// added/removed
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

	// create the scene
	scene_ = new WbScene(session_, this);
	scene_->setItemIndexMethod(QGraphicsScene::NoIndex);
	setRenderHint(QPainter::Antialiasing);
	setTransformationAnchor(AnchorUnderMouse);
	setResizeAnchor(AnchorViewCenter);
	setScene(scene_);

	// render the initial document
	rerender();
	// rerender on update
	connect(session_, SIGNAL(documentUpdated(bool)), SLOT(handleDocumentUpdated(bool)));

	// add the initial items
	const QDomNodeList children = session_->document().documentElement().childNodes();
	for(int i = 0; i < (int)children.length(); i++) {
		const QDomNode node = children.at(i);
		if(node.isElement()) {
			queueNodeInspection(node.toElement());
		}
	}
	inspectNodes();

	// add new items as nodes are added
	// remove/add items if corresponding nodes are moved
	connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode)));
	connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode)));
	// remove items if corresponding nodes are deleted
	connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(removeWbItem(QDomNode)));
	connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(checkForRemovalOfId(QDomNode)));
	// adjust the viewBox as necessary
	connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));
	connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));
	connect(session_, SIGNAL(chdataChanged(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));

	// set the default mode to select
	setMode(Select);

	// set the initial size
	if(session_->document().documentElement().hasAttribute("viewBox"))
		checkForViewBoxChange(session_->document().documentElement().attributeNode("viewBox"));
	else {
		QSize size;
		QRectF rect = scene_->sceneRect();
		size.setWidth(rect.x() + rect.width());
		size.setHeight(rect.y() + rect.height());
		if(size.width() > 0 && size.height() > 0)
			setSize(size);
		else
			setSize(QSize(400, 600));
	}
}