本文整理汇总了C++中gcn::MouseEvent::getSource方法的典型用法代码示例。如果您正苦于以下问题:C++ MouseEvent::getSource方法的具体用法?C++ MouseEvent::getSource怎么用?C++ MouseEvent::getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcn::MouseEvent
的用法示例。
在下文中一共展示了MouseEvent::getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseClicked
void ChatBox::mouseClicked(gcn::MouseEvent& mouseEvent){
if( mouseEvent.isConsumed() ){ return; }
InfraellyWindow::mouseClicked(mouseEvent);
//click from the chat area
if( mouseEvent.getSource() == chatArea ){
chatArea->requestFocus();
typing = 0;
}
//click from the input field
if( mouseEvent.getSource() == inputField ){
typing = 1;
}
//if click was from send button
if( mouseEvent.getSource() == sendButton ){
// add the text from the text field into the chat area
push_back( inputField->getText(), DO_CALLBACK|PUT_USERNAME );
//clear off the text field
inputField->setText("");
//--------------------------
// play sound
//------------------------
}
}
示例2: mouseMoved
void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
{
Popup::mouseMoved(event);
const int x = event.getX();
const int y = event.getY();
if (event.getSource() == mXpBar)
{
mTextPopup->show(x + getX(), y + getY(),
strprintf("%u/%u", PlayerInfo::getAttribute(EXP),
PlayerInfo::getAttribute(EXP_NEEDED)),
strprintf("%s: %u", _("Need"),
PlayerInfo::getAttribute(EXP_NEEDED)
- PlayerInfo::getAttribute(EXP)));
}
else if (event.getSource() == mHpBar)
{
mTextPopup->show(x + getX(), y + getY(),
strprintf("%u/%u", PlayerInfo::getAttribute(HP),
PlayerInfo::getAttribute(MAX_HP)));
}
else if (event.getSource() == mMpBar)
{
mTextPopup->show(x + getX(), y + getY(),
strprintf("%u/%u", PlayerInfo::getAttribute(MP),
PlayerInfo::getAttribute(MAX_MP)));
}
else
{
mTextPopup->setVisible(false);
}
}
示例3: getResizeHandles
int Window::getResizeHandles(gcn::MouseEvent &event)
{
int resizeHandles = 0;
const int y = event.getY();
if (mGrip && y > (int) mTitleBarHeight)
{
const int x = event.getX();
if (!getChildrenArea().isPointInRect(x, y) &&
event.getSource() == this)
{
resizeHandles |= (x > getWidth() - resizeBorderWidth) ? RIGHT :
(x < resizeBorderWidth) ? LEFT : 0;
resizeHandles |= (y > getHeight() - resizeBorderWidth) ? BOTTOM :
(y < resizeBorderWidth) ? TOP : 0;
}
if (event.getSource() == mGrip)
{
mDragOffsetX = x;
mDragOffsetY = y;
resizeHandles |= BOTTOM | RIGHT;
}
}
return resizeHandles;
}
示例4: mouseClicked
void NpcDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mItemList &&
isDoubleClick(mItemList->getSelected()))
{
action(gcn::ActionEvent(mButton, mButton->getActionEventId()));
}
if (mouseEvent.getSource() == mTextBox && isDoubleClick((int)(long)mTextBox))
{
if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
action(gcn::ActionEvent(mButton, mButton->getActionEventId()));
}
}
示例5: mouseClicked
void LoginBox::mouseClicked(gcn::MouseEvent& mouseEvent){
if( mouseEvent.getSource() == doneButton ){
if( isAlphNum(usernameTextField->getText()) &&
isAlphNum(passwordTextField->getText()) )
{
infoReady = true;
} else {
infoReady = false;
}
} else
if( mouseEvent.getSource() == cancelButton ){
setVisible(false);
}
}
示例6: mousePressed
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
}
}
示例7: mouseClicked
void ItemMakerBox::mouseClicked(gcn::MouseEvent& mouseEvent){
if( mouseEvent.isConsumed() ){ return; };
// Save Button
if( mouseEvent.getSource() == saveBtn ){
mouseEvent.consume();
save( filenameFld->getText() );
} else
// Load Button
if( mouseEvent.getSource() == loadBtn ){
mouseEvent.consume();
load( filenameFld->getText() );
} else {
setCaption(caption_);
}
}
示例8: mouseClicked
void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
if (event.getButton() == gcn::MouseEvent::RIGHT &&
event.getSource() == mItems)
mItems->showPopupMenu(INVENTORY);
}
示例9: mouseMoved
// Show ItemTooltip
void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
{
if (event.getSource() == mItemIcon)
{
mItemPopup->setItem(mItem->getInfo());
mItemPopup->position(viewport->getMouseX(), viewport->getMouseY());
}
}
示例10: mouseClicked
void StorageWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
if (event.getButton() == gcn::MouseEvent::RIGHT &&
event.getSource() == mItems)
mItems->showPopupMenu(STORAGE);
}
示例11: mouseClicked
void BuyDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mShopItemList &&
isDoubleClick(mShopItemList->getSelected()))
{
action(gcn::ActionEvent(mBuyButton, mBuyButton->getActionEventId()));
}
}
示例12: mouseClicked
void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mServersList &&
isDoubleClick(mServersList->getSelected()))
{
action(gcn::ActionEvent(mConnectButton,
mConnectButton->getActionEventId()));
}
}
示例13: mouseClicked
void WorldSelectDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mWorldList &&
isDoubleClick(mWorldList->getSelected()))
{
action(gcn::ActionEvent(mChooseWorld,
mChooseWorld->getActionEventId()));
}
}
示例14: mousePressed
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;
}
}
}
示例15: mouseClicked
void Console::mouseClicked(gcn::MouseEvent& mouseEvent){
if( mouseEvent.isConsumed() ){ return; };
//click from the text area
if( mouseEvent.getSource() == textArea ){
inputField->requestFocus();
};
//if click was from send button
if( mouseEvent.getSource() == sendButton ){
// add the text from the text field into the text area
push_back( inputField->getText(), DO_CALLBACK|PUT_USERNAME);
//store command entered
lastCommand = inputField->getText();
//clear off the text field
inputField->setText("");
//--------------------------
// play sound
//------------------------
inputField->requestFocus();
}
}