void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) return; if (event.getButton() == gcn::MouseEvent::LEFT) { // Stores the selected item if theirs one. if (itemShortcut->isItemSelected() && inventoryWindow->isVisible()) { itemShortcut->setItem(index); itemShortcut->setItemSelected(-1); } else if (itemShortcut->getItem(index)) mItemClicked = true; } else if (event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = player_node->getInventory()-> findItem(itemShortcut->getItem(index)); if (!item) return; // Convert relative to the window coordinates to absolute screen // coordinates. viewport->showPopup(viewport->getMouseX(), viewport->getMouseY(), item); } }
void WorldEditor::mousePressed(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) { return; } if (mDrawingNewRoom) { mDrawingNewRoom = false; return; } if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) { if (mWorldPieces.find(mRoomSelector->getSelectedRoom()) == mWorldPieces.end()) { WorldPiece* worldPiece = new WorldPiece(mRoomSelector->getSelectedRoom()); mWorldPieces[mRoomSelector->getSelectedRoom()] = worldPiece; worldPiece->setPosition(mouseEvent.getX() - mouseEvent.getX() % 20, mouseEvent.getY() - mouseEvent.getY() % 15); worldPiece->addActionListener(this); add(worldPiece); } } else if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { if (!mNewRoomDialogWindow->isVisible() && getWidgetAt(mouseEvent.getX(), mouseEvent.getY()) == NULL) { mDrawingNewRoom = true; if (mouseEvent.getX() % 20 < 10) { mNewRoomX = mouseEvent.getX() - mouseEvent.getX() % 20; } else { mNewRoomX = mouseEvent.getX() - mouseEvent.getX() % 20 + 20; } if (mouseEvent.getY() % 15 < 8) { mNewRoomY = mouseEvent.getY() - mouseEvent.getY() % 15; } else { mNewRoomY = mouseEvent.getY() - mouseEvent.getY() % 15 + 15; } mNewRoomWidth = 0; mNewRoomHeight = 0; } } }
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) { Window::mousePressed(mouseEvent); if (!mEquipment) return; const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { if (mForing) return; // Checks if any of the presses were in the equip boxes. int i = 0; for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(), it_end = mBoxes.end(); it != it_end; ++ it, ++ i) { EquipmentBox *box = *it; if (!box) continue; Item *item = mEquipment->getEquipment(i); const gcn::Rectangle tRect(box->x, box->y, BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y) && item) setSelected(i); } } else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) { if (Item *item = getItem(x, y)) { if (mItemPopup) mItemPopup->setVisible(false); /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = x + getX(); const int my = y + getY(); if (viewport) { if (mForing) viewport->showUndressPopup(mx, my, mBeing, item); else viewport->showPopup(this, mx, my, item, true); } } } }
/* void GuildListBox::setSelected(int selected) { if (!mListModel) { mSelected = -1; } else { // Update mSelected with bounds checking mSelected = std::min(mListModel->getNumberOfElements() - 1, std::max(-1, selected)); gcn::Widget *parent; parent = (gcn::Widget*)getParent(); if (parent) { gcn::Rectangle scroll; scroll.y = (mSelected < 0) ? 0 : getFont()->getHeight() * mSelected; scroll.height = getFont()->getHeight(); parent->showWidgetPart(this, scroll); } } distributeValueChangedEvent(); } */ void GuildListBox::mousePressed(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { int y = event.getY(); setSelected(y / getFont()->getHeight()); distributeActionEvent(); } // TODO: Add guild functions, ie private messaging if (event.getButton() == gcn::MouseEvent::RIGHT) { // Show context menu } }
void Windowiki::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); const int x = event.getX(); const int y = event.getY(); mMouseResize = 0; // Activate resizing handles as appropriate if (event.getSource() == this && isResizable() && event.getButton() == gcn::MouseEvent::LEFT && !getChildrenArea().isPointInRect(x, y)) { mMouseResize |= (x > getWidth() - resizeBorderWidthiki) ? RIGHT : (x < resizeBorderWidthiki) ? LEFT : 0; mMouseResize |= (y > getHeight() - resizeBorderWidthiki) ? BOTTOM : (y < resizeBorderWidthiki) ? TOP : 0; } else if (event.getSource() == mGrip) { mDragOffsetX = x + mGrip->getX(); mDragOffsetY = y + mGrip->getY(); mMouseResize |= BOTTOM | RIGHT; mIsMoving = false; } if (event.getButton() == gcn::MouseEvent::LEFT) { const int x = event.getX(); const int y = event.getY(); // Handle close button if (mCloseButton) { gcn::Rectangle closeButtonRect( getWidth() - closeImage->getWidth() - getPadding(), getPadding(), closeImage->getWidth(), closeImage->getHeight()); if (closeButtonRect.isPointInRect(x, y)) { setVisible(false); } } // Handle window resizing } }
void OutfitWindow::mouseDragged(gcn::MouseEvent &event) { Window::mouseDragged(event); if (event.getButton() == gcn::MouseEvent::LEFT) { if (!mItemMoved && mItemClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) return; const int itemId = mItems[mCurrentOutfit][index]; if (itemId < 0) return; Item *item = PlayerInfo::getInventory()->findItem(itemId); if (item) { mItemMoved = item; mItems[mCurrentOutfit][index] = -1; } } if (mItemMoved) { mCursorPosX = event.getX(); mCursorPosY = event.getY(); } } }
void PlayControllerZone::mouseReleased( gcn::MouseEvent& mouseEvent ) { model().setMouse( "ZoneO", mouseEvent.getX(), mouseEvent.getY() ); // // Tenemos un area para seleccionar. adjustSelectedArea( mouseEvent.getX(), mouseEvent.getY() ); switch ( mouseEvent.getButton() ) { case gcn::MouseEvent::LEFT: view().setSelectedArea( m_selectarea ); break; case gcn::MouseEvent::RIGHT: view().setDestination( m_selectarea ); break; default: break; } mouseEvent.consume(); }
void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { if (itemShortcut->isItemSelected()) itemShortcut->setItemSelected(-1); const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { mItemMoved = NULL; return; } if (mItemMoved) { itemShortcut->setItems(index, mItemMoved->getId()); mItemMoved = NULL; } else if (itemShortcut->getItem(index) && mItemClicked) { itemShortcut->useItem(index); } if (mItemClicked) mItemClicked = false; } }
void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { if (!mItemMoved && mItemClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); const int itemId = itemShortcut->getItem(index); if (index == -1 || itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); if (item) { mItemMoved = item; itemShortcut->removeItem(index); } } if (mItemMoved) { mCursorPosX = event.getX(); mCursorPosY = event.getY(); } } }
void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (emoteShortcut->isEmoteSelected()) emoteShortcut->setEmoteSelected(0); if (index == -1) { mEmoteMoved = 0; return; } if (mEmoteMoved) { emoteShortcut->setEmotes(index, mEmoteMoved); mEmoteMoved = 0; } else if (emoteShortcut->getEmote(index) && mEmoteClicked) { emoteShortcut->useEmote(index + 1); } if (mEmoteClicked) mEmoteClicked = false; } }
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) { Window::mousePressed(mouseEvent); const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); Item *item = 0; // Checks if any of the presses were in the equip boxes. for (int i = 0; i < mBoxesNumber; ++i) { item = mEquipment->getEquipment(i); gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y) && item) { setSelected(i); break; } } if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) { if (item) { /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = x + getX(); const int my = y + getY(); viewport->showPopup(this, mx, my, item, true, false); } } }
void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); if (event.getButton() == gcn::MouseEvent::LEFT) { const int x = event.getX(); const int y = event.getY(); // Handle close button if (mCloseButton) { gcn::Rectangle closeButtonRect( getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), getPadding(), mSkin->getCloseImage()->getWidth(), mSkin->getCloseImage()->getHeight()); if (closeButtonRect.isPointInRect(x, y)) close(); } // Handle window resizing mouseResize = getResizeHandles(event); } }
void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { if (!mEmoteMoved && mEmoteClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) return; const int emoteId = emoteShortcut->getEmote(index); if (emoteId) { mEmoteMoved = emoteId; emoteShortcut->removeEmote(index); } } if (mEmoteMoved) { mCursorPosX = event.getX(); mCursorPosY = event.getY(); } } }
void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); if (event.getButton() == gcn::MouseEvent::RIGHT && event.getSource() == mItems) mItems->showPopupMenu(INVENTORY); }
void LayerPanel::mouseClicked(gcn::MouseEvent& me) { gcn::Widget *src = me.getSource(); // poll the buttons for a click for(uint32 i = 0; i < LAYER_MAX; i++) { if(src == btnLayers[i]) { if(me.getButton() == gcn::MouseEvent::LEFT) _engine->GetDrawPanel()->SetActiveLayer(i); else if(me.getButton() == gcn::MouseEvent::RIGHT) _engine->ToggleLayerVisible(i); return; } } }
void StorageWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); if (event.getButton() == gcn::MouseEvent::RIGHT && event.getSource() == mItems) mItems->showPopupMenu(STORAGE); }
void ListBox::mouseDragged(gcn::MouseEvent &event) { if (event.getButton() != gcn::MouseEvent::LEFT) return; // Make list selection update on drag, but guard against negative y int y = std::max(0, event.getY()); setSelected(y / getRowHeight()); }
void GlassWidget::mousePressed(gcn::MouseEvent &e) { if(me) { PyObject *res = PyObject_CallMethod(me, "_mousePressed", "(iiii)", e.getType(), e.getButton(), e.getX(), e.getY()); if(res == NULL && PyErr_Occurred() != NULL) Py_HandleError(); else Py_XDECREF(res); } }
void ListBox::mouseClicked(gcn::MouseEvent &mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { setSelected(mouseEvent.getY() / getRowHeight()); if (mouseEvent.getClickCount() == 2) distributeActionEvent(); } }
void EmotePopup::mousePressed(gcn::MouseEvent &event) { if (event.getButton() != gcn::MouseEvent::LEFT) return; const int index = getIndexAt(event.getX(), event.getY()); if (index != -1) { setSelectedEmoteIndex(index); emoteShortcut->setEmoteSelected(index + 1); } }
void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getButton() != gcn::MouseEvent::LEFT) return; // Make table selection update on drag const int x = std::max(0, mouseEvent.getX()); const int y = std::max(0, mouseEvent.getY()); setSelectedRow(getRowForY(y)); setSelectedColumn(getColumnForX(x)); }
void ItemContainer::mousePressed(gcn::MouseEvent &event) { const int button = event.getButton(); if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) { Item *item = getItem(event.getX(), event.getY()); if (item) setSelectedItemIndex(item->getInvIndex()); } }
void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); if (event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = mItems->getSelectedItem(); if (!item) return; /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = event.getX() + getX(); const int my = event.getY() + getY(); viewport->showPopup(this, mx, my, item, isMainInventory()); } if (event.getButton() == gcn::MouseEvent::LEFT) { if (instances.size() > 1 && keyboard.isKeyActive(keyboard.KEY_EMOTE)) { Item *item = mItems->getSelectedItem(); if(!item) return; if (mInventory->isMainInventory()) Net::getInventoryHandler()->moveItem(Inventory::INVENTORY, item->getInvIndex(), item->getQuantity(), Inventory::STORAGE); else Net::getInventoryHandler()->moveItem(Inventory::STORAGE, item->getInvIndex(), item->getQuantity(), Inventory::INVENTORY); } } }
void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); if (event.getButton() == gcn::MouseEvent::LEFT) { // Handle window resizing mouseResize = getResizeHandles(event); if (event.getSource() == this) requestFocus(); } }
void SoundCfg::mousePressed(gcn::MouseEvent& mouseEvent) { bool comp_has_mouse = false; if ( mouseEvent.getSource() == &mDescriptionBox ) comp_has_mouse = true; if ((comp_has_mouse == true) && mouseEvent.getButton() == gcn::MouseInput::LEFT) { mSettingsDirty = true; } gcn::Window::mousePressed ( mouseEvent ); }
void DropDown::mousePressed(gcn::MouseEvent& mouseEvent) { gcn::DropDown::mousePressed(mouseEvent); if (0 <= mouseEvent.getY() && mouseEvent.getY() < getHeight() && mouseEvent.getX() >= 0 && mouseEvent.getX() < getWidth() && mouseEvent.getButton() == gcn::MouseEvent::LEFT && mDroppedDown && mouseEvent.getSource() == mListBox) { mPushed = false; foldUp(); releaseModalMouseInputFocus(); distributeActionEvent(); } }
void ItemContainer::mousePressed(gcn::MouseEvent &event) { if (!mInventory) return; const int button = event.getButton(); mClicks = event.getClickCount(); if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) { const int index = getSlotIndex(event.getX(), event.getY()); if (index == Inventory::NO_SLOT_INDEX) return; Item *item = mInventory->getItem(index); // put item name into chat window if (item && mDescItems && chatWindow) chatWindow->addItemText(item->getInfo().getName()); if (mSelectedIndex == index && mClicks != 2) { mSelectionStatus = SEL_DESELECTING; } else if (item && item->getId()) { setSelectedIndex(index); mSelectionStatus = SEL_SELECTING; int num = itemShortcutWindow->getTabIndex(); if (num >= 0 && num < SHORTCUT_TABS) { if (itemShortcut[num]) itemShortcut[num]->setItemSelected(item); } if (dropShortcut) dropShortcut->setItemSelected(item); if (item->isEquipment() && outfitWindow) outfitWindow->setItemSelected(item); if (shopWindow) shopWindow->setItemSelected(item->getId()); } else { selectNone(); } } }
// -- MouseListener notifications void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); if (row > -1 && column > -1 && row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; } distributeActionEvent(); } }
void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) { if (mouseEvent.isConsumed()) return; if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); if (tab) { setSelectedTab(tab); requestFocus(); } } }
void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); if (event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = mItems->getSelectedItem(); if (!item) return; /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = event.getX() + getX(); const int my = event.getY() + getY(); viewport->showPopup(mx, my, item); } }