Exemplo n.º 1
0
bool wxTopLevelWindowGTK::Show( bool show )
{
    wxCHECK_MSG(m_widget, false, "invalid frame");

#ifdef GDK_WINDOWING_X11
    bool deferShow = show && !m_isShown && m_deferShow;
    if (deferShow)
    {
        deferShow = m_deferShowAllowed &&
            gs_requestFrameExtentsStatus != RFE_STATUS_BROKEN &&
            !gtk_widget_get_realized(m_widget) &&
            GDK_IS_X11_DISPLAY(gtk_widget_get_display(m_widget)) &&
            g_signal_handler_find(m_widget,
                GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
                g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
                0, NULL, NULL, this);
        if (deferShow)
        {
            GdkScreen* screen = gtk_widget_get_screen(m_widget);
            GdkAtom atom = gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false);
            deferShow = gdk_x11_screen_supports_net_wm_hint(screen, atom) != 0;

            // If _NET_REQUEST_FRAME_EXTENTS not supported, don't allow changes
            // to m_decorSize, it breaks saving/restoring window size with
            // GetSize()/SetSize() because it makes window bigger between each
            // restore and save.
            m_updateDecorSize = deferShow;
        }

        m_deferShow = deferShow;
    }
    if (deferShow)
    {
        // Initial show. If WM supports _NET_REQUEST_FRAME_EXTENTS, defer
        // calling gtk_widget_show() until _NET_FRAME_EXTENTS property
        // notification is received, so correct frame extents are known.
        // This allows resizing m_widget to keep the overall size in sync with
        // what wxWidgets expects it to be without an obvious change in the
        // window size immediately after it becomes visible.

        // Realize m_widget, so m_widget->window can be used. Realizing normally
        // causes the widget tree to be size_allocated, which generates size
        // events in the wrong order. However, the size_allocates will not be
        // done if the allocation is not the default (1,1).
        GtkAllocation alloc;
        gtk_widget_get_allocation(m_widget, &alloc);
        const int alloc_width = alloc.width;
        if (alloc_width == 1)
        {
            alloc.width = 2;
            gtk_widget_set_allocation(m_widget, &alloc);
        }
        gtk_widget_realize(m_widget);
        if (alloc_width == 1)
        {
            alloc.width = 1;
            gtk_widget_set_allocation(m_widget, &alloc);
        }

        // send _NET_REQUEST_FRAME_EXTENTS
        XClientMessageEvent xevent;
        memset(&xevent, 0, sizeof(xevent));
        xevent.type = ClientMessage;
        GdkWindow* window = gtk_widget_get_window(m_widget);
        xevent.window = GDK_WINDOW_XID(window);
        xevent.message_type = gdk_x11_atom_to_xatom_for_display(
            gdk_window_get_display(window),
            gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
        xevent.format = 32;
        Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
        XSendEvent(display, DefaultRootWindow(display), false,
            SubstructureNotifyMask | SubstructureRedirectMask,
            (XEvent*)&xevent);

        if (gs_requestFrameExtentsStatus == RFE_STATUS_UNKNOWN)
        {
            // if WM does not respond to request within 1 second,
            // we assume support for _NET_REQUEST_FRAME_EXTENTS is not working
            m_netFrameExtentsTimerId =
                g_timeout_add(1000, request_frame_extents_timeout, this);
        }

        // defer calling gtk_widget_show()
        m_isShown = true;
        return true;
    }
#endif // GDK_WINDOWING_X11

    if (show && !gtk_widget_get_realized(m_widget))
    {
        // size_allocate signals occur in reverse order (bottom to top).
        // Things work better if the initial wxSizeEvents are sent (from the
        // top down), before the initial size_allocate signals occur.
        wxSizeEvent event(GetSize(), GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);

#ifdef __WXGTK3__
        GTKSizeRevalidate();
#endif
    }

    bool change = base_type::Show(show);

    if (change && !show)
    {
        // make sure window has a non-default position, so when it is shown
        // again, it won't be repositioned by WM as if it were a new window
        // Note that this must be done _after_ the window is hidden.
        gtk_window_move((GtkWindow*)m_widget, m_x, m_y);
    }

    return change;
}
Exemplo n.º 2
0
void
stars(void)
{
	double lomoon, himoon, sd;
	int wrap, f, i;
	char *saop;
	static char saoa[100];

	sd = 1000*radsec;
	lomoon = omoon.point[0].ra - sd;
	if(lomoon < 0)
		lomoon += pipi;
	himoon = omoon.point[NPTS+1].ra + sd;
	if(himoon > pipi)
		himoon -= pipi;
	lomoon *= 12/pi;
	himoon *= 12/pi;
	wrap = 0;
	if(lomoon > himoon)
		wrap++;

	f = open(startab, OREAD);
	if(f < 0) {
		fprint(2, "%s?\n", startab);
		return;
	}
	epoch = 1950.0;
	epoch = (epoch-1900.0) * 365.24220 + 0.313;
	saop = saoa;

/*
 *	read mean places of stars at epoch of star table
 */

loop:
	if(rline(f)) {
		close(f);
		return;
	}
	rah = atof(line+17);
	ram = atof(line+20);
	ras = atof(line+23);

	alpha = rah + ram/60 + ras/3600;
	if(wrap == 0) {
		if(alpha < lomoon || alpha > himoon)
			goto loop;
	} else
		if(alpha < lomoon && alpha > himoon)
			goto loop;

	sao = atof(line+0);
	sprint(saop, "%ld", sao);
	da = atof(line+30);
	dday = atof(line+37);
	dmin = atof(line+41);
	dsec = atof(line+44);
	dd = atof(line+50);
	px = atof(line+57);
	mag = atof(line+61);

/*
 *	convert rt ascension and declination to internal format
 */

	delta = fabs(dday) + dmin/60 + dsec/3600;
	if(dday < 0)
		delta = -delta;

	star();
/*
 *	if(fabs(beta) > 6.55*radian)
 *		goto loop;
 */
	sd = .0896833e0*cos(beta)*sin(lambda-1.3820+.00092422117*eday)
		 + 0.99597*sin(beta);
	if(fabs(sd) > .0183)
		goto loop;

	for(i=0; i<=NPTS+1; i++)
		setobj(&ostar.point[i]);

	occult(&omoon, &ostar, 0);
	if(occ.t1 >= 0 || occ.t5 >= 0) {
		i = PTIME;
		if(mag > 2)
			i |= DARK;
		if(mag < 5)
			i |= SIGNIF;
		if(occ.t1 >= 0 && occ.e1 >= 0)
			event("Occultation of SAO %s begins at ",
				saop, "", occ.t1, i);
		if(occ.t5 >= 0 && occ.e5 >= 0)
			event("Occultation of SAO %s ends at ",
				saop, "", occ.t5, i);
		while(*saop++)
			;
	}
	goto loop;
}
Exemplo n.º 3
0
void Host_UpdateTitle(const std::string& title)
{
	wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_TITLE);
	event.SetString(StrToWxStr(title));
	main_frame->GetEventHandler()->AddPendingEvent(event);
}
void PVAuthorEngineNodeUtility::NodeCommandCompleted(const PVMFCmdResp& aResponse)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "PVAuthorEngineNodeUtility::NodeCommandCompleted"));

    if (iCmdQueue.empty())
    {
        LOG_ERR((0, "PVAuthorEngineNodeUtility::NodeCommandCompleted: Error - Empty command queue"));
        PVMFAsyncEvent event(PVMFErrorEvent, PVMFFailure, NULL, NULL);
        iObserver->NodeUtilErrorEvent(event);
        return;
    }

    PVAENodeUtilCmd cmd = iCmdQueue[0];
    if (aResponse.GetCmdStatus() != PVMFSuccess)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "PVAuthorEngineNodeUtility::NodeCommandCompleted: Command failed - context=0x%x, status=0x%x",
                         aResponse.GetContext(), aResponse.GetCmdStatus()));
        CompleteUtilityCmd(cmd, aResponse.GetCmdStatus());
        return;
    }

    PVMFStatus status = PVMFSuccess;
    switch (cmd.iType)
    {
        case PVAENU_CMD_CONNECT:
            status = CompleteConnect(cmd, aResponse);
            break;
        case PVAENU_CMD_DISCONNECT:
            status = DoDisconnect(cmd);
            break;
        case PVAENU_CMD_QUERY_UUID:
            status = PVMFSuccess;
            break;
        case PVAENU_CMD_QUERY_INTERFACE:
            status = CompleteQueryInterface(cmd);
            break;
        case PVAENU_CMD_INIT:
            status = CompleteStateTransition(cmd, EPVMFNodeInitialized);
            break;
        case PVAENU_CMD_PREPARE:
            status = CompleteStateTransition(cmd, EPVMFNodePrepared);
            break;
        case PVAENU_CMD_START:
            status = CompleteStateTransition(cmd, EPVMFNodeStarted);
            break;
        case PVAENU_CMD_PAUSE:
            status = CompleteStateTransition(cmd, EPVMFNodePaused);
            break;
        case PVAENU_CMD_STOP:
        case PVAENU_CMD_FLUSH:
            status = CompleteStateTransition(cmd, EPVMFNodePrepared);
            break;
        case PVAENU_CMD_RESET:
            status = CompleteStateTransition(cmd, EPVMFNodeCreated);
            break;
        default:
            status = PVMFFailure;
            break;
    }

    if (status != PVMFPending)
    {
        CompleteUtilityCmd(cmd, status);
    }
    else if (iCmdQueue.size() == 1) {  // kick off the execution of the command
        RunIfNotReady();
    }
}
Exemplo n.º 5
0
// Process messages from the frame
MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2)
{
   MRESULT mresult = 0;
   BOOL    bDone = FALSE;

   switch (msg)
   {
      case WM_WINDOWPOSCHANGED:
      {
         PSWP pSwp = (PSWP) mp1;

         // Note that client windows never get 'move' messages (well, they won't here anyway)
         if( pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE))
         {
            // These commented-out `-1's cancel each other out.
            POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy /* - 1 */ };
            ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y /* - 1*/ ;
            mBounds.x = ptl.x;
            mBounds.y = ptl.y;
            OnMove( ptl.x, ptl.y);
         }

         // When the frame is sized, do stuff to recalculate client size.
         if( pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE))
         {
            mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);
            bDone = TRUE;

            mBounds.width = pSwp->cx;
            mBounds.height = pSwp->cy;

            UpdateClientSize();
            DispatchResizeEvent( mSizeClient.width, mSizeClient.height);
         }
 
         if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) {
           nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this);
            if (pSwp->fl & SWP_MAXIMIZE)
              event.mSizeMode = nsSizeMode_Maximized;
            else if (pSwp->fl & SWP_MINIMIZE)
              event.mSizeMode = nsSizeMode_Minimized;
            else
              event.mSizeMode = nsSizeMode_Normal;
            InitEvent(event);
            DispatchWindowEvent(&event);
         }

         break;
      }

      // a frame window in kiosk/fullscreen mode must have its frame
      // controls reattached before it's minimized & detached after it's
      // restored;  if this doesn't happen at the correct times, clicking
      // on the icon won't restore it, the sysmenu will have the wrong
      // items, and/or the minmax button will have the wrong buttons

      case WM_ADJUSTWINDOWPOS:
      {
        if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) {
          HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu");
          if (hwndTemp)
            WinSetParent(hwndTemp, mFrameWnd, TRUE);
        }
        break;
      }
      case WM_ADJUSTFRAMEPOS:
      {
        if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) {
          HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
          hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax");
          if (hwndTemp)
            WinSetParent(hwndTemp, HWND_OBJECT, TRUE);
        }
        break;
      }

      case WM_DESTROY:
         DEBUGFOCUS(frame WM_DESTROY);
         WinSubclassWindow( mFrameWnd, fnwpDefFrame);
         WinSetWindowPtr( mFrameWnd, QWL_USER, 0);
         WinRemoveProperty(mFrameWnd, "hwndTitleBar");
         WinRemoveProperty(mFrameWnd, "hwndSysMenu");
         WinRemoveProperty(mFrameWnd, "hwndMinMax");
         WinRemoveProperty(mFrameWnd, "ulStyle");
         break;
      case WM_INITMENU:
         /* If we are in fullscreen/kiosk mode, disable maximize menu item */
         if (mChromeHidden) {
            if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
              if (SHORT1FROMMP(mp1) == SC_SYSMENU) {
                MENUITEM menuitem;
                WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem));
                mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);
                WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE);
                bDone = TRUE;
              }
            }
         }
         break;
      case WM_SYSCOMMAND:
         /* If we are in fullscreen/kiosk mode, don't honor maximize requests */
         if (mChromeHidden) {
            if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
              if ((SHORT1FROMMP(mp1) == SC_MAXIMIZE))
              {
                bDone = TRUE;
              }
            }
         }
         break;

      // When the frame is activated, set a flag to be acted on after
      // PM has finished changing focus.  When deactivated, dispatch
      // the event immediately because it doesn't affect the focus.
      case WM_ACTIVATE:
         DEBUGFOCUS(WM_ACTIVATE);
         if (mp1) {
            mNeedActivation = PR_TRUE;
         } else {
            mNeedActivation = PR_FALSE;
            DEBUGFOCUS(NS_DEACTIVATE);
            DispatchFocus(NS_DEACTIVATE);
            // Prevent the frame from automatically focusing any window
            // when it's reactivated.  Let moz set the focus to avoid
            // having non-widget children of plugins focused in error.
            WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0);
         }
         break;
   }

   if( !bDone)
      mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2);

   return mresult;
}
void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
                                     EDA_ITEM* aItem )
{
    if( aHotKey == 0 )
        return;

    bool           blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
    BOARD_ITEM*    item     = GetCurItem();
    bool           ItemFree = (item == 0) || (item->GetFlags() == 0);
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    /* Convert lower to upper case (the usual toupper function has problem with non ascii
     * codes like function keys */
    if( (aHotKey >= 'a') && (aHotKey <= 'z') )
        aHotKey += 'A' - 'a';

    EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotKey, common_Hotkey_List );

    if( HK_Descr == NULL )
        HK_Descr = GetDescriptorFromHotkey( aHotKey, module_edit_Hotkey_List );

    if( HK_Descr == NULL )
        return;

    switch( HK_Descr->m_Idcommand )
    {
    default:
    case HK_NOT_FOUND:
        return;
        break;

    case HK_HELP:                   // Display Current hotkey list
        DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr );
        break;

    case HK_RESET_LOCAL_COORD:      // set local (relative) coordinate origin
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        break;

    case HK_SET_GRID_ORIGIN:
        SetGridOrigin( GetCrossHairPosition() );
        m_canvas->Refresh();
        break;

    case HK_RESET_GRID_ORIGIN:
        SetGridOrigin( wxPoint(0,0) );
        m_canvas->Refresh();
        break;

    case HK_SWITCH_UNITS:
        cmd.SetId( (g_UserUnit == INCHES) ?
                    ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_ZOOM_IN:
        cmd.SetId( ID_POPUP_ZOOM_IN );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_ZOOM_OUT:
        cmd.SetId( ID_POPUP_ZOOM_OUT );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_ZOOM_REDRAW:
        cmd.SetId( ID_ZOOM_REDRAW );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_ZOOM_CENTER:
        cmd.SetId( ID_POPUP_ZOOM_CENTER );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_UNDO:
    case HK_REDO:
        if( ItemFree && !blockActive )
        {
            wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
            wxPostEvent( this, event );
        }
        break;

    case HK_ZOOM_AUTO:
        cmd.SetId( ID_ZOOM_PAGE );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case HK_EDIT_ITEM:
        OnHotkeyEditItem( HK_EDIT_ITEM );
        break;

    case HK_DELETE:
        OnHotkeyDeleteItem( HK_DELETE );
        break;

    case HK_MOVE_ITEM:
        OnHotkeyMoveItem( HK_MOVE_ITEM );
        break;

    case HK_ROTATE_ITEM:
        OnHotkeyRotateItem( HK_ROTATE_ITEM );
        break;
    }
}
Exemplo n.º 7
0
void SeekSliderPrivate::_k_currentSourceChanged()
{
    //this releases the mouse and makes the seek slider stop seeking if the current source has changed
    QMouseEvent event(QEvent::MouseButtonRelease, QPoint(), Qt::LeftButton, 0, 0);
    QApplication::sendEvent(&slider, &event);
}
Exemplo n.º 8
0
DumpRenderTree::DumpRenderTree()
    : m_stdin(0)
    , m_enableTextOutput(false)
    , m_standAloneMode(false)
    , m_graphicsBased(false)
    , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP")))
{
    QByteArray viewMode = getenv("QT_DRT_WEBVIEW_MODE");
    if (viewMode == "graphics")
        setGraphicsBased(true);

    DumpRenderTreeSupportQt::initialize();

    // Set running in DRT mode for qwebpage to create testable objects.
    DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true);
    DumpRenderTreeSupportQt::overwritePluginDirectories();
    QWebSettings::enablePersistentStorage(m_persistentStoragePath);

    m_networkAccessManager = new NetworkAccessManager(this);
    // create our primary testing page/view.
    if (isGraphicsBased()) {
        WebViewGraphicsBased* view = new WebViewGraphicsBased(0);
        m_page = new WebPage(view, this);
        view->setPage(m_page);
        m_mainView = view;
    } else {
        QWebView* view = new QWebView(0);
        m_page = new WebPage(view, this);
        view->setPage(m_page);
        m_mainView = view;
    }
    // Use a frame group name for all pages created by DumpRenderTree to allow
    // testing of cross-page frame lookup.
    DumpRenderTreeSupportQt::webPageSetGroupName(m_page, "org.webkit.qt.DumpRenderTree");

    m_mainView->setContextMenuPolicy(Qt::NoContextMenu);
    m_mainView->resize(QSize(TestRunner::maxViewWidth, TestRunner::maxViewHeight));

    // clean up cache by resetting quota.
    qint64 quota = webPage()->settings()->offlineWebApplicationCacheQuota();
    webPage()->settings()->setOfflineWebApplicationCacheQuota(quota);

    // create our controllers. This has to be done before connectFrame,
    // as it exports there to the JavaScript DOM window.
    m_controller = new TestRunner(this);
    connect(m_controller, SIGNAL(showPage()), this, SLOT(showPage()));
    connect(m_controller, SIGNAL(hidePage()), this, SLOT(hidePage()));

    // async geolocation permission set by controller
    connect(m_controller, SIGNAL(geolocationPermissionSet()), this, SLOT(geolocationPermissionSet()));

    connect(m_controller, SIGNAL(done()), this, SLOT(dump()));
    m_eventSender = new EventSender(m_page);
    m_textInputController = new TextInputController(m_page);
    m_gcController = new GCController(m_page);

    // now connect our different signals
    connect(m_page, SIGNAL(frameCreated(QWebFrame *)),
            this, SLOT(connectFrame(QWebFrame *)));
    connectFrame(m_page->mainFrame());

    connect(m_page, SIGNAL(loadFinished(bool)),
            m_controller, SLOT(maybeDump(bool)));
    // We need to connect to loadStarted() because notifyDone should only
    // dump results itself when the last page loaded in the test has finished loading.
    connect(m_page, SIGNAL(loadStarted()),
            m_controller, SLOT(resetLoadFinished()));
    connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
    connect(m_page, SIGNAL(printRequested(QWebFrame*)), this, SLOT(dryRunPrint(QWebFrame*)));

    connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)),
            SLOT(titleChanged(const QString&)));
    connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)),
            this, SLOT(dumpDatabaseQuota(QWebFrame*,QString)));
    connect(m_page, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin *, quint64, quint64)),
            this, SLOT(dumpApplicationCacheQuota(QWebSecurityOrigin *, quint64, quint64)));
    connect(m_page, SIGNAL(statusBarMessage(const QString&)),
            this, SLOT(statusBarMessage(const QString&)));

    QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection);

    DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true);
    DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(webPage(), true);
    QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason);
    QApplication::sendEvent(m_mainView, &event);
}
Exemplo n.º 9
0
void DebugFrontend::EventThreadProc()
{

    unsigned int eventId;

    while (m_eventChannel.ReadUInt32(eventId))
    {

        unsigned int vm;
        m_eventChannel.ReadUInt32(vm);

        wxDebugEvent event(static_cast<EventId>(eventId), vm);

        if (eventId == EventId_LoadScript)
        {

            CriticalSectionLock lock(m_criticalSection);        

            Script* script = new Script;

            m_eventChannel.ReadString(script->name);
            m_eventChannel.ReadString(script->source);

            unsigned int codeState;
            m_eventChannel.ReadUInt32(codeState);

            script->state = static_cast<CodeState>(codeState);

            // If the debuggee does wacky things when it specifies the file name
            // we need to correct for that or it can make trying to access the
            // file bad.
            script->name = MakeValidFileName(script->name);

            unsigned int scriptIndex = m_scripts.size();
            m_scripts.push_back(script);
        
            event.SetScriptIndex(scriptIndex);

        }
        else if (eventId == EventId_Break)
        {

            m_state = State_Broken;
            
            unsigned int numStackFrames; 
            m_eventChannel.ReadUInt32(numStackFrames);
            m_stackFrames.resize(numStackFrames);

            for (unsigned int i = 0; i < numStackFrames; ++i)
            {

                m_eventChannel.ReadUInt32(m_stackFrames[i].scriptIndex);

                if (m_stackFrames[i].scriptIndex != -1)
                {
                    assert(m_stackFrames[i].scriptIndex < m_scripts.size());
                }

                m_eventChannel.ReadUInt32(m_stackFrames[i].line);
                m_eventChannel.ReadString(m_stackFrames[i].function);
            
            }

            if (numStackFrames > 0)
            {
                event.SetScriptIndex(m_stackFrames[0].scriptIndex);
                event.SetLine(m_stackFrames[0].line);
            }

        }
        else if (eventId == EventId_SetBreakpoint)
        {
            
            unsigned int scriptIndex;
            m_eventChannel.ReadUInt32(scriptIndex);
            
            unsigned int line;
            m_eventChannel.ReadUInt32(line);

            unsigned int set;
            m_eventChannel.ReadUInt32(set);

            event.SetScriptIndex(scriptIndex);
            event.SetLine(line);
            event.SetEnabled(set != 0);

        }
        else if (eventId == EventId_Exception)
        {
            
            std::string message;
            m_eventChannel.ReadString(message);
            
            event.SetMessage(message);
        
        }
        else if (eventId == EventId_LoadError)
        {

            std::string message;
            m_eventChannel.ReadString(message);
            
            event.SetMessage(message);
        
        }
        else if (eventId == EventId_Message)
        {

            unsigned int type;
            m_eventChannel.ReadUInt32(type);

            std::string message;
            m_eventChannel.ReadString(message);
            
            event.SetMessage(message);
            event.SetMessageType(static_cast<MessageType>(type));
        
        }        
        else if (eventId == EventId_SessionEnd)
        {
            // Backends shouldn't send this.
            assert(0);
            continue;
        }
        else if (eventId == EventId_NameVM)
        {
            
            std::string message;
            m_eventChannel.ReadString(message);
            
            event.SetMessage(message);            

        }

        // Dispatch the message to the UI.
        if (m_eventHandler != NULL)
        {
            m_eventHandler->AddPendingEvent(event);
        }

    }

    // Send the exit event message to the UI.
    if (m_eventHandler != NULL)
    {
        wxDebugEvent event(static_cast<EventId>(EventId_SessionEnd), 0);
        m_eventHandler->AddPendingEvent(event);        
    }

}
Exemplo n.º 10
0
void QGLView::sendLeaveEvent(QObject *object)
{
    QEvent event(QEvent::Leave);
    QCoreApplication::sendEvent(object, &event);
}
Exemplo n.º 11
0
    void ProcessNativeEvent(const inotify_event& inevt)
    {
        wxLogTrace(wxTRACE_FSWATCHER, InotifyEventToString(inevt));

        // after removing inotify watch we get IN_IGNORED for it, but the watch
        // will be already removed from our list at that time
        if (inevt.mask & IN_IGNORED)
        {
            return;
        }

        // get watch entry for this event
        wxFSWatchEntryDescriptors::iterator it = m_watchMap.find(inevt.wd);
        wxCHECK_RET(it != m_watchMap.end(),
                             "Watch descriptor not present in the watch map!");

        wxFSWatchEntry& watch = *(it->second);
        int nativeFlags = inevt.mask;
        int flags = Native2WatcherFlags(nativeFlags);

        // check out for error/warning condition
        if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
        {
            wxString errMsg = GetErrorDescription(Watcher2NativeFlags(flags));
            wxFileSystemWatcherEvent event(flags, errMsg);
            SendEvent(event);
        }
        // filter out ignored events and those not asked for.
        // we never filter out warnings or exceptions
        else if ((flags == 0) || !(flags & watch.GetFlags()))
        {
            return;
        }
        // renames
        else if (nativeFlags & IN_MOVE)
        {
            wxInotifyCookies::iterator it = m_cookies.find(inevt.cookie);
            if ( it == m_cookies.end() )
            {
                int size = sizeof(inevt) + inevt.len;
                inotify_event* e = (inotify_event*) operator new (size);
                memcpy(e, &inevt, size);

                wxInotifyCookies::value_type val(e->cookie, e);
                m_cookies.insert(val);
            }
            else
            {
                inotify_event& oldinevt = *(it->second);

                wxFileSystemWatcherEvent event(flags);
                if ( inevt.mask & IN_MOVED_FROM )
                {
                    event.SetPath(GetEventPath(watch, inevt));
                    event.SetNewPath(GetEventPath(watch, oldinevt));
                }
                else
                {
                    event.SetPath(GetEventPath(watch, oldinevt));
                    event.SetNewPath(GetEventPath(watch, inevt));
                }
                SendEvent(event);

                m_cookies.erase(it);
                delete &oldinevt;
            }
        }
        // every other kind of event
        else
        {
            wxFileName path = GetEventPath(watch, inevt);
            wxFileSystemWatcherEvent event(flags, path, path);
            SendEvent(event);
        }
    }
