Пример #1
0
void wxIFMDefaultPlugin::OnFloat(wxIFMFloatEvent &event)
{
    wxIFMComponent *component = event.GetComponent();

    // undock if we are docked already
    if( component->m_docked )
    {
        wxIFMUndockEvent evt(component, true);
        GetIP()->ProcessPluginEvent(evt);
    }

    // create a window with which to float
    wxIFMCreateFloatingWindowEvent wndevt(GetManager()->GetParent(), component);
    GetIP()->ProcessPluginEvent(wndevt);

    wxIFMFloatingWindowBase *base = wndevt.GetWindow();
    wxASSERT_MSG(base, wxT("NULL window returned by CreateFloatingWindow event!"));

    // size and position the window
    wxPoint pos = event.GetPosition();
    wxSize size = event.GetSize();

    // if default rect is specified, use desired size and mouse position
    if( size == IFM_DEFAULT_RECT.GetSize() )
    {
        wxIFMRectEvent evt(wxEVT_IFM_GETDESIREDSIZE, component);
        GetIP()->ProcessPluginEvent(evt);
        size = evt.GetSize();
    }

    // convert from client to absolute coordinates up through the chain of parents until
    // we reach the root component
    for( wxIFMComponent *parent = component; parent && parent != base->m_component; parent = parent->m_parent )
    {
        wxIFMConvertRectEvent cvtevt(parent, IFM_COORDS_CLIENT, IFM_COORDS_ABSOLUTE, wxPoint(), size);
        GetIP()->ProcessPluginEvent(cvtevt);
        size = cvtevt.GetSize();
    }

    wxSize display_size = wxGetDisplaySize();

    // hide the root component to make sure it doesnt display the frame before we are ready
    //! \note Yes, I know I directly access m_hidden here.
    base->m_component->m_hidden = true;

    base->GetWindow()->SetClientSize(size);
    size = base->GetWindow()->GetSize();

    // use mouse position now if needed as at this point we have an accurate size
    if( pos == IFM_DEFAULT_RECT.GetPosition() )
    {
        pos = ::wxGetMousePosition();
        pos.x -= size.GetWidth() / 2;

        wxIFMConvertRectEvent cvtevt(base->m_component, IFM_COORDS_FLOATINGWINDOW, IFM_COORDS_ABSOLUTE, pos, size);
        GetIP()->ProcessPluginEvent(cvtevt);
        const wxPoint &pos2 = cvtevt.GetPosition();

        pos.x = pos2.x;
        pos.y -= (pos.y - pos2.y) / 2;
    }

    // convert from absolute coords of the root component into floating coords to position and size the
    // floating window
    wxIFMConvertRectEvent cvtevt3(base->m_component, IFM_COORDS_ABSOLUTE, IFM_COORDS_FLOATINGWINDOW, pos, size);
    GetIP()->ProcessPluginEvent(cvtevt3);

    //! \todo Find out why windows get nudged to the right when double clicked when already floating
    pos = cvtevt3.GetPosition();
    size = cvtevt3.GetSize();

    {
        // dont position the window off screen
        if( pos.x < 0 )
            pos.x = 0;
        if( pos.y < 0 )
            pos.y = 0;

        if( pos.x + size.GetWidth() > display_size.GetWidth() )
            pos.x = display_size.GetWidth() - size.GetWidth();
        if( pos.y + size.GetHeight() > display_size.GetHeight() )
            pos.y = display_size.GetHeight() - size.GetHeight();
    }

    base->GetWindow()->Move(pos);

    // unhide the root component
    base->m_component->m_hidden = false;

    // show the window
    base->GetWindow()->Show();

    // updating after we show the window seems to fix broken 2.5.3 release mode behavior
    base->Update();
}
Пример #2
0
void user_event_filter_t::remove(const std::string& kind)
{
	user_event_meta_t::type_list_t types;
	user_event_meta_t evt(kind, types);
	remove(evt);
}
Пример #3
0
 void postEvent(int id, const DataType& data)
 {
    boost::shared_ptr<CEventBase> evt(new CEvent<DataType>(id, data));
    postEvent(evt);
 }
