Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

IWidget.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "IWidget.h"
00010 
00011 #include "MouseStroke.h"
00012 
00013 //-----------------------------------------------------------------
00014 /**
00015  * Call own_mouseButton when stroke is inside own body.
00016  */
00017 void
00018 IWidget::mouseButton(const MouseStroke &stroke)
00019 {
00020     if (isInside(stroke.getLoc())) {
00021         own_mouseButton(stroke);
00022     }
00023 }
00024 //-----------------------------------------------------------------
00025 /**
00026  * Returns own_getTip when location is inside own body.
00027  */
00028 std::string
00029 IWidget::getTip(const V2 &loc)
00030 {
00031     std::string result;
00032     if (isInside(loc)) {
00033         result = own_getTip(loc);
00034     }
00035     return result;
00036 }
00037 //-----------------------------------------------------------------
00038 /**
00039  * Test whether location is inside this widget.
00040  * @param loc world location
00041  * @return true when location is inside widget body
00042  */
00043 bool
00044 IWidget::isInside(const V2 &loc)
00045 {
00046     V2 inside = loc.minus(m_shift);
00047     return (inside.getX() >= 0 && inside.getX() < getW()
00048         && inside.getY() >= 0 && inside.getY() < getH());
00049 }
00050 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2