Ejemplo n.º 1
0
HWND openTempFile(void)
    {
    char original[MAX_PATH];

    ::SendMessage(nppData._nppHandle, NPPM_GETFULLCURRENTPATH, 0, (LPARAM)original);
    HWND originalwindow = getCurrentWindow();	

	LRESULT curBuffer = ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
	LangType curLang = (LangType)::SendMessage(nppData._nppHandle, NPPM_GETBUFFERLANGTYPE, curBuffer, 0);

    int result = ::SendMessage(nppData._nppHandle, NPPM_SWITCHTOFILE, 0, (LPARAM)compareFilePath);
    HWND window = getCurrentWindow();		
    int win = SendMessageA(window, SCI_GETDOCPOINTER, 0, 0);
    
    if(result == 0 || win != tempWindow)
    {
        ::SendMessage(nppData._nppHandle, WM_COMMAND, IDM_FILE_NEW, (LPARAM)0);
        ::SendMessage(nppData._nppHandle, NPPM_GETFILENAME, 0, (LPARAM)compareFilePath);
        tempWindow = SendMessageA(window, SCI_GETDOCPOINTER, 0, 0);

		curBuffer = ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
		::SendMessage(nppData._nppHandle, NPPM_SETBUFFERLANGTYPE, curBuffer, curLang);
	}	

    if(originalwindow == window)
    {
        ::SendMessage(nppData._nppHandle, NPPM_SWITCHTOFILE, 0, (LPARAM)original);
        SendMessage(nppData._nppHandle, WM_COMMAND, IDM_VIEW_GOTO_ANOTHER_VIEW, 0);
		//::SendMessage(nppData._nppHandle, NPPM_GETFILENAME, 0, (LPARAM)compareFilePath);
        panelsOpened = true;
    }

    result=::SendMessage(nppData._nppHandle,NPPM_SWITCHTOFILE, 0, (LPARAM)original);

    window = getOtherWindow();

    int pointer = SendMessageA(window, SCI_GETDOCPOINTER, 0, 0);
    if(tempWindow != pointer)
    {
        window = getCurrentWindow();
        pointer = SendMessageA(window, SCI_GETDOCPOINTER, 0, 0);
    }

    //assert(tempWindow == pointer);

    //move focus to new document, or the other document will be marked as dirty
    ::SendMessageA(window, SCI_GRABFOCUS, 0, 0);
    ::SendMessageA(window, SCI_SETREADONLY, 0, 0);
    ::SendMessageA(window, SCI_CLEARALL, 0, 0);

    return window;
}
Ejemplo n.º 2
0
	void doDisposeWindow()
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			boost::lock_guard<boost::recursive_mutex> lock(operationsMutex);

			glutDisplayFunc(&noOp);
			glutReshapeFunc(NULL);
			glutKeyboardFunc(NULL);
			glutKeyboardUpFunc(NULL);
			glutMouseFunc(NULL);
			glutMotionFunc(NULL);
			glutPassiveMotionFunc(NULL);
			glutSpecialFunc(NULL);
			glutSpecialUpFunc(NULL);

			stopOperationsProcessing = true;

			int id = windows.right.at(window);
			windows.right.erase(window);
			windowGraphicsContexts.erase(window);
			windowNonFullscreenBounds.erase(window);

			glutDestroyWindow(id);

			window->disposed();
		}
	}
Ejemplo n.º 3
0
	void specialUp(int key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), getSpecialKey(key)));
		}
	}
Ejemplo n.º 4
0
	void passiveMotion(int x, int y)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->mouseMoved(MouseEvent(InputEvent::MODIFIER_NONE, MouseEvent::NONE, Point(x, y)));
		}
	}
Ejemplo n.º 5
0
	void keyboardUp(unsigned char key, int, int)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			window->keyReleased(KeyEvent(getModifiers(), GLUT_TO_KEYEVENT_KEYS[key]));
		}
	}
