Example #1
0
void CGuiWidget::SetIsVisible(bool vis)
{
    xf6_25_isVisible = vis;
    if (vis)
        OnVisible();
    else
        OnInvisible();
}
Example #2
0
int XWindow::RunModal()
{
    Prepare();

    // Trap XWindows "WM_DELETE_WINDOW" message
    Atom wmDeleteMessage = XInternAtom(windowDisplay, "WM_DELETE_WINDOW", false);
    XSetWMProtocols(windowDisplay, window, &wmDeleteMessage, 1);

    XkbEvent event;
    do {
        // Gets the new event
        int res = XNextEvent(windowDisplay, &event.core);
        if (window != event.core.xany.window) continue;

        // Processes the events
        if (event.type == ButtonPress) {
            WindowEventMouseButton e(&event.core.xbutton);
            OnMouseDown(&e);
        } else if (event.type == ButtonRelease) {
            WindowEventMouseButton e(&event.core.xbutton);
            OnMouseUp(&e);
        } else if (event.type == MotionNotify) {
            WindowEventMouseMove e(&event.core.xmotion);
            OnMouseMove(&e);
        } else if (event.type == EnterNotify) {
            WindowEventEnterLeave e(&event.core.xcrossing);
            OnMouseEnterLeave(&e);
        } else if (event.type == LeaveNotify) {
            WindowEventEnterLeave e(&event.core.xcrossing);
            OnMouseEnterLeave(&e);
        } else if (event.type == FocusIn) {
            WindowEventFocus e(&event.core.xfocus);
            OnFocus(&e);
        } else if (event.type == FocusOut) {
            WindowEventFocus e(&event.core.xfocus);
            OnFocus(&e);
        } else if (event.type == Expose && event.core.xexpose.count == 0) {
            WindowEventDraw e(gc, &event.core.xexpose);
            OnDraw(&e);
        } else if (event.type == VisibilityNotify) {
            WindowEventVisible e(&event.core.xvisibility);
            OnVisible(&e);
        } else if (event.type == UnmapNotify) {
            WindowEventShow e(false);
            OnShow(&e);
        } else if (event.type == MapNotify) {
            WindowEventShow e(true);
            OnShow(&e);
        } else if (event.type == ConfigureNotify) {
            bool generateWindowMoveEvent =
                area->GetX() != event.core.xconfigure.x ||
                area->GetY() != event.core.xconfigure.y;
            bool generateWindowResizeEvent =
                area->GetWidth() != event.core.xconfigure.width ||
                area->GetHeight() != event.core.xconfigure.height;

            *area = NRectangle(
                        event.core.xconfigure.x, event.core.xconfigure.y,
                        event.core.xconfigure.width, event.core.xconfigure.height);
            borderwidth = event.core.xconfigure.border_width;

            if (generateWindowMoveEvent) {
                WindowEventMove e(&event.core.xconfigure);
                OnMove(&e);
            }
            if (generateWindowResizeEvent) {
                gc->Resize(area->GetWidth(), area->GetHeight());	// Resize XWindowGraphics
                WindowEventResize e(&event.core.xconfigure);
                OnResize(&e);
            }
        } else if (event.type == ColormapNotify) {
            WindowEventColormap e(&event.core.xcolormap);
            OnColormap(&e);
        } else if (event.type == KeyPress) {
            WindowEventKey e(&event.core.xkey);
            OnKeyPress(&e);
        } else if (event.type == KeyRelease) {
            WindowEventKey e(&event.core.xkey);
            OnKeyRelease(&e);
        } else if (event.type == XDisplay::Default().XkbBaseEvent() + XkbEventCode) {
            // XkbEvents
            if (event.any.xkb_type == XkbMapNotify) {
                WindowEventKeymap e(&event.map);
                OnKeymap(&e);
            } else if (event.any.xkb_type == XkbNewKeyboardNotify) {
                WindowEventKeyboardMapping e(&event.new_kbd);
                OnKeyboardMapping(&e);
            } else if (event.any.xkb_type == XkbStateNotifyMask) {
                int kk = 1;
            }
        } else if (event.type == ClientMessage) {
            if (event.core.xclient.data.l[0] == wmDeleteMessage)
                break;
        } else if (event.type != 28 && event.type != 21) {
            int kk = 1;
        }

        // Locks the collection of delegations
        windowMutex->Lock();
        for (int i=0; i<delegationsToExecute->Count(); i++) {
            // Retrieve delegation and parameters
            void **item = (void **)(*delegationsToExecute)[i];
            NDelegation *d = (NDelegation *)item[0];
            void *params = item[1];

            // Execute delegation
            try {
                d->Execute(params);
            } catch (Exception *e) {
                delete e;
            }

            // Deletes delegation and item array
            delete d;
            delete item;
        }

        // Clear delegations collection and unlocks the mutex
        delegationsToExecute->Clear();
        windowMutex->Unlock();
    } while (true);

    Dispose();
}
Example #3
0
STDMETHODIMP DWebBrowserEventsImpl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
            EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
	switch (dispIdMember)
		{
			/////////////////////////////////////////////////////////
			// The parameters for this DISPID are as follows:
			// [0]: Cancel flag  - VT_BYREF|VT_BOOL
			// [1]: IDispatch* - Pointer to an IDispatch interface. 
			//		You can set this parameter to the IDispatch of 
			//		a WebBrowser Control that you've created. When 
			//		you pass back an IDispatch like this, MSHTML will 
			//		use the control you've given it to open the link.
			//
		case DISPID_NEWWINDOW2:
			{
				NewWindow2(pDispParams->rgvarg[1].ppdispVal, pDispParams->rgvarg[0].pboolVal);
			}
			break;

			///////////////////////////////////////////////////////////
			// The parameters for this DISPID are as follows:
			// [0]: Cancel flag  - VT_BYREF|VT_BOOL
			// [1]: HTTP headers - VT_BYREF|VT_VARIANT
			// [2]: Address of HTTP POST data  - VT_BYREF|VT_VARIANT 
			// [3]: Target frame name - VT_BYREF|VT_VARIANT 
			// [4]: Option flags - VT_BYREF|VT_VARIANT
			// [5]: URL to navigate to - VT_BYREF|VT_VARIANT
			// [6]: An object that evaluates to the top-level or frame
			//      WebBrowser object corresponding to the event. 
			// 
			// User clicked a link or launched the browser.
			//
		case DISPID_BEFORENAVIGATE2:
			{
				BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, 
					pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal);
			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: URL navigated to - VT_BYREF|VT_VARIANT
			// [1]: An object that evaluates to the top-level or frame
			//      WebBrowser object corresponding to the event. 
			//
			// Fires after a navigation to a link is completed on either 
			// a window or frameSet element.
			//
		case DISPID_NAVIGATECOMPLETE2:
			{
				NavigateComplete2(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal);
				
				// Check if m_lpDocCompleteDisp is NULL. If NULL, that means it is
				// the top level NavigateComplete2. Save the LPDISPATCH
				if (!m_lpDocCompleteDisp)
				{
					VARIANTARG varDisp = pDispParams->rgvarg[1];
					m_lpDocCompleteDisp = varDisp.pdispVal;
				}

			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: New status bar text - VT_BSTR
			//
		case DISPID_STATUSTEXTCHANGE:
			{
				StatusTextChange(pDispParams->rgvarg[0].bstrVal);
			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Maximum progress - VT_I4
			// [1]: Amount of total progress - VT_I4
			//
		case DISPID_PROGRESSCHANGE:
			{
				ProgressChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].intVal);
			}
			break;

			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: URL navigated to - VT_BYREF|VT_VARIANT
			// [1]: An object that evaluates to the top-level or frame
			//      WebBrowser object corresponding to the event. 
			//
			// Fires when a document has been completely loaded and initialized.
			// Unreliable -- currently, the DWebBrowserEvents2::DocumentComplete 
			// does not fire when the IWebBrowser2::Visible property of the 
			// WebBrowser Control is set to false (see Q259935).  Also, multiple 
			// DISPID_DOCUMENTCOMPLETE events can be fired before the final 
			// READYSTATE_COMPLETE (see Q180366).
			//
		case DISPID_DOCUMENTCOMPLETE:
			{
				DocumentComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal);
				
				VARIANTARG varDisp = pDispParams->rgvarg[1];
				if (m_lpDocCompleteDisp && m_lpDocCompleteDisp == varDisp.pdispVal)
				{
					// if the LPDISPATCH are same, that means
					// it is the final DocumentComplete. Reset m_lpDocCompleteDisp
					m_lpDocCompleteDisp = NULL;

					// Handle new doc.
					DocumentReallyComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal);
				}

			}
			break;
			
			///////////////////////////////////////////////////////////
			// No parameters
			//
			// Fires when a navigation operation is beginning.
			//
		case DISPID_DOWNLOADBEGIN:
			DownloadBegin();
			break;
			
			///////////////////////////////////////////////////////////
			// No parameters
			//
			// Fires when a navigation operation finishes, is halted, or fails.
			//
		case DISPID_DOWNLOADCOMPLETE:
			DownloadComplete();
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Enabled state - VT_BOOL
			// [1]: Command identifier - VT_I4
			//
		case DISPID_COMMANDSTATECHANGE:
			{
				CommandStateChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].boolVal);
			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Document title - VT_BSTR
			// [1]: An object that evaluates to the top-level or frame
			//      WebBrowser object corresponding to the event.
			//
		case DISPID_TITLECHANGE:
			{
				TitleChange(pDispParams->rgvarg[0].bstrVal);
			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Name of property that changed - VT_BSTR
			//
		case DISPID_PROPERTYCHANGE:
			{
				PropertyChange(pDispParams->rgvarg[0].bstrVal);
			}
			break;
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Cancel flag  - VT_BYREF|VT_BOOL
			// [1]: Child Window (created from script) - VT_BOOL
			//      
			//
		case DISPID_WINDOWCLOSING:
			{
				WindowClosing(pDispParams->rgvarg[1].boolVal, pDispParams->rgvarg[0].pboolVal);
			}
			break;

			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Cancel flag  - VT_BYREF|VT_BOOL
			//      
			//
		case DISPID_FILEDOWNLOAD:
			{
				FileDownload(pDispParams->rgvarg[0].pboolVal);
			}
			break;
			
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID are as follows:
			// [0]: Cancel flag			- VT_BYREF|VT_BOOL
			// [1]: Error status code	- VT_BYREF|VT_VARIANT  
			// [2]: Target frame name	- VT_BYREF|VT_VARIANT 
			// [3]: URL where navigate failed - VT_BYREF|VT_VARIANT
			// [4]: An object that evaluates to the top-level or frame
			//      WebBrowser object corresponding to the event. 
			// 
			//
		case DISPID_NAVIGATEERROR:
			{
				NavigateError(pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, 
					pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal);

				m_lpDocCompleteDisp = NULL;
			}
			break;
			///////////////////////////////////////////////////////////
			// The parameters for this DISPID:
			// [0]: Visible  - VT_BOOL
			//
		case DISPID_ONVISIBLE:
			{
				OnVisible(pDispParams->rgvarg[0].boolVal);
			}
			break;

			///////////////////////////////////////////////////////////
			// No parameters
			//
			// The BHO docs in MSDN say to use DISPID_QUIT, but this is an error.
			// The BHO never gets a DISPID_QUIT and thus the browser connection
			// never gets unadvised and so the BHO never gets the FinalRelease().
			// This is bad.  So use DISPID_ONQUIT instead and everything is cool --
			// EXCEPT when you exit the browser when viewing a page that launches
			// a popup in the onunload event!  In that case the BHO is already
			// unadvised so it does not intercept the popup.  So the trick is to
			// navigate to a known page (I used the about:blank page) that does 
			// not have a popup in the onunload event before unadvising.
			//
		case DISPID_ONQUIT:
			OnQuit();
			break;

		default:
			{
			}
			break;
	}

	return NOERROR;
}