Example #1
0
void Draw::regeneratePath(DrawPath* path) {
  _parent->setCursor(Qt::WaitCursor);
  printf("regenerate path\n");
  DrawPath *aPath, *bPath, *curr = path;
  int aFrame = _frame-1, bFrame = _frame+1;
  
  curr = path->prevC();
  while (curr && !curr->fixed() && curr->prevC() != NULL) {
    curr = curr->prevC();
    aFrame--;
  }
  aPath = curr;
  
  curr = path->nextC(); 
  while (curr && !curr->fixed() && curr->nextC() != NULL) {
    curr = curr->nextC();
    bFrame++;
  }
  bPath = curr;

  // 1. regenerate forwards and backwards curves
  if (aPath && aPath!= _selected && aPath->nextC()!=_selected)
    biGenerateSpan(aPath, aFrame, _selected, _frame);
  if (bPath && bPath!=_selected && bPath->prevC()!=_selected) {
    if (bPath->fixed())
      biGenerateSpan(_selected, _frame, bPath, bFrame);
    else

      forwGenerateSpan(_selected, aFrame);
  }
  
  
  emit restoreCursor();
  _selected->setFixed(true);
}
Example #2
0
void ImageArea::mouseMoveEvent(QMouseEvent *event)
{
    InstrumentsEnum instrument = DataSingleton::Instance()->getInstrument();
    mInstrumentHandler = mInstrumentsHandlers.at(DataSingleton::Instance()->getInstrument());
    if(mIsResize)
    {
         mAdditionalTools->resizeCanvas(event->x(), event->y());
         emit sendNewImageSize(mImage->size());
    }
    else if(event->pos().x() < mImage->rect().right() + 6 &&
            event->pos().x() > mImage->rect().right() &&
            event->pos().y() > mImage->rect().bottom() &&
            event->pos().y() < mImage->rect().bottom() + 6)
    {
        setCursor(Qt::SizeFDiagCursor);
        if (qobject_cast<AbstractSelection*>(mInstrumentHandler))
            return;
    }
    else if (!qobject_cast<AbstractSelection*>(mInstrumentHandler))
    {
        restoreCursor();
    }
    if(event->pos().x() < mImage->width() &&
            event->pos().y() < mImage->height())
    {
        emit sendCursorPos(event->pos());
    }

    if(instrument != NONE_INSTRUMENT)
    {
        mInstrumentHandler->mouseMoveEvent(event, *this);
    }
}
Example #3
0
void ClangFormat::disableFormattingSelectedText()
{
    TextEditor::TextEditorWidget *widget = TextEditor::TextEditorWidget::currentTextEditorWidget();
    if (!widget)
        return;

    const QTextCursor tc = widget->textCursor();
    if (!tc.hasSelection())
        return;

    // Insert start marker
    const QTextBlock selectionStartBlock = tc.document()->findBlock(tc.selectionStart());
    QTextCursor insertCursor(tc.document());
    insertCursor.beginEditBlock();
    insertCursor.setPosition(selectionStartBlock.position());
    insertCursor.insertText("// clang-format off\n");
    const int positionToRestore = tc.position();

    // Insert end marker
    QTextBlock selectionEndBlock = tc.document()->findBlock(tc.selectionEnd());
    insertCursor.setPosition(selectionEndBlock.position() + selectionEndBlock.length() - 1);
    insertCursor.insertText("\n// clang-format on");
    insertCursor.endEditBlock();

    // Reset the cursor position in order to clear the selection.
    QTextCursor restoreCursor(tc.document());
    restoreCursor.setPosition(positionToRestore);
    widget->setTextCursor(restoreCursor);

    // The indentation of these markers might be undesired, so reformat.
    // This is not optimal because two undo steps will be needed to remove the markers.
    const int reformatTextLength = insertCursor.position() - selectionStartBlock.position();
    BeautifierPlugin::formatCurrentFile(command(selectionStartBlock.position(),
                                                  reformatTextLength));
}
Example #4
0
static void GUI_showMenu( const MenuItem * items, int count,
						 int selection, int row, int height )
{
    int         i;
    CursorState cursorState;
	
    if ( items == NULL || count == 0 ) 
		return;
	
    // head and tail points to the start and the end of the list.
    // top and bottom points to the first and last visible items
    // in the menu window.
	
    gMenuItems		= items;
    gMenuRow		= row;
    gMenuHeight		= height;
    gMenuItemCount	= count;
    gMenuTop		= 0;
    gMenuBottom		= min( count, height ) - 1;
    gMenuSelection	= selection;
	
    gMenuStart		= 0;
    gMenuEnd	    = min( count, gui.maxdevices ) - 1;
	
	// If the selected item is not visible, shift the list down.
	
    if ( gMenuSelection > gMenuBottom )
    {
        gMenuTop += ( gMenuSelection - gMenuBottom );
        gMenuBottom = gMenuSelection;
    }
	
	if ( gMenuSelection > gMenuEnd )
    {
		gMenuStart += ( gMenuSelection - gMenuEnd );
        gMenuEnd = gMenuSelection;
    }
	
	// Draw the visible items.
	
	if( bootArgs->Video.v_display == GRAPHICS_MODE )
	{
		drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);
	}
	else 
	{
		
		changeCursor( 0, row, kCursorTypeHidden, &cursorState );
		
		for ( i = gMenuTop; i <= gMenuBottom; i++ )
		{
			printMenuItem( &items[i], (i == gMenuSelection) );
		}
		
		restoreCursor( &cursorState );
    }
}
Example #5
0
static void showMenu( const MenuItem * items, int count,
					 int selection, int row, int height )
{
    int         i;
    CursorState cursorState;
	
    if ( items == NULL || count == 0 ) 
		return;
	
    // head and tail points to the start and the end of the list.
    // top and bottom points to the first and last visible items
    // in the menu window.
	
    gMenuItems		= items;
    int MenuTop		= 0;
    int MenuBottom		= min( count, height ) - 1;
    int MenuSelection	= selection;	
    int MenuStart		= 0;
    int MenuEnd	    = count; //min( count, gui.maxdevices ) - 1;
	
	// If the selected item is not visible, shift the list down.
	
    if ( MenuSelection > MenuBottom )
    {
        MenuTop += ( MenuSelection - MenuBottom );
        MenuBottom = MenuSelection;
    }
	
	if ( MenuSelection > MenuEnd )
    {
		MenuStart += ( MenuSelection - MenuEnd );
        MenuEnd = MenuSelection;
    }
	
	// Draw the visible items.
	
	changeCursor( 0, row, kCursorTypeHidden, &cursorState );
	
	for ( i = MenuTop; i <= MenuBottom; i++ )
	{
		printMenuItem( &items[i], (i == MenuSelection) );
	}
	
    safe_set_env(envgMenuRow,row);
    safe_set_env(envgMenuHeight,height);
    safe_set_env(envgMenuItemCount,count);
    safe_set_env(envgMenuTop,MenuTop);
    safe_set_env(envgMenuBottom,MenuBottom);
    safe_set_env(envgMenuSelection,MenuSelection);
    safe_set_env(envgMenuStart,MenuStart);
    safe_set_env(envgMenuEnd,MenuEnd); 
    
    
	restoreCursor( &cursorState );
}
void UndoChangeScriptCommand::undo()
{
    // Save text value and cursor position
    saveCursor();
    after = QString::fromStdString(n->getScript());

    n->setScript(before.toStdString());

    // Restore cursor to previous position
    restoreCursor(cursor_before);
}
Example #7
0
void Draw::corrPropAll() {
  _parent->setCursor(Qt::WaitCursor);
  _dc->startDrawPathIterator();
  DrawPath* curr;
  while ((curr=_dc->IterateNext()) != NULL) {
    if (!curr->corrToRoto()) {
      curr->correspondRoto2(_is->getRotoCurves(_frame), _w, _h);
    }
    if (curr->nextC() == NULL || curr->prevC() == NULL)
      propagatePathEverywhere(curr);
  }
  emit restoreCursor();
}
Example #8
0
void ImageArea::mouseReleaseEvent(QMouseEvent *event)
{
    if(mIsResize)
    {
       mIsResize = false;
       restoreCursor();
    }
    else if(DataSingleton::Instance()->getInstrument() != NONE_INSTRUMENT)
    {
        mInstrumentHandler = mInstrumentsHandlers.at(DataSingleton::Instance()->getInstrument());
        mInstrumentHandler->mouseReleaseEvent(event, *this);
    }
}
Example #9
0
int main() {
	int width, height, cursorx, cursory, cbsize;

	init(&width, &height);				   // Graphics initialization
	cursorx = width / 2;
	cursory = height / 2;
	cbsize = (CUR_SIZ * 2) + 1;
	VGImage CursorBuffer = vgCreateImage(VG_sABGR_8888, cbsize, cbsize, VG_IMAGE_QUALITY_BETTER);

	if (mouseinit(width, height) != 0) {
		fprintf(stderr, "Unable to initialize the mouse\n");
		exit(1);
	}
	Start(width, height);				   // Start the picture
	Background(0, 0, 0);				   // Black background
	Fill(44, 77, 232, 1);				   // Big blue marble
	Circle(width / 2, 0, width);			   // The "world"
	Fill(255, 255, 255, 1);				   // White text
	TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);	// Greetings 
	End();						   // update picture

	// MAIN LOOP
	while (left_count < 2) {			   // Loop until the left mouse button pressed & released
		// if the mouse moved...
		if (mouse.x != cursorx || mouse.y != cursory) {
			restoreCursor(CursorBuffer);
			cursorx = mouse.x;
			cursory = mouse.y;
			saveCursor(CursorBuffer, cursorx, cursory, width, height, CUR_SIZ);
			circleCursor(cursorx, cursory, width, height, CUR_SIZ);
			End();				   // update picture
		}
	}
	restoreCursor(CursorBuffer);			   // not strictly necessary as display will be closed
	vgDestroyImage(CursorBuffer);			   // tidy up memory
	finish();					   // Graphics cleanup
	exit(0);
}
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
{
    switch (window->cursorMode)
    {
        case GLFW_CURSOR_NORMAL:
            restoreCursor(window);
            break;
        case GLFW_CURSOR_HIDDEN:
            hideCursor(window);
            break;
        case GLFW_CURSOR_DISABLED:
            disableCursor(window);
            break;
    }
}
Example #11
0
static void showMenu( const MenuItem * items, int count,
                      int selection, int row, int height )
{
    int         i;
    CursorState cursorState;

    if ( items == NULL || count == 0 ) return;

    // head and tail points to the start and the end of the list.
    // top and bottom points to the first and last visible items
    // in the menu window.

    gMenuItems     = items;
    gMenuRow       = row;
    gMenuHeight    = height;
    gMenuItemCount = count;
    gMenuTop       = 0;
    gMenuBottom    = min( count, height ) - 1;
    gMenuSelection = selection;

    // If the selected item is not visible, shift the list down.

    if ( gMenuSelection > gMenuBottom )
    {
        gMenuTop += ( gMenuSelection - gMenuBottom );
        gMenuBottom = gMenuSelection;
    }

    // Draw the visible items.

    changeCursor( 0, row, kCursorTypeHidden, &cursorState );

    for ( i = gMenuTop; i <= gMenuBottom; i++ )
    {
        printMenuItem( &items[i], (i == gMenuSelection) );
    }

    restoreCursor( &cursorState );
}
void UndoChangeScriptCommand::redo()
{
    n->setScript(after.toStdString());
    restoreCursor(cursor_after);
}
// Window callback function (handles window events)
//
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
                                   WPARAM wParam, LPARAM lParam)
{
    _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0);

    switch (uMsg)
    {
        case WM_NCCREATE:
        {
            CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;
            SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);
            break;
        }

        case WM_SETFOCUS:
        {
            if (window->cursorMode != GLFW_CURSOR_NORMAL)
                _glfwPlatformApplyCursorMode(window);

            if (window->monitor && window->autoIconify)
                enterFullscreenMode(window);

            _glfwInputWindowFocus(window, GL_TRUE);
            return 0;
        }

        case WM_KILLFOCUS:
        {
            if (window->cursorMode != GLFW_CURSOR_NORMAL)
                restoreCursor(window);

            if (window->monitor && window->autoIconify)
            {
                _glfwPlatformIconifyWindow(window);
                leaveFullscreenMode(window);
            }

            _glfwInputWindowFocus(window, GL_FALSE);
            return 0;
        }

        case WM_SYSCOMMAND:
        {
            switch (wParam & 0xfff0)
            {
                case SC_SCREENSAVE:
                case SC_MONITORPOWER:
                {
                    if (window->monitor)
                    {
                        // We are running in full screen mode, so disallow
                        // screen saver and screen blanking
                        return 0;
                    }
                    else
                        break;
                }

                // User trying to access application menu using ALT?
                case SC_KEYMENU:
                    return 0;
            }
            break;
        }

        case WM_CLOSE:
        {
            _glfwInputWindowCloseRequest(window);
            return 0;
        }

        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        {
            const int scancode = (lParam >> 16) & 0x1ff;
            const int key = translateKey(wParam, lParam);
            if (key == _GLFW_KEY_INVALID)
                break;

            _glfwInputKey(window, key, scancode, GLFW_PRESS, getKeyMods());
            break;
        }

        case WM_CHAR:
        {
            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);
            return 0;
        }

        case WM_SYSCHAR:
        {
            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_FALSE);
            return 0;
        }

        case WM_UNICHAR:
        {
            // This message is not sent by Windows, but is sent by some
            // third-party input method engines

            if (wParam == UNICODE_NOCHAR)
            {
                // Returning TRUE here announces support for this message
                return TRUE;
            }

            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);
            return FALSE;
        }

        case WM_KEYUP:
        case WM_SYSKEYUP:
        {
            const int mods = getKeyMods();
            const int scancode = (lParam >> 16) & 0x1ff;
            const int key = translateKey(wParam, lParam);
            if (key == _GLFW_KEY_INVALID)
                break;

            if (wParam == VK_SHIFT)
            {
                // Release both Shift keys on Shift up event, as only one event
                // is sent even if both keys are released
                _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);
                _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);
            }
            else if (wParam == VK_SNAPSHOT)
            {
                // Key down is not reported for the print screen key
                _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
            }
            else
                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);

            break;
        }

        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
        {
            const int mods = getKeyMods();

            SetCapture(hWnd);

            if (uMsg == WM_LBUTTONDOWN)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
            else if (uMsg == WM_RBUTTONDOWN)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
            else if (uMsg == WM_MBUTTONDOWN)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
            else
            {
                if (HIWORD(wParam) == XBUTTON1)
                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS, mods);
                else if (HIWORD(wParam) == XBUTTON2)
                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS, mods);

                return TRUE;
            }

            return 0;
        }

        case WM_LBUTTONUP:
        case WM_RBUTTONUP:
        case WM_MBUTTONUP:
        case WM_XBUTTONUP:
        {
            const int mods = getKeyMods();

            ReleaseCapture();

            if (uMsg == WM_LBUTTONUP)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods);
            else if (uMsg == WM_RBUTTONUP)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, mods);
            else if (uMsg == WM_MBUTTONUP)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE, mods);
            else
            {
                if (HIWORD(wParam) == XBUTTON1)
                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_RELEASE, mods);
                else if (HIWORD(wParam) == XBUTTON2)
                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_RELEASE, mods);

                return TRUE;
            }

            return 0;
        }

        case WM_MOUSEMOVE:
        {
            const int x = GET_X_LPARAM(lParam);
            const int y = GET_Y_LPARAM(lParam);

            if (window->cursorMode == GLFW_CURSOR_DISABLED)
            {
                if (_glfw.focusedWindow != window)
                    break;

                _glfwInputCursorMotion(window,
                                        x - window->win32.cursorPosX,
                                        y - window->win32.cursorPosY);
            }
            else
                _glfwInputCursorMotion(window, x, y);

            window->win32.cursorPosX = x;
            window->win32.cursorPosY = y;

            if (!window->win32.cursorInside)
            {
                TRACKMOUSEEVENT tme;
                ZeroMemory(&tme, sizeof(tme));
                tme.cbSize = sizeof(tme);
                tme.dwFlags = TME_LEAVE;
                tme.hwndTrack = window->win32.handle;
                TrackMouseEvent(&tme);

                window->win32.cursorInside = GL_TRUE;
                _glfwInputCursorEnter(window, GL_TRUE);
            }

            return 0;
        }

        case WM_MOUSELEAVE:
        {
            window->win32.cursorInside = GL_FALSE;
            _glfwInputCursorEnter(window, GL_FALSE);
            return 0;
        }

        case WM_MOUSEWHEEL:
        {
            _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
            return 0;
        }

        case WM_MOUSEHWHEEL:
        {
            // This message is only sent on Windows Vista and later
            // NOTE: The X-axis is inverted for consistency with OS X and X11.
            _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
            return 0;
        }

        case WM_SIZE:
        {
            if (_glfw.focusedWindow == window)
            {
                if (window->cursorMode == GLFW_CURSOR_DISABLED)
                    updateClipRect(window);
            }

            if (!window->win32.iconified && wParam == SIZE_MINIMIZED)
            {
                window->win32.iconified = GL_TRUE;
                _glfwInputWindowIconify(window, GL_TRUE);
            }
            else if (window->win32.iconified &&
                     (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED))
            {
                window->win32.iconified = GL_FALSE;
                _glfwInputWindowIconify(window, GL_FALSE);
            }

            _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
            _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
            return 0;
        }

        case WM_MOVE:
        {
            if (_glfw.focusedWindow == window)
            {
                if (window->cursorMode == GLFW_CURSOR_DISABLED)
                    updateClipRect(window);
            }

            // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
            // those macros do not handle negative window positions correctly
            _glfwInputWindowPos(window,
                                GET_X_LPARAM(lParam),
                                GET_Y_LPARAM(lParam));
            return 0;
        }

        case WM_PAINT:
        {
            _glfwInputWindowDamage(window);
            break;
        }

        case WM_ERASEBKGND:
        {
            return TRUE;
        }

        case WM_SETCURSOR:
        {
            if (_glfw.focusedWindow == window && LOWORD(lParam) == HTCLIENT)
            {
                if (window->cursorMode == GLFW_CURSOR_HIDDEN ||
                    window->cursorMode == GLFW_CURSOR_DISABLED)
                {
                    SetCursor(NULL);
                    return TRUE;
                }
                else if (window->cursor)
                {
                    SetCursor(window->cursor->win32.handle);
                    return TRUE;
                }
            }

            break;
        }

        case WM_DEVICECHANGE:
        {
            if (DBT_DEVNODES_CHANGED == wParam)
            {
                _glfwInputMonitorChange();
                return TRUE;
            }
            break;
        }

        case WM_DWMCOMPOSITIONCHANGED:
        {
            if (_glfwIsCompositionEnabled())
            {
                _GLFWwindow* previous = _glfwPlatformGetCurrentContext();
                _glfwPlatformMakeContextCurrent(window);
                _glfwPlatformSwapInterval(0);
                _glfwPlatformMakeContextCurrent(previous);
            }

            // TODO: Restore vsync if compositing was disabled
            break;
        }

        case WM_DROPFILES:
        {
            HDROP hDrop = (HDROP) wParam;
            POINT pt;
            int i;

            const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0);
            char** paths = calloc(count, sizeof(char*));

            // Move the mouse to the position of the drop
            DragQueryPoint(hDrop, &pt);
            _glfwInputCursorMotion(window, pt.x, pt.y);

            for (i = 0;  i < count;  i++)
            {
                const UINT length = DragQueryFileW(hDrop, i, NULL, 0);
                WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));

                DragQueryFileW(hDrop, i, buffer, length + 1);
                paths[i] = _glfwCreateUTF8FromWideString(buffer);

                free(buffer);
            }

            _glfwInputDrop(window, count, (const char**) paths);

            for (i = 0;  i < count;  i++)
                free(paths[i]);
            free(paths);

            DragFinish(hDrop);
            return 0;
        }
    }

    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Example #14
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;

    union {
        struct {
            unsigned int
                selectionUp   : 1,
                selectionDown : 1,
                scrollUp      : 1,
                scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};

    if ( gMenuItems == NULL )
		return 0;

	if( bootArgs->Video.v_display == GRAPHICS_MODE )
	{
		int res;
		
		// set navigation keys for horizontal layout as defaults
		int previous	= 0x4B00;		// left arrow
		int subsequent	= 0x4D00;		// right arrow
		int menu		= 0x5000;		// down arrow
		
		if ( gui.layout == VerticalLayout )
		{
			// set navigation keys for vertical layout
			previous	= 0x4800;		// up arrow
			subsequent	= 0x5000;		// down arrow
			menu		= 0x4B00;		// right arrow
		} 

		if ( key == previous )
		{
			if ( gMenuSelection > gMenuTop )
				draw.f.selectionUp = 1;
			else if ( gMenuTop > 0 )
				draw.f.scrollDown = 1;
			
		}
		
		else if ( key ==  subsequent )
		{
			if ( gMenuSelection != gMenuBottom)
				draw.f.selectionDown = 1;
			else if ( gMenuBottom < ( gMenuItemCount - 1 ) )
				draw.f.scrollUp = 1;
		}
		
		else if ( key == menu )
		{
			if ( gui.menu.draw )
				updateInfoMenu(key);
			else
				drawInfoMenu();
		}

		else if ( gui.menu.draw )
		{
			res = updateInfoMenu(key);

			if ( res == CLOSE_INFO_MENU )
				gui.menu.draw = false;
			else
			{
				shouldboot = ( res != DO_NOT_BOOT );
				
				if ( shouldboot )
					gui.menu.draw = false;

				switch (res)
				{
					case BOOT_NORMAL:
						gVerboseMode = false;
						gBootMode = kBootModeNormal;
						break;
						
					case BOOT_VERBOSE:
						gVerboseMode = true;
						gBootMode = kBootModeNormal;
						addBootArg(kVerboseModeFlag);
						break;
						
					case BOOT_IGNORECACHE:
						gVerboseMode = false;
						gBootMode = kBootModeNormal;
						addBootArg(kIgnoreCachesFlag);
						break;
						
					case BOOT_SINGLEUSER:
						gVerboseMode = true;
						gBootMode = kBootModeNormal;
						addBootArg(kSingleUserModeFlag);
						break;
				}
				
			}
			
		}	
			
	} else {
		switch ( key )
		{
        	case 0x4800:  // Up Arrow
				if ( gMenuSelection != gMenuTop )
					draw.f.selectionUp = 1;
				else if ( gMenuTop > 0 )
					draw.f.scrollDown = 1;
				break;

			case 0x5000:  // Down Arrow
				if ( gMenuSelection != gMenuBottom )
					draw.f.selectionDown = 1;
				else if ( gMenuBottom < (gMenuItemCount - 1) ) 
					draw.f.scrollUp = 1;
				break;
		}
	}

    if ( draw.w )
    {
        if ( draw.f.scrollUp )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
            gMenuTop++; gMenuBottom++;
			gMenuStart++; gMenuEnd++;
            draw.f.selectionDown = 1;
        }

        if ( draw.f.scrollDown )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
            gMenuTop--; gMenuBottom--;
            gMenuStart--; gMenuEnd--;
            draw.f.selectionUp = 1;
        }

        if ( draw.f.selectionUp || draw.f.selectionDown )
        {

			CursorState cursorState;

			// Set cursor at current position, and clear inverse video.
	
			if( bootArgs->Video.v_display == VGA_TEXT_MODE )
			{
				changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState );
				printMenuItem( &gMenuItems[gMenuSelection], 0 );
			}

			if ( draw.f.selectionUp )
			{
				gMenuSelection--;
				if(( gMenuSelection - gMenuStart) == -1 )
				{
					gMenuStart--;
					gMenuEnd--;
				}
				
			} else {
			gMenuSelection++;
			if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )
			{
				gMenuStart++;
				gMenuEnd++;
			}
	    }

		if( bootArgs->Video.v_display == VGA_TEXT_MODE )
	    {
			moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );
			printMenuItem( &gMenuItems[gMenuSelection], 1 );
			restoreCursor( &cursorState );

	    } else

			drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);

	}

        *paramPtr = gMenuItems[gMenuSelection].param;        
        moved = 1;
    }

	return moved;
}
Example #15
0
void QBasicDrag::drop(const QMouseEvent *)
{
    disableEventFilter();
    restoreCursor();
    m_drag_icon_window->setVisible(false);
}
Example #16
0
void QBasicDrag::cancel()
{
    disableEventFilter();
    restoreCursor();
    m_drag_icon_window->setVisible(false);
}
Example #17
0
// Process the specified X event
//
static void processEvent(XEvent *event)
{
    _GLFWwindow* window = NULL;

    if (event->type != GenericEvent)
    {
        window = _glfwFindWindowByHandle(event->xany.window);
        if (window == NULL)
        {
            // This is an event for a window that has already been destroyed
            return;
        }
    }

    switch (event->type)
    {
        case KeyPress:
        {
            const int key = translateKey(event->xkey.keycode);
            const int mods = translateState(event->xkey.state);
            const int character = translateChar(&event->xkey);

            _glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);

            if (character != -1)
                _glfwInputChar(window, character);

            break;
        }

        case KeyRelease:
        {
            const int key = translateKey(event->xkey.keycode);
            const int mods = translateState(event->xkey.state);

            _glfwInputKey(window, key, event->xkey.keycode, GLFW_RELEASE, mods);
            break;
        }

        case ButtonPress:
        {
            const int mods = translateState(event->xbutton.state);

            if (event->xbutton.button == Button1)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
            else if (event->xbutton.button == Button2)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
            else if (event->xbutton.button == Button3)
                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);

            // Modern X provides scroll events as mouse button presses
            else if (event->xbutton.button == Button4)
                _glfwInputScroll(window, 0.0, 1.0);
            else if (event->xbutton.button == Button5)
                _glfwInputScroll(window, 0.0, -1.0);
            else if (event->xbutton.button == Button6)
                _glfwInputScroll(window, -1.0, 0.0);
            else if (event->xbutton.button == Button7)
                _glfwInputScroll(window, 1.0, 0.0);

            else
            {
                // Additional buttons after 7 are treated as regular buttons
                // We subtract 4 to fill the gap left by scroll input above
                _glfwInputMouseClick(window,
                                     event->xbutton.button - 4,
                                     GLFW_PRESS,
                                     mods);
            }

            break;
        }

        case ButtonRelease:
        {
            const int mods = translateState(event->xbutton.state);

            if (event->xbutton.button == Button1)
            {
                _glfwInputMouseClick(window,
                                     GLFW_MOUSE_BUTTON_LEFT,
                                     GLFW_RELEASE,
                                     mods);
            }
            else if (event->xbutton.button == Button2)
            {
                _glfwInputMouseClick(window,
                                     GLFW_MOUSE_BUTTON_MIDDLE,
                                     GLFW_RELEASE,
                                     mods);
            }
            else if (event->xbutton.button == Button3)
            {
                _glfwInputMouseClick(window,
                                     GLFW_MOUSE_BUTTON_RIGHT,
                                     GLFW_RELEASE,
                                     mods);
            }
            else if (event->xbutton.button > Button7)
            {
                // Additional buttons after 7 are treated as regular buttons
                // We subtract 4 to fill the gap left by scroll input above
                _glfwInputMouseClick(window,
                                     event->xbutton.button - 4,
                                     GLFW_RELEASE,
                                     mods);
            }
            break;
        }

        case EnterNotify:
        {
            _glfwInputCursorEnter(window, GL_TRUE);
            break;
        }

        case LeaveNotify:
        {
            _glfwInputCursorEnter(window, GL_FALSE);
            break;
        }

        case MotionNotify:
        {
            if (event->xmotion.x != window->x11.warpPosX ||
                event->xmotion.y != window->x11.warpPosY)
            {
                // The cursor was moved by something other than GLFW

                int x, y;

                if (window->cursorMode == GLFW_CURSOR_DISABLED)
                {
                    if (_glfw.focusedWindow != window)
                        break;

                    x = event->xmotion.x - window->x11.cursorPosX;
                    y = event->xmotion.y - window->x11.cursorPosY;
                }
                else
                {
                    x = event->xmotion.x;
                    y = event->xmotion.y;
                }

                _glfwInputCursorMotion(window, x, y);
            }

            window->x11.cursorPosX = event->xmotion.x;
            window->x11.cursorPosY = event->xmotion.y;
            break;
        }

        case ConfigureNotify:
        {
            if (event->xconfigure.width != window->x11.width ||
                event->xconfigure.height != window->x11.height)
            {
                _glfwInputFramebufferSize(window,
                                          event->xconfigure.width,
                                          event->xconfigure.height);

                _glfwInputWindowSize(window,
                                     event->xconfigure.width,
                                     event->xconfigure.height);

                window->x11.width = event->xconfigure.width;
                window->x11.height = event->xconfigure.height;
            }

            if (event->xconfigure.x != window->x11.xpos ||
                event->xconfigure.y != window->x11.ypos)
            {
                _glfwInputWindowPos(window,
                                    event->xconfigure.x,
                                    event->xconfigure.y);

                window->x11.xpos = event->xconfigure.x;
                window->x11.ypos = event->xconfigure.y;
            }

            break;
        }

        case ClientMessage:
        {
            // Custom client message, probably from the window manager

            if ((Atom) event->xclient.data.l[0] == _glfw.x11.WM_DELETE_WINDOW)
            {
                // The window manager was asked to close the window, for example by
                // the user pressing a 'close' window decoration button

                _glfwInputWindowCloseRequest(window);
            }
            else if (_glfw.x11.NET_WM_PING &&
                     (Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING)
            {
                // The window manager is pinging the application to ensure it's
                // still responding to events

                event->xclient.window = _glfw.x11.root;
                XSendEvent(_glfw.x11.display,
                           event->xclient.window,
                           False,
                           SubstructureNotifyMask | SubstructureRedirectMask,
                           event);
            }
            else if (event->xclient.message_type == _glfw.x11.XdndEnter)
            {
                // A drag operation has entered the window
                // TODO: Check if UTF-8 string is supported by the source
            }
            else if (event->xclient.message_type == _glfw.x11.XdndDrop)
            {
                // The drag operation has finished dropping on
                // the window, ask to convert it to a UTF-8 string
                _glfw.x11.xdnd.source = event->xclient.data.l[0];
                XConvertSelection(_glfw.x11.display,
                                  _glfw.x11.XdndSelection,
                                  _glfw.x11.UTF8_STRING,
                                  _glfw.x11.XdndSelection,
                                  window->x11.handle, CurrentTime);
            }
            else if (event->xclient.message_type == _glfw.x11.XdndPosition)
            {
                // The drag operation has moved over the window
                const int absX = (event->xclient.data.l[2] >> 16) & 0xFFFF;
                const int absY = (event->xclient.data.l[2]) & 0xFFFF;
                int x, y;

                _glfwPlatformGetWindowPos(window, &x, &y);
                _glfwInputCursorMotion(window, absX - x, absY - y);

                // Reply that we are ready to copy the dragged data
                XEvent reply;
                memset(&reply, 0, sizeof(reply));

                reply.type = ClientMessage;
                reply.xclient.window = event->xclient.data.l[0];
                reply.xclient.message_type = _glfw.x11.XdndStatus;
                reply.xclient.format = 32;
                reply.xclient.data.l[0] = window->x11.handle;
                reply.xclient.data.l[1] = 1; // Always accept the dnd with no rectangle
                reply.xclient.data.l[2] = 0; // Specify an empty rectangle
                reply.xclient.data.l[3] = 0;
                reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;

                XSendEvent(_glfw.x11.display, event->xclient.data.l[0],
                           False, NoEventMask, &reply);
                XFlush(_glfw.x11.display);
            }

            break;
        }

        case SelectionNotify:
        {
            if (event->xselection.property)
            {
                // The converted data from the drag operation has arrived
                char* data;
                const int result = _glfwGetWindowProperty(event->xselection.requestor,
                                                          event->xselection.property,
                                                          event->xselection.target,
                                                          (unsigned char**) &data);

                if (result)
                {
                    int i, count;
                    char** names = splitUriList(data, &count);

                    _glfwInputDrop(window, count, (const char**) names);

                    for (i = 0;  i < count;  i++)
                        free(names[i]);
                    free(names);
                }

                XFree(data);

                XEvent reply;
                memset(&reply, 0, sizeof(reply));

                reply.type = ClientMessage;
                reply.xclient.window = _glfw.x11.xdnd.source;
                reply.xclient.message_type = _glfw.x11.XdndFinished;
                reply.xclient.format = 32;
                reply.xclient.data.l[0] = window->x11.handle;
                reply.xclient.data.l[1] = result;
                reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;

                // Reply that all is well
                XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
                           False, NoEventMask, &reply);
                XFlush(_glfw.x11.display);
            }

            break;
        }

        case MapNotify:
        {
            _glfwInputWindowVisibility(window, GL_TRUE);
            break;
        }

        case UnmapNotify:
        {
            _glfwInputWindowVisibility(window, GL_FALSE);
            break;
        }

        case FocusIn:
        {
            _glfwInputWindowFocus(window, GL_TRUE);

            if (window->cursorMode == GLFW_CURSOR_DISABLED)
                disableCursor(window);

            break;
        }

        case FocusOut:
        {
            _glfwInputWindowFocus(window, GL_FALSE);

            if (window->cursorMode == GLFW_CURSOR_DISABLED)
                restoreCursor(window);

            break;
        }

        case Expose:
        {
            _glfwInputWindowDamage(window);
            break;
        }

        case PropertyNotify:
        {
            if (event->xproperty.atom == _glfw.x11.WM_STATE &&
                event->xproperty.state == PropertyNewValue)
            {
                struct {
                    CARD32 state;
                    Window icon;
                } *state = NULL;

                if (_glfwGetWindowProperty(window->x11.handle,
                                           _glfw.x11.WM_STATE,
                                           _glfw.x11.WM_STATE,
                                           (unsigned char**) &state) >= 2)
                {
                    if (state->state == IconicState)
                        _glfwInputWindowIconify(window, GL_TRUE);
                    else if (state->state == NormalState)
                        _glfwInputWindowIconify(window, GL_FALSE);
                }

                XFree(state);
            }

            break;
        }

        case SelectionClear:
        {
            _glfwHandleSelectionClear(event);
            break;
        }

        case SelectionRequest:
        {
            _glfwHandleSelectionRequest(event);
            break;
        }

        case DestroyNotify:
            return;

        case GenericEvent:
        {
            if (event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
                XGetEventData(_glfw.x11.display, &event->xcookie))
            {
                if (event->xcookie.evtype == XI_Motion)
                {
                    XIDeviceEvent* data = (XIDeviceEvent*) event->xcookie.data;

                    window = _glfwFindWindowByHandle(data->event);
                    if (window)
                    {
                        if (data->event_x != window->x11.warpPosX ||
                            data->event_y != window->x11.warpPosY)
                        {
                            // The cursor was moved by something other than GLFW

                            double x, y;

                            if (window->cursorMode == GLFW_CURSOR_DISABLED)
                            {
                                if (_glfw.focusedWindow != window)
                                    break;

                                x = data->event_x - window->x11.cursorPosX;
                                y = data->event_y - window->x11.cursorPosY;
                            }
                            else
                            {
                                x = data->event_x;
                                y = data->event_y;
                            }

                            _glfwInputCursorMotion(window, x, y);
                        }

                        window->x11.cursorPosX = data->event_x;
                        window->x11.cursorPosY = data->event_y;
                    }
                }
            }

            XFreeEventData(_glfw.x11.display, &event->xcookie);
            break;
        }

        default:
        {
            switch (event->type - _glfw.x11.randr.eventBase)
            {
                case RRScreenChangeNotify:
                {
                    XRRUpdateConfiguration(event);
                    break;
                }
            }

            break;
        }
    }
}
Example #18
0
							}
							else
							{
								pluginsName += moduleInstance->name();
								pluginsInstance += moduleInstance;
							}
						}
					}
				}
			}
		}
	}

	VideoFilters::init();

	connect(this, SIGNAL(restoreCursor()), this, SLOT(restoreCursorSlot()));
	connect(this, SIGNAL(waitCursor()), this, SLOT(waitCursorSlot()));
	connect(this, SIGNAL(busyCursor()), this, SLOT(busyCursorSlot()));
}
void QMPlay2CoreClass::quit()
{
	if (settingsDir.isEmpty())
		return;
	for (Module *pluginInstance : asConst(pluginsInstance))
		delete pluginInstance;
	pluginsInstance.clear();
	videoFilters.clear();
	settingsDir.clear();
	shareDir.clear();
	langDir.clear();
	avformat_network_deinit();
Example #19
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;

    union {
        struct {
            unsigned int
                selectionUp   : 1,
                selectionDown : 1,
                scrollUp      : 1,
                scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};

    if ( NULL == gMenuItems ) return 0;

    // Look at the scan code.

    switch ( key )
    {
        case 0x4800:  // Up Arrow
            if ( gMenuSelection != gMenuTop )
                draw.f.selectionUp = 1;
            else if ( gMenuTop > 0 )
                draw.f.scrollDown = 1;
            break;

        case 0x5000:  // Down Arrow
            if ( gMenuSelection != gMenuBottom )
                draw.f.selectionDown = 1;
            else if ( gMenuBottom < (gMenuItemCount - 1) ) 
                draw.f.scrollUp = 1;
            break;
    }

    if ( draw.w )
    {
        if ( draw.f.scrollUp )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);
            gMenuTop++; gMenuBottom++;
            draw.f.selectionDown = 1;
        }

        if ( draw.f.scrollDown )
        {
            scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);
            gMenuTop--; gMenuBottom--;
            draw.f.selectionUp = 1;
        }

        if ( draw.f.selectionUp || draw.f.selectionDown )
        {
            CursorState cursorState;

            // Set cursor at current position, and clear inverse video.

            changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop,
                          kCursorTypeHidden, &cursorState );

            printMenuItem( &gMenuItems[gMenuSelection], 0 );

            if ( draw.f.selectionUp ) gMenuSelection--;
            else                      gMenuSelection++;

            moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );

            printMenuItem( &gMenuItems[gMenuSelection], 1 );

            restoreCursor( &cursorState );
        }

        *paramPtr = gMenuItems[gMenuSelection].param;        
        moved = 1;
    }

    return moved;
}
Example #20
0
void Draw::propagatePathEverywhere(DrawPath* path) {
  _parent->setCursor(Qt::WaitCursor);
  //RotoPath **currRotos = new RotoPath*[path->getNumElements()];
  bool kosher = true;
  
  DrawPath* currD;
  int frame = _frame, shit, i;
   
  // forwards
  kosher = path->getCorrRoto()->nextRotosExist();
  //for (i=0; i<path->getNumElements(); i++) {
  //currRotos[i] = path->getRotoCorr(i,shit)->nextC();
  //if (!currRotos[i]) kosher = false;
  //}
  currD = path;
  if (path->nextC()==NULL) {
    while (kosher) {
      frame++;      
      DrawPath* newPath = new DrawPath();
      newPath->setFixed(false);
      newPath->copyLook(path);
      _is->getDrawCurves(frame)->addPath(newPath);
      newPath->setPrevC(currD);
      currD->setNextC(newPath);
      DrawPath::fillForwardInterpolatedCurve(newPath,currD);
      currD = newPath;      
      kosher = currD->getCorrRoto()->nextRotosExist();

      currD->redoStroke(); // HM?
      currD->freshenAppearance();

      //for (i=0; i<path->getNumElements(); i++) {
      //currRotos[i] = currRotos[i]->nextC();
      //if (!currRotos[i]) kosher = false;
      //}
    } // end while
  }
  if (frame > _frame && 0) //G!
    optimizeDrawShape(path, currD, _frame, frame, false);

  /*
  // backwards
  kosher = true;
  for (i=0; i<path->getNumElements(); i++) {
    currRotos[i] = path->getRotoCorr(i,shit)->prevC();
    if (!currRotos[i]) kosher = false;
  }  
  currD = path;
  frame = _frame;
  if (path->prevC()==NULL) {
    while (kosher) {
      frame--;
      DrawPath* newPath = new DrawPath();
      newPath->setFixed(false);
      newPath->copyLook(path);
      _is->getDrawCurves(frame)->addPath(newPath);
      newPath->setNextC(currD);
      currD->setPrevC(newPath);
      DrawPath::fillBackwardInterpolatedCurve(newPath,currD,currRotos);
      currD = newPath;
      for (i=0; i<path->getNumElements(); i++) {
	currRotos[i] = currRotos[i]->prevC();
	if (!currRotos[i]) kosher = false;
      }
    } // end while
  }
  */
  emit restoreCursor();
}
Example #21
0
void Draw::mouseReleaseEvent( QMouseEvent *e ) {
  //  printf("mouse release event %d\n", e->button());
  // draw
  _mousePressed = 0;
  if (_tool == D_DRAW && _currDPath) {  // draw
    //_pressure = 2.*_sens; 
    if (_currDPath->getNumElements() > 1) {
      _parent->setCursor(Qt::WaitCursor);
      Vec2f loc = unproject(e->x(), e->y(), _h);
      _currDPath->addVertex(loc.x(), loc.y(), mapPressure());
      _dc->addPath(_currDPath);

      //for (int i=0; i<2; i++)
      //_currDPath->fair();
      _currDPath->resample(NULL);
      _currDPath->redoStroke();

      bool res=false;
      if (!_freeDraw)
	res = _currDPath->correspondRoto2(_is->getRotoCurves(_frame), _w, _h);
      _currDPath->calculateStrokeDisplayList();
      if (res) {
	_corrShow = 1;
	propagatePathEverywhere(_currDPath);
      }
      else _currDPath = NULL;
      emit restoreCursor();
    }
    else {
      delete _currDPath;
      _currDPath = NULL;
    }
  }

  /*
  else if (_tool == D_PAINT && _currDPath) { // paint
    Bboxf2D bbox = _currDPath->calcBbox();
    DrawPatch *dch = new DrawPatch((int)floor(bbox.lower.x()),(int)floor(bbox.lower.y()),
				   (int)ceil(bbox.width()), (int)ceil(bbox.height()),
				   _currColor);
    dch->takeStroke(_currDPath->giveStroke());
    _currDPath->forgetStroke();
    _dc->addPatch(dch);
    //printf("patch corner: %f %f, window: %f %f\n",dch->x(), dch->y(),
    //   bbox.width(), bbox.height());
    delete _currDPath;
    _currDPath = NULL;

    if (_propPatch && _propMode==1)
      keyframeInterpolatePatch(dch);
  }
  */

  else if (_tool == D_SELECT) { // select
    if (_selected && _dragDirty) {
      regeneratePath(_selected);
      _selected->fixLoc();
      _dragDirty = false;
    }
  }
  else if (_tool == D_OVERDRAW && _currDPath) {// overdraw 
    if (_currDPath->getNumElements() > 1) {
      _currDPath->resample(NULL);
      spliceDrawCurve();
    }
    else {
      delete _currDPath; _currDPath=NULL;
      _spliceFlag=-1; 
    }
  }

  else if (_tool==D_DROPPER) {
    _captureColor = true;
    _captureColorLoc.Set(e->x(), _h-e->y());
    _parent->updateGL();
    _captureColor = false;
  }

  else if (_tool==D_NUDGE) { // nudge
    _spliceIndex=-1;
  }

  //_minimalRenderMode = 0;
  _parent->updateGL();
}
Example #22
0
static int updateMenu( int key, void ** paramPtr )
{
    int moved = 0;
    
    int MenuTop = (int)get_env(envgMenuTop);
    int MenuSelection = (int)get_env(envgMenuSelection);
    int MenuRow = (int)get_env(envgMenuRow);
    int MenuHeight = (int)get_env(envgMenuHeight);
    int MenuBottom = (int)get_env(envgMenuBottom);
    int MenuStart = (int)get_env(envgMenuStart);
    int MenuEnd = (int)get_env(envgMenuEnd);
	
    union {
        struct {
            unsigned int
			selectionUp   : 1,
			selectionDown : 1,
			scrollUp      : 1,
			scrollDown    : 1;
        } f;
        unsigned int w;
    } draw = {{0}};
	
	if ( gMenuItems == NULL )
		return 0;
	
	switch ( key )
	{
		case 0x4800:  // Up Arrow
        {
			if ( MenuSelection != MenuTop )
				draw.f.selectionUp = 1;
			else if ( MenuTop > 0 )
				draw.f.scrollDown = 1;
			break;
        }
		case 0x5000:  // Down Arrow
        {
			if ( MenuSelection != MenuBottom )
				draw.f.selectionDown = 1;
			else if ( MenuBottom < (get_env(envgMenuItemCount) - 1) ) 
				draw.f.scrollUp = 1;
			break;
        }
		default:
			break;
	}
	
    if ( draw.w )
    {        
        if ( draw.f.scrollUp )
        {
            scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, 1);
            MenuTop++;  MenuBottom++;
			MenuStart++; MenuEnd++;
            draw.f.selectionDown = 1;
        }
		
        if ( draw.f.scrollDown )
        {
            scollPage(0, MenuRow, 40, MenuRow + MenuHeight - 1, 0x07, 1, -1);
            MenuTop--; MenuBottom--;
            MenuStart--; MenuEnd--;
            draw.f.selectionUp = 1;
        }        
		
        if ( draw.f.selectionUp || draw.f.selectionDown )
        {
			
			CursorState cursorState;
			
			// Set cursor at current position, and clear inverse video.
			changeCursor( 0, MenuRow + MenuSelection - MenuTop, kCursorTypeHidden, &cursorState );
			printMenuItem( &gMenuItems[MenuSelection], 0 );
			
			if ( draw.f.selectionUp )
			{
				MenuSelection--;
				if(( MenuSelection - MenuStart) == -1 )
				{
					MenuStart--;
					MenuEnd--;
				}
				
			} else {
				MenuSelection++;
				if(( MenuSelection - ( MenuEnd - 1) - MenuStart) > 0 )
				{
					MenuStart++;
					MenuEnd++;
				}
			}
			
			moveCursor( 0, MenuRow + MenuSelection - MenuTop );
			printMenuItem( &gMenuItems[MenuSelection], 1 );
			restoreCursor( &cursorState );
			
		}
		
        *paramPtr = gMenuItems[MenuSelection].param;        
        moved = 1;
    }
	
    safe_set_env(envgMenuSelection,MenuSelection);
    safe_set_env(envgMenuTop,MenuTop );
    safe_set_env(envgMenuRow,MenuRow);
    safe_set_env(envgMenuHeight,MenuHeight);
    safe_set_env(envgMenuBottom,MenuBottom);
    safe_set_env(envgMenuStart,MenuStart);
    safe_set_env(envgMenuEnd,MenuEnd);
	
	return moved;
}