Ejemplo n.º 6
0
ofPoint Renderer::getCurrentWindowSize()
{
    windows_iterator = _windows.find( getCurrentWindow() );
    if( windows_iterator != _windows.end() ){
        return windows_iterator->second->getWindowSize();
    }
    return ofPoint(-1,-1);
}
Ejemplo n.º 7
0
ofRectangle Renderer::getCurrentPixelViewport()
{
    windows_iterator = _windows.find( getCurrentWindow() );
    if( windows_iterator != _windows.end() ){
        return windows_iterator->second->getPixelViewport();
    }
    return ofRectangle();
}
Ejemplo n.º 8
0
shared_ptr<ofBaseRenderer> Renderer::ofRenderer()
{
    windows_iterator = _windows.find( getCurrentWindow() );
    if( windows_iterator != _windows.end() ){
        return windows_iterator->second->renderer();
    }
    LBERROR << "Stardust::Renderer::ofRenderer() ---> Something is seriously wrong -- Stardust could not find an OF renderer for window " << getCurrentWindow() << "____Prepare to FAIL____" << std::endl;
}
Ejemplo n.º 9
0
int Renderer::getCurrentWindowHeight()
{
    windows_iterator = _windows.find( getCurrentWindow() );
    if( windows_iterator != _windows.end() ){
        return windows_iterator->second->getHeight();
    }
    return -1;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetY(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
	Display *disp = (Display *)(intptr_t)display_ptr;
	Window win = getCurrentWindow(env, display_ptr, window_ptr);

	XWindowAttributes win_attribs;
	XGetWindowAttributes(disp, win, &win_attribs);

	return win_attribs.y;
}
Ejemplo n.º 11
0
	void mouse(int button, int state, int x, int y)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			if (state == GLUT_DOWN) {
				window->mousePressed(MouseEvent(getModifiers(), getButton(button), Point(x, y)));
			} else if (state == GLUT_UP) {
				window->mouseReleased(MouseEvent(getModifiers(), getButton(button), Point(x, y)));
			}
		}
	}
Ejemplo n.º 12
0
	void reshape(int width, int height)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			inReshapeCallback = true;

			window->setSize(Size(width, height));

			inReshapeCallback = false;
		}
	}
Ejemplo n.º 13
0
	void doSetWindowVisible(bool visible)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			if (visible) {
				glutShowWindow();
				window->onShow();
			} else {
				glutHideWindow();
				window->onHide();
			}
		}
	}
Ejemplo n.º 14
0
Window getActiveWindow() {

/*	Window *root_return = None, *child_return = None;
	int *root_x_return = 0, *root_y_return = 0;
	int *win_x_return = 0, *win_y_return = 0;
	unsigned int *mask_return = 0;

	XQueryPointer(display, root, root_return, child_return, root_x_return, root_y_return, 
                     win_x_return, win_y_return, mask_return);

	return *child_return;*/
	return getCurrentWindow();

}
Ejemplo n.º 15
0
void Renderer::draw( co::Object* frameData )
{
    if( _userRenderer )
    {
        /// update events
        windows_iterator = _windows.find( getCurrentWindow() );
        if( windows_iterator != _windows.end() ){
            windows_iterator->second->events().notifyUpdate();
        }
        ///> update callback
        _userRenderer->update();
        ///> draw callback
        _userRenderer->draw( frameData );
    }
}
Ejemplo n.º 16
0
	void display()
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			GraphicsContext& context = windowGraphicsContexts.find(window)->second;
			context.setViewportSize(window->getSize());
			context.checkNativeImages();

			Graphics g(context, getFontManager());

			window->display(g);

			glutSwapBuffers();
		}
	}
Ejemplo n.º 17
0
	void doSetWindowFullscreen(bool fullscreen)
	{
		Window::Ptr window = getCurrentWindow();
		if (window) {
			bool isAlreadyFullscreen = windowNonFullscreenBounds.find(window) != windowNonFullscreenBounds.end();

			if (fullscreen && !isAlreadyFullscreen) {
				windowNonFullscreenBounds.insert(std::make_pair(window, Rectangle(window->getPosition(), window->getSize())));
				glutFullScreen();
			} else if (!fullscreen && isAlreadyFullscreen) {
				const Rectangle& bounds = windowNonFullscreenBounds.find(window)->second;
				doSetWindowSize(bounds.size);
				doSetWindowPosition(bounds.upperLeftCorner);
				windowNonFullscreenBounds.erase(window);
			}
		}
	}
Ejemplo n.º 18
0
	bool isCurrentWindow(Window::Ptr window)
	{
		return window == getCurrentWindow();
	}
Ejemplo n.º 19
0
void Renderer::processWindowEvent( eq::Window* eqWindow, const eq::Event& event )
{
    ///> forward moused/keyboard events...
    windows_iterator = _windows.find( getCurrentWindow() );
    if( windows_iterator != _windows.end() )
    {
        switch(event.type)
        {
            case eq::Event::WINDOW_POINTER_BUTTON_PRESS:
            {
                ofGetMainLoop()->setCurrentWindow(windows_iterator->second);
                const eq::PointerEvent& pressEvent = event.pointerButtonPress;
                int button = 0;
                switch( pressEvent.button )
                {
                    case eq::PTR_BUTTON1:
                    {
                        button = OF_MOUSE_BUTTON_LEFT;
                        break;
                    }
                    case eq::PTR_BUTTON2:
                    {
                        button = OF_MOUSE_BUTTON_MIDDLE;
                        break;
                    }
                    case eq::PTR_BUTTON3:
                    {
                        button = OF_MOUSE_BUTTON_RIGHT;
                        break;
                    }
                }
                windows_iterator->second->_buttonPressed = true;
                windows_iterator->second->_buttonInUse = button;
                windows_iterator->second->events().notifyMousePressed( pressEvent.x, pressEvent.y, button );
                break;
            }
            case eq::Event::WINDOW_POINTER_BUTTON_RELEASE:
            {
                ofGetMainLoop()->setCurrentWindow(windows_iterator->second);
                const eq::PointerEvent& releaseEvent = event.pointerButtonRelease;
                int button = 0;
                switch( releaseEvent.button )
                {
                    case eq::PTR_BUTTON1:
                    {
                        button = OF_MOUSE_BUTTON_LEFT;
                        break;
                    }
                    case eq::PTR_BUTTON2:
                    {
                        button = OF_MOUSE_BUTTON_MIDDLE;
                        break;
                    }
                    case eq::PTR_BUTTON3:
                    {
                        button = OF_MOUSE_BUTTON_RIGHT;
                        break;
                    }
                }
                windows_iterator->second->_buttonPressed = false;
                windows_iterator->second->_buttonInUse = button;
                windows_iterator->second->events().notifyMouseReleased( releaseEvent.x, releaseEvent.y, button );
                break;
            }
            case eq::Event::WINDOW_POINTER_MOTION:
            {
                ofGetMainLoop()->setCurrentWindow(windows_iterator->second);
                if( windows_iterator->second->_buttonPressed )
                {
                    windows_iterator->second->events().notifyMouseDragged( event.pointerMotion.x, event.pointerMotion.y, windows_iterator->second->_buttonInUse );
                }
                else
                {
                    windows_iterator->second->events().notifyMouseMoved( event.pointerMotion.x, event.pointerMotion.y );
                }
                break;
            }
            default:
            {
                break;
            }
        }
    }
}
Ejemplo n.º 20
0
ofCoreEvents& Renderer::events()
{
    windows_iterator = _windows.find( getCurrentWindow() );
    return windows_iterator->second->events();
}
Ejemplo n.º 21
0
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
    long start, end;

    switch (notifyCode->nmhdr.code) 
    {
    case SCN_PAINTED:
        if(active) 
        {            
            start = SendMessage(nppData._scintillaMainHandle, SCI_GETFIRSTVISIBLELINE, 0, 0);
            end   = SendMessage(nppData._scintillaMainHandle, SCI_LINESONSCREEN, 0, 0) + start;

            if((start_old != start) && (NavDlg.ReadyToDraw == TRUE))
            {
                NavDlg.DrawView(start, end);
                start_old = start;
            }
        }
        break;

    case NPPN_TBMODIFICATION:
        {         
            tbNext.hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDB_NEXT), IMAGE_BITMAP, 0, 0, (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));
            tbPrev.hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDB_PREV), IMAGE_BITMAP, 0, 0, (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));
            tbFirst.hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDB_FIRST), IMAGE_BITMAP, 0, 0, (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));
            tbLast.hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDB_LAST), IMAGE_BITMAP, 0, 0, (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));

			::SendMessage(nppData._nppHandle, NPPM_ADDTOOLBARICON, (WPARAM)funcItem[CMD_FIRST]._cmdID, (LPARAM)&tbFirst);
            ::SendMessage(nppData._nppHandle, NPPM_ADDTOOLBARICON, (WPARAM)funcItem[CMD_PREV]._cmdID, (LPARAM)&tbPrev);
            ::SendMessage(nppData._nppHandle, NPPM_ADDTOOLBARICON, (WPARAM)funcItem[CMD_NEXT]._cmdID, (LPARAM)&tbNext);
            ::SendMessage(nppData._nppHandle, NPPM_ADDTOOLBARICON, (WPARAM)funcItem[CMD_LAST]._cmdID, (LPARAM)&tbLast);

            ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_ALIGN_MATCHES]._cmdID, (LPARAM)Settings.AddLine);
            ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_IGNORE_SPACING]._cmdID, (LPARAM)Settings.IncludeSpace);
            ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_DETECT_MOVES]._cmdID, (LPARAM)Settings.DetectMove);
            ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_USE_NAV_BAR]._cmdID, (LPARAM)Settings.UseNavBar);

            break;
        }

    case NPPN_FILEBEFORECLOSE:
    case NPPN_FILECLOSED:
    case NPPN_FILEBEFOREOPEN:
    case NPPN_FILEOPENED:
        {
        notepadVersionOk = true;
        break;
        }

    case NPPN_FILEBEFORESAVE:
        {
            notepadVersionOk = true;

            SendMessage(nppData._nppHandle, NPPM_GETFULLCURRENTPATH, 0, (LPARAM)emptyLinesDoc);

            HWND window = getCurrentWindow();						
            int win = SendMessageA(window, SCI_GETDOCPOINTER, 0,0);

            if(getCompare(win)!=-1)
            {				
                topLine = SendMessageA(window,SCI_GETFIRSTVISIBLELINE,0,0);
                lastEmptyLines = removeEmptyLines(window,true);
            }
            else
            {
                lastEmptyLines=NULL;
            }

            break;
        }

    case NPPN_FILESAVED:
        {
            notepadVersionOk = true;
            TCHAR name[MAX_PATH];
            SendMessage(nppData._nppHandle,NPPM_GETFULLCURRENTPATH,0,(LPARAM)name);

            if(lastEmptyLines != NULL && lstrcmp(name, emptyLinesDoc) == 0)
            {
                HWND window = getCurrentWindow();
                ::addBlankLines(window,lastEmptyLines);
                int linesOnScreen = SendMessageA(window,SCI_LINESONSCREEN,0,0);
                int curPosBeg = ::SendMessageA(window, SCI_GETSELECTIONSTART, 0, 0);
                int curPosEnd = ::SendMessageA(window, SCI_GETSELECTIONEND, 0, 0);
                SendMessageA(window,SCI_GOTOLINE,topLine,0);
                SendMessageA(window,SCI_GOTOLINE,topLine+linesOnScreen-1,0);
                SendMessageA(window, SCI_SETSEL, curPosBeg, curPosEnd);
                cleanEmptyLines(lastEmptyLines);
                delete lastEmptyLines;
                lastEmptyLines = NULL;
                emptyLinesDoc[0] = 0;
            }
        }
        break;
	case NPPN_SHUTDOWN:
		{
			// Always close it, else N++'s plugin manager would call 'ViewNavigationBar'
			// on startup, when N++ has been shut down before with opened navigation bar
			if (NavDlg.isVisible())
				NavDlg.doDialog(false);
			break;
		}
    }
}
Ejemplo n.º 22
0
// Exit compare session
// - Clear results
// - Delete objects
// - Restore previous NP++ appearance (markers, highlight, ...)
void reset()
{
    if (active == true)
    {
		LRESULT RODoc1;
		LRESULT RODoc2;

		// Remove read-only attribute
		if ((RODoc1 = SendMessage(nppData._scintillaMainHandle, SCI_GETREADONLY, 0, 0)) == 1)
			SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, false, 0);

		if ((RODoc2 = SendMessage(nppData._scintillaSecondHandle, SCI_GETREADONLY, 0, 0)) == 1)
			SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, false, 0);

        int doc1 = SendMessageA(nppData._scintillaMainHandle, SCI_GETDOCPOINTER, 0, 0);
        int doc2 = SendMessageA(nppData._scintillaSecondHandle, SCI_GETDOCPOINTER, 0, 0);

        int doc1Index = getCompare(doc1);
        int doc2Index = getCompare(doc2);
        int win = 3;

        ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&win);
        HWND window = getCurrentHScintilla(win);

        if(doc1Index != -1)
        {
            clearWindow(nppData._scintillaMainHandle, true);
        }
        if(doc2Index != -1)
        {
            clearWindow(nppData._scintillaSecondHandle, true);
        }

        ::SendMessageA(window, SCI_GRABFOCUS, 0, (LPARAM)1);

        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLV, 0), 0);
        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLH, 0), 0);	

        if(panelsOpened)
        {
            ::SendMessageA(nppData._scintillaSecondHandle, SCI_GRABFOCUS, 0, (LPARAM)0);
            SendMessage(nppData._nppHandle, WM_COMMAND, IDM_VIEW_GOTO_ANOTHER_VIEW, 0);
        }

        if(tempWindow!=-1)
        {
            ::SendMessage(nppData._nppHandle, NPPM_SWITCHTOFILE, 0, (LPARAM)compareFilePath);
            window = getCurrentWindow();	
            int tempPointer = SendMessageA(window, SCI_GETDOCPOINTER, 0, 0);
            
            if(tempPointer == tempWindow)
            {
                SendMessageA(window,SCI_EMPTYUNDOBUFFER,0,0);
                SendMessage(nppData._nppHandle, WM_COMMAND, IDM_FILE_CLOSE, 0);
            }
            tempWindow = -1;
			LRESULT ROTemp = RODoc1; RODoc1 = RODoc2; RODoc2 = ROTemp;
        }

        // Remove margin mask
        ::SendMessage(nppData._scintillaMainHandle, SCI_SETMARGINMASKN, (WPARAM)4, (LPARAM)0);
        ::SendMessage(nppData._scintillaSecondHandle, SCI_SETMARGINMASKN, (WPARAM)4, (LPARAM)0);

        // Remove margin
        ::SendMessage(nppData._scintillaMainHandle, SCI_SETMARGINWIDTHN, (WPARAM)4, (LPARAM)0);
        ::SendMessage(nppData._scintillaSecondHandle, SCI_SETMARGINWIDTHN, (WPARAM)4, (LPARAM)0);

        removeCompare(doc1);
        removeCompare(doc2);

        panelsOpened = false;
        active = false;

        // Close NavBar
        NavDlg.doDialog(false);

        // Disable Prev/Next menu entry
        HMENU hMenu = ::GetMenu(nppData._nppHandle);
        ::EnableMenuItem(hMenu, funcItem[CMD_PREV]._cmdID, MF_BYCOMMAND | MF_GRAYED);
        ::EnableMenuItem(hMenu, funcItem[CMD_NEXT]._cmdID, MF_BYCOMMAND | MF_GRAYED);
        ::EnableMenuItem(hMenu, funcItem[CMD_FIRST]._cmdID, MF_BYCOMMAND | MF_GRAYED);
        ::EnableMenuItem(hMenu, funcItem[CMD_LAST]._cmdID, MF_BYCOMMAND | MF_GRAYED);

        // Restore side bar item entry state (because tick has been removed by the docked window)
        CheckMenuItem(hMenu, funcItem[CMD_USE_NAV_BAR]._cmdID, MF_BYCOMMAND | (Settings.UseNavBar ? MF_CHECKED : MF_UNCHECKED));

		// Restore previous read-only attribute
		if (RODoc1 == 1) SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, true, 0);
		if (RODoc2 == 1) SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, true, 0);
    }
}