Exemplo n.º 12
0
void QGLView::sendEnterEvent(QObject *object)
{
    QEvent event(QEvent::Enter);
    QCoreApplication::sendEvent(object, &event);
}
Exemplo n.º 13
0
void EventDispatcherBase<TDerived>::selectTransitions(bool onlyEventless,
                                                      event_type event)
{
    transition_type** outputIter = &m_enabledTransitions;

    // Loop over the states in post-order. This way, the descendent states are
    // checked before their ancestors.
    for (auto stateIter = derived().post_order_begin();
         stateIter != derived().post_order_end(); ++stateIter)
    {
        if (!(stateIter->m_flags & state_type::Active))
            continue;

        // If a transition in a descendant of a parallel state has already
        // been selected, the parallel state itself and all its ancestors
        // can be skipped.
        if (stateIter->m_flags & state_type::SkipTransitionSelection)
            continue;

        bool foundTransition = false;
        for (auto transitionIter = stateIter->beginTransitions();
             transitionIter != stateIter->endTransitions(); ++transitionIter)
        {
            // Skip transitions with events in microstepping mode.
            if (onlyEventless && !transitionIter->eventless())
                continue;

            // If a transition has an event, the event must match.
            if (!transitionIter->eventless()
                && transitionIter->event() != event)
            {
                continue;
            }

            // If the transition has a guard, it must evaluate to true in order
            // to select the transition. A transition without guard is selected
            // unconditionally.
            if (!transitionIter->guard() || transitionIter->guard()(event))
            {
                *outputIter = &*transitionIter;
                outputIter = &transitionIter->m_nextInEnabledSet;
                foundTransition = true;

                // When the transition selection shall stop after the first
                // match, we must break out of the loop now. Otherwise, the
                // remaining transitions of this state have to be scanned.
                if (options::transition_selection_stops_after_first_match)
                    break;
            }
        }

        if (foundTransition)
        {
            // As we have found a transition in this state, there is no need to
            // check the ancestors for a matching transition.
            bool hasParallelAncestor = false;
            state_type* ancestor = stateIter->parent();
            while (ancestor)
            {
                ancestor->m_flags |= state_type::SkipTransitionSelection;
                hasParallelAncestor |= ancestor->isParallel();
                ancestor = ancestor->parent();
            }

            // If none of the ancestors is a parallel state, there is no
            // need to continue scanning the other states. This is because
            // the remaining active states are all ancestors of the current
            // state and no transition in an ancestor is more specific than
            // the one which has been selected right now.
            if (!hasParallelAncestor)
                return;
        }
    }
}
Exemplo n.º 14
0
Error processEvent(FileEventContext* pContext,
                   struct inotify_event* pEvent,
                   std::vector<FileChangeEvent>* pFileChanges)
{
   // determine event type
   FileChangeEvent::Type eventType = FileChangeEvent::None;
   if (pEvent->mask & IN_CREATE)
      eventType = FileChangeEvent::FileAdded;
   else if (pEvent->mask & IN_DELETE)
      eventType = FileChangeEvent::FileRemoved;
   else if (pEvent->mask & IN_MODIFY)
      eventType = FileChangeEvent::FileModified;
   else if (pEvent->mask & IN_MOVED_TO)
      eventType = FileChangeEvent::FileAdded;
   else if (pEvent->mask & IN_MOVED_FROM)
      eventType = FileChangeEvent::FileRemoved;

   // return event if we got a valid event type and the event applies to a
   // child of the monitored directory (len == 0 occurs for root element)
   if ((eventType != FileChangeEvent::None) && (pEvent->len > 0))
   {
      // find the FileInfo for this wd (ignore if we can't find one)
      Watch watch = pContext->watches.find(pEvent->wd);
      if (watch.empty())
         return Success();

      // get an iterator to the parent dir
      FileInfo parentDir(watch.path, true);
      tcl::unique_tree<FileInfo>::tree_type* pParentNode
                           = impl::findNode(&pContext->fileTree, parentDir);

      // if we can't find a parent then return (this directory may have
      // been excluded from scanning due to a filter)
      if (pParentNode == NULL)
         return Success();

      // get file info
      FilePath filePath = FilePath(pParentNode->get()->absolutePath()).complete(
                                                                 pEvent->name);


      // if the file exists then collect as many extended attributes
      // as necessary -- otherwise just record path and dir status
      FileInfo fileInfo;
      if (filePath.exists())
      {
         fileInfo = FileInfo(filePath, filePath.isSymlink());
      }
      else
      {
         fileInfo = FileInfo(filePath.absolutePath(), pEvent->mask & IN_ISDIR);
      }

      // if this doesn't meet the filter then ignore
      if (pContext->filter && !pContext->filter(fileInfo))
         return Success();

      // handle the various types of actions
      switch(eventType)
      {
         case FileChangeEvent::FileRemoved:
         {
            // generate events
            FileChangeEvent event(FileChangeEvent::FileRemoved, fileInfo);
            std::vector<FileChangeEvent> removeEvents;
            impl::processFileRemoved(pParentNode,
                                     event,
                                     pContext->recursive,
                                     &pContext->fileTree,
                                     &removeEvents);

            // for each directory remove event remove any watches we have for it
            BOOST_FOREACH(const FileChangeEvent& event, removeEvents)
            {
               if (event.fileInfo().isDirectory())
               {
                  Watch watch = pContext->watches.find(
                                             event.fileInfo().absolutePath());
                  if (!watch.empty())
                  {
                     removeWatch(pContext->fd, watch);
                     pContext->watches.erase(watch);
                  }
               }
            }

            // copy to the target events
            std::copy(removeEvents.begin(),
                      removeEvents.end(),
                      std::back_inserter(*pFileChanges));

            break;
         }
         case FileChangeEvent::FileAdded:
         {
            FileChangeEvent event(FileChangeEvent::FileAdded, fileInfo);
            Error error = impl::processFileAdded(pParentNode,
                                                 event,
                                                 pContext->recursive,
                                                 pContext->filter,
                                                 addWatchFunction(pContext),
                                                 &pContext->fileTree,
                                                 pFileChanges);
            // log the error if it wasn't no such file/dir (this can happen
            // in the normal course of business if a file is deleted between
            // the time the change is detected and we try to inspect it)
            if (error &&
               (error.code() != boost::system::errc::no_such_file_or_directory))
            {
               LOG_ERROR(error);
            }
            break;
         }
         case FileChangeEvent::FileModified:
         {
            FileChangeEvent event(FileChangeEvent::FileModified, fileInfo);
            impl::processFileModified(pParentNode,
                                      event,
                                      &pContext->fileTree,
                                      pFileChanges);
            break;
         }
         case FileChangeEvent::None:
            break;
      }
   }
bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
                               EDA_ITEM* aItem )
{
    if( aHotkeyCode == 0 )
        return false;

    bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetFlags();
    MODULE* module = NULL;
    int evt_type = 0;       //Used to post a wxCommandEvent on demand
    PCB_SCREEN* screen = GetScreen();

    /* Convert lower to upper case
     * (the usual toupper function has problem with non ascii codes like function keys
     */
    if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
        aHotkeyCode += 'A' - 'a';

    EDA_HOTKEY* HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, common_Hotkey_List );

    if( HK_Descr == NULL )
        HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, board_edit_Hotkey_List );

    if( HK_Descr == NULL )
        return false;

    int hk_id = HK_Descr->m_Idcommand;

    if( (m_RecordingMacros != -1) &&
        !( hk_id > HK_MACRO_ID_BEGIN && hk_id < HK_MACRO_ID_END) )
    {
        MACROS_RECORD macros_record;
        macros_record.m_HotkeyCode = aHotkeyCode;
        macros_record.m_Idcommand = HK_Descr->m_Idcommand;
        macros_record.m_Position  = GetNearestGridPosition( aPosition ) -
                                    m_Macros[m_RecordingMacros].m_StartPosition;
        m_Macros[m_RecordingMacros].m_Record.push_back( macros_record );
        wxString msg;
        msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros );
        SetStatusText( msg );
    }

    // Create a wxCommandEvent that will be posted in some hot keys functions
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    LAYER_NUM  ll;

    switch( hk_id )
    {
    default:
    case HK_NOT_FOUND:
        return false;

    case HK_LEFT_CLICK:
        OnLeftClick( aDC, aPosition );
        break;

    case HK_LEFT_DCLICK:    // Simulate a double left click: generate 2 events
        OnLeftClick( aDC, aPosition );
        OnLeftDClick( aDC, aPosition );
        break;

    case HK_RECORD_MACROS_0:
    case HK_RECORD_MACROS_1:
    case HK_RECORD_MACROS_2:
    case HK_RECORD_MACROS_3:
    case HK_RECORD_MACROS_4:
    case HK_RECORD_MACROS_5:
    case HK_RECORD_MACROS_6:
    case HK_RECORD_MACROS_7:
    case HK_RECORD_MACROS_8:
    case HK_RECORD_MACROS_9:
        RecordMacros( aDC, hk_id - HK_RECORD_MACROS_0 );
        break;

    case HK_CALL_MACROS_0:
    case HK_CALL_MACROS_1:
    case HK_CALL_MACROS_2:
    case HK_CALL_MACROS_3:
    case HK_CALL_MACROS_4:
    case HK_CALL_MACROS_5:
    case HK_CALL_MACROS_6:
    case HK_CALL_MACROS_7:
    case HK_CALL_MACROS_8:
    case HK_CALL_MACROS_9:
        CallMacros( aDC, GetCrossHairPosition( false ), hk_id - HK_CALL_MACROS_0 );
        break;

    case HK_SWITCH_TRACK_WIDTH_TO_NEXT:
        if( GetCanvas()->IsMouseCaptured() )
            GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );

        if( GetDesignSettings().GetTrackWidthIndex() < GetDesignSettings().m_TrackWidthList.size() - 1 )
            GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() + 1 );
        else
            GetDesignSettings().SetTrackWidthIndex( 0 );

        if( GetCanvas()->IsMouseCaptured() )
            GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );

        break;

    case HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS:
        if( GetCanvas()->IsMouseCaptured() )
            GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );

        if( GetDesignSettings().GetTrackWidthIndex() <= 0 )
            GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().m_TrackWidthList.size() -1 );
        else
            GetDesignSettings().SetTrackWidthIndex( GetDesignSettings().GetTrackWidthIndex() - 1 );

        if( GetCanvas()->IsMouseCaptured() )
            GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );

        break;

    case HK_SWITCH_GRID_TO_FASTGRID1:
        SetFastGrid1();
        break;

    case HK_SWITCH_GRID_TO_FASTGRID2:
        SetFastGrid2();
        break;

    case HK_SWITCH_GRID_TO_NEXT:
        SetNextGrid();
        break;

    case HK_SWITCH_GRID_TO_PREVIOUS:
        SetPrevGrid();
        break;

    case HK_SWITCH_LAYER_TO_PREVIOUS:
        ll = GetActiveLayer();

        if( !IsCopperLayer( ll ) )
            break;

        if( ll == F_Cu )
            ll = B_Cu;
        else if( ll == B_Cu )
            ll = ToLAYER_ID( GetBoard()->GetCopperLayerCount() - 2 );
        else
            ll = ll - 1;

        SwitchLayer( aDC, ToLAYER_ID( ll ) );
        break;

    case HK_SWITCH_LAYER_TO_NEXT:
        ll = GetActiveLayer();

        if( !IsCopperLayer( ll ) )
            break;

        if( ll == B_Cu )
            ll = F_Cu;
        else if( ++ll >= GetBoard()->GetCopperLayerCount() - 1 )
            ll = B_Cu;

        SwitchLayer( aDC, ToLAYER_ID( ll ) );
        break;

    case HK_SWITCH_LAYER_TO_COMPONENT:
        SwitchLayer( aDC, F_Cu );
        break;

    case HK_SWITCH_LAYER_TO_COPPER:
        SwitchLayer( aDC, B_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER1:
        SwitchLayer( aDC, In1_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER2:
        SwitchLayer( aDC, In2_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER3:
        SwitchLayer( aDC, In3_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER4:
        SwitchLayer( aDC, In4_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER5:
        SwitchLayer( aDC, In5_Cu );
        break;

    case HK_SWITCH_LAYER_TO_INNER6:
        SwitchLayer( aDC, In6_Cu );
        break;

    case HK_HELP: // Display Current hotkey list
        DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr );
        break;

    case HK_ZOOM_IN:
        evt_type = ID_POPUP_ZOOM_IN;
        break;

    case HK_ZOOM_OUT:
        evt_type = ID_POPUP_ZOOM_OUT;
        break;

    case HK_ZOOM_REDRAW:
        evt_type = ID_ZOOM_REDRAW;
        break;

    case HK_ZOOM_AUTO:
        evt_type = ID_ZOOM_PAGE;
        break;

    case HK_ZOOM_CENTER:
        evt_type = ID_POPUP_ZOOM_CENTER;
        break;

    case HK_ADD_MODULE:
        evt_type = ID_PCB_MODULE_BUTT;
        break;

    case HK_UNDO:
    case HK_REDO:
        if( !itemCurrentlyEdited )
        {
            wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
            wxPostEvent( this, event );
        }

        break;

    case HK_RESET_LOCAL_COORD:  // Set the relative coord
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        break;

    case HK_SET_GRID_ORIGIN:
        SetGridOrigin( GetCrossHairPosition() );
        OnModify();     // because grid origin is saved in board, show as modified
        m_canvas->Refresh();
        break;

    case HK_RESET_GRID_ORIGIN:
        SetGridOrigin( wxPoint( 0,0 ) );
        OnModify();     // because grid origin is saved in board, show as modified
        m_canvas->Refresh();
        break;

    case HK_SWITCH_UNITS:
        evt_type = (g_UserUnit == INCHES) ?
                    ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH;
        break;

    case HK_SWITCH_TRACK_DISPLAY_MODE:
        DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill;
        m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
        m_canvas->Refresh();
        break;

    case HK_DELETE:
        OnHotkeyDeleteItem( aDC );
        break;

    case HK_BACK_SPACE:
        if( IsCopperLayer( GetActiveLayer() ) )
        {
            if( !itemCurrentlyEdited )
            {
                // no track is currently being edited - select a segment and remove it.
                // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay()
                // so it can restrict its search to specific item types.
                BOARD_ITEM * item = PcbGeneralLocateAndDisplay();

                // don't let backspace delete modules!!
                if( item && item->IsTrack() )
                {
                    Delete_Segment( aDC, (TRACK*) item );
                    SetCurItem( NULL );
                }

                OnModify();
            }
            else if( GetCurItem()->IsTrack() )
            {
                // then an element is being edited - remove the last segment.
                // simple lines for debugger:
                TRACK* track = (TRACK*) GetCurItem();
                track = Delete_Segment( aDC, track );
                SetCurItem( track );
                OnModify();
            }
        }

        break;

    case HK_GET_AND_MOVE_FOOTPRINT:
        if( !itemCurrentlyEdited )
            evt_type = ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST;

        break;

    case HK_FIND_ITEM:
        if( !itemCurrentlyEdited )
            evt_type = ID_FIND_ITEMS;

        break;

    case HK_LOAD_BOARD:
        if( !itemCurrentlyEdited )
            evt_type = ID_LOAD_FILE ;

        break;

    case HK_SAVE_BOARD:
        if( !itemCurrentlyEdited )
            evt_type = ID_SAVE_BOARD;

        break;

    case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
        if( GetToolId() != ID_TRACK_BUTT )
            return true;

        if( !itemCurrentlyEdited )                         // no track in progress: nothing to do
            break;

        if( GetCurItem()->Type() != PCB_TRACE_T )           // Should not occur
            return true;

        if( !GetCurItem()->IsNew() )
            return true;

        // place micro via and switch layer
        if( IsMicroViaAcceptable() )
            evt_type = ID_POPUP_PCB_PLACE_MICROVIA;

        break;

    case HK_ADD_BLIND_BURIED_VIA:
    case HK_ADD_THROUGH_VIA: // Switch to alternate layer and Place a via if a track is in progress
        if( GetBoard()->GetDesignSettings().m_BlindBuriedViaAllowed &&
            hk_id == HK_ADD_BLIND_BURIED_VIA  )
            GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_BLIND_BURIED;
        else
            GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_THROUGH;

        if( !itemCurrentlyEdited ) // no track in progress: switch layer only
        {
            Other_Layer_Route( NULL, aDC );
            if( DisplayOpt.ContrastModeDisplay )
                m_canvas->Refresh();
            break;
        }

        if( GetToolId() != ID_TRACK_BUTT )
            return true;

        if( GetCurItem()->Type() != PCB_TRACE_T )
            return true;

        if( !GetCurItem()->IsNew() )
            return true;

        evt_type = hk_id == HK_ADD_BLIND_BURIED_VIA ?
            ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA : ID_POPUP_PCB_PLACE_THROUGH_VIA;
        break;

    case HK_SEL_LAYER_AND_ADD_THROUGH_VIA:
    case HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA:
        if( GetCurItem() == NULL || !GetCurItem()->IsNew() ||
            GetCurItem()->Type() != PCB_TRACE_T )
            break;

        evt_type = hk_id == HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA ?
            ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA :
            ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA;
        break;

    case HK_SWITCH_TRACK_POSTURE:
        /* change the position of initial segment when creating new tracks
         * switch from _/  to -\ .
         */
        evt_type = ID_POPUP_PCB_SWITCH_TRACK_POSTURE ;
        break;

    case HK_DRAG_TRACK_KEEP_SLOPE:
        OnHotkeyMoveItem( HK_DRAG_TRACK_KEEP_SLOPE );
        break;

    case HK_PLACE_ITEM:
        OnHotkeyPlaceItem( aDC );
        break;

    case HK_ADD_NEW_TRACK: // Start new track, if possible
        OnHotkeyBeginRoute( aDC );
        break;

    case HK_EDIT_ITEM:      // Edit board item
        OnHotkeyEditItem( HK_EDIT_ITEM );
        break;

    // Footprint edition:
    case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
        // get any module, locked or not locked and toggle its locked status
        if( !itemCurrentlyEdited )
        {
            wxPoint pos = RefPos( true );
            module = GetBoard()->GetFootprint( pos, screen->m_Active_Layer, true );
        }
        else if( GetCurItem()->Type() == PCB_MODULE_T )
        {
            module = (MODULE*) GetCurItem();
        }

        if( module )
        {
            SetCurItem( module );
            module->SetLocked( !module->IsLocked() );
            OnModify();
            SetMsgPanel( module );
        }
        break;

    case HK_DRAG_ITEM:    // Start drag module or track segment
        OnHotkeyMoveItem( HK_DRAG_ITEM );
        break;

    case HK_MOVE_ITEM:                  // Start move item
        OnHotkeyMoveItem( HK_MOVE_ITEM );
        break;

    case HK_COPY_ITEM:
        evt_type = OnHotkeyCopyItem();
        break;

    case HK_ROTATE_ITEM:        // Rotation
        OnHotkeyRotateItem( HK_ROTATE_ITEM );
        break;

    case HK_FLIP_ITEM:
        OnHotkeyRotateItem( HK_FLIP_ITEM );
        break;

    case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
        DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
        m_canvas->Refresh();
        break;

    case HK_CANVAS_CAIRO:
        evt_type = ID_MENU_CANVAS_CAIRO;
        break;

    case HK_CANVAS_OPENGL:
        evt_type = ID_MENU_CANVAS_OPENGL;
        break;

    case HK_CANVAS_DEFAULT:
        evt_type = ID_MENU_CANVAS_DEFAULT;
        break;
    }

    if( evt_type != 0 )
    {
        wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
        evt.SetEventObject( this );
        evt.SetId( evt_type );
        GetEventHandler()->ProcessEvent( evt );
    }

    return true;
}
Exemplo n.º 16
0
bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate),
                                        WXHWND hwndAct,
                                        WXHWND hwndDeact)
{
    wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();

    HMENU menuToSet = 0;

    bool activated;

    if ( m_hWnd == hwndAct )
    {
        activated = true;
        parent->m_currentChild = this;

        HMENU child_menu = (HMENU)GetWinMenu();
        if ( child_menu )
        {
            parent->m_parentFrameActive = false;

            menuToSet = child_menu;
        }
    }
    else if ( m_hWnd == hwndDeact )
    {
        wxASSERT_MSG( parent->m_currentChild == this,
                      wxT("can't deactivate MDI child which wasn't active!") );

        activated = false;
        parent->m_currentChild = NULL;

        HMENU parent_menu = (HMENU)parent->GetWinMenu();

        // activate the the parent menu only when there is no other child
        // that has been activated
        if ( parent_menu && !hwndAct )
        {
            parent->m_parentFrameActive = true;

            menuToSet = parent_menu;
        }
    }
    else
    {
        // we have nothing to do with it
        return false;
    }

    if ( menuToSet )
    {
        MDISetMenu(parent->GetClientWindow(),
                   menuToSet, GetMDIWindowMenu(parent));
    }

    wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId);
    event.SetEventObject( this );

    ResetWindowStyle((void *)NULL);

    return GetEventHandler()->ProcessEvent(event);
}
/**
 * @todo: instead of double wrapping of events into signals maybe it
 * make sense to use passive listeners, and peek up events in main thread.
 */