void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
{
    for( TOOL_ID toolId : m_activeTools )
    {
        TOOL_STATE* st = m_toolIdIndex[toolId];

        // the tool requested a context menu. The menu is activated on RMB click (CMENU_BUTTON mode)
        // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
        if( st->contextMenuTrigger == CMENU_OFF )
            continue;

        if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
            break;

        st->pendingWait = true;
        st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );

        // Store the menu pointer in case it is changed by the TOOL when handling menu events
        CONTEXT_MENU* m = st->contextMenu;

        if( st->contextMenuTrigger == CMENU_NOW )
            st->contextMenuTrigger = CMENU_OFF;

        // Store the cursor position, so the tools could execute actions
        // using the point where the user has invoked a context menu
        m_menuCursor = m_viewControls->GetCursorPosition();

        // Save all tools cursor settings, as they will be overridden
        for( auto idState : m_toolIdIndex )
        {
            TOOL_STATE* s = idState.second;
            const auto& vc = s->vcSettings;

            if( vc.m_forceCursorPosition )
                m_cursorSettings[idState.first] = vc.m_forcedPosition;
            else
                m_cursorSettings[idState.first] = NULLOPT;
        }

        m_viewControls->ForceCursorPosition( true, m_menuCursor );

        // Display a copy of menu
        std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );

        // Run update handlers on the created copy
        menu->UpdateAll();
        m_menuOwner = toolId;
        m_menuActive = true;

        auto frame = dynamic_cast<wxFrame*>( m_editFrame );

        if( frame )
            frame->PopupMenu( menu.get() );

        // Warp the cursor as long as the menu wasn't clicked out of
        if( menu->GetSelected() >= 0 )
            m_viewControls->WarpCursor( m_menuCursor, true, false );
        // Otherwise notify the tool of a cancelled menu
        else
        {
            TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, -1 );
            evt.SetParameter( m );
            dispatchInternal( evt );
        }

        // Notify the tools that menu has been closed
        TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CLOSED );
        evt.SetParameter( m );
        dispatchInternal( evt );

        m_menuActive = false;
        m_menuOwner = -1;

        // Restore cursor settings
        for( auto cursorSetting : m_cursorSettings )
        {
            auto it = m_toolIdIndex.find( cursorSetting.first );
            wxASSERT( it != m_toolIdIndex.end() );

            if( it == m_toolIdIndex.end() )
                continue;

            KIGFX::VC_SETTINGS& vc = it->second->vcSettings;
            vc.m_forceCursorPosition = (bool) cursorSetting.second;
            vc.m_forcedPosition = cursorSetting.second ? *cursorSetting.second : VECTOR2D( 0, 0 );
        }

        m_cursorSettings.clear();
        break;
    }
}
Пример #5
0
GenerateDlg::GenerateDlg(wxWindow *parent, int a, int pl)
{
	genAuto = a;
	lastTime = 0;
	canceled = 0;
	paused = 0;
	if (pl >= 0)
		playLive = pl;
	dlgLock.Create();

	wxXmlResource::Get()->LoadDialog(this, parent, "DLG_GENERATE");
	CenterOnParent();
	EnableOK(1, 0);

	wxSize sz;
	wxPoint pt;

	ed = (wxTextCtrl*)FindWindow("IDC_TEXT");
	tm = (wxTextCtrl*)FindWindow("IDC_TIME");
	tm->ChangeValue("00:00.0");
	sz = tm->GetSize();
	pt = tm->GetPosition();
	pt.x += sz.GetWidth() + 2;
	wxWindow *btn = FindWindow(wxID_OK);
	sz.SetWidth(btn->GetPosition().x + btn->GetSize().GetWidth() - pt.x);
	tml = new BarMeter(this, wxWindowID(102), pt, sz);

	lpk = (wxTextCtrl*)FindWindow("IDC_LEFT_PEAK");
	rpk = (wxTextCtrl*)FindWindow("IDC_RIGHT_PEAK");

	sz = lpk->GetSize();
	pt = lpk->GetPosition();
	pt.x += sz.GetWidth() + 2;
	sz.SetWidth(sz.GetWidth() * 2);
	lpkMtr = new BarMeter(this, wxWindowID(100), pt, sz);
	lpkMtr->SetRange(1.2);
	lpkMtr->Show();

	sz = rpk->GetSize();
	pt = rpk->GetPosition();
	pt.x += sz.GetWidth() + 2;
	sz.SetWidth(sz.GetWidth() * 2);
	rpkMtr = new BarMeter(this, wxWindowID(100), pt, sz);
	rpkMtr->SetRange(1.2);
	rpkMtr->Show();

	rateWnd = (wxComboBox*)FindWindow("IDC_RATE");
	rateWnd->Append("0.1 Sec", (void*)1);
	rateWnd->Append("0.5 Sec", (void*)5);
	rateWnd->Append("1.0 Sec", (void*)10);
	rateWnd->Append("5.0 Sec", (void*)50);
	rateWnd->Select(0);

	SetPlayOutput();
	SetPlayRange();

	FormatTime("IDC_PLAY_FROM", playFrom);
	FormatTime("IDC_PLAY_TO", playTo);

	wxCheckBox *on;
	on = (wxCheckBox*)FindWindow("IDC_PEAK_ON");
	on->SetValue(pkOn);
	on = (wxCheckBox*)FindWindow("IDC_TIME_ON");
	on->SetValue(tmOn);

	if (genAuto)
	{
		wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, XRCID("IDC_START"));
		evt.SetEventObject(this);
		wxPostEvent(this, evt);
	}
}
void OutlineTab::OnRenameSymbol(wxCommandEvent& e)
{
    wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("rename_symbol"));
    EventNotifier::Get()->TopFrame()->GetEventHandler()->AddPendingEvent(evt);
}
Пример #7
0
void mmAttachmentDialog::OnMagicButton(wxCommandEvent& event)
{
    wxDataViewEvent evt(wxEVT_NULL);
    OnItemRightClick(evt);
}
Пример #8
0
int main(int argc, char** argv){
	setlocale( LC_ALL, "");
	bindtextdomain( "gpc", LOCALEDIR);
	textdomain( "gpc" );
	Gtk::Main app(argc, argv);
	Glib::thread_init();
	GrubEnv env;
	GPC presenter(env);
	GrublistCfg listcfg(env);
	GrublistCfgDlgGtk listCfgView;
	SettingsManagerDataStore settings(env);
	SettingsManagerDataStore settingsOnDisk(env);
	GrubInstaller installer(env);
	GrubInstallDlgGtk installDlg;
	ScriptAddDlgGtk scriptAddDlg;
	MountTable mountTable;
	PartitionChooserGtk partitionChooser;
	GrublistCfg savedListCfg(env);
	FbResolutionsGetter fbResolutionsGetter;
	GrubSettingsDlgGtk settingsDlg;
	DeviceDataList deviceDataList;
	AboutDialogGtk aboutDialog;
	GlibMutex listCfgMutex1;
	GlibMutex listCfgMutex2;
	GlibThreadController threadC(presenter);
	presenter.setListCfg(listcfg);
	presenter.setListCfgDlg(listCfgView);
	presenter.setSettingsDialog(settingsDlg);
	presenter.setSettingsManager(settings);
	presenter.setSettingsBuffer(settingsOnDisk);
	presenter.setInstaller(installer);
	presenter.setInstallDlg(installDlg);
	presenter.setScriptAddDlg(scriptAddDlg);
	presenter.setPartitionChooser(partitionChooser);
	presenter.setSavedListCfg(savedListCfg);
	presenter.setFbResolutionsGetter(fbResolutionsGetter);
	presenter.setDeviceDataList(deviceDataList);
	presenter.setMountTable(mountTable);
	presenter.setAboutDialog(aboutDialog);
	presenter.setThreadController(threadC);
	EventListener evt(presenter);
	listCfgView.setEventListener(evt);
	installDlg.setEventListener(evt);
	scriptAddDlg.setEventListener(evt);
	settingsDlg.setEventListener(evt);
	partitionChooser.setEventListener(evt);
	listcfg.setEventListener(evt);
	installer.setEventListener(evt);
	fbResolutionsGetter.setEventListener(evt);
	StreamLogger logger(std::cout);
	presenter.setLogger(logger);
	listcfg.setLogger(logger);
	listCfgView.setLogger(logger);
	settings.setLogger(logger);
	settingsOnDisk.setLogger(logger);
	installer.setLogger(logger);
	installDlg.setLogger(logger);
	scriptAddDlg.setLogger(logger);
	mountTable.setLogger(logger);
	partitionChooser.setLogger(logger);
	savedListCfg.setLogger(logger);
	fbResolutionsGetter.setLogger(logger);
	settingsDlg.setLogger(logger);
	deviceDataList.setLogger(logger);
	aboutDialog.setLogger(logger);
	listCfgMutex1.setLogger(logger);
	listCfgMutex2.setLogger(logger);
	threadC.setLogger(logger);
	env.setLogger(logger);
	listcfg.setMutex(listCfgMutex1);
	savedListCfg.setMutex(listCfgMutex2);
	presenter.init();
	app.run();
}
Пример #9
0
// -------------------------------------------------------------------
// OnSocketClose
// -------------------------------------------------------------------
void BitSwarmClient::OnSocketClose(unsigned long long context)
{
	BitSwarmClient* instance = (BitSwarmClient*)context;

	instance->lockDispose.lock();

	if (instance->isDisposed == true)
	{
		instance->lockDispose.unlock();
		return;
	}

	bool isRegularDisconnection = instance->sfs==NULL || (!instance->attemptingReconnection && instance->sfs->GetReconnectionSeconds() == 0);
	//bool isManualDisconnection = (evt!=null) && (string)evt.Params["reason"] == ClientDisconnectionReason.MANUAL;
	bool isManualDisconnection = instance->manualDisconnection;

	/*
	* There are three cases in which we need to acknowledge the disconnection
	* 
	* 	1. 	We're in the middle of Reconnection Attempt:
	*		In this case a disconnection means that there's no way we can reconnect, so end of story.
	*
	*	2.	It is Regular Disconnection (no reconnection feature available)
	*
	*	3.	It is a voluntary (Manual) disconnection, initiated on the client
	*
	*/
	if (instance->attemptingReconnection || isRegularDisconnection || isManualDisconnection) {
		// Reset UDP Manager
		if (instance->udpManager!=NULL) {
			instance->udpManager->Reset();
		}

					
		/*
		* Disconnection at socket level
		* Dispatching the event here only in the case of manual disconnection. If it's disconnection from server 
		* This will be dispatched from the server disconnection event handler
		*/

		if (isManualDisconnection) {
			boost::shared_ptr<map<string, boost::shared_ptr<void> > > args (new map<string, boost::shared_ptr<void> >());
			args->insert(pair<string, boost::shared_ptr<void> >("reason", (boost::static_pointer_cast<void>)(ClientDisconnectionReason::MANUAL)));

			boost::shared_ptr<BitSwarmEvent> evt (new BitSwarmEvent(BitSwarmEvent::DISCONNECT, args));
			instance->sfs->DispatchEvent(evt);

			// Don't resetting manualDisconnection flag here as there will be OnSocketError event
		}

		if (!instance->attemptingReconnection)
		{
			instance->lockDispose.unlock();
			return;
		}
	}

	char buffer[512];
	sprintf (buffer, "Attempting reconnection in %ld sec", instance->ReconnectionSeconds());
	string logMessage = buffer;

	boost::shared_ptr<vector<string> > logMessages (new vector<string>());
	logMessages->push_back(logMessage);
	instance->log->Debug(logMessages);

	//--- Attempt a reconnection to the server --------------------------------------------------------

	if (instance->attemptingReconnection == false)
	{
		/*
		* If we aren't in any of the above three cases then it's time to attempt a
		* reconnection to the server.
		*/
		instance->attemptingReconnection = true;

		// Fire event and retry
		boost::shared_ptr<BitSwarmEvent> evt (new BitSwarmEvent(BitSwarmEvent::RECONNECTION_TRY));
		instance->DispatchEvent(evt);

		// Retry connection: pause n seconds and retry
		// instance->RetryConnection(instance->ReconnectionSeconds()/**1000*/);
		instance->RetryConnection(1);
	}

	instance->lockDispose.unlock();
}
Пример #10
0
bool SkListView::ensureCache()
{
	if (fSkinName.size() == 0)
		return false;

	if (fAnims == NULL)
	{
		int n = SkMax32(1, fVisibleRowCount);

		SkASSERT(fAnimContentDirty);
		fAnims = new SkAnimator[n];
		for (int i = 0; i < n; i++)
		{
			fAnims[i].setHostEventSink(this);
			init_skin_anim(fSkinName.c_str(), &fAnims[i]);
		}
		
		fHeights[kNormal_Height] = fAnims[0].getScalar("idleHeight", "value");
		fHeights[kSelected_Height] = fAnims[0].getScalar("focusedHeight", "value");

		fAnimFocusDirty = true;
	}

	if (fAnimContentDirty && fSource)
	{
		fAnimContentDirty = false;

		SkString	str;
		SkEvent		evt("user");
		evt.setString("id", "setFields");
		evt.setS32("rowCount", fVisibleRowCount);
		
		SkEvent	dimEvt("user");
		dimEvt.setString("id", "setDim");
		dimEvt.setScalar("dimX", this->getContentWidth());
		dimEvt.setScalar("dimY", this->height());

		for (int i = fScrollIndex; i < fScrollIndex + fVisibleRowCount; i++)
		{
			evt.setS32("relativeIndex", i - fScrollIndex);
			for (int j = 0; j < fBindingCount; j++)
			{
				fSource->getRecord(i, fBindings[j].fFieldIndex, &str);
//SkDEBUGF(("getRecord(%d,%d,%s) slot(%s)\n", i, fBindings[j].fFieldIndex, str.c_str(), fBindings[j].fSlotName.c_str()));
				evt.setString(fBindings[j].fSlotName.c_str(), str.c_str());
			}
			(void)fAnims[i % fVisibleRowCount].doUserEvent(evt);
			(void)fAnims[i % fVisibleRowCount].doUserEvent(dimEvt);
		}
		fAnimFocusDirty = true;
	}

	if (fAnimFocusDirty)
	{
//SkDEBUGF(("service fAnimFocusDirty\n"));
		fAnimFocusDirty = false;

		SkEvent		focusEvt("user");
		focusEvt.setString("id", "setFocus");

		for (int i = fScrollIndex; i < fScrollIndex + fVisibleRowCount; i++)
		{
			focusEvt.setS32("FOCUS", i == fCurrIndex);
			(void)fAnims[i % fVisibleRowCount].doUserEvent(focusEvt);
		}
	}

	return true;
}
Пример #11
0
// NetPlayUI methods called from ---NETPLAY--- thread
void NetPlayDialog::Update()
{
	wxThreadEvent evt(wxEVT_THREAD, 1);
	GetEventHandler()->AddPendingEvent(evt);
}
Пример #12
0
void wxCustomHeightListCtrl::OnMouseEvent(wxMouseEvent& event)
{
	bool changed = false;
	if (event.ButtonDown() && m_allow_selection)
	{
		wxPoint pos = event.GetPosition();
		int x, y;
		CalcUnscrolledPosition(pos.x, pos.y, &x, &y);
		if (y > m_lineHeight * m_lineCount)
		{
			m_focusedLine = -1;
			m_selectedLines.clear();
			changed = true;
		}
		else
		{
			int line = y / m_lineHeight;
			if (event.ShiftDown())
			{
				if (line < m_focusedLine)
				{
					for (int i = line; i <= m_focusedLine; i++)
					{
						if (m_selectedLines.find(i) == m_selectedLines.end())
						{
							changed = true;
							m_selectedLines.insert(i);
						}
					}
				}
				else
				{
					for (int i = line; i >= m_focusedLine; i--)
					{
						if (m_selectedLines.find(i) == m_selectedLines.end())
						{
							changed = true;
							m_selectedLines.insert(i);
						}
					}
				}
			}
			else if (event.ControlDown())
			{
				if (m_selectedLines.find(line) == m_selectedLines.end())
					m_selectedLines.insert(line);
				else
					m_selectedLines.erase(line);
				changed = true;
			}
			else
			{
				m_selectedLines.clear();
				m_selectedLines.insert(line);
				changed = true;
			}

			m_focusedLine = line;				

		}
		Refresh();
	}

	event.Skip();

	if (changed)
	{
		wxCommandEvent evt(wxEVT_COMMAND_LISTBOX_SELECTED, GetId());
		ProcessEvent(evt);
	}
}
Пример #13
0
void GribGrabberWin::OnMouseEvent( wxMouseEvent& event )
{
    if( event.RightDown() ) {
        wxMouseEvent evt(event);
        ((wxEvtHandler*)GetParent())->ProcessEvent( evt );
        return;
    }

    static wxPoint s_gspt;
    int x, y;

    event.GetPosition( &x, &y );
    wxPoint spt = ClientToScreen( wxPoint( x, y ) );

#ifdef __WXOSX__
    if (!m_bLeftDown && event.LeftIsDown())
    {
        m_bLeftDown = true;
        s_gspt = spt;
        if (!HasCapture()) CaptureMouse();
    }
    else if (m_bLeftDown && !event.LeftIsDown())
    {
       // GetParent()->Move( GetParent()->GetPosition() );
        m_bLeftDown = false;
        if (HasCapture()) ReleaseMouse();
    }
#else

    if( event.LeftDown() ) {
        s_gspt = spt;
        CaptureMouse();
    }

    if( event.LeftUp() ) {
        //GetParent()->Move( GetParent()->GetPosition() );
        if( HasCapture() ) ReleaseMouse();
    }
#endif

    if( event.Dragging() ) {

        wxPoint par_pos_old = GetParent()->GetPosition();

        wxPoint par_pos = par_pos_old;
        par_pos.x += spt.x - s_gspt.x;
        par_pos.y += spt.y - s_gspt.y;

        wxPoint pos_in_parent = GetOCPNCanvasWindow()->ScreenToClient( par_pos );
        wxPoint pos_in_parent_old = GetOCPNCanvasWindow()->ScreenToClient( par_pos_old );

		// X
		if( pos_in_parent.x < pos_in_parent_old.x ) {           // moving left
			if( pos_in_parent.x < 10 ) {
				pos_in_parent.x = 0;
			}
		} else
        if( pos_in_parent.x > pos_in_parent_old.x ) {           // moving right
            int max_right = GetOCPNCanvasWindow()->GetClientSize().x - GetParent()->GetSize().x;
            if( pos_in_parent.x > ( max_right - 10 ) ) {
                pos_in_parent.x = max_right;
            }
        }

		// Y
		if( pos_in_parent.y < pos_in_parent_old.y ) {            // moving up
			if( pos_in_parent.y < 10 ) {
				pos_in_parent.y = 0;
			}
		} else
        if( pos_in_parent.y > pos_in_parent_old.y ) {            // moving dow
            int max_down = GetOCPNCanvasWindow()->GetClientSize().y - GetParent()->GetSize().y;
            if( pos_in_parent.y > ( max_down - 10 ) ) {
                pos_in_parent.y = max_down;
            }
        }

		wxPoint final_pos = GetOCPNCanvasWindow()->ClientToScreen( pos_in_parent );

		GetParent()->Move( final_pos );

        s_gspt = spt;

    }
}
Пример #14
0
void wxIFMDefaultPlugin::OnSetRect(wxIFMRectEvent &event)
{
    wxIFMComponent *component = event.GetComponent();
    wxEventType type = event.GetEventType();

    if( type == wxEVT_IFM_SETRECT )
    {
        // store the rect
        wxRect rect = event.GetRect();

        // see if we need to use existing values
        if( rect.x == IFM_USE_CURRENT_VALUE || rect.y == IFM_USE_CURRENT_VALUE ||
                rect.width == IFM_USE_CURRENT_VALUE || rect.height == IFM_USE_CURRENT_VALUE )
        {
            // we need to use some existing values, find out what they are first
            // do this with an event to allow GETRECT to be processed in all circumstances
            wxIFMRectEvent rectevt(wxEVT_IFM_GETRECT, component);
            GetIP()->ProcessPluginEvent(rectevt);
            wxRect m_rect = rectevt.GetRect();

            if( rect.x == IFM_USE_CURRENT_VALUE )
                rect.x = m_rect.x;
            if( rect.y == IFM_USE_CURRENT_VALUE )
                rect.y = m_rect.y;
            if( rect.width == IFM_USE_CURRENT_VALUE )
                rect.width = m_rect.width;
            if( rect.height == IFM_USE_CURRENT_VALUE )
                rect.height = m_rect.height;
        }

        // make sure we don't size the component smaller than its minimum size
        wxIFMRectEvent minevt(wxEVT_IFM_GETMINSIZE, component);
        GetIP()->ProcessPluginEvent(minevt);
        const wxSize &min_size = minevt.GetSize();

        if( min_size.GetWidth() != IFM_NO_MINIMUM && min_size.GetWidth() > rect.width )
            rect.width = min_size.GetWidth();
        if( min_size.GetHeight() != IFM_NO_MINIMUM && min_size.GetHeight() > rect.height )
            rect.height = min_size.GetHeight();

        // dont size bigger than the maximum either
        wxIFMRectEvent maxevt(wxEVT_IFM_GETMAXSIZE, component);
        GetIP()->ProcessPluginEvent(maxevt);
        const wxSize &max_size = maxevt.GetSize();

        if( max_size.GetWidth() != IFM_NO_MAXIMUM && max_size.GetWidth() < rect.width )
            rect.width = max_size.GetWidth();
        if( max_size.GetHeight() != IFM_NO_MAXIMUM && max_size.GetHeight() < rect.height )
            rect.height = max_size.GetHeight();

        component->m_rect = rect;
    }
    else if( type == wxEVT_IFM_SETBACKGROUNDRECT )
    {
        // calculate new rect
        wxRect rect = event.GetRect();

        // see if we need to use existing values
        if( rect.x == IFM_USE_CURRENT_VALUE || rect.y == IFM_USE_CURRENT_VALUE ||
                rect.width == IFM_USE_CURRENT_VALUE || rect.height == IFM_USE_CURRENT_VALUE )
        {
            // we need to use some existing values, find out what they are first
            // do this with an event to allow GETBACKGROUNDRECT to be processed in all circumstances
            wxIFMRectEvent rectevt(wxEVT_IFM_GETBACKGROUNDRECT, component);
            GetIP()->ProcessPluginEvent(rectevt);
            wxRect m_rect = rectevt.GetRect();

            if( rect.x == IFM_USE_CURRENT_VALUE )
                rect.x = m_rect.x;

            if( rect.y == IFM_USE_CURRENT_VALUE )
                rect.y = m_rect.y;

            if( rect.width == IFM_USE_CURRENT_VALUE )
                rect.width = m_rect.width;

            if( rect.height == IFM_USE_CURRENT_VALUE )
                rect.height = m_rect.height;
        }

        // Calculate the new absolute size using CONVERTRECT event
        wxIFMConvertRectEvent evt(component, IFM_COORDS_BACKGROUND, IFM_COORDS_ABSOLUTE, rect);
        GetIP()->ProcessPluginEvent(evt);
        rect = evt.GetRect();

        // set the rect
        component->m_rect = rect;
    }
    else if( type == wxEVT_IFM_SETCLIENTRECT )
    {
        // calculate new rect
        wxRect rect = event.GetRect();

        // see if we need to use existing values
        if( rect.x == IFM_USE_CURRENT_VALUE || rect.y == IFM_USE_CURRENT_VALUE ||
                rect.width == IFM_USE_CURRENT_VALUE || rect.height == IFM_USE_CURRENT_VALUE )
        {
            // we need to use some existing values, find out what they are first
            // do this with an event to allow GETCLIENTRECT to be processed in all circumstances
            wxIFMRectEvent rectevt(wxEVT_IFM_GETCLIENTRECT, component);
            GetIP()->ProcessPluginEvent(rectevt);
            wxRect m_rect = rectevt.GetRect();

            if( rect.x == IFM_USE_CURRENT_VALUE )
                rect.x = m_rect.x;

            if( rect.y == IFM_USE_CURRENT_VALUE )
                rect.y = m_rect.y;

            if( rect.width == IFM_USE_CURRENT_VALUE )
                rect.width = m_rect.width;

            if( rect.height == IFM_USE_CURRENT_VALUE )
                rect.height = m_rect.height;
        }

        // Calculate the new absolute size using CONVERTRECT event
        wxIFMConvertRectEvent evt(component, IFM_COORDS_CLIENT, IFM_COORDS_ABSOLUTE, rect);
        GetIP()->ProcessPluginEvent(evt);
        rect = evt.GetRect();

        // set the new rect
        component->m_rect = rect;
    }
#ifdef __WXDEBUG__
    else
        wxFAIL_MSG(wxT("Unknown event type encountered"));
#endif
}
void OutlineTab::OnGotoImpl(wxCommandEvent& e)
{
    wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("find_impl"));
    EventNotifier::Get()->TopFrame()->GetEventHandler()->AddPendingEvent(evt);
}
Пример #16
0
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
    SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
        wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME )
{
    m_showAxis   = true;            // true to draw axis
    SetShowDeMorgan( false );
    m_drawSpecificConvert = true;
    m_drawSpecificUnit    = false;
    m_hotkeysDescrList    = g_Libedit_Hokeys_Descr;
    m_editPinsPerPartOrConvert = false;
    m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN;

    m_my_part = NULL;
    m_tempCopyComponent = NULL;

    // Delayed initialization
    if( m_textSize == -1 )
        m_textSize = GetDefaultTextSize();

    // Initialize grid id to the default value 50 mils:
    m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;

    wxIcon icon;
    icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) );
    SetIcon( icon );

    LoadSettings( config() );

    SetScreen( new SCH_SCREEN( aKiway ) );
    GetScreen()->m_Center = true;
    GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );

    SetCrossHairPosition( wxPoint( 0, 0 ) );

    // Ensure m_LastGridSizeId is an offset inside the allowed schematic range
    if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 )
        m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;

    if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000 )
        m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000;

    SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );

    GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId  );

    if( m_canvas )
        m_canvas->SetEnableBlockCommands( true );

    ReCreateMenuBar();
    ReCreateHToolbar();
    ReCreateVToolbar();

    // Ensure the current alias name is valid if a part is loaded
    // Sometimes it is not valid. This is the case
    // when a part value (the part lib name), or the alias list was modified
    // during a previous session and the modifications not saved in lib.
    // Reopen libedit in a new session gives a non valid m_aliasName
    // because the curr part is reloaded from the library (and this is the unmodified part)
    // and the old alias name (from the previous edition) can be invalid
    LIB_PART* part = GetCurPart();

    if( part == NULL )
        m_aliasName.Empty();
    else if( m_aliasName != part->GetName() )
    {
        LIB_ALIAS* alias = part->GetAlias( m_aliasName );

        if( !alias )
            m_aliasName = part->GetName();
    }


    CreateOptionToolbar();
    DisplayLibInfos();
    DisplayCmpDoc();
    UpdateAliasSelectList();
    UpdatePartSelectList();

    m_auimgr.SetManagedWindow( this );

    EDA_PANEINFO horiz;
    horiz.HorizontalToolbarPane();

    EDA_PANEINFO vert;
    vert.VerticalToolbarPane();

    EDA_PANEINFO mesg;
    mesg.MessageToolbarPane();

    m_auimgr.AddPane( m_mainToolBar,
                      wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );

    m_auimgr.AddPane( m_drawToolBar,
                      wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );

    m_auimgr.AddPane( m_optionsToolBar,
                      wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );

    m_auimgr.AddPane( m_canvas,
                      wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );

    m_auimgr.AddPane( m_messagePanel,
                      wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );

    m_auimgr.Update();

    Raise();
    Show( true );

    wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
    wxPostEvent( this, evt );
}
void OutlineTab::OnFindReferenes(wxCommandEvent& e)
{
    wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, XRCID("find_references"));
    EventNotifier::Get()->TopFrame()->GetEventHandler()->AddPendingEvent(evt);
}
Пример #18
0
void TrackStatusHandler::pipelineStreamEnd(Pipeline* const pipeline) throw() {
    // NOTE: this function is called from a gst thread.
    wxCommandEvent evt(NAVI_EVENT_TRACK_NEXT);
    AddPendingEvent(evt);
}
Пример #19
0
void ReplayProvider::OnFileSystemChange(wxFileSystemWatcherEvent& event)
{
	wxLogDebug(event.ToString());
	if (!event.GetPath().GetExt().IsSameAs("replay", false))
		return;

	if (event.GetChangeType() & wxFSW_EVENT_CREATE)
	{
		Replay* existingReplay = FindReplay(event.GetPath().GetFullPath());
		if (existingReplay) // Replay is already in list
			return;

		// Give rocket league some time to write the file
		wxMilliSleep(500);

		// Add new file
		Replay::Ptr ri(new Replay(event.GetPath().GetFullPath()));
		replay.push_back(ri);

		if (wxConfig::Get()->ReadBool("AutoUpload", false))
		{
			TransferManager::Get().Upload(ri);
		}

		wxCommandEvent evt(wxEVT_REPLAY_ADDED);
		evt.SetInt(replay.size() - 1);
		evt.SetEventObject(this);
		GetRoot()->ProcessEvent(evt);
	}
	else if (event.GetChangeType() & wxFSW_EVENT_DELETE)
	{
		// Find replay and remove it
		size_t index = 0;
		wxString changePath = event.GetPath().GetFullPath();

		for (auto replayIT = replay.begin(); replayIT != replay.end(); ++replayIT, ++index)
		{
			if ((*replayIT)->GetFileName().IsSameAs(changePath, false))
			{
				replay.erase(replayIT);
				break;
			}
		}

		wxCommandEvent evt(wxEVT_REPLAY_REMOVED);
		evt.SetInt(index);
		evt.SetEventObject(this);
		GetRoot()->ProcessEvent(evt);
	}
	else if (event.GetChangeType() & wxFSW_EVENT_RENAME)
	{
		wxString changePath = event.GetPath().GetFullPath();

		// Find replay and update filename
		for (auto replayIT = replay.begin(); replayIT != replay.end(); ++replayIT)
		{
			if ((*replayIT)->GetFileName().IsSameAs(changePath, false))
			{
				(*replayIT)->SetFileName(event.GetNewPath().GetFullPath());
				break;
			}
		}
	}

	event.Skip();
}
Пример #20
0
void RowHeading::OnLayerPopup(wxCommandEvent& event)
{
    Row_Information_Struct *ri = mSequenceElements->GetVisibleRowInformation(mSelectedRow);
    Element* element = ri->element;
    int layer_index = ri->layerIndex;
    int id = event.GetId();
    if(id == ID_ROW_MNU_INSERT_LAYER_ABOVE)
    {
        element->InsertEffectLayer(layer_index);
        wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
        wxPostEvent(GetParent(), eventRowHeaderChanged);
    }
    else if(id == ID_ROW_MNU_INSERT_LAYER_BELOW)
    {
        if( layer_index < element->GetEffectLayerCount()-1)
        {
            element->InsertEffectLayer(layer_index+1);
        }
        else
        {
            element->AddEffectLayer();
        }
        wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
        wxPostEvent(GetParent(), eventRowHeaderChanged);
    }
    else if(id == ID_ROW_MNU_DELETE_LAYER)
    {
        int layerIndex = mSequenceElements->GetVisibleRowInformation(mSelectedRow)->layerIndex;
        wxString prompt = wxString::Format("Delete 'Layer %d' of '%s'?",
                                      layerIndex+1,element->GetName());
        wxString caption = "Confirm Layer Deletion";

        int answer = wxMessageBox(prompt,caption,wxYES_NO);
        if(answer == wxYES)
        {
            element->RemoveEffectLayer(layerIndex);
            wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
            wxPostEvent(GetParent(), eventRowHeaderChanged);
        }
    }
    else if(id == ID_ROW_MNU_ADD_TIMING_TRACK)
    {
        std::string name = wxGetTextFromUser("What is name of new timing track?", "Timing Track Name").ToStdString();
        if( mSequenceElements->ElementExists(name) )
        {
            wxMessageBox("Timing name already exists in sequence as a model or another timing.", "ERROR");
        }
        else if(name.size()>0)
        {
            // Deactivate active timing mark so new one is selected;
            mSequenceElements->DeactivateAllTimingElements();
            int timingCount = mSequenceElements->GetNumberOfTimingElements();
            Element* e = mSequenceElements->AddElement(timingCount,name,
                                                       "timing",true,false,true,false);
            e->AddEffectLayer();
            mSequenceElements->AddTimingToAllViews(name);
            wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
            wxPostEvent(GetParent(), eventRowHeaderChanged);
        }
    }
    else if(id == ID_ROW_MNU_DELETE_TIMING_TRACK)
    {
        wxString prompt = wxString::Format("Delete 'Timing Track '%s'?",element->GetName());
        wxString caption = "Confirm Timing Track Deletion";

        int answer = wxMessageBox(prompt,caption,wxYES_NO);
        if(answer == wxYES)
        {
            mSequenceElements->DeleteElement(element->GetName());
            wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
            wxPostEvent(GetParent(), eventRowHeaderChanged);
        }
    } else if(id == ID_ROW_MNU_IMPORT_TIMING_TRACK) {
        wxCommandEvent playEvent(EVT_IMPORT_TIMING);
        wxPostEvent(GetParent(), playEvent);
    } else if(id == ID_ROW_MNU_IMPORT_LYRICS) {
        mSequenceElements->ImportLyrics(element, GetParent());
    } else if(id == ID_ROW_MNU_BREAKDOWN_TIMING_PHRASES) {
        int result = wxMessageBox("Breakdown phrases? Any existing words and phonemes will be deleted.", "Confirm Action", wxOK | wxCANCEL | wxCENTER);
        if (result == wxOK) {
            BreakdownTimingPhrases(element);
        }
    } else if(id == ID_ROW_MNU_BREAKDOWN_TIMING_WORDS) {
        int result = wxMessageBox("Breakdown words? Any existing phonemes will be deleted.", "Confirm Action", wxOK | wxCANCEL | wxCENTER);
        if (result == wxOK) {
            BreakdownTimingWords(element);
        }
    } else if (id == ID_ROW_MNU_EXPORT_MODEL) {
        wxCommandEvent playEvent(EVT_EXPORT_MODEL);
        playEvent.SetInt(0);
        playEvent.SetString(element->GetName());
        wxPostEvent(GetParent(), playEvent);
    } else if (id == ID_ROW_MNU_EXPORT_RENDERED_MODEL) {
        wxCommandEvent playEvent(EVT_EXPORT_MODEL);
        playEvent.SetInt(1);
        playEvent.SetString(element->GetName());
        wxPostEvent(GetParent(), playEvent);
    } else if (id == ID_ROW_MNU_PLAY_MODEL) {
        wxCommandEvent playEvent(EVT_PLAY_MODEL);
        playEvent.SetString(element->GetName());
        wxPostEvent(GetParent(), playEvent);
    } else if (id == ID_ROW_MNU_COPY_MODEL) {
        wxCommandEvent copyModelEvent(EVT_COPY_MODEL_EFFECTS);
        copyModelEvent.SetInt(mSelectedRow);
        wxPostEvent(GetParent(), copyModelEvent);
        mCanPaste = true;
    } else if (id == ID_ROW_MNU_PASTE_MODEL) {
        wxCommandEvent copyModelEvent(EVT_PASTE_MODEL_EFFECTS);
        copyModelEvent.SetInt(mSelectedRow);
        wxPostEvent(GetParent(), copyModelEvent);
    } else if(id==ID_ROW_MNU_EDIT_DISPLAY_ELEMENTS) {
        wxCommandEvent displayElementEvent(EVT_SHOW_DISPLAY_ELEMENTS);
        wxPostEvent(GetParent(), displayElementEvent);
    } else if (id == ID_ROW_MNU_TOGGLE_STRANDS) {
        element->ShowStrands(!element->ShowStrands());
        wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
        eventRowHeaderChanged.SetString(element->GetName());
        wxPostEvent(GetParent(), eventRowHeaderChanged);
    } else if (id == ID_ROW_MNU_TOGGLE_NODES) {
        if (mSequenceElements->GetVisibleRowInformation(mSelectedRow)->strandIndex == -1) {
            element->GetStrandLayer(0)->ShowNodes(true);
            element->ShowStrands(!element->ShowStrands());
        } else {
            ((StrandLayer*)mSequenceElements->GetVisibleEffectLayer(mSelectedRow))->ShowNodes(!((StrandLayer*)mSequenceElements->GetVisibleEffectLayer(mSelectedRow))->ShowNodes());
        }
        wxCommandEvent eventRowHeaderChanged(EVT_ROW_HEADINGS_CHANGED);
        wxPostEvent(GetParent(), eventRowHeaderChanged);
    } else if (id == ID_ROW_MNU_CONVERT_TO_EFFECTS) {
        wxCommandEvent evt(EVT_CONVERT_DATA_TO_EFFECTS);
        evt.SetClientData(element);
        int i = ((ri->strandIndex << 16) & 0xFFFF0000) + ri->nodeIndex;
        evt.SetInt(i);
        wxPostEvent(GetParent(), evt);
    } else if (id == ID_ROW_MNU_PROMOTE_EFFECTS) {
        wxCommandEvent evt(EVT_PROMOTE_EFFECTS);
        evt.SetClientData(element);
        wxPostEvent(GetParent(), evt);
    }

    // Make sure message box is painted over by grid.
    wxCommandEvent eventForceRefresh(EVT_FORCE_SEQUENCER_REFRESH);
    wxPostEvent(GetParent(), eventForceRefresh);
}
void TOOL_MANAGER::DeactivateTool()
{
    // Deactivate the active tool, but do not run anything new
    TOOL_EVENT evt( TC_COMMAND, TA_CANCEL_TOOL );
    processEvent( evt );
}
Пример #22
0
void PortraitCut::compute() {
  _myStop = false;
  int iter;
  int step_counter = 0, step;
  double E, E_old;

  /*initializeResult();
  for (step=0; step<_n; ++step) {
  float score = 0;
  for (int j=0; j<_h; ++j)
  for (int i=0; i<_w; ++i) 
  score += BVZ_data_penalty(Coord(i,j), step);
  fprintf(_fp,"Step %d scores %f\n",step, score); fflush(_fp);
  }
  return;*/


  fprintf(_fp, "%d images:\n",_n);
  //for (iter=0; iter<_n; ++iter)
  //fprintf(_fp,"dim: %d %d, displace: %d %d\n",
  //(*_images)[iter]->_size.x,(*_images)[iter]->_size.y,
  //  (*_images)[iter]->_displacement.x,(*_images)[iter]->_displacement.y);
  fflush(_fp);


  //initializeResult();  
  E = BVZ_ComputeEnergy();
  fprintf(_fp,"Starting E = %f\n",E);
  //exit(0);
  for (iter=0; iter<_ITER_MAX_ && step_counter<_n; ++iter) { 
    
    for (step=0; step<_n && step_counter<_n; step++) { 
      E_old = E;

	  
      //while (!SINGLE_THREAD && dataMutex->Lock () != wxMUTEX_NO_ERROR)
      //Sleep (10);
      
      E = BVZ_Expand(step, E_old);
      //if(!SINGLE_THREAD)
      //dataMutex->Unlock ();

      fprintf(_fp,"new %f\n",E);
      //assert (E <= E_old);
      if (E_old == E) step_counter ++;
      else            step_counter = 0;      
      fprintf(_fp,"iteration %d, label %d, E = %f\n",iter, step, E);
      fflush(_fp);


      /*if (E < E_old && !SINGLE_THREAD) {
	wxCommandEvent evt(TH_REFRESH_VIEWER);
	wxPostEvent (_th_frame, evt);
	wxTheApp->Yield();
	//Sleep (10);
      }

      if (!SINGLE_THREAD && _myStop)
	return;
      */

      if (_myStop) return;
      wxCommandEvent evt(TH_REFRESH_VIEWER);
      wxPostEvent (_th_frame, evt);
      wxTheApp->Yield();
    }
    
  }
  /*
  if (!SINGLE_THREAD) {
    wxCommandEvent evt(TH_REFRESH_VIEWER);
    _th_frame->ProcessEvent(evt);
    wxCommandEvent evt2(END_GLOBAL_COMPUTE);
    wxPostEvent(_th_frame, evt2);
  }
  */
}
Пример #23
0
// -------------------------------------------------------------------
// OnUDPData
// -------------------------------------------------------------------
void UDPManager::OnUDPData(unsigned long long context, boost::shared_ptr<vector<unsigned char> > bt)
{
	// Map context
	UDPManager* instance = (UDPManager*)context;

	boost::shared_ptr<ByteArray> bytes (new ByteArray(bt));

	// Not enough data!
	if (bytes->BytesAvailable() < 4) {
		char buffer[512];
		sprintf (buffer, "Too small UDP packet. Len: %ld", bytes->Length());
		string logMessage = buffer;

		boost::shared_ptr<vector<string> > logMessages (new vector<string>());
		logMessages->push_back(logMessage);
		instance->log->Warn(logMessages);

		return;
	}

	if (instance->sfs->Debug()) {

		boost::shared_ptr<vector<string> > logMessages (new vector<string>());
		logMessages->push_back("UDP Data Read: ");
		logMessages->push_back(*(DefaultObjectDumpFormatter::HexDump(bytes)));
		instance->log->Info(logMessages);
	}

	// Skip the header byte
	unsigned char header;
	bytes->ReadByte(header);

	// Get the compression and encryption flags
	bool compressed = (header & 0x20) > 0; 
	bool encrypted = (header & 0x40) > 0;

	// Read the size of message (UDP can only use the short version)
	short dataSize;
	bytes->ReadShort(dataSize);

	if (dataSize != bytes->BytesAvailable()) {
		char buffer[512];
		sprintf (buffer, "Insufficient UDP data. Expected: %ld, got: %ld", dataSize, bytes->BytesAvailable());
		string logMessage = buffer;

		boost::shared_ptr<vector<string> > logMessages (new vector<string>());
		logMessages->push_back(logMessage);
		instance->log->Warn(logMessages);

		return;
	}

	// Grab the message body and deserialize it
	boost::shared_ptr<vector<unsigned char> > data (new vector<unsigned char>());
	bytes->ReadBytes(bytes->BytesAvailable(), *(data.get()));
	boost::shared_ptr<ByteArray> objBytes (new ByteArray(data));

	// Handle encryption
	if (encrypted)
	{
		try 
		{
			instance->packetEncrypter->Decrypt(objBytes);
		}
		catch(exception ex) {

			boost::shared_ptr<string> message (new string(ex.what()));

			char buffer[512];
			sprintf (buffer, "UDP data decryption failed due to error: %s", message->c_str());
			string logMessage = buffer;

			boost::shared_ptr<vector<string> > logMessages (new vector<string>());
			logMessages->push_back(logMessage);
			instance->log->Error(logMessages);

			return;
		}
	}

	// Handle compression
	if (compressed) {
		objBytes->Uncompress();
	}

	boost::shared_ptr<ISFSObject> reqObj = SFSObject::NewFromBinaryData(objBytes);

	// Check if this is an UDP Handshake response. If so, fire event and stop here.
	if (reqObj->ContainsKey("h")) {
		if (!instance->initSuccess) {
			// Unlock
			instance->StopTimer();
			instance->locked = false;
			instance->initSuccess = true;

			boost::shared_ptr<map<string, boost::shared_ptr<void> > > evtParams (new map<string, boost::shared_ptr<void> >());
			boost::shared_ptr<bool> value (new bool());
			*value = true;
			evtParams->insert(pair<string, boost::shared_ptr<void> >("success", value));
			boost::shared_ptr<SFSEvent> evt (new SFSEvent(SFSEvent::UDP_INIT, evtParams));
			instance->sfs->DispatchEvent(evt);
		}
		return;
	}
			
	// Hand it to the ProtocolCodec
	instance->sfs->GetSocketEngine()->IoHandler()->Codec()->OnPacketRead(reqObj);
}
Пример #24
0
LRESULT CALLBACK Win32Loop::processEvent( HWND hwnd, UINT msg,
                                          WPARAM wParam, LPARAM lParam )
{
    Win32Factory *pFactory =
        (Win32Factory*)Win32Factory::instance( getIntf() );
    GenericWindow *pWin = pFactory->m_windowMap[hwnd];

    GenericWindow &win = *pWin;
    switch( msg )
    {
        case WM_PAINT:
        {
            PAINTSTRUCT Infos;
            BeginPaint( hwnd, &Infos );
            EvtRefresh evt( getIntf(),
                            Infos.rcPaint.left,
                            Infos.rcPaint.top,
                            Infos.rcPaint.right - Infos.rcPaint.left + 1,
                            Infos.rcPaint.bottom - Infos.rcPaint.top + 1 );
            win.processEvent( evt );
            EndPaint( hwnd, &Infos );
            return 0;
        }
        case WM_COMMAND:
        {
            EvtMenu evt( getIntf(), LOWORD( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSEMOVE:
        {
            // Needed to generate WM_MOUSELEAVE events
            TRACKMOUSEEVENT TrackEvent;
            TrackEvent.cbSize      = sizeof( TRACKMOUSEEVENT );
            TrackEvent.dwFlags     = TME_LEAVE;
            TrackEvent.hwndTrack   = hwnd;
            TrackEvent.dwHoverTime = 1;
            TrackMouseEvent( &TrackEvent );

            // Compute the absolute position of the mouse
            int x = GET_X_LPARAM( lParam ) + win.getLeft();
            int y = GET_Y_LPARAM( lParam ) + win.getTop();
            EvtMotion evt( getIntf(), x, y );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSELEAVE:
        {
            EvtLeave evt( getIntf() );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSEWHEEL:
        {
            int x = GET_X_LPARAM( lParam ) - win.getLeft();
            int y = GET_Y_LPARAM( lParam ) - win.getTop();
            int mod = getMod( wParam );
            if( GET_WHEEL_DELTA_WPARAM( wParam ) > 0 )
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kUp, mod );
                win.processEvent( evt );
            }
            else
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kDown, mod );
                win.processEvent( evt );
            }
            return 0;
        }
        case WM_LBUTTONDOWN:
        {
            SetCapture( hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kDown, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONDOWN:
        {
            SetCapture( hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kDown, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_LBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kUp, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kUp, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_LBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kDblClick, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kDblClick, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        case WM_KEYUP:
        case WM_SYSKEYUP:
        {
            // The key events are first processed here and not translated
            // into WM_CHAR events because we need to know the status of
            // the modifier keys.

            // Get VLC key code from the virtual key code
            int key = virtKeyToVlcKey[wParam];
            if( !key )
            {
                // This appears to be a "normal" (ascii) key
                key = tolower( (unsigned char)MapVirtualKey( wParam, 2 ) );
            }

            if( key )
            {
                // Get the modifier
                int mod = 0;
                if( GetKeyState( VK_CONTROL ) & 0x8000 )
                {
                    mod |= EvtInput::kModCtrl;
                }
                if( GetKeyState( VK_SHIFT ) & 0x8000 )
                {
                    mod |= EvtInput::kModShift;
                }
                if( GetKeyState( VK_MENU ) & 0x8000 )
                {
                    mod |= EvtInput::kModAlt;
                }

                // Get the state
                EvtKey::ActionType_t state;
                if( msg == WM_KEYDOWN ||
                    msg == WM_SYSKEYDOWN )
                {
                    state = EvtKey::kDown;
                }
                else
                {
                    state = EvtKey::kUp;
                }

                EvtKey evt( getIntf(), key, state, mod );
                win.processEvent( evt );
            }
            return 0;
        }
        default:
            break;
    }
    return DefWindowProc( hwnd, msg, wParam, lParam );;
}
Пример #25
0
void GenerateDlg::Finished()
{
	wxCommandEvent evt(genEnd, GetId());
	evt.SetEventObject(this);
	wxPostEvent(this, evt);
}
Пример #26
0
static ibool MGLAPI wxWindowMouseHandler(window_t *wnd, event_t *e)
{
    wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
    wxPoint orig(win->GetClientAreaOrigin());
    wxPoint where;

    g_buttonState = e->modifiers;

    MGL_wmCoordGlobalToLocal(win->GetHandle(),
                             e->where_x, e->where_y, &where.x, &where.y);

    for (wxWindowMGL *w = win; w; w = w->GetParent())
    {
        if ( !w->IsEnabled() )
            return FALSE;
        if ( w->IsTopLevel() )
            break;
    }

    wxEventType type = wxEVT_NULL;
    wxMouseEvent event;
    event.SetEventObject(win);
    event.SetTimestamp(e->when);
    event.m_x = where.x - orig.x;
    event.m_y = where.y - orig.y;
    event.m_shiftDown = ( e->modifiers & EVT_SHIFTKEY ) != 0;
    event.m_controlDown = ( e->modifiers & EVT_CTRLSTATE ) != 0;
    event.m_altDown = ( e->modifiers & EVT_LEFTALT ) != 0;
    event.m_metaDown = ( e->modifiers & EVT_RIGHTALT ) != 0;
    event.m_leftDown = ( e->modifiers & EVT_LEFTBUT ) != 0;
    event.m_middleDown = ( e->modifiers & EVT_MIDDLEBUT ) != 0;
    event.m_rightDown = ( e->modifiers & EVT_RIGHTBUT ) != 0;

    switch (e->what)
    {
        case EVT_MOUSEDOWN:
            // Change focus if the user clicks outside focused window:
            if ( win->CanAcceptFocus() && wxWindow::FindFocus() != win )
                win->SetFocus();

            if ( e->message & EVT_DBLCLICK )
            {
                if ( e->message & EVT_LEFTBMASK )
                    type = wxEVT_LEFT_DCLICK;
                else if ( e->message & EVT_MIDDLEBMASK )
                    type = wxEVT_MIDDLE_DCLICK;
                else if ( e->message & EVT_RIGHTBMASK )
                    type = wxEVT_RIGHT_DCLICK;
            }
            else
            {
                if ( e->message & EVT_LEFTBMASK )
                    type = wxEVT_LEFT_DOWN;
                else if ( e->message & EVT_MIDDLEBMASK )
                    type = wxEVT_MIDDLE_DOWN;
                else if ( e->message & EVT_RIGHTBMASK )
                    type = wxEVT_RIGHT_DOWN;
            }

            break;

        case EVT_MOUSEUP:
            if ( e->message & EVT_LEFTBMASK )
                type = wxEVT_LEFT_UP;
            else if ( e->message & EVT_MIDDLEBMASK )
                type = wxEVT_MIDDLE_UP;
            else if ( e->message & EVT_RIGHTBMASK )
                type = wxEVT_RIGHT_UP;
            break;

        case EVT_MOUSEMOVE:
            if ( !gs_mouseCapture )
            {
                if ( win != gs_windowUnderMouse )
                {
                    if ( gs_windowUnderMouse )
                    {
                        wxMouseEvent event2(event);
                        MGL_wmCoordGlobalToLocal(gs_windowUnderMouse->GetHandle(),
                                                 e->where_x, e->where_y,
                                                 &event2.m_x, &event2.m_y);

                        wxPoint orig(gs_windowUnderMouse->GetClientAreaOrigin());
                        event2.m_x -= orig.x;
                        event2.m_y -= orig.y;

                        event2.SetEventObject(gs_windowUnderMouse);
                        event2.SetEventType(wxEVT_LEAVE_WINDOW);
                        gs_windowUnderMouse->HandleWindowEvent(event2);
                    }

                    wxMouseEvent event3(event);
                    event3.SetEventType(wxEVT_ENTER_WINDOW);
                    win->HandleWindowEvent(event3);

                    gs_windowUnderMouse = win;
                }
            }
            else // gs_mouseCapture
            {
                bool inside = (where.x >= 0 &&
                               where.y >= 0 &&
                               where.x < win->GetSize().x &&
                               where.y < win->GetSize().y);
                if ( (inside && gs_windowUnderMouse != win) ||
                     (!inside && gs_windowUnderMouse == win) )
                {
                    wxMouseEvent evt(inside ?
                                     wxEVT_ENTER_WINDOW : wxEVT_LEAVE_WINDOW);
                    evt.SetEventObject(win);
                    win->HandleWindowEvent(evt);
                    gs_windowUnderMouse = inside ? win : NULL;
                }
            }

            type = wxEVT_MOTION;
            break;

        default:
            break;
    }

    if ( type == wxEVT_NULL )
    {
        return FALSE;
    }
    else
    {
        event.SetEventType(type);
        return win->HandleWindowEvent(event);
    }
}
Пример #27
0
 //--------------------------------------------------------------
 /// \brief	    Send empty event (without data)
 /// \param[in] id Event id
 //--------------------------------------------------------------
 void postEvent(int id)
 {
    boost::shared_ptr<CEventBase> evt(new CEventBase(id));
    postEvent(evt);
 }
Пример #28
0
wxThread::ExitCode MyThread::Entry()
{
	unsigned int st_time = GET_TICK_COUNT();

	DatabaseDlg *dd = (DatabaseDlg *)m_pParent;
	wxTreeItemId rootitem = dd->m_searchResult->GetRootItem();

	if (!m_results.empty()) m_results.clear();

	if (m_cats)
	{
		int catnum = m_cats->size();
		int schtxtnum = m_schtxts.size();

		for (int i = m_cur_cat; i < catnum; i++)
		{
			int itemnum = (*m_cats)[i].items.size();
			for (int j = m_cur_item; j < itemnum; j++)
			{
				bool found = false;
				for (int k = 0; k < schtxtnum; k++)
				{
					if (!m_schtxts[k].IsEmpty() && (*m_cats)[i].items[j]->desc.Find(m_schtxts[k]) != -1) found = true;
				}

				//if(found) m_results.push_back((*m_cats)[i].items[j]);

				if(found)
				{
					//dd->SetEvtHandlerEnabled(false);
					wxTreeItemId item = dd->m_searchResult->AppendItem(rootitem, (*m_cats)[i].items[j]->name + wxT(" (") + (*m_cats)[i].items[j]->cat_name + wxT(")"), 0);
					DBItemInfo* item_data = new DBItemInfo( *((*m_cats)[i].items[j]) );
					dd->m_searchResult->SetItemData(item, item_data);
					//dd->SetEvtHandlerEnabled(true);
				}
				//wxUsleep(10);

				m_progress++;

				unsigned int rn_time = GET_TICK_COUNT();
				if (rn_time - st_time > m_time_limit || TestDestroy())
				{
					wxCommandEvent evt(TestDestroy() ? wxEVT_MYTHREAD_COMPLETED: wxEVT_MYTHREAD_PAUSED, GetId());
					MyThreadData *data = new MyThreadData;
					data->m_cur_cat = i;
					data->m_cur_item = j + 1;
					data->m_progress = m_progress;
					data->m_results = m_results;
					evt.SetClientData(data);
					wxPostEvent(m_pParent, evt);
					if (m_gauge) m_gauge->SetValue(m_progress);
					return 0;
				}
			}
			m_cur_item = 0;
		}
	}

	wxCommandEvent evt(wxEVT_MYTHREAD_COMPLETED, GetId());
	MyThreadData *data = new MyThreadData;
	data->m_cur_cat = m_cur_cat;
	data->m_cur_item = m_cur_item;
	data->m_progress = m_progress;
	data->m_results = m_results;
	evt.SetClientData(data);
	wxPostEvent(m_pParent, evt);

	return 0;
}
Пример #29
0
CtrlGeneric *TopWindow::findHitControl( int xPos, int yPos )
{
    if( m_pActiveLayout == NULL )
    {
        return NULL;
    }

    // Get the controls in the active layout
    const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
    list<LayeredControl>::const_reverse_iterator iter;

    // New control hit by the mouse
    CtrlGeneric *pNewHitControl = NULL;

    // Loop on the control list to find the uppest hit control
    for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); ++iter )
    {
        // Get the position of the control in the layout
        const Position *pos = (*iter).m_pControl->getPosition();
        if( pos != NULL )
        {
            // Compute the coordinates of the mouse relative to the control
            int xRel = xPos - pos->getLeft();
            int yRel = yPos - pos->getTop();

            CtrlGeneric *pCtrl = (*iter).m_pControl;
            // Control hit ?
            if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
            {
                pNewHitControl = (*iter).m_pControl;
                break;
            }
        }
        else
        {
            msg_Dbg( getIntf(), "control at NULL position" );
        }
    }

    // If the hit control has just been entered, send it an enter event
    if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
    {
        // Don't send the event if another control captured the mouse
        if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
        {
            EvtEnter evt( getIntf() );
            pNewHitControl->handleEvent( evt );

            if( !m_pCapturingControl )
            {
                // Show the tooltip
                m_rWindowManager.hideTooltip();
                UString tipText = pNewHitControl->getTooltipText();
                if( tipText.length() > 0 )
                {
                    // Set the tooltip text variable
                    VarManager *pVarManager = VarManager::instance( getIntf() );
                    pVarManager->getTooltipText().set( tipText );
                    m_rWindowManager.showTooltip();
                }
            }
        }
    }

    return pNewHitControl;
}
Пример #30
0
bool EventTarget::dispatchGenericEvent(EventTargetNode* referenceNode, PassRefPtr<Event> e, ExceptionCode&, bool tempEvent)
{
    RefPtr<Event> evt(e);

    ASSERT(!eventDispatchForbidden());
    ASSERT(evt->target());
    ASSERT(!evt->type().isNull()); // JavaScript code could create an event with an empty name

    // work out what nodes to send event to
    DeprecatedPtrList<Node> nodeChain;

    if (referenceNode->inDocument()) {
        for (Node* n = referenceNode; n; n = n->eventParentNode()) {
            n->ref();
            nodeChain.prepend(n);
        }
    } else {
        // if node is not in the document just send event to itself 
        referenceNode->ref();
        nodeChain.prepend(referenceNode);
    }

    DeprecatedPtrListIterator<Node> it(nodeChain);

    // Before we begin dispatching events, give the target node a chance to do some work prior
    // to the DOM event handlers getting a crack.
    void* data = preDispatchEventHandler(evt.get());

    // trigger any capturing event handlers on our way down
    evt->setEventPhase(Event::CAPTURING_PHASE);
    it.toFirst();

    // Handle window events for capture phase, except load events, this quirk is needed
    // because Mozilla used to never propagate load events to the window object
    if (evt->type() != eventNames().loadEvent && it.current()->isDocumentNode() && !evt->propagationStopped())
        static_cast<Document*>(it.current())->handleWindowEvent(evt.get(), true);

    EventTargetNode* eventTargetNode = 0;
    for (; it.current() && it.current() != referenceNode && !evt->propagationStopped(); ++it) {
        eventTargetNode = EventTargetNodeCast(it.current());
        evt->setCurrentTarget(eventTargetRespectingSVGTargetRules(eventTargetNode));

        eventTargetNode->handleLocalEvents(evt.get(), true);
    }

    // dispatch to the actual target node
    it.toLast();

    if (!evt->propagationStopped()) {
        evt->setEventPhase(Event::AT_TARGET);

        eventTargetNode = EventTargetNodeCast(it.current());
        evt->setCurrentTarget(eventTargetRespectingSVGTargetRules(eventTargetNode));

        // We do want capturing event listeners to be invoked here, even though
        // that violates the specification since Mozilla does it.
        eventTargetNode->handleLocalEvents(evt.get(), true);

        eventTargetNode->handleLocalEvents(evt.get(), false);
    }

    --it;

    // ok, now bubble up again (only non-capturing event handlers will be called)
    // ### recalculate the node chain here? (e.g. if target node moved in document by previous event handlers)
    // no. the DOM specs says:
    // The chain of EventTargets from the event target to the top of the tree
    // is determined before the initial dispatch of the event.
    // If modifications occur to the tree during event processing,
    // event flow will proceed based on the initial state of the tree.
    //
    // since the initial dispatch is before the capturing phase,
    // there's no need to recalculate the node chain.
    // (tobias)

    if (evt->bubbles()) {
        evt->setEventPhase(Event::BUBBLING_PHASE);

        for (; it.current() && !evt->propagationStopped() && !evt->cancelBubble(); --it) {
            eventTargetNode = EventTargetNodeCast(it.current());
            evt->setCurrentTarget(eventTargetRespectingSVGTargetRules(eventTargetNode));

            eventTargetNode->handleLocalEvents(evt.get(), false);
        }

        it.toFirst();

        // Handle window events for bubbling phase, except load events, this quirk is needed
        // because Mozilla used to never propagate load events at all
        if (evt->type() != eventNames().loadEvent && it.current()->isDocumentNode() && !evt->propagationStopped() && !evt->cancelBubble()) {
            evt->setCurrentTarget(EventTargetNodeCast(it.current()));
            static_cast<Document*>(it.current())->handleWindowEvent(evt.get(), false);
        } 
    }

    evt->setCurrentTarget(0);
    evt->setEventPhase(0); // I guess this is correct, the spec does not seem to say
                           // anything about the default event handler phase.


    // Now call the post dispatch.
    postDispatchEventHandler(evt.get(), data);

    // now we call all default event handlers (this is not part of DOM - it is internal to WebCore)
    it.toLast();

    if (evt->bubbles())
        for (; it.current() && !evt->defaultPrevented() && !evt->defaultHandled(); --it)
            EventTargetNodeCast(it.current())->defaultEventHandler(evt.get());
    else if (!evt->defaultPrevented() && !evt->defaultHandled())
        EventTargetNodeCast(it.current())->defaultEventHandler(evt.get());

    // deref all nodes in chain
    it.toFirst();
    for (; it.current(); ++it)
        it.current()->deref(); // this may delete us

    Document::updateDocumentsRendering();

    // If tempEvent is true, this means that the DOM implementation
    // will not be storing a reference to the event, i.e.  there is no
    // way to retrieve it from javascript if a script does not already
    // have a reference to it in a variable.  So there is no need for
    // the interpreter to keep the event in it's cache
    Frame* frame = referenceNode->document()->frame();
    if (tempEvent && frame && frame->script()->isEnabled())
        frame->script()->finishedWithEvent(evt.get());

    return !evt->defaultPrevented(); // ### what if defaultPrevented was called before dispatchEvent?
}