void nsSystemTrayIconBase::DispatchEvent(const nsAString& aType,
                                         PRUint16 aButton, PRInt32 aDetail,
                                         bool aCtrlKey, bool aAltKey,
                                         bool aShiftKey, bool aMetaKey)
{
  nsresult rv;

  // first, create an event...
  nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mEventTarget, &rv));
  if (NS_FAILED(rv)) return;
  
  nsCOMPtr<nsIDOMDocument> doc;
  rv = node->GetOwnerDocument(getter_AddRefs(doc));
  if (NS_FAILED(rv)) return;
  
  nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc, &rv));
  if (NS_FAILED(rv)) return;
  
  nsCOMPtr<nsIDOMEvent> event;
  rv = docEvent->CreateEvent(NS_LITERAL_STRING("mouseevent"),
                             getter_AddRefs(event));
  if (NS_FAILED(rv)) return;
  
  nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(event, &rv));
  if (NS_FAILED(rv)) return;
  
  // get the view the event occurred on
  nsCOMPtr<nsIDOMDocumentView> documentView(do_QueryInterface(doc, &rv));
  if (NS_FAILED(rv)) return;
  
  nsCOMPtr<nsIDOMAbstractView> view;
  rv = documentView->GetDefaultView(getter_AddRefs(view));
  if (NS_FAILED(rv)) return;
  
  // figure out where to position the popup
  nsPoint position = GetPopupPosition();
  
  // initialize the event
  // TODO: give useful arguments here
  rv = mouseEvent->InitMouseEvent(aType,
                                  PR_FALSE, PR_TRUE, view, aDetail,
                                  position.x, position.y, position.x, position.y,
                                  aCtrlKey, aAltKey, aShiftKey, aMetaKey,
                                  aButton, nsnull);
  if (NS_FAILED(rv)) return;
  
  // and dispatch it. (yes, return value is ignored; we can't do anything)
  bool result;
  mEventTarget->DispatchEvent(event, &result);
}
Esempio n. 2
0
void CAppMenu::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
    target.draw(m_shape, states);
    target.draw(m_title, states);
    if (m_isOpen)
    {
        CTransformTranslateScope scope(states.transform, GetPopupPosition());
        target.draw(m_popup, states);
        for (const SAction &action : m_actions)
        {
            target.draw(*action.m_text, states);
        }
    }
}
Esempio n. 3
0
sf::FloatRect CAppMenu::GetPopupFrame() const
{
    sf::Vector2f pos = GetPopupPosition();
    sf::Vector2f size = GetPopupSize();
    return sf::FloatRect(pos.x, pos.y, size.x, size.y);
}