STDMETHODIMP UIMainEventListener::HandleEvent(VBoxEventType_T /* type */, IEvent *pEvent)
{
    CEvent event(pEvent);
    // printf("Event received: %d\n", event.GetType());
    switch(event.GetType())
    {
        /*
         * All VirtualBox Events
         */
        case KVBoxEventType_OnMachineStateChanged:
        {
            CMachineStateChangedEvent es(pEvent);
            emit sigMachineStateChange(es.GetMachineId(), es.GetState());
            break;
        }
        case KVBoxEventType_OnMachineDataChanged:
        {
            CMachineDataChangedEvent es(pEvent);
            emit sigMachineDataChange(es.GetMachineId());
            break;
        }
        case KVBoxEventType_OnExtraDataCanChange:
        {
            CExtraDataCanChangeEvent es(pEvent);
            /* Has to be done in place to give an answer */
            bool fVeto = false;
            QString strReason;
            emit sigExtraDataCanChange(es.GetMachineId(), es.GetKey(), es.GetValue(), fVeto, strReason);
            if (fVeto)
                es.AddVeto(strReason);
            break;
        }
        case KVBoxEventType_OnExtraDataChanged:
        {
            CExtraDataChangedEvent es(pEvent);
            emit sigExtraDataChange(es.GetMachineId(), es.GetKey(), es.GetValue());
            break;
        }
        /* Not used:
        case KVBoxEventType_OnMediumRegistered:
         */
        case KVBoxEventType_OnMachineRegistered:
        {
            CMachineRegisteredEvent es(pEvent);
            emit sigMachineRegistered(es.GetMachineId(), es.GetRegistered());
            break;
        }
        case KVBoxEventType_OnSessionStateChanged:
        {
            CSessionStateChangedEvent es(pEvent);
            emit sigSessionStateChange(es.GetMachineId(), es.GetState());
            break;
        }
        case KVBoxEventType_OnSnapshotTaken:
        {
            CSnapshotTakenEvent es(pEvent);
            emit sigSnapshotChange(es.GetMachineId(), es.GetSnapshotId());
            break;
        }
        case KVBoxEventType_OnSnapshotDeleted:
        {
            CSnapshotDeletedEvent es(pEvent);
            emit sigSnapshotChange(es.GetMachineId(), es.GetSnapshotId());
            break;
        }
        case KVBoxEventType_OnSnapshotChanged:
        {
            CSnapshotChangedEvent es(pEvent);
            emit sigSnapshotChange(es.GetMachineId(), es.GetSnapshotId());
            break;
        }
        /* Not used:
        case KVBoxEventType_OnGuestPropertyChange:
         */
        /*
         * All Console Events
         */
        case KVBoxEventType_OnMousePointerShapeChanged:
        {
            CMousePointerShapeChangedEvent es(pEvent);
            emit sigMousePointerShapeChange(es.GetVisible(), es.GetAlpha(), QPoint(es.GetXhot(), es.GetYhot()), QSize(es.GetWidth(), es.GetHeight()), es.GetShape());
            break;
        }
        case KVBoxEventType_OnMouseCapabilityChanged:
        {
            CMouseCapabilityChangedEvent es(pEvent);
            emit sigMouseCapabilityChange(es.GetSupportsAbsolute(), es.GetSupportsRelative(), es.GetSupportsMultiTouch(), es.GetNeedsHostCursor());
            break;
        }
        case KVBoxEventType_OnKeyboardLedsChanged:
        {
            CKeyboardLedsChangedEvent es(pEvent);
            emit sigKeyboardLedsChangeEvent(es.GetNumLock(), es.GetCapsLock(), es.GetScrollLock());
            break;
        }
        case KVBoxEventType_OnStateChanged:
        {
            CStateChangedEvent es(pEvent);
            emit sigStateChange(es.GetState());
            break;
        }
        case KVBoxEventType_OnAdditionsStateChanged:
        {
            emit sigAdditionsChange();
            break;
        }
        case KVBoxEventType_OnNetworkAdapterChanged:
        {
            CNetworkAdapterChangedEvent es(pEvent);
            emit sigNetworkAdapterChange(es.GetNetworkAdapter());
            break;
        }
        /* Not used *
        case KVBoxEventType_OnSerialPortChanged:
        case KVBoxEventType_OnParallelPortChanged:
        case KVBoxEventType_OnStorageControllerChanged:
         */
        case KVBoxEventType_OnMediumChanged:
        {
            CMediumChangedEvent es(pEvent);
            emit sigMediumChange(es.GetMediumAttachment());
            break;
        }
        /* Not used *
        case KVBoxEventType_OnCPUChange:
         */
        case KVBoxEventType_OnVRDEServerChanged:
        case KVBoxEventType_OnVRDEServerInfoChanged:
        {
            emit sigVRDEChange();
            break;
        }
        case KVBoxEventType_OnVideoCaptureChanged:
        {
            emit sigVideoCaptureChange();
            break;
        }
        case KVBoxEventType_OnUSBControllerChanged:
        {
            emit sigUSBControllerChange();
            break;
        }
        case KVBoxEventType_OnUSBDeviceStateChanged:
        {
            CUSBDeviceStateChangedEvent es(pEvent);
            emit sigUSBDeviceStateChange(es.GetDevice(), es.GetAttached(), es.GetError());
            break;
        }
        case KVBoxEventType_OnSharedFolderChanged:
        {
            emit sigSharedFolderChange();
            break;
        }
        case KVBoxEventType_OnRuntimeError:
        {
            CRuntimeErrorEvent es(pEvent);
            emit sigRuntimeError(es.GetFatal(), es.GetId(), es.GetMessage());
            break;
        }
        case KVBoxEventType_OnCanShowWindow:
        {
            CCanShowWindowEvent es(pEvent);
            /* Has to be done in place to give an answer */
            bool fVeto = false;
            QString strReason;
            emit sigCanShowWindow(fVeto, strReason);
            if (fVeto)
                es.AddVeto(strReason);
            break;
        }
        case KVBoxEventType_OnShowWindow:
        {
            CShowWindowEvent es(pEvent);
            /* Has to be done in place to give an answer */
            LONG64 winId;
            emit sigShowWindow(winId);
            es.SetWinId(winId);
            break;
        }
        case KVBoxEventType_OnCPUExecutionCapChanged:
        {
            emit sigCPUExecutionCapChange();
            break;
        }
        case KVBoxEventType_OnGuestMonitorChanged:
        {
            CGuestMonitorChangedEvent es(pEvent);
            emit sigGuestMonitorChange(es.GetChangeType(), es.GetScreenId(),
                                       QRect(es.GetOriginX(), es.GetOriginY(), es.GetWidth(), es.GetHeight()));
            break;
        }
        default: break;
    }
    return S_OK;
}
Exemplo n.º 18
0
// "map" from m_menu
static void menu_map(GtkWidget*, wxMenu* menu)
{
    wxMenuEvent event(wxEVT_MENU_OPEN, menu->m_popupShown ? -1 : 0, menu);
    DoCommonMenuCallbackCode(menu, event);
}
Exemplo n.º 19
0
PhysicalParameter::PhysicalParameter(BaseLib::Obj* baseLib, xml_node<>* node) : PhysicalParameter()
{
	try
	{
		for(xml_attribute<>* attr = node->first_attribute(); attr; attr = attr->next_attribute())
		{
			std::string attributeName(attr->name());
			std::string attributeValue(attr->value());
			if(attributeName == "type") {
				if(attributeValue == "integer") type = Type::Enum::typeInteger;
				else if(attributeValue == "boolean") type = Type::Enum::typeBoolean;
				else if(attributeValue == "string") type = Type::Enum::typeString;
				else baseLib->out.printWarning("Warning: Unknown physical type: " + attributeValue);
			}
			else if(attributeName == "interface")
			{
				if(attributeValue == "command") interface = Interface::Enum::command;
				else if(attributeValue == "central_command") interface = Interface::Enum::centralCommand;
				else if(attributeValue == "internal") interface = Interface::Enum::internal;
				else if(attributeValue == "config") interface = Interface::Enum::config;
				else if(attributeValue == "config_string") interface = Interface::Enum::configString;
				else if(attributeValue == "store") interface = Interface::Enum::store;
				else if(attributeValue == "eeprom") interface = Interface::Enum::eeprom;
				else baseLib->out.printWarning("Warning: Unknown interface for \"physical\": " + attributeValue);
			}
			else if(attributeName == "endian")
			{
				if(attributeValue == "little") endian = Endian::Enum::little;
				else if(attributeValue == "big") endian = Endian::Enum::big; //default
				else baseLib->out.printWarning("Warning: Unknown endianess for \"physical\": " + attributeValue);
			}
			else if(attributeName == "value_id") valueID = attributeValue;
			else if(attributeName == "no_init") {}
			else if(attributeName == "list") list = Math::getNumber(attributeValue);
			else if(attributeName == "index")
			{
				std::pair<std::string, std::string> splitValue = baseLib->hf.split(attributeValue, '.');
				index = 0;
				if(!splitValue.second.empty())
				{
					index += Math::getNumber(splitValue.second);
					index /= 10;
				}
				index += Math::getNumber(splitValue.first);
			}
			else if(attributeName == "size")
			{
				std::pair<std::string, std::string> splitValue = baseLib->hf.split(attributeValue, '.');
				size = 0;
				if(!splitValue.second.empty())
				{
					size += Math::getNumber(splitValue.second);
					size /= 10;
				}
				size += Math::getNumber(splitValue.first);
				sizeDefined = true;
			}
			//else if(attributeName == "read_size") readSize = Math::getNumber(attributeValue);
			else if(attributeName == "counter") {}
			else if(attributeName == "volatile") {}
			else if(attributeName == "id") { id = attributeValue; }
			else if(attributeName == "save_on_change") {} //not necessary, all values are saved on change
			else if(attributeName == "mask") mask = Math::getNumber(attributeValue);
			else if(attributeName == "read_size") {} //not necessary, because size can be determined through index
			else baseLib->out.printWarning("Warning: Unknown attribute for \"physical\": " + attributeName);
		}
		if(mask != -1 && fmod(index, 1) != 0) baseLib->out.printWarning("Warning: mask combined with unaligned index not supported.");
		startIndex = std::lround(std::floor(index));
		int32_t intDiff = std::lround(std::floor(size)) - 1;
		if(intDiff < 0) intDiff = 0;
		endIndex = startIndex + intDiff;
		for(xml_node<>* physicalNode = node->first_node(); physicalNode; physicalNode = physicalNode->next_sibling())
		{
			std::string nodeName(physicalNode->name());
			xml_attribute<>* attr;
			if(nodeName == "set")
			{
				attr = physicalNode->first_attribute("request");
				if(attr) setRequest = std::string(attr->value());
			}
			else if(nodeName == "get")
			{
				attr = physicalNode->first_attribute("request");
				if(attr) getRequest = std::string(attr->value());
				attr = physicalNode->first_attribute("response");
				if(attr) getResponse = std::string(attr->value());
			}
			else if(nodeName == "event")
			{
				attr = physicalNode->first_attribute("frame");
				if(!attr) attr = physicalNode->first_attribute("packet");
				if(!attr) continue;
				std::shared_ptr<PhysicalParameterEvent> event(new PhysicalParameterEvent());
				event->frame = std::string(attr->value());
				for(xml_node<>* eventNode = physicalNode->first_node(); eventNode; eventNode = eventNode->next_sibling())
				{
					std::string eventNodeName(eventNode->name());
					if(eventNodeName == "domino_event")
					{
						if(type == Type::Enum::typeInteger)
						{
							xml_attribute<>* attr1 = eventNode->first_attribute("value");
							xml_attribute<>* attr2 = eventNode->first_attribute("delay_id");
							if(!attr1 || !attr2) continue;
							event->dominoEvent = true;
							std::string eventValue = std::string(attr1->value());
							event->dominoEventValue = Math::getNumber(eventValue);
							event->dominoEventDelayID = std::string(attr2->value());
						}
						else baseLib->out.printWarning("Warning: domino_event is only supported for physical type integer.");
					}
					else baseLib->out.printWarning("Warning: Unknown node for \"physical\\event\": " + eventNodeName);
				}
				eventFrames.push_back(event);
			}
			else if(nodeName == "setEx")
			{
				std::shared_ptr<SetRequestEx> setRequestEx(new SetRequestEx(baseLib, physicalNode));
				setRequestsEx.push_back(setRequestEx);
			}
			else if(nodeName == "address")
			{
				for(xml_attribute<>* addressAttr = physicalNode->first_attribute(); addressAttr; addressAttr = addressAttr->next_attribute())
				{
					std::string attributeName(addressAttr->name());
					std::string attributeValue(addressAttr->value());
					if(attributeName == "index")
					{
						if(attributeValue.substr(0, 1) == "+")
						{
							address.operation = PhysicalParameterAddress::Operation::addition;
							attributeValue.erase(0, 1);
						}
						else if(attributeValue.substr(0, 1) == "-")
						{
							address.operation = PhysicalParameterAddress::Operation::substraction;
							attributeValue.erase(0, 1);
						}
						std::pair<std::string, std::string> splitValue = baseLib->hf.split(attributeValue, '.');
						address.index = 0;
						if(!splitValue.second.empty())
						{
							address.index += Math::getNumber(splitValue.second);
							address.index /= 10;
						}
						address.index += Math::getNumber(splitValue.first);
						if(std::lround(address.index * 10) % 10 >= 8) address.index += 0.2; //e. g. 15.9 => 16.1
						index = address.index;
					}
					else if(attributeName == "step")
					{
						address.step = Math::getDouble(attributeValue);
					}
					else baseLib->out.printWarning("Warning: Unknown attribute for \"address\": " + attributeName);
				}
			}
			else if(nodeName == "reset_after_send")
			{
				attr = physicalNode->first_attribute("param");
				if(attr) resetAfterSend.push_back(std::string(attr->value()));
			}
			else baseLib->out.printWarning("Warning: Unknown node for \"physical\": " + nodeName);
		}
	}
	catch(const std::exception& ex)
    {
    	baseLib->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(const Exception& ex)
    {
    	baseLib->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
    	baseLib->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemplo n.º 20
0
// "hide" from m_menu
static void menu_hide(GtkWidget*, wxMenu* menu)
{
    wxMenuEvent event(wxEVT_MENU_CLOSE, menu->m_popupShown ? -1 : 0, menu);
    menu->m_popupShown = false;
    DoCommonMenuCallbackCode(menu, event);
}
Exemplo n.º 21
0
/******************************************************************************
*  Return the alarm summary text.
*/
QString TemplateListViewItem::lastColumnText() const
{
	return event().templateName();
}
Exemplo n.º 22
0
int main(int argc, char **argv)
{
    SDL_Event ev;
    Uint32 now, last_frame_time;

    quit_flag = 0;
    videoFlags = DEFAULT_FLAGS;
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    screen = SDL_SetVideoMode(DEFAULT_WIDTH, DEFAULT_HEIGHT,
                             DEFAULT_DEPTH, videoFlags); 
    init();
    reshape(screen->w, screen->h);

    fps = 0;
    frame_count = 0;
    last_frame_time = frame_time = SDL_GetTicks();
    while (!quit_flag) 
    {
        /* Process all pending events */
        while (SDL_PollEvent(&ev))
        {
            switch (ev.type)
            {
                case SDL_QUIT:
                    quit();
                    break;
                case SDL_MOUSEBUTTONDOWN:
                    printf("Mouse button %d pressed at (%d,%d)\n",
                    ev.button.button, ev.button.x, ev.button.y);   
                    break;
                case SDL_VIDEORESIZE:
                    screen = SDL_SetVideoMode(ev.resize.w, 
                                              ev.resize.h,
                                              DEFAULT_DEPTH, videoFlags);
                    reshape(screen->w, screen->h);
                    break;
                default:
                    event(&ev);
                    break;
            }
        }
        /* Calculate time passed */
        now = SDL_GetTicks();
        update(now - last_frame_time);
        last_frame_time = now;

        /* Refresh display and flip buffers */
      
        display(screen);
       
        // Draw the screen
   
        SDL_GL_SwapBuffers();

        /* Update FPS */
        frame_count++;
        if (now - frame_time > 1000)
        {
            fps = (frame_count * 1000) / (now - frame_time);
            frame_count = 0;
            frame_time = now;
        }
    }

    cleanup();
    SDL_Quit();
    
    return EXIT_SUCCESS;
}
Exemplo n.º 23
0
wxThread::ExitCode SymbolParserThread::Entry()
{
    
    while (!TestDestroy() && !m_exit)
    {

        // Wait for something to show up in the queue.
        m_itemsAvailable.Wait();

        while (!TestDestroy())
        {

            m_itemsLock.Enter();

            if (m_items.empty())
            {
                m_itemsLock.Leave();
                break;
            }

            wxCriticalSectionLocker locker(m_headLock);

            m_headItem = m_items.back();
            m_items.pop_back();

            m_itemsLock.Leave();

            if (m_eventHandler != NULL)
            {

                std::vector<Symbol*> symbols;
                wxStringInputStream input(m_headItem->code);

                ParseFileSymbols(input, symbols);

                m_itemsLock.Enter();
                bool isLastItem=m_items.empty();
                m_itemsLock.Leave();

                // Dispatch the message to event handler.
                SymbolParserEvent event(m_headItem->fileId, symbols, isLastItem);
                m_eventHandler->AddPendingEvent(event);
            }

            delete m_headItem;
            m_headItem = NULL;

        }

    }

    wxCriticalSectionLocker locker1(m_itemsLock);
    ClearVector(m_items);

    wxCriticalSectionLocker locker2(m_headLock);
    delete m_headItem;
    m_headItem = NULL;
    
    return 0;

}
Exemplo n.º 24
0
bool DhQIntValidator::Dvhevent(QEvent* x1) {
  return event(x1);
}
Exemplo n.º 25
0
bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
{
    dispatcher.dispatch();
    ASSERT(!event().defaultPrevented());
    return event().defaultHandled() || event().defaultPrevented();
}
bool sipQAbstractState::sipProtectVirt_event(bool sipSelfWasArg,QEvent *a0)
{
    return (sipSelfWasArg ? QAbstractState::event(a0) : event(a0));
}
Exemplo n.º 27
0
void Host_Message(int Id)
{
	wxCommandEvent event(wxEVT_HOST_COMMAND, Id);
	main_frame->GetEventHandler()->AddPendingEvent(event);
}
Exemplo n.º 28
0
void RegistrationUtils::register_with_application_servers(Ifcs& ifcs,
        RegStore* store,
        pjsip_rx_data *received_register,
        pjsip_tx_data *ok_response, // Can only be NULL if received_register is
        int expires,
        bool is_initial_registration,
        const std::string& served_user,
        SNMP::RegistrationStatsTables* third_party_reg_stats_tbls,
        SAS::TrailId trail)
{
    // Function preconditions
    if (received_register == NULL)
    {
        // We should have both messages or neither
        assert(ok_response == NULL);
    }
    else
    {
        // We should have both messages or neither
        assert(ok_response != NULL);
    }

    if (third_party_reg_stats_tbls != NULL)
    {
        third_party_reg_stats_tables = third_party_reg_stats_tbls;
    }

    std::vector<AsInvocation> as_list;
    // Choice of SessionCase::Originating is not arbitrary - we don't expect iFCs to specify SessionCase
    // constraints for REGISTER messages, but we only get the served user from the From address in an
    // Originating message, otherwise we use the Request-URI. We need to use the From for REGISTERs.
    // See 3GPP TS 23.218 s5.2.1 note 2: "REGISTER is considered part of the UE-originating".

    if (received_register == NULL)
    {
        pj_status_t status;
        pjsip_method method;
        pjsip_method_set(&method, PJSIP_REGISTER_METHOD);
        pjsip_tx_data *tdata;

        std::string served_user_uri_string = "<"+served_user+">";
        const pj_str_t served_user_uri = pj_str(const_cast<char *>(served_user_uri_string.c_str()));

        TRC_INFO("Generating a fake REGISTER to send to IfcHandler using AOR %s", served_user.c_str());

        SAS::Event event(trail, SASEvent::REGISTER_AS_START, 0);
        event.add_var_param(served_user);
        SAS::report_event(event);

        status = pjsip_endpt_create_request(stack_data.endpt,
                                            &method,               // Method
                                            &stack_data.scscf_uri, // Target
                                            &served_user_uri,      // From
                                            &served_user_uri,      // To
                                            &served_user_uri,      // Contact
                                            NULL,                  // Auto-generate Call-ID
                                            1,                     // CSeq
                                            NULL,                  // No body
                                            &tdata);               // OUT

        if (status == PJ_SUCCESS)
        {
            // As per TS 24.229, section 5.4.1.7, note 1, we don't fill in any
            // P-Associated-URI details.
            ifcs.interpret(SessionCase::Originating,
                           true,
                           is_initial_registration,
                           tdata->msg,
                           as_list,
                           trail);
            pjsip_tx_data_dec_ref(tdata);
        }
        else
        {
            TRC_DEBUG("Unable to create third party registration for %s",
                      served_user.c_str());
            SAS::Event event(trail, SASEvent::DEREGISTER_AS_FAILED, 0);
            event.add_var_param(served_user);
            SAS::report_event(event);
        }
    }
    else
    {
        ifcs.interpret(SessionCase::Originating, true, is_initial_registration, received_register->msg_info.msg, as_list, trail);
    }

    TRC_INFO("Found %d Application Servers", as_list.size());

    // Loop through the as_list
    for (std::vector<AsInvocation>::iterator as_iter = as_list.begin();
            as_iter != as_list.end();
            as_iter++)
    {
        if (expires == 0)
        {
            third_party_reg_stats_tables->de_reg_tbl->increment_attempts();
        }
        else if (is_initial_registration)
        {
            third_party_reg_stats_tables->init_reg_tbl->increment_attempts();
        }
        else
        {
            third_party_reg_stats_tables->re_reg_tbl->increment_attempts();
        }
        send_register_to_as(received_register, ok_response, *as_iter, expires, is_initial_registration, served_user, trail);
    }
}
Exemplo n.º 29
0
void Host_RequestRenderWindowSize(int width, int height)
{
	wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_WINDOW_SIZE_REQUEST);
	event.SetClientData(new std::pair<int, int>(width, height));
	main_frame->GetEventHandler()->AddPendingEvent(event);
}
Exemplo n.º 30
0
void wxDynamicSashWindowImpl::Unify(int panel)
{
    int other = panel == 0 ? 1 : 0;

    if (m_child[panel]->m_leaf)
    {
        wxDynamicSashWindowImpl *child[2];

        child[0] = m_child[0];
        child[1] = m_child[1];

        m_child[0] = m_child[1] = NULL;

        m_leaf = new wxDynamicSashWindowLeaf(this);
        m_leaf->Create();
        m_leaf->m_child = child[panel]->m_leaf->m_child;

        m_leaf->m_vscroll->SetScrollbar(child[panel]->m_leaf->m_vscroll->GetThumbPosition(),
                                        child[panel]->m_leaf->m_vscroll->GetThumbSize(),
                                        child[panel]->m_leaf->m_vscroll->GetRange(),
                                        child[panel]->m_leaf->m_vscroll->GetPageSize());
        m_leaf->m_hscroll->SetScrollbar(child[panel]->m_leaf->m_hscroll->GetThumbPosition(),
                                        child[panel]->m_leaf->m_hscroll->GetThumbSize(),
                                        child[panel]->m_leaf->m_hscroll->GetRange(),
                                        child[panel]->m_leaf->m_hscroll->GetPageSize());
        m_add_child_target = NULL;
        wxDynamicSashReparentEvent event(m_leaf);
        m_leaf->ProcessEvent(event);

        delete child[0];
        delete child[1];

        m_split = DSR_NONE;

        wxDynamicSashUnifyEvent unify(m_leaf->m_child);
        m_leaf->m_child->ProcessEvent(unify);
    }
    else
    {
        m_split = m_child[panel]->m_split;

        delete m_child[other];

        wxDynamicSashWindowImpl *child_panel = m_child[panel];
        m_child[0] = child_panel->m_child[0];
        m_child[1] = child_panel->m_child[1];

        m_child[0]->m_parent = this;
        m_child[1]->m_parent = this;

        m_add_child_target = NULL;
        m_child[0]->m_container->Reparent(m_container);
        m_child[1]->m_container->Reparent(m_container);

        child_panel->m_child[0] = child_panel->m_child[1] = NULL;
        delete child_panel;

        wxSize size = m_container->GetSize();
        wxSize child_size = m_child[0]->m_container->GetSize();

        ConstrainChildren(child_size.GetWidth() * 100 / size.GetWidth(),
                            child_size.GetHeight() * 100 / size.GetHeight());

        m_container->Layout();
    }
}