void CDisplayText::HideText(bool bHide) { Ui::CWindow* pw; Ui::CGroup* pg; Ui::CLabel* pl; Ui::CButton* pb; int i; m_bHide = bHide; pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return; for ( i=0 ; i<MAXDTLINE ; i++ ) { pg = static_cast<Ui::CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i))); if ( pg != 0 ) { pg->SetState(STATE_VISIBLE, !bHide); } pl = static_cast<Ui::CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i))); if ( pl != 0 ) { pl->SetState(STATE_VISIBLE, !bHide); } pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb != 0 ) { pb->SetState(STATE_VISIBLE, !bHide); } } }
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback) { if (event_type >= (int) event_types.size()) event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT")); event_types[event_type] = EventType(callback, name); }
// ---------------------------------------------------------------------- void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int flavor, UInt64 guid, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_KeyboardSpecialEventCallback::log(true, EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ Params_KeyboardSpecialEventCallback params(EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (!device) return; ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get(device)); if (!item) return; // ------------------------------------------------------------ // Device Hacks // Drop events if "Disable an internal keyboard while external keyboards are connected" is enabled. if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_internal_keyboard_if_external_keyboard_exsits)) { if (item->isInternalDevice() && ListHookedKeyboard::instance().isExternalDevicesConnected()) { return; } } // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); setTimer(); }
void CDisplayText::ClearText() { Ui::CWindow* pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); for (int i = 0; i < MAXDTLINE; i++) { if (pw != nullptr) { pw->DeleteControl(EventType(EVENT_DT_GROUP0+i)); pw->DeleteControl(EventType(EVENT_DT_LABEL0+i)); pw->DeleteControl(EventType(EVENT_DT_VISIT0+i)); } m_textLines[i] = TextLine(); } }
void CDownloadQueue::AddDownload(CPartFile* file, bool paused, uint8 category) { wxCHECK_RET(!IsFileExisting(file->GetFileHash()), wxT("Adding duplicate part-file")); if (file->GetStatus(true) == PS_ALLOCATING) { file->PauseFile(); } else if (paused && GetFileCount()) { file->StopFile(); } { wxMutexLocker lock(m_mutex); m_filelist.push_back( file ); DoSortByPriority(); } NotifyObservers( EventType( EventType::INSERTED, file ) ); if (category < theApp->glob_prefs->GetCatCount()) { file->SetCategory(category); } else { AddDebugLogLineN( logDownloadQueue, wxT("Tried to add download into invalid category.") ); } Notify_DownloadCtrlAddFile( file ); theApp->searchlist->UpdateSearchFileByHash(file->GetFileHash()); // Update file in the search dialog if it's still open AddLogLineC(CFormat(_("Downloading %s")) % file->GetFileName() ); }
void CServerList::RemoveServer(CServer* in_server) { if (in_server == theApp->serverconnect->GetCurrentServer()) { theApp->ShowAlert(_("You are connected to the server you are trying to delete. please disconnect first."), _("Info"), wxOK); } else { CInternalList::iterator it = std::find(m_servers.begin(), m_servers.end(), in_server); if ( it != m_servers.end() ) { if (theApp->downloadqueue->GetUDPServer() == in_server) { theApp->downloadqueue->SetUDPServer( 0 ); } NotifyObservers( EventType( EventType::REMOVED, in_server ) ); if (m_serverpos == it) { ++m_serverpos; } if (m_statserverpos == it) { ++m_statserverpos; } m_servers.erase(it); theStats::DeleteServer(); Notify_ServerRemove(in_server); delete in_server; } } }
void RuleWidget::applyConfiguration(void) { try { Rule *rule=nullptr; unsigned count, i; startConfiguration<Rule>(); rule=dynamic_cast<Rule *>(this->object); rule->setEventType(EventType(event_cmb->currentText())); rule->setExecutionType(ExecutionType(exec_type_cmb->currentText())); rule->setConditionalExpression(cond_expr_txt->toPlainText().toUtf8()); rule->removeCommands(); count=commands_tab->getRowCount(); for(i=0; i < count; i++) rule->addCommand(commands_tab->getCellText(i,0).toUtf8()); BaseObjectWidget::applyConfiguration(); finishConfiguration(); } catch(Exception &e) { cancelConfiguration(); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void DoState(PointerWrap &p) { std::lock_guard<std::recursive_mutex> lk(externalEventSection); auto s = p.Section("CoreTiming", 1, 2); if (!s) return; int n = (int) event_types.size(); p.Do(n); // These (should) be filled in later by the modules. event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT")); p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL); p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast); p.Do(CPU_HZ); p.Do(slicelength); p.Do(globalTimer); p.Do(idledCycles); if (s >= 2) { p.Do(lastGlobalTimeTicks); p.Do(lastGlobalTimeUs); } else { lastGlobalTimeTicks = 0; lastGlobalTimeUs = 0; } }
static const std::vector<EventType> GetTracepointEventTypes() { std::vector<EventType> result; const std::string tracepoint_dirname = "/sys/kernel/debug/tracing/events"; std::vector<std::string> system_dirs; GetEntriesInDir(tracepoint_dirname, nullptr, &system_dirs); for (auto& system_name : system_dirs) { std::string system_path = tracepoint_dirname + "/" + system_name; std::vector<std::string> event_dirs; GetEntriesInDir(system_path, nullptr, &event_dirs); for (auto& event_name : event_dirs) { std::string id_path = system_path + "/" + event_name + "/id"; std::string id_content; if (!android::base::ReadFileToString(id_path, &id_content)) { continue; } char* endptr; uint64_t id = strtoull(id_content.c_str(), &endptr, 10); if (endptr == id_content.c_str()) { LOG(DEBUG) << "unexpected id '" << id_content << "' in " << id_path; continue; } result.push_back(EventType(system_name + ":" + event_name, PERF_TYPE_TRACEPOINT, id)); } } std::sort(result.begin(), result.end(), [](const EventType& type1, const EventType& type2) { return type1.name < type2.name; }); return result; }
void MidiEventBase::read(Xml& xml) { setType(Note); a = 0; b = 0; c = 0; int dataLen = 0; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown("Event"); break; case Xml::Text: { QByteArray ba = tag.toLatin1(); const char*s = ba.constData(); edata.data = new unsigned char[dataLen]; edata.dataLen = dataLen; unsigned char* d = edata.data; for (int i = 0; i < dataLen; ++i) { char* endp; *d++ = strtol(s, &endp, 16); s = endp; } } break; case Xml::Attribut: if (tag == "tick") setTick(xml.s2().toInt()); else if (tag == "type") setType(EventType(xml.s2().toInt())); else if (tag == "len") setLenTick(xml.s2().toInt()); else if (tag == "a") a = xml.s2().toInt(); else if (tag == "b") b = xml.s2().toInt(); else if (tag == "c") c = xml.s2().toInt(); else if (tag == "datalen") dataLen = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "event") return; default: break; } } }
void CDownloadQueue::RemoveFile(CPartFile* file) { RemoveLocalServerRequest( file ); NotifyObservers( EventType( EventType::REMOVED, file ) ); wxMutexLocker lock( m_mutex ); EraseValue( m_filelist, file ); }
void CServerList::ObserverAdded( ObserverType* o ) { CObservableQueue<CServer*>::ObserverAdded( o ); EventType::ValueList ilist; ilist.reserve( m_servers.size() ); ilist.assign( m_servers.begin(), m_servers.end() ); NotifyObservers( EventType( EventType::INITIAL, &ilist ), o ); }
/** Method that computes the result for the smoothing. */ void compute( Measurement::Timestamp t ) { if( !m_init ){ m_mean = *( m_inPort.get() ); m_init = true; } else m_mean = ( m_alpha * ( *( m_inPort.get() ) ) ) + ( ( 1. - m_alpha ) * m_mean ); LOG4CPP_TRACE( logger, "exponential smoothing: " << m_mean ); m_outPort.send( EventType( t, m_mean ) ); }
void CServerList::RemoveAllServers() { NotifyObservers( EventType( EventType::CLEARED ) ); theStats::DeleteAllServers(); // no connection, safely remove all servers while ( !m_servers.empty() ) { delete m_servers.back(); m_servers.pop_back(); } m_serverpos = m_servers.end(); m_statserverpos = m_servers.end(); }
void CDisplayText::ClearText() { Ui::CWindow* pw; int i; pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); for ( i=0 ; i<MAXDTLINE ; i++ ) { if ( pw != 0 ) { pw->DeleteControl(EventType(EVENT_DT_GROUP0+i)); pw->DeleteControl(EventType(EVENT_DT_LABEL0+i)); pw->DeleteControl(EventType(EVENT_DT_VISIT0+i)); } m_bExist[i] = false; m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f); m_visitDist[i] = 0.0f; m_visitHeight[i] = 0.0f; m_time[i] = 0.0f; } }
void CDownloadQueue::ObserverAdded( ObserverType* o ) { CObservableQueue<CPartFile*>::ObserverAdded( o ); EventType::ValueList list; { wxMutexLocker lock(m_mutex); list.reserve( m_filelist.size() ); list.insert( list.begin(), m_filelist.begin(), m_filelist.end() ); } NotifyObservers( EventType( EventType::INITIAL, &list ), o ); }
void AllegroFlasher::run() { const int zero = 0; timer = al_create_timer(1.0 / FPS.at(zero)); display = al_create_display(width, height); event_queue = al_create_event_queue(); al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_mouse_event_source()); al_start_timer(timer); // Start the timer int counter = 0; while(!done) // Main loop { EVENT Event = EventType(); // Wait for an event to occur if (Event == ESCAPE) { // Quit the program counter = frames.at(zero); break; } else if (Event == UPDATE) { // A timer event if(useBlankStart && counter < frames.at(zero)/2) displayBlankScreen(); // Simply display a black screen else updateDisplay(); counter++; } else if (Event == UP) { moveBlock(UP); } else if (Event == DOWN) { moveBlock(DOWN); } else if (Event == LEFT) { moveBlock(LEFT); } else if (Event == RIGHT) { moveBlock(RIGHT); } if(counter == frames.at(zero)) done = true; } al_destroy_timer(timer); al_destroy_display(display); al_destroy_event_queue(event_queue); done = false; // Set again for the next time }
void CDownloadQueue::RemoveFile(CPartFile* file, bool keepAsCompleted) { RemoveLocalServerRequest( file ); NotifyObservers( EventType( EventType::REMOVED, file ) ); wxMutexLocker lock( m_mutex ); EraseValue( m_filelist, file ); if (keepAsCompleted) { m_completedDownloads.push_back(file); } }
bool CDisplayText::IsVisit(EventType event) { Ui::CWindow* pw; Ui::CButton* pb; int i; i = event-EVENT_DT_VISIT0; if ( i < 0 || i >= MAXDTLINE ) return false; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return false; pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == 0 ) return false; return (pb->GetIcon() == 48); // > ? }
void CDisplayText::SetVisit(EventType event) { Ui::CWindow* pw; Ui::CButton* pb; int i; i = event-EVENT_DT_VISIT0; if ( i < 0 || i >= MAXDTLINE ) return; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == nullptr ) return; pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == nullptr ) return; pb->SetIcon(48); // > }
void Engine::StartUp() { SINGLETONINSTANCE(Profiler)->StartUp(); SINGLETONINSTANCE(Profiler)->Begin("StartUp"); lastTime = Time::GetCurrentMS(); m_Window = new Window(); m_Window->StartUp(); m_SettingsManager = new SettingsManager(); m_SettingsManager->StartUp(); m_EventManager = new EventManager(); m_EventManager->StartUp("Global event manager", true); //Register useful event types. m_EventManager->AddRegisteredEventType( EventType ("keydownEvent") ); m_EventManager->AddRegisteredEventType( EventType ("mouseClickPositionEvent") ); m_EventManager->AddRegisteredEventType( EventType ("mouseClickHUDEvent") ); //IMPORTANT: Call this before m_Graphics->StartUp() m_Physics = SINGLETONINSTANCE(PhysicsSystem); m_Physics->StartUp(); m_Graphics = new GraphicsSystem(); m_Graphics->StartUp(); m_FPSCalculator = new FPSCalculator(); m_FPSCalculator->StartUp(); m_SingleFrameAllocator = new StackAllocator(MB(100)); m_Running = false; SINGLETONINSTANCE(Profiler)->End("StartUp"); }
void CDisplayText::ClearVisit() { Ui::CWindow* pw; Ui::CButton* pb; int i; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return; for ( i=0 ; i<MAXDTLINE ; i++ ) { pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i))); if ( pb == 0 ) break; pb->SetIcon(14); // eyes } }
void DoState(PointerWrap &p) { std::lock_guard<std::recursive_mutex> lk(externalEventSection); int n = (int) event_types.size(); p.Do(n); // These (should) be filled in later by the modules. event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT")); p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL); p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast); p.Do(CPU_HZ); p.Do(downcount); p.Do(slicelength); p.Do(globalTimer); p.Do(idledCycles); p.DoMarker("CoreTiming"); }
// ---------------------------------------------------------------------- void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target, unsigned int eventType, unsigned int flags, unsigned int key, unsigned int flavor, UInt64 guid, bool repeat, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (! lk) return; Params_KeyboardSpecialEventCallback::log(true, EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat); // ------------------------------------------------------------ Params_KeyboardSpecialEventCallback::auto_ptr ptr(Params_KeyboardSpecialEventCallback::alloc(EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat)); if (! ptr) return; Params_KeyboardSpecialEventCallback& params = *ptr; // ------------------------------------------------------------ IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender); if (! device) return; ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get(device)); if (! item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ // Because we handle the key repeat ourself, drop the key repeat by hardware. if (repeat) return; // ------------------------------------------------------------ bool retainFlagStatusTemporaryCount = false; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); setTimer(); }
bool CDisplayText::ClearLastText() { Ui::CWindow *pw; Ui::CButton *pb1, *pb2; Ui::CGroup *pg1, *pg2; Ui::CLabel *pl1, *pl2; int i; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) return false; pb2 = static_cast<CButton*>(pw->SearchControl(EVENT_DT_VISIT0)); if ( pb2 == 0 ) return false; // same not of first-line pg2 = static_cast<CGroup*>(pw->SearchControl(EVENT_DT_GROUP0)); if ( pg2 == 0 ) return false; pl2 = static_cast<CLabel*>(pw->SearchControl(EVENT_DT_LABEL0)); if ( pl2 == 0 ) return false; for ( i=0 ; i<MAXDTLINE-1 ; i++ ) { pb1 = pb2; pg1 = pg2; pl1 = pl2; pb2 = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i+1))); if ( pb2 == 0 ) break; pg2 = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i+1))); if ( pg2 == 0 ) break; pl2 = static_cast<CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i+1))); if ( pl2 == 0 ) break; pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE)); pg1->SetIcon(pg2->GetIcon()); pl1->SetName(pl2->GetName()); m_time[i] = m_time[i+1]; m_visitGoal[i] = m_visitGoal[i+1]; m_visitDist[i] = m_visitDist[i+1]; m_visitHeight[i] = m_visitHeight[i+1]; // shift } pw->DeleteControl(EventType(EVENT_DT_VISIT0+i)); pw->DeleteControl(EventType(EVENT_DT_GROUP0+i)); pw->DeleteControl(EventType(EVENT_DT_LABEL0+i)); m_bExist[i] = false; return true; }
#include "ActorId.hpp" #include "TransactionFailEvent.hpp" #include "EventType.hpp" /* Initialize the event type of ActorMovedEvent using the address of the * event_type static member variable */ const EventType TransactionFailEvent::event_type = EventType(&TransactionFailEvent::event_type); TransactionFailEvent::TransactionFailEvent() : EventInterface(), ship_id(0), port_id(0), ship_gold(0), ship_rum(0), port_rum(0), fail_reason(BUY_EXCEEDS_MAX_SHIP_INVENTORY) { } TransactionFailEvent::TransactionFailEvent(ActorId ship_id, ActorId port_id, unsigned int ship_gold, unsigned int ship_rum, unsigned int port_rum, FailReason fail_reason) : EventInterface(), ship_id(ship_id), port_id(port_id), ship_gold(ship_gold), ship_rum(ship_rum),
int RegisterEvent(const char *name, TimedCallback callback) { event_types.push_back(EventType(callback, name)); return (int)event_types.size() - 1; }
{ event_types.push_back(EventType(callback, name)); return (int)event_types.size() - 1; } void AntiCrashCallback(u64 userdata, int cyclesLate) { ERROR_LOG(TIME, "Savestate broken: an unregistered event was called."); Core_Halt("invalid timing events"); } void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback) { _assert_msg_(CORETIMING, event_type >= 0, "Invalid event type %d", event_type) if (event_type >= (int) event_types.size()) event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT")); event_types[event_type] = EventType(callback, name); } void UnregisterAllEvents() { if (first) PanicAlert("Cannot unregister events with events pending"); event_types.clear(); } void Init() { currentMIPS->downcount = INITIAL_SLICE_LENGTH; slicelength = INITIAL_SLICE_LENGTH;
namespace KJSEmbed { JSEventMapper *JSEventMapper::m_inst = 0; /** Used internally for the event handler table. */ struct EventType { EventType( KJS::Identifier _id, QEvent::Type _type ) : id(_id), type(_type) {;} const KJS::Identifier id; const QEvent::Type type; }; /* Qt4 events as of Qt 4.0 None = 0, // invalid event Timer = 1, // timer event MouseButtonPress = 2, // mouse button pressed MouseButtonRelease = 3, // mouse button released MouseButtonDblClick = 4, // mouse button double click MouseMove = 5, // mouse move KeyPress = 6, // key pressed KeyRelease = 7, // key released FocusIn = 8, // keyboard focus received FocusOut = 9, // keyboard focus lost Enter = 10, // mouse enters widget Leave = 11, // mouse leaves widget Paint = 12, // paint widget Move = 13, // move widget Resize = 14, // resize widget Create = 15, // after widget creation Destroy = 16, // during widget destruction Show = 17, // widget is shown Hide = 18, // widget is hidden Close = 19, // request to close widget Quit = 20, // request to quit application ParentChange = 21, // widget has been reparented ParentAboutToChange = 131, // sent just before the parent change is done ThreadChange = 22, // object has changed threads WindowActivate = 24, // window was activated WindowDeactivate = 25, // window was deactivated ShowToParent = 26, // widget is shown to parent HideToParent = 27, // widget is hidden to parent Wheel = 31, // wheel event WindowTitleChange = 33, // window title changed WindowIconChange = 34, // icon changed ApplicationWindowIconChange = 35, // application icon changed ApplicationFontChange = 36, // application font changed ApplicationLayoutDirectionChange = 37, // application layout direction changed ApplicationPaletteChange = 38, // application palette changed PaletteChange = 39, // widget palette changed Clipboard = 40, // internal clipboard event Speech = 42, // reserved for speech input MetaCall = 43, // meta call event SockAct = 50, // socket activation WinEventAct = 123, // win event activation DeferredDelete = 52, // deferred delete event DragEnter = 60, // drag moves into widget DragMove = 61, // drag moves in widget DragLeave = 62, // drag leaves or is canceled Drop = 63, // actual drop DragResponse = 64, // drag accepted/rejected ChildAdded = 68, // new child widget ChildPolished = 69, // polished child widget ChildRemoved = 71, // deleted child widget ShowWindowRequest = 73, // widget's window should be mapped PolishRequest = 74, // widget should be polished Polish = 75, // widget is polished LayoutRequest = 76, // widget should be relayouted UpdateRequest = 77, // widget should be repainted EmbeddingControl = 79, // ActiveX embedding ActivateControl = 80, // ActiveX activation DeactivateControl = 81, // ActiveX deactivation ContextMenu = 82, // context popup menu InputMethod = 83, // input method AccessibilityPrepare = 86, // accessibility information is requested TabletMove = 87, // Wacom tablet event LocaleChange = 88, // the system locale changed LanguageChange = 89, // the application language changed LayoutDirectionChange = 90, // the layout direction changed Style = 91, // internal style event TabletPress = 92, // tablet press TabletRelease = 93, // tablet release OkRequest = 94, // CE (Ok) button pressed HelpRequest = 95, // CE (?) button pressed IconDrag = 96, // proxy icon dragged FontChange = 97, // font has changed EnabledChange = 98, // enabled state has changed ActivationChange = 99, // window activation has changed StyleChange = 100, // style has changed IconTextChange = 101, // icon text has changed ModifiedChange = 102, // modified state has changed MouseTrackingChange = 109, // mouse tracking state has changed WindowBlocked = 103, // window is about to be blocked modally WindowUnblocked = 104, // windows modal blocking has ended WindowStateChange = 105, ToolTip = 110, WhatsThis = 111, StatusTip = 112, ActionChanged = 113, ActionAdded = 114, ActionRemoved = 115, FileOpen = 116, // file open request Shortcut = 117, // shortcut triggered ShortcutOverride = 51, // shortcut override request WhatsThisClicked = 118, ToolBarChange = 120, // toolbar visibility toggled ApplicationActivated = 121, // application has been changed to active ApplicationDeactivated = 122, // application has been changed to inactive QueryWhatsThis = 123, // query what's this widget help EnterWhatsThisMode = 124, LeaveWhatsThisMode = 125, ZOrderChange = 126, // child widget has had its z-order changed HoverEnter = 127, // mouse cursor enters a hover widget HoverLeave = 128, // mouse cursor leaves a hover widget HoverMove = 129, // mouse cursor move inside a hover widget AccessibilityHelp = 119, // accessibility help text request AccessibilityDescription = 130 */ static EventType events[] = { EventType( KJS::Identifier("onTimerEvent"), QEvent::Timer ), EventType( KJS::Identifier("onMouseButtonPressEvent"), QEvent::MouseButtonPress ), EventType( KJS::Identifier("onMouseButtonReleaseEvent"), QEvent::MouseButtonRelease ), EventType( KJS::Identifier("onMouseButtonDblClickEvent"), QEvent::MouseButtonDblClick ), EventType( KJS::Identifier("onMouseMoveEvent"), QEvent::MouseMove ), EventType( KJS::Identifier("onKeyPressEvent"), QEvent::KeyPress ), EventType( KJS::Identifier("onKeyReleaseEvent"), QEvent::KeyRelease ), EventType( KJS::Identifier("onFocusInEvent"), QEvent::FocusIn ), EventType( KJS::Identifier("onFocusOutEvent"), QEvent::FocusOut ), EventType( KJS::Identifier("onEnterEvent"), QEvent::Enter ), EventType( KJS::Identifier("onLeaveEvent"), QEvent::Leave ), EventType( KJS::Identifier("onPaintEvent"), QEvent::Paint ), EventType( KJS::Identifier("onMoveEvent"), QEvent::Move ), EventType( KJS::Identifier("onResizeEvent"), QEvent::Resize ), EventType( KJS::Identifier("onCreateEvent"), QEvent::Create ), EventType( KJS::Identifier("onDestroyEvent"), QEvent::Destroy ), EventType( KJS::Identifier("onShowEvent"), QEvent::Show ), EventType( KJS::Identifier("onHideEvent"), QEvent::Hide ), EventType( KJS::Identifier("onCloseEvent"), QEvent::Close ), EventType( KJS::Identifier("onQuitEvent"), QEvent::Quit ), EventType( KJS::Identifier("onParentChangeEvent"), QEvent::ParentChange ), EventType( KJS::Identifier("onParentAboutToChangeEvent"), QEvent::ParentAboutToChange ), EventType( KJS::Identifier("onThreadChangeEvent"), QEvent::ThreadChange ), EventType( KJS::Identifier("onWindowActivateEvent"), QEvent::WindowActivate ), EventType( KJS::Identifier("onWindowDeactivateEvent"), QEvent::WindowDeactivate ), EventType( KJS::Identifier("onShowToParentEvent"), QEvent::ShowToParent ), EventType( KJS::Identifier("onHideToParentEvent"), QEvent::HideToParent ), EventType( KJS::Identifier("onWheelEvent"), QEvent::Wheel ), EventType( KJS::Identifier("onWindowTitleChangeEvent"), QEvent::WindowTitleChange ), EventType( KJS::Identifier("onWindowIconChangeEvent"), QEvent::WindowIconChange ), EventType( KJS::Identifier("onApplicationWindowIconChangeEvent"), QEvent::ApplicationWindowIconChange ), EventType( KJS::Identifier("onApplicationFontChangeEvent"), QEvent::ApplicationFontChange ), EventType( KJS::Identifier("onApplicationLayoutDirectionChangeEvent"), QEvent::ApplicationLayoutDirectionChange ), EventType( KJS::Identifier("onApplicationPaletteChangeEvent"), QEvent::ApplicationPaletteChange ), EventType( KJS::Identifier("onPaletteChangeEvent"), QEvent::PaletteChange ), EventType( KJS::Identifier("onClipboardEvent"), QEvent::Clipboard ), EventType( KJS::Identifier("onSpeechEvent"), QEvent::Speech ), EventType( KJS::Identifier("onMetaCallEvent"), QEvent::MetaCall ), EventType( KJS::Identifier("onSockActEvent"), QEvent::SockAct ), EventType( KJS::Identifier("onWinEventActEvent"), QEvent::WinEventAct ), EventType( KJS::Identifier("onDeferredDeleteEvent"), QEvent::DeferredDelete ), EventType( KJS::Identifier("onDragEnterEvent"), QEvent::DragEnter ), EventType( KJS::Identifier("onDragMoveEvent"), QEvent::DragMove ), EventType( KJS::Identifier("onDragLeaveEvent"), QEvent::DragLeave ), EventType( KJS::Identifier("onDropEvent"), QEvent::Drop ), EventType( KJS::Identifier("onDragResponseEvent"), QEvent::DragResponse ), EventType( KJS::Identifier("onChildAddedEvent"), QEvent::ChildAdded ), EventType( KJS::Identifier("onChildPolishedEvent"), QEvent::ChildRemoved ), EventType( KJS::Identifier("onShowWindowRequestEvent"), QEvent::ShowWindowRequest ), EventType( KJS::Identifier("onPolishRequestEvent"), QEvent::PolishRequest ), EventType( KJS::Identifier("onPolishEvent"), QEvent::Polish ), EventType( KJS::Identifier("onLayoutRequestEvent"), QEvent::LayoutRequest ), EventType( KJS::Identifier("onUpdateRequestEvent"), QEvent::UpdateRequest ), EventType( KJS::Identifier("onEmbeddingControlEvent"), QEvent::EmbeddingControl ), EventType( KJS::Identifier("onActivateControlEvent"), QEvent::ActivateControl ), EventType( KJS::Identifier("onDeactivateControlEvent"), QEvent::DeactivateControl ), EventType( KJS::Identifier("onContextMenuEvent"), QEvent::ContextMenu ), EventType( KJS::Identifier("onInputMethodEvent"), QEvent::InputMethod ), EventType( KJS::Identifier("onAccessibilityPrepareEvent"), QEvent::AccessibilityPrepare ), EventType( KJS::Identifier("onTabletMoveEvent"), QEvent::TabletMove ), EventType( KJS::Identifier("onLocaleChangeEvent"), QEvent::LocaleChange ), EventType( KJS::Identifier("onLanguageChangeEvent"), QEvent::LanguageChange ), EventType( KJS::Identifier("onLayoutDirectionChangeEvent"), QEvent::LayoutDirectionChange ), EventType( KJS::Identifier("onStyleEvent"), QEvent::Style ), EventType( KJS::Identifier("onTabletPressEvent"), QEvent::TabletPress ), EventType( KJS::Identifier("onTabletReleaseEvent"), QEvent::TabletRelease ), EventType( KJS::Identifier("onOkRequestEvent"), QEvent::OkRequest ), EventType( KJS::Identifier("onHelpRequestEvent"), QEvent::HelpRequest ), EventType( KJS::Identifier("onIconDragEvent"), QEvent::IconDrag ), EventType( KJS::Identifier("onFontChangeEvent"), QEvent::FontChange ), EventType( KJS::Identifier("onEnabledChangeEvent"), QEvent::EnabledChange ), EventType( KJS::Identifier("onActivationChangeEvent"), QEvent::ActivationChange ), EventType( KJS::Identifier("onStyleChangeEvent"), QEvent::StyleChange ), EventType( KJS::Identifier("onIconTextChangeEvent"), QEvent::IconTextChange ), EventType( KJS::Identifier("onModifiedChangeEvent"), QEvent::ModifiedChange ), EventType( KJS::Identifier("onMouseTrackingChangeEvent"), QEvent::MouseTrackingChange ), EventType( KJS::Identifier("onWindowBlockedEvent"), QEvent::WindowBlocked ), EventType( KJS::Identifier("onWindowUnblockedEvent"), QEvent::WindowUnblocked ), EventType( KJS::Identifier("onWindowStateChangeEvent"), QEvent::WindowStateChange ), EventType( KJS::Identifier("onToolTipEvent"), QEvent::ToolTip ), EventType( KJS::Identifier("onWhatsThisEvent"), QEvent::WhatsThis ), EventType( KJS::Identifier("onStatusTipEvent"), QEvent::StatusTip ), EventType( KJS::Identifier("onActionChangedEvent"), QEvent::ActionChanged ), EventType( KJS::Identifier("onActionAddedEvent"), QEvent::ActionAdded ), EventType( KJS::Identifier("onActionRemovedEvent"), QEvent::ActionRemoved ), EventType( KJS::Identifier("onFileOpenEvent"), QEvent::FileOpen ), EventType( KJS::Identifier("onShortcutEvent"), QEvent::Shortcut ), EventType( KJS::Identifier("onShortcutOverrideEvent"), QEvent::ShortcutOverride ), EventType( KJS::Identifier("onWhatsThisClickedEvent"), QEvent::WhatsThisClicked ), EventType( KJS::Identifier("onToolBarChangeEvent"), QEvent::ToolBarChange ), EventType( KJS::Identifier("onApplicationActivatedEvent"), QEvent::ApplicationActivated ), EventType( KJS::Identifier("onApplicationDeactivatedEvent"), QEvent::ApplicationDeactivated ), EventType( KJS::Identifier("onQueryWhatsThisEvent"), QEvent::QueryWhatsThis ), EventType( KJS::Identifier("onEnterWhatsThisModeEvent"), QEvent::EnterWhatsThisMode ), EventType( KJS::Identifier("onLeaveWhatsThisModeEvent"), QEvent::LeaveWhatsThisMode ), EventType( KJS::Identifier("onZOrderChangeEvent"), QEvent::ZOrderChange ), EventType( KJS::Identifier("onHoverEnterEvent"), QEvent::HoverEnter ), EventType( KJS::Identifier("onHoverLeaveEvent"), QEvent::HoverLeave ), EventType( KJS::Identifier("onHoverMoveEvent"), QEvent::HoverMove ), EventType( KJS::Identifier("onAccessibilityHelpEvent"), QEvent::AccessibilityHelp ), EventType( KJS::Identifier("onAccessibilityDescriptionEvent"), QEvent::AccessibilityDescription ), EventType(KJS::Identifier(), QEvent::None ) }; JSEventMapper::JSEventMapper() { int i = 0; do { addEvent( events[i].id, events[i].type ); i++; } while( events[i].type != QEvent::None ); } JSEventMapper::~JSEventMapper() { } void JSEventMapper::addEvent( const KJS::Identifier &name, QEvent::Type t ) { m_handlerToEvent[ toQString(name) ] = t; m_eventToHandler[ t ] = name; } QEvent::Type JSEventMapper::findEventType( const KJS::Identifier &name ) const { return m_handlerToEvent[ toQString(name) ]; } bool JSEventMapper::isEventHandler( const KJS::Identifier &name ) const { return m_handlerToEvent.contains( toQString(name) ); } KJS::Identifier JSEventMapper::findEventHandler( QEvent::Type t ) const { return m_eventToHandler[t]; } JSEventMapper *JSEventMapper::mapper() { if ( m_inst ) return m_inst; m_inst = new JSEventMapper(); return m_inst; } } // namespace KJSEmbed
void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height, float dist, float time, TextType type) { CObject* toto; CMotion* motion; Ui::CWindow* pw; Ui::CButton* button; Ui::CGroup* group; Ui::CLabel* label; Math::Point pos, ppos, dim; Sound sound; float hLine, hBox; int nLine, icon, i; if ( !m_bEnable ) return; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw == 0 ) { pos.x = 0.0f; pos.y = 0.0f; dim.x = 0.0f; dim.y = 0.0f; pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW2); } hBox = 0.045f; hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE); nLine = 0; for ( i=0 ; i<MAXDTLINE ; i++ ) { group = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i))); if ( group == 0 ) break; nLine ++; } if ( nLine == MAXDTLINE ) { ClearLastText(); nLine --; } pos.x = 0.10f; pos.y = 0.92f-hBox-hBox*nLine; dim.x = 0.80f; dim.y = hBox; icon = 1; // yellow if ( type == TT_ERROR ) icon = 9; // red if ( type == TT_WARNING ) icon = 10; // blue if ( type == TT_INFO ) icon = 8; // green if ( type == TT_MESSAGE ) icon = 11; // yellow pw->CreateGroup(pos, dim, icon, EventType(EVENT_DT_GROUP0+nLine)); pw->SetTrashEvent(false); ppos = pos; ppos.y -= hLine/2.0f; label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text); if ( label != 0 ) { label->SetFontSize(FONTSIZE); } dim.x = dim.y*0.75f; pos.x -= dim.x; button = pw->CreateButton(pos, dim, 14, EventType(EVENT_DT_VISIT0+nLine)); if ( goal.x == 0.0f && goal.y == 0.0f && goal.z == 0.0f ) { button->ClearState(STATE_ENABLE); } m_bExist[nLine] = true; m_visitGoal[nLine] = goal; m_visitDist[nLine] = dist; m_visitHeight[nLine] = height; m_time[nLine] = time*m_delayFactor; toto = SearchToto(); if ( toto != 0 ) { motion = toto->GetMotion(); if ( motion != 0 ) { if ( type == TT_ERROR ) { motion->SetAction(MT_ERROR, 4.0f); } if ( type == TT_WARNING ) { motion->SetAction(MT_WARNING, 4.0f); } if ( type == TT_INFO ) { motion->SetAction(MT_INFO, 4.0f); } if ( type == TT_MESSAGE ) { motion->SetAction(MT_MESSAGE, 4.0f); } } } if ( m_bHide ) { HideText(m_bHide); // hide all } else { sound = SOUND_CLICK; if ( type == TT_ERROR ) sound = SOUND_ERROR; if ( type == TT_WARNING ) sound = SOUND_WARNING; if ( type == TT_INFO ) sound = SOUND_INFO; if ( type == TT_MESSAGE ) sound = SOUND_MESSAGE; if ( sound != SOUND_CLICK ) { m_sound->Play(sound); } } }