// // HandleEvent // // Passes events through to the user // U32 ICGrid::HandleEvent(Event &e) { if (e.type == Input::EventID()) { // Input events switch (e.subType) { case Input::MOUSEBUTTONDOWN: case Input::MOUSEBUTTONDBLCLK: { // Is the click inside the client area if (InClient(Point<S32>(e.input.mouseX, e.input.mouseY))) { // Ignore if we already have capture if (IFace::GetCapture() != this) { // Grab capture GetMouseCapture(); // Save mouse code captureCode = e.input.code; } } break; } case Input::MOUSEBUTTONUP: case Input::MOUSEBUTTONDBLCLKUP: { if (HasMouseCapture() && e.input.code == captureCode) { ReleaseMouseCapture(); // Get mouse position relative to client window Point<S32> p = ScreenToClient(Point<S32>(e.input.mouseX, e.input.mouseY)); // Calculate the (flipped) cell positions U32 x = xFlip ? gridSize.x - (p.x / cellSize.x) - 1 : p.x / cellSize.x; U32 y = yFlip ? gridSize.y - (p.y / cellSize.y) - 1 : p.y / cellSize.y; // Set currently selected if (x < gridSize.x && y < gridSize.y) { selected.Set(x, y); } if (captureCode == Input::LeftButtonCode()) { CallEventHandler(0x90E4DA5D); // "LeftClick" } else if (captureCode == Input::MidButtonCode()) { CallEventHandler(0x316EC946); // "MiddleClick" } else if (captureCode == Input::RightButtonCode()) { CallEventHandler(0x173F5F78); // "RightClick" } return (TRUE); } break; } } } // Allow parent class to process this event return IControl::HandleEvent(e); }
// // HandleEvent // // Pass any events to the registered handler // U32 Color::HandleEvent(Event &e) { if (e.type == ::Input::EventID()) { // Input events switch (e.subType) { case ::Input::MOUSEBUTTONDOWN: case ::Input::MOUSEBUTTONDBLCLK: { if (e.input.code == ::Input::LeftButtonCode()) { Point<S32> mouse(e.input.mouseX, e.input.mouseY); if (InClient(mouse)) { // Figure out which day (if any) was clicked on mouse = ScreenToClient(mouse); colorSelected->SetIntegerValue(mouse.x / GetSize().y); } } break; } } } else if (e.type == IFace::EventID()) { switch (e.subType) { case IFace::NOTIFY: { // Do specific handling switch (e.iface.p1) { case IControlNotify::Activating: { // Activate vars ActivateVar(colorCurrent); ActivateVar(colorSelected); break; } case IControlNotify::Deactivated: { // Deactivate vars colorCurrent->Deactivate(); colorSelected->Deactivate(); break; } case ContextMsg::SetTeam: { teamId = e.iface.p2; break; } case ContextMsg::ClearTeam: { teamId = U32_MAX; break; } } } } } return (IControl::HandleEvent(e